Skip to content

Instantly share code, notes, and snippets.

@tristen
Created January 19, 2022 19:47
Show Gist options
  • Save tristen/473fb1137bf54c54e140d193d71b14be to your computer and use it in GitHub Desktop.
Save tristen/473fb1137bf54c54e140d193d71b14be to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).mapboxgl=t()}(this,function(){"use strict";var e,t,i;function r(r,n){if(e)if(t){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s),i=n(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=n;else e=n}return r(0,function(e){var t="2.7.0-dev",i=r;function r(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=r,this.p2x=i,this.p2y=r}r.prototype.sampleCurveX=function(e){return((this.ax*e+this.bx)*e+this.cx)*e},r.prototype.sampleCurveY=function(e){return((this.ay*e+this.by)*e+this.cy)*e},r.prototype.sampleCurveDerivativeX=function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},r.prototype.solveCurveX=function(e,t){var i,r,n,o,s;for(void 0===t&&(t=1e-6),n=e,s=0;s<8;s++){if(o=this.sampleCurveX(n)-e,Math.abs(o)<t)return n;var a=this.sampleCurveDerivativeX(n);if(Math.abs(a)<1e-6)break;n-=o/a}if((n=e)<(i=0))return i;if(n>(r=1))return r;for(;i<r;){if(o=this.sampleCurveX(n),Math.abs(o-e)<t)return n;e>o?i=n:r=n,n=.5*(r-i)+i}return n},r.prototype.solve=function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))};var n=o;function o(e,t){this.x=e,this.y=t}o.prototype={clone:function(){return new o(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,i=e.y-this.y;return t*t+i*i},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[0]*this.x+e[1]*this.y,i=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=i,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),i=Math.sin(e),r=t*this.x-i*this.y,n=i*this.x+t*this.y;return this.x=r,this.y=n,this},_rotateAround:function(e,t){var i=Math.cos(e),r=Math.sin(e),n=t.x+i*(this.x-t.x)-r*(this.y-t.y),o=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=n,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},o.convert=function(e){return e instanceof o?e:Array.isArray(e)?new o(e[0],e[1]):e};var s="undefined"!=typeof self?self:{},a=1e-6,l="undefined"!=typeof Float32Array?Float32Array:Array;function c(){var e=new l(9);return l!=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 h(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 u(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],m=t[12],_=t[13],g=t[14],y=t[15],x=i[0],v=i[1],b=i[2],w=i[3];return e[0]=x*r+v*a+b*u+w*m,e[1]=x*n+v*l+b*d+w*_,e[2]=x*o+v*c+b*p+w*g,e[3]=x*s+v*h+b*f+w*y,x=i[4],v=i[5],b=i[6],w=i[7],e[4]=x*r+v*a+b*u+w*m,e[5]=x*n+v*l+b*d+w*_,e[6]=x*o+v*c+b*p+w*g,e[7]=x*s+v*h+b*f+w*y,x=i[8],v=i[9],b=i[10],w=i[11],e[8]=x*r+v*a+b*u+w*m,e[9]=x*n+v*l+b*d+w*_,e[10]=x*o+v*c+b*p+w*g,e[11]=x*s+v*h+b*f+w*y,x=i[12],v=i[13],b=i[14],w=i[15],e[12]=x*r+v*a+b*u+w*m,e[13]=x*n+v*l+b*d+w*_,e[14]=x*o+v*c+b*p+w*g,e[15]=x*s+v*h+b*f+w*y,e}function d(e,t,i){var r,n,o,s,a,l,c,h,u,d,p,f,m=i[0],_=i[1],g=i[2];return t===e?(e[12]=t[0]*m+t[4]*_+t[8]*g+t[12],e[13]=t[1]*m+t[5]*_+t[9]*g+t[13],e[14]=t[2]*m+t[6]*_+t[10]*g+t[14],e[15]=t[3]*m+t[7]*_+t[11]*g+t[15]):(r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=t[9],p=t[10],f=t[11],e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=h,e[8]=u,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*_+u*g+t[12],e[13]=n*m+l*_+d*g+t[13],e[14]=o*m+c*_+p*g+t[14],e[15]=s*m+h*_+f*g+t[15]),e}function p(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function f(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],h=t[9],u=t[10],d=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]=o*n+c*r,e[5]=s*n+h*r,e[6]=a*n+u*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=h*n-s*r,e[10]=u*n-a*r,e[11]=d*n-l*r,e}function m(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],h=t[9],u=t[10],d=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]=o*n-c*r,e[1]=s*n-h*r,e[2]=a*n-u*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+h*n,e[10]=a*r+u*n,e[11]=l*r+d*n,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var _=u;function g(){var e=new l(3);return l!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function y(e){var t=new l(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function x(e){var t=e[0],i=e[1],r=e[2];return Math.hypot(t,i,r)}function v(e,t,i){var r=new l(3);return r[0]=e,r[1]=t,r[2]=i,r}function b(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e}function w(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e}function T(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e}function E(e,t,i){return e[0]=Math.max(t[0],i[0]),e[1]=Math.max(t[1],i[1]),e[2]=Math.max(t[2],i[2]),e}function S(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function I(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e}function M(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function A(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function C(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e}function z(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return s=s||1,e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/s,e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e}function k(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],h=n*c-o*l,u=o*a-r*c,d=r*l-n*a,p=n*d-o*u,f=o*h-r*d,m=r*u-n*h,_=2*s;return h*=_,u*=_,d*=_,p*=2,f*=2,m*=2,e[0]=a+h+p,e[1]=l+u+f,e[2]=c+d+m,e}var P=w,D=T,L=function(e,t,i){return e[0]=t[0]/i[0],e[1]=t[1]/i[1],e[2]=t[2]/i[2],e},B=x;function R(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e}function F(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e}g();var O=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e};function U(){var e=new l(4);return l!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function V(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function N(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e}!function(){var e,t=(e=new l(4),l!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var j=function(e){var t=e[0],i=e[1],r=e[2],n=e[3];return Math.hypot(t,i,r,n)},G=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},Z=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]};function $(e,t){return e[0]===t[0]&&e[1]===t[1]}g(),v(1,0,0),v(0,1,0),U(),U(),c(),function(){var e,t=(e=new l(2),l!=Float32Array&&(e[0]=0,e[1]=0),e)}();const q=Math.PI/180,X=180/Math.PI;function W(e){return e*q}function H(e){return e*X}const K=[[0,0],[1,0],[1,1],[0,1]];function J(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Y(e,t,r,n){const o=new i(e,t,r,n);return function(e){return o.solve(e)}}const Q=Y(.25,.1,.25,1);function ee(e,t,i){return Math.min(i,Math.max(t,e))}function te(e,t,i){return(i=ee((i-e)/(t-e),0,1))*i*(3-2*i)}function ie(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function re(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach((e,s)=>{t(e,(e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n)})})}function ne(e){const t=[];for(const i in e)t.push(e[i]);return t}function oe(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let se=1;function ae(){return se++}function le(){return function e(t){return t?(t^16*Math.random()>>t/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function ce(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function he(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 ue(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function de(e,t){return-1!==e.indexOf(t,e.length-t.length)}function pe(e,t,i){const r={};for(const n in e)r[n]=t.call(i||this,e[n],n,e);return r}function fe(e,t,i){const r={};for(const n in e)t.call(i||this,e[n],n,e)&&(r[n]=e[n]);return r}function me(e){return Array.isArray(e)?e.map(me):"object"==typeof e&&e?pe(e,me):e}const _e={};function ge(e){_e[e]||("undefined"!=typeof console&&console.warn(e),_e[e]=!0)}function ye(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function xe(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n<o;s=n++)i=e[n],t+=((r=e[s]).x-i.x)*(i.y+r.y);return t}function ve(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function be(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let we,Te,Ee,Se=null;function Ie(e){if(null==Se){const t=e.navigator?e.navigator.userAgent:null;Se=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Se}function Me(e){try{const t=s[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Ae(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const Ce={now:()=>void 0!==Ee?Ee:s.performance.now(),setNow(e){Ee=e},restoreNow(){Ee=void 0},frame(e){const t=s.requestAnimationFrame(e);return{cancel:()=>s.cancelAnimationFrame(t)}},getImageData(e,t=0){const i=s.document.createElement("canvas"),r=i.getContext("2d");if(!r)throw new Error("failed to create canvas 2d context");return i.width=e.width,i.height=e.height,r.drawImage(e,0,0,e.width,e.height),r.getImageData(-t,-t,e.width+2*t,e.height+2*t)},resolveURL:e=>(we||(we=s.document.createElement("a")),we.href=e,we.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==Te&&(Te=s.matchMedia("(prefers-reduced-motion: reduce)")),Te.matches)}};let ze;const ke={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==ze){const e=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{ze=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):e}catch(t){ze=e}}return ze},get EVENTS_URL(){return this.API_URL?0===this.API_URL.indexOf("https://api.mapbox.cn")?"https://events.mapbox.cn/events/v2":0===this.API_URL.indexOf("https://api.mapbox.com")?"https://events.mapbox.com/events/v2":null:null},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},Pe={supported:!1,testSupport:function(e){if(Be||!Le)return;Re?Fe(e):De=e}};let De,Le,Be=!1,Re=!1;function Fe(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,Le),e.isContextLost())return;Pe.supported=!0}catch(e){}e.deleteTexture(t),Be=!0}s.document&&((Le=s.document.createElement("img")).onload=function(){De&&Fe(De),De=null,Re=!0},Le.onerror=function(){Be=!0,De=null},Le.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Oe="01";const Ue="NO_ACCESS_TOKEN";function Ve(e){return 0===e.indexOf("mapbox:")}function Ne(e){return ke.API_URL_REGEX.test(e)}const je=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ge(e){const t=e.match(je);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 Ze(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const $e="mapbox.eventData";function qe(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse((i=t[1],decodeURIComponent(s.atob(i).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))))}catch(e){return null}var i}class Xe{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=qe(ke.ACCESS_TOKEN);let i="";var r;return t&&t.u?(r=t.u,i=s.btoa(encodeURIComponent(r).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))):i=ke.ACCESS_TOKEN||"",e?`${$e}.${e}:${i}`:`${$e}:${i}`}fetchEventData(){const e=Me("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{const e=s.localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const r=s.localStorage.getItem(i);r&&(this.anonId=r)}catch(e){ge("Unable to read from LocalStorage")}}saveEventData(){const e=Me("localStorage"),t=this.getStorageKey(),i=this.getStorageKey("uuid");if(e)try{s.localStorage.setItem(i,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){ge("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,i,r,n){if(!ke.EVENTS_URL)return;const o=Ge(ke.EVENTS_URL);o.params.push(`access_token=${n||ke.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(e).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:Oe,userId:this.anonId},a=i?oe(s,i):s,l={url:Ze(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=yt(l,e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(n)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const We=new class extends Xe{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){ke.EVENTS_URL&&ke.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>Ve(e)||Ne(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=qe(ke.ACCESS_TOKEN),i=t?t.u:ke.ACCESS_TOKEN;let r=i!==this.eventData.tokenU;he(this.anonId)||(this.anonId=le(),r=!0);const n=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(n),i=(n-this.eventData.lastSuccess)/864e5;r=r||i>=1||i<-1||e.getDate()!==t.getDate()}else r=!0;if(!r)return this.processRequests();this.postEvent(n,{"enabled.telemetry":!1},e=>{e||(this.eventData.lastSuccess=n,this.eventData.tokenU=i)},e)}},He=We.postTurnstileEvent.bind(We),Ke=new class extends Xe{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,i,r){this.skuToken=t,this.errorCb=r,ke.EVENTS_URL&&(i||ke.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Ue)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),he(this.anonId)||(this.anonId=le()),this.postEvent(i,{skuToken:this.skuToken},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}},Je=Ke.postMapLoadEvent.bind(Ke),Ye=new class extends Xe{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,i,r){if(!ke.API_URL||!ke.SESSION_PATH)return;const n=Ge(ke.API_URL+ke.SESSION_PATH);n.params.push(`sku=${t||""}`),n.params.push(`access_token=${r||ke.ACCESS_TOKEN||""}`);const o={url:Ze(n),headers:{"Content-Type":"text/plain"}};this.pendingRequest=xt(o,e=>{this.pendingRequest=null,i(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(e,t,i,r){this.skuToken=t,this.errorCb=r,ke.SESSION_PATH&&ke.API_URL&&(i||ke.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},i):this.errorCb(new Error(Ue)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}},Qe=Ye.getSessionAPI.bind(Ye),et=new Set;const tt="mapbox-tiles";let it=500,rt=50;const nt=42e4;let ot,st;function at(){s.caches&&!ot&&(ot=s.caches.open(tt))}function lt(e,t,i){if(at(),!ot)return;const r={status:t.status,statusText:t.statusText,headers:new s.Headers};t.headers.forEach((e,t)=>r.headers.set(t,e));const n=be(t.headers.get("Cache-Control")||"");n["no-store"]||(n["max-age"]&&r.headers.set("Expires",new Date(i+1e3*n["max-age"]).toUTCString()),new Date(r.headers.get("Expires")).getTime()-i<nt||function(e,t){if(void 0===st)try{new Response(new ReadableStream),st=!0}catch(e){st=!1}st?t(e.body):e.blob().then(t)}(t,t=>{const i=new s.Response(t,r);at(),ot&&ot.then(t=>t.put(ct(e.url),i)).catch(e=>ge(e.message))}))}function ct(e){const t=e.indexOf("?");return t<0?e:e.slice(0,t)}function ht(e,t){if(at(),!ot)return t(null);const i=ct(e.url);ot.then(e=>{e.match(i).then(r=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=be(e.headers.get("Cache-Control")||"");return t>Date.now()&&!i["no-cache"]}(r);e.delete(i),n&&e.put(i,r.clone()),t(null,r,n)}).catch(t)}).catch(t)}let ut=1/0;const dt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(dt);class pt extends Error{constructor(e,t,i){401===t&&Ne(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ft=ve()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href;function mt(e,t){const i=new s.AbortController,r=new s.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:ft(),signal:i.signal});let n=!1,o=!1;const a=(l=r.url).indexOf("sku=")>0&&Ne(l);var l;"json"===e.type&&r.headers.set("Accept","application/json");const c=(i,n,l)=>{if(o)return;if(i&&"SecurityError"!==i.message&&ge(i),n&&l)return h(n);const c=Date.now();s.fetch(r).then(i=>{if(i.ok){const e=a?i.clone():null;return h(i,e,c)}return t(new pt(i.statusText,i.status,e.url))}).catch(e=>{20!==e.code&&t(new Error(e.message))})},h=(i,s,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then(e=>{o||(s&&a&&lt(r,s,a),n=!0,t(null,e,i.headers.get("Cache-Control"),i.headers.get("Expires")))}).catch(e=>{o||t(new Error(e.message))})};return a?ht(r,c):c(null,null),{cancel:()=>{o=!0,n||i.abort()}}}const _t=function(e,t){if(!(e=>/^file:/.test(e)||/^file:/.test(ft())&&!/^\w+:/.test(e))(e.url)){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return mt(e,t);if(ve()&&self.worker&&self.worker.actor){const i=!0;return self.worker.actor.send("getResource",e,t,void 0,i)}}return function(e,t){const i=new s.XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=(()=>{t(new Error(i.statusText))}),i.onload=(()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===e.type)try{r=JSON.parse(i.response)}catch(e){return t(e)}t(null,r,i.getResponseHeader("Cache-Control"),i.getResponseHeader("Expires"))}else t(new pt(i.statusText,i.status,e.url))}),i.send(e.body),{cancel:()=>i.abort()}}(e,t)},gt=function(e,t){return _t(oe(e,{type:"arrayBuffer"}),t)},yt=function(e,t){return _t(oe(e,{method:"POST"}),t)},xt=function(e,t){return _t(oe(e,{method:"GET"}),t)};function vt(e){const t=s.document.createElement("a");return t.href=e,t.protocol===s.document.location.protocol&&t.host===s.document.location.host}const bt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let wt,Tt;wt=[],Tt=0;const Et=function(e,t){if(Pe.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Tt>=ke.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return wt.push(i),i}Tt++;let i=!1;const r=()=>{if(!i)for(i=!0,Tt--;wt.length&&Tt<ke.MAX_PARALLEL_IMAGE_REQUESTS;){const e=wt.shift(),{requestParameters:t,callback:i,cancelled:r}=e;r||(e.cancel=Et(t,i).cancel)}},n=gt(e,(e,i,n,o)=>{r(),e?t(e):i&&(s.createImageBitmap?function(e,t){const i=new s.Blob([new Uint8Array(e)],{type:"image/png"});s.createImageBitmap(i).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(i,(e,i)=>t(e,i,n,o)):function(e,t){const i=new s.Image,r=s.URL;i.onload=(()=>{t(null,i),r.revokeObjectURL(i.src),i.onload=null,s.requestAnimationFrame(()=>{i.src=bt})}),i.onerror=(()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.")));const n=new s.Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?r.createObjectURL(n):bt}(i,(e,i)=>t(e,i,n,o)))});return{cancel:()=>{n.cancel(),r()}}};function St(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function It(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class Mt{constructor(e,t={}){oe(this,t),this.type=e}}class At extends Mt{constructor(e,t={}){super("error",oe({error:e},t))}}class Ct{on(e,t){return this._listeners=this._listeners||{},St(e,t,this._listeners),this}off(e,t){return It(e,t,this._listeners),It(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},St(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new Mt(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)It(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(oe(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof At&&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 zt=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"}},"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},"horizon-blend":{"type":"number","property-type":"data-constant","default":0.1,"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}},"atmosphere":{"type":{"type":"enum","values":{"gradient":{}}},"gradient-inner-color":{"type":"color","default":"#ffffffff","requires":[{"type":"gradient"}]},"gradient-outer-color":{"type":"color","default":"#03befcff","requires":[{"type":"gradient"}]},"gradient-outer-radius":{"type":"number","default":"2","requires":[{"type":"gradient"}]}},"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","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"atmosphere":{"type":"atmosphere"}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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"}},"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":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-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"}},"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":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"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"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');class kt{constructor(e,t,i,r){this.message=(e?`${e}: `:"")+i,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Pt(e){const t=e.key,i=e.value;return i?[new kt(t,i,"constants have been deprecated as of v8")]:[]}function Dt(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}function Lt(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Bt(e){if(Array.isArray(e))return e.map(Bt);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Bt(e[i]);return t}return Lt(e)}class Rt extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class Ft{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new Ft(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(`${e} not found in scope.`)}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}const Ot={kind:"null"},Ut={kind:"number"},Vt={kind:"string"},Nt={kind:"boolean"},jt={kind:"color"},Gt={kind:"object"},Zt={kind:"value"},$t={kind:"collator"},qt={kind:"formatted"},Xt={kind:"resolvedImage"};function Wt(e,t){return{kind:"array",itemType:e,N:t}}function Ht(e){if("array"===e.kind){const t=Ht(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Kt=[Ot,Ut,Vt,Nt,jt,qt,Gt,Wt(Zt),Xt];function Jt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Jt(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 Kt)if(!Jt(e,t))return null}return`Expected ${Ht(e)} but found ${Ht(t)} instead.`}function Yt(e,t){return t.some(t=>t.kind===e.kind)}function Qt(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)}function ei(e){var t={exports:{}};return e(t,t.exports),t.exports}var ti=ei(function(e,t){var i={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function r(e){return(e=Math.round(e))<0?0:e>255?255:e}function n(e){return e<0?0:e>1?1:e}function o(e){return"%"===e[e.length-1]?r(parseFloat(e)/100*255):r(parseInt(e))}function s(e){return"%"===e[e.length-1]?n(parseFloat(e)/100):n(parseFloat(e))}function a(e,t,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?e+(t-e)*i*6:2*i<1?t:3*i<2?e+(t-e)*(2/3-i)*6:e}try{t.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in i)return i[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 l=n.indexOf("("),c=n.indexOf(")");if(-1!==l&&c+1===n.length){var h=n.substr(0,l),u=n.substr(l+1,c-(l+1)).split(","),d=1;switch(h){case"rgba":if(4!==u.length)return null;d=s(u.pop());case"rgb":return 3!==u.length?null:[o(u[0]),o(u[1]),o(u[2]),d];case"hsla":if(4!==u.length)return null;d=s(u.pop());case"hsl":if(3!==u.length)return null;var p=(parseFloat(u[0])%360+360)%360/360,f=s(u[1]),m=s(u[2]),_=m<=.5?m*(f+1):m+f-m*f,g=2*m-_;return[r(255*a(g,_,p+1/3)),r(255*a(g,_,p)),r(255*a(g,_,p-1/3)),d];default:return null}}return null}}catch(e){}});class ii{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof ii)return e;if("string"!=typeof e)return;const t=ti.parseCSSColor(e);return t?new ii(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,i,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*i/r,r]}}ii.black=new ii(0,0,0,1),ii.white=new ii(1,1,1,1),ii.transparent=new ii(0,0,0,0),ii.red=new ii(1,0,0,1),ii.blue=new ii(0,0,1,1);class ri{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,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 ni{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class oi{constructor(e){this.sections=e}static fromString(e){return new oi([new ni(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 oi?e:oi.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 i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class si{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new si({name:e,available:!1}):null}serialize(){return["image",this.name]}}function ai(e,t,i,r){if(!("number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255)){return`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}return void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`}function li(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 ii)return!0;if(e instanceof ri)return!0;if(e instanceof oi)return!0;if(e instanceof si)return!0;if(Array.isArray(e)){for(const t of e)if(!li(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!li(e[t]))return!1;return!0}return!1}function ci(e){if(null===e)return Ot;if("string"==typeof e)return Vt;if("boolean"==typeof e)return Nt;if("number"==typeof e)return Ut;if(e instanceof ii)return jt;if(e instanceof ri)return $t;if(e instanceof oi)return qt;if(e instanceof si)return Xt;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=ci(t);if(i){if(i===e)continue;i=Zt;break}i=e}return Wt(i||Zt,t)}return Gt}function hi(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof ii||e instanceof oi||e instanceof si?e.toString():JSON.stringify(e)}class ui{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 ${e.length-1} instead.`);if(!li(e[1]))return t.error("invalid value");const i=e[1];let r=ci(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new ui(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof ii?["rgba"].concat(this.value.toArray()):this.value instanceof oi?this.value.serialize():this.value}}class di{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const pi={string:Vt,number:Ut,boolean:Nt,object:Gt};class fi{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 i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in pi)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=pi[i],r++}else n=Zt;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);o=e[2],r++}i=Wt(n,o)}else i=pi[n];const o=[];for(;r<e.length;r++){const i=t.parse(e[r],r,Zt);if(!i)return null;o.push(i)}return new fi(i,o)}evaluate(e){for(let t=0;t<this.args.length;t++){const i=this.args[t].evaluate(e);if(!Jt(this.type,ci(i)))return i;if(t===this.args.length-1)throw new di(`Expected value to be of type ${Ht(this.type)}, but found ${Ht(ci(i))} instead.`)}return null}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const i=e.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){t.push(i.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}class mi{constructor(e){this.type=qt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&!(e=t.parse(o["font-scale"],1,Ut)))return null;let i=null;if(o["text-font"]&&!(i=t.parse(o["text-font"],1,Wt(Vt))))return null;let s=null;if(o["text-color"]&&!(s=t.parse(o["text-color"],1,jt)))return null;const a=r[r.length-1];a.scale=e,a.font=i,a.textColor=s}else{const o=t.parse(e[i],1,Zt);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new mi(r)}evaluate(e){return new oi(this.sections.map(t=>{const i=t.content.evaluate(e);return ci(i)===Xt?new ni("",i,null,null,null):new ni(hi(i),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 i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class _i{constructor(e){this.type=Xt,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Vt);return i?new _i(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=si.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const gi={"to-boolean":Nt,"to-color":jt,"to-number":Ut,"to-string":Vt};class yi{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 i=e[0];if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const r=gi[i],n=[];for(let i=1;i<e.length;i++){const r=t.parse(e[i],i,Zt);if(!r)return null;n.push(r)}return new yi(r,n)}evaluate(e){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(e));if("color"===this.type.kind){let t,i;for(const r of this.args){if(t=r.evaluate(e),i=null,t instanceof ii)return t;if("string"==typeof t){const i=e.parseColor(t);if(i)return i}else if(Array.isArray(t)&&!(i=t.length<3||t.length>4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:ai(t[0],t[1],t[2],t[3])))return new ii(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new di(i||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const i of this.args){if(null===(t=i.evaluate(e)))return 0;const r=Number(t);if(!isNaN(r))return r}throw new di(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?oi.fromString(hi(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?si.fromString(hi(this.args[0].evaluate(e))):hi(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 mi([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new _i(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const xi=["Unknown","Point","LineString","Polygon"];class vi{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&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?xi[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:i,y:r}=this.featureTileCoord,n=i*t-e[0],o=r*t-e[1];return this.featureDistanceData.bearing[0]*n+this.featureDistanceData.bearing[1]*o}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=ii.parse(e)),t}}class bi{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}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 i=e[0],r=bi.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[r,o]of s){a=new $i(t.registry,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t<e.length;t++){const i=e[t],n=Array.isArray(r)?r[t-1]:r.type,o=a.parse(i,1+s.length,n);if(!o){l=!0;break}s.push(o)}if(!l)if(Array.isArray(r)&&r.length!==s.length)a.error(`Expected ${r.length} arguments, but found ${s.length} instead.`);else{for(let e=0;e<s.length;e++){const t=Array.isArray(r)?r[e]:r.type,i=s[e];a.concat(e+1).checkSubtype(t,i.type)}if(0===a.errors.length)return new bi(i,n,o,s)}}if(1===s.length)t.errors.push(...a.errors);else{const i=(s.length?s:o).map(([e])=>(function(e){return Array.isArray(e)?`(${e.map(Ht).join(", ")})`:`(${Ht(e.type)}...)`})(e)).join(" | "),r=[];for(let i=1;i<e.length;i++){const n=t.parse(e[i],1+r.length);if(!n)return null;r.push(Ht(n.type))}t.error(`Expected arguments of type ${i}, but found (${r.join(", ")}) instead.`)}return null}static register(e,t){bi.definitions=t;for(const i in t)e[i]=bi}}class wi{constructor(e,t,i){this.type=$t,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Nt);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Nt);if(!n)return null;let o=null;return i.locale&&!(o=t.parse(i.locale,1,Vt))?null:new wi(r,n,o)}evaluate(e){return new ri(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}serialize(){const e={};return e["case-sensitive"]=this.caseSensitive.serialize(),e["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(e.locale=this.locale.serialize()),["collator",e]}}const Ti=8192;function Ei(e,t){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Si(e,t){return!(e[0]<=t[0])&&(!(e[2]>=t[2])&&(!(e[1]<=t[1])&&!(e[3]>=t[3])))}function Ii(e,t){const i=(180+e[0])/360;const r=(n=e[1],(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+n*Math.PI/360)))/360);var n;const o=Math.pow(2,t.z);return[Math.round(i*o*Ti),Math.round(r*o*Ti)]}function Mi(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Ai(e,t){let i=!1;for(let s=0,a=t.length;s<a;s++){const a=t[s];for(let t=0,s=a.length;t<s-1;t++){if(Mi(e,a[t],a[t+1]))return!1;r=e,n=a[t],o=a[t+1],n[1]>r[1]!=o[1]>r[1]&&r[0]<(o[0]-n[0])*(r[1]-n[1])/(o[1]-n[1])+n[0]&&(i=!i)}}var r,n,o;return i}function Ci(e,t){for(let i=0;i<t.length;i++)if(Ai(e,t[i]))return!0;return!1}function zi(e,t,i,r){const n=e[0]-i[0],o=e[1]-i[1],s=t[0]-i[0],a=t[1]-i[1],l=r[0]-i[0],c=r[1]-i[1],h=n*c-l*o,u=s*c-l*a;return h>0&&u<0||h<0&&u>0}function ki(e,t,i,r){const n=[t[0]-e[0],t[1]-e[1]],o=[r[0]-i[0],r[1]-i[1]];return 0!=(s=o)[0]*(a=n)[1]-s[1]*a[0]&&!(!zi(e,t,i,r)||!zi(i,r,e,t));var s,a}function Pi(e,t,i){for(const r of i)for(let i=0;i<r.length-1;++i)if(ki(e,t,r[i],r[i+1]))return!0;return!1}function Di(e,t){for(let i=0;i<e.length;++i)if(!Ai(e[i],t))return!1;for(let i=0;i<e.length-1;++i)if(Pi(e[i],e[i+1],t))return!1;return!0}function Li(e,t){for(let i=0;i<t.length;i++)if(Di(e,t[i]))return!0;return!1}function Bi(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=[];for(let r=0;r<e[n].length;r++){const s=Ii(e[n][r],i);Ei(t,s),o.push(s)}r.push(o)}return r}function Ri(e,t,i){const r=[];for(let n=0;n<e.length;n++){const o=Bi(e[n],t,i);r.push(o)}return r}function Fi(e,t,i,r){if(e[0]<i[0]||e[0]>i[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}Ei(t,e)}function Oi(e,t,i,r){const n=Math.pow(2,r.z)*Ti,o=[r.x*Ti,r.y*Ti],s=[];for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Fi(r,t,i,n),s.push(r)}return s}function Ui(e,t,i,r){const n=Math.pow(2,r.z)*Ti,o=[r.x*Ti,r.y*Ti],s=[];for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Ei(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Fi(r,t,i,n)}var a;return s}class Vi{constructor(e,t){this.type=Nt,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 ${e.length-1} instead.`);if(li(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e<t.features.length;++e){const i=t.features[e].geometry.type;if("Polygon"===i||"MultiPolygon"===i)return new Vi(t,t.features[e].geometry)}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Vi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Vi(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const o=Bi(t.coordinates,r,n),s=Oi(e.geometry(),i,r,n);if(!Si(i,r))return!1;for(const e of s)if(!Ai(e,o))return!1}if("MultiPolygon"===t.type){const o=Ri(t.coordinates,r,n),s=Oi(e.geometry(),i,r,n);if(!Si(i,r))return!1;for(const e of s)if(!Ci(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const o=Bi(t.coordinates,r,n),s=Ui(e.geometry(),i,r,n);if(!Si(i,r))return!1;for(const e of s)if(!Di(e,o))return!1}if("MultiPolygon"===t.type){const o=Ri(t.coordinates,r,n),s=Ui(e.geometry(),i,r,n);if(!Si(i,r))return!1;for(const e of s)if(!Li(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function Ni(e){if(e instanceof bi){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Vi)return!1;let t=!0;return e.eachChild(e=>{t&&!Ni(e)&&(t=!1)}),t}function ji(e){if(e instanceof bi&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!ji(e)&&(t=!1)}),t}function Gi(e,t){if(e instanceof bi&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Gi(e,t)&&(i=!1)}),i}class Zi{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 i=e[1];return t.scope.has(i)?new Zi(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class $i{constructor(e,t=[],i,r=new Ft,n=[]){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=n,this.expectedType=i}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new fi(t,[e]):"coerce"===i?new yi(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 r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"coerce");else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof ui)&&"resolvedImage"!==r.type.kind&&function e(t){if(t instanceof Zi)return e(t.boundExpression);if(t instanceof bi&&"error"===t.name)return!1;if(t instanceof wi)return!1;if(t instanceof Vi)return!1;const i=t instanceof yi||t instanceof fi;let r=!0;t.eachChild(t=>{r=i?r&&e(t):r&&t instanceof ui});if(!r)return!1;return Ni(t)&&Gi(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}(r)){const e=new vi;try{r=new ui(r.type,r.evaluate(e))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return void 0===e?this.error("'undefined' value invalid. Use null instead."):"object"==typeof e?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new $i(this.registry,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Rt(i,e))}checkSubtype(e,t){const i=Jt(e,t);return i&&this.error(i),i}}function qi(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(r=e[a=Math.floor((o+s)/2)],n=e[a+1],r<=t){if(a===i||t<n)return a;o=a+1}else{if(!(r>t))throw new di("Input is not a number.");s=a-1}return 0}class Xi{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,Ut);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i<e.length;i+=2){const o=1===i?-1/0:e[i],s=e[i+1],a=i,l=i+1;if("number"!=typeof o)return t.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(r.length&&r[r.length-1][0]>=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Xi(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[qi(t,r)].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;t<this.labels.length;t++)t>0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}function Wi(e,t,i){return e*(1-i)+t*i}var Hi=Object.freeze({__proto__:null,number:Wi,color:function(e,t,i){return new ii(Wi(e.r,t.r,i),Wi(e.g,t.g,i),Wi(e.b,t.b,i),Wi(e.a,t.a,i))},array:function(e,t,i){return e.map((e,r)=>Wi(e,t[r],i))}});const Ki=.95047,Ji=1,Yi=1.08883,Qi=4/29,er=6/29,tr=3*er*er,ir=er*er*er,rr=Math.PI/180,nr=180/Math.PI;function or(e){return e>ir?Math.pow(e,1/3):e/tr+Qi}function sr(e){return e>er?e*e*e:tr*(e-Qi)}function ar(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function lr(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function cr(e){const t=lr(e.r),i=lr(e.g),r=lr(e.b),n=or((.4124564*t+.3575761*i+.1804375*r)/Ki),o=or((.2126729*t+.7151522*i+.072175*r)/Ji);return{l:116*o-16,a:500*(n-o),b:200*(o-or((.0193339*t+.119192*i+.9503041*r)/Yi)),alpha:e.a}}function hr(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=Ji*sr(t),i=Ki*sr(i),r=Yi*sr(r),new ii(ar(3.2404542*i-1.5371385*t-.4985314*r),ar(-.969266*i+1.8760108*t+.041556*r),ar(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function ur(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const dr={forward:cr,reverse:hr,interpolate:function(e,t,i){return{l:Wi(e.l,t.l,i),a:Wi(e.a,t.a,i),b:Wi(e.b,t.b,i),alpha:Wi(e.alpha,t.alpha,i)}}},pr={forward:function(e){const{l:t,a:i,b:r}=cr(e),n=Math.atan2(r,i)*nr;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*rr,i=e.c;return hr({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:ur(e.h,t.h,i),c:Wi(e.c,t.c,i),l:Wi(e.l,t.l,i),alpha:Wi(e.alpha,t.alpha,i)}}};var fr=Object.freeze({__proto__:null,lab:dr,hcl:pr});class mr{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,r,n){let o=0;if("exponential"===e.name)o=_r(t,e.base,r,n);else if("linear"===e.name)o=_r(t,1,r,n);else if("cubic-bezier"===e.name){const s=e.controlPoints;o=new i(s[0],s[1],s[2],s[3]).solve(_r(t,1,r,n))}return o}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.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);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(!(n=t.parse(n,2,Ut)))return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=jt:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e<o.length;e+=2){const i=o[e],r=o[e+1],n=e+3,l=e+4;if("number"!=typeof i)return t.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(s.length&&s[s.length-1][0]>=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new mr(a,i,r,n,s):t.error(`Type ${Ht(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=qi(t,r),s=t[o],a=t[o+1],l=mr.interpolationFactor(this.interpolation,r,s,a),c=i[o].evaluate(e),h=i[o+1].evaluate(e);return"interpolate"===this.operator?Hi[this.type.kind.toLowerCase()](c,h,l):"interpolate-hcl"===this.operator?pr.reverse(pr.interpolate(pr.forward(c),pr.forward(h),l)):dr.reverse(dr.interpolate(dr.forward(c),dr.forward(h),l))}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 e=0;e<this.labels.length;e++)t.push(this.labels[e],this.outputs[e].serialize());return t}}function _r(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}class gr{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expectected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}const o=r&&n.some(e=>Jt(r,e.type));return new gr(o?Zt:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,(i=n.evaluate(e))&&i instanceof si&&!i.available&&(t||(t=i),i=null,r===this.args.length))return t;if(null!==i)break}return i}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}}class yr{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 ${e.length-1} instead.`);const i=[];for(let r=1;r<e.length-1;r+=2){const n=e[r];if("string"!=typeof n)return t.error(`Expected string, but found ${typeof n} instead.`,r);if(/[^a-zA-Z0-9_]/.test(n))return t.error("Variable names must contain only alphanumeric characters or '_'.",r);const o=t.parse(e[r+1],r+1);if(!o)return null;i.push([n,o])}const r=t.parse(e[e.length-1],e.length-1,t.expectedType,i);return r?new yr(i,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const e=["let"];for(const[t,i]of this.bindings)e.push(t,i.serialize());return e.push(this.result.serialize()),e}}class xr{constructor(e,t,i){this.type=e,this.index=t,this.input=i}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ut),r=t.parse(e[2],2,Wt(t.expectedType||Zt));if(!i||!r)return null;const n=r.type;return new xr(n.itemType,i,r)}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new di(`Array index out of bounds: ${t} < 0.`);if(t>=i.length)throw new di(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new di(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class vr{constructor(e,t){this.type=Nt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Zt),r=t.parse(e[2],2,Zt);return i&&r?Yt(i.type,[Nt,Vt,Ut,Ot,Zt])?new vr(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!Qt(t,["boolean","string","number","null"]))throw new di(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(ci(t))} instead.`);if(!Qt(i,["string","array"]))throw new di(`Expected second argument to be of type array or string, but found ${Ht(ci(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class br{constructor(e,t,i){this.type=Ut,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Zt),r=t.parse(e[2],2,Zt);if(!i||!r)return null;if(!Yt(i.type,[Nt,Vt,Ut,Ot,Zt]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ut);return n?new br(i,r,n):null}return new br(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Qt(t,["boolean","string","number","null"]))throw new di(`Expected first argument to be of type boolean, string, number or null, but found ${Ht(ci(t))} instead.`);if(!Qt(i,["string","array"]))throw new di(`Expected second argument to be of type array or string, but found ${Ht(ci(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.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()]}}class wr{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;s<e.length-1;s+=2){let a=e[s];const l=e[s+1];Array.isArray(a)||(a=[a]);const c=t.concat(s);if(0===a.length)return c.error("Expected at least one branch label.");for(const e of a){if("number"!=typeof e&&"string"!=typeof e)return c.error("Branch labels must be numbers or strings.");if("number"==typeof e&&Math.abs(e)>Number.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ci(e)))return null}else i=ci(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const h=t.parse(l,s,r);if(!h)return null;r=r||h.type,o.push(h)}const s=t.parse(e[1],1,Zt);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new wr(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(ci(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(),i=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)1===r.length?e.push(n(r[0])):e.push(r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class Tr{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;n<e.length-1;n+=2){const o=t.parse(e[n],n,Nt);if(!o)return null;const s=t.parse(e[n+1],n+1,i);if(!s)return null;r.push([o,s]),i=i||s.type}const n=t.parse(e[e.length-1],e.length-1,i);return n?new Tr(i,r,n):null}evaluate(e){for(const[t,i]of this.branches)if(t.evaluate(e))return i.evaluate(e);return this.otherwise.evaluate(e)}eachChild(e){for(const[t,i]of this.branches)e(t),e(i);e(this.otherwise)}outputDefined(){return this.branches.every(([e,t])=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class Er{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Zt),r=t.parse(e[2],2,Ut);if(!i||!r)return null;if(!Yt(i.type,[Wt(Zt),Vt,Zt]))return t.error(`Expected first argument to be of type array or string, but found ${Ht(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ut);return n?new Er(i.type,i,r,n):null}return new Er(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Qt(t,["string","array"]))throw new di(`Expected first argument to be of type array or string, but found ${Ht(ci(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}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()]}}function Sr(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 Ir(e,t,i,r){return 0===r.compare(t,i)}function Mr(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=Nt,this.lhs=e,this.rhs=t,this.collator=i,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 i=e[0];let o=t.parse(e[1],1,Zt);if(!o)return null;if(!Sr(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ht(o.type)}'.`);let s=t.parse(e[2],2,Zt);if(!s)return null;if(!Sr(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ht(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ht(o.type)}' and '${Ht(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new fi(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new fi(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(!(a=t.parse(e[3],3,$t)))return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=ci(o),i=ci(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new di(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=ci(o),i=ci(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}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 Ar=Mr("==",function(e,t,i){return t===i},Ir),Cr=Mr("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!Ir(0,t,i,r)}),zr=Mr("<",function(e,t,i){return t<i},function(e,t,i,r){return r.compare(t,i)<0}),kr=Mr(">",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),Pr=Mr("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0});class Dr{constructor(e,t,i,r,n){this.type=Vt,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ut);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&!(n=t.parse(r.locale,1,Vt)))return null;let o=null;if(r.currency&&!(o=t.parse(r.currency,1,Vt)))return null;let s=null;if(r["min-fraction-digits"]&&!(s=t.parse(r["min-fraction-digits"],1,Ut)))return null;let a=null;return r["max-fraction-digits"]&&!(a=t.parse(r["max-fraction-digits"],1,Ut))?null:new Dr(i,n,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.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.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Lr{constructor(e){this.type=Ut,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ht(i.type)} instead.`):new Lr(i):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 di(`Expected value to be of type string or array, but found ${Ht(ci(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const Br={"==":Ar,"!=":Cr,">":kr,"<":zr,">=":Mr(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0}),"<=":Pr,array:fi,at:xr,boolean:fi,case:Tr,coalesce:gr,collator:wi,format:mi,image:_i,in:vr,"index-of":br,interpolate:mr,"interpolate-hcl":mr,"interpolate-lab":mr,length:Lr,let:yr,literal:ui,match:wr,number:fi,"number-format":Dr,object:fi,slice:Er,step:Xi,string:fi,"to-boolean":yi,"to-color":yi,"to-number":yi,"to-string":yi,var:Zi,within:Vi};function Rr(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=ai(t,i,r,o);if(s)throw new di(s);return new ii(t/255*o,i/255*o,r/255*o,o)}function Fr(e,t){return e in t}function Or(e,t){const i=t[e];return void 0===i?null:i}function Ur(e){return{type:e}}function Vr(e){return{result:"success",value:e}}function Nr(e){return{result:"error",value:e}}function jr(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Zr(e){return!!e.expression&&e.expression.interpolated}function $r(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function qr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Xr(e){return e}function Wr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Hr(e,t,i,r,n){return Wr(typeof i===n?r[i]:void 0,e.default,t.default)}function Kr(e,t,i){if("number"!==$r(i))return Wr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=qi(e.stops.map(e=>e[0]),i);return e.stops[n][1]}function Jr(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==$r(i))return Wr(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=qi(e.stops.map(e=>e[0]),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=Hi[t.type]||Xr;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=fr[e.colorSpace];c=((e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s)))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function Yr(e,t,i){return"color"===t.type?i=ii.parse(i):"formatted"===t.type?i=oi.fromString(i.toString()):"resolvedImage"===t.type?i=si.fromString(i.toString()):$r(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Wr(i,e.default,t.default)}bi.register(Br,{error:[{kind:"error"},[Vt],(e,[t])=>{throw new di(t.evaluate(e))}],typeof:[Vt,[Zt],(e,[t])=>Ht(ci(t.evaluate(e)))],"to-rgba":[Wt(Ut,4),[jt],(e,[t])=>t.evaluate(e).toArray()],rgb:[jt,[Ut,Ut,Ut],Rr],rgba:[jt,[Ut,Ut,Ut,Ut],Rr],has:{type:Nt,overloads:[[[Vt],(e,[t])=>Fr(t.evaluate(e),e.properties())],[[Vt,Gt],(e,[t,i])=>Fr(t.evaluate(e),i.evaluate(e))]]},get:{type:Zt,overloads:[[[Vt],(e,[t])=>Or(t.evaluate(e),e.properties())],[[Vt,Gt],(e,[t,i])=>Or(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Zt,[Vt],(e,[t])=>Or(t.evaluate(e),e.featureState||{})],properties:[Gt,[],e=>e.properties()],"geometry-type":[Vt,[],e=>e.geometryType()],id:[Zt,[],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:[Zt,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ut,Ur(Ut),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Ut,Ur(Ut),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Ut,overloads:[[[Ut,Ut],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ut],(e,[t])=>-t.evaluate(e)]]},"/":[Ut,[Ut,Ut],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ut,[Ut,Ut],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ut,[],()=>Math.LN2],pi:[Ut,[],()=>Math.PI],e:[Ut,[],()=>Math.E],"^":[Ut,[Ut,Ut],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ut,[Ut],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ut,[Ut],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[Ut,[Ut],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ut,[Ut],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ut,[Ut],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ut,[Ut],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ut,[Ut],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ut,[Ut],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ut,Ur(Ut),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Ut,Ur(Ut),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Ut,[Ut],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ut,[Ut],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ut,[Ut],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ut,[Ut],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Nt,[Vt,Zt],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Nt,[Zt],(e,[t])=>e.id()===t.value],"filter-type-==":[Nt,[Vt],(e,[t])=>e.geometryType()===t.value],"filter-<":[Nt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Nt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<r}],"filter->":[Nt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Nt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Nt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Nt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Nt,[Vt,Zt],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Nt,[Zt],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Nt,[Zt],(e,[t])=>t.value in e.properties()],"filter-has-id":[Nt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Nt,[Wt(Vt)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Nt,[Wt(Zt)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Nt,[Vt,Wt(Zt)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Nt,[Vt,Wt(Zt)],(e,[t,i])=>(function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1})(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Nt,overloads:[[[Nt,Nt],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Ur(Nt),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Nt,overloads:[[[Nt,Nt],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Ur(Nt),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Nt,[Nt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Nt,[Vt],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[Vt,[Vt],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[Vt,[Vt],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[Vt,Ur(Zt),(e,t)=>t.map(t=>hi(t.evaluate(e))).join("")],"resolved-locale":[Vt,[$t],(e,[t])=>t.evaluate(e).resolvedLocale()]});class Qr{constructor(e,t){var i;this.expression=e,this._warningHistory={},this._evaluator=new vi,this._defaultValue=t?"color"===(i=t).type&&qr(i.default)?new ii(0,0,0,0):"color"===i.type?ii.parse(i.default)||null:void 0===i.default?null:i.default:null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,i,r,n,o,s,a){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o,s,a){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new di(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${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 en(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Br}function tn(e,t){const i=new $i(Br,[],t?function(e){const t={color:jt,string:Vt,number:Ut,enum:Vt,boolean:Nt,formatted:qt,resolvedImage:Xt};if("array"===e.type)return Wt(t[e.value]||Zt,e.length);return t[e.type]}(t):void 0),r=i.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Vr(new Qr(r,t)):Nr(i.errors)}class rn{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!ji(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}}class nn{constructor(e,t,i,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!ji(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?mr.interpolationFactor(this.interpolationType,e,t,i):0}}function on(e,t){if("error"===(e=tn(e,t)).result)return e;const i=e.value.expression,r=Ni(i);if(!r&&!jr(t))return Nr([new Rt("","data expressions not supported")]);const n=Gi(i,["zoom","pitch","distance-from-center"]);if(!n&&!Gr(t))return Nr([new Rt("","zoom expressions not supported")]);const o=function e(t){let i=null;if(t instanceof yr)i=e(t.result);else if(t instanceof gr){for(const r of t.args)if(i=e(r))break}else(t instanceof Xi||t instanceof mr)&&t.input instanceof bi&&"zoom"===t.input.name&&(i=t);if(i instanceof Rt)return i;t.eachChild(t=>{const r=e(t);r instanceof Rt?i=r:!i&&r?i=new Rt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):i&&r&&i!==r&&(i=new Rt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))});return i}(i);if(!o&&!n)return Nr([new Rt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(o instanceof Rt)return Nr([o]);if(o instanceof mr&&!Zr(t))return Nr([new Rt("",'"interpolate" expressions cannot be used with this property')]);if(!o)return Vr(new rn(r?"constant":"source",e.value));const s=o instanceof mr?o.interpolation:void 0;return Vr(new nn(r?"camera":"composite",e.value,o.labels,s))}class sn{constructor(e,t){this._parameters=e,this._specification=t,Dt(this,function e(t,i){const r="color"===i.type,n=t.stops&&"object"==typeof t.stops[0][0],o=n||void 0!==t.property,s=n||!o,a=t.type||(Zr(i)?"exponential":"interval");if(r&&((t=Dt({},t)).stops&&(t.stops=t.stops.map(e=>[e[0],ii.parse(e[1])])),t.default?t.default=ii.parse(t.default):t.default=ii.parse(i.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!fr[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let l,c,h;if("exponential"===a)l=Jr;else if("interval"===a)l=Kr;else if("categorical"===a){l=Hr,c=Object.create(null);for(const e of t.stops)c[e[0]]=e[1];h=typeof t.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);l=Yr}if(n){const r={},n=[];for(let e=0;e<t.stops.length;e++){const i=t.stops[e],o=i[0].zoom;void 0===r[o]&&(r[o]={zoom:o,type:t.type,property:t.property,default:t.default,stops:[]},n.push(o)),r[o].stops.push([i[0].value,i[1]])}const o=[];for(const t of n)o.push([r[t].zoom,e(r[t],i)]);const s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:mr.interpolationFactor.bind(void 0,s),zoomStops:o.map(e=>e[0]),evaluate:({zoom:e},r)=>Jr({stops:o,base:t.base},i,e).evaluate(e,r)}}if(s){const e="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:e,interpolationFactor:mr.interpolationFactor.bind(void 0,e),zoomStops:t.stops.map(e=>e[0]),evaluate:({zoom:e})=>l(t,i,e,c,h)}}return{kind:"source",evaluate(e,r){const n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?Wr(t.default,i.default):l(t,i,n,c,h)}}}(this._parameters,this._specification))}static deserialize(e){return new sn(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function an(e){const t=e.key,i=e.value,r=e.valueSpec||{},n=e.objectElementValidators||{},o=e.style,s=e.styleSpec;let a=[];const l=$r(i);if("object"!==l)return[new kt(t,i,`object expected, ${l} found`)];for(const e in i){const l=e.split(".")[0],c=r[l]||r["*"];let h;if(n[l])h=n[l];else if(r[l])h=Bn;else if(n["*"])h=n["*"];else{if(!r["*"]){a.push(new kt(t,i[e],`unknown property "${e}"`));continue}h=Bn}a=a.concat(h({key:(t?`${t}.`:t)+e,value:i[e],valueSpec:c,style:o,styleSpec:s,object:i,objectKey:e},i))}for(const e in r)n[e]||r[e].required&&void 0===r[e].default&&void 0===i[e]&&a.push(new kt(t,i,`missing required property "${e}"`));return a}function ln(e){const t=e.value,i=e.valueSpec,r=e.style,n=e.styleSpec,o=e.key,s=e.arrayElementValidator||Bn;if("array"!==$r(t))return[new kt(o,t,`array expected, ${$r(t)} found`)];if(i.length&&t.length!==i.length)return[new kt(o,t,`array length ${i.length} expected, length ${t.length} found`)];if(i["min-length"]&&t.length<i["min-length"])return[new kt(o,t,`array length at least ${i["min-length"]} expected, length ${t.length} found`)];let a={type:i.value,values:i.values,minimum:i.minimum,maximum:i.maximum};n.$version<7&&(a.function=i.function),"object"===$r(i.value)&&(a=i.value);let l=[];for(let e=0;e<t.length;e++)l=l.concat(s({array:t,arrayIndex:e,value:t[e],valueSpec:a,style:r,styleSpec:n,key:`${o}[${e}]`}));return l}function cn(e){const t=e.key,i=e.value,r=e.valueSpec;let n=$r(i);if("number"===n&&i!=i&&(n="NaN"),"number"!==n)return[new kt(t,i,`number expected, ${n} found`)];if("minimum"in r){let n=r.minimum;if("array"===$r(r.minimum)){const t=e.arrayIndex;n=r.minimum[t]}if(i<n)return[new kt(t,i,`${i} is less than the minimum value ${n}`)]}if("maximum"in r){let n=r.maximum;if("array"===$r(r.maximum)){const t=e.arrayIndex;n=r.maximum[t]}if(i>n)return[new kt(t,i,`${i} is greater than the maximum value ${n}`)]}return[]}function hn(e){const t=e.valueSpec,i=Lt(e.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===$r(e.value.stops)&&"array"===$r(e.value.stops[0])&&"object"===$r(e.value.stops[0][0]),h=an({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new kt(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;t=t.concat(ln({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:u})),"array"===$r(r)&&0===r.length&&t.push(new kt(e.key,r,"array must have at least one stop"));return t},default:function(e){return Bn({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&h.push(new kt(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||h.push(new kt(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Zr(e.valueSpec)&&h.push(new kt(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!jr(e.valueSpec)?h.push(new kt(e.key,e.value,"property functions not supported")):a&&!Gr(e.valueSpec)&&h.push(new kt(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||h.push(new kt(e.key,e.value,'"property" property is required')),h;function u(e){let i=[];const r=e.value,a=e.key;if("array"!==$r(r))return[new kt(a,r,`array expected, ${$r(r)} found`)];if(2!==r.length)return[new kt(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==$r(r[0]))return[new kt(a,r,`object expected, ${$r(r[0])} found`)];if(void 0===r[0].zoom)return[new kt(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new kt(a,r,"object stop key must have value")];if(o&&o>Lt(r[0].zoom))return[new kt(a,r[0].zoom,"stop zoom values must appear in ascending order")];Lt(r[0].zoom)!==o&&(o=Lt(r[0].zoom),n=void 0,s={}),i=i.concat(an({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:cn,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return en(Bt(r[1]))?i.concat([new kt(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(Bn({key:`${a}[1]`,value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=$r(e.value),l=Lt(e.value),c=null!==e.value?e.value:o;if(r){if(a!==r)return[new kt(e.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new kt(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return jr(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new kt(e.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&l<n?[new kt(e.key,c,"stop domain values must appear in ascending order")]:(n=l,"categorical"===i&&l in s?[new kt(e.key,c,"stop domain values must be unique")]:(s[l]=!0,[])):[new kt(e.key,c,`integer expected, found ${l}`)]}}function un(e){const t=("property"===e.expressionContext?on:tn)(Bt(e.value),e.valueSpec);if("error"===t.result)return t.value.map(t=>new kt(`${e.key}${t.key}`,e.value,t.message));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new kt(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!ji(i))return[new kt(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return function e(t,i){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);for(const e of i.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const n=[];if(t instanceof bi&&r.has(t.name))return[new kt(i.key,i.value,`["${t.name}"] expression is not supported in a filter for a ${i.object.type} layer with id: ${i.object.id}`)];t.eachChild(t=>{n.push(...e(t,i))});return n}(i,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Gi(i,["zoom","feature-state"]))return[new kt(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Ni(i))return[new kt(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function dn(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Lt(i))&&n.push(new kt(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Lt(i))&&n.push(new kt(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function pn(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(!pn(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function fn(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};pn(e)||(e=yn(e));const i=e;let r=!0;try{r=function(e){if(!mn(e))return e;let t=Bt(e);return function e(t){let i=!1;const r=[];if("case"===t[0]){for(let e=1;e<t.length-1;e+=2)i=i||mn(t[e]),r.push(t[e+1]);r.push(t[t.length-1])}else if("match"===t[0]){i=i||mn(t[1]);for(let e=2;e<t.length-1;e+=2)r.push(t[e+1]);r.push(t[t.length-1])}else if("step"===t[0]){i=i||mn(t[1]);for(let e=1;e<t.length-1;e+=2)r.push(t[e+1])}i&&(t.length=0,t.push("any",...r));for(let i=1;i<t.length;i++)e(t[i])}(t),t=function e(t){if(!Array.isArray(t))return t;const i=function(e){if(_n.has(e[0]))for(let t=1;t<e.length;t++){const i=e[t];if(mn(i))return!0}return e}(t);return!0===i?i:i.map(t=>e(t))}(t)}(i)}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${JSON.stringify(i,null,2)}\n `)}const n=zt[`filter_${t}`],o=tn(r,n);let s=null;if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=((e,t,i)=>o.value.evaluate(e,t,{},i));let a=null,l=null;if(r!==i){const e=tn(i,n);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=((t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o)),l=!Ni(e.value.expression)}return{filter:s=s,dynamicFilter:a||void 0,needGeometry:function e(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let i=1;i<t.length;i++)if(e(t[i]))return!0;return!1}(r),needFeature:!!l}}function mn(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t<e.length;t++){if(mn(e[t]))return!0}return!1}const _n=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function gn(e,t){return e<t?-1:e>t?1:0}function yn(e){if(!e)return!0;const t=e[0];return e.length<=1?"any"!==t:"=="===t?xn(e[1],e[2],"=="):"!="===t?wn(xn(e[1],e[2],"==")):"<"===t||">"===t||"<="===t||">="===t?xn(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(yn))):"all"===t?["all"].concat(e.slice(1).map(yn)):"none"===t?["all"].concat(e.slice(1).map(yn).map(wn)):"in"===t?vn(e[1],e.slice(2)):"!in"===t?wn(vn(e[1],e.slice(2))):"has"===t?bn(e[1]):"!has"===t?wn(bn(e[1])):"within"!==t||e;var i}function xn(e,t,i){switch(e){case"$type":return[`filter-type-${i}`,t];case"$id":return[`filter-id-${i}`,t];default:return[`filter-${i}`,e,t]}}function vn(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(gn)]]:["filter-in-small",e,["literal",t]]}}function bn(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function wn(e){return["!",e]}function Tn(e){if(pn(Bt(e.value))){const t=Bt(e.layerType);return un(Dt({},e,{expressionContext:"filter",valueSpec:e.styleSpec[`filter_${t||"fill"}`]}))}return function e(t){const i=t.value;const r=t.key;if("array"!==$r(i))return[new kt(r,i,`array expected, ${$r(i)} found`)];const n=t.styleSpec;let o;let s=[];if(i.length<1)return[new kt(r,i,"filter array must have at least 1 element")];s=s.concat(dn({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec}));switch(Lt(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===Lt(i[1])&&s.push(new kt(r,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&s.push(new kt(r,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&"string"!==(o=$r(i[1]))&&s.push(new kt(`${r}[1]`,i[1],`string expected, ${o} found`));for(let e=2;e<i.length;e++)o=$r(i[e]),"$type"===Lt(i[1])?s=s.concat(dn({key:`${r}[${e}]`,value:i[e],valueSpec:n.geometry_type,style:t.style,styleSpec:t.styleSpec})):"string"!==o&&"number"!==o&&"boolean"!==o&&s.push(new kt(`${r}[${e}]`,i[e],`string, number, or boolean expected, ${o} found`));break;case"any":case"all":case"none":for(let n=1;n<i.length;n++)s=s.concat(e({key:`${r}[${n}]`,value:i[n],style:t.style,styleSpec:t.styleSpec}));break;case"has":case"!has":o=$r(i[1]),2!==i.length?s.push(new kt(r,i,`filter array for "${i[0]}" operator must have 2 elements`)):"string"!==o&&s.push(new kt(`${r}[1]`,i[1],`string expected, ${o} found`));break;case"within":o=$r(i[1]),2!==i.length?s.push(new kt(r,i,`filter array for "${i[0]}" operator must have 2 elements`)):"object"!==o&&s.push(new kt(`${r}[1]`,i[1],`object expected, ${o} found`))}return s}(e)}function En(e,t){const i=e.key,r=e.style,n=e.styleSpec,o=e.value,s=e.objectKey,a=n[`${t}_${e.layerType}`];if(!a)return[];const l=s.match(/^(.*)-transition$/);if("paint"===t&&l&&a[l[1]]&&a[l[1]].transition)return Bn({key:i,value:o,valueSpec:n.transition,style:r,styleSpec:n});const c=e.valueSpec||a[s];if(!c)return[new kt(i,o,`unknown property "${s}"`)];let h;if("string"===$r(o)&&jr(c)&&!c.tokens&&(h=/^{([^}]+)}$/.exec(o)))return[new kt(i,o,`"${s}" does not support interpolation syntax\n`+`Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(h[1])} }\`.`)];const u=[];return"symbol"===e.layerType&&("text-field"===s&&r&&!r.glyphs&&u.push(new kt(i,o,'use of "text-field" requires a style "glyphs" property')),"text-font"===s&&qr(Bt(o))&&"identity"===Lt(o.type)&&u.push(new kt(i,o,'"text-font" does not support identity functions'))),u.concat(Bn({key:e.key,value:o,valueSpec:c,style:r,styleSpec:n,expressionContext:"property",propertyType:t,propertyKey:s}))}function Sn(e){return En(e,"paint")}function In(e){return En(e,"layout")}function Mn(e){let t=[];const i=e.value,r=e.key,n=e.style,o=e.styleSpec;i.type||i.ref||t.push(new kt(r,i,'either "type" or "ref" is required'));let s=Lt(i.type);const a=Lt(i.ref);if(i.id){const o=Lt(i.id);for(let s=0;s<e.arrayIndex;s++){const e=n.layers[s];Lt(e.id)===o&&t.push(new kt(r,i.id,`duplicate layer id "${i.id}", previously used at line ${e.id.__line__}`))}}if("ref"in i){let e;["type","source","source-layer","filter","layout"].forEach(e=>{e in i&&t.push(new kt(r,i[e],`"${e}" is prohibited for ref layers`))}),n.layers.forEach(t=>{Lt(t.id)===a&&(e=t)}),e?e.ref?t.push(new kt(r,i.ref,"ref cannot reference another ref layer")):s=Lt(e.type):t.push(new kt(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const e=n.sources&&n.sources[i.source],o=e&&Lt(e.type);e?"vector"===o&&"raster"===s?t.push(new kt(r,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?t.push(new kt(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?t.push(new kt(r,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new kt(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new kt(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new kt(r,i.source,`source "${i.source}" not found`))}else t.push(new kt(r,i,'missing required property "source"'));return t=t.concat(an({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Bn({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:i,objectKey:"type"}),filter:e=>Tn(Dt({layerType:s},e)),layout:e=>an({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>In(Dt({layerType:s},e))}}),paint:e=>an({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>Sn(Dt({layerType:s},e))}})}}))}function An(e){const t=e.value,i=e.key,r=$r(t);return"string"!==r?[new kt(i,t,`string expected, ${r} found`)]:[]}const Cn={promoteId:function({key:e,value:t}){if("string"===$r(t))return An({key:e,value:t});{const i=[];for(const r in t)i.push(...An({key:`${e}.${r}`,value:t[r]}));return i}}};function zn(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style;if(!t.type)return[new kt(i,t,'"type" is required')];const o=Lt(t.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=an({key:i,value:t,valueSpec:r[`source_${o.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Cn});case"geojson":if(s=an({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,objectElementValidators:Cn}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;s.push(...un({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),s.push(...un({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return an({key:i,value:t,valueSpec:r.source_video,style:n,styleSpec:r});case"image":return an({key:i,value:t,valueSpec:r.source_image,style:n,styleSpec:r});case"canvas":return[new kt(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return dn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:n,styleSpec:r})}}function kn(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const s=$r(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new kt("light",t,`object expected, ${s} found`)]);for(const e in t){const s=e.match(/^(.*)-transition$/);o=s&&r[s[1]]&&r[s[1]].transition?o.concat(Bn({key:e,value:t[e],valueSpec:i.transition,style:n,styleSpec:i})):r[e]?o.concat(Bn({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i})):o.concat([new kt(e,t[e],`unknown property "${e}"`)])}return o}function Pn(e){const t=e.value,i=e.key,r=e.style,n=e.styleSpec,o=n.terrain;let s=[];const a=$r(t);if(void 0===t)return s;if("object"!==a)return s=s.concat([new kt("terrain",t,`object expected, ${a} found`)]);for(const e in t){const i=e.match(/^(.*)-transition$/);s=i&&o[i[1]]&&o[i[1]].transition?s.concat(Bn({key:e,value:t[e],valueSpec:n.transition,style:r,styleSpec:n})):o[e]?s.concat(Bn({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:n})):s.concat([new kt(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],n=e&&Lt(e.type);e?"raster-dem"!==n&&s.push(new kt(i,t.source,`terrain cannot be used with a source of type ${n}, it only be used with a "raster-dem" source type`)):s.push(new kt(i,t.source,`source "${t.source}" not found`))}else s.push(new kt(i,t,'terrain is missing required property "source"'));return s}function Dn(e){const t=e.value,i=e.style,r=e.styleSpec,n=r.fog;let o=[];const s=$r(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new kt("fog",t,`object expected, ${s} found`)]);for(const e in t){const s=e.match(/^(.*)-transition$/);o=s&&n[s[1]]&&n[s[1]].transition?o.concat(Bn({key:e,value:t[e],valueSpec:r.transition,style:i,styleSpec:r})):n[e]?o.concat(Bn({key:e,value:t[e],valueSpec:n[e],style:i,styleSpec:r})):o.concat([new kt(e,t[e],`unknown property "${e}"`)])}return o}const Ln={"*":()=>[],array:ln,boolean:function(e){const t=e.value,i=e.key,r=$r(t);return"boolean"!==r?[new kt(i,t,`boolean expected, ${r} found`)]:[]},number:cn,color:function(e){const t=e.key,i=e.value,r=$r(i);return"string"!==r?[new kt(t,i,`color expected, ${r} found`)]:null===ti.parseCSSColor(i)?[new kt(t,i,`color expected, "${i}" found`)]:[]},constants:Pt,enum:dn,filter:Tn,function:hn,layer:Mn,object:an,source:zn,light:kn,terrain:Pn,fog:Dn,string:An,formatted:function(e){return 0===An(e).length?[]:un(e)},resolvedImage:function(e){return 0===An(e).length?[]:un(e)},projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style;let o=[];const s=$r(t);if("object"===s)for(const e in t)o=o.concat(Bn({key:e,value:t[e],valueSpec:r[e],style:n,styleSpec:i}));else"string"!==s&&(o=o.concat([new kt("projection",t,`object or string expected, ${s} found`)]));return o}};function Bn(e){const t=e.value,i=e.valueSpec,r=e.styleSpec;if(i.expression&&qr(Lt(t)))return hn(e);if(i.expression&&en(Bt(t)))return un(e);if(i.type&&Ln[i.type])return Ln[i.type](e);return an(Dt({},e,{valueSpec:i.type?r[i.type]:i}))}function Rn(e){const t=e.value,i=e.key,r=An(e);return r.length?r:(-1===t.indexOf("{fontstack}")&&r.push(new kt(i,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new kt(i,t,'"glyphs" url must include a "{range}" token')),r)}function Fn(e,t=zt){let i=[];return i=i.concat(Bn({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:Rn,"*":()=>[]}})),e.constants&&(i=i.concat(Pt({key:"constants",value:e.constants,style:e,styleSpec:t}))),On(i)}function On(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Un(e){return function(...t){return On(e.apply(this,t))}}Fn.source=Un(zn),Fn.light=Un(kn),Fn.terrain=Un(Pn),Fn.fog=Un(Dn),Fn.layer=Un(Mn),Fn.filter=Un(Tn),Fn.paintProperty=Un(Sn),Fn.layoutProperty=Un(In);const Vn=Fn,Nn=Vn.light,jn=Vn.fog,Gn=Vn.paintProperty,Zn=Vn.layoutProperty;function $n(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new At(new Error(r.message))),i=!0;return i}var qn=Wn,Xn=3;function Wn(e,t,i){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var n=new Int32Array(this.arrayBuffer);e=n[0],t=n[1],i=n[2],this.d=t+2*i;for(var o=0;o<this.d*this.d;o++){var s=n[Xn+o],a=n[Xn+o+1];r.push(s===a?null:n.subarray(s,a))}var l=n[Xn+r.length],c=n[Xn+r.length+1];this.keys=n.subarray(l,c),this.bboxes=n.subarray(c),this.insert=this._insertReadonly}else{this.d=t+2*i;for(var h=0;h<this.d*this.d;h++)r.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=e,this.padding=i,this.scale=t/e,this.uid=0;var u=i/t*e;this.min=-u,this.max=e+u}Wn.prototype.insert=function(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)},Wn.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},Wn.prototype._insertCell=function(e,t,i,r,n,o){this.cells[n].push(o)},Wn.prototype.query=function(e,t,i,r,n){var o=this.min,s=this.max;if(e<=o&&t<=o&&s<=i&&s<=r&&!n)return Array.prototype.slice.call(this.keys);var a=[];return this._forEachCell(e,t,i,r,this._queryCell,a,{},n),a},Wn.prototype._queryCell=function(e,t,i,r,n,o,s,a){var l=this.cells[n];if(null!==l)for(var c=this.keys,h=this.bboxes,u=0;u<l.length;u++){var d=l[u];if(void 0===s[d]){var p=4*d;(a?a(h[p+0],h[p+1],h[p+2],h[p+3]):e<=h[p+2]&&t<=h[p+3]&&i>=h[p+0]&&r>=h[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},Wn.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),h=this._convertToCellCoord(i),u=this._convertToCellCoord(r),d=l;d<=h;d++)for(var p=c;p<=u;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},Wn.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Wn.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Wn.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=Xn+this.cells.length+1+1,i=0,r=0;r<this.cells.length;r++)i+=this.cells[r].length;var n=new Int32Array(t+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;for(var o=t,s=0;s<e.length;s++){var a=e[s];n[Xn+s]=o,n.set(a,o),o+=a.length}return n[Xn+e.length]=o,n.set(this.keys,o),o+=this.keys.length,n[Xn+e.length+1]=o,n.set(this.bboxes,o),o+=this.bboxes.length,n.buffer};const{ImageData:Hn,ImageBitmap:Kn}=s,Jn={};function Yn(e,t,i={}){Object.defineProperty(t,"_classRegistryKey",{value:e,writeable:!1}),Jn[e]={klass:t,omit:i.omit||[],shallow:i.shallow||[]}}Yn("Object",Object),qn.serialize=function(e,t){const i=e.toArrayBuffer();return t&&t.push(i),{buffer:i}},qn.deserialize=function(e){return new qn(e.buffer)},Yn("Grid",qn),Yn("Color",ii),Yn("Error",Error),Yn("ResolvedImage",si),Yn("StylePropertyFunction",sn),Yn("StyleExpression",Qr,{omit:["_evaluator"]}),Yn("ZoomDependentExpression",nn),Yn("ZoomConstantExpression",rn),Yn("CompoundExpression",bi,{omit:["_evaluate"]});for(const e in Br)Br[e]._classRegistryKey||Yn(`Expression_${e}`,Br[e]);function Qn(e){return e&&"undefined"!=typeof ArrayBuffer&&(e instanceof ArrayBuffer||e.constructor&&"ArrayBuffer"===e.constructor.name)}function eo(e){return Kn&&e instanceof Kn}function to(e,t){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(Qn(e)||eo(e))return t&&t.push(e),e;if(ArrayBuffer.isView(e)){const i=e;return t&&t.push(i.buffer),i}if(e instanceof Hn)return t&&t.push(e.data.buffer),e;if(Array.isArray(e)){const i=[];for(const r of e)i.push(to(r,t));return i}if("object"==typeof e){const i=e.constructor,r=i._classRegistryKey;if(!r)throw new Error("can't serialize object of unregistered class");const n=i.serialize?i.serialize(e,t):{};if(!i.serialize){for(const i in e){if(!e.hasOwnProperty(i))continue;if(Jn[r].omit.indexOf(i)>=0)continue;const o=e[i];n[i]=Jn[r].shallow.indexOf(i)>=0?o:to(o,t)}e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error(`can't serialize object of type ${typeof e}`)}function io(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||Qn(e)||eo(e)||ArrayBuffer.isView(e)||e instanceof Hn)return e;if(Array.isArray(e))return e.map(io);if("object"==typeof e){const t=e.$name||"Object",{klass:i}=Jn[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const n=e[i];r[i]=Jn[t].shallow.indexOf(i)>=0?n:io(n)}return r}throw new Error(`can't deserialize object of type ${typeof e}`)}class ro{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=t),e!==this.lastZoom&&(this.lastZoom=e,this.lastFloorZoom=i,!0))}}const no={"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 oo(e){for(const t of e)if(lo(t.charCodeAt(0)))return!0;return!1}function so(e){for(const t of e)if(!ao(t.charCodeAt(0)))return!1;return!0}function ao(e){return!no.Arabic(e)&&(!no["Arabic Supplement"](e)&&(!no["Arabic Extended-A"](e)&&(!no["Arabic Presentation Forms-A"](e)&&!no["Arabic Presentation Forms-B"](e))))}function lo(e){return 746===e||747===e||!(e<4352)&&(!!no["Bopomofo Extended"](e)||(!!no.Bopomofo(e)||(!(!no["CJK Compatibility Forms"](e)||e>=65097&&e<=65103)||(!!no["CJK Compatibility Ideographs"](e)||(!!no["CJK Compatibility"](e)||(!!no["CJK Radicals Supplement"](e)||(!!no["CJK Strokes"](e)||(!(!no["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||(!!no["CJK Unified Ideographs Extension A"](e)||(!!no["CJK Unified Ideographs"](e)||(!!no["Enclosed CJK Letters and Months"](e)||(!!no["Hangul Compatibility Jamo"](e)||(!!no["Hangul Jamo Extended-A"](e)||(!!no["Hangul Jamo Extended-B"](e)||(!!no["Hangul Jamo"](e)||(!!no["Hangul Syllables"](e)||(!!no.Hiragana(e)||(!!no["Ideographic Description Characters"](e)||(!!no.Kanbun(e)||(!!no["Kangxi Radicals"](e)||(!!no["Katakana Phonetic Extensions"](e)||(!(!no.Katakana(e)||12540===e)||(!(!no["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)||(!(!no["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(!!no["Unified Canadian Aboriginal Syllabics"](e)||(!!no["Unified Canadian Aboriginal Syllabics Extended"](e)||(!!no["Vertical Forms"](e)||(!!no["Yijing Hexagram Symbols"](e)||(!!no["Yi Syllables"](e)||!!no["Yi Radicals"](e))))))))))))))))))))))))))))))}function co(e){return!(lo(e)||function(e){return!!(no["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||no["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)||no["Letterlike Symbols"](e)||no["Number Forms"](e)||no["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)||no["Control Pictures"](e)&&9251!==e||no["Optical Character Recognition"](e)||no["Enclosed Alphanumerics"](e)||no["Geometric Shapes"](e)||no["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||no["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||no["CJK Symbols and Punctuation"](e)||no.Katakana(e)||no["Private Use Area"](e)||no["CJK Compatibility Forms"](e)||no["Small Form Variants"](e)||no["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 ho(e){return e>=1424&&e<=2303||no["Arabic Presentation Forms-A"](e)||no["Arabic Presentation Forms-B"](e)}function uo(e,t){return!(!t&&ho(e))&&!(e>=2304&&e<=3583||e>=3840&&e<=4255||no.Khmer(e))}function po(e){for(const t of e)if(ho(t.charCodeAt(0)))return!0;return!1}const fo="deferred",mo="loading",_o="loaded",go="error";let yo=null,xo="unavailable",vo=null;const bo=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(xo=go),yo&&yo(e)};function wo(){To.fire(new Mt("pluginStateChange",{pluginStatus:xo,pluginURL:vo}))}const To=new Ct,Eo=function(){return xo},So=function(){if(xo!==fo||!vo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");xo=mo,wo(),vo&&gt({url:vo},e=>{e?bo(e):(xo=_o,wo())})},Io={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>xo===_o||null!=Io.applyArabicShaping,isLoading:()=>xo===mo,setState(e){xo=e.pluginStatus,vo=e.pluginURL},isParsed:()=>null!=Io.applyArabicShaping&&null!=Io.processBidirectionalText&&null!=Io.processStyledBidirectionalText,getPluginURL:()=>vo},Mo=function(){Io.isLoading()||Io.isLoaded()||"deferred"!==Eo()||So()};class Ao{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ro,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const i of e)if(!uo(i.charCodeAt(0),t))return!1;return!0}(e,Io.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}class Co{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(qr(e))return new sn(e,t);if(en(e)){const i=on(e,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return i.value}{let i=e;return"string"==typeof e&&"color"===t.type&&(i=ii.parse(e)),{kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class zo{constructor(e){this.property=e,this.value=new Co(e,void 0)}transitioned(e,t){return new Po(this.property,this.value,t,oe({},e.transition,this.transition),e.now)}untransitioned(){return new Po(this.property,this.value,null,{},0)}}class ko{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return me(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new zo(this._values[e].property)),this._values[e].value=new Co(this._values[e].property,null===t?void 0:me(t))}getTransition(e){return me(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new zo(this._values[e].property)),this._values[e].transition=me(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Do(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Do(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Po{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return o.possiblyEvaluate(e,t,i);{const s=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(o.possiblyEvaluate(e,t,i),n,J(s))}}return n}}class Do{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,t,i){const r=new Ro(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Lo{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}getValue(e){return me(this._values[e].value)}setValue(e,t){this._values[e]=new Co(this._values[e].property,null===t?void 0:me(t))}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i)}return e}possiblyEvaluate(e,t,i){const r=new Ro(this._properties);for(const n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(e,t,i);return r}}class Bo{constructor(e,t,i){this.property=e,this.value=t,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(e){return"constant"===this.value.kind?this.value.value:e}evaluate(e,t,i,r){return this.property.evaluate(this.value,this.parameters,e,t,i,r)}}class Ro{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class Fo{constructor(e){this.specification=e}possiblyEvaluate(e,t){return e.expression.evaluate(t)}interpolate(e,t,i){const r=Hi[this.specification.type];return r?r(e,t,i):e}}class Oo{constructor(e,t){this.specification=e,this.overrides=t}possiblyEvaluate(e,t,i,r){return"constant"===e.expression.kind||"camera"===e.expression.kind?new Bo(this,{kind:"constant",value:e.expression.evaluate(t,null,{},i,r)},t):new Bo(this,e.expression,t)}interpolate(e,t,i){if("constant"!==e.value.kind||"constant"!==t.value.kind)return e;if(void 0===e.value.value||void 0===t.value.value)return new Bo(this,{kind:"constant",value:void 0},e.parameters);const r=Hi[this.specification.type];return r?new Bo(this,{kind:"constant",value:r(e.value.value,t.value.value,i)},e.parameters):e}evaluate(e,t,i,r,n,o){return"constant"===e.kind?e.value:e.evaluate(t,i,r,n,o)}}class Uo extends Oo{possiblyEvaluate(e,t,i,r){if(void 0===e.value)return new Bo(this,{kind:"constant",value:void 0},t);if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r),o="resolvedImage"===e.property.specification.type&&"string"!=typeof n?n.name:n,s=this._calculate(o,o,o,t);return new Bo(this,{kind:"constant",value:s},t)}if("camera"===e.expression.kind){const i=this._calculate(e.expression.evaluate({zoom:t.zoom-1}),e.expression.evaluate({zoom:t.zoom}),e.expression.evaluate({zoom:t.zoom+1}),t);return new Bo(this,{kind:"constant",value:i},t)}return new Bo(this,e.expression,t)}evaluate(e,t,i,r,n,o){if("source"===e.kind){const s=e.evaluate(t,i,r,n,o);return this._calculate(s,s,s,t)}return"composite"===e.kind?this._calculate(e.evaluate({zoom:Math.floor(t.zoom)-1},i,r),e.evaluate({zoom:Math.floor(t.zoom)},i,r),e.evaluate({zoom:Math.floor(t.zoom)+1},i,r),t):e.value}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t,other:i}:{from:i,to:t,other:e}}interpolate(e){return e}}class Vo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new Ao(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Ao(Math.floor(t.zoom),t)),e.expression.evaluate(new Ao(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class No{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class jo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const r=this.defaultPropertyValues[t]=new Co(i,void 0),n=this.defaultTransitionablePropertyValues[t]=new zo(i);this.defaultTransitioningPropertyValues[t]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}function Go(e,t){return 256*(e=ee(Math.floor(e),0,255))+(t=ee(Math.floor(t),0,255))}Yn("DataDrivenProperty",Oo),Yn("DataConstantProperty",Fo),Yn("CrossFadedDataDrivenProperty",Uo),Yn("CrossFadedProperty",Vo),Yn("ColorRampProperty",No);const Zo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class $o{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}const qo=128,Xo=5;class Wo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(this.capacity*Xo),qo),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")}}function Ho(e,t=1){let i=0,r=0;return{members:e.map(e=>{const n=function(e){return Zo[e].BYTES_PER_ELEMENT}(e.type),o=i=Ko(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}}),size:Ko(i,Math.max(r,t)),alignment:t}}function Ko(e,t){return Math.ceil(e/t)*t}class Jo extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}Jo.prototype.bytesPerElement=4,Yn("StructArrayLayout2i4",Jo);class Yo extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}Yo.prototype.bytesPerElement=8,Yn("StructArrayLayout4i8",Yo);class Qo extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,h=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[h+2]=a,e}}Qo.prototype.bytesPerElement=12,Yn("StructArrayLayout2i4ub1f12",Qo);class es extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}es.prototype.bytesPerElement=12,Yn("StructArrayLayout3f12",es);class ts extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,n,o,s,a,l,c)}emplace(e,t,i,r,n,o,s,a,l,c,h){const u=10*e;return this.uint16[u+0]=t,this.uint16[u+1]=i,this.uint16[u+2]=r,this.uint16[u+3]=n,this.uint16[u+4]=o,this.uint16[u+5]=s,this.uint16[u+6]=a,this.uint16[u+7]=l,this.uint16[u+8]=c,this.uint16[u+9]=h,e}}ts.prototype.bytesPerElement=20,Yn("StructArrayLayout10ui20",ts);class is extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,o,s,a)}emplace(e,t,i,r,n,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}is.prototype.bytesPerElement=16,Yn("StructArrayLayout8ui16",is);class rs extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_){const g=16*e;return this.int16[g+0]=t,this.int16[g+1]=i,this.int16[g+2]=r,this.int16[g+3]=n,this.uint16[g+4]=o,this.uint16[g+5]=s,this.uint16[g+6]=a,this.uint16[g+7]=l,this.int16[g+8]=c,this.int16[g+9]=h,this.int16[g+10]=u,this.int16[g+11]=d,this.int16[g+12]=p,this.int16[g+13]=f,this.int16[g+14]=m,this.int16[g+15]=_,e}}rs.prototype.bytesPerElement=32,Yn("StructArrayLayout4i4ui4i4i32",rs);class ns extends Wo{_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){const i=1*e;return this.uint32[i+0]=t,e}}ns.prototype.bytesPerElement=4,Yn("StructArrayLayout1ul4",ns);class os extends Wo{_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,i,r,n,o,s,a,l,c,h,u,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,h,u,d)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=h,this.uint32[m+8]=u,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}os.prototype.bytesPerElement=40,Yn("StructArrayLayout5i4f1i1ul2ui40",os);class ss extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}ss.prototype.bytesPerElement=16,Yn("StructArrayLayout3i2i2i16",ss);class as extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}as.prototype.bytesPerElement=16,Yn("StructArrayLayout2f1f2i16",as);class ls extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=12*e,s=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=i,this.float32[s+1]=r,this.float32[s+2]=n,e}}ls.prototype.bytesPerElement=12,Yn("StructArrayLayout2ub2f12",ls);class cs extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}cs.prototype.bytesPerElement=6,Yn("StructArrayLayout3ui6",cs);class hs extends Wo{_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,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=i,this.int16[w+2]=r,this.float32[T+2]=n,this.float32[T+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[T+5]=l,this.uint32[T+6]=c,this.uint32[T+7]=h,this.uint16[w+16]=u,this.uint16[w+17]=d,this.uint16[w+18]=p,this.float32[T+10]=f,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=x,this.int16[w+28]=v,this.uint8[E+58]=b,e}}hs.prototype.bytesPerElement=60,Yn("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",hs);class us extends Wo{_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,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C){const z=this.length;return this.resize(z+1),this.emplace(z,e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C)}emplace(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E,S,I,M,A,C,z){const k=38*e,P=19*e;return this.int16[k+0]=t,this.int16[k+1]=i,this.int16[k+2]=r,this.float32[P+2]=n,this.float32[P+3]=o,this.int16[k+8]=s,this.int16[k+9]=a,this.int16[k+10]=l,this.int16[k+11]=c,this.int16[k+12]=h,this.int16[k+13]=u,this.uint16[k+14]=d,this.uint16[k+15]=p,this.uint16[k+16]=f,this.uint16[k+17]=m,this.uint16[k+18]=_,this.uint16[k+19]=g,this.uint16[k+20]=y,this.uint16[k+21]=x,this.uint16[k+22]=v,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=S,this.uint16[k+28]=I,this.uint32[P+15]=M,this.float32[P+16]=A,this.float32[P+17]=C,this.float32[P+18]=z,e}}us.prototype.bytesPerElement=76,Yn("StructArrayLayout3i2f6i15ui1ul3f76",us);class ds extends Wo{_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){const i=1*e;return this.float32[i+0]=t,e}}ds.prototype.bytesPerElement=4,Yn("StructArrayLayout1f4",ds);class ps extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}ps.prototype.bytesPerElement=6,Yn("StructArrayLayout3i6",ps);class fs extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}fs.prototype.bytesPerElement=28,Yn("StructArrayLayout7f28",fs);class ms extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=3*e,s=6*e;return this.uint32[o+0]=t,this.uint16[s+2]=i,this.uint16[s+3]=r,this.uint16[s+4]=n,e}}ms.prototype.bytesPerElement=12,Yn("StructArrayLayout1ul3ui12",ms);class _s extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}_s.prototype.bytesPerElement=4,Yn("StructArrayLayout2ui4",_s);class gs extends Wo{_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){const i=1*e;return this.uint16[i+0]=t,e}}gs.prototype.bytesPerElement=2,Yn("StructArrayLayout1ui2",gs);class ys extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}ys.prototype.bytesPerElement=8,Yn("StructArrayLayout2f8",ys);class xs extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}xs.prototype.bytesPerElement=16,Yn("StructArrayLayout4f16",xs);class vs extends $o{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]}}vs.prototype.size=40;class bs extends os{get(e){return new vs(this,e)}}Yn("CollisionBoxArray",bs);class ws extends $o{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}}ws.prototype.size=60;class Ts extends hs{get(e){return new ws(this,e)}}Yn("PlacedSymbolArray",Ts);class Es extends $o{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]}}Es.prototype.size=76;class Ss extends us{get(e){return new Es(this,e)}}Yn("SymbolInstanceArray",Ss);class Is extends ds{getoffsetX(e){return this.float32[1*e+0]}}Yn("GlyphOffsetArray",Is);class Ms extends ps{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Yn("SymbolLineVertexArray",Ms);class As extends $o{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]}}As.prototype.size=12;class Cs extends ms{get(e){return new As(this,e)}}Yn("FeatureIndexArray",Cs);class zs extends $o{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}zs.prototype.size=4;class ks extends _s{get(e){return new zs(this,e)}}Yn("FillExtrusionCentroidArray",ks);const Ps=Ho([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),Ds=Ho([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Ls=ei(function(e){e.exports=function(e,t){var i,r,n,o,s,a,l,c;for(i=3&e.length,r=e.length-i,n=t,s=3432918353,a=461845907,c=0;c<r;)l=255&e.charCodeAt(c)|(255&e.charCodeAt(++c))<<8|(255&e.charCodeAt(++c))<<16|(255&e.charCodeAt(++c))<<24,++c,n=27492+(65535&(o=5*(65535&(n=(n^=l=(65535&(l=(l=(65535&l)*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}}),Bs=ei(function(e){e.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}}),Rs=Ls,Fs=Ls,Os=Bs;Rs.murmur3=Fs,Rs.murmur2=Os;class Us{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(Vs(e)),this.positions.push(t,i,r)}getPositions(e){const t=Vs(e);let i=0,r=this.ids.length-1;for(;i<r;){const e=i+r>>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;){const e=this.positions[3*i],t=this.positions[3*i+1],r=this.positions[3*i+2];n.push({index:e,start:t,end:r}),i++}return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return function e(t,i,r,n){for(;r<n;){const o=t[r+n>>1];let s=r-1,a=n+1;for(;;){do{s++}while(t[s]<o);do{a--}while(t[a]>o);if(s>=a)break;Ns(t,s,a),Ns(i,3*s,3*a),Ns(i,3*s+1,3*a+1),Ns(i,3*s+2,3*a+2)}a-r<n-a?(e(t,i,r,a),r=a+1):(e(t,i,a+1,n),n=a)}}(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new Us;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function Vs(e){const t=+e;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Rs(String(e))}function Ns(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}Yn("FeaturePositionMap",Us);class js{constructor(e,t){this.gl=e.gl,this.location=t}}class Gs extends js{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1f(this.location,e))}}class Zs extends js{constructor(e,t){super(e,t),this.current=[0,0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]&&e[3]===this.current[3]||(this.current=e,this.gl.uniform4f(this.location,e[0],e[1],e[2],e[3]))}}class $s extends js{constructor(e,t){super(e,t),this.current=ii.transparent}set(e){e.r===this.current.r&&e.g===this.current.g&&e.b===this.current.b&&e.a===this.current.a||(this.current=e,this.gl.uniform4f(this.location,e.r,e.g,e.b,e.a))}}const qs=new Float32Array(16);const Xs=new Float32Array(9);const Ws=new Float32Array(4);function Hs(e){return[Go(255*e.r,255*e.g),Go(255*e.b,255*e.a)]}class Ks{constructor(e,t,i){this.value=e,this.uniformNames=t.map(e=>`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new $s(e,t):new Gs(e,t)}}class Js{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,i,r){const n="u_pattern_to"===r||"u_dash_to"===r?this.patternTo:"u_pattern_from"===r||"u_dash_from"===r?this.patternFrom:"u_pixel_ratio_to"===r?this.pixelRatioTo:"u_pixel_ratio_from"===r?this.pixelRatioFrom:null;n&&e.set(n)}getBinding(e,t,i){return"u_pattern_from"===i||"u_pattern_to"===i||"u_dash_from"===i||"u_dash_to"===i?new Zs(e,t):new Gs(e,t)}}class Ys{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new Ao(0),t,{},n,r,o);this.paintVertexArray.resize(e),this._setPaintValue(s,e,a)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:0},i,r,void 0,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const r=Hs(i);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=e;r<t;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Qs{constructor(e,t,i,r,n,o){this.expression=e,this.uniformNames=t.map(e=>`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o){const s=this.expression.evaluate(new Ao(this.zoom),t,{},n,r,o),a=this.expression.evaluate(new Ao(this.zoom+1),t,{},n,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,s,a)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate({zoom:this.zoom},i,r,void 0,n),s=this.expression.evaluate({zoom:this.zoom+1},i,r,void 0,n);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Hs(i),o=Hs(r);for(let i=e;i<t;i++)this.paintVertexArray.emplace(i,n[0],n[1],o[0],o[1])}else{for(let n=e;n<t;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(e){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=e.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(e,t){const i=this.useIntegerZoom?Math.floor(t.zoom):t.zoom,r=ee(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);e.set(r)}getBinding(e,t,i){return new Gs(e,t)}}class ea{constructor(e,t,i,r,n,o,s){this.expression=e,this.type=i,this.useIntegerZoom=r,this.zoom=n,this.layerId=s,this.paintVertexAttributes=("array"===i?Ds:Ps).members;for(let e=0;e<t.length;++e);this.zoomInPaintVertexArray=new o,this.zoomOutPaintVertexArray=new o}populatePaintArray(e,t,i){const r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(e),this.zoomOutPaintVertexArray.resize(e),this._setPaintValues(r,e,t.patterns&&t.patterns[this.layerId],i)}updatePaintArray(e,t,i,r,n,o){this._setPaintValues(e,t,i.patterns&&i.patterns[this.layerId],o)}_setPaintValues(e,t,i,r){if(!r||!i)return;const{min:n,mid:o,max:s}=i,a=r[n],l=r[o],c=r[s];if(a&&l&&c)for(let i=e;i<t;i++)this._setPaintValue(this.zoomInPaintVertexArray,i,l,a),this._setPaintValue(this.zoomOutPaintVertexArray,i,l,c)}_setPaintValue(e,t,i,r){e.emplace(t,i.tl[0],i.tl[1],i.br[0],i.br[1],r.tl[0],r.tl[1],r.br[0],r.br[1],i.pixelRatio,r.pixelRatio)}upload(e){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=e.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=e.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class ta{constructor(e,t,i=(()=>!0)){this.binders={},this._buffers=[];const r=[];for(const n in e.paint._values){if(!i(n))continue;const o=e.paint.get(n);if(!(o instanceof Bo&&jr(o.property.specification)))continue;const s=na(n,e.type),a=o.value,l=o.property.specification.type,c=o.property.useIntegerZoom,h=o.property.specification["property-type"],u="cross-faded"===h||"cross-faded-data-driven"===h,d="line-dasharray"===String(n)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==a.kind||d)if("source"===a.kind||d||u){const i=aa(n,l,"source");this.binders[n]=u?new ea(a,s,l,c,t,i,e.id):new Ys(a,s,l,i),r.push(`/a_${n}`)}else{const e=aa(n,l,"composite");this.binders[n]=new Qs(a,s,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=u?new Js(a.value,s):new Ks(a.value,s,l),r.push(`/u_${n}`)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Ys||t instanceof Qs?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o){for(const s in this.binders){const a=this.binders[s];(a instanceof Ys||a instanceof Qs||a instanceof ea)&&a.populatePaintArray(e,t,i,r,n,o)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof Js&&r.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,i,r,n,o){let s=!1;for(const a in e){const l=t.getPositions(a);for(const t of l){const l=i.feature(t.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof Ys||c instanceof Qs||c instanceof ea)&&!0===c.expression.isStateDependent){const h=r.paint.get(i);c.expression=h.value,c.updatePaintArray(t.start,t.end,l,e[a],n,o),s=!0}}}}return s}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Ks||i instanceof Js)&&e.push(...i.uniformNames.map(e=>`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ys||i instanceof Qs||i instanceof ea)for(let t=0;t<i.paintVertexAttributes.length;t++)e.push(i.paintVertexAttributes[t].name)}return e}getBinderUniforms(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ks||i instanceof Js||i instanceof Qs)for(const t of i.uniformNames)e.push(t)}return e}getPaintVertexBuffers(){return this._buffers}getUniforms(e,t){const i=[];for(const r in this.binders){const n=this.binders[r];if(n instanceof Ks||n instanceof Js||n instanceof Qs)for(const o of n.uniformNames)if(t[o]){const s=n.getBinding(e,t[o],o);i.push({name:o,property:r,binding:s})}}return i}setUniforms(e,t,i,r){for(const{name:e,property:n,binding:o}of t)this.binders[n].setUniform(o,r,i.get(n),e)}updatePaintBuffers(e){this._buffers=[];for(const t in this.binders){const i=this.binders[t];if(e&&i instanceof ea){const t=2===e.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;t&&this._buffers.push(t)}else(i instanceof Ys||i instanceof Qs)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof Ys||i instanceof Qs||i instanceof ea)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Ys||t instanceof Qs||t instanceof ea)&&t.destroy()}}}class ia{constructor(e,t,i=(()=>!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ta(r,t,i);this.needsUpload=!1,this._featureMap=new Us,this._bufferOffset=0}populatePaintArrays(e,t,i,r,n,o,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r,n){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,n)||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 ra={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function na(e,t){return ra[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const oa={"line-pattern":{source:ts,composite:ts},"fill-pattern":{source:ts,composite:ts},"fill-extrusion-pattern":{source:ts,composite:ts},"line-dasharray":{source:is,composite:is}},sa={color:{source:ys,composite:xs},number:{source:ds,composite:ys}};function aa(e,t,i){const r=oa[e];return r&&r[i]||sa[t][i]}Yn("ConstantBinder",Ks),Yn("CrossFadedConstantBinder",Js),Yn("SourceExpressionBinder",Ys),Yn("CrossFadedCompositeBinder",ea),Yn("CompositeExpressionBinder",Qs),Yn("ProgramConfiguration",ta,{omit:["_buffers"]}),Yn("ProgramConfigurationSet",ia);const la="-transition";class ca extends Ct{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&&(e=e,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 Lo(t.layout)),t.paint)){this._transitionablePaint=new ko(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 Ro(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,i={}){if(null!=t){const r=`layers.${this.id}.layout.${e}`;if(this._validate(Zn,r,e,t,i))return}"visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t}getPaintProperty(e){return de(e,la)?this._transitionablePaint.getTransition(e.slice(0,-la.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t){const r=`layers.${this.id}.paint.${e}`;if(this._validate(Gn,r,e,t,i))return!1}if(de(e,la))return this._transitionablePaint.setTransition(e.slice(0,-la.length),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&e<this.minzoom)||(!!(this.maxzoom&&e>=this.maxzoom)||"none"===this.visibility)}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),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),fe(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&$n(this,e.call(Vn,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:zt,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 Bo&&jr(t.property.specification)&&(("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent))return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=fn(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ha=Ho([{name:"a_pos",components:2,type:"Int16"}],4),{members:ua,size:da,alignment:pa}=ha;class fa{constructor(e=[]){this.segments=e}prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>fa.MAX_VERTEX_ARRAY_LENGTH&&ge(`Max vertices per segment is ${fa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>fa.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new fa([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}fa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Yn("SegmentVector",fa);var ma=8192;class _a{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 ya?new ya(e.lng,e.lat):ya.convert(e),this}setSouthWest(e){return this._sw=e instanceof ya?new ya(e.lng,e.lat):ya.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof ya)r=e,n=e;else{if(!(e instanceof _a)){if(Array.isArray(e)){if(4===e.length||e.every(Array.isArray)){const t=e;return this.extend(_a.convert(t))}{const t=e;return this.extend(ya.convert(t))}}return this}if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new ya(r.lng,r.lat),this._ne=new ya(n.lng,n.lat)),this}getCenter(){return new ya((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 ya(this.getWest(),this.getNorth())}getSouthEast(){return new ya(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(e){const{lng:t,lat:i}=ya.convert(e),r=this._sw.lat<=i&&i<=this._ne.lat;let n=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=t&&t>=this._ne.lng),r&&n}static convert(e){return!e||e instanceof _a?e:new _a(e)}}const ga=6371008.8;class ya{constructor(e,t){if(isNaN(e)||isNaN(t))throw new Error(`Invalid LngLat object: (${e}, ${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 ya(ie(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return ga*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new _a(new ya(this.lng-i,this.lat-t),new ya(this.lng+i,this.lat+t))}static convert(e){if(e instanceof ya)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new ya(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new ya(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const xa=2*Math.PI*ga;function va(e){return xa*Math.cos(e*Math.PI/180)}function ba(e){return(180+e)/360}function wa(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Ta(e,t){return e/va(t)}function Ea(e){return 360*e-180}function Sa(e){const t=180-360*e;return 360/Math.PI*Math.atan(Math.exp(t*Math.PI/180))-90}function Ia(e,t){return e*va(Sa(t))}const Ma=85.051129;class Aa{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=ya.convert(e);return new Aa(ba(i.lng),wa(i.lat),Ta(t,i.lat))}toLngLat(){return new ya(Ea(this.x),Sa(this.y))}toAltitude(){return Ia(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/xa*(e=Sa(this.y),1/Math.cos(e*Math.PI/180));var e}}function Ca(e,t,i,r,o,s,a,l,c){const h=(t+r)/2,u=(i+o)/2,d=new n(h,u);l(d),function(e,t,i,r,n,o){const s=i-n,a=r-o;return Math.abs((r-t)*s-(i-e)*a)/Math.hypot(s,a)}(d.x,d.y,s.x,s.y,a.x,a.y)>=c?(Ca(e,t,i,h,u,s,d,l,c),Ca(e,h,u,r,o,d,a,l,c)):e.push(a)}function za(e,t,i){const r=[];let n,o,s;for(const a of e){const{x:e,y:l}=a;t(a),s?Ca(r,n,o,e,l,s,a,t,i):r.push(a),n=e,o=l,s=a}return r}const ka=Math.pow(2,14)-1,Pa=-ka-1;function Da(e,t){const i=Math.round(e.x*t),r=Math.round(e.y*t);return e.x=ee(i,Pa,ka),e.y=ee(r,Pa,ka),(i<e.x||i>e.x+1||r<e.y||r>e.y+1)&&ge("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function La(e,t,i){const r=e.loadGeometry(),n=e.extent,o=ma/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<<t.z,{scale:s,x:a,y:l,projection:c}=i,h=e=>{const i=Ea((t.x+e.x/n)/o),r=Sa((t.y+e.y/n)/o),h=c.project(i,r);e.x=(h.x*s-a)*n,e.y=(h.y*s-l)*n};for(let t=0;t<r.length;t++)if(1!==e.type)r[t]=za(r[t],h,1);else{const e=[];for(const i of r[t])i.x<0||i.x>=n||i.y<0||i.y>=n||(h(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)Da(t,o);return r}function Ba(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?La(e):[]}}function Ra(e,t,i,r,n){e.emplaceBack(2*t+(r+1)/2,2*i+(n+1)/2)}class Fa{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.layoutVertexArray=new Jo,this.indexArray=new cs,this.segments=new fa,this.programConfigurations=new ia(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ba(t,e);if(!this.layers[0]._featureFilter.filter(new Ao(this.zoom),c,i))continue;const h=s?s.evaluate(c,{},i):void 0,u={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:La(t,i,r),patterns:{},sortKey:h};o.push(u)}s&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,a=e[o].feature;this.addFeature(r,n,o,t.availableImages,i),t.featureIndex.insert(a,n,o,s,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ua),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())}addFeature(e,t,i,r,n){for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=ma||r<0||r>=ma)continue;const n=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),o=n.vertexLength;Ra(this.layoutVertexArray,i,r,-1,-1),Ra(this.layoutVertexArray,i,r,1,-1),Ra(this.layoutVertexArray,i,r,1,1),Ra(this.layoutVertexArray,i,r,-1,1),this.indexArray.emplaceBack(o,o+1,o+2),this.indexArray.emplaceBack(o,o+3,o+2),n.vertexLength+=4,n.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n)}}function Oa(e,t){for(let i=0;i<e.length;i++)if(Xa(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(Xa(e,t[i]))return!0;return!!ja(e,t)}function Ua(e,t,i){return!!Xa(e,t)||!!Za(t,e,i)}function Va(e,t){if(1===e.length)return qa(t,e[0]);for(let i=0;i<t.length;i++){const r=t[i];for(let t=0;t<r.length;t++)if(Xa(e,r[t]))return!0}for(let i=0;i<e.length;i++)if(qa(t,e[i]))return!0;for(let i=0;i<t.length;i++)if(ja(e,t[i]))return!0;return!1}function Na(e,t,i){if(e.length>1){if(ja(e,t))return!0;for(let r=0;r<t.length;r++)if(Za(t[r],e,i))return!0}for(let r=0;r<e.length;r++)if(Za(e[r],t,i))return!0;return!1}function ja(e,t){if(0===e.length||0===t.length)return!1;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++){if(Ga(r,n,t[e],t[e+1]))return!0}}return!1}function Ga(e,t,i,r){return ye(e,i,r)!==ye(t,i,r)&&ye(e,t,i)!==ye(e,t,r)}function Za(e,t,i){const r=i*i;if(1===t.length)return e.distSqr(t[0])<r;for(let i=1;i<t.length;i++){if($a(e,t[i-1],t[i])<r)return!0}return!1}function $a(e,t,i){const r=t.distSqr(i);if(0===r)return e.distSqr(t);const n=((e.x-t.x)*(i.x-t.x)+(e.y-t.y)*(i.y-t.y))/r;return n<0?e.distSqr(t):n>1?e.distSqr(i):e.distSqr(i.sub(t)._mult(n)._add(t))}function qa(e,t){let i,r,n,o=!1;for(let s=0;s<e.length;s++)for(let a=0,l=(i=e[s]).length-1;a<i.length;l=a++)r=i[a],n=i[l],r.y>t.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o);return o}function Xa(e,t){let i=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){const o=e[r],s=e[n];o.y>t.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Wa(e,t,i,r,o){for(const n of e)if(t<=n.x&&i<=n.y&&r>=n.x&&o>=n.y)return!0;const s=[new n(t,i),new n(t,o),new n(r,o),new n(r,i)];if(e.length>2)for(const t of s)if(Xa(e,t))return!0;for(let t=0;t<e.length-1;t++){if(Ha(e[t],e[t+1],s))return!0}return!1}function Ha(e,t,i){const r=i[0],n=i[2];if(e.x<r.x&&t.x<r.x||e.x>n.x&&t.x>n.x||e.y<r.y&&t.y<r.y||e.y>n.y&&t.y>n.y)return!1;const o=ye(e,t,i[0]);return o!==ye(e,t,i[1])||o!==ye(e,t,i[2])||o!==ye(e,t,i[3])}function Ka(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ja(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function Ya(e,t,i,r,o){if(!t[0]&&!t[1])return e;const s=n.convert(t)._mult(o);"viewport"===i&&s._rotate(-r);const a=[];for(let t=0;t<e.length;t++){const i=e[t];a.push(i.sub(s))}return a}function Qa(e,t,i,r){const o=n.convert(e)._mult(r);return"viewport"===t&&o._rotate(-i),o}Yn("CircleBucket",Fa,{omit:["layers"]});const el=new jo({"circle-sort-key":new Oo(zt.layout_circle["circle-sort-key"])});var tl={paint:new jo({"circle-radius":new Oo(zt.paint_circle["circle-radius"]),"circle-color":new Oo(zt.paint_circle["circle-color"]),"circle-blur":new Oo(zt.paint_circle["circle-blur"]),"circle-opacity":new Oo(zt.paint_circle["circle-opacity"]),"circle-translate":new Fo(zt.paint_circle["circle-translate"]),"circle-translate-anchor":new Fo(zt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new Fo(zt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new Fo(zt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Oo(zt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Oo(zt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Oo(zt.paint_circle["circle-stroke-opacity"])}),layout:el};class il{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,i){const r=A(t,this.dir);if(Math.abs(r)<1e-6)return!1;const n=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return i[0]=this.pos[0]+this.dir[0]*n,i[1]=this.pos[1]+this.dir[1]*n,i[2]=this.pos[2]+this.dir[2]*n,!0}closestPointOnSphere(e,t,i){if(function(e,t){var i=e[0],r=e[1],n=e[2],o=t[0],s=t[1],l=t[2];return Math.abs(i-o)<=a*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(r-s)<=a*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-l)<=a*Math.max(1,Math.abs(n),Math.abs(l))}(this.pos,e)||0===t)return i[0]=i[1]=i[2]=0,!1;const[r,n,o]=this.dir,s=this.pos[0]-e[0],l=this.pos[1]-e[1],c=this.pos[2]-e[2],h=r*r+n*n+o*o,u=2*(s*r+l*n+c*o),d=u*u-4*h*(s*s+l*l+c*c-t*t);if(d<0){const e=Math.max(-u/2,0),a=s+r*e,h=l+n*e,d=c+o*e,p=Math.hypot(a,h,d);return i[0]=a*t/p,i[1]=h*t/p,i[2]=d*t/p,!1}{const e=(-u-Math.sqrt(d))/(2*h);if(e<0){const e=Math.hypot(s,l,c);return i[0]=s*t/e,i[1]=l*t/e,i[2]=c*t/e,!1}return i[0]=s+r*e,i[1]=l+n*e,i[2]=c+o*e,!0}}}class rl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,i,r){const n=Math.pow(2,i),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(i=>{const o=F([],i,e),s=1/o[3]/t*n;return O(o,o,[s,s,r?1/o[3]:s,s])}),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=M([],C([],P([],o[e[0]],o[e[1]]),P([],o[e[2]],o[e[1]]))),i=-A(t,o[e[1]]);return t.concat(i)});return new rl(o,s)}}class nl{constructor(e,t){this.min=e,this.max=t,this.center=S([],b([],this.min,this.max),.5)}quadrant(e){const t=[e%2==0,e<2],i=y(this.min),r=y(this.max);for(let e=0;e<t.length;e++)i[e]=t[e]?this.min[e]:this.center[e],r[e]=t[e]?this.center[e]:this.max[e];return r[2]=this.max[2],new nl(i,r)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}distanceZ(e){return Math.max(Math.min(this.max[2],e[2]),this.min[2])-e[2]}getCorners(){const e=this.min,t=this.max;return[[e[0],e[1],e[2]],[t[0],e[1],e[2]],[t[0],t[1],e[2]],[e[0],t[1],e[2]],[e[0],e[1],t[2]],[t[0],e[1],t[2]],[t[0],t[1],t[2]],[e[0],t[1],t[2]]]}intersects(e){const t=this.getCorners();let i=!0;for(let r=0;r<e.planes.length;r++){const n=e.planes[r];let o=0;for(let e=0;e<t.length;e++)o+=A(n,t[e])+n[3]>=0;if(0===o)return 0;o!==t.length&&(i=!1)}if(i)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;n<e.points.length;n++){const o=e.points[n][t]-this.min[t];i=Math.min(i,o),r=Math.max(r,o)}if(r<0||i>this.max[t]-this.min[t])return 0}return 1}}function ol(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);for(const c of t)for(const t of c){const c=t.add(a),h=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(c.x,c.y,!0):0,u=o?c:sl(c,h,r),d=o?e.tilespaceRays.map(e=>cl(e,h)):e.queryGeometry.screenGeometry,p=F([],[t.x,t.y,h,1],r);if(!s&&o?l*=p[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/p[3]),Ua(d,u,l))return!0}return!1}function sl(e,t,i){const r=F([],[e.x,e.y,t,1],i);return new n(r[0]/r[3],r[1]/r[3])}const al=v(0,0,0),ll=v(0,0,1);function cl(e,t){const i=g();return al[2]=t,e.intersectsPlane(al,ll,i),new n(i[0],i[1])}class hl extends Fa{}function ul(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function dl(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;const n=ul({},{width:t,height:i},r);pl(e,n,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=n.data}function pl(e,t,i,r,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;for(let l=0;l<n.height;l++){const c=((i.y+l)*e.width+i.x)*o,h=((r.y+l)*t.width+r.x)*o;for(let e=0;e<n.width*o;e++)a[h+e]=s[c+e]}return t}Yn("HeatmapBucket",hl,{omit:["layers"]});class fl{constructor(e,t){ul(this,e,1,t)}resize(e){dl(this,e,1)}clone(){return new fl({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){pl(e,t,i,r,n,1)}}class ml{constructor(e,t){ul(this,e,4,t)}resize(e){dl(this,e,4)}replace(e,t){t?this.data.set(e):e instanceof Uint8ClampedArray?this.data=new Uint8Array(e.buffer):this.data=e}clone(){return new ml({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(e,t,i,r,n){pl(e,t,i,r,n,4)}}Yn("AlphaImage",fl),Yn("RGBAImage",ml);var _l={paint:new jo({"heatmap-radius":new Oo(zt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Oo(zt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Fo(zt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new No(zt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Fo(zt.paint_heatmap["heatmap-opacity"])})};function gl(e){const t={},i=e.resolution||256,r=e.clips?e.clips.length:1,n=e.image||new ml({width:i,height:r}),o=(i,r,o)=>{t[e.evaluationKey]=o;const s=e.expression.evaluate(t);n.data[i+r+0]=Math.floor(255*s.r/s.a),n.data[i+r+1]=Math.floor(255*s.g/s.a),n.data[i+r+2]=Math.floor(255*s.b/s.a),n.data[i+r+3]=Math.floor(255*s.a)};if(e.clips)for(let t=0,n=0;t<r;++t,n+=4*i)for(let r=0,s=0;r<i;r++,s+=4){const a=r/(i-1),{start:l,end:c}=e.clips[t];o(n,s,l*(1-a)+c*a)}else for(let e=0,t=0;e<i;e++,t+=4){o(0,t,e/(i-1))}return n}var yl={paint:new jo({"hillshade-illumination-direction":new Fo(zt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new Fo(zt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new Fo(zt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new Fo(zt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new Fo(zt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new Fo(zt.paint_hillshade["hillshade-accent-color"])})};const xl=Ho([{name:"a_pos",components:2,type:"Int16"}],4),{members:vl,size:bl,alignment:wl}=xl;var Tl=Sl,El=Sl;function Sl(e,t,i){i=i||2;var r,n,o,s,a,l,c,h=t&&t.length,u=h?t[0]*i:e.length,d=Il(e,0,u,i,!0),p=[];if(!d||d.next===d.prev)return p;if(h&&(d=function(e,t,i,r){var n,o,s,a,l,c=[];for(n=0,o=t.length;n<o;n++)s=t[n]*r,a=n<o-1?t[n+1]*r:e.length,(l=Il(e,s,a,r,!1))===l.next&&(l.steiner=!0),c.push(Fl(l));for(c.sort(Dl),n=0;n<c.length;n++)i=Ml(i=Ll(c[n],i),i.next);return i}(e,t,d,i)),e.length>80*i){r=o=e[0],n=s=e[1];for(var f=i;f<u;f+=i)(a=e[f])<r&&(r=a),(l=e[f+1])<n&&(n=l),a>o&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-r,s-n))?1/c:0}return Al(d,p,i,r,n,c),p}function Il(e,t,i,r,n){var o,s;if(n===Kl(e,t,i,r)>0)for(o=t;o<i;o+=r)s=Xl(o,e[o],e[o+1],s);else for(o=i-r;o>=t;o-=r)s=Xl(o,e[o],e[o+1],s);return s&&Nl(s,s.next)&&(Wl(s),s=s.next),s}function Ml(e,t){if(!e)return e;t||(t=e);var i,r=e;do{if(i=!1,r.steiner||!Nl(r,r.next)&&0!==Vl(r.prev,r,r.next))r=r.next;else{if(Wl(r),(r=t=r.prev)===r.next)break;i=!0}}while(i||r!==t);return t}function Al(e,t,i,r,n,o,s){if(e){!s&&o&&function(e,t,i,r){var n=e;do{null===n.z&&(n.z=Rl(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){var t,i,r,n,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;t<c&&(a++,r=r.nextZ);t++);for(l=c;a>0||l>0&&r;)0!==a&&(0===l||!r||i.z<=r.z)?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(s>1)}(n)}(e,r,n,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?zl(e,r,n,o):Cl(e))t.push(a.i/i),t.push(e.i/i),t.push(l.i/i),Wl(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?Al(e=kl(Ml(e),t,i),t,i,r,n,o,2):2===s&&Pl(e,t,i,r,n,o):Al(Ml(e),t,i,r,n,o,1);break}}}function Cl(e){var t=e.prev,i=e,r=e.next;if(Vl(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(Ol(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&Vl(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function zl(e,t,i,r){var n=e.prev,o=e,s=e.next;if(Vl(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,l=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,c=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,h=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,u=Rl(a,l,t,i,r),d=Rl(c,h,t,i,r),p=e.prevZ,f=e.nextZ;p&&p.z>=u&&f&&f.z<=d;){if(p!==e.prev&&p!==e.next&&Ol(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Vl(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==e.prev&&f!==e.next&&Ol(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Vl(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=u;){if(p!==e.prev&&p!==e.next&&Ol(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&Vl(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&Ol(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Vl(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function kl(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!Nl(n,o)&&jl(n,r,r.next,o)&&$l(n,o)&&$l(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),Wl(r),Wl(r.next),r=e=o),r=r.next}while(r!==e);return Ml(r)}function Pl(e,t,i,r,n,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&Ul(s,a)){var l=ql(s,a);return s=Ml(s,s.next),l=Ml(l,l.next),Al(s,t,i,r,n,o),void Al(l,t,i,r,n,o)}a=a.next}s=s.next}while(s!==e)}function Dl(e,t){return e.x-t.x}function Ll(e,t){var i=function(e,t){var i,r=t,n=e.x,o=e.y,s=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!i)return null;if(n===s)return i;var l,c=i,h=i.x,u=i.y,d=1/0;r=i;do{n>=r.x&&r.x>=h&&n!==r.x&&Ol(o<u?n:s,o,h,u,o<u?s:n,o,r.x,r.y)&&(l=Math.abs(o-r.y)/(n-r.x),$l(r,e)&&(l<d||l===d&&(r.x>i.x||r.x===i.x&&Bl(i,r)))&&(i=r,d=l)),r=r.next}while(r!==c);return i}(e,t);if(!i)return t;var r=ql(i,e),n=Ml(i,i.next);return Ml(r,r.next),t===i?n:t}function Bl(e,t){return Vl(e.prev,e,t.prev)<0&&Vl(t.next,e,e.next)<0}function Rl(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Fl(e){var t=e,i=e;do{(t.x<i.x||t.x===i.x&&t.y<i.y)&&(i=t),t=t.next}while(t!==e);return i}function Ol(e,t,i,r,n,o,s,a){return(n-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function Ul(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&($l(e,t)&&$l(t,e)&&function(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(Vl(e.prev,e,t.prev)||Vl(e,t.prev,t))||Nl(e,t)&&Vl(e.prev,e,e.next)>0&&Vl(t.prev,t,t.next)>0)}function Vl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Nl(e,t){return e.x===t.x&&e.y===t.y}function jl(e,t,i,r){var n=Zl(Vl(e,t,i)),o=Zl(Vl(e,t,r)),s=Zl(Vl(i,r,e)),a=Zl(Vl(i,r,t));return n!==o&&s!==a||(!(0!==n||!Gl(e,i,t))||(!(0!==o||!Gl(e,r,t))||(!(0!==s||!Gl(i,e,r))||!(0!==a||!Gl(i,t,r)))))}function Gl(e,t,i){return t.x<=Math.max(e.x,i.x)&&t.x>=Math.min(e.x,i.x)&&t.y<=Math.max(e.y,i.y)&&t.y>=Math.min(e.y,i.y)}function Zl(e){return e>0?1:e<0?-1:0}function $l(e,t){return Vl(e.prev,e,e.next)<0?Vl(e,t,e.next)>=0&&Vl(e,e.prev,t)>=0:Vl(e,t,e.prev)<0||Vl(e,e.next,t)<0}function ql(e,t){var i=new Hl(e.i,e.x,e.y),r=new Hl(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Xl(e,t,i,r){var n=new Hl(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Wl(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 Hl(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Kl(e,t,i,r){for(var n=0,o=t,s=i-r;o<i;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}function Jl(e,t,i,r,n){!function e(t,i,r,n,o){for(;n>r;){if(n-r>600){var s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1),u=Math.max(r,Math.floor(i-a*c/s+h)),d=Math.min(n,Math.floor(i+(s-a)*c/s+h));e(t,i,u,d,o)}var p=t[i],f=r,m=n;for(Yl(t,r,i),o(t[n],p)>0&&Yl(t,r,n);f<m;){for(Yl(t,f,m),f++,m--;o(t[f],p)<0;)f++;for(;o(t[m],p)>0;)m--}0===o(t[r],p)?Yl(t,r,m):Yl(t,++m,n),m<=i&&(r=m+1),i<=m&&(n=m-1)}}(e,t,i||0,r||e.length-1,n||Ql)}function Yl(e,t,i){var r=e[t];e[t]=e[i],e[i]=r}function Ql(e,t){return e<t?-1:e>t?1:0}function ec(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t<i;t++){const i=xe(e[t]);0!==i&&(e[t].area=Math.abs(i),void 0===o&&(o=i<0),o===i<0?(n&&r.push(n),n=[e[t]]):n.push(e[t]))}if(n&&r.push(n),t>1)for(let e=0;e<r.length;e++)r[e].length<=t||(Jl(r[e],t,1,r[e].length-1,tc),r[e]=r[e].slice(0,t));return r}function tc(e,t){return t.area-e.area}function ic(e,t,i){const r=i.patternDependencies;let n=!1;for(const i of t){const t=i.paint.get(`${e}-pattern`);t.isConstant()||(n=!0);const o=t.constantOr(null);o&&(n=!0,r[o.to]=!0,r[o.from]=!0)}return n}function rc(e,t,i,r,n){const o=n.patternDependencies;for(const s of t){const t=s.paint.get(`${e}-pattern`).value;if("constant"!==t.kind){let e=t.evaluate({zoom:r-1},i,{},n.availableImages),a=t.evaluate({zoom:r},i,{},n.availableImages),l=t.evaluate({zoom:r+1},i,{},n.availableImages);e=e&&e.name?e.name:e,a=a&&a.name?a.name:a,l=l&&l.name?l.name:l,o[e]=!0,o[a]=!0,o[l]=!0,i.patterns[s.id]={min:e,mid:a,max:l}}}return i}Sl.deviation=function(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(Kl(e,0,o,i));if(n)for(var a=0,l=t.length;a<l;a++){var c=t[a]*i,h=a<l-1?t[a+1]*i:e.length;s-=Math.abs(Kl(e,c,h,i))}var u=0;for(a=0;a<r.length;a+=3){var d=r[a]*i,p=r[a+1]*i,f=r[a+2]*i;u+=Math.abs((e[d]-e[f])*(e[p+1]-e[d+1])-(e[d]-e[p])*(e[f+1]-e[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},Sl.flatten=function(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var s=0;s<t;s++)i.vertices.push(e[n][o][s]);n>0&&(r+=e[n-1].length,i.holes.push(r))}return i},Tl.default=El;const nc=500;class oc{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.patternFeatures=[],this.layoutVertexArray=new Jo,this.indexArray=new cs,this.indexArray2=new _s,this.programConfigurations=new ia(e.layers,e.zoom),this.segments=new fa,this.segments2=new fa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i,r){this.hasPattern=ic("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,h=Ba(s,e);if(!this.layers[0]._featureFilter.filter(new Ao(this.zoom),h,i))continue;const u=n?n.evaluate(h,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?h.geometry:La(s,i,r),patterns:{},sortKey:u};o.push(d)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=rc("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages);const a=e[o].feature;t.featureIndex.insert(a,n,o,s,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,vl),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,i,r,n,o=[]){for(const e of ec(t,nc)){let t=0;for(const i of e)t+=i.length;const i=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=i.vertexLength,n=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(n.length/2);const i=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=i.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),n.push(t[0].x),n.push(t[0].y);for(let e=1;e<t.length;e++)this.layoutVertexArray.emplaceBack(t[e].x,t[e].y),this.indexArray2.emplaceBack(r+e-1,r+e),n.push(t[e].x),n.push(t[e].y);i.vertexLength+=t.length,i.primitiveLength+=t.length}const s=Tl(n,o);for(let e=0;e<s.length;e+=3)this.indexArray.emplaceBack(r+s[e],r+s[e+1],r+s[e+2]);i.vertexLength+=t,i.primitiveLength+=s.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}}Yn("FillBucket",oc,{omit:["layers","patternFeatures"]});const sc=new jo({"fill-sort-key":new Oo(zt.layout_fill["fill-sort-key"])});var ac={paint:new jo({"fill-antialias":new Fo(zt.paint_fill["fill-antialias"]),"fill-opacity":new Oo(zt.paint_fill["fill-opacity"]),"fill-color":new Oo(zt.paint_fill["fill-color"]),"fill-outline-color":new Oo(zt.paint_fill["fill-outline-color"]),"fill-translate":new Fo(zt.paint_fill["fill-translate"]),"fill-translate-anchor":new Fo(zt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Uo(zt.paint_fill["fill-pattern"])}),layout:sc};const lc=Ho([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),cc=Ho([{name:"a_centroid_pos",components:2,type:"Uint16"}]),{members:hc,size:uc,alignment:dc}=lc;var pc=fc;function fc(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(mc,this,t)}function mc(e,t,i){1==e?t.id=i.readVarint():2==e?function(e,t){var i=e.readVarint()+e.pos;for(;e.pos<i;){var r=t._keys[e.readVarint()],n=t._values[e.readVarint()];t.properties[r]=n}}(i,t):3==e?t.type=i.readVarint():4==e&&(t._geometry=i.pos)}function _c(e){for(var t,i,r=0,n=0,o=e.length,s=o-1;n<o;s=n++)t=e[n],r+=((i=e[s]).x-t.x)*(t.y+i.y);return r}fc.types=["Unknown","Point","LineString","Polygon"],fc.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,i=e.readVarint()+e.pos,r=1,o=0,s=0,a=0,l=[];e.pos<i;){if(o<=0){var c=e.readVarint();r=7&c,o=c>>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(t&&l.push(t),t=[]),t.push(new n(s,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&l.push(t),l},fc.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;e.pos<t;){if(r<=0){var h=e.readVarint();i=7&h,r=h>>3}if(r--,1===i||2===i)(n+=e.readSVarint())<s&&(s=n),n>a&&(a=n),(o+=e.readSVarint())<l&&(l=o),o>c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},fc.prototype.toGeoJSON=function(e,t,i){var r,n,o=this.extent*Math.pow(2,i),s=this.extent*e,a=this.extent*t,l=this.loadGeometry(),c=fc.types[this.type];function h(e){for(var t=0;t<e.length;t++){var i=e[t],r=180-360*(i.y+a)/o;e[t]=[360*(i.x+s)/o-180,360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90]}}switch(this.type){case 1:var u=[];for(r=0;r<l.length;r++)u[r]=l[r][0];h(l=u);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(e){var t=e.length;if(t<=1)return[e];for(var i,r,n=[],o=0;o<t;o++){var s=_c(e[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(i&&n.push(i),i=[e[o]]):i.push(e[o]))}i&&n.push(i);return n}(l),r=0;r<l.length;r++)for(n=0;n<l[r].length;n++)h(l[r][n])}1===l.length?l=l[0]:c="Multi"+c;var d={type:"Feature",geometry:{type:c,coordinates:l},properties:this.properties};return"id"in this&&(d.id=this.id),d};var gc=yc;function yc(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(xc,this,t),this.length=this._features.length}function xc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){var t=null,i=e.readVarint()+e.pos;for(;e.pos<i;){var r=e.readVarint()>>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(i))}function vc(e,t,i){if(3===e){var r=new gc(i,i.readVarint()+i.pos);r.length&&(t[r.name]=r)}}yc.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 pc(this._pbf,t,this.extent,this._keys,this._values)};var bc={VectorTile:function(e,t){this.layers=e.readFields(vc,{},t)},VectorTileFeature:pc,VectorTileLayer:gc};const wc=bc.VectorTileFeature.types,Tc=500,Ec=Math.pow(2,13),Sc=7,Ic=450;function Mc(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*Ec)<<1)+n,Math.round(a))}class Ac{constructor(){this.acc=new n(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new n(e.x,e.y),this.max=new n(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);let i=!!this.borders;const r=this.min,n=this.max;e.x<r.x?(r.x=e.x,i=!0):e.x>n.x&&(n.x=e.x,i=!0),e.y<r.y?(r.y=e.y,i=!0):e.y>n.y&&(n.y=e.y,i=!0),((0===e.x||e.x===ma)&&e.x===t.x)!=((0===e.y||e.y===ma)&&e.y===t.y)&&this.processBorderOverlap(e,t),i&&this.checkBorderIntersection(e,t)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,Wi(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>ma!=e.x>ma&&this.addBorderIntersection(1,Wi(t.y,e.y,(ma-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Wi(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>ma!=e.y>ma&&this.addBorderIntersection(3,Wi(t.x,e.x,(ma-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 i=this.borders[e];t<i[0]&&(i[0]=t),t>i[1]&&(i[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const i=0===e.x?0:1;this.addBorderIntersection(i,t.y),this.addBorderIntersection(i,e.y)}else{const i=0===e.y?2:3;this.addBorderIntersection(i,t.x),this.addBorderIntersection(i,e.x)}}centroid(){const e=this.polyCount.reduce((e,t)=>e+t.edges,0);return 0!==e?this.acc.div(e)._round():new n(0,0)}span(){return new n(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0)}}class Cc{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.layoutVertexArray=new Yo,this.centroidVertexArray=new ks,this.indexArray=new cs,this.programConfigurations=new ia(e.layers,e.zoom),this.segments=new fa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.enableTerrain=e.enableTerrain}populate(e,t,i,r){this.features=[],this.hasPattern=ic("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(e){const t=e.y/(1<<e.z),i=Math.exp(Math.PI*(1-2*t));return 80150034*i/(i*i+1)/ma/(1<<e.z)}(i);for(const{feature:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ba(n,e);if(!this.layers[0]._featureFilter.filter(new Ao(this.zoom),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:La(n,i,r),properties:n.properties,type:n.type,patterns:{}},h=this.layoutVertexArray.length;this.hasPattern?this.features.push(rc("fill-extrusion",this.layers,c,this.zoom,t)):this.addFeature(c,c.geometry,s,i,{},t.availableImages),t.featureIndex.insert(n,c.geometry,s,a,this.index,h)}this.sortBorders()}addFeatures(e,t,i,r){for(const e of this.features){const{geometry:n}=e;this.addFeature(e,n,e.index,t,i,r)}this.sortBorders()}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}uploadCentroid(e){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,cc.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,n,o){const s=this.enableTerrain?new Ac:null;for(const i of ec(t,Tc)){let t=0,r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);if(0===i.length||((a=i[0]).every(e=>e.x<=0)||a.every(e=>e.x>=ma)||a.every(e=>e.y<=0)||a.every(e=>e.y>=ma)))continue;for(let e=0;e<i.length;e++){const n=i[e];if(0===n.length)continue;t+=n.length;let o=0;s&&s.startRing(n[0]);for(let e=0;e<n.length;e++){const t=n[e];if(e>=1){const i=n[e-1];if(!zc(t,i)){s&&s.append(t,i),r.vertexLength+4>fa.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const e=t.sub(i)._perp(),n=e.x/(Math.abs(e.x)+Math.abs(e.y)),a=e.y>0?1:0,l=i.dist(t);o+l>32768&&(o=0),Mc(this.layoutVertexArray,t.x,t.y,n,a,0,0,o),Mc(this.layoutVertexArray,t.x,t.y,n,a,0,1,o),o+=l,Mc(this.layoutVertexArray,i.x,i.y,n,a,0,0,o),Mc(this.layoutVertexArray,i.x,i.y,n,a,0,1,o);const c=r.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),r.vertexLength+=4,r.primitiveLength+=2}}}}if(r.vertexLength+t>fa.MAX_VERTEX_ARRAY_LENGTH&&(r=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray)),"Polygon"!==wc[e.type])continue;const n=[],o=[],l=r.vertexLength;for(let e=0;e<i.length;e++){const t=i[e];if(0!==t.length){t!==i[0]&&o.push(n.length/2);for(let e=0;e<t.length;e++){const i=t[e];Mc(this.layoutVertexArray,i.x,i.y,0,0,1,1,0),n.push(i.x),n.push(i.y),s&&s.currentPolyCount.top++}}}const c=Tl(n,o);for(let e=0;e<c.length;e+=3)this.indexArray.emplaceBack(l+c[e],l+c[e+2],l+c[e+1]);r.primitiveLength+=c.length/3,r.vertexLength+=t}var a;if(s&&s.polyCount.length>0){if(s.borders){s.vertexArrayOffset=this.centroidVertexArray.length;const e=s.borders,t=this.featuresOnBorder.push(s)-1;for(let i=0;i<4;i++)e[i][0]!==Number.MAX_VALUE&&this.borders[i].push(t)}this.encodeCentroid(s.borders?void 0:s.centroid(),s)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((t,i)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}encodeCentroid(e,t,i=!0){let r,n;if(e)if(0!==e.y){const i=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(i.x/10)),n=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else r=Math.ceil((e.x+Ic)*Sc),n=0;else r=0,n=+i;let o=i?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;t<2*e.edges;t++)this.centroidVertexArray.emplace(o++,0,n),this.centroidVertexArray.emplace(o++,r,n);for(let t=0;t<e.top;t++)this.centroidVertexArray.emplace(o++,r,n)}}}function zc(e,t){return e.x===t.x&&(e.x<0||e.x>ma)||e.y===t.y&&(e.y<0||e.y>ma)}Yn("FillExtrusionBucket",Cc,{omit:["layers","features"]}),Yn("PartMetadata",Ac);var kc={paint:new jo({"fill-extrusion-opacity":new Fo(zt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Oo(zt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Fo(zt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Fo(zt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Uo(zt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Oo(zt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Oo(zt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Fo(zt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Pc(e,t){return e.x*t.x+e.y*t.y}function Dc(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(!(n=t[i++]))return 1/0;for(;i<t.length;i++){const o=t[i],s=e[0],a=n.sub(r),l=o.sub(r),c=s.sub(r),h=Pc(a,a),u=Pc(a,l),d=Pc(l,l),p=Pc(c,a),f=Pc(c,l),m=h*d-u*u,_=(d*p-u*f)/m,g=(h*f-u*p)/m,y=1-_-g,x=r.z*y+n.z*_+o.z*g;if(isFinite(x))return x}return 1/0}{let e=1/0;for(const i of t)e=Math.min(e,i.z);return e}}function Lc(e){const t=new n(e[0],e[1]);return t.z=e[2],t}function Bc(e,t,i,r,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],h=c?0===o[1]?s*(o[0]/Sc-Ic):s*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),s=10*(t[1]-8*n),a=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),h=Math.floor(.5*(s*l-1)),u=e.tileCoordToPixel(r,n),d=2*c+1,p=2*h+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,u.x-c,u.y-h,d,p),m=Math.abs(f[0]-f[1]),_=Math.abs(f[2]-f[3]),g=Math.abs(f[0]-f[2]),y=Math.abs(f[1]-f[3]),x=m+_,v=g+y,b=Math.min(.25,.5*l*x/d),w=Math.min(.25,.5*l*v/p);return a+Math.max(b*o,w*s)}(n,o,a):l;return{base:l+(0===i)?-1:i,top:c?Math.max(h+r,l+i+2):l+r}}const Rc=Ho([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:Fc,size:Oc,alignment:Uc}=Rc,Vc=Ho([{name:"a_packed",components:3,type:"Float32"}]),{members:Nc,size:jc,alignment:Gc}=Vc,Zc=bc.VectorTileFeature.types,$c=63,qc=Math.cos(Math.PI/180*37.5),Xc=15,Wc=20;class Hc{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.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new Qo,this.layoutVertexArray2=new es,this.indexArray=new cs,this.programConfigurations=new ia(e.layers,e.zoom),this.segments=new fa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i,r){this.hasPattern=ic("line",this.layers,t);const n=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ba(t,e);if(!this.layers[0]._featureFilter.filter(new Ao(this.zoom),c,i))continue;const h=n?n.evaluate(c,{},i):void 0,u={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:La(t,i,r),patterns:{},sortKey:h};o.push(u)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:s,featureIndex:a}=t,l=this.addConstantDashes(s);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:c}=r;if(l&&this.addFeatureDashes(r,s),this.hasPattern){const e=rc("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,s.positions,t.availableImages);const h=e[o].feature;a.insert(h,n,o,c,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i.from,t),e.addDash(i.to,t),i.other&&e.addDash(i.other,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a,l,c,h,u;if("constant"===n.kind){const e=n.value;if(!e)continue;s=e.other||e.to,a=e.to,l=e.from}else s=n.evaluate({zoom:i-1},e),a=n.evaluate({zoom:i},e),l=n.evaluate({zoom:i+1},e);"constant"===o.kind?c=h=u=o.value:(c=o.evaluate({zoom:i-1},e),h=o.evaluate({zoom:i},e),u=o.evaluate({zoom:i+1},e)),t.addDash(s,c),t.addDash(a,h),t.addDash(l,u);const d=t.getKey(s,c),p=t.getKey(a,h),f=t.getKey(l,u);e.patterns[r.id]={min:d,mid:p,max:f}}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,i,r)}addFeatures(e,t,i,r){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r)}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,Nc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Fc),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,i,r,n,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(e,{}),l=s.get("line-cap").evaluate(e,{}),c=s.get("line-miter-limit"),h=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,a,l,c,h);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r)}addLine(e,t,i,r,n,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t<e.length-1;t++)this.totalDistance+=e[t].dist(e[t+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const s="Polygon"===Zc[t.type];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;let l=0;for(;l<a-1&&e[l].equals(e[l+1]);)l++;if(a<(s?3:2))return;"bevel"===i&&(n=1.05);const c=this.overscaling<=16?Xc*ma/(512*this.overscaling):0,h=this.segments.prepareSegment(10*a,this.layoutVertexArray,this.indexArray);let u,d=void 0,p=void 0,f=void 0,m=void 0;this.e1=this.e2=-1,s&&(u=e[a-2],m=e[l].sub(u)._unit()._perp());for(let t=l;t<a;t++){if((p=t===a-1?s?e[l+1]:void 0:e[t+1])&&e[t].equals(p))continue;m&&(f=m),u&&(d=u),u=e[t],m=p?p.sub(u)._unit()._perp():f;let _=(f=f||m).add(m);0===_.x&&0===_.y||_._unit();const g=f.x*m.x+f.y*m.y,y=_.x*m.x+_.y*m.y,x=0!==y?1/y:1/0,v=2*Math.sqrt(2-2*y),b=y<qc&&d&&p,w=f.x*m.y-f.y*m.x>0;if(b&&t>l){const e=u.dist(d);if(e>2*c){const t=u.sub(u.sub(d)._mult(c/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,f,0,0,h),d=t}}const T=d&&p;let E=T?i:s?"butt":r;if(T&&"round"===E&&(x<o?E="miter":x<=2&&(E="fakeround")),"miter"===E&&x>n&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x<n&&(E="miter")),d&&this.updateDistance(d,u),"miter"===E)_._mult(x),this.addCurrentVertex(u,_,0,0,h);else if("flipbevel"===E){if(x>100)_=m.mult(-1);else{const e=x*f.add(m).mag()/f.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(u,_,0,0,h),this.addCurrentVertex(u,_.mult(-1),0,0,h)}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(x*x-1),t=w?e:0,i=w?0:e;if(d&&this.addCurrentVertex(u,f,t,i,h),"fakeround"===E){const e=Math.round(180*v/Math.PI/Wc);for(let t=1;t<e;t++){let i=t/e;if(.5!==i){const e=i-.5;i+=i*e*(i-1)*((1.0904+g*(g*(3.55645-1.43519*g)-3.2452))*e*e+(.848013+g*(.215638*g-1.06021)))}const r=m.sub(f)._mult(i)._add(f)._unit()._mult(w?-1:1);this.addHalfVertex(u,r.x,r.y,!1,w,0,h)}}p&&this.addCurrentVertex(u,m,-t,-i,h)}else if("butt"===E)this.addCurrentVertex(u,_,0,0,h);else if("square"===E){const e=d?1:-1;d||this.addCurrentVertex(u,_,e,e,h),this.addCurrentVertex(u,_,0,0,h),d&&this.addCurrentVertex(u,_,e,e,h)}else"round"===E&&(d&&(this.addCurrentVertex(u,f,0,0,h),this.addCurrentVertex(u,f,1,1,h,!0)),p&&(this.addCurrentVertex(u,m,-1,-1,h,!0),this.addCurrentVertex(u,m,0,0,h)));if(b&&t<a-1){const e=u.dist(p);if(e>2*c){const t=u.add(p.sub(u)._mult(c/e)._round());this.updateDistance(u,t),this.addCurrentVertex(t,m,0,0,h),u=t}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.x+t.y*i,a=t.y-t.x*i,l=-t.x+t.y*r,c=-t.y-t.x*r;this.addHalfVertex(e,s,a,o,!1,i,n),this.addHalfVertex(e,l,c,o,!0,-r,n)}addHalfVertex({x:e,y:t},i,r,n,o,s,a){this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round($c*i)+128,Math.round($c*r)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.lineClips.end-this.lineClips.start,t=this.totalDistance/e;this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}Yn("LineBucket",Hc,{omit:["layers","patternFeatures"]});const Kc=new jo({"line-cap":new Oo(zt.layout_line["line-cap"]),"line-join":new Oo(zt.layout_line["line-join"]),"line-miter-limit":new Fo(zt.layout_line["line-miter-limit"]),"line-round-limit":new Fo(zt.layout_line["line-round-limit"]),"line-sort-key":new Oo(zt.layout_line["line-sort-key"])});var Jc={paint:new jo({"line-opacity":new Oo(zt.paint_line["line-opacity"]),"line-color":new Oo(zt.paint_line["line-color"]),"line-translate":new Fo(zt.paint_line["line-translate"]),"line-translate-anchor":new Fo(zt.paint_line["line-translate-anchor"]),"line-width":new Oo(zt.paint_line["line-width"]),"line-gap-width":new Oo(zt.paint_line["line-gap-width"]),"line-offset":new Oo(zt.paint_line["line-offset"]),"line-blur":new Oo(zt.paint_line["line-blur"]),"line-dasharray":new Uo(zt.paint_line["line-dasharray"]),"line-pattern":new Uo(zt.paint_line["line-pattern"]),"line-gradient":new No(zt.paint_line["line-gradient"])}),layout:Kc};const Yc=new class extends Oo{possiblyEvaluate(e,t){return t=new Ao(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=oe({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}(Jc.paint.properties["line-width"].specification);Yc.useIntegerZoom=!0;function Qc(e,t){return t>0?t+2*e:e}const eh=Ho([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_z_tile_anchor",components:4,type:"Int16"}],4),th=Ho([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ho([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ih=Ho([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),rh=Ho([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ho([{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 nh=Ho([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),oh=Ho([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ho([{name:"triangle",components:3,type:"Uint16"}]),Ho([{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"}]),Ho([{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"}]),Ho([{type:"Float32",name:"offsetX"}]),Ho([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);var sh=24;const ah=128;function lh(e,t){const{expression:i}=t;if("constant"===i.kind){return{kind:"constant",layoutSize:i.evaluate(new Ao(e+1))}}if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;n<t.length&&t[n]<=e;)n++;let o=n=Math.max(0,n-1);for(;o<t.length&&t[o]<e+1;)o++;o=Math.min(t.length-1,o);const s=t[n],a=t[o];return"composite"===i.kind?{kind:"composite",minZoom:s,maxZoom:a,interpolationType:r}:{kind:"camera",minZoom:s,maxZoom:a,minSize:i.evaluate(new Ao(s)),maxSize:i.evaluate(new Ao(a)),interpolationType:r}}}function ch(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/ah:"composite"===e.kind?Wi(r/ah,n/ah,i):t}function hh(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=e,a=n?ee(mr.interpolationFactor(n,t,o,s),0,1):0;"camera"===e.kind?r=Wi(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:r}}var uh=Object.freeze({__proto__:null,getSizeData:lh,evaluateSizeForFeature:ch,evaluateSizeForZoom:hh,SIZE_PACK_FACTOR:ah});function dh(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)}),e}const ph={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function fh(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function mh(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var _h=function(e,t,i,r,n){var o,s,a=8*n-r-1,l=(1<<a)-1,c=l>>1,h=-7,u=i?n-1:0,d=i?-1:1,p=e[t+u];for(u+=d,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+e[t+u],u+=d,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+e[t+u],u+=d,h-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=c}return(p?-1:1)*s*Math.pow(2,o-r)},gh=function(e,t,i,r,n,o){var s,a,l,c=8*o-n-1,h=(1<<c)-1,u=h>>1,d=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=h):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+u>=1?d/l:d*Math.pow(2,1-u))*l>=2&&(s++,l/=2),s+u>=h?(a=0,s=h):s+u>=1?(a=(t*l-1)*Math.pow(2,n),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,n),s=0));n>=8;e[i+p]=255&a,p+=f,a/=256,n-=8);for(s=s<<n|a,c+=n;c>0;e[i+p]=255&s,p+=f,s/=256,c-=8);e[i+p-f]|=128*m},yh=xh;function xh(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}xh.Varint=0,xh.Fixed64=1,xh.Bytes=2,xh.Fixed32=5;var vh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function bh(e){return e.type===xh.Bytes?e.readVarint()+e.pos:e.pos+1}function wh(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Th(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function Eh(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function Sh(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function Ih(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function Mh(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function Ah(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function Ch(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function zh(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function kh(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function Ph(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function Dh(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function Lh(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function Bh(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}xh.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),n=r>>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Dh(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Bh(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Dh(this.buf,this.pos)+4294967296*Dh(this.buf,this.pos+4);return this.pos+=8,e},readSFixed64:function(){var e=Dh(this.buf,this.pos)+4294967296*Bh(this.buf,this.pos+4);return this.pos+=8,e},readFloat:function(){var e=_h(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=_h(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(n=o[i.pos++],r=(112&n)>>4,n<128)return wh(e,r,t);if(n=o[i.pos++],r|=(127&n)<<3,n<128)return wh(e,r,t);if(n=o[i.pos++],r|=(127&n)<<10,n<128)return wh(e,r,t);if(n=o[i.pos++],r|=(127&n)<<17,n<128)return wh(e,r,t);if(n=o[i.pos++],r|=(127&n)<<24,n<128)return wh(e,r,t);if(n=o[i.pos++],r|=(1&n)<<31,n<128)return wh(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[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&&vh?function(e,t,i){return vh.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){var r="",n=t;for(;n<i;){var o,s,a,l=e[n],c=null,h=l>239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(o=e[n+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===h?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,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!==xh.Bytes)return e.push(this.readVarint(t));var i=bh(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==xh.Bytes)return e.push(this.readSVarint());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==xh.Bytes)return e.push(this.readBoolean());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==xh.Bytes)return e.push(this.readFloat());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==xh.Bytes)return e.push(this.readDouble());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==xh.Bytes)return e.push(this.readFixed32());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==xh.Bytes)return e.push(this.readSFixed32());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==xh.Bytes)return e.push(this.readFixed64());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==xh.Bytes)return e.push(this.readSFixed64());var t=bh(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===xh.Varint)for(;this.buf[this.pos++]>127;);else if(t===xh.Bytes)this.pos=this.readVarint()+this.pos;else if(t===xh.Fixed32)this.pos+=4;else{if(t!==xh.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;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Lh(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Lh(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Lh(this.buf,-1&e,this.pos),Lh(this.buf,Math.floor(e*(1/4294967296)),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Lh(this.buf,-1&e,this.pos),Lh(this.buf,Math.floor(e*(1/4294967296)),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos]=127&e}(i,0,t),function(e,t){var i=(7&e)<<4;if(t.buf[t.pos++]|=i|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,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,i){for(var r,n,o=0;o<t.length;o++){if((r=t.charCodeAt(o))>55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&Th(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),gh(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),gh(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 i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&Th(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,xh.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Eh,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Sh,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Ah,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Ih,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Mh,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Ch,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,zh,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,kh,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Ph,t)},writeBytesField:function(e,t){this.writeTag(e,xh.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,xh.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,xh.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,xh.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,xh.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,xh.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,xh.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,xh.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,xh.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,xh.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};const Rh=3;function Fh(e,t,i){t.glyphs=[],1===e&&i.readMessage(Oh,t)}function Oh(e,t,i){if(3===e){const{id:e,bitmap:r,width:n,height:o,left:s,top:a,advance:l}=i.readMessage(Uh,{});t.glyphs.push({id:e,bitmap:new fl({width:n+2*Rh,height:o+2*Rh},r),metrics:{width:n,height:o,left:s,top:a,advance:l}})}else 4===e?t.ascender=i.readSVarint():5===e&&(t.descender=i.readSVarint())}function Uh(e,t,i){1===e?t.id=i.readVarint():2===e?t.bitmap=i.readBytes():3===e?t.width=i.readVarint():4===e?t.height=i.readVarint():5===e?t.left=i.readSVarint():6===e?t.top=i.readSVarint():7===e&&(t.advance=i.readVarint())}const Vh=Rh;function Nh(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();e<r.length&&(r[e]=t)}else t.h===i.h?(i.x+=t.w,i.w-=t.w):t.w===i.w?(i.y+=t.h,i.h-=t.h):(r.push({x:i.x+t.w,y:i.y,w:i.w-t.w,h:t.h}),i.y+=t.h,i.h-=t.h);break}}return{w:n,h:o,fill:t/(n*o)||0}}const jh=1;class Gh{constructor(e,{pixelRatio:t,version:i,stretchX:r,stretchY:n,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=n,this.content=o,this.version=i}get tl(){return[this.paddedRect.x+jh,this.paddedRect.y+jh]}get br(){return[this.paddedRect.x+this.paddedRect.w-jh,this.paddedRect.y+this.paddedRect.h-jh]}get displaySize(){return[(this.paddedRect.w-2*jh)/this.pixelRatio,(this.paddedRect.h-2*jh)/this.pixelRatio]}}class Zh{constructor(e,t){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(e,i,n),this.addImages(t,r,n);const{w:o,h:s}=Nh(n),a=new ml({width:o||1,height:s||1});for(const t in e){const r=e[t],n=i[t].paddedRect;ml.copy(r.data,a,{x:0,y:0},{x:n.x+jh,y:n.y+jh},r.data)}for(const e in t){const i=t[e],n=r[e].paddedRect,o=n.x+jh,s=n.y+jh,l=i.data.width,c=i.data.height;ml.copy(i.data,a,{x:0,y:0},{x:o,y:s},i.data),ml.copy(i.data,a,{x:0,y:c-1},{x:o,y:s-1},{width:l,height:1}),ml.copy(i.data,a,{x:0,y:0},{x:o,y:s+c},{width:l,height:1}),ml.copy(i.data,a,{x:l-1,y:0},{x:o-1,y:s},{width:1,height:c}),ml.copy(i.data,a,{x:0,y:0},{x:o+l,y:s},{width:1,height:c})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(e,t,i){for(const r in e){const n=e[r],o={x:0,y:0,w:n.data.width+2*jh,h:n.data.height+2*jh};i.push(o),t[r]=new Gh(o,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in e.updatedImages)this.patchUpdatedImage(this.iconPositions[i],e.getImage(i),t),this.patchUpdatedImage(this.patternPositions[i],e.getImage(i),t)}patchUpdatedImage(e,t,i){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,n]=e.tl;i.update(t.data,void 0,{x:r,y:n})}}Yn("ImagePosition",Gh),Yn("ImageAtlas",Zh);const $h={horizontal:1,vertical:2,horizontalOnly:3},qh=-17;const Xh=57344,Wh=63743;class Hh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const i=new Hh;return i.scale=e||1,i.fontStack=t,i}static forImage(e){const t=new Hh;return t.imageName=e,t}}class Kh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const i=new Kh;for(let r=0;r<e.sections.length;r++){const n=e.sections[r];n.image?i.addImageSection(n):i.addTextSection(n,t)}return i}length(){return this.text.length}getSection(e){return this.sections[this.sectionIndex[e]]}getSections(){return this.sections}getSectionIndex(e){return this.sectionIndex[e]}getCharCode(e){return this.text.charCodeAt(e)}verticalizePunctuation(e){this.text=function(e,t){let i="";for(let r=0;r<e.length;r++){const n=e.charCodeAt(r+1)||null,o=e.charCodeAt(r-1)||null;!t&&(n&&co(n)&&!ph[e[r+1]]||o&&co(o)&&!ph[e[r-1]])||!ph[e[r]]?i+=e[r]:i+=ph[e[r]]}return i}(this.text,e)}trim(){let e=0;for(let t=0;t<this.text.length&&Yh[this.text.charCodeAt(t)];t++)e++;let t=this.text.length;for(let i=this.text.length-1;i>=0&&i>=e&&Yh[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new Kh;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}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(Hh.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t<e.text.length;++t)this.sectionIndex.push(i)}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void ge("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push(Hh.forImage(t)),this.sectionIndex.push(this.sections.length-1)):ge(`Reached maximum number of images ${Wh-Xh+2}`)}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=Wh?null:++this.imageSectionID:(this.imageSectionID=Xh,this.imageSectionID)}}function Jh(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=Kh.fromFeature(e,n);let g;u===$h.vertical&&_.verticalizePunctuation(d);const{processBidirectionalText:y,processStyledBidirectionalText:x}=Io;if(y&&1===_.sections.length){g=[];const e=y(_.toString(),nu(_,c,o,t,r,p,f));for(const t of e){const e=new Kh;e.text=t,e.sections=_.sections;for(let i=0;i<t.length;i++)e.sectionIndex.push(0);g.push(e)}}else if(x){g=[];const e=x(_.text,_.sectionIndex,nu(_,c,o,t,r,p,f));for(const t of e){const e=new Kh;e.text=t[0],e.sectionIndex=t[1],e.sections=_.sections,g.push(e)}}else g=function(e,t){const i=[],r=e.text;let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return n<r.length&&i.push(e.substring(n,r.length)),i}(_,nu(_,c,o,t,r,p,f));const v=[],b={positionedLines:v,text:_.toString(),top:h[1],bottom:h[1],left:h[0],right:h[0],writingMode:u,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(e,t,i,r,n,o,s,a,l,c,h,u){let d=0,p=0,f=0;const m="right"===a?1:"left"===a?0:.5;let _=!1;for(const e of n){const i=e.getSections();for(const e of i){if(e.imageName)continue;const i=t[e.fontStack];if(i&&!(_=void 0!==i.ascender&&void 0!==i.descender))break}if(!_)break}let g=0;for(const s of n){s.trim();const n=s.getMaxScale(),a=(n-1)*sh,x={positionedGlyphs:[],lineOffset:0};e.positionedLines[g]=x;const v=x.positionedGlyphs;let b=0;if(!s.length()){p+=o,++g;continue}let w=0,T=0;for(let o=0;o<s.length();o++){const a=s.getSection(o),f=s.getSectionIndex(o),m=s.getCharCode(o);let g=a.scale,x=null,E=null,S=null,I=sh,M=0;const A=!(l===$h.horizontal||!h&&!lo(m)||h&&(Yh[m]||(y=m,no.Arabic(y)||no["Arabic Supplement"](y)||no["Arabic Extended-A"](y)||no["Arabic Presentation Forms-A"](y)||no["Arabic Presentation Forms-B"](y))));if(a.imageName){const t=r[a.imageName];if(!t)continue;S=a.imageName,e.iconsInText=e.iconsInText||!0,E=t.paddedRect;const i=t.displaySize;if(g=g*sh/u,x={width:i[0],height:i[1],left:jh,top:-Vh,advance:A?i[1]:i[0],localGlyph:!1},_){const e=x.height;M=-e*g}else M=qh+n*sh-i[1]*g;I=x.advance;const o=(A?i[0]:i[1])*g-sh*n;o>0&&o>b&&(b=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(E=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(x=o.metrics,I=8203!==m?sh:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*g;w<i&&(w=i,T=(e-t)/2*g),M=-e*g}else M=qh+(n-g)*sh}A?(e.verticalizable=!0,v.push({glyph:m,imageName:S,x:d,y:p+M,vertical:A,scale:g,localGlyph:x.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:x,rect:E}),d+=I*g+c):(v.push({glyph:m,imageName:S,x:d,y:p+M,vertical:A,scale:g,localGlyph:x.localGlyph,fontStack:a.fontStack,sectionIndex:f,metrics:x,rect:E}),d+=x.advance*g+c)}if(0!==v.length){const e=d-c;f=Math.max(e,f),_?su(v,m,b,T,o*n/2):su(v,m,b,0,o/2)}d=0;const E=o*n+b;x.lineOffset=Math.max(b,a),p+=E,++g}var y;const x=p,{horizontalAlign:v,verticalAlign:b}=ou(s);(function(e,t,i,r,n,o){const s=(t-i)*n,a=-o*r;for(const t of e)for(const e of t.positionedGlyphs)e.x+=s,e.y+=a})(e.positionedLines,m,v,b,f,x),e.top+=-b*x,e.bottom=e.top+x,e.left+=-v*f,e.right=e.left+f,e.hasBaseline=_}(b,t,i,r,g,s,a,l,u,c,d,m),!function(e){for(const t of e)if(0!==t.positionedGlyphs.length)return!1;return!0}(v)&&b}const Yh={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Qh={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function eu(e,t,i,r,n,o){if(t.imageName){const e=r[t.imageName];return e?e.displaySize[0]*t.scale*sh/o+n:0}{const r=i[t.fontStack],o=r&&r.glyphs[e];return o?o.metrics.advance*t.scale+n:0}}function tu(e,t,i,r){const n=Math.pow(e-t,2);return r?e<t?n/2:2*n:n+Math.abs(i)*i}function iu(e,t,i){let r=0;return 10===e&&(r-=1e4),i&&(r+=150),40!==e&&65288!==e||(r+=50),41!==t&&65289!==t||(r+=50),r}function ru(e,t,i,r,n,o){let s=null,a=tu(t,i,n,o);for(const e of r){const r=tu(t-e.x,i,n,o)+e.badness;r<=a&&(s=e,a=r)}return{index:e,x:t,priorBreak:s,badness:a}}function nu(e,t,i,r,n,o,s){if("point"!==o)return[];if(!e)return[];const a=[],l=function(e,t,i,r,n,o){let s=0;for(let i=0;i<e.length();i++){const a=e.getSection(i);s+=eu(e.getCharCode(i),a,r,n,t,o)}return s/Math.max(1,Math.ceil(s/i))}(e,t,i,r,n,s),c=e.text.indexOf("​")>=0;let h=0;for(let i=0;i<e.length();i++){const o=e.getSection(i),d=e.getCharCode(i);if(Yh[d]||(h+=eu(d,o,r,n,t,s)),i<e.length()-1){const t=!!(!((u=d)<11904)&&(no["Bopomofo Extended"](u)||no.Bopomofo(u)||no["CJK Compatibility Forms"](u)||no["CJK Compatibility Ideographs"](u)||no["CJK Compatibility"](u)||no["CJK Radicals Supplement"](u)||no["CJK Strokes"](u)||no["CJK Symbols and Punctuation"](u)||no["CJK Unified Ideographs Extension A"](u)||no["CJK Unified Ideographs"](u)||no["Enclosed CJK Letters and Months"](u)||no["Halfwidth and Fullwidth Forms"](u)||no.Hiragana(u)||no["Ideographic Description Characters"](u)||no["Kangxi Radicals"](u)||no["Katakana Phonetic Extensions"](u)||no.Katakana(u)||no["Vertical Forms"](u)||no["Yi Radicals"](u)||no["Yi Syllables"](u)));(Qh[d]||t||o.imageName)&&a.push(ru(i+1,h,l,a,iu(d,e.getCharCode(i+1),t&&c),!1))}}var u;return function e(t){return t?e(t.priorBreak).concat(t.index):[]}(ru(e.length(),h,l,a,0,!0))}function ou(e){let t=.5,i=.5;switch(e){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(e){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:t,verticalAlign:i}}function su(e,t,i,r,n){if(!(t||i||r||n))return;const o=e.length-1,s=e[o],a=s.metrics.advance*s.scale,l=(s.x+a)*t;for(let t=0;t<=o;t++)e[t].x-=l,e[t].y+=i+r+n}function au(e,t,i){const{horizontalAlign:r,verticalAlign:n}=ou(i),o=t[0],s=t[1],a=o-e.displaySize[0]*r,l=a+e.displaySize[0],c=s-e.displaySize[1]*n;return{image:e,top:c,bottom:c+e.displaySize[1],left:a,right:l}}function lu(e,t,i,r,n,o){const s=e.image;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let h,u,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],u=n[0]+c+r[1]):u=(p=n[0]+(l+c-s.displaySize[0])/2)+s.displaySize[0];const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(h=n[1]+f-r[0],d=n[1]+m+r[2]):d=(h=n[1]+(f+m-s.displaySize[1])/2)+s.displaySize[1],{image:s,top:h,right:u,bottom:d,left:p,collisionPadding:a}}class cu extends n{constructor(e,t,i,r,n){super(e,t),this.angle=r,this.z=i,void 0!==n&&(this.segment=n)}clone(){return new cu(this.x,this.y,this.z,this.angle,this.segment)}}function hu(e,t,i,r,n){if(void 0===t.segment)return!0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(--s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;a<i/2;){const t=e[s-1],i=e[s],o=e[s+1];if(!o)return!1;let h=t.angleTo(i)-i.angleTo(o);for(h=Math.abs((h+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:h}),c+=h;a-l[0].distance>r;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=i.dist(o)}return!0}function uu(e){let t=0;for(let i=0;i<e.length-1;i++)t+=e[i].dist(e[i+1]);return t}function du(e,t,i){return e?.6*t*i:0}function pu(e,t){return Math.max(e?e.right-e.left:0,t?t.right-t.left:0)}function fu(e,t,i,r,n,o){const s=du(i,n,o),a=pu(i,r)*o;let l=0;const c=uu(e)/2;for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1],o=r.dist(n);if(l+o>c){const h=(c-l)/o,u=Wi(r.x,n.x,h),d=Wi(r.y,n.y,h),p=new cu(u,d,0,n.angleTo(r),i);return!s||hu(e,p,a,s,t)?p:void 0}l+=o}}function mu(e,t,i,r,n,o,s,a,l){const c=du(r,o,s),h=pu(r,n),u=h*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-u<t/4&&(t=u+t/4),function e(t,i,r,n,o,s,a,l,c){const h=s/2;const u=uu(t);let d=0,p=i-r;let f=[];for(let e=0;e<t.length-1;e++){const i=t[e],a=t[e+1],l=i.dist(a),m=a.angleTo(i);for(;p+r<d+l;){const _=((p+=r)-d)/l,g=Wi(i.x,a.x,_),y=Wi(i.y,a.y,_);if(g>=0&&g<c&&y>=0&&y<c&&p-h>=0&&p+h<=u){const i=new cu(g,y,0,m,e);i._round(),n&&!hu(t,i,s,n,o)||f.push(i)}}d+=l}l||f.length||a||(f=e(t,d/2,r,n,o,s,a,!0,c));return f}(e,d?t/2*a%t:(h/2+2*o)*s*a%t,t,c,i,u,d,!1,l)}function _u(e,t,i,r,o){const s=[];for(let a=0;a<e.length;a++){const l=e[a];let c;for(let e=0;e<l.length-1;e++){let a=l[e],h=l[e+1];a.x<t&&h.x<t||(a.x<t?a=new n(t,a.y+(h.y-a.y)*((t-a.x)/(h.x-a.x)))._round():h.x<t&&(h=new n(t,a.y+(h.y-a.y)*((t-a.x)/(h.x-a.x)))._round()),a.y<i&&h.y<i||(a.y<i?a=new n(a.x+(h.x-a.x)*((i-a.y)/(h.y-a.y)),i)._round():h.y<i&&(h=new n(a.x+(h.x-a.x)*((i-a.y)/(h.y-a.y)),i)._round()),a.x>=r&&h.x>=r||(a.x>=r?a=new n(r,a.y+(h.y-a.y)*((r-a.x)/(h.x-a.x)))._round():h.x>=r&&(h=new n(r,a.y+(h.y-a.y)*((r-a.x)/(h.x-a.x)))._round()),a.y>=o&&h.y>=o||(a.y>=o?a=new n(a.x+(h.x-a.x)*((o-a.y)/(h.y-a.y)),o)._round():h.y>=o&&(h=new n(a.x+(h.x-a.x)*((o-a.y)/(h.y-a.y)),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(h)))))}}return s}Yn("Anchor",cu);const gu=1e20;function yu(e,t,i,r,n,o,s,a,l){for(let c=t;c<t+r;c++)xu(e,i*o+c,o,n,s,a,l);for(let c=i;c<i+n;c++)xu(e,c*o+t,1,r,s,a,l)}function xu(e,t,i,r,n,o,s){o[0]=0,s[0]=-gu,s[1]=gu,n[0]=e[t];for(let a=1,l=0,c=0;a<r;a++){n[a]=e[t+a*i];const r=a*a;do{const e=o[l];c=(n[a]-n[e]+r-e*e)/(a-e)/2}while(c<=s[l]&&--l>-1);o[++l]=a,s[l]=c,s[l+1]=gu}for(let a=0,l=0;a<r;a++){for(;s[l+1]<a;)l++;const r=o[l],c=a-r;e[t+a*i]=n[r]+c*c}}const vu=2,bu={none:0,ideographs:1,all:2};class wu{constructor(e,t,i){this.requestManager=e,this.localGlyphMode=t,this.localFontFamily=i,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(e){this.url=e}getGlyphs(e,t){const i=[];for(const t in e)for(const r of e[t])i.push({stack:t,id:r});re(i,({stack:e,id:t},i)=>{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let n=r.glyphs[t];if(void 0!==n)return void i(null,{stack:e,id:t,glyph:n});if(n=this._tinySDF(r,e,t))return r.glyphs[t]=n,void i(null,{stack:e,id:t,glyph:n});const o=Math.floor(t/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void i(null,{stack:e,id:t,glyph:n});let s=r.requests[o];s||(s=r.requests[o]=[],wu.loadGlyphRange(e,o,this.url,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const i of s)i(e,t);delete r.requests[o]})),s.push((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})})},(e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:r,glyph:n}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==bu.none&&(this.localGlyphMode===bu.all?!!this.localFontFamily:!!this.localFontFamily&&(no["CJK Unified Ideographs"](e)||no["Hangul Syllables"](e)||no.Hiragana(e)||no.Katakana(e))||no["CJK Symbols and Punctuation"](e))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200");const o=24*vu,s=3*vu,a=8*vu;(n=e.tinySDF=new wu.TinySDF({fontFamily:r,fontWeight:i,fontSize:o,buffer:s,radius:a})).fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:h,glyphLeft:u,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new fl({width:a,height:l},s),metrics:{width:c/vu,height:h/vu,left:u/vu,top:d/vu-27,advance:p/vu,localGlyph:!0}}}}wu.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),dt.Glyphs);gt(a,(e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new yh(e).readFields(Fh,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})},wu.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}){this.buffer=t,this.cutoff=r,this.radius=i;const a=this.size=e+4*t,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${e}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.floor(i),a=Math.min(this.size-this.buffer,Math.ceil(o-n)),l=Math.min(this.size-this.buffer,Math.ceil(i)+Math.ceil(r)),c=a+2*this.buffer,h=l+2*this.buffer,u=c*h,d=new Uint8ClampedArray(u),p={data:d,width:c,height:h,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:_,gridOuter:g}=this;f.clearRect(m,m,a,l),f.fillText(e,m,m+s+1);const y=f.getImageData(m,m,a,l);g.fill(gu,0,u),_.fill(0,0,u);for(let e=0;e<l;e++)for(let t=0;t<a;t++){const i=y.data[4*(e*a+t)+3]/255;if(0===i)continue;const r=(e+m)*c+t+m;if(1===i)g[r]=0,_[r]=gu;else{const e=.5-i;g[r]=e>0?e*e:0,_[r]=e<0?e*e:0}}yu(g,0,0,c,h,c,this.f,this.v,this.z),yu(_,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e<u;e++){const t=Math.sqrt(g[e])-Math.sqrt(_[e]);d[e]=Math.round(255-255*(t/this.radius+this.cutoff))}return p}};const Tu=jh;function Eu(e,t,i,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2*Tu,c=s.paddedRect.h-2*Tu,h=e.right-e.left,u=e.bottom-e.top,d=s.stretchX||[[0,l]],p=s.stretchY||[[0,c]],f=(e,t)=>e+t[1]-t[0],m=d.reduce(f,0),_=p.reduce(f,0),g=l-m,y=c-_;let x=0,v=m,b=0,w=_,T=0,E=g,S=0,I=y;if(s.content&&r){const e=s.content;x=Su(d,0,e[0]),b=Su(p,0,e[1]),v=Su(d,e[0],e[2]),w=Su(p,e[1],e[3]),T=e[0]-x,S=e[1]-b,E=e[2]-e[0]-v,I=e[3]-e[1]-w}const M=(r,o,l,c)=>{const d=Mu(r.stretch-x,v,h,e.left),p=Au(r.fixed-T,E,r.stretch,m),f=Mu(o.stretch-b,w,u,e.top),g=Au(o.fixed-S,I,o.stretch,_),y=Mu(l.stretch-x,v,h,e.left),M=Au(l.fixed-T,E,l.stretch,m),A=Mu(c.stretch-b,w,u,e.top),C=Au(c.fixed-S,I,c.stretch,_),z=new n(d,f),k=new n(y,f),P=new n(y,A),D=new n(d,A),L=new n(p/a,g/a),B=new n(M/a,C/a),R=t*Math.PI/180;if(R){const e=Math.sin(R),t=Math.cos(R),i=[t,-e,e,t];z._matMult(i),k._matMult(i),D._matMult(i),P._matMult(i)}const F=r.stretch+r.fixed,O=l.stretch+l.fixed,U=o.stretch+o.fixed,V=c.stretch+c.fixed;return{tl:z,tr:k,bl:D,br:P,tex:{x:s.paddedRect.x+Tu+F,y:s.paddedRect.y+Tu+U,w:O-F,h:V-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:B,minFontScaleX:E/a/h,minFontScaleY:I/a/u,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const e=Iu(d,g,m),t=Iu(p,y,_);for(let i=0;i<e.length-1;i++){const r=e[i],n=e[i+1];for(let e=0;e<t.length-1;e++){const i=t[e],s=t[e+1];o.push(M(r,i,n,s))}}}else o.push(M({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:l+1},{fixed:0,stretch:c+1}));return o}function Su(e,t,i){let r=0;for(const n of e)r+=Math.max(t,Math.min(i,n[1]))-Math.max(t,Math.min(i,n[0]));return r}function Iu(e,t,i){const r=[{fixed:-Tu,stretch:0}];for(const[t,i]of e){const e=r[r.length-1];r.push({fixed:t-e.stretch,stretch:e.stretch}),r.push({fixed:t-e.stretch,stretch:e.stretch+(i-t)})}return r.push({fixed:t+Tu,stretch:i}),r}function Mu(e,t,i,r){return e/t*i+r}function Au(e,t,i,r){return e-t*i/r}function Cu(e,t,i,r){const n=t+e.positionedLines[r].lineOffset;return 0===r?i+n/2:i+(n+(t+e.positionedLines[r-1].lineOffset))/2}class zu{constructor(e=[],t=function(e,t){return e<t?-1:e>t?1:0}){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}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:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e<r;){let r=1+(e<<1),o=t[r];const s=r+1;if(s<this.length&&i(t[s],o)<0&&(r=s,o=t[s]),i(o,n)>=0)break;t[e]=o,e=r}t[e]=n}}function ku(e,t=1,i=!1){let r=1/0,o=1/0,s=-1/0,a=-1/0;const l=e[0];for(let e=0;e<l.length;e++){const t=l[e];(!e||t.x<r)&&(r=t.x),(!e||t.y<o)&&(o=t.y),(!e||t.x>s)&&(s=t.x),(!e||t.y>a)&&(a=t.y)}const c=s-r,h=a-o,u=Math.min(c,h);let d=u/2;const p=new zu([],Pu);if(0===u)return new n(r,o);for(let t=r;t<s;t+=u)for(let i=o;i<a;i+=u)p.push(new Du(t+d,i+d,d,e));let f=function(e){let t=0,i=0,r=0;const n=e[0];for(let e=0,o=n.length,s=o-1;e<o;s=e++){const o=n[e],a=n[s],l=o.x*a.y-a.x*o.y;i+=(o.x+a.x)*l,r+=(o.y+a.y)*l,t+=3*l}return new Du(i/t,r/t,0,e)}(e),m=p.length;for(;p.length;){const r=p.pop();(r.d>f.d||!f.d)&&(f=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,m)),r.max-f.d<=t||(d=r.h/2,p.push(new Du(r.p.x-d,r.p.y-d,d,e)),p.push(new Du(r.p.x+d,r.p.y-d,d,e)),p.push(new Du(r.p.x-d,r.p.y+d,d,e)),p.push(new Du(r.p.x+d,r.p.y+d,d,e)),m+=4)}return i&&(console.log(`num probes: ${m}`),console.log(`best distance: ${f.d}`)),f.p}function Pu(e,t){return t.max-e.max}function Du(e,t,i,r){this.p=new n(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;n<t.length;n++){const o=t[n];for(let t=0,n=o.length,s=n-1;t<n;s=t++){const n=o[t],a=o[s];n.y>e.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,$a(e,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const Lu=7,Bu=Number.POSITIVE_INFINITY,Ru=Math.sqrt(2);function Fu(e,t){return t[1]!==Bu?function(e,t,i){let r=0,n=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-Lu;break;case"bottom-right":case"bottom-left":case"bottom":n=-i+Lu}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,n]}(e,t[0],t[1]):function(e,t){let i=0,r=0;t<0&&(t=0);const n=t/Ru;switch(e){case"top-right":case"top-left":r=n-Lu;break;case"bottom-right":case"bottom-left":r=-n+Lu;break;case"bottom":r=-t+Lu;break;case"top":r=t-Lu}switch(e){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0])}function Ou(e,t,i,r,n,o,s,a,l,c){e.createArrays();const h=512*e.overscaling;e.tilePixelRatio=ma/h,e.compareText={},e.iconsNeedLinear=!1;const u=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[d["text-size"].possiblyEvaluate(new Ao(t),a),d["text-size"].possiblyEvaluate(new Ao(i),a)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[d["icon-size"].possiblyEvaluate(new Ao(t),a),d["icon-size"].possiblyEvaluate(new Ao(i),a)]}p.layoutTextSize=d["text-size"].possiblyEvaluate(new Ao(l+1),a),p.layoutIconSize=d["icon-size"].possiblyEvaluate(new Ao(l+1),a),p.textMaxSize=d["text-size"].possiblyEvaluate(new Ao(18),a);const f="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),m=u.get("text-size");for(const o of e.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=m.evaluate(o,{},a),d=p.layoutTextSize.evaluate(o,{},a),_=p.layoutIconSize.evaluate(o,{},a),g={horizontal:{},vertical:void 0},y=o.text;let x,v=[0,0];if(y){const r=y.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*sh,c=u.get("text-line-height").evaluate(o,{},a)*sh,p=so(r)?s:0,m=u.get("text-anchor").evaluate(o,{},a),_=u.get("text-variable-anchor");if(!_){const e=u.get("text-radial-offset").evaluate(o,{},a);v=e?Fu(m,[e*sh,Bu]):u.get("text-offset").evaluate(o,{},a).map(e=>e*sh)}let x=f?"center":u.get("text-justify").evaluate(o,{},a);const b=u.get("symbol-placement"),w="point"===b,T="point"===b?u.get("text-max-width").evaluate(o,{},a)*sh:0,E=o=>{e.allowVerticalPlacement&&oo(r)&&(g.vertical=Jh(y,t,i,n,l,T,c,m,o,p,v,$h.vertical,!0,b,d,h))};if(!f&&_){const e="auto"===x?_.map(e=>Uu(e)):[x];let r=!1;for(let o=0;o<e.length;o++){const s=e[o];if(!g.horizontal[s])if(r)g.horizontal[s]=g.horizontal[0];else{const e=Jh(y,t,i,n,l,T,c,"center",s,p,v,$h.horizontal,!1,b,d,h);e&&(g.horizontal[s]=e,r=1===e.positionedLines.length)}}E("left")}else{if("auto"===x&&(x=Uu(m)),w||u.get("text-writing-mode").indexOf("horizontal")>=0||!oo(r)){const e=Jh(y,t,i,n,l,T,c,m,x,p,v,$h.horizontal,!1,b,d,h);e&&(g.horizontal[x]=e)}E("point"===b?"left":x)}}let b=!1;if(o.icon&&o.icon.name){const t=r[o.icon.name];t&&(x=au(n[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),b=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&ge("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),t.pixelRatio!==e.pixelRatio?e.iconsNeedLinear=!0:0!==u.get("icon-rotate").constantOr(1)&&(e.iconsNeedLinear=!0))}const w=Zu(g.horizontal)||g.vertical;e.iconsInText||(e.iconsInText=!!w&&w.iconsInText),(w||x)&&Vu(e,o,g,x,r,p,d,_,v,b,s,a,c)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Uu(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 Vu(e,t,i,r,n,o,s,a,l,c,h,u,d){let p=o.textMaxSize.evaluate(t,{},u);void 0===p&&(p=s);const f=e.layers[0].layout,m=f.get("icon-offset").evaluate(t,{},u),_=Zu(i.horizontal)||i.vertical,g=sh,y=s/g,x=e.tilePixelRatio*p/g,v=(e.tilePixelRatio,e.tilePixelRatio*f.get("symbol-spacing")),b=f.get("text-padding")*e.tilePixelRatio,w=f.get("icon-padding")*e.tilePixelRatio,T=W(f.get("text-max-angle")),E="map"===f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),S="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),I=f.get("symbol-placement"),M=v/2,A=f.get("icon-text-fit");let C;r&&"none"!==A&&(e.allowVerticalPlacement&&i.vertical&&(C=lu(r,i.vertical,A,f.get("icon-text-fit-padding"),m,y)),_&&(r=lu(r,_,A,f.get("icon-text-fit-padding"),m,y)));const z=(s,a,p)=>{if(a.x<0||a.x>=ma||a.y<0||a.y>=ma)return;const{x:f,y:_,z:g}=d.projectTilePoint(a.x,a.y,p),y=new cu(f,_,g,0,void 0);!function(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g,y,x,v,b,w,T,E){const S=e.addToLineVertexArray(t,r);let I,M,A,C,z,k,P,D=0,L=0,B=0,R=0,F=-1,O=-1;const U={};let V=Rs(""),N=0,j=0;void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[N,j]=l.layout.get("text-offset").evaluate(v,{},E).map(e=>e*sh):(N=l.layout.get("text-radial-offset").evaluate(v,{},E)*sh,j=Bu);if(e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)k=qu(e),a&&(P=qu(a));else{const r=l.layout.get("text-rotate").evaluate(v,{},E),n=r+90;A=$u(c,i,t,h,u,d,e,p,n,m),a&&(C=$u(c,i,t,h,u,d,a,g,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(v,{},E),n="none"!==l.layout.get("icon-text-fit"),s=Eu(o,r,w,n),p=a?Eu(a,r,w,n):void 0;M=$u(c,i,t,h,u,d,o,g,r),D=4*s.length;const f=e.iconSizeData;let m=null;"source"===f.kind?(m=[ah*l.layout.get("icon-size").evaluate(v,{},E)])[0]>ju&&ge(`${e.layerIds[0]}: Value for "icon-size" is >= ${Nu}. Reduce your "icon-size".`):"composite"===f.kind&&((m=[ah*b.compositeIconSizes[0].evaluate(v,{},E),ah*b.compositeIconSizes[1].evaluate(v,{},E)])[0]>ju||m[1]>ju)&&ge(`${e.layerIds[0]}: Value for "icon-size" is >= ${Nu}. Reduce your "icon-size".`),e.addSymbols(e.icon,s,m,x,y,v,!1,i,t,S.lineStartIndex,S.lineLength,-1,T,E),F=e.icon.placedSymbolArray.length-1,p&&(L=4*p.length,e.addSymbols(e.icon,p,m,x,y,v,$h.vertical,i,t,S.lineStartIndex,S.lineLength,-1,T,E),O=e.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=n.horizontal[r];if(!I)if(V=Rs(o.text),f)z=qu(o);else{const e=l.layout.get("text-rotate").evaluate(v,{},E);I=$u(c,i,t,h,u,d,o,p,e,m)}const a=1===o.positionedLines.length;if(B+=Gu(e,i,t,o,s,l,f,v,m,S,n.vertical?$h.horizontal:$h.horizontalOnly,a?Object.keys(n.horizontal):[r],U,F,b,T,E),a)break}n.vertical&&(R+=Gu(e,i,t,n.vertical,s,l,f,v,m,S,$h.vertical,["vertical"],U,O,b,T,E));let G=-1;const Z=(e,t)=>e?Math.max(e,t):t;G=Z(z,G),G=Z(k,G);const $=(G=Z(P,G))>-1?1:0;e.glyphOffsetArray.length>=td.MAX_GLYPHS&&ge("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907");void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey);e.symbolInstances.emplaceBack(i.x,i.y,i.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,F,O,V,void 0!==I?I:e.collisionBoxArray.length,void 0!==I?I+1:e.collisionBoxArray.length,void 0!==A?A:e.collisionBoxArray.length,void 0!==A?A+1:e.collisionBoxArray.length,void 0!==M?M:e.collisionBoxArray.length,void 0!==M?M+1:e.collisionBoxArray.length,C||e.collisionBoxArray.length,C?C+1:e.collisionBoxArray.length,h,B,R,D,L,$,0,N,j,G)}(e,a,y,s,i,r,n,C,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,b,E,l,0,w,S,m,t,o,c,h,u)};if("line"===I)for(const n of _u(t.geometry,0,0,ma,ma)){const t=mu(n,v,T,i.vertical||_,r,g,x,e.overscaling,ma);for(const i of t){const t=_;t&&Xu(e,t.text,M,i)||z(n,i,u)}}else if("line-center"===I){for(const e of t.geometry)if(e.length>1){const t=fu(e,T,i.vertical||_,r,g,x);t&&z(e,t,u)}}else if("Polygon"===t.type)for(const e of ec(t.geometry,0)){const t=ku(e,16);z(e[0],new cu(t.x,t.y,0,0,void 0),u)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new cu(e[0].x,e[0].y,0,0,void 0),u);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)z([t],new cu(t.x,t.y,0,0,void 0),u)}const Nu=255,ju=Nu*ah;function Gu(e,t,i,r,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=function(e,t,i,r,o,s,a,l){const c=[];if(0===t.positionedLines.length)return c;const h=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let d=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)d-=e.lineOffset;const p=t.positionedLines.length,f=d/p;let m=t.top-i[1];for(let e=0;e<p;++e){const r=t.positionedLines[e];m=Cu(t,f,m,e);for(const e of r.positionedGlyphs){if(!e.rect)continue;const r=e.rect||{};let s=Vh+1,d=!0,p=1,f=0;if(e.imageName){const t=a[e.imageName];if(!t)continue;if(t.sdf){ge("SDF images are not supported in formatted text and will be ignored.");continue}d=!1,p=t.pixelRatio,s=jh/p}const _=(o||l)&&e.vertical,g=e.metrics.advance*e.scale/2,y=e.metrics,x=e.rect;if(null===x)continue;l&&t.verticalizable&&(f=e.imageName?g-e.metrics.width*e.scale/2:0);const v=o?[e.x+g,e.y]:[0,0];let b=[0,0],w=[0,0],T=!1;o||(_?(w=[e.x+g+u[0],e.y+u[1]-f],T=!0):b=[e.x+g+i[0],e.y+i[1]-f]);const E=x.w*e.scale/(p*(e.localGlyph?vu:1)),S=x.h*e.scale/(p*(e.localGlyph?vu:1));let I,M,A,C;if(_){const t=e.y-m,i=new n(-g,g-t),r=-Math.PI/2,o=new n(...w);(I=new n(-g+b[0],b[1]))._rotateAround(r,i)._add(o),I.x+=-t+g,I.y-=(y.left-s)*e.scale;const a=e.imageName?y.advance*e.scale:sh*e.scale,l=String.fromCharCode(e.glyph);if(fh(l))I.x+=(1-s)*e.scale;else if(mh(l)){const t=a-y.height*e.scale;I.x+=t+(-s-1)*e.scale}else if(e.imageName||y.width+2*s===x.w&&y.height+2*s===x.h){const e=a-S;I.x+=e/2}else{const t=a-(y.height+2*s)*e.scale;I.x+=t/2}M=new n(I.x,I.y-E),A=new n(I.x+S,I.y),C=new n(I.x+S,I.y-E)}else{const t=(y.left-s)*e.scale-g+b[0],i=(-y.top-s)*e.scale+b[1],r=t+E,o=i+S;I=new n(t,i),M=new n(r,i),A=new n(t,o),C=new n(r,o)}if(h){let e;e=o?new n(0,0):T?new n(u[0],u[1]):new n(i[0],i[1]),I._rotateAround(h,e),M._rotateAround(h,e),A._rotateAround(h,e),C._rotateAround(h,e)}const z=new n(0,0),k=new n(0,0),P=0,D=0;c.push({tl:I,tr:M,bl:A,br:C,tex:r,writingMode:t.writingMode,glyphOffset:v,sectionIndex:e.sectionIndex,isSDF:d,pixelOffsetTL:z,pixelOffsetBR:k,minFontScaleX:P,minFontScaleY:D})}}return c}(0,r,c,s,a,l,o,e.allowVerticalPlacement),x=e.textSizeData;let v=null;"source"===x.kind?(v=[ah*s.layout.get("text-size").evaluate(l,{},g)])[0]>ju&&ge(`${e.layerIds[0]}: Value for "text-size" is >= ${Nu}. Reduce your "text-size".`):"composite"===x.kind&&((v=[ah*m.compositeTextSizes[0].evaluate(l,{},g),ah*m.compositeTextSizes[1].evaluate(l,{},g)])[0]>ju||v[1]>ju)&&ge(`${e.layerIds[0]}: Value for "text-size" is >= ${Nu}. Reduce your "text-size".`),e.addSymbols(e.text,y,v,c,a,l,u,t,i,h.lineStartIndex,h.lineLength,f,_,g);for(const t of d)p[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Zu(e){for(const t in e)return e[t];return null}function $u(e,t,i,r,o,s,a,l,c,h){let u=a.top,d=a.bottom,p=a.left,f=a.right;const m=a.collisionPadding;if(m&&(p-=m[0],u-=m[1],f+=m[2],d+=m[3]),c){const e=new n(p,u),t=new n(f,u),i=new n(p,d),r=new n(f,d),o=W(c);let s=new n(0,0);h&&(s=new n(h[0],h[1])),e._rotateAround(o,s),t._rotateAround(o,s),i._rotateAround(o,s),r._rotateAround(o,s),p=Math.min(e.x,t.x,i.x,r.x),f=Math.max(e.x,t.x,i.x,r.x),u=Math.min(e.y,t.y,i.y,r.y),d=Math.max(e.y,t.y,i.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,u,f,d,l,r,o,s),e.length-1}function qu(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 Xu(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])<i)return!0}else n[t]=[];return n[t].push(r),!1}const Wu=bc.VectorTileFeature.types,Hu=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Ku(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=h?Math.min(ju,Math.round(h[0])):0,g=h?Math.min(ju,Math.round(h[1])):0;e.emplaceBack(t,i,Math.round(32*s),Math.round(32*a),l,c,(_<<1)+(u?1:0),g,16*d,16*p,256*f,256*m,r,n,o,0)}function Ju(e,t,i){e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i),e.emplaceBack(t.x,t.y,i)}function Yu(e){for(const t of e.sections)if(po(t.text))return!0;return!1}class Qu{constructor(e){this.layoutVertexArray=new rs,this.indexArray=new cs,this.programConfigurations=e,this.segments=new fa,this.dynamicLayoutVertexArray=new es,this.opacityVertexArray=new ns,this.placedSymbolArray=new Ts}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,eh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,th.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Hu,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&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())}}Yn("SymbolBuffers",Qu);class ed{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new fa,this.collisionVertexArray=new ls,this.collisionVertexArrayExt=new es}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,ih.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,rh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Yn("CollisionBuffers",ed);class td{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=h([]),this.placementViewportMatrix=h([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=lh(this.zoom,t["text-size"]),this.iconSizeData=lh(this.zoom,t["icon-size"]);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&void 0!==r.constantOr(1);const o="viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey;this.sortFeaturesByY=o&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>$h[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID}createArrays(){this.text=new Qu(new ia(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Qu(new ia(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Is,this.lineVertexArray=new Ms,this.symbolInstances=new Ss}calculateGlyphDependencies(e,t,i,r,n){for(let i=0;i<e.length;i++)if(t[e.charCodeAt(i)]=!0,r&&n){const r=ph[e.charAt(i)];r&&(t[r.charCodeAt(0)]=!0)}}populate(e,t,i,r){const n=this.layers[0],o=n.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof oi&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const d=t.iconDependencies,p=t.glyphDependencies,f=t.availableImages,m=new Ao(this.zoom);for(const{feature:t,id:a,index:l,sourceLayerIndex:_}of e){const e=n._featureFilter.needGeometry,g=Ba(t,e);if(!n._featureFilter.filter(m,g,i))continue;let y,x;if(e||(g.geometry=La(t,i,r)),c){const e=n.getValueAndResolveTokens("text-field",g,i,f),t=oi.factory(e);Yu(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Eo()||this.hasRTLText&&Io.isParsed())&&(y=dh(t,n,g))}if(h){const e=n.getValueAndResolveTokens("icon-image",g,i,f);x=e instanceof si?e:si.fromString(e)}if(!y&&!x)continue;const v=this.sortFeaturesByKey?u.evaluate(g,{},i):void 0,b={id:a,text:y,icon:x,index:l,sourceLayerIndex:_,geometry:g.geometry,properties:t.properties,type:Wu[t.type],sortKey:v};if(this.features.push(b),x&&(d[x.name]=!0),y){const e=s.evaluate(g,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf($h.vertical)>=0;for(const i of y.sections)if(i.image)d[i.image.name]=!0;else{const r=oo(y.toString()),n=i.fontStack||e,o=p[n]=p[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;c<e.length;c++){const h=e[c],u=h.geometry,d=h.text?h.text.toString():null;if(!d){o(c);continue}const p=l(d,u),f=l(d,u,!0);if(p in i&&f in t&&i[p]!==t[f]){const e=a(p,f,u),n=s(p,f,r[e].geometry);delete t[p],delete i[f],i[l(d,r[n].geometry,!0)]=n,r[e].geometry=null}else p in i?s(p,f,u):f in t?a(p,f,u):(o(c),t[p]=n-1,i[f]=n-1)}return r.filter(e=>e.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,i,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,i,r))}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()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]);const n={};for(let r=e.segment+1;r<t.length;r++)n[r]={x:t[r].x,y:t[r].y,tileUnitDistanceFromAnchor:i},r<t.length-1&&(i+=t[r+1].dist(t[r]));for(let i=e.segment||0;i>=0;i--)n[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=t[i-1].dist(t[i]));for(let e=0;e<t.length;e++){const t=n[e];this.lineVertexArray.emplaceBack(t.x,t.y,t.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,t,i,r,n,o,s,a,l,c,h,u,d,p){const f=e.indexArray,m=e.layoutVertexArray,_=e.segments.prepareSegment(4*t.length,m,f,this.canOverlap?o.sortKey:void 0),g=this.glyphOffsetArray.length,y=_.vertexLength,x=this.allowVerticalPlacement&&s===$h.vertical?Math.PI/2:0,v=o.text&&o.text.sections;for(let r=0;r<t.length;r++){const{tl:n,tr:s,bl:c,br:h,tex:u,pixelOffsetTL:g,pixelOffsetBR:y,minFontScaleX:b,minFontScaleY:w,glyphOffset:T,isSDF:E,sectionIndex:S}=t[r],I=_.vertexLength,M=T[1];Ku(m,a.x,a.y,a.z,l.x,l.y,n.x,M+n.y,u.x,u.y,i,E,g.x,g.y,b,w),Ku(m,a.x,a.y,a.z,l.x,l.y,s.x,M+s.y,u.x+u.w,u.y,i,E,y.x,g.y,b,w),Ku(m,a.x,a.y,a.z,l.x,l.y,c.x,M+c.y,u.x,u.y+u.h,i,E,g.x,y.y,b,w),Ku(m,a.x,a.y,a.z,l.x,l.y,h.x,M+h.y,u.x+u.w,u.y+u.h,i,E,y.x,y.y,b,w),Ju(e.dynamicLayoutVertexArray,a,x),f.emplaceBack(I,I+1,I+2),f.emplaceBack(I+1,I+2,I+3),_.vertexLength+=4,_.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(T[0]),r!==t.length-1&&S===t[r+1].sectionIndex||e.programConfigurations.populatePaintArrays(m.length,o,o.index,{},d,p,v&&v[S])}e.placedSymbolArray.emplaceBack(a.x,a.y,a.z,l.x,l.y,g,this.glyphOffsetArray.length-g,y,c,h,l.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],s,0,!1,0,u,0)}_commitLayoutVertex(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,Math.round(s.x),Math.round(s.y))}_addCollisionDebugVertices(e,t,i,r,o,s,a){const l=i.segments.prepareSegment(4,i.layoutVertexArray,i.indexArray),c=l.vertexLength,h=a.tileAnchorX,u=a.tileAnchorY;for(let e=0;e<4;e++)i.collisionVertexArray.emplaceBack(0,0,0,0);i.collisionVertexArrayExt.emplaceBack(t,-e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,-e.padding),i.collisionVertexArrayExt.emplaceBack(t,e.padding,e.padding),i.collisionVertexArrayExt.emplaceBack(t,-e.padding,e.padding),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,h,u,new n(e.x1,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,h,u,new n(e.x2,e.y1)),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,h,u,new n(e.x2,e.y2)),this._commitLayoutVertex(i.layoutVertexArray,r,o,s,h,u,new n(e.x1,e.y2)),l.vertexLength+=4;const d=i.indexArray;d.emplaceBack(c,c+1),d.emplaceBack(c+1,c+2),d.emplaceBack(c+2,c+3),d.emplaceBack(c+3,c),l.primitiveLength+=4}_addTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s);this._addCollisionDebugVertices(r,n,this.textCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}_addIconDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceIconSize(e,t,s);this._addCollisionDebugVertices(r,n,this.iconCollisionBox,r.projectedAnchorX,r.projectedAnchorY,r.projectedAnchorZ,o)}}generateCollisionDebugBuffers(e,t){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ed(ss,nh.members,_s),this.iconCollisionBox=new ed(ss,nh.members,_s);const i=hh(this.iconSizeData,e),r=hh(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._addTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._addTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex,o),this._addIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex,o)}}getSymbolInstanceTextSize(e,t,i,r){const n=t.rightJustifiedTextSymbolIndex>=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r,o=this.text.placedSymbolArray.get(n),s=ch(this.textSizeData,e,o)/sh;return this.tilePixelRatio*s}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=ch(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i){e.emplaceBack(t,-i,-i),e.emplaceBack(t,i,-i),e.emplaceBack(t,i,i),e.emplaceBack(t,-i,i)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o){for(let s=r;s<n;s++){const r=i.get(s),n=this.getSymbolInstanceTextSize(e,o,t,s),a=this.textCollisionBox.collisionVertexArrayExt;this._commitDebugCollisionVertexUpdate(a,n,r.padding)}}_updateIconDebugCollisionBoxes(e,t,i,r,n){for(let o=r;o<n;o++){const r=i.get(o),n=this.getSymbolInstanceIconSize(e,t,o),s=this.iconCollisionBox.collisionVertexArrayExt;this._commitDebugCollisionVertexUpdate(s,n,r.padding)}}updateCollisionDebugBuffers(e,t){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const i=hh(this.iconSizeData,e),r=hh(this.textSizeData,e);for(let n=0;n<this.symbolInstances.length;n++){const o=this.symbolInstances.get(n);this._updateTextDebugCollisionBoxes(r,e,t,o.textBoxStartIndex,o.textBoxEndIndex,o),this._updateTextDebugCollisionBoxes(r,e,t,o.verticalTextBoxStartIndex,o.verticalTextBoxEndIndex,o),this._updateIconDebugCollisionBoxes(i,e,t,o.iconBoxStartIndex,o.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(i,e,t,o.verticalIconBoxStartIndex,o.verticalIconBoxEndIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(e,t,i,r,n,o,s,a,l){const c={};for(let r=t;r<i;r++){const t=e.get(r);c.textBox={x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,padding:t.padding,projectedAnchorX:t.projectedAnchorX,projectedAnchorY:t.projectedAnchorY,projectedAnchorZ:t.projectedAnchorZ,tileAnchorX:t.tileAnchorX,tileAnchorY:t.tileAnchorY},c.textFeatureIndex=t.featureIndex;break}for(let t=r;t<n;t++){const i=e.get(t);c.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalTextFeatureIndex=i.featureIndex;break}for(let t=o;t<s;t++){const i=e.get(t);c.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.iconFeatureIndex=i.featureIndex;break}for(let t=a;t<l;t++){const i=e.get(t);c.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,padding:i.padding,projectedAnchorX:i.projectedAnchorX,projectedAnchorY:i.projectedAnchorY,projectedAnchorZ:i.projectedAnchorZ,tileAnchorX:i.tileAnchorX,tileAnchorY:i.tileAnchorY},c.verticalIconFeatureIndex=i.featureIndex;break}return c}deserializeCollisionBoxes(e){this.collisionArrays=[];for(let t=0;t<this.symbolInstances.length;t++){const i=this.symbolInstances.get(t);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(e,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;t<r;t+=4)e.indexArray.emplaceBack(t,t+1,t+2),e.indexArray.emplaceBack(t+1,t+2,t+3)}getSortedSymbolIndexes(e){if(this.sortedAngle===e&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const t=Math.sin(e),i=Math.cos(e),r=[],n=[],o=[];for(let e=0;e<this.symbolInstances.length;++e){o.push(e);const s=this.symbolInstances.get(e);r.push(0|Math.round(t*s.tileAnchorX+i*s.tileAnchorY)),n.push(s.featureIndex)}return o.sort((e,t)=>r[e]-r[t]||n[t]-n[e]),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===t?i.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),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Yn("SymbolBucket",td,{omit:["layers","collisionBoxArray","features","compareText"]}),td.MAX_GLYPHS=65535,td.addDynamicAttributes=Ju;const id=new jo({"symbol-placement":new Fo(zt.layout_symbol["symbol-placement"]),"symbol-spacing":new Fo(zt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fo(zt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Oo(zt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fo(zt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Fo(zt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Fo(zt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fo(zt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fo(zt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Oo(zt.layout_symbol["icon-size"]),"icon-text-fit":new Fo(zt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Fo(zt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Oo(zt.layout_symbol["icon-image"]),"icon-rotate":new Oo(zt.layout_symbol["icon-rotate"]),"icon-padding":new Fo(zt.layout_symbol["icon-padding"]),"icon-keep-upright":new Fo(zt.layout_symbol["icon-keep-upright"]),"icon-offset":new Oo(zt.layout_symbol["icon-offset"]),"icon-anchor":new Oo(zt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fo(zt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fo(zt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fo(zt.layout_symbol["text-rotation-alignment"]),"text-field":new Oo(zt.layout_symbol["text-field"]),"text-font":new Oo(zt.layout_symbol["text-font"]),"text-size":new Oo(zt.layout_symbol["text-size"]),"text-max-width":new Oo(zt.layout_symbol["text-max-width"]),"text-line-height":new Oo(zt.layout_symbol["text-line-height"]),"text-letter-spacing":new Oo(zt.layout_symbol["text-letter-spacing"]),"text-justify":new Oo(zt.layout_symbol["text-justify"]),"text-radial-offset":new Oo(zt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fo(zt.layout_symbol["text-variable-anchor"]),"text-anchor":new Oo(zt.layout_symbol["text-anchor"]),"text-max-angle":new Fo(zt.layout_symbol["text-max-angle"]),"text-writing-mode":new Fo(zt.layout_symbol["text-writing-mode"]),"text-rotate":new Oo(zt.layout_symbol["text-rotate"]),"text-padding":new Fo(zt.layout_symbol["text-padding"]),"text-keep-upright":new Fo(zt.layout_symbol["text-keep-upright"]),"text-transform":new Oo(zt.layout_symbol["text-transform"]),"text-offset":new Oo(zt.layout_symbol["text-offset"]),"text-allow-overlap":new Fo(zt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Fo(zt.layout_symbol["text-ignore-placement"]),"text-optional":new Fo(zt.layout_symbol["text-optional"])});var rd={paint:new jo({"icon-opacity":new Oo(zt.paint_symbol["icon-opacity"]),"icon-color":new Oo(zt.paint_symbol["icon-color"]),"icon-halo-color":new Oo(zt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Oo(zt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Oo(zt.paint_symbol["icon-halo-blur"]),"icon-translate":new Fo(zt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fo(zt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Oo(zt.paint_symbol["text-opacity"]),"text-color":new Oo(zt.paint_symbol["text-color"],{runtimeType:jt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Oo(zt.paint_symbol["text-halo-color"]),"text-halo-width":new Oo(zt.paint_symbol["text-halo-width"]),"text-halo-blur":new Oo(zt.paint_symbol["text-halo-blur"]),"text-translate":new Fo(zt.paint_symbol["text-translate"]),"text-translate-anchor":new Fo(zt.paint_symbol["text-translate-anchor"])}),layout:id};class nd{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){if(!this.defaultValue.isConstant()){e(this.defaultValue.value._styleExpression.expression)}}outputDefined(){return!1}serialize(){return null}}Yn("FormatSectionOverride",nd,{omit:["defaultValue"]});class od extends ca{constructor(e){super(e,rd)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["icon-rotation-alignment"]="map":this.layout._values["icon-rotation-alignment"]="viewport"),"auto"===this.layout.get("text-rotation-alignment")&&("point"!==this.layout.get("symbol-placement")?this.layout._values["text-rotation-alignment"]="map":this.layout._values["text-rotation-alignment"]="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 i=this.layout.get("text-writing-mode");if(i){const e=[];for(const t of i)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else"point"===this.layout.get("symbol-placement")?this.layout._values["text-writing-mode"]=["horizontal"]:this.layout._values["text-writing-mode"]=["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||en(o.value)||!n?n:(s=t.properties,n.replace(/{([^{}]+)}/g,(e,t)=>t in s?String(s[t]):""));var s}createBucket(e){return new td(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of rd.paint.overridableProperties){if(!od.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new nd(t),r=new Qr(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new rn("source",r):new nn("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Bo(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&od.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=rd.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof oi)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{if(!n)if(t instanceof ui&&ci(t.value)===qt){const e=t.value;o(e.sections)}else t instanceof mi?o(t.sections):t.eachChild(e)},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramConfiguration(e){return new ta(this,e)}}var sd={paint:new jo({"background-color":new Fo(zt.paint_background["background-color"]),"background-pattern":new Vo(zt.paint_background["background-pattern"]),"background-opacity":new Fo(zt.paint_background["background-opacity"])})};var ad={paint:new jo({"raster-opacity":new Fo(zt.paint_raster["raster-opacity"]),"raster-hue-rotate":new Fo(zt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Fo(zt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Fo(zt.paint_raster["raster-brightness-max"]),"raster-saturation":new Fo(zt.paint_raster["raster-saturation"]),"raster-contrast":new Fo(zt.paint_raster["raster-contrast"]),"raster-resampling":new Fo(zt.paint_raster["raster-resampling"]),"raster-fade-duration":new Fo(zt.paint_raster["raster-fade-duration"])})};class ld extends ca{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}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 cd={paint:new jo({"sky-type":new Fo(zt.paint_sky["sky-type"]),"sky-atmosphere-sun":new Fo(zt.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Fo(zt.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Fo(zt.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Fo(zt.paint_sky["sky-gradient-radius"]),"sky-gradient":new No(zt.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Fo(zt.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Fo(zt.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Fo(zt.paint_sky["sky-opacity"])})};function hd(e,t,i){const r=v(0,0,1),n=V(U());return function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a}(n,n,i?-W(e)+Math.PI:W(e)),N(n,n,-W(t)),k(r,r,n),M(r,r)}const ud={circle:class extends ca{constructor(e){super(e,tl)}createBucket(e){return new Fa(e)}queryRadius(e){const t=e;return Ka("circle-radius",this,t)+Ka("circle-stroke-width",this,t)+Ja(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,i,r,n,o,s,a){const l=Qa(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(t,i)+this.paint.get("circle-stroke-width").evaluate(t,i);return ol(e,r,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ta(this,e)}},heatmap:class extends ca{createBucket(e){return new hl(e)}constructor(e){super(e,_l),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){const e=this._transitionablePaint._values["heatmap-color"].value.expression;this.colorRamp=gl({expression:e,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(e){return Ka("heatmap-radius",this,e)}queryIntersectsFeature(e,t,i,r,o,s,a,l){const c=this.paint.get("heatmap-radius").evaluate(t,i);return ol(e,r,s,a,l,!0,!0,new n(0,0),c)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ta(this,e)}},hillshade:class extends ca{constructor(e){super(e,yl)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}getProgramConfiguration(e){return new ta(this,e)}},fill:class extends ca{constructor(e){super(e,ac)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),i=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(e){return new ta(this,e)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new oc(e)}queryRadius(){return Ja(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,i,r,n,o){return!e.queryGeometry.isAboveHorizon&&Va(Ya(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends ca{constructor(e){super(e,kc)}createBucket(e){return new Cc(e)}queryRadius(){return Ja(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 ta(this,e)}queryIntersectsFeature(e,t,i,r,o,s,a,l,c){const h=Qa(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(t,i),d=this.paint.get("fill-extrusion-base").evaluate(t,i),p=[0,0],f=l&&s.elevation,m=s.elevation?s.elevation.exaggeration():1;if(f){const t=e.tile.getBucket(this).centroidVertexArray,i=c+1;if(i<t.length){const e=t.get(i);p[0]=e.a_centroid_pos0,p[1]=e.a_centroid_pos1}}if(0===p[0]&&1===p[1])return!1;const _=function(e,t,i,r,o,s,a,l,c){return s?function(e,t,i,r,n,o,s,a,l){const c=[],h=[],u=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const h=c.x+r.x,d=c.y+r.y,f=Bc(h,d,t,i,o,s,a,l);u[0]=h,u[1]=d,u[2]=f.base,u[3]=1,F(u,u,n),u[3]=Math.max(u[3],1e-5);const m=Lc([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);u[0]=h,u[1]=d,u[2]=f.top,u[3]=1,F(u,u,n),u[3]=Math.max(u[3],1e-5);const _=Lc([u[0]/u[3],u[1]/u[3],u[2]/u[3]]);e.push(m),p.push(_)}c.push(e),h.push(p)}return[c,h]}(e,t,i,r,o,s,a,l,c):function(e,t,i,r,o){const s=[],a=[],l=o[8]*t,c=o[9]*t,h=o[10]*t,u=o[11]*t,d=o[8]*i,p=o[9]*i,f=o[10]*i,m=o[11]*i;for(const t of e){const e=[],i=[];for(const s of t){const t=s.x+r.x,a=s.y+r.y,_=o[0]*t+o[4]*a+o[12],g=o[1]*t+o[5]*a+o[13],y=o[2]*t+o[6]*a+o[14],x=o[3]*t+o[7]*a+o[15],v=_+l,b=g+c,w=y+h,T=Math.max(x+u,1e-5),E=_+d,S=g+p,I=y+f,M=Math.max(x+m,1e-5),A=new n(v/T,b/T);A.z=w/T,e.push(A);const C=new n(E/M,S/M);C.z=I/M,i.push(C)}s.push(e),a.push(i)}return[s,a]}(e,t,i,r,o)}(r,d,u,h,a,f?l:null,p,m,s.center.lat),g=_[0],y=_[1],x=e.queryGeometry;return function(e,t,i){let r=1/0;Va(i,t)&&(r=Dc(i,t[0]));for(let n=0;n<t.length;n++){const o=t[n],s=e[n];for(let e=0;e<o.length-1;e++){const t=o[e],n=o[e+1],a=s[e],l=s[e+1],c=[t,n,l,a,t];Oa(i,c)&&(r=Math.min(r,Dc(i,c)))}}return r!==1/0&&r}(g,y,x.isPointQuery()?x.screenBounds:x.screenGeometry)}},line:class extends ca{constructor(e){super(e,Jc),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Xi,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Yc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Hc(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(e){return new ta(this,e)}queryRadius(e){const t=e,i=Qc(Ka("line-width",this,t),Ka("line-gap-width",this,t)),r=Ka("line-offset",this,t);return i/2+Math.abs(r)+Ja(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,r,o,s){if(e.queryGeometry.isAboveHorizon)return!1;const a=Ya(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),s.angle,e.pixelToTileUnitsFactor),l=e.pixelToTileUnitsFactor/2*Qc(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),c=this.paint.get("line-offset").evaluate(t,i);return c&&(r=function(e,t){const i=[],r=new n(0,0);for(let n=0;n<e.length;n++){const o=e[n],s=[];for(let e=0;e<o.length;e++){const i=o[e-1],n=o[e],a=o[e+1],l=0===e?r:n.sub(i)._unit()._perp(),c=e===o.length-1?r:a.sub(n)._unit()._perp(),h=l._add(c)._unit(),u=h.x*c.x+h.y*c.y;h._mult(1/u),s.push(h._mult(t)._add(n))}i.push(s)}return i}(r,c*e.pixelToTileUnitsFactor)),function(e,t,i){for(let r=0;r<t.length;r++){const n=t[r];if(e.length>=3)for(let t=0;t<n.length;t++)if(Xa(e,n[t]))return!0;if(Na(e,n,i))return!0}return!1}(a,r,l)}isTileClipped(){return!0}},symbol:od,background:class extends ca{constructor(e){super(e,sd)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends ca{constructor(e){super(e,ad)}getProgramIds(){return["raster"]}},sky:class extends ca{constructor(e){super(e,cd),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"sky-gradient"===e?this._updateColorRamp():"sky-atmosphere-sun"!==e&&"sky-atmosphere-halo-color"!==e&&"sky-atmosphere-color"!==e&&"sky-atmosphere-sun-intensity"!==e||(this._skyboxInvalidated=!0)}_updateColorRamp(){const e=this._transitionablePaint._values["sky-gradient"].value.expression;this.colorRamp=gl({expression:e,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(e){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=e.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}}getCenter(e,t){const i=this.paint.get("sky-type");if("atmosphere"===i){const i=this.paint.get("sky-atmosphere-sun"),r=!i,n=e.style.light,o=n.properties.get("position");return r&&"viewport"===n.properties.get("anchor")&&ge("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),r?hd(o.azimuthal,90-o.polar,t):hd(i[0],90-i[1],t)}if("gradient"===i){const e=this.paint.get("sky-gradient-center");return hd(e[0],90-e[1],t)}}is3D(){return!1}isSky(){return!0}markSkyboxValid(e){this._skyboxInvalidated=!1,this._lightPosition=e.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const e=this.paint.get("sky-type");return"atmosphere"===e?["skyboxCapture","skybox"]:"gradient"===e?["skyboxGradient"]:null}}};const{HTMLImageElement:dd,HTMLCanvasElement:pd,HTMLVideoElement:fd,ImageData:md,ImageBitmap:_d}=s;class gd{constructor(e,t,i,r){this.context=e,this.format=i,this.texture=e.gl.createTexture(),this.update(t,r)}update(e,t,i){const{width:r,height:n}=e,{context:o}=this,{gl:s}=o;if(s.bindTexture(s.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1),o.pixelStoreUnpackPremultiplyAlpha.set(this.format===s.RGBA&&(!t||!1!==t.premultiply)),i||this.size&&this.size[0]===r&&this.size[1]===n){const{x:t,y:o}=i||{x:0,y:0};e instanceof dd||e instanceof pd||e instanceof fd||e instanceof md||_d&&e instanceof _d?s.texSubImage2D(s.TEXTURE_2D,0,t,o,s.RGBA,s.UNSIGNED_BYTE,e):s.texSubImage2D(s.TEXTURE_2D,0,t,o,r,n,s.RGBA,s.UNSIGNED_BYTE,e.data)}else this.size=[r,n],e instanceof dd||e instanceof pd||e instanceof fd||e instanceof md||_d&&e instanceof _d?s.texImage2D(s.TEXTURE_2D,0,this.format,this.format,s.UNSIGNED_BYTE,e):s.texImage2D(s.TEXTURE_2D,0,this.format,r,n,0,this.format,s.UNSIGNED_BYTE,e.data);this.useMipmap=Boolean(t&&t.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&s.generateMipmap(s.TEXTURE_2D)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_2D,this.texture),e!==this.filter&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,this.useMipmap?e===r.NEAREST?r.NEAREST_MIPMAP_NEAREST:r.LINEAR_MIPMAP_NEAREST:e),this.filter=e),t!==this.wrap&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t),this.wrap=t)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class yd{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new fl({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const i=this.getKey(e,t);return this.positions[i]}trim(){const e=this.width,t=this.height=ce(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,i){const r=[];let n=e.length%2==1?-e[e.length-1]*i:0,o=e[0]*i,s=!0;r.push({left:n,right:o,isDash:s,zeroLength:0===e[0]});let a=e[0];for(let t=1;t<e.length;t++){s=!s;const l=e[t];n=a*i,o=(a+=l)*i,r.push({left:n,right:o,isDash:s,zeroLength:0===l})}return r}addRoundDash(e,t,i){const r=t/2;for(let t=-i;t<=i;t++){const n=this.nextRow+i+t,o=this.width*n;let s=0,a=e[s];for(let n=0;n<this.width;n++){n/a.right>1&&(a=e[++s]);const l=Math.abs(n-a.left),c=Math.abs(n-a.right),h=Math.min(l,c);let u;const d=t/i*(r+1);if(a.isDash){const e=r-Math.abs(d);u=Math.sqrt(h*h+e*e)}else u=r-Math.sqrt(h*h+d*d);this.image.data[o+n]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i<this.width;i++){i/s.right>1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a),c=(s.isDash?l:-l)+t;this.image.data[n+i]=Math.max(0,Math.min(255,c+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return ge("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;t<e.length;t++)e[t]<0&&(ge("Negative value is found in line dasharray, replacing values with 0"),e[t]=0),s+=e[t];if(0!==s){const i=this.width/s,o=this.getDashRanges(e,this.width,i);if(r)this.addRoundDash(o,i,n);else{const e="square"===t?.5*i:0;this.addRegularDash(o,e)}}const a=this.nextRow+n;this.nextRow+=o;const l={tl:[a,n],br:[s,0]};return this.positions[i]=l,l}}Yn("LineAtlas",yd);class xd{constructor(e){this._callback=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=(()=>{this._triggered=!1,this._callback()}))}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){delete this._channel,this._callback=(()=>{})}}const vd=s.performance;function bd(e){const t=e?e.url.toString():void 0;return vd.getEntriesByName(t)}class wd{constructor(){this.tasks={},this.taskQueue=[],ue(["process"],this),this.invoker=new xd(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){ve();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){ve();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 i=0;i<this.taskQueue.length;i++){const r=this.taskQueue[i],n=this.tasks[r];n.priority<t&&(t=n.priority,e=i)}if(null===e)return null;const i=this.taskQueue[e];return this.taskQueue.splice(e,1),i}remove(){this.invoker.remove()}}function Td(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Ed{constructor(e,t,i){this.z=e,this.x=t,this.y=i,this.key=Md(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const i=(r=this.x,n=this.y,o=this.z,s=Td(256*r,256*(n=Math.pow(2,o)-n-1),o),a=Td(256*(r+1),256*(n+1),o),s[0]+","+s[1]+","+a[0]+","+a[1]);var r,n,o,s,a;const l=function(e,t,i){let r,n="";for(let o=e;o>0;o--)n+=(t&(r=1<<o-1)?1:0)+(i&r?2:0);return n}(this.z,this.x,this.y);return e[(this.x+this.y)%e.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace("{z}",String(this.z)).replace("{x}",String(this.x)).replace("{y}",String("tms"===t?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",l).replace("{bbox-epsg-3857}",i)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Sd{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Md(e,t.z,t.z,t.x,t.y)}}class Id{constructor(e,t,i,r,n){this.overscaledZ=e,this.wrap=t,this.canonical=new Ed(i,+r,+n),this.key=0===t&&e===i?this.canonical.key:Md(t,e,i,r,n)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){const t=this.canonical.z-e;return e>this.canonical.z?new Id(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Id(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}calculateScaledKey(e,t=!0){if(this.overscaledZ===e&&t)return this.key;if(e>this.canonical.z)return Md(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Md(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ<this.overscaledZ&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Id(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Id(t,this.wrap,t,i,r),new Id(t,this.wrap,t,i+1,r),new Id(t,this.wrap,t,i,r+1),new Id(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrap<e.wrap||!(this.wrap>e.wrap)&&(this.overscaledZ<e.overscaledZ||!(this.overscaledZ>e.overscaledZ)&&(this.canonical.x<e.canonical.x||!(this.canonical.x>e.canonical.x)&&this.canonical.y<e.canonical.y))}wrapped(){return new Id(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new Id(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Sd(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Md(e,t,i,r,n){const o=1<<Math.min(i,22);let s=o*(n%o)+r%o;if(e&&i<22){s+=o*o*((e<0?-2*e-1:2*e)%(1<<2*(22-i)))}return 16*(32*s+i)+(t-i)}Yn("CanonicalTileID",Ed),Yn("OverscaledTileID",Id,{omit:["projMatrix"]});class Ad{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}Ad.ReadOnly=!1,Ad.ReadWrite=!0,Ad.disabled=new Ad(519,Ad.ReadOnly,[0,1]);class Cd{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Cd.disabled=new Cd({func:519,mask:0},0,0,7680,7680,7680);class zd{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}zd.Replace=[1,0],zd.disabled=new zd(zd.Replace,ii.transparent,[!1,!1,!1,!1]),zd.unblended=new zd(zd.Replace,ii.transparent,[!0,!0,!0,!0]),zd.alphaBlended=new zd([1,771],ii.transparent,[!0,!0,!0,!0]);class kd{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}kd.disabled=new kd(!1,1029,2305),kd.backCCW=new kd(!0,1029,2305),kd.backCW=new kd(!0,1029,2304),kd.frontCW=new kd(!0,1028,2304),kd.frontCCW=new kd(!0,1028,2305);class Pd{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t<e.length;t++){const i=e[t];this._stringToNumber[i]=t,this._numberToString[t]=i}}encode(e){return this._stringToNumber[e]}decode(e){return this._numberToString[e]}}class Dd{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=r,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Ld{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},oe(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else{if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i){this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}}}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t){if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null}else this.deletedStates[e]=null}getState(e,t){const i=String(t),r=this.state[e]||{},n=this.stateChanges[e]||{},o=oe({},r[i],n[i]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const i=this.deletedStates[e][t];if(null===i)return{};for(const e in i)delete o[e]}return o}initializeTileState(e,t){e.setFeatureState(this.state,t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),oe(this.state[e][i],this.stateChanges[e][i]),t[i]=this.state[e][i];i[e]=t}for(const e in this.deletedStates){this.state[e]=this.state[e]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else for(const t of Object.keys(this.deletedStates[e][i]))delete this.state[e][i][t];t[i]=this.state[e][i]}i[e]=i[e]||{},oe(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const r in e){e[r].setFeatureState(i,t)}}}class Bd{constructor(e){this.size=e,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(e,t){const i=this.toIdx(e,t);return{min:this.minimums[i],max:this.maximums[i]}}isLeaf(e,t){return this.leaves[this.toIdx(e,t)]}toIdx(e,t){return t*this.size+e}}function Rd(e,t,i,r){let n=0,o=Number.MAX_VALUE;for(let s=0;s<3;s++)if(Math.abs(r[s])<1e-15){if(i[s]<e[s]||i[s]>t[s])return null}else{const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),c<o&&(o=c),n>o)return null}return n}function Fd(e,t,i,r,n,o,s,a,l,c,h){const u=r-e,d=n-t,p=o-i,f=s-e,m=a-t,_=l-i,g=h[1]*_-h[2]*m,y=h[2]*f-h[0]*_,x=h[0]*m-h[1]*f,v=u*g+d*y+p*x;if(Math.abs(v)<1e-15)return null;const b=1/v,w=c[0]-e,T=c[1]-t,E=c[2]-i,S=(w*g+T*y+E*x)*b;if(S<0||S>1)return null;const I=T*p-E*d,M=E*u-w*p,A=w*d-T*u,C=(h[0]*I+h[1]*M+h[2]*A)*b;return C<0||S+C>1?null:(f*I+m*M+_*A)*b}function Od(e,t,i){return(e-t)/(i-t)}function Ud(e,t,i,r,n,o,s,a,l){const c=1<<i,h=o-r,u=s-n,d=(e+0)/c*h+r,p=(e+1)/c*h+r,f=(t+0)/c*u+n,m=(t+1)/c*u+n;a[0]=d,a[1]=f,l[0]=p,l[1]=m}const Vd=100;class Nd{constructor(e){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=e,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const t=function(e){const t=e.dim,i=Math.ceil(Math.log2(t/8)),r=[];let n=Math.ceil(Math.pow(2,i));const o=1/n,s=(e,t,i,r,n)=>{const o=r?1:0,s=e*i,a=(e+1)*i-o,l=t*i,c=(t+1)*i-o;n[0]=s,n[1]=l,n[2]=a,n[3]=c};let a=new Bd(n);const l=[];for(let t=0;t<n*n;t++){const i=Math.floor(t/n),r=t%n;s(r,i,o,!1,l);const c=Gd(l[0],l[1],e),h=Gd(l[2],l[1],e),u=Gd(l[2],l[3],e),d=Gd(l[0],l[3],e);a.minimums.push(Math.min(c,h,u,d)),a.maximums.push(Math.max(c,h,u,d)),a.leaves.push(1)}for(r.push(a),n/=2;n>=1;n/=2){const e=r[r.length-1];a=new Bd(n);for(let t=0;t<n*n;t++){const i=Math.floor(t/n),r=t%n;s(r,i,2,!0,l);const o=e.getElevation(l[0],l[1]),c=e.getElevation(l[2],l[1]),h=e.getElevation(l[2],l[3]),u=e.getElevation(l[0],l[3]),d=e.isLeaf(l[0],l[1]),p=e.isLeaf(l[2],l[1]),f=e.isLeaf(l[2],l[3]),m=e.isLeaf(l[0],l[3]),_=Math.min(o.min,c.min,h.min,u.min),g=Math.max(o.max,c.max,h.max,u.max),y=d&&p&&f&&m;a.maximums.push(g),a.minimums.push(_),g-_<=5&&y?a.leaves.push(1):a.leaves.push(0)}r.push(a)}return r}(this.dem),i=t.length-1,r=t[i],n=r.minimums,o=r.maximums,s=r.leaves;this._addNode(n[0],o[0],s[0]),this._construct(t,0,0,i,0)}raycastRoot(e,t,i,r,n,o,s=1){return Rd([e,t,-Vd],[i,r,this.maximums[0]*s],n,o)}raycast(e,t,i,r,n,o,s=1){if(!this.nodeCount)return null;const a=this.raycastRoot(e,t,i,r,n,o,s);if(null==a)return null;const l=[],c=[],h=[],u=[],d=[{idx:0,t:a,nodex:0,nodey:0,depth:0}];for(;d.length>0;){const{idx:a,t:p,nodex:f,nodey:m,depth:_}=d.pop();if(this.leaves[a]){Ud(f,m,_,e,t,i,r,h,u);const a=1<<_,l=(f+0)/a,c=(f+1)/a,d=(m+0)/a,g=(m+1)/a,y=Gd(l,d,this.dem)*s,x=Gd(c,d,this.dem)*s,v=Gd(c,g,this.dem)*s,b=Gd(l,g,this.dem)*s,w=Fd(h[0],h[1],y,u[0],h[1],x,u[0],u[1],v,n,o),T=Fd(u[0],u[1],v,h[0],u[1],b,h[0],h[1],y,n,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=I([],n,o,p);if(jd(y,x,b,v,Od(e[0],h[0],u[0]),Od(e[1],h[1],u[1]))>=e[2])return p}continue}let g=0;for(let d=0;d<this._siblingOffset.length;d++){Ud((f<<1)+this._siblingOffset[d][0],(m<<1)+this._siblingOffset[d][1],_+1,e,t,i,r,h,u),h[2]=-Vd,u[2]=this.maximums[this.childOffsets[a]+d]*s;const p=Rd(h,u,n,o);if(null!=p){const e=p;l[d]=e;let t=!1;for(let i=0;i<g&&!t;i++)e>=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[g]=d),g++}}for(let e=0;e<g;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:_+1})}}return null}_addNode(e,t,i){return this.minimums.push(e),this.maximums.push(t),this.leaves.push(i),this.childOffsets.push(0),this.nodeCount++}_construct(e,t,i,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=e[o];let a,l=0;for(let e=0;e<this._siblingOffset.length;e++){const r=2*t+this._siblingOffset[e][0],n=2*i+this._siblingOffset[e][1],o=s.getElevation(r,n),c=s.isLeaf(r,n),h=this._addNode(o.min,o.max,c);c&&(l|=1<<e),a||(a=h)}for(let r=0;r<this._siblingOffset.length;r++)l&1<<r||this._construct(e,2*t+this._siblingOffset[r][0],2*i+this._siblingOffset[r][1],o,a+r)}}function jd(e,t,i,r,n,o){return Wi(Wi(e,i,o),Wi(t,r,o),n)}function Gd(e,t,i){const r=i.dim,n=ee(e*r-.5,0,r-1),o=ee(t*r-.5,0,r-1),s=Math.floor(n),a=Math.floor(o),l=Math.min(s+1,r-1),c=Math.min(a+1,r-1);return jd(i.get(s,a),i.get(l,a),i.get(s,c),i.get(l,c),n-s,o-a)}const Zd={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class $d{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(e,t,i,r=!1,n=!1){if(this.uid=e,t.height!==t.width)throw new RangeError("DEM tiles must be square");if(i&&"mapbox"!==i&&"terrarium"!==i)return ge(`"${i}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=t.height;const o=this.dim=t.height-2;if(this.data=new Uint32Array(t.data.buffer),this.encoding=i||"mapbox",this.borderReady=r,!r){for(let e=0;e<o;e++)this.data[this._idx(-1,e)]=this.data[this._idx(0,e)],this.data[this._idx(o,e)]=this.data[this._idx(o-1,e)],this.data[this._idx(e,-1)]=this.data[this._idx(e,0)],this.data[this._idx(e,o)]=this.data[this._idx(e,o-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(o,-1)]=this.data[this._idx(o-1,0)],this.data[this._idx(-1,o)]=this.data[this._idx(0,o-1)],this.data[this._idx(o,o)]=this.data[this._idx(o-1,o-1)],n&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new Nd(this)}get(e,t,i=!1){const r=new Uint8Array(this.data.buffer);i&&(e=ee(e,-1,this.dim),t=ee(t,-1,this.dim));const n=4*this._idx(e,t);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(r[n],r[n+1],r[n+2])}static getUnpackVector(e){return Zd[e]}get unpackVector(){return Zd[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)}_unpackMapbox(e,t,i){return(256*e*256+256*t+i)/10-1e4}_unpackTerrarium(e,t,i){return 256*e+t+i/256-32768}static pack(e,t){const i=[0,0,0,0],r=$d.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new ml({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t<s;t++)for(let i=r;i<n;i++)this.data[this._idx(i,t)]=e.data[this._idx(i+a,t+l)]}onDeserialize(){this._tree&&(this._tree.dem=this)}}Yn("DEMData",$d),Yn("DemMinMaxQuadTree",Nd,{omit:["dem"]});class qd{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout(()=>{this.remove(e,n)},i)),this.data[r].push(n),this.order.push(r),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){if(!this.has(e))return null;return this.data[e.wrapped().key][0].value}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(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 i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Xd extends Ct{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,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 qd(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new Ld}onAdd(e){this.map=e,this._minTileCacheSize=e?e._minTileCacheSize:null,this._maxTileCacheSize=e?e._maxTileCacheSize:null}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 i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return ne(this._tiles).map(e=>e.tileID).sort(Wd).map(e=>e.key)}getRenderableIds(e){const t=[];for(const i in this._tiles)this._isIdRenderable(+i,e)&&t.push(this._tiles[i]);return e?t.sort((e,t)=>{const i=e.tileID,r=t.tileID,o=new n(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),s=new n(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):t.map(e=>e.tileID).sort(Wd).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 i=this._tiles[e];i&&("loading"!==i.state&&(i.state=t),this._loadTile(i,this._tileLoaded.bind(this,i,e,t)))}_tileLoaded(e,t,i,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new At(r,{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=Ce.now(),"expired"===i&&(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 Mt("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r<t.length;r++){const n=t[r];if(e.neighboringTiles&&e.neighboringTiles[n]){const t=this.getTileByID(n);i(e,t),i(t,e)}}function i(e,t){if(!e.dem||e.dem.borderReady)return;e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0;let i=t.tileID.canonical.x-e.tileID.canonical.x;const r=t.tileID.canonical.y-e.tileID.canonical.y,n=Math.pow(2,e.tileID.canonical.z),o=t.tileID.key;0===i&&0===r||Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,i,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);(o=this._tiles[e.key])&&o.hasData()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(e[(a=a.scaledTo(a.overscaledZ-1)).key]){r[s.key]=s;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const i=this._loadedParentTiles[e.key];return i&&i.tileID.overscaledZ>=t?i:null}for(let i=e.overscaledZ-1;i>=t;i--){const t=e.scaledTo(i),r=this._getLoadedTile(t);if(r)return r}}_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 i=(Math.ceil(e.width/t)+1)*(Math.ceil(e.height/t)+1),r=Math.floor(5*i),n="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(o)}handleWrapJump(e){const t=(e-(void 0===this._prevLng?e:this._prevLng))/360,i=Math.round(t);if(this._prevLng=e,i){const e={};for(const t in this._tiles){const r=this._tiles[t];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+i),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles){const t=this._tiles[e];this._setTileReloadTimer(+e,t)}}}update(e,t,i){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new Id(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[];const n=this._updateRetainedTiles(r);if(Hd(this._source.type)&&0!==r.length){const e={},t={},i=Object.keys(n);for(const r of i){const i=n[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=Ce.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-Xd.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),e[s.tileID.key]=s.tileID),t[r]=i}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const i=this._tiles[e];if(n[e]||!i.hasData())continue;let r=i.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){n[e]=i.tileID;break}}}for(const t in e)n[t]||(this._coveredTiles[t]=!0,n[t]=e[t])}for(const e in n)this._tiles[e].clearFadeHold();const o=function(e,t){const i=[];for(const r in e)r in t||i.push(r);return i}(this._tiles,n);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}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 i={},r=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),n=e[0].overscaledZ,o=Math.max(n-Xd.maxOverzooming,this._source.minzoom),s=Math.max(n+Xd.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r<this._source.maxzoom&&(a[i.key]=i)}this._retainLoadedChildren(a,r,s,t);for(const r of e){let e=this._tiles[r.key];if(e.hasData())continue;if(r.canonical.z>=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,!(e=this.getTile(o))&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e))break;r=e}for(const e of t)this._loadedParentTiles[e]=i}}_addTile(e){let t=this._tiles[e.key];if(t)return t;(t=this._cache.getAndRemove(e))&&(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 i=Boolean(t);if(!i){const i=this.map?this.map.painter:null,r="raster"===this._source.type||"raster-dem"===this._source.type;t=new fp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,i,r),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,i||this._source.fire(new Mt("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 i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_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()}tilesIn(e,t,i){const r=[],n=this.transform;if(!n)return r;for(const o in this._tiles){const s=this._tiles[o];if(i&&s.clearQueryDebugViz(),s.holdingForFade())continue;const a=e.containsTile(s,n,t);a&&r.push(a)}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Hd(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=Ce.now())return!0}return!1}setFeatureState(e,t,i){e=e||"_geojsonTileLayer",this._state.updateState(e,t,i)}removeFeatureState(e,t,i){e=e||"_geojsonTileLayer",this._state.removeFeatureState(e,t,i)}getFeatureState(e,t){return e=e||"_geojsonTileLayer",this._state.getState(e,t)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.setDependencies(t,i)}reloadTilesForDependencies(e,t){for(const i in this._tiles){this._tiles[i].hasDependency(e,t)&&this._reloadTile(+i,"reloading")}this._cache.filter(i=>!i.hasDependency(e,t))}_preloadTiles(e,t){const i=new Map,r=Array.isArray(e)?e:[e],n=this.map.painter.terrain,o=this.usedForTerrain&&n?n.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)i.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const s=Array.from(i.values()),a="raster"===this._source.type||"raster-dem"===this._source.type;re(s,(e,t)=>{const i=new fp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,a);this._loadTile(i,e=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),t(e,i)})},t)}}function Wd(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Hd(e){return"raster"===e||"image"===e||"video"===e}Xd.maxOverzooming=10,Xd.maxUnderzooming=3;class Kd{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<<t.canonical.z-o.canonical.z,a=(t.canonical.x/s-o.canonical.x)*n.dim,l=(t.canonical.y/s-o.canonical.y)*n.dim,c=r.tileSize/ma/s;return new Kd(r,c,[a,l])}tileCoordToPixel(e,t){const i=e*this._scale+this._offset[0],r=t*this._scale+this._offset[1],o=Math.floor(i),s=Math.floor(r);return new n(o,s)}getElevationAt(e,t,i,r){const n=e*this._scale+this._offset[0],o=t*this._scale+this._offset[1],s=Math.floor(n),a=Math.floor(o),l=this._dem;return r=!!r,i?Wi(Wi(l.get(s,a,r),l.get(s,a+1,r),o-a),Wi(l.get(s+1,a,r),l.get(s+1,a+1,r),o-a),n-s):l.get(s,a,r)}getElevationAtPixel(e,t,i){return this._dem.get(e,t,!!i)}getMeterToDEM(e){return(1<<this._demTile.tileID.canonical.z)*Ta(1,e)*this._dem.stride}}class Jd{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new qn(ma,16,0),this.featureIndexArray=new Cs,this.promoteId=t}insert(e,t,i,r,n,o=0){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n,o);const a=this.grid;for(let e=0;e<t.length;e++){const i=t[e],r=[1/0,1/0,-1/0,-1/0];for(let e=0;e<i.length;e++){const t=i[e];r[0]=Math.min(r[0],t.x),r[1]=Math.min(r[1],t.y),r[2]=Math.max(r[2],t.x),r[3]=Math.max(r[3],t.y)}r[0]<ma&&r[1]<ma&&r[2]>=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new bc.VectorTile(new yh(this.rawTileData)).layers,this.sourceLayerCoder=new Pd(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,i,r){this.loadVTLayers();const n=e.params||{},o=fn(n.filter),s=e.tileResult,a=e.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,(e,t,i,r)=>Wa(s.bufferedTilespaceGeometry,e,t,i,r));c.sort(Qd);let h=null;a.elevation&&c.length>0&&(h=Kd.create(a.elevation,this.tileID));const u={};let d;for(let a=0;a<c.length;a++){const l=c[a];if(l===d)continue;d=l;const p=this.featureIndexArray.get(l);let f=null;this.loadMatchingFeature(u,p,o,n.layers,n.availableImages,t,i,r,(t,i,r,n=0)=>(f||(f=La(t,this.tileID.canonical,e.tileTransform)),i.queryIntersectsFeature(s,t,r,f,this.z,e.transform,e.pixelPosMatrix,h,n)))}return u}loadMatchingFeature(e,t,i,r,n,o,s,a,l){const{featureIndex:c,bucketIndex:h,sourceLayerIndex:u,layoutVertexArrayOffset:d}=t,p=this.bucketLayerIDs[h];if(r&&!function(e,t){for(let i=0;i<e.length;i++)if(t.indexOf(e[i])>=0)return!0;return!1}(r,p))return;const f=this.sourceLayerCoder.decode(u),m=this.vtLayers[f].feature(c);if(i.needGeometry){const e=Ba(m,!0);if(!i.filter(new Ao(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!i.filter(new Ao(this.tileID.overscaledZ),m))return;const _=this.getId(m,f);for(let t=0;t<p.length;t++){const i=p[t];if(r&&r.indexOf(i)<0)continue;const h=o[i];if(!h)continue;let u={};void 0!==_&&a&&(u=a.getState(h.sourceLayer||"_geojsonTileLayer",_));const f=oe({},s[i]);f.paint=Yd(f.paint,h.paint,m,u,n),f.layout=Yd(f.layout,h.layout,m,u,n);const g=!l||l(m,h,u,d);if(!g)continue;const y=new Dd(m,this.z,this.x,this.y,_);y.layer=f;let x=e[i];void 0===x&&(x=e[i]=[]),x.push({featureIndex:c,feature:y,intersectionZ:g})}}lookupSymbolFeatures(e,t,i,r,n,o,s,a){const l={};this.loadVTLayers();const c=fn(n);for(const n of e)this.loadMatchingFeature(l,{bucketIndex:i,sourceLayerIndex:r,featureIndex:n,layoutVertexArrayOffset:0},c,o,s,a,t);return l}loadFeature(e){const{featureIndex:t,sourceLayerIndex:i}=e;this.loadVTLayers();const r=this.sourceLayerCoder.decode(i),n=this.vtFeatures[r];if(n[t])return n[t];const o=this.vtLayers[r].feature(t);return n[t]=o,o}hasLayer(e){for(const t of this.bucketLayerIDs)for(const i of t)if(e===i)return!0;return!1}getId(e,t){let i=e.id;if(this.promoteId){const r="string"==typeof this.promoteId?this.promoteId:this.promoteId[t];"boolean"==typeof(i=e.properties[r])&&(i=Number(i))}return i}}function Yd(e,t,i,r,n){return pe(e,(e,o)=>{const s=t instanceof Ro?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s})}function Qd(e,t){return t-e}Yn("FeatureIndex",Jd,{omit:["rawTileData","sourceLayerCoder"]});var ep=Ho([{name:"a_pos",type:"Int16",components:2}]);const tp=32,ip=tp+1,rp=tp*tp*2-2,np=rp-tp*tp,op=new Uint16Array(4*rp);for(let e=0;e<rp;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=tp:i=r=a=tp;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l}const l=4*e;op[l+0]=i,op[l+1]=r,op[l+2]=n,op[l+3]=o}const sp=new Uint16Array(ip*ip*2),ap=new Uint8Array(ip*ip),lp=new Uint16Array(ip*ip),cp=tp/256/4;function hp(e){return 0===e?-cp:e===ip-1?cp:0}var up=Ho([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const dp=3e4,pp=(()=>({type:2,extent:ma,loadGeometry:()=>[[new n(0,0),new n(ma+1,0),new n(ma+1,ma+1),new n(0,ma+1),new n(0,0)]]}))();class fp{constructor(e,t,i,r,n){this.tileID=e,this.uid=ae(),this.uses=0,this.tileSize=t,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=n,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<Ce.now()||this.fadeEndTime&&t<this.fadeEndTime||(this.fadeEndTime=t)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=$p(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(e,t,i){if(this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=r}}return i}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof td){if(this.hasSymbolBuckets=!0,!i)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof td&&t.hasRTLText){this.hasRTLText=!0,Mo();break}}this.queryPadding=0;for(const e in this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(i))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new bs}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._tileDebugIndexBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this.globeGridBuffer&&(this.globeGridBuffer.destroy(),this.globeGridBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new gd(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new gd(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new gd(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:s,transform:o,params:n,tileTransform:this.tileTransform},e,t,i):{}}querySourceFeatures(e,t){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const r=i.loadVTLayers(),n=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[n];if(!o)return;const s=fn(t&&t.filter),{z:a,x:l,y:c}=this.tileID.canonical,h={z:a,x:l,y:c};for(let t=0;t<o.length;t++){const r=o.feature(t);if(s.needGeometry){const e=Ba(r,!0);if(!s.filter(new Ao(this.tileID.overscaledZ),e,this.tileID.canonical))continue}else if(!s.filter(new Ao(this.tileID.overscaledZ),r))continue;const u=i.getId(r,n),d=new Dd(r,a,l,c,u);d.tile=h,e.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(e){const t=this.expirationTime;if(e.cacheControl){const t=be(e.cacheControl);t["max-age"]&&(this.expirationTime=Date.now()+1e3*t["max-age"])}else e.expires&&(this.expirationTime=new Date(e.expires).getTime());if(this.expirationTime){const e=Date.now();let i=!1;if(this.expirationTime>e)i=!1;else if(t)if(this.expirationTime<t)i=!0;else{const r=this.expirationTime-t;r?this.expirationTime=e+Math.max(r,dp):i=!0}else i=!0;i?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(e,t){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length||!t)return;const i=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages();for(const n in this.buckets){if(!t.style.hasLayer(n))continue;const o=this.buckets[n],s=o.layers[0].sourceLayer||"_geojsonTileLayer",a=i[s],l=e[s];if(!a||!l||0===Object.keys(l).length)continue;if(o.update(l,a,r,this.imageAtlas&&this.imageAtlas.patternPositions||{}),o instanceof Hc||o instanceof oc){const e=t.style._getSourceCache(o.layers[0].source);t._terrain&&t._terrain.enabled&&e&&o.programConfigurations.needsUpload&&t._terrain._clearRenderCacheForTile(e.id,this.tileID)}const c=t&&t.style&&t.style.getLayer(n);c&&(this.queryPadding=Math.max(this.queryPadding,c.queryRadius(o)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<Ce.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(e){this.symbolFadeHoldUntil=Ce.now()+e}setDependencies(e,t){const i={};for(const e of t)i[e]=!0;this.dependencies[e]=i}hasDependency(e,t){for(const i of e){const e=this.dependencies[i];if(e)for(const i of t)if(e[i])return!0}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(e,t){if(!t||"mercator"===t.name||this._tileDebugBuffer)return;const i=La(pp,this.tileID.canonical,this.tileTransform)[0],r=new Jo,n=new gs;for(let e=0;e<i.length;e++){const{x:t,y:o}=i[e];r.emplaceBack(t,o),n.emplaceBack(e)}n.emplaceBack(0),this._tileDebugIndexBuffer=e.createIndexBuffer(n),this._tileDebugBuffer=e.createVertexBuffer(r,up.members),this._tileDebugSegments=fa.simpleSegment(0,0,r.length,n.length)}_makeTileBoundsBuffers(e,t){if(this._tileBoundsBuffer||!t||"mercator"===t.name)return;const i=La(pp,this.tileID.canonical,this.tileTransform)[0];let r,n;if(this.isRaster){const e=function(e,t){const i=$p(e,t),r=Math.pow(2,e.z);for(let n=0;n<ip;n++)for(let o=0;o<ip;o++){const s=Ea((e.x+(o+hp(o))/tp)/r),a=Sa((e.y+(n+hp(n))/tp)/r),l=t.project(s,a),c=n*ip+o;sp[2*c+0]=Math.round((l.x*i.scale-i.x)*ma),sp[2*c+1]=Math.round((l.y*i.scale-i.y)*ma)}ap.fill(0),lp.fill(0);for(let e=rp-1;e>=0;e--){const t=4*e,i=op[t+0],r=op[t+1],n=op[t+2],o=op[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,h=r*ip+i,u=o*ip+n,d=a*ip+s,p=sp[2*h+0],f=sp[2*h+1],m=sp[2*u+0],_=sp[2*u+1],g=sp[2*d+0],y=sp[2*d+1],x=Math.hypot((p+m)/2-g,(f+_)/2-y)>=16;if(ap[d]=ap[d]||(x?1:0),e<np){const e=(r+c>>1)*ip+(i+l>>1),t=(o+c>>1)*ip+(n+l>>1);ap[d]=ap[d]||ap[e]||ap[t]}}const n=new Yo,o=new cs;let s=0;function a(e,t){const i=t*ip+e;return 0===lp[i]&&(n.emplaceBack(sp[2*i+0],sp[2*i+1],e*ma/tp,t*ma/tp),lp[i]=++s),lp[i]-1}function l(e,t,i,r,n,s){const c=e+i>>1,h=t+r>>1;if(Math.abs(e-n)+Math.abs(t-s)>1&&ap[h*ip+c])l(n,s,e,t,c,h),l(i,r,n,s,c,h);else{const l=a(e,t),c=a(i,r),h=a(n,s);o.emplaceBack(l,c,h)}}return l(0,0,tp,tp,tp,0),l(tp,tp,0,0,0,tp),{vertices:n,indices:o}}(this.tileID.canonical,t);r=e.vertices,n=e.indices}else{r=new Yo,n=new cs;for(const{x:e,y:t}of i)r.emplaceBack(e,t,0,0);const e=Tl(r.int16,void 0,4);for(let t=0;t<e.length;t+=3)n.emplaceBack(e[t],e[t+1],e[t+2])}this._tileBoundsBuffer=e.createVertexBuffer(r,up.members),this._tileBoundsIndexBuffer=e.createIndexBuffer(n),this._tileBoundsSegments=fa.simpleSegment(0,0,r.length,n.length)}}const mp=Ho([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2}]),_p=Ho([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:gp,size:yp,alignment:xp}=mp,vp=ma/Math.PI/2,bp=2*Ta(1,0)*vp*Math.PI;class wp{constructor(e,t){this._tr=e,this._worldSize=t,this._globeMatrix=Vp(e,t)}createTileMatrix(e){const t=Op(Pp(e.canonical));return u([],this._globeMatrix,t)}createInversionMatrix(e){const t=h(new Float64Array(16)),i=this._tr.center,r=Up(this._worldSize),n=h(new Float64Array(16));u(n,n,Fp(Pp(e.canonical))),m(n,n,W(i.lng)),f(n,n,W(i.lat)),p(n,n,[1/r,1/r,1]);const o=Ta(1,i.lat)*this._worldSize/this._tr.pixelsPerMeter,s=this._worldSize/o/(2*Math.PI)/(ma/(2*Math.PI));return p(t,t,[s,s,1]),u(n,n,t)}upVector(e,t,i){const r=1<<e.z,n=(t/ma+e.x)/r;return Bp(Sa((i/ma+e.y)/r),Ea(n),1)}upVectorScale(e,t,i){const r=Ta(1,t)*i;return{metersToTile:bp*Rp(Pp(e)),metersToLabelSpace:r}}pointCoordinate(e,t){const i=[e,t,0,1],r=[e,t,1,1];F(i,i,this._tr.pixelMatrixInverse),F(r,r,this._tr.pixelMatrixInverse),R(i,i,1/i[3]),R(r,r,1/r[3]);const n=M([],P([],r,i)),o=z([],[0,0,0],this._globeMatrix),s=this._worldSize/(2*Math.PI),a=[];new il(i,n).closestPointOnSphere(o,s,a);const l=M([],Ae(this._globeMatrix,0)),c=M([],Ae(this._globeMatrix,1)),h=M([],Ae(this._globeMatrix,2)),u=A(l,a),d=A(c,a),p=A(h,a),f=H(Math.asin(-d/s)),m=ba(H(Math.atan2(u,p))),_=wa(f);return new Aa(m,_)}}function Tp(e,t){const i=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,n=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(i)*n/Math.sin(Math.max(Math.PI/2-e._pitch-i,.01)),s=Math.sin(e._pitch)*o+n,a=n*(1/e._horizonShift);return Math.min(1.01*s,a)}const Ep=ma/Math.PI/2,Sp=16383,Ip=64,Mp=512;var Ap={name:"globe",requiresDraping:!0,wrap:!0,supportsWorldCopies:!1,supportsTerrain:!0,supportsFreeCamera:!0,zAxisUnit:"pixels",center:[0,0],unsupportedLayers:["circle","heatmap","fill-extrusion","debug","custom"],atmosphere:{"gradient-inner-color":"rgba(255, 255, 255, 255)","gradient-outer-color":"rgba(3, 190, 252, 255)","gradient-outer-radius":2},project:(e,t)=>({x:ba(e),y:wa(t),z:0}),unproject(e,t){const i=Ea(e),r=Sa(t);return new ya(i,r)},projectTilePoint(e,t,i){const r=Math.pow(2,i.z),n=(e/ma+i.x)/r,o=Bp(Sa((t/ma+i.y)/r),Ea(n));return z(o,o,Fp(Pp(i))),{x:o[0],y:o[1],z:o[2]}},locationPoint(e,t){const i=Bp(t.lat,t.lng),r=M([],i),o=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;I(i,i,r,Ta(1,0)*ma*o);const s=Vp(e,e.worldSize);return u(s,e.pixelMatrix,s),z(i,i,s),new n(i[0],i[1])},pixelsPerMeter:(e,t)=>Ta(1,0)*t,createTileTransform:(e,t)=>new wp(e,t),farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=b([],S([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,h=Math.tan(e.fovAboveCenter),u=S([],n.up(),h),d=S([],n.right(),h*c),p=M([],b([],b([],o,u),d)),f=[];let m;if(new il(s,p).closestPointOnSphere(l,a,f)){const t=b([],f,l),i=P([],t,s);m=Math.cos(e.fovAboveCenter)*x(i)}else{const e=P([],s,l),t=P([],l,s);M(t,t);const i=x(e)-a;m=Math.sqrt(i*i+2*a*i);const r=Math.acos(m/(a+i))-Math.acos(A(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=Gp(e.zoom);if(i>0){return Wi(t,Tp(e,Ta(1,e.center.lat)*e.worldSize),i)}return t}};const Cp=-Ep,zp=Ep,kp=[new nl([Cp,Cp,Cp],[zp,zp,zp]),new nl([Cp,Cp,Cp],[0,0,zp]),new nl([0,Cp,Cp],[zp,0,zp]),new nl([Cp,0,Cp],[0,zp,zp]),new nl([0,0,Cp],[zp,zp,zp])];function Pp(e){if(e.z<=1)return kp[e.z+2*e.y+e.x];const[t,i]=Dp(e),r=[Bp(t[0],t[1]),Bp(t[0],i[1]),Bp(i[0],t[1]),Bp(i[0],i[1])],n=[zp,zp,zp],o=[Cp,Cp,Cp];for(const e of r)n[0]=Math.min(n[0],e[0]),n[1]=Math.min(n[1],e[1]),n[2]=Math.min(n[2],e[2]),o[0]=Math.max(o[0],e[0]),o[1]=Math.max(o[1],e[1]),o[2]=Math.max(o[2],e[2]);return new nl(n,o)}function Dp(e){const t=Math.pow(2,e.z),i=e.x/t,r=(e.x+1)/t,n=e.y/t,o=(e.y+1)/t;return[[Sa(n),Ea(i)],[Sa(o),Ea(r)]]}function Lp(e,t,i,r){return i=W(i),r||(r=Ep),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function Bp(e,t,i){return Lp(Math.cos(W(e)),Math.sin(W(e)),t,i)}function Rp(e){const t=Math.max(...P([],e.max,e.min));return Sp/t}function Fp(e){const t=h(new Float64Array(16)),i=Rp(e);var r,n;return p(t,t,[i,i,i]),d(t,t,(r=[],n=e.min,r[0]=-n[0],r[1]=-n[1],r[2]=-n[2],r)),t}function Op(e){const t=h(new Float64Array(16)),i=1/Rp(e);return d(t,t,e.min),p(t,t,[i,i,i]),t}function Up(e){const t=ma/(2*Math.PI);return e/(2*Math.PI)/t}function Vp(e,t,i){const r=t/(2*Math.PI),n=Up(t);if(!i){const r=ee(e.center.lat,-Ma,Ma);i=[ba(e.center.lng)*t,wa(r)*t]}const o=h(new Float64Array(16));return d(o,o,[i[0],i[1],-r]),p(o,o,[n,n,n]),f(o,o,W(-e._center.lat)),m(o,o,W(-e._center.lng)),o}const Np=5,jp=6;function Gp(e){return te(Np,jp,e)}class Zp{constructor(e){const t=this._createGridIndices();this.gridIndexBuffer=e.createIndexBuffer(t,!0);const i=Ip*Ip*2,r=(Ip+1)*(Ip+1);this.gridSegments=fa.simpleSegment(0,0,r,i);const n=this._createPoleTriangleIndices();this.poleIndexBuffer=e.createIndexBuffer(n,!0);const o=this._createPoleVerticesForAllZooms(!0),s=this._createPoleVerticesForAllZooms(!1);this.poleNorthVertexBuffer=e.createVertexBuffer(o,gp,!1),this.poleSouthVertexBuffer=e.createVertexBuffer(s,gp,!1),this.poleSegments=this._createPoleSegments();const a=new fs;a.emplaceBack(-1,1,1,0,0,0,0),a.emplaceBack(1,1,1,0,0,1,0),a.emplaceBack(1,-1,1,0,0,1,1),a.emplaceBack(-1,-1,1,0,0,0,1);const l=new cs;l.emplaceBack(0,1,2),l.emplaceBack(2,3,0),this.atmosphereVertexBuffer=e.createVertexBuffer(a,_p.members),this.atmosphereIndexBuffer=e.createIndexBuffer(l),this.atmosphereSegments=fa.simpleSegment(0,0,4,2)}destroy(){this.poleIndexBuffer.destroy(),this.gridIndexBuffer.destroy(),this.poleNorthVertexBuffer.destroy(),this.poleSouthVertexBuffer.destroy(),this.poleSegments.destroy(),this.gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this.wireframeIndexBuffer&&(this.wireframeIndexBuffer.destroy(),this.wireframeSegments.destroy())}_createPoleVertices(e,t,i){const r=(e,t,i)=>e*(1-i)+t*i,n=1<<e,o=n*Mp/Math.PI/2;i.emplaceBack(0,-o,0,0,0,.5,t?0:1);const s=360/n,a=Math.cos(W(85)),l=Math.sin(W(85));for(let e=0;e<=Ip;e++){const n=e/Ip,c=Lp(a,l,r(0,s,n),o);i.emplaceBack(c[0],c[1],c[2],0,0,n,t?0:1)}}_createPoleVerticesForAllZooms(e){const t=new fs;for(let i=0;i<Np;i++)this._createPoleVertices(i,e,t);return t}_createPoleTriangleIndices(){const e=new cs;for(let t=0;t<=Ip;t++)e.emplaceBack(0,t+1,t+2);return e}_createPoleSegments(){const e=[];let t=0;const i=Ip,r=Ip+2;for(let n=0;n<Np;n++)e.push({vertexOffset:t,primitiveOffset:0,vertexLength:r,primitiveLength:i,vaos:{},sortKey:0}),t+=r;return new fa(e)}static createGridVertices(e){const t=Math.pow(2,e.z),i=(e,t,i)=>e*(1-i)+t*i,[r,n]=Dp(e),o=new fs,s=Fp(Pp(e)),a=Ip+1;o.reserve(Ip*Ip);for(let l=0;l<a;l++){const c=i(r[0],n[0],l/Ip),h=wa(c),u=h*t-e.y,d=Math.sin(W(c)),p=Math.cos(W(c));for(let e=0;e<a;e++){const t=e/Ip,a=i(r[1],n[1],t),l=Lp(p,d,a);z(l,l,s);const c=ba(a);o.emplaceBack(l[0],l[1],l[2],c,h,t,u)}}return o}_createGridIndices(){const e=new cs,t=Ip,i=t+1,r=(t,r)=>{const n=r*i+t;e.emplaceBack(n+1,n,n+i),e.emplaceBack(n+i,n+i+1,n+1)};for(let e=0;e<t;e++)for(let i=0;i<t;i++)r(i,e);return e}getWirefameBuffer(e){if(!this.wireframeSegments){const t=this._createWireframeGrid();this.wireframeIndexBuffer=e.createIndexBuffer(t);const i=Ip*Ip;this.wireframeSegments=fa.simpleSegment(0,0,i,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}_createWireframeGrid(){const e=new _s,t=Ip,i=t+1,r=(t,r)=>{const n=r*i+t;e.emplaceBack(n,n+1),e.emplaceBack(n,n+i),e.emplaceBack(n,n+i+1)};for(let e=0;e<t;e++)for(let i=0;i<t;i++)r(i,e);return e}getPoleBuffersForTile(e,t){return[t?this.poleNorthVertexBuffer:this.poleSouthVertexBuffer,e>=0&&e<this.poleSegments.get().length?new fa([this.poleSegments.get()[e]]):null]}}function $p(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<<e.z,x:e.x,y:e.y,x2:e.x+1,y2:e.y+1,projection:t};const i=Math.pow(2,-e.z),r=e.x*i,n=(e.x+1)*i,o=e.y*i,s=(e.y+1)*i,a=Ea(r),l=Ea(n),c=Sa(o),h=Sa(s),u=t.project(a,c),d=t.project(l,c),p=t.project(l,h),f=t.project(a,h);let m=Math.min(u.x,d.x,p.x,f.x),_=Math.min(u.y,d.y,p.y,f.y),g=Math.max(u.x,d.x,p.x,f.x),y=Math.max(u.y,d.y,p.y,f.y);const x=i/16;function v(e,i,r,n,o,s){const a=(r+o)/2,l=(n+s)/2,c=t.project(Ea(a),Sa(l)),h=Math.max(0,m-c.x,_-c.y,c.x-g,c.y-y);m=Math.min(m,c.x),g=Math.max(g,c.x),_=Math.min(_,c.y),y=Math.max(y,c.y),h>x&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s))}v(u,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,u,r,s,r,o),m-=x,_-=x,g+=x,y+=x;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}const qp=1,Xp=qp*vu;class Wp{constructor(e){const t={},i=[];for(const r in e){const n=e[r],o=t[r]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const r=t.metrics.localGlyph?Xp:qp,s={x:0,y:0,w:t.bitmap.width+2*r,h:t.bitmap.height+2*r};i.push(s),o[e]=s}}const{w:r,h:n}=Nh(i),o=new fl({width:r||1,height:n||1});for(const i in e){const r=e[i];for(const e in r.glyphs){const n=r.glyphs[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const s=t[i][e],a=n.metrics.localGlyph?Xp:qp;fl.copy(n.bitmap,o,{x:0,y:0},{x:s.x+a,y:s.y+a},n.bitmap)}}this.image=o,this.positions=t}}Yn("GlyphAtlas",Wp);class Hp{constructor(e){this.tileID=new Id(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.tileZoom=e.tileZoom,this.uid=e.uid,this.zoom=e.zoom,this.canonical=e.tileID.canonical,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.enableTerrain=!!e.enableTerrain,this.isSymbolTile=e.isSymbolTile,this.tileTransform=$p(e.tileID.canonical,e.projection),this.projection=e.projection}parse(e,t,i,r,n){this.status="parsing",this.data=e,this.collisionBoxArray=new bs;const o=new Pd(Object.keys(e.layers).sort()),s=new Jd(this.tileID,this.promoteId);s.bucketLayerIDs=[];const a={},l=new yd(256,256),c={featureIndex:s,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:i},h=t.familiesBySource[this.source];for(const t in h){const r=e.layers[t];if(!r)continue;let n=!1,l=!1;for(const e of h[t])"symbol"===e[0].type?n=!0:l=!0;if(!0===this.isSymbolTile&&!n)continue;if(!1===this.isSymbolTile&&!l)continue;1===r.version&&ge(`Vector tile source "${this.source}" layer "${t}" `+"does not use vector tile spec v2 and therefore may have some rendering errors.");const u=o.encode(t),d=[];for(let e=0;e<r.length;e++){const i=r.feature(e),n=s.getId(i,t);d.push({feature:i,id:n,index:e,sourceLayerIndex:u})}for(const e of h[t]){const t=e[0];void 0!==this.isSymbolTile&&"symbol"===t.type!==this.isSymbolTile||(t.minzoom&&this.zoom<Math.floor(t.minzoom)||t.maxzoom&&this.zoom>=t.maxzoom||"none"!==t.visibility&&(Kp(e,this.zoom,i),(a[t.id]=t.createBucket({index:s.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:u,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:i})).populate(d,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(e.map(e=>e.id))))}}let u,d,p,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=pe(c.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},(e,t)=>{u||(u=e,d=t,x.call(this))},void 0,!1,m):d={};const g=Object.keys(c.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},(e,t)=>{u||(u=e,p=t,x.call(this))},void 0,!1,m):p={};const y=Object.keys(c.patternDependencies);function x(){if(u)return n(u);if(d&&p&&f){const e=new Wp(d),t=new Zh(p,f);for(const r in a){const n=a[r];n instanceof td?(Kp(n.layers,this.zoom,i),Ou(n,d,e.positions,p,t.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection),n.projection=this.projection.name):n.hasPattern&&(n instanceof Hc||n instanceof oc||n instanceof Cc)&&(Kp(n.layers,this.zoom,i),n.addFeatures(c,this.tileID.canonical,t.patternPositions,i))}this.status="done",n(null,{buckets:ne(a).filter(e=>!e.isEmpty()),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?p:null,glyphPositions:this.returnDependencies?e.positions:null})}}y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},(e,t)=>{u||(u=e,f=t,x.call(this))},void 0,!1,m):f={},x.call(this)}}function Kp(e,t,i){const r=new Ao(t);for(const t of e)t.recalculate(r,i)}class Jp{constructor(e){this.entries={},this.scheduler=e}request(e,t,i,r){const n=this.entries[e]=this.entries[e]||{callbacks:[]};if(n.result){const[e,i]=n.result;return this.scheduler?this.scheduler.add(()=>{r(e,i)},t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add(()=>{e(i,r)},t):e(i,r);setTimeout(()=>delete this.entries[e],3e3)})),()=>{n.result||(n.callbacks=n.callbacks.filter(e=>e!==r),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}}function Yp(e,t,i){const r=JSON.stringify(e.request);e.data&&(this.deduped.entries[r]={result:[null,e.data]});const n={type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom};return this.deduped.request(r,n,t=>{const r=gt(e.request,(e,r,n,o)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new bc.VectorTile(new yh(r)),rawData:r,cacheControl:n,expires:o})});return()=>{r.cancel(),t()}},t)}const Qp=h(new Float64Array(16));class ef{constructor(e,t){this._tr=e,this._worldSize=t}createInversionMatrix(){return Qp}createTileMatrix(e){let t,i,r;const n=e.canonical,o=h(new Float64Array(16)),s=this._tr.projection;if(s.isReprojectedInTileSpace){const a=$p(n,s);t=1,i=a.x+e.wrap*a.scale,r=a.y,p(o,o,[t/a.scale,t/a.scale,this._tr.pixelsPerMeter/this._worldSize])}else{t=this._worldSize/this._tr.zoomScale(n.z),i=(n.x+Math.pow(2,n.z)*e.wrap)*t,r=n.y*t}return d(o,o,[i,r,0]),p(o,o,[t/ma,t/ma,1]),o}pointCoordinate(e,t,i){const r=this._tr.horizonLineFromTop(!1),o=new n(e,Math.max(r,t));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(o,i))}upVector(){return[0,0,1]}upVectorScale(){return{metersToTile:1,metersToLabelSpace:1}}}var tf={name:"albers",range:[4,7],center:[-96,37.5],parallels:[29.5,45.5],zAxisUnit:"meters",conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&$(this.parallels,this.constants.parallels))return;const e=Math.sin(W(this.parallels[0])),t=(e+Math.sin(W(this.parallels[1])))/2,i=1+e*(2*t-e),r=Math.sqrt(i)/t;this.constants={n:t,c:i,r0:r,parallels:this.parallels}},project(e,t){this.initializeConstants();const i=W(e-this.center[0]),r=W(t),{n:n,c:o,r0:s}=this.constants,a=Math.sqrt(o-2*n*Math.sin(r))/n;return{x:a*Math.sin(i*n),y:a*Math.cos(i*n)-s,z:0}},unproject(e,t){this.initializeConstants();const{n:i,c:r,r0:n}=this.constants,o=n+t;let s=Math.atan2(e,Math.abs(o))*Math.sign(o);o*i<0&&(s-=Math.PI*Math.sign(e)*Math.sign(o));const a=W(this.center[0])*i,l=H((s=ie(s,-Math.PI-a,Math.PI-a))/i)+this.center[0],c=Math.asin(ee((r-(e*e+o*o)*i*i)/(2*i),-1,1)),h=ee(H(c),-Ma,Ma);return new ya(l,h)},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)};const rf=1.340264,nf=-.081106,of=893e-6,sf=.003796,af=Math.sqrt(3)/2;var lf={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(e,t){t=t/180*Math.PI,e=e/180*Math.PI;const i=Math.asin(af*Math.sin(t)),r=i*i,n=r*r*r,o=e*Math.cos(i)/(af*(rf+3*nf*r+n*(7*of+9*sf*r))),s=i*(rf+nf*r+n*(of+sf*r));return{x:.5*(o/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}},unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=i*i,n=r*r*r;for(let e,o,s,a=0;a<12&&(n=(r=(i=ee(i-(e=(o=i*(rf+nf*r+n*(of+sf*r))-t)/(s=rf+3*nf*r+n*(7*of+9*sf*r))),-Math.PI/3,Math.PI/3))*i)*r*r,!(Math.abs(e)<1e-12));++a);const o=af*e*(rf+3*nf*r+n*(7*of+9*sf*r))/Math.cos(i),s=Math.asin(Math.sin(i)/af),a=ee(180*o/Math.PI,-180,180),l=ee(180*s/Math.PI,-Ma,Ma);return new ya(a,l)},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)},cf={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(e,t)=>({x:.5+e/360,y:.5-t/360,z:0}),unproject(e,t){const i=360*(e-.5),r=ee(360*(.5-t),-Ma,Ma);return new ya(i,r)},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)};const hf=Math.PI/2;function uf(e){return Math.tan((hf+e)/2)}var df={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&$(this.parallels,this.constants.parallels))return;const e=W(this.parallels[0]),t=W(this.parallels[1]),i=Math.cos(e),r=e===t?Math.sin(e):Math.log(i/Math.cos(t))/Math.log(uf(t)/uf(e)),n=i*Math.pow(uf(e),r)/r;this.constants={n:r,f:n,parallels:this.parallels}},project(e,t){this.initializeConstants(),t=W(t),e=W(e-this.center[0]);const{n:i,f:r}=this.constants;r>0?t<1e-6-hf&&(t=1e-6-hf):t>hf-1e-6&&(t=hf-1e-6);const n=r/Math.pow(uf(t),i),o=n*Math.sin(i*e),s=r-n*Math.cos(i*e);return{x:.5*(o/Math.PI+.5),y:1-.5*(s/Math.PI+.5),z:0}},unproject(e,t){this.initializeConstants(),e=(2*e-.5)*Math.PI,t=(2*(1-t)-.5)*Math.PI;const{n:i,f:r}=this.constants,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=ee(H(a/i)+this.center[0],-180,180),c=ee(H(2*Math.atan(Math.pow(r/s,1/i))-hf),-Ma,Ma);return new ya(l,c)},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)},pf={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(e,t)=>({x:ba(e),y:wa(t),z:0}),unproject(e,t){const i=Ea(e),r=Sa(t);return new ya(i,r)},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)};const ff=W(Ma);var mf={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(e,t){const i=(t=W(t))*t,r=i*i,n=t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)));return{x:.5*((e=W(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(n/Math.PI+1),z:0}},unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{const e=(o=i*i)*o;i=ee(i-(n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e)))),-ff,ff)}while(Math.abs(n)>1e-6&&--r>0);const s=ee(H(e/(.8707+(o=i*i)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=H(i);return new ya(s,a)},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)};const _f=W(Ma);const gf={globe:Ap,albers:tf,equalEarth:lf,equirectangular:cf,lambertConformalConic:df,mercator:pf,naturalEarth:mf,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(e,t){t=W(t),e=W(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}},unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;let o=0,s=0;do{const n=Math.cos(r),a=Math.sin(r),l=2*a*n,c=a*a,h=n*n,u=Math.cos(i/2),d=Math.sin(i/2),p=2*u*d,f=d*d,m=1-h*u*u,_=m?1/m:0,g=m?Math.acos(n*u)*Math.sqrt(1/m):0,y=.5*(2*g*n*d+2*i/Math.PI)-e,x=.5*(g*a+r)-t,v=.5*_*(h*f+g*n*u*c)+1/Math.PI,b=_*(p*l/4-g*a*d),w=.125*_*(l*d-g*a*h*p),T=.5*_*(c*u+g*f*n)+.5,E=b*w-T*v;s=(y*w-x*v)/E,i=ee(i-(o=(x*b-y*T)/E),-Math.PI,Math.PI),r=ee(r-s,-_f,_f)}while((Math.abs(o)>1e-6||Math.abs(s)>1e-6)&&--n>0);return new ya(H(i),H(r))},projectTilePoint:(e,t)=>({x:e,y:t,z:0}),locationPoint:(e,t)=>e._coordinatePoint(e.locationCoordinate(t),!1),pixelsPerMeter:(e,t)=>Ta(1,e)*t,farthestPixelDistance(e){return Tp(e,this.pixelsPerMeter(e.center.lat,e.worldSize))},createTileTransform:(e,t)=>new ef(e,t)}};function yf(e,t){if(t.parallels&&Math.abs(t.parallels[0]+t.parallels[1])<.01){let i=function(e){const t=Math.max(.01,Math.cos(W(e))),i=1/(2*Math.max(Math.PI*t,1/t));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom"],project(e,r){const n=W(e)*t,o=Math.sin(W(r))/t;return{x:n*i+.5,y:-o*i+.5,z:0}},unproject(e,r){const n=-(r-.5)/i,o=ee(H((e-.5)/i)/t,-180,180),s=n*t,a=Math.asin(ee(s,-1,1)),l=ee(H(a),-Ma,Ma);return new ya(o,l)}}}(t.parallels[0]);if("lambertConformalConic"===t.name){const{project:e,unproject:t}=gf.mercator;i={wrap:!0,supportsWorldCopies:!0,project:e,unproject:t}}return oe({},e,t,i)}return e}e.ARRAY_TYPE=l,e.AUTH_ERR_MSG=Ue,e.Aabb=nl,e.Actor=class{constructor(e,t,i){this.target=e,this.parent=t,this.mapId=i,this.callbacks={},this.cancelCallbacks={},ue(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=ve()?e:s,this.scheduler=new wd}send(e,t,i,r,n=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=Ie(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:e,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:to(t,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"<cancel>",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if("<cancel>"===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||ve()){const e=this.callbacks[i],r=e&&e.metadata||{type:"message"};this.cancelCallbacks[i]=this.scheduler.add(()=>this.processTask(i,t),r)}else this.processTask(i,t)}processTask(e,t){if("<response>"===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(io(t.error)):i(null,io(t.data)))}else{const i=Ie(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:t?to(t):null,data:to(r,i)},i)}:e=>{},n=io(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],n.source)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Ed,e.Color=ii,e.ColorMode=zd,e.CullFaceMode=kd,e.DEMData=$d,e.DataConstantProperty=Fo,e.DedupedRequest=Jp,e.DepthMode=Ad,e.EXTENT=ma,e.Elevation=class{getAtPointOrZero(e,t=0){return this.getAtPoint(e,t)||0}getAtPoint(e,t,i=!0){null==t&&(t=null);const r=this._source();if(!r)return t;if(e.y<0||e.y>1)return t;const n=r.getSource().maxzoom,o=1<<n,s=Math.floor(e.x),a=e.x-s,l=new Id(n,s,n,Math.floor(a*o),Math.floor(e.y*o)),c=this.findDEMTileFor(l);if(!c||!c.dem)return t;const h=c.dem,u=1<<c.tileID.canonical.z,d=(a*u-c.tileID.canonical.x)*h.dim,p=(e.y*u-c.tileID.canonical.y)*h.dim,f=Math.floor(d),m=Math.floor(p);return(i?this.exaggeration():1)*Wi(Wi(h.get(f,m),h.get(f,m+1),p-m),Wi(h.get(f+1,m),h.get(f+1,m+1),p-m),d-f)}getAtTileOffset(e,t,i){const r=1<<e.canonical.z;return this.getAtPointOrZero(new Aa(e.wrap+(e.canonical.x+t/ma)/r,(e.canonical.y+i/ma)/r))}getAtTileOffsetFunc(e,t,i,r){return n=>{const o=this.getAtTileOffset(e,n.x,n.y),s=r.upVector(e.canonical,n.x,n.y);return S(s,s,o*r.upVectorScale(e.canonical,t,i).metersToTile),s}}getForTilePoints(e,t,i,r){const n=Kd.create(this,e,r);return!!n&&(t.forEach(e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)}),!0)}getMinMaxForTile(e){const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<<e.canonical.z-r.canonical.z;let o=e.canonical.x/n-r.canonical.x,s=e.canonical.y/n-r.canonical.y,a=0;for(let t=0;t<e.canonical.z-r.canonical.z&&!i.leaves[a];t++){o*=2,s*=2;const e=2*Math.floor(s)+Math.floor(o);a=i.childOffsets[a]+e,o%=1,s%=1}return{min:this.exaggeration()*i.minimums[a],max:this.exaggeration()*i.maximums[a]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(e,t,i){throw new Error("Pure virtual method called.")}pointCoordinate(e){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(e){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},e.ErrorEvent=At,e.EvaluationParameters=Ao,e.Event=Mt,e.Evented=Ct,e.Frustum=rl,e.GLOBE_ZOOM_THRESHOLD_MAX=jp,e.GlobeSharedBuffers=Zp,e.GlyphManager=wu,e.ImagePosition=Gh,e.LineAtlas=yd,e.LngLat=ya,e.LngLatBounds=_a,e.LocalGlyphMode=bu,e.MAX_MERCATOR_LATITUDE=Ma,e.MercatorCoordinate=Aa,e.ONE_EM=sh,e.OverscaledTileID=Id,e.Properties=jo,e.RGBAImage=ml,e.Ray=il,e.RequestManager=class{constructor(e,t,i){this._transformRequestFn=e,this._customAccessToken=t,this._silenceAuthErrors=!!i,this._createSkuToken()}_createSkuToken(){const e=function(){let e="";for(let t=0;t<10;t++)e+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Oe,e].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=e.token,this._skuTokenExpiresAt=e.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!Ve(e))return e;const i=Ge(e);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!Ve(e))return e;const i=Ge(e);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||t)}normalizeSourceURL(e,t){if(!Ve(e))return e;const i=Ge(e);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,i,r){const n=Ge(e);return Ve(e)?(n.path=`/styles/v1${n.path}/sprite${t}${i}`,this._makeAPIURL(n,this._customAccessToken||r)):(n.path+=`${t}${i}`,Ze(n))}normalizeTileURL(e,t,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!Ve(e))return e;const r=Ge(e),n=Pe.supported?".webp":"$1",o=i&&"raster"!==r.authority&&512===i,s=t||o?"@2x":"";if(r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${s}${n}`),"raster"===r.authority)r.path=`/${ke.RASTER_URL_PREFIX}${r.path}`;else{const e=/^.+\/v4\//;r.path=r.path.replace(e,"/"),r.path=`/${ke.TILE_URL_VERSION}${r.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}(r.params)||ke.ACCESS_TOKEN;return ke.REQUIRE_ACCESS_TOKEN&&a&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,a)}canonicalizeTileURL(e,t){const i=Ge(e);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return e;let r="mapbox://";if(i.path.match(/^\/raster\/v1\//)){const e=`/${ke.RASTER_URL_PREFIX}/`;r+=`raster/${i.path.replace(e,"")}`}else{const e=`/${ke.TILE_URL_VERSION}/`;r+=`tiles/${i.path.replace(e,"")}`}let n=i.params;return t&&(n=n.filter(e=>!e.match(/^access_token=/))),n.length&&(r+=`?${n.join("&")}`),r}canonicalizeTileset(e,t){const i=!!t&&Ve(t),r=[];for(const t of e.tiles||[])Ne(t)?r.push(this.canonicalizeTileURL(t,i)):r.push(t);return r}_makeAPIURL(e,t){const i="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=Ge(ke.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!ke.REQUIRE_ACCESS_TOKEN)return Ze(e);if(t=t||ke.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===t[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push(`access_token=${t||""}`),Ze(e)}},e.ResourceType=dt,e.SegmentVector=fa,e.SourceCache=Xd,e.StencilMode=Cd,e.StructArrayLayout1ui2=gs,e.StructArrayLayout2f1f2i16=as,e.StructArrayLayout2i4=Jo,e.StructArrayLayout2ui4=_s,e.StructArrayLayout3f12=es,e.StructArrayLayout3ui6=cs,e.StructArrayLayout4i8=Yo,e.Texture=gd,e.Tile=fp,e.Transitionable=ko,e.Uniform1f=Gs,e.Uniform1i=class extends js{constructor(e,t){super(e,t),this.current=0}set(e){this.current!==e&&(this.current=e,this.gl.uniform1i(this.location,e))}},e.Uniform2f=class extends js{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.Uniform3f=class extends js{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.Uniform4f=Zs,e.UniformColor=$s,e.UniformMatrix2f=class extends js{constructor(e,t){super(e,t),this.current=Ws}set(e){for(let t=0;t<4;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix2fv(this.location,!1,e);break}}},e.UniformMatrix3f=class extends js{constructor(e,t){super(e,t),this.current=Xs}set(e){for(let t=0;t<9;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix3fv(this.location,!1,e);break}}},e.UniformMatrix4f=class extends js{constructor(e,t){super(e,t),this.current=qs}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.UnwrappedTileID=Sd,e.ValidationError=kt,e.VectorTileWorkerSource=class extends Ct{constructor(e,t,i,r,n){super(),this.actor=e,this.layerIndex=t,this.availableImages=i,this.loadVectorData=n||Yp,this.loading={},this.loaded={},this.deduped=new Jp(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler}loadTile(e,t){const i=e.uid,r=e&&e.request,n=r&&r.collectResourceTiming,o=this.loading[i]=new Hp(e);o.abort=this.loadVectorData(e,(s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),t(s);const c=a.rawData,h={};a.expires&&(h.expires=a.expires),a.cacheControl&&(h.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new bc.VectorTile(new yh(c));const u=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,(e,i)=>{if(e||!i)return t(e);const o={};if(n){const e=bd(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,oe({rawTileData:c.slice(0)},i,h,o))})};this.isSpriteLoaded?u():this.once("isSpriteLoaded",()=>{if(this.scheduler){const t={type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom};this.scheduler.add(u,t)}else u()}),this.loaded=this.loaded||{},this.loaded[i]=o})}reloadTile(e,t){const i=this.loaded,r=e.uid,n=this;if(i&&i[r]){const o=i[r];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection;const s=(e,i)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),t(e,i)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}},e.WritingMode=$h,e.ZoomHistory=ro,e.add=b,e.addDynamicAttributes=Ju,e.adjoint=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8];return e[0]=s*h-a*c,e[1]=n*c-r*h,e[2]=r*a-n*s,e[3]=a*l-o*h,e[4]=i*h-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e},e.asyncAll=re,e.bezier=Y,e.bindAll=ue,e.boundsAttributes=up,e.bufferConvexPolygon=function(e,t){const i=[];for(let r=0;r<e.length;r++){const n=ie(r-1,-1,e.length-1),o=ie(r+1,-1,e.length-1),s=e[n],a=e[r],l=e[o],c=s.sub(a).unit(),h=l.sub(a).unit(),u=h.angleWithSep(c.x,c.y),d=c.add(h).unit().mult(-1*t/Math.sin(u/2));i.push(a.add(d))}return i},e.cacheEntryPossiblyAdded=function(e){++ut>rt&&(e.getActor().send("enforceCacheSizeLimit",it),ut=0)},e.calculateGlobeMatrix=Vp,e.calculateGlobeMercatorMatrix=function(e){const t=e.worldSize,i=ee(e.center.lat,-Ma,Ma),r=new n(ba(e.center.lng)*t,wa(i)*t),o=Ta(1,e.center.lat)*t/e.pixelsPerMeter,s=e.pixelsPerMeter,a=t/o,l=h(new Float64Array(16));return d(l,l,[r.x,r.y,0]),p(l,l,[a,a,s]),l},e.clamp=ee,e.clearTileCache=function(e){const t=s.caches.delete(tt);e&&t.catch(e).then(()=>e())},e.clipLine=_u,e.clone=function(e){var t=new l(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=me,e.collisionCircleLayout=oh,e.config=ke,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 l(16);return l!=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=c,e.createExpression=tn,e.createLayout=Ho,e.createStyleLayer=function(e){return"custom"===e.type?new ld(e):new ud[e.type](e)},e.cross=C,e.degToRad=W,e.div=L,e.dot=A,e.ease=Q,e.easeCubicInOut=J,e.emitValidationErrors=$n,e.endsWith=de,e.enforceCacheSizeLimit=function(e){at(),ot&&ot.then(t=>{t.keys().then(i=>{for(let r=0;r<i.length-e;r++)t.delete(i[r])})})},e.evaluateSizeForFeature=ch,e.evaluateSizeForZoom=hh,e.evaluateVariableOffset=Fu,e.evented=To,e.exactEquals=Z,e.exactEquals$1=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]},e.exported=Ce,e.exported$1=Pe,e.extend=oe,e.extend$1=Dt,e.filterObject=fe,e.fromMat4=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e},e.fromQuat=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,h=r*s,u=r*a,d=n*s,p=n*a,f=n*l,m=o*s,_=o*a,g=o*l;return e[0]=1-u-f,e[1]=h+g,e[2]=d-_,e[3]=0,e[4]=h-g,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+_,e[9]=p-m,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.fromRotation=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.fromScaling=function(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},e.furthestTileCorner=function(e){const t=(e+45+360)%360,i=Math.round(t/90)%4;return K[i]},e.getAABBPointSquareDist=function(e,t,i){let r=0;for(let n=0;n<2;++n){const o=i?i[n]:0;e[n]>o&&(r+=(e[n]-o)*(e[n]-o)),t[n]<o&&(r+=(o-t[n])*(o-t[n]))}return r},e.getAnchorAlignment=ou,e.getAnchorJustification=Uu,e.getBounds=function(e){let t=1/0,i=1/0,r=-1/0,o=-1/0;for(const n of e)t=Math.min(t,n.x),i=Math.min(i,n.y),r=Math.max(r,n.x),o=Math.max(o,n.y);return{min:new n(t,i),max:new n(r,o)}},e.getColumn=Ae,e.getImage=Et,e.getJSON=function(e,t){return _t(oe(e,{type:"json"}),t)},e.getMapSessionAPI=Qe,e.getPerformanceMeasurement=bd,e.getProjection=function(e){const t=gf[e.name];if(!t)throw new Error(`Invalid projection name: ${e.name}`);return oe({},t.conic?yf(t,e):t,e)},e.getRTLTextPluginStatus=Eo,e.getReferrer=ft,e.getTilePoint=function(e,{x:t,y:i},r=0){return new n(((t-r)*e.scale-e.x)*ma,(i*e.scale-e.y)*ma)},e.getTileVec3=function(e,t,i=0){return v(((t.x-i)*e.scale-e.x)*ma,(t.y*e.scale-e.y)*ma,Ia(t.z,t.y))},e.getVideo=function(e,t){const i=s.document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t<e.length;t++){const r=s.document.createElement("source");vt(e[t])||(i.crossOrigin="Anonymous"),r.src=e[t],i.appendChild(r)}return{cancel:()=>{}}},e.globeDenormalizeECEF=Op,e.globeMatrixForTile=function(e,t){const i=Op(Pp(e)),r=(n=new Float64Array(16),o=t,n[0]=o[0],n[1]=o[1],n[2]=o[2],n[3]=o[3],n[4]=o[4],n[5]=o[5],n[6]=o[6],n[7]=o[7],n[8]=o[8],n[9]=o[9],n[10]=o[10],n[11]=o[11],n[12]=o[12],n[13]=o[13],n[14]=o[14],n[15]=o[15],n);var n,o;return _(r,r,i),r},e.globePoleMatrixForTile=function(e,t,i){const r=h(new Float64Array(16)),n=Math.pow(2,e.z),o=(e.x-n/2)/n*Math.PI*2,s=i.point,a=i.worldSize,l=i.worldSize/(i.tileSize*n);return d(r,r,[s.x,s.y,-a/Math.PI/2]),p(r,r,[l,l,l]),f(r,r,W(-i._center.lat)),m(r,r,W(-i._center.lng)),m(r,r,o),t||p(r,r,[1,-1,1]),r},e.globeTileBounds=Pp,e.globeToMercatorTransition=Gp,e.globeVertexBufferForTileMesh=function(e,t,i){const r=e.context,n=i.canonical;let o=t.globeGridBuffer;if(!o){const e=Zp.createGridVertices(n);o=t.globeGridBuffer=r.createVertexBuffer(e,gp,!1)}return o},e.identity=h,e.identity$1=V,e.invert=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],p=t[11],f=t[12],m=t[13],_=t[14],g=t[15],y=i*a-r*s,x=i*l-n*s,v=i*c-o*s,b=r*l-n*a,w=r*c-o*a,T=n*c-o*l,E=h*m-u*f,S=h*_-d*f,I=h*g-p*f,M=u*_-d*m,A=u*g-p*m,C=d*g-p*_,z=y*C-x*A+v*M+b*I-w*S+T*E;return z?(z=1/z,e[0]=(a*C-l*A+c*M)*z,e[1]=(n*A-r*C-o*M)*z,e[2]=(m*T-_*w+g*b)*z,e[3]=(d*w-u*T-p*b)*z,e[4]=(l*I-s*C-c*S)*z,e[5]=(i*C-n*I+o*S)*z,e[6]=(_*v-f*T-g*x)*z,e[7]=(h*T-d*v+p*x)*z,e[8]=(s*A-a*I+c*E)*z,e[9]=(r*I-i*A-o*E)*z,e[10]=(f*w-m*v+g*y)*z,e[11]=(u*v-h*w-p*y)*z,e[12]=(a*S-s*M-l*E)*z,e[13]=(i*M-r*S+n*E)*z,e[14]=(m*x-f*b-_*y)*z,e[15]=(h*b-u*x+d*y)*z,e):null},e.isMapAuthenticated=function(e){return et.has(e)},e.isMapboxURL=Ve,e.latFromMercatorY=Sa,e.len=B,e.length=x,e.length$1=j,e.loadVectorTile=Yp,e.makeRequest=_t,e.mercatorXfromLng=ba,e.mercatorYfromLat=wa,e.mercatorZfromAltitude=Ta,e.mul=_,e.mul$1=D,e.multiply=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],h=t[7],u=t[8],d=i[0],p=i[1],f=i[2],m=i[3],_=i[4],g=i[5],y=i[6],x=i[7],v=i[8];return e[0]=d*r+p*s+f*c,e[1]=d*n+p*a+f*h,e[2]=d*o+p*l+f*u,e[3]=m*r+_*s+g*c,e[4]=m*n+_*a+g*h,e[5]=m*o+_*l+g*u,e[6]=y*r+x*s+v*c,e[7]=y*n+x*a+v*h,e[8]=y*o+x*l+v*u,e},e.multiply$1=u,e.multiply$2=T,e.nextPowerOfTwo=ce,e.normalize=M,e.normalize$1=G,e.number=Wi,e.ortho=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e},e.pbf=yh,e.perspective=function(e,t,i,r,n){var o,s=1/Math.tan(t/2);return e[0]=s/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,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!=n&&n!==1/0?(o=1/(r-n),e[10]=(n+r)*o,e[14]=2*n*r*o):(e[10]=-1,e[14]=-2*r),e},e.pick=function(e,t){const i={};for(let r=0;r<t.length;r++){const n=t[r];n in e&&(i[n]=e[n])}return i},e.plugin=Io,e.pointGeometry=n,e.polygonIntersectsBox=Wa,e.polygonIntersectsPolygon=Oa,e.polygonizeBounds=function(e,t,i=0,r=!0){const o=new n(i,i),s=e.sub(o),a=t.add(o),l=[s,new n(a.x,s.y),a,new n(s.x,a.y)];return r&&l.push(s),l},e.posAttributes=ep,e.postMapLoadEvent=Je,e.postTurnstileEvent=He,e.potpack=Nh,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=H,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:xo,pluginURL:vo}),To.on("pluginStateChange",e),e},e.removeAuthState=function(e){et.delete(e)},e.renderColorRamp=gl,e.rotateX=f,e.rotateX$1=N,e.rotateY=m,e.rotateZ=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],h=t[5],u=t[6],d=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]=o*n+c*r,e[1]=s*n+h*r,e[2]=a*n+u*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=h*n-s*r,e[6]=u*n-a*r,e[7]=d*n-l*r,e},e.rotateZ$1=function(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a,e},e.scale=p,e.scale$1=R,e.scale$2=S,e.scaleAndAdd=I,e.setCacheLimits=function(e,t){it=e,rt=t},e.setColumn=function(e,t,i){e[4*t+0]=i[0],e[4*t+1]=i[1],e[4*t+2]=i[2],e[4*t+3]=i[3]},e.setRTLTextPlugin=function(e,t,i=!1){if(xo===fo||xo===mo||xo===_o)throw new Error("setRTLTextPlugin cannot be called multiple times.");vo=Ce.resolveURL(e),xo=fo,yo=t,wo(),i||So()},e.smoothstep=te,e.spec=zt,e.storeAuthState=function(e,t){t?et.add(e):et.delete(e)},e.sub=P,e.subtract=w,e.symbolSize=uh,e.tileAABB=function(e,t,i,r,n,o,s,a,l){if("globe"===l.name){const s=Pp(new Sd(o,new Ed(i,r,n)).canonical).getCorners(),a=Number.MAX_VALUE,l=[-a,-a,-a],d=[a,a,a],p=Vp(e,t);for(let e=0;e<s.length;e++)z(s[e],s[e],p),c=d,h=d,u=s[e],c[0]=Math.min(h[0],u[0]),c[1]=Math.min(h[1],u[1]),c[2]=Math.min(h[2],u[2]),E(l,l,s[e]);return new nl(d,l)}var c,h,u;const d=$p({z:i,x:r,y:n},l),p=d.x/d.scale,f=d.y/d.scale,m=d.x2/d.scale,_=d.y2/d.scale;return new nl([(o+p)*t,t*f,s],[(o+m)*t,t*_,a])},e.tileTransform=$p,e.transformMat3=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},e.transformMat4=z,e.transformMat4$1=F,e.transformQuat=k,e.translate=d,e.transpose=function(e,t){if(e===t){var i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n}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=bo,e.uniqueId=ae,e.validateCustomStyleLayer=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.validateFog=jn,e.validateLight=Nn,e.validateStyle=Vn,e.values=ne,e.vectorTile=bc,e.version=t,e.warnOnce=ge,e.window=s,e.wrap=ie}),r(0,function(e){function t(e){const i=typeof e;if("number"===i||"boolean"===i||"string"===i||null==e)return JSON.stringify(e);if(Array.isArray(e)){let i="[";for(const r of e)i+=`${t(r)},`;return`${i}]`}const r=Object.keys(e).sort();let n="{";for(let i=0;i<r.length;i++)n+=`${JSON.stringify(r[i])}:${t(e[r[i]])},`;return`${n}}`}function i(i){let r="";for(const n of e.refProperties)r+=`/${t(i[n])}`;return r}class r{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,r){for(const i of t){this._layerConfigs[i.id]=i,(this._layers[i.id]=e.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const r={};for(let n=0;n<e.length;n++){const o=t&&t[e[n].id]||i(e[n]);t&&(t[e[n].id]=o);let s=r[o];s||(s=r[o]=[]),s.push(e[n])}const n=[];for(const e in r)n.push(r[e]);return n}(e.values(this._layerConfigs),this.keyCache);for(const e of n){const t=e.map(e=>this._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const{ImageBitmap:n}=e.window;class o{loadTile(t,i){const{uid:r,encoding:o,rawImageData:s,padding:a,buildQuadTree:l}=t,c=n&&s instanceof n?this.getImageData(s,a):s;i(null,new e.DEMData(r,c,o,a<1,l))}getImageData(t,i){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const r=this.offscreenCanvasContext.getImageData(-i,-i,t.width+2*i,t.height+2*i);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new e.RGBAImage({width:r.width,height:r.height},r.data)}}var s=function e(t,i){var r,n=t&&t.type;if("FeatureCollection"===n)for(r=0;r<t.features.length;r++)e(t.features[r],i);else if("GeometryCollection"===n)for(r=0;r<t.geometries.length;r++)e(t.geometries[r],i);else if("Feature"===n)e(t.geometry,i);else if("Polygon"===n)a(t.coordinates,i);else if("MultiPolygon"===n)for(r=0;r<t.coordinates.length;r++)a(t.coordinates[r],i);return t};function a(e,t){if(0!==e.length){l(e[0],t);for(var i=1;i<e.length;i++)l(e[i],!t)}}function l(e,t){for(var i=0,r=0,n=0,o=e.length,s=o-1;n<o;s=n++){var a=(e[n][0]-e[s][0])*(e[s][1]+e[n][1]),l=i+a;r+=Math.abs(i)>=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!t&&e.reverse()}const c=e.vectorTile.VectorTileFeature.prototype.toGeoJSON;class h{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.pointGeometry(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const r=[];for(const t of i)r.push(new e.pointGeometry(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,i){return c.call(this,e,t,i)}}class u{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.EXTENT,this.length=t.length,this._features=t}feature(e){return new h(this._features[e])}}var d=e.vectorTile.VectorTileFeature,p=f;function f(e,t){this.options=t||{},this.features=e,this.length=e.length}function m(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}f.prototype.feature=function(e){return new m(this.features[e],this.options.extent)},m.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var i=0;i<t.length;i++){for(var r=t[i],n=[],o=0;o<r.length;o++)n.push(new e.pointGeometry(r[o][0],r[o][1]));this.geometry.push(n)}return this.geometry},m.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var e=this.geometry,t=1/0,i=-1/0,r=1/0,n=-1/0,o=0;o<e.length;o++)for(var s=e[o],a=0;a<s.length;a++){var l=s[a];t=Math.min(t,l.x),i=Math.max(i,l.x),r=Math.min(r,l.y),n=Math.max(n,l.y)}return[t,r,i,n]},m.prototype.toGeoJSON=d.prototype.toGeoJSON;var _=v,g=v,y=function(e,t){t=t||{};var i={};for(var r in e)i[r]=new p(e[r].features,t),i[r].name=r,i[r].version=t.version,i[r].extent=t.extent;return v({layers:i})},x=p;function v(t){var i=new e.pbf;return function(e,t){for(var i in e.layers)t.writeMessage(3,b,e.layers[i])}(t,i),i.finish()}function b(e,t){var i;t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);var r={keys:[],values:[],keycache:{},valuecache:{}};for(i=0;i<e.length;i++)r.feature=e.feature(i),t.writeMessage(2,w,r);var n=r.keys;for(i=0;i<n.length;i++)t.writeStringField(3,n[i]);var o=r.values;for(i=0;i<o.length;i++)t.writeMessage(4,M,o[i])}function w(e,t){var i=e.feature;void 0!==i.id&&t.writeVarintField(1,i.id),t.writeMessage(2,T,e),t.writeVarintField(3,i.type),t.writeMessage(4,I,i)}function T(e,t){var i=e.feature,r=e.keys,n=e.values,o=e.keycache,s=e.valuecache;for(var a in i.properties){var l=i.properties[a],c=o[a];if(null!==l){void 0===c&&(r.push(a),c=r.length-1,o[a]=c),t.writeVarint(c);var h=typeof l;"string"!==h&&"boolean"!==h&&"number"!==h&&(l=JSON.stringify(l));var u=h+":"+l,d=s[u];void 0===d&&(n.push(l),d=n.length-1,s[u]=d),t.writeVarint(d)}}}function E(e,t){return(t<<3)+(7&e)}function S(e){return e<<1^e>>31}function I(e,t){for(var i=e.loadGeometry(),r=e.type,n=0,o=0,s=i.length,a=0;a<s;a++){var l=i[a],c=1;1===r&&(c=l.length),t.writeVarint(E(1,c));for(var h=3===r?l.length-1:l.length,u=0;u<h;u++){1===u&&1!==r&&t.writeVarint(E(2,h-1));var d=l[u].x-n,p=l[u].y-o;t.writeVarint(S(d)),t.writeVarint(S(p)),n+=d,o+=p}3===r&&t.writeVarint(E(7,1))}}function M(e,t){var i=typeof e;"string"===i?t.writeStringField(1,e):"boolean"===i?t.writeBooleanField(7,e):"number"===i&&(e%1!=0?t.writeDoubleField(3,e):e<0?t.writeSVarintField(6,e):t.writeVarintField(5,e))}function A(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;!function e(t,i,r,n,o,s){for(;o>n;){if(o-n>600){const a=o-n+1,l=r-n+1,c=Math.log(a),h=.5*Math.exp(2*c/3),u=.5*Math.sqrt(c*h*(a-h)/a)*(l-a/2<0?-1:1),d=Math.max(n,Math.floor(r-l*h/a+u)),p=Math.min(o,Math.floor(r+(a-l)*h/a+u));e(t,i,r,d,p,s)}const a=i[2*r+s];let l=n,c=o;for(C(t,i,n,r),i[2*o+s]>a&&C(t,i,n,o);l<c;){for(C(t,i,l,c),l++,c--;i[2*l+s]<a;)l++;for(;i[2*c+s]>a;)c--}i[2*n+s]===a?C(t,i,n,c):C(t,i,++c,o),c<=r&&(n=c+1),r<=c&&(o=c-1)}}(e,t,s,r,n,o%2),A(e,t,i,r,s-1,o+1),A(e,t,i,s+1,n,o+1)}function C(e,t,i,r){z(e,i,r),z(t,2*i,2*r),z(t,2*i+1,2*r+1)}function z(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function k(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}_.fromVectorTileJs=g,_.fromGeojsonVt=y,_.GeoJSONWrapper=x;const P=e=>e[0],D=e=>e[1];class L{constructor(e,t=P,i=D,r=64,n=Float64Array){this.nodeSize=r,this.points=e;const o=e.length<65536?Uint16Array:Uint32Array,s=this.ids=new o(e.length),a=this.coords=new n(2*e.length);for(let r=0;r<e.length;r++)s[r]=r,a[2*r]=t(e[r]),a[2*r+1]=i(e[r]);A(s,a,r,0,s.length-1,0)}range(e,t,i,r){return function(e,t,i,r,n,o,s){const a=[0,e.length-1,0],l=[];let c,h;for(;a.length;){const u=a.pop(),d=a.pop(),p=a.pop();if(d-p<=s){for(let s=p;s<=d;s++)c=t[2*s],h=t[2*s+1],c>=i&&c<=n&&h>=r&&h<=o&&l.push(e[s]);continue}const f=Math.floor((p+d)/2);c=t[2*f],h=t[2*f+1],c>=i&&c<=n&&h>=r&&h<=o&&l.push(e[f]);const m=(u+1)%2;(0===u?i<=c:r<=h)&&(a.push(p),a.push(f-1),a.push(m)),(0===u?n>=c:o>=h)&&(a.push(f+1),a.push(d),a.push(m))}return l}(this.ids,this.coords,e,t,i,r,this.nodeSize)}within(e,t,i){return function(e,t,i,r,n,o){const s=[0,e.length-1,0],a=[],l=n*n;for(;s.length;){const c=s.pop(),h=s.pop(),u=s.pop();if(h-u<=o){for(let n=u;n<=h;n++)k(t[2*n],t[2*n+1],i,r)<=l&&a.push(e[n]);continue}const d=Math.floor((u+h)/2),p=t[2*d],f=t[2*d+1];k(p,f,i,r)<=l&&a.push(e[d]);const m=(c+1)%2;(0===c?i-n<=p:r-n<=f)&&(s.push(u),s.push(d-1),s.push(m)),(0===c?i+n>=p:r+n>=f)&&(s.push(d+1),s.push(h),s.push(m))}return a}(this.ids,this.coords,e,t,i,this.nodeSize)}}const B={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},R=Math.fround||(e=>t=>(e[0]=+t,e[0]))(new Float32Array(1));class F{constructor(e){this.options=$(Object.create(B),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:i,maxZoom:r,nodeSize:n}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;let s=[];for(let t=0;t<e.length;t++)e[t].geometry&&s.push(U(e[t],t));this.trees[r+1]=new L(s,q,X,n,Float32Array),t&&console.timeEnd(o);for(let e=r;e>=i;e--){const i=+Date.now();s=this._cluster(s,e),this.trees[e]=new L(s,q,X,n,Float32Array),t&&console.log("z%d: %d clusters in %dms",e,s.length,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(j(i),G(o),j(n),G(r)),l=[];for(const e of a){const t=s.points[e];l.push(t.numPoints?V(t):this.points[t.index])}return l}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.points[t];if(!o)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o.x,o.y,s),l=[];for(const t of a){const i=n.points[t];i.parentId===e&&l.push(i.numPoints?V(i):this.points[i.index])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){t=t||10,i=i||0;const r=[];return this._appendLeaves(r,e,t,i,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,h={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.points,t,i,n,h),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.points,n,i,n,h),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.points,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n<r?n++:e.push(t),e.length===i)break}return n}_addTileFeatures(e,t,i,r,n,o){for(const s of e){const e=t[s],a=e.numPoints;let l,c,h;if(a)l=N(e),c=e.x,h=e.y;else{const t=this.points[e.index];l=t.properties,c=j(t.geometry.coordinates[0]),h=G(t.geometry.coordinates[1])}const u={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(h*n-r))]],tags:l};let d;a?d=e.id:this.options.generateId?d=e.index:this.points[e.index].id&&(d=this.points[e.index].id),void 0!==d&&(u.id=d),o.features.push(u)}}_limitZoom(e){return Math.max(this.options.minZoom,Math.min(+e,this.options.maxZoom+1))}_cluster(e,t){const i=[],{radius:r,extent:n,reduce:o,minPoints:s}=this.options,a=r/(n*Math.pow(2,t));for(let r=0;r<e.length;r++){const n=e[r];if(n.zoom<=t)continue;n.zoom=t;const l=this.trees[t+1],c=l.within(n.x,n.y,a),h=n.numPoints||1;let u=h;for(const e of c){const i=l.points[e];i.zoom>t&&(u+=i.numPoints||1)}if(u>h&&u>=s){let e=n.x*h,s=n.y*h,a=o&&h>1?this._map(n,!0):null;const d=(r<<5)+(t+1)+this.points.length;for(const i of c){const r=l.points[i];if(r.zoom<=t)continue;r.zoom=t;const c=r.numPoints||1;e+=r.x*c,s+=r.y*c,r.parentId=d,o&&(a||(a=this._map(n,!0)),o(a,this._map(r)))}n.parentId=d,i.push(O(e/u,s/u,d,u,a))}else if(i.push(n),u>1)for(const e of c){const r=l.points[e];r.zoom<=t||(r.zoom=t,i.push(r))}}return i}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?$({},e.properties):e.properties;const i=this.points[e.index].properties,r=this.options.map(i);return t&&r===i?$({},r):r}}function O(e,t,i,r,n){return{x:R(e),y:R(t),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function U(e,t){const[i,r]=e.geometry.coordinates;return{x:R(j(i)),y:R(G(r)),zoom:1/0,index:t,parentId:-1}}function V(e){return{type:"Feature",id:e.id,properties:N(e),geometry:{type:"Point",coordinates:[(t=e.x,360*(t-.5)),Z(e.y)]}};var t}function N(e){const t=e.numPoints,i=t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?`${Math.round(t/100)/10}k`:t;return $($({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:i})}function j(e){return e/360+.5}function G(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function Z(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t){for(const i in t)e[i]=t[i];return e}function q(e){return e.x}function X(e){return e.y}function W(e,t,i,r,n,o){var s=n-i,a=o-r;if(0!==s||0!==a){var l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return(s=e-i)*s+(a=t-r)*a}function H(e,t,i,r){var n={id:void 0===e?null:e,type:t,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,i=e.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)K(e,t);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r<t.length;r++)K(e,t[r]);else if("MultiPolygon"===i)for(r=0;r<t.length;r++)for(var n=0;n<t[r].length;n++)K(e,t[r][n])}(n),n}function K(e,t){for(var i=0;i<t.length;i+=3)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function J(e,t,i,r){if(t.geometry){var n=t.geometry.coordinates,o=t.geometry.type,s=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2),a=[],l=t.id;if(i.promoteId?l=t.properties[i.promoteId]:i.generateId&&(l=r||0),"Point"===o)Y(n,a);else if("MultiPoint"===o)for(var c=0;c<n.length;c++)Y(n[c],a);else if("LineString"===o)Q(n,a,s,!1);else if("MultiLineString"===o){if(i.lineMetrics){for(c=0;c<n.length;c++)a=[],Q(n[c],a,s,!1),e.push(H(l,"LineString",a,t.properties));return}ee(n,a,s,!1)}else if("Polygon"===o)ee(n,a,s,!0);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(c=0;c<t.geometry.geometries.length;c++)J(e,{id:l,geometry:t.geometry.geometries[c],properties:t.properties},i,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(c=0;c<n.length;c++){var h=[];ee(n[c],h,s,!0),a.push(h)}}e.push(H(l,o,a,t.properties))}}function Y(e,t){t.push(te(e[0])),t.push(ie(e[1])),t.push(0)}function Q(e,t,i,r){for(var n,o,s=0,a=0;a<e.length;a++){var l=te(e[a][0]),c=ie(e[a][1]);t.push(l),t.push(c),t.push(0),a>0&&(s+=r?(n*c-l*o)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-o,2))),n=l,o=c}var h=t.length-3;t[2]=1,function e(t,i,r,n){for(var o,s=n,a=r-i>>1,l=r-i,c=t[i],h=t[i+1],u=t[r],d=t[r+1],p=i+3;p<r;p+=3){var f=W(t[p],t[p+1],c,h,u,d);if(f>s)o=p,s=f;else if(f===s){var m=Math.abs(p-a);m<l&&(o=p,l=m)}}s>n&&(o-i>3&&e(t,i,o,n),t[o+2]=s,r-o>3&&e(t,o,r,n))}(t,0,h,i),t[h+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function ee(e,t,i,r){for(var n=0;n<e.length;n++){var o=[];Q(e[n],o,i,r),t.push(o)}}function te(e){return e/360+.5}function ie(e){var t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function re(e,t,i,r,n,o,s,a){if(r/=t,o>=(i/=t)&&s<r)return e;if(s<i||o>=r)return null;for(var l=[],c=0;c<e.length;c++){var h=e[c],u=h.geometry,d=h.type,p=0===n?h.minX:h.minY,f=0===n?h.maxX:h.maxY;if(p>=i&&f<r)l.push(h);else if(!(f<i||p>=r)){var m=[];if("Point"===d||"MultiPoint"===d)ne(u,m,i,r,n);else if("LineString"===d)oe(u,m,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===d)ae(u,m,i,r,n,!1);else if("Polygon"===d)ae(u,m,i,r,n,!0);else if("MultiPolygon"===d)for(var _=0;_<u.length;_++){var g=[];ae(u[_],g,i,r,n,!0),g.length&&m.push(g)}if(m.length){if(a.lineMetrics&&"LineString"===d){for(_=0;_<m.length;_++)l.push(H(h.id,d,m[_],h.tags));continue}"LineString"!==d&&"MultiLineString"!==d||(1===m.length?(d="LineString",m=m[0]):d="MultiLineString"),"Point"!==d&&"MultiPoint"!==d||(d=3===m.length?"Point":"MultiPoint"),l.push(H(h.id,d,m,h.tags))}}}return l.length?l:null}function ne(e,t,i,r,n){for(var o=0;o<e.length;o+=3){var s=e[o+n];s>=i&&s<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,i,r,n,o,s){for(var a,l,c=se(e),h=0===n?ce:he,u=e.start,d=0;d<e.length-3;d+=3){var p=e[d],f=e[d+1],m=e[d+2],_=e[d+3],g=e[d+4],y=0===n?p:f,x=0===n?_:g,v=!1;s&&(a=Math.sqrt(Math.pow(p-_,2)+Math.pow(f-g,2))),y<i?x>i&&(l=h(c,p,f,_,g,i),s&&(c.start=u+a*l)):y>r?x<r&&(l=h(c,p,f,_,g,r),s&&(c.start=u+a*l)):le(c,p,f,m),x<i&&y>=i&&(l=h(c,p,f,_,g,i),v=!0),x>r&&y<=r&&(l=h(c,p,f,_,g,r),v=!0),!o&&v&&(s&&(c.end=u+a*l),t.push(c),c=se(e)),s&&(u+=a)}var b=e.length-3;p=e[b],f=e[b+1],m=e[b+2],(y=0===n?p:f)>=i&&y<=r&&le(c,p,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&le(c,c[0],c[1],c[2]),c.length&&t.push(c)}function se(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ae(e,t,i,r,n,o){for(var s=0;s<e.length;s++)oe(e[s],t,i,r,n,o,!1)}function le(e,t,i,r){e.push(t),e.push(i),e.push(r)}function ce(e,t,i,r,n,o){var s=(o-t)/(r-t);return e.push(o),e.push(i+(n-i)*s),e.push(1),s}function he(e,t,i,r,n,o){var s=(o-i)/(n-i);return e.push(t+(r-t)*s),e.push(o),e.push(1),s}function ue(e,t){for(var i=[],r=0;r<e.length;r++){var n,o=e[r],s=o.type;if("Point"===s||"MultiPoint"===s||"LineString"===s)n=de(o.geometry,t);else if("MultiLineString"===s||"Polygon"===s){n=[];for(var a=0;a<o.geometry.length;a++)n.push(de(o.geometry[a],t))}else if("MultiPolygon"===s)for(n=[],a=0;a<o.geometry.length;a++){for(var l=[],c=0;c<o.geometry[a].length;c++)l.push(de(o.geometry[a][c],t));n.push(l)}i.push(H(o.id,s,n,o.tags))}return i}function de(e,t){var i=[];i.size=e.size,void 0!==e.start&&(i.start=e.start,i.end=e.end);for(var r=0;r<e.length;r+=3)i.push(e[r]+t,e[r+1],e[r+2]);return i}function pe(e,t){if(e.transformed)return e;var i,r,n,o=1<<e.z,s=e.x,a=e.y;for(i=0;i<e.features.length;i++){var l=e.features[i],c=l.geometry,h=l.type;if(l.geometry=[],1===h)for(r=0;r<c.length;r+=2)l.geometry.push(fe(c[r],c[r+1],t,o,s,a));else for(r=0;r<c.length;r++){var u=[];for(n=0;n<c[r].length;n+=2)u.push(fe(c[r][n],c[r][n+1],t,o,s,a));l.geometry.push(u)}}return e.transformed=!0,e}function fe(e,t,i,r,n,o){return[Math.round(i*(e*r-n)),Math.round(i*(t*r-o))]}function me(e,t,i,r,n){for(var o=t===n.maxZoom?0:n.tolerance/((1<<t)*n.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:i,y:r,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},a=0;a<e.length;a++){s.numFeatures++,_e(s,e[a],o,n);var l=e[a].minX,c=e[a].minY,h=e[a].maxX,u=e[a].maxY;l<s.minX&&(s.minX=l),c<s.minY&&(s.minY=c),h>s.maxX&&(s.maxX=h),u>s.maxY&&(s.maxY=u)}return s}function _e(e,t,i,r){var n=t.geometry,o=t.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a<n.length;a+=3)s.push(n[a]),s.push(n[a+1]),e.numPoints++,e.numSimplified++;else if("LineString"===o)ge(s,n,e,i,!1,!1);else if("MultiLineString"===o||"Polygon"===o)for(a=0;a<n.length;a++)ge(s,n[a],e,i,"Polygon"===o,0===a);else if("MultiPolygon"===o)for(var l=0;l<n.length;l++){var c=n[l];for(a=0;a<c.length;a++)ge(s,c[a],e,i,!0,0===a)}if(s.length){var h=t.tags||null;if("LineString"===o&&r.lineMetrics){for(var u in h={},t.tags)h[u]=t.tags[u];h.mapbox_clip_start=n.start/n.size,h.mapbox_clip_end=n.end/n.size}var d={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:h};null!==t.id&&(d.id=t.id),e.features.push(d)}}function ge(e,t,i,r,n,o){var s=r*r;if(r>0&&t.size<(n?s:r))i.numPoints+=t.length/3;else{for(var a=[],l=0;l<t.length;l+=3)(0===r||t[l+2]>s)&&(i.numSimplified++,a.push(t[l]),a.push(t[l+1])),i.numPoints++;n&&function(e,t){for(var i=0,r=0,n=e.length,o=n-2;r<n;o=r,r+=2)i+=(e[r]-e[o])*(e[r+1]+e[o+1]);if(i>0===t)for(r=0,n=e.length;r<n/2;r+=2){var s=e[r],a=e[r+1];e[r]=e[n-2-r],e[r+1]=e[n-1-r],e[n-2-r]=s,e[n-1-r]=a}}(a,o),e.push(a)}}function ye(e,t){var i=(t=this.options=function(e,t){for(var i in t)e[i]=t[i];return e}(Object.create(this.options),t)).debug;if(i&&console.time("preprocess data"),t.maxZoom<0||t.maxZoom>24)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 r=function(e,t){var i=[];if("FeatureCollection"===e.type)for(var r=0;r<e.features.length;r++)J(i,e.features[r],t,r);else"Feature"===e.type?J(i,e,t):J(i,{geometry:e},t);return i}(e,t);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",t.indexMaxZoom,t.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(r=function(e,t){var i=t.buffer/t.extent,r=e,n=re(e,1,-1-i,i,0,-1,2,t),o=re(e,1,1-i,2+i,0,-1,2,t);return(n||o)&&(r=re(e,1,-i,1+i,0,-1,2,t)||[],n&&(r=ue(n,1).concat(r)),o&&(r=r.concat(ue(o,-1)))),r}(r,t)).length&&this.splitTile(r,0,0,0),i&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function xe(e,t,i){return 32*((1<<e)*i+t)+e}function ve(e,t){const i=e.tileID.canonical;if(!this._geoJSONIndex)return t(null,null);const r=this._geoJSONIndex.getTile(i.z,i.x,i.y);if(!r)return t(null,null);const n=new u(r.features);let o=_(n);0===o.byteOffset&&o.byteLength===o.buffer.byteLength||(o=new Uint8Array(o)),t(null,{vectorTile:n,rawData:o.buffer})}ye.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},ye.prototype.splitTile=function(e,t,i,r,n,o,s){for(var a=[e,t,i,r],l=this.options,c=l.debug;a.length;){r=a.pop(),i=a.pop(),t=a.pop(),e=a.pop();var h=1<<t,u=xe(t,i,r),d=this.tiles[u];if(!d&&(c>1&&console.time("creation"),d=this.tiles[u]=me(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var p="z"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++}if(d.source=e,n){if(t===l.maxZoom||t===n)continue;var f=1<<n-t;if(i!==Math.floor(o/f)||r!==Math.floor(s/f))continue}else if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue;if(d.source=null,0!==e.length){c>1&&console.time("clipping");var m,_,g,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,x=re(e,h,i-b,i+T,0,d.minX,d.maxX,l),v=re(e,h,i+w,i+E,0,d.minX,d.maxX,l),e=null,x&&(m=re(x,h,r-b,r+T,1,d.minY,d.maxY,l),_=re(x,h,r+w,r+E,1,d.minY,d.maxY,l),x=null),v&&(g=re(v,h,r-b,r+T,1,d.minY,d.maxY,l),y=re(v,h,r+w,r+E,1,d.minY,d.maxY,l),v=null),c>1&&console.timeEnd("clipping"),a.push(m||[],t+1,2*i,2*r),a.push(_||[],t+1,2*i,2*r+1),a.push(g||[],t+1,2*i+1,2*r),a.push(y||[],t+1,2*i+1,2*r+1)}}},ye.prototype.getTile=function(e,t,i){var r=this.options,n=r.extent,o=r.debug;if(e<0||e>24)return null;var s=1<<e,a=xe(e,t=(t%s+s)%s,i);if(this.tiles[a])return pe(this.tiles[a],n);o>1&&console.log("drilling down to z%d-%d-%d",e,t,i);for(var l,c=e,h=t,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[xe(c,h,u)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,h,u),o>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,e,t,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?pe(this.tiles[a],n):null):null};class be extends e.VectorTileWorkerSource{constructor(e,t,i,r,n){super(e,t,i,r,ve),n&&(this.loadGeoJSON=n)}loadData(t,i){const r=t&&t.request,n=r&&r.collectResourceTiming;this.loadGeoJSON(t,(o,a)=>{if(o||!a)return i(o);if("object"!=typeof a)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{s(a,!0);try{if(t.filter){const i=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=a.features.filter(e=>i.value.evaluate({zoom:0},e));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new F(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.createExpression(s),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=a.value,n[t]=l.value}return t.map=(e=>{s.properties=e;const t={};for(const e of a)t[e]=r[e].evaluate(o,s);return t}),t.reduce=((e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)}),t}(t)).load(a.features):function(e,t){return new ye(e,t)}(a,t.geojsonVtOptions)}catch(o){return i(o)}this.loaded={};const l={};if(n){const i=e.getPerformanceMeasurement(r);i&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}})}reloadTile(e,t){const i=this.loaded,r=e.uid;return i&&i[r]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.getJSON(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${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 we{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:be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=((e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${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,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,i){this.isSpriteLoaded[t]=i;for(const r in this.workerSources[t]){const n=this.workerSources[t][r];for(const t in n)n[t]instanceof e.VectorTileWorkerSource&&(n[t].isSpriteLoaded=i,n[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,i){this.availableImages[e]=t;for(const i in this.workerSources[e]){const r=this.workerSources[e][i];for(const e in r)r[e].availableImages=t}i()}enableTerrain(e,t,i){this.terrain=t,i()}setProjection(t,i){this.projections[t]=e.getProjection(i)}setLayers(e,t,i){this.getLayerIndex(e).replace(t),i()}updateLayers(e,t,i){this.getLayerIndex(e).update(t.layers,t.removedIds),i()}loadTile(t,i,r){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},i):i;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,i.type,i.source).loadTile(n,r)}loadDEMTile(t,i,r){const n=this.enableTerrain?e.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(t,i.source).loadTile(n,r)}reloadTile(t,i,r){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},i):i;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,i.type,i.source).reloadTile(n,r)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source).removeTile(t,i)}removeSource(e,t,i){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const r=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,r){try{e.plugin.setState(i);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const i=e.plugin.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),i)}}catch(e){r(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 r),t}getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const r={send:(t,i,r,n,o,s)=>{this.actor.send(t,i,r,e,o,s)},scheduler:this.actor.scheduler};this.workerSources[e][t][i]=new this.workerSourceTypes[t](r,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])}return this.workerSources[e][t][i]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new o),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,i){e.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new we(self)),we}),r(0,function(e){var t=i;function i(e){return!function(e){if("undefined"==typeof window||"undefined"==typeof document)return"not a browser";if(!(Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray))return"insufficent Array support";if(!Function.prototype||!Function.prototype.bind)return"insufficient Function support";if(!(Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions))return"insufficient Object support";if(!("JSON"in window&&"parse"in JSON&&"stringify"in JSON))return"insufficient JSON support";if(!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}t&&t.terminate();return URL.revokeObjectURL(r),e}())return"insufficient worker support";if(!("Uint8ClampedArray"in window))return"insufficient Uint8ClampedArray support";if(!ArrayBuffer.isView)return"insufficient ArrayBuffer support";if(!function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}())return"insufficient Canvas/getImageData support";if(!function(e){void 0===r[e]&&(r[e]=function(e){var t,r=function(e){var t=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=e,t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}(e);if(!r)return!1;try{t=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}if(!t||r.isContextLost())return!1;return r.shaderSource(t,"void main() {}"),r.compileShader(t),!0===r.getShaderParameter(t,r.COMPILE_STATUS)}(e));return r[e]}(e&&e.failIfMajorPerformanceCaveat))return"insufficient WebGL support";if(document.documentMode)return"insufficient ECMAScript 6 support"}(e)}var r={};function n(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(s=1/s,e[0]=o*s,e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null}function o(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!o(e[i],t[i]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==t){if("object"!=typeof t)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!o(e[i],t[i]))return!1;return!0}return e===t}i.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const s={create:function(t,i,r){const n=e.window.document.createElement(t);return void 0!==i&&(n.className=i),r&&r.appendChild(n),n},createSVG:function(t,i,r){const n=e.window.document.createElementNS("http://www.w3.org/2000/svg",t);for(const e of Object.keys(i))n.setAttributeNS(null,e,i[e]);return r&&r.appendChild(n),n}},a=e.window.document&&e.window.document.documentElement.style,l=a&&void 0!==a.userSelect?"userSelect":"WebkitUserSelect";let c;s.disableDrag=function(){a&&l&&(c=a[l],a[l]="none")},s.enableDrag=function(){a&&l&&(a[l]=c)};const h=function(t){t.preventDefault(),t.stopPropagation(),e.window.removeEventListener("click",h,!0)};function u(t,i,r){const n=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.pointGeometry((r.clientX-i.left)*n,(r.clientY-i.top)*n)}function d(e){const{userImage:t}=e;if(t&&t.render){if(t.render())return e.data.replace(new Uint8Array(t.data.buffer)),!0}return!1}s.suppressClick=function(){e.window.addEventListener("click",h,!0),e.window.setTimeout(()=>{e.window.removeEventListener("click",h,!0)},0)},s.mousePos=function(e,t){const i=e.getBoundingClientRect();return u(e,i,t)},s.touchPos=function(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;n<t.length;n++)r.push(u(e,i,t[n]));return r},s.mouseButton=function(t){return void 0!==e.window.InstallTrigger&&2===t.button&&t.ctrlKey&&e.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:t.button};const p=1;class f 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=[]}}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]<i||r[1]<r[0]||t<r[1])return!1;i=r[1]}return!0}_validateContent(e,t){return!e||4===e.length&&(!(e[0]<0||t.data.width<e[0])&&(!(e[1]<0||t.data.height<e[1])&&(!(e[2]<0||t.data.width<e[2])&&(!(e[3]<0||t.data.height<e[3])&&(!(e[2]<e[0])&&!(e[3]<e[1]))))))}updateImage(e,t){const i=this.images[e];t.version=i.version+1,this.images[e]=t,this.updatedImages[e]=!0}removeImage(e){const t=this.images[e];delete this.images[e],delete this.patterns[e],t.userImage&&t.userImage.onRemove&&t.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(e,t){let i=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(i=!1);this.isLoaded()||i?this._notify(e,t):this.requestors.push({ids:e,callback:t})}_notify(t,i){const r={};for(const i of t){this.images[i]||this.fire(new e.Event("styleimagemissing",{id:i}));const t=this.images[i];t?r[i]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)}:e.warnOnce(`Image "${i}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}i(null,r)}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(t){const i=this.patterns[t],r=this.getImage(t);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2*p,h:r.data.height+2*p,x:0,y:0},n=new e.ImagePosition(i,r);this.patterns[t]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const i=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new e.Texture(t,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:r}=e.potpack(t),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],r=i.x+p,o=i.y+p,s=this.images[t].data,a=s.width,l=s.height;e.RGBAImage.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),e.RGBAImage.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),e.RGBAImage.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),e.RGBAImage.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),e.RGBAImage.copy(s,n,{x:0,y:0},{x:r+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const t of e){if(this.callbackDispatchedThisFrame[t])continue;this.callbackDispatchedThisFrame[t]=!0;const e=this.images[t];d(e)&&this.updateImage(t,e)}}}const m=new e.Properties({anchor:new e.DataConstantProperty(e.spec.light.anchor),position:new class{constructor(){this.specification=e.spec.light.position}possiblyEvaluate(t,i){return function([t,i,r]){const n=e.degToRad(i+90),o=e.degToRad(r);return{x:t*Math.cos(n)*Math.sin(o),y:t*Math.sin(n)*Math.sin(o),z:t*Math.cos(o),azimuthal:i,polar:r}}(t.expression.evaluate(i))}interpolate(t,i,r){return{x:e.number(t.x,i.x,r),y:e.number(t.y,i.y,r),z:e.number(t.z,i.z,r),azimuthal:e.number(t.azimuthal,i.azimuthal,r),polar:e.number(t.polar,i.polar,r)}}},color:new e.DataConstantProperty(e.spec.light.color),intensity:new e.DataConstantProperty(e.spec.light.intensity)}),_="-transition";class g extends e.Evented{constructor(t){super(),this._transitionable=new e.Transitionable(m),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i={}){if(!this._validate(e.validateLight,t,i))for(const i in t){const r=t[i];e.endsWith(i,_)?this._transitionable.setTransition(i.slice(0,-_.length),r):this._transitionable.setValue(i,r)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}_validate(t,i,r){return(!r||!1!==r.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}const y={deferred:0,elevated:1},x=new e.Properties({source:new e.DataConstantProperty(e.spec.terrain.source),exaggeration:new e.DataConstantProperty(e.spec.terrain.exaggeration)}),v="-transition";class b extends e.Evented{constructor(t,i){super(),this._transitionable=new e.Transitionable(x),this.set(t),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=i}get(){return this._transitionable.serialize()}set(t){for(const i in t){const r=t[i];e.endsWith(i,v)?this._transitionable.setTransition(i.slice(0,-v.length),r):this._transitionable.setValue(i,r)}}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}}const w=45,T=65,E=.9;function S(t,i,r,n){const o=e.smoothstep(w,T,r),[s,a]=I(t,n),l=(e.length(i)-s)/(a-s);let c=1-Math.min(1,Math.exp(-6*l));return c*=c*c,(c=Math.min(1,1.00747*c))*o*t.alpha}function I(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}const M=new e.Properties({range:new e.DataConstantProperty(e.spec.fog.range),color:new e.DataConstantProperty(e.spec.fog.color),"horizon-blend":new e.DataConstantProperty(e.spec.fog["horizon-blend"])}),A="-transition";class C extends e.Evented{constructor(t,i){super(),this._transitionable=new e.Transitionable(M),this.set(t),this._transitioning=this._transitionable.untransitioned(),this._transform=i}get state(){return{range:this.properties.get("range"),horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(t,i={}){if(!this._validate(e.validateFog,t,i))for(const i in t){const r=t[i];e.endsWith(i,A)?this._transitionable.setTransition(i.slice(0,-A.length),r):this._transitionable.setValue(i,r)}}getOpacity(t){if(!this._transform.projection.supportsFog)return 0;const i=this.properties&&this.properties.get("color")||1;return e.smoothstep(w,T,t)*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,r){const n=e.MercatorCoordinate.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0,s=[n.x,n.y,o];return e.transformMat4(s,s,r.mercatorFogMatrix),S(t,s,r.pitch,r._fov)}(this.state,t,i):0}getFovAdjustedRange(e){return this._transform.projection.supportsFog?I(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,i,r){return(!r||!1!==r.validate)&&e.emitValidationErrors(this,t.call(e.validateStyle,e.extend({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.spec})))}}class z{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e.uniqueId();const r=this.workerPool.acquire(this.id);for(let e=0;e<r.length;e++){const t=r[e],n=new z.Actor(t,i,this.id);n.name=`Worker ${e}`,this.actors.push(n)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(t,i,r){r=r||function(){},e.asyncAll(this.actors,(e,r)=>{e.send(t,i,r)},r)}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 k(t,i,r){return i*(e.EXTENT/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}z.Actor=e.Actor;class P{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){const e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}}const D={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class L{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i<this.attributes.length;i++){const r=this.attributes[i],n=t.attributes[r.name];void 0!==n&&e.enableVertexAttribArray(n)}}setVertexAttribPointers(e,t,i){for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r],o=t.attributes[n.name];void 0!==o&&e.vertexAttribPointer(o,n.components,e[D[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){const e=this.context.gl;this.buffer&&(e.deleteBuffer(this.buffer),delete this.buffer)}}class B{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class R extends B{getDefault(){return e.Color.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class F extends B{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class O extends B{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class U extends B{getDefault(){return[!0,!0,!0,!0]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class V extends B{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class N extends B{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class j extends B{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){const t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class G extends B{getDefault(){const e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class Z extends B{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class $ extends B{getDefault(){return[0,1]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class q extends B{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class X extends B{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class W extends B{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class H extends B{getDefault(){const e=this.gl;return[e.ONE,e.ZERO]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class K extends B{getDefault(){return e.Color.transparent}set(e){const t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class J extends B{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Y extends B{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Q extends B{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class ee extends B{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class te extends B{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class ie extends B{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class re extends B{getDefault(){const e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){const t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class ne extends B{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class oe extends B{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class se extends B{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class ae extends B{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class le extends B{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class ce extends B{constructor(e){super(e),this.vao=e.extVertexArrayObject}getDefault(){return null}set(e){this.vao&&(e!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(e),this.current=e,this.dirty=!1)}}class he extends B{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class ue extends B{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class de extends B{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;const t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class pe extends B{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class fe extends pe{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class me extends pe{attachment(){return this.gl.DEPTH_ATTACHMENT}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,this.attachment(),t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class _e extends me{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class ge{constructor(e,t,i,r){this.context=e,this.width=t,this.height=i;const n=e.gl,o=this.framebuffer=n.createFramebuffer();this.colorAttachment=new fe(e,o),r&&(this.depthAttachment=new me(e,o))}destroy(){const e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){const t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class ye{constructor(e){this.gl=e,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new R(this),this.clearDepth=new F(this),this.clearStencil=new O(this),this.colorMask=new U(this),this.depthMask=new V(this),this.stencilMask=new N(this),this.stencilFunc=new j(this),this.stencilOp=new G(this),this.stencilTest=new Z(this),this.depthRange=new $(this),this.depthTest=new q(this),this.depthFunc=new X(this),this.blend=new W(this),this.blendFunc=new H(this),this.blendColor=new K(this),this.blendEquation=new J(this),this.cullFace=new Y(this),this.cullFaceSide=new Q(this),this.frontFace=new ee(this),this.program=new te(this),this.activeTexture=new ie(this),this.viewport=new re(this),this.bindFramebuffer=new ne(this),this.bindRenderbuffer=new oe(this),this.bindTexture=new se(this),this.bindVertexBuffer=new ae(this),this.bindElementBuffer=new le(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new ce(this),this.pixelStoreUnpack=new he(this),this.pixelStoreUnpackPremultiplyAlpha=new ue(this),this.pixelStoreUnpackFlipY=new de(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.extTextureHalfFloat=e.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(e.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float")),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 P(this,e,t)}createVertexBuffer(e,t,i){return new L(this,e,t,i)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i){return new ge(this,e,t,i)}clear({color:e,depth:t,stencil:i}){const r=this.gl;let n=0;e&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),void 0!==t&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}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(t){o(t.blendFunction,e.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class xe{constructor(e,t,i,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(e=>r.pointCoordinate3D(e)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(t,i){let r,n;if(t instanceof e.pointGeometry||"number"==typeof t[0]){const o=e.pointGeometry.convert(t);r=[e.pointGeometry.convert(t)],n=i.isPointAboveHorizon(o)}else{const o=e.pointGeometry.convert(t[0]),s=e.pointGeometry.convert(t[1]);r=[o,s],n=e.polygonizeBounds(o,s).every(e=>i.isPointAboveHorizon(e))}return new xe(r,i.getCameraPoint(),n,i)}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 i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],n=e.polygonizeBounds(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x<r.x?n.splice(3,0,this.cameraPoint):this.cameraPoint.x>=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),e.bufferConvexPolygon(n,t)}containsTile(t,i,r){const n=t.queryPadding+1,o=t.tileID.wrap,s=r?this._bufferedCameraMercator(n,i).map(i=>e.getTilePoint(t.tileTransform,i,o)):this._bufferedScreenMercator(n,i).map(i=>e.getTilePoint(t.tileTransform,i,o)),a=this.screenGeometryMercator.map(i=>e.getTileVec3(t.tileTransform,i,o)),l=a.map(t=>new e.pointGeometry(t[0],t[1])),c=i.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),h=e.getTileVec3(t.tileTransform,c,o),u=a.map(t=>{const i=e.sub(t,t,h);return e.normalize(i,i),new e.Ray(h,i)}),d=k(t,1,i.zoom);if(e.polygonIntersectsBox(s,0,0,e.EXTENT,e.EXTENT))return{queryGeometry:this,tilespaceGeometry:l,tilespaceRays:u,bufferedTilespaceGeometry:s,bufferedTilespaceBounds:be(e.getBounds(s)),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:d}}_bufferedScreenMercator(e,t){const i=ve(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{const r=this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e));return this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=ve(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{const r=this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e));return this._cameraRaycastCache[i]=r,r}}}function ve(e){return 100*e|0}function be(t){return t.min.x=e.clamp(t.min.x,0,e.EXTENT),t.min.y=e.clamp(t.min.y,0,e.EXTENT),t.max.x=e.clamp(t.max.x,0,e.EXTENT),t.max.y=e.clamp(t.max.y,0,e.EXTENT),t}function we(t,i,r){const n=function(n,o){if(n)return r(n);if(o){const n=e.pick(e.extend(o,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);o.vector_layers&&(n.vectorLayers=o.vector_layers,n.vectorLayerIds=n.vectorLayers.map(e=>e.id)),n.tiles=i.canonicalizeTileset(n,t.url),r(null,n)}};return t.url?e.getJSON(i.transformRequest(i.normalizeSourceURL(t.url),e.ResourceType.Source),n):e.exported.frame(()=>n(null,t))}class Te{constructor(t,i,r){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=r||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 i=Math.pow(2,t.z),r=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*i),n=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*i);return t.x>=r&&t.x<o&&t.y>=n&&t.y<s}}class Ee extends e.Evented{constructor(t,i,r,n){super(),this.id=t,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.extend({type:"raster"},i),e.extend(this,e.pick(i,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=we(this._options,this.map._requestManager,(t,i)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(e.extend(this,i),i.bounds&&(this.tileBounds=new Te(i.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(i.tiles),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(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const r=e.exported.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(n,e.ResourceType.Tile),(r,n,o,s)=>{if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s});const r=this.map.painter.context,a=r.gl;t.texture=this.map.painter.getTileTexture(n.width),t.texture?t.texture.update(n,{useMipmap:!0}):(t.texture=new e.Texture(r,n,a.RGBA,{useMipmap:!0}),t.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE),r.extTextureFilterAnisotropic&&a.texParameterf(a.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax)),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),i(null)}})}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}}let Se;function Ie(t,i,r,n,o,s,a,l){const c=[t,r,o,i,n,s,1,1,1],h=[a,l,1],u=e.adjoint([],c),[d,p,f]=e.transformMat3(h,h,e.transpose(u,u));return e.multiply(c,[d,0,0,0,p,0,0,0,f],c)}class Me extends e.Evented{constructor(e,t,i,r){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t}load(t,i){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),(r,n)=>{this._loaded=!0,r?this.fire(new e.ErrorEvent(r)):n&&(this.image=e.exported.getImageData(n),this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),i&&i(),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,()=>{this.texture=null}),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()}setCoordinates(t){this.coordinates=t,delete this._boundsArray;const i=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let i=1/0,r=1/0,n=-1/0,o=-1/0;for(const e of t)i=Math.min(i,e.x),r=Math.min(r,e.y),n=Math.max(n,e.x),o=Math.max(o,e.y);const s=n-i,a=o-r,l=Math.max(s,a),c=Math.max(0,Math.floor(-Math.log(l)/Math.LN2)),h=Math.pow(2,c);return new e.CanonicalTileID(c,Math.floor((i+n)/2*h),Math.floor((r+o)/2*h))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const t=e.tileTransform(this.tileID,this.map.transform.projection),[i,r,n,o]=this.coordinates.map(i=>{const r=t.projection.project(i[0],i[1]);return e.getTilePoint(t,r)._round()});return this.perspectiveTransform=function(t,i,r,n,o,s,a,l,c,h){const u=Ie(0,0,t,0,0,i,t,i),d=Ie(r,n,o,s,a,l,c,h);return e.multiply(d,e.adjoint(u,u),d),[d[6]/d[8]*t/e.EXTENT,d[7]/d[8]*i/e.EXTENT]}(this.width,this.height,i.x,i.y,r.x,r.y,o.x,o.y,n.x,n.y),this._boundsArray=new e.StructArrayLayout4i8,this._boundsArray.emplaceBack(i.x,i.y,0,0),this._boundsArray.emplaceBack(r.x,r.y,e.EXTENT,0),this._boundsArray.emplaceBack(o.x,o.y,0,e.EXTENT),this._boundsArray.emplaceBack(n.x,n.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,e.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new e.Texture(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}}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 Ae={vector:class extends e.Evented{constructor(t,i,r,n){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(i,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(n),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=we(this._options,this.map._requestManager,(t,i)=>{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(e.extend(this,i),i.bounds&&(this.tileBounds=new Te(i.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(i.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"})))})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e();const t=this.map.style._getSourceCaches(this.id);for(const e of t)e.clearTiles();this.load()}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,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(n.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",n,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);else{const i=e.loadVectorTile.call({deduped:this._deduped},n,(e,i)=>{e||!i?o.call(this,e):(n.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send("loadTile",n,o.bind(this),void 0,!0))},!0);t.request={cancel:i}}function o(r,n){return delete t.request,t.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),i(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={}}},raster:Ee,"raster-dem":class extends Ee{constructor(t,i,r,n){super(t,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),function(r,n,o,s){if(delete t.request,t.aborted)t.state="unloaded",i(null);else if(r)t.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:s});const r=e.window.ImageBitmap&&n instanceof e.window.ImageBitmap&&(null==Se&&(Se=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),Se),a=(n.width-e.prevPowerOfTwo(n.width))/2,l=1-a,c=l<1;c||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const h=r?n:e.exported.getImageData(n,l),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:h,encoding:this.encoding,padding:l};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,function(e,r){e&&(t.state="errored",i(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",i(null))}.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const i=t.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?t.wrap-1:t.wrap,s=(i.x+1+r)%r,a=i.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1<r&&(l[new e.OverscaledTileID(t.overscaledZ,o,i.z,n,i.y+1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,a,i.z,s,i.y+1).key]={backfilled:!1}),l}unloadTile(e){e.demTexture&&this.map.painter.saveTileTexture(e.demTexture),e.fbo&&(e.fbo.destroy(),delete e.fbo),e.dem&&delete e.dem,delete e.neighboringTiles,e.state="unloaded"}},geojson:class extends e.Evented{constructor(t,i,r,n){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=r.getActor(),this.setEventedParent(n),this._data=i.data,this._options=e.extend({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId;const o=e.EXTENT/this.tileSize;this.workerOptions=e.extend({source:this.id,cluster:i.cluster||!1,geojsonVtOptions:{buffer:(void 0!==i.buffer?i.buffer:128)*o,tolerance:(void 0!==i.tolerance?i.tolerance:.375)*o,extent:e.EXTENT,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1},superclusterOptions:{maxZoom:void 0!==i.clusterMaxZoom?i.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.EXTENT,radius:(void 0!==i.clusterRadius?i.clusterRadius:50)*o,log:!1,generateId:i.generateId||!1},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}onAdd(e){this.map=e,this.setData(this._data)}setData(e){return this._data=e,this._updateWorkerData(),this}getClusterExpansionZoom(e,t){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:e,source:this.id},t),this}getClusterChildren(e,t){return this.actor.send("geojson.getClusterChildren",{clusterId:e,source:this.id},t),this}getClusterLeaves(e,t,i,r){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:e,limit:t,offset:i},r),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new e.Event("dataloading",{dataType:"source"})),this._loaded=!1;const t=e.extend({},this.workerOptions),i=this._data;"string"==typeof i?(t.request=this.map._requestManager.transformRequest(e.exported.resolveURL(i),e.ResourceType.Source),t.request.collectResourceTiming=this._collectResourceTiming):t.data=JSON.stringify(i),this._pendingLoad=this.actor.send(`${this.type}.loadData`,t,(t,i)=>{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&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.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,i){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n={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};t.request=this.actor.send(r,n,(e,n)=>(delete t.request,t.unloadVectorData(),t.aborted?i(null):e?i(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null))),void 0,"loadTile"===r)}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 Me{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.ResourceType.Source).url);e.getVideo(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(this.video=i,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 i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=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,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,e.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2));for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Me,canvas:class extends Me{constructor(t,i,r,n){super(t,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof 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 i=this.map.painter.context,r=i.gl;this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,e.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(i,this.canvas,r.RGBA,{premultiply:!0});for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}}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}}},Ce=function(t,i,r,n){const o=new Ae[i.type](t,i,r,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function ze(t,i){const r=e.identity([]);return e.scale(r,r,[.5*t.width,.5*-t.height,1]),e.translate(r,r,[1,-1,0]),e.multiply$1(r,r,t.calculateProjMatrix(i.toUnwrapped()))}function ke(e,t,i,r,n,o,s,a=!1){const l=e.tilesIn(r,s,a);l.sort(De);const c=[];for(const r of l)c.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e._state,r,n,o,ze(e.transform,r.tile.tileID),a)});const h=function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(c);for(const t in h)h[t].forEach(t=>{const i=t.feature,r=e.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r});return h}function Pe(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],n={};for(let e=0;e<i.length;e++){const o=i[e],s=o.tileID.canonical.key;n[s]||(n[s]=!0,o.querySourceFeatures(r,t))}return r}function De(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Le(){return null!=rs.workerClass?new rs.workerClass:new e.window.Worker(rs.workerUrl)}const Be="mapboxgl_preloaded_worker_pool";class Re{constructor(){this.active={}}acquire(e){if(!this.workers)for(this.workers=[];this.workers.length<Re.workerCount;)this.workers.push(new Le);return this.active[e]=!0,this.workers.slice()}release(e){delete this.active[e],0===this.numActive()&&(this.workers.forEach(e=>{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Be]}numActive(){return Object.keys(this.active).length}}let Fe;function Oe(){return Fe||(Fe=new Re),Fe}function Ue(t,i){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return e.refProperties.forEach(e=>{e in i&&(r[e]=i[e])}),r}function Ve(e){e=e.slice();const t=Object.create(null);for(let i=0;i<e.length;i++)t[e[i].id]=e[i];for(let i=0;i<e.length;i++)"ref"in e[i]&&(e[i]=Ue(e[i],t[e[i].ref]));return e}Re.workerCount=2;const Ne={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function je(e,t,i){i.push({command:Ne.addSource,args:[e,t[e]]})}function Ge(e,t,i){t.push({command:Ne.removeSource,args:[e]}),i[e]=!0}function Ze(e,t,i,r){Ge(e,i,r),je(e,t,i)}function $e(e,t,i){let r;for(r in e[i])if(e[i].hasOwnProperty(r)&&"data"!==r&&!o(e[i][r],t[i][r]))return!1;for(r in t[i])if(t[i].hasOwnProperty(r)&&"data"!==r&&!o(e[i][r],t[i][r]))return!1;return!0}function qe(e,t,i,r,n,s){let a;for(a in t=t||{},e=e||{})e.hasOwnProperty(a)&&(o(e[a],t[a])||i.push({command:s,args:[r,a,t[a],n]}));for(a in t)t.hasOwnProperty(a)&&!e.hasOwnProperty(a)&&(o(e[a],t[a])||i.push({command:s,args:[r,a,t[a],n]}))}function Xe(e){return e.id}function We(e,t){return e[t.id]=t,e}function He(e,t){if(!e)return[{command:Ne.setStyle,args:[t]}];let i=[];try{if(!o(e.version,t.version))return[{command:Ne.setStyle,args:[t]}];o(e.center,t.center)||i.push({command:Ne.setCenter,args:[t.center]}),o(e.zoom,t.zoom)||i.push({command:Ne.setZoom,args:[t.zoom]}),o(e.bearing,t.bearing)||i.push({command:Ne.setBearing,args:[t.bearing]}),o(e.pitch,t.pitch)||i.push({command:Ne.setPitch,args:[t.pitch]}),o(e.sprite,t.sprite)||i.push({command:Ne.setSprite,args:[t.sprite]}),o(e.glyphs,t.glyphs)||i.push({command:Ne.setGlyphs,args:[t.glyphs]}),o(e.transition,t.transition)||i.push({command:Ne.setTransition,args:[t.transition]}),o(e.light,t.light)||i.push({command:Ne.setLight,args:[t.light]}),o(e.fog,t.fog)||i.push({command:Ne.setFog,args:[t.fog]}),o(e.projection,t.projection)||i.push({command:Ne.setProjection,args:[t.projection]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})e.hasOwnProperty(n)&&(t.hasOwnProperty(n)||Ge(n,i,r));for(n in t)t.hasOwnProperty(n)&&(e.hasOwnProperty(n)?o(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&$e(e,t,n)?i.push({command:Ne.setGeoJSONSourceData,args:[n,t[n].data]}):Ze(n,t,i,r)):je(n,t,i))}(e.sources,t.sources,n,r);const s=[];e.layers&&e.layers.forEach(e=>{r[e.source]?i.push({command:Ne.removeLayer,args:[e.id]}):s.push(e)});let a=e.terrain;a&&r[a.source]&&(i.push({command:Ne.setTerrain,args:[void 0]}),a=void 0),i=i.concat(n),o(a,t.terrain)||i.push({command:Ne.setTerrain,args:[t.terrain]}),function(e,t,i){t=t||[];const r=(e=e||[]).map(Xe),n=t.map(Xe),s=e.reduce(We,{}),a=t.reduce(We,{}),l=r.slice(),c=Object.create(null);let h,u,d,p,f,m,_;for(h=0,u=0;h<r.length;h++)d=r[h],a.hasOwnProperty(d)?u++:(i.push({command:Ne.removeLayer,args:[d]}),l.splice(l.indexOf(d,u),1));for(h=0,u=0;h<n.length;h++)d=n[n.length-1-h],l[l.length-1-h]!==d&&(s.hasOwnProperty(d)?(i.push({command:Ne.removeLayer,args:[d]}),l.splice(l.lastIndexOf(d,l.length-u),1)):u++,m=l[l.length-h],i.push({command:Ne.addLayer,args:[a[d],m]}),l.splice(l.length-h,0,d),c[d]=!0);for(h=0;h<n.length;h++)if(p=s[d=n[h]],f=a[d],!c[d]&&!o(p,f))if(o(p.source,f.source)&&o(p["source-layer"],f["source-layer"])&&o(p.type,f.type)){for(_ in qe(p.layout,f.layout,i,d,null,Ne.setLayoutProperty),qe(p.paint,f.paint,i,d,null,Ne.setPaintProperty),o(p.filter,f.filter)||i.push({command:Ne.setFilter,args:[d,f.filter]}),o(p.minzoom,f.minzoom)&&o(p.maxzoom,f.maxzoom)||i.push({command:Ne.setLayerZoomRange,args:[d,f.minzoom,f.maxzoom]}),p)p.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?qe(p[_],f[_],i,d,_.slice(6),Ne.setPaintProperty):o(p[_],f[_])||i.push({command:Ne.setLayerProperty,args:[d,_,f[_]]}));for(_ in f)f.hasOwnProperty(_)&&!p.hasOwnProperty(_)&&"layout"!==_&&"paint"!==_&&"filter"!==_&&"metadata"!==_&&"minzoom"!==_&&"maxzoom"!==_&&(0===_.indexOf("paint.")?qe(p[_],f[_],i,d,_.slice(6),Ne.setPaintProperty):o(p[_],f[_])||i.push({command:Ne.setLayerProperty,args:[d,_,f[_]]}))}else i.push({command:Ne.removeLayer,args:[d]}),m=l[l.lastIndexOf(d)+1],i.push({command:Ne.addLayer,args:[f,m]})}(s,t.layers,i)}catch(e){console.warn("Unable to compute style diff:",e),i=[{command:Ne.setStyle,args:[t]}]}return i}class Ke{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e<this.points.length;e++)this._distances[e]=this._distances[e-1]+this.points[e].dist(this.points[e-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(t||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.clamp(t,0,1);let i=1,r=this._distances[i];const n=t*this.paddedLength+this.padding;for(;r<n&&i<this._distances.length;)r=this._distances[++i];const o=i-1,s=this._distances[o],a=r-s,l=a>0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Je{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;e<this.xCellCount*this.yCellCount;e++)r.push([]),n.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=e,this.height=t,this.xScale=this.xCellCount/e,this.yScale=this.yCellCount/t,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,t,i,r,n){this._forEachCell(t,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(t),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(e,t,i,r){this._forEachCell(t-r,i-r,t+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(e),this.circles.push(t),this.circles.push(i),this.circles.push(r)}_insertBoxCell(e,t,i,r,n,o){this.boxCells[n].push(o)}_insertCircleCell(e,t,i,r,n,o){this.circleCells[n].push(o)}_query(e,t,i,r,n,o){if(i<0||e>this.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e<this.boxKeys.length;e++)s.push({key:this.boxKeys[e],x1:this.bboxes[4*e],y1:this.bboxes[4*e+1],x2:this.bboxes[4*e+2],y2:this.bboxes[4*e+3]});for(let e=0;e<this.circleKeys.length;e++){const t=this.circles[3*e],i=this.circles[3*e+1],r=this.circles[3*e+2];s.push({key:this.circleKeys[e],x1:t-r,y1:i-r,x2:t+r,y2:i+r})}return o?s.filter(o):s}{const a={hitTest:n,seenUids:{box:{},circle:{}}};return this._forEachCell(e,t,i,r,this._queryCell,s,a,o),n?s.length>0:s}}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[],h={hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}};return this._forEachCell(o,a,s,l,this._queryCellCircle,c,h,n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[h]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[h],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const h=this.circleCells[n];if(null!==h){const n=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[h],t=n[h+1],i=n[h+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const u=this.circleCells[n];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let d=l;d<=h;d++)for(let l=c;l<=u;l++){const c=this.xCellCount*l+d;if(n.call(this,e,t,i,r,c,o,s,a))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,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,h=Math.abs(t-(n+c));if(h>c+i)return!1;if(l<=a||h<=c)return!0;const u=l-a,d=h-c;return u*u+d*d<=i*i}}const Ye={unknown:0,flipRequired:1,flipNotRequired:2},Qe=Math.tan(85*Math.PI/180);function et(t,i,r,o,s,a){let l=e.create();if(r){if("globe"===s.projection.name){const t=s.worldSize/s._projectionScaler;l=e.calculateGlobeMatrix(s,t,[0,0]),e.multiply$1(l,l,e.globeDenormalizeECEF(e.globeTileBounds(i)))}else{const e=n([],a);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3]}o||e.rotateZ(l,l,s.angle)}else e.multiply$1(l,s.labelPlaneMatrix,t);return l}function tt(t,i,r,n,o,s){if(r){if("globe"===o.projection.name){const a=et(t,i,r,n,o,s);return e.invert(a,a),e.multiply$1(a,t,a),a}{const i=e.clone(t),r=e.identity([]);return r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3],e.multiply$1(i,i,r),n||e.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function it(t,i,r=0){const n=[t.x,t.y,r,1];r?e.transformMat4$1(n,n,i):mt(n,n,i);const o=n[3];return{point:new e.pointGeometry(n[0]/o,n[1]/o),signedDistanceFromCamera:o}}function rt(t,i){const r=[t[0],t[1],t[2],1];e.transformMat4$1(r,r,i);const n=r[3];return{point:new e.pointGeometry(r[0]/n,r[1]/n),signedDistanceFromCamera:n}}function nt(e,t){return Math.min(.5+e/t*.5,1.5)}function ot(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function st(t,i,r,n,o,s,a,l,c,h){const u=r.transform,d=n?t.textSizeData:t.iconSizeData,p=e.evaluateSizeForZoom(d,r.transform.zoom),f=[256/r.width*2+1,256/r.height*2+1],m=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();const _=t.lineVertexArray,g=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=r.transform.width/r.transform.height;let x=!1;for(let n=0;n<g.length;n++){const v=g.get(n);if(v.writingMode!==e.WritingMode.vertical||x||0!==n&&g.get(n-1).writingMode===e.WritingMode.horizontal||(x=!0),v.hidden||v.writingMode===e.WritingMode.vertical&&!x){ft(v.numGlyphs,m);continue}x=!1;const b=new e.pointGeometry(v.tileAnchorX,v.tileAnchorY),w=c?c(b):[0,0,0],T=u.projection.projectTilePoint(b.x,b.y,h.canonical),E=[T.x+w[0],T.y+w[1],T.z+w[2]],S=[...E,1];if(e.transformMat4$1(S,S,i),!ot(S,f)){ft(v.numGlyphs,m);continue}const I=S[3],M=nt(r.transform.cameraToCenterDistance,I),A=e.evaluateSizeForFeature(d,p,v),C=a?A/M:A*M,z=it(new e.pointGeometry(E[0],E[1]),o,E[2]);if(z.signedDistanceFromCamera<=0){ft(v.numGlyphs,m);continue}let k={};const P=a?null:c,D=ct(v,C,!1,l,i,o,s,t.glyphOffsetArray,_,m,z.point,b,k,y,P,u.projection,h);x=D.useVertical,P&&D.needsFlipping&&(k={}),(D.notEnoughRoom||x||D.needsFlipping&&ct(v,C,!0,l,i,o,s,t.glyphOffsetArray,_,m,z.point,b,k,y,P,u.projection,h).notEnoughRoom)&&ft(v.numGlyphs,m)}n?t.text.dynamicLayoutVertexBuffer.updateData(m):t.icon.dynamicLayoutVertexBuffer.updateData(m)}function at(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=a.glyphStartIndex+a.numGlyphs,_=a.lineStartIndex,g=a.lineStartIndex+a.lineLength,y=t.getoffsetX(a.glyphStartIndex),x=t.getoffsetX(m-1),v=dt(e*y,i,r,n,o,s,a.segment,_,g,l,c,h,u,d,!0,p,f);if(!v)return null;const b=dt(e*x,i,r,n,o,s,a.segment,_,g,l,c,h,u,d,!0,p,f);return b?{first:v,last:b}:null}function lt(t,i,r,n){if(t.writingMode===e.WritingMode.horizontal){if(Math.abs(r.y-i.y)>Math.abs(r.x-i.x)*n)return{useVertical:!0}}return t.writingMode===e.WritingMode.vertical?i.y<r.y?{needsFlipping:!0}:null:t.flipState!==Ye.unknown&&function(e,t,i){const r=t.y-e.y,n=(t.x-e.x)*i;return 0===n||Math.abs(r/n)>Qe}(i,r,n)?t.flipState===Ye.flipRequired?{needsFlipping:!0}:null:i.x>r.x?{needsFlipping:!0}:null}function ct(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=i/24,x=t.lineOffsetX*y,v=t.lineOffsetY*y;let b;if(t.numGlyphs>1){const e=t.glyphStartIndex+t.numGlyphs,i=t.lineStartIndex,o=t.lineStartIndex+t.lineLength,h=at(y,l,x,v,r,u,d,t,c,s,p,m,!1,_,g);if(!h)return{notEnoughRoom:!0};const w=it(h.first.point,a).point,T=it(h.last.point,a).point;if(n&&!r){const e=lt(t,w,T,f);if(t.flipState=e&&e.needsFlipping?Ye.flipRequired:Ye.flipNotRequired,e)return e}b=[h.first];for(let n=t.glyphStartIndex+1;n<e-1;n++)b.push(dt(y*l.getoffsetX(n),x,v,r,u,d,t.segment,i,o,c,s,p,m,!1,!1,_,g));b.push(h.last)}else{if(n&&!r){const i=it(d,o).point,r=t.lineStartIndex+t.segment+1,n=new e.pointGeometry(c.getx(r),c.gety(r)),s=it(n,o),a=lt(t,i,s.signedDistanceFromCamera>0?s.point:ut(d,n,i,1,o,void 0,_,g.canonical),f);if(t.flipState=a&&a.needsFlipping?Ye.flipRequired:Ye.flipNotRequired,a)return a}const i=dt(y*l.getoffsetX(t.glyphStartIndex),x,v,r,u,d,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,s,p,m,!1,!1,_,g);if(!i)return{notEnoughRoom:!0};b=[i]}for(const t of b)e.addDynamicAttributes(h,t.point,t.angle);return{}}function ht(t,i,r,n,o){const s=n.projectTilePoint(t.x,t.y,i);if(!o)return it(s,r,s.z);const a=o(t);return it(new e.pointGeometry(s.x+a[0],s.y+a[1]),r,s.z+a[2])}function ut(e,t,i,r,n,o,s,a){const l=ht(e.add(e.sub(t)._unit()),a,n,s,o).point,c=i.sub(l);return i.add(c._mult(r/c.mag()))}function dt(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=n?t-i:t+i;let x=y>0?1:-1,v=0;n&&(x*=-1,v=Math.PI),x<0&&(v+=Math.PI);let b=x>0?l+a:l+a+1,w=o,T=o,E=0,S=0;const I=Math.abs(y),M=[],A=[];let C=s;const z=()=>{const t=b-x;return 0===E?s:new e.pointGeometry(h.getx(t),h.gety(t))},k=()=>ut(z(),C,T,I-E+1,u,p,_,g.canonical);for(;E+S<=I;){if((b+=x)<l||b>=c)return null;if(T=w,M.push(w),f&&A.push(C||z()),void 0===(w=d[b])){const t=ht(C=new e.pointGeometry(h.getx(b),h.gety(b)),g.canonical,u,_,p);w=t.signedDistanceFromCamera>0?d[b]=t.point:k()}else C=null;E+=S,S=T.dist(w)}m&&p&&(C=C||new e.pointGeometry(h.getx(b),h.gety(b)),d[b]=w=void 0===d[b]?w:k(),S=T.dist(w));const P=(I-E)/S,D=w.sub(T),L=D.mult(P)._add(T);r&&L._add(D._unit()._perp()._mult(r*x));const B=v+Math.atan2(w.y-T.y,w.x-T.x);if(M.push(L),f){C=C||new e.pointGeometry(h.getx(b),h.gety(b));const t=A.length>0?A[A.length-1]:C;A.push(function(t,i,r){const n=1-r;return new e.pointGeometry(t.x*n+i.x*r,t.y*n+i.y*r)}(t,C,P))}return{point:L,angle:B,path:M,tilePath:A}}const pt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ft(e,t){for(let i=0;i<e;i++){const e=t.length;t.resize(e+4),t.float32.set(pt,3*e)}}function mt(e,t,i){const r=t[0],n=t[1];return e[0]=i[0]*r+i[4]*n+i[12],e[1]=i[1]*r+i[5]*n+i[13],e[3]=i[3]*r+i[7]*n+i[15],e}const _t=100;class gt{constructor(e,t,i=new Je(e.width+2*_t,e.height+2*_t,25),r=new Je(e.width+2*_t,e.height+2*_t,25)){this.transform=e,this.grid=i,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+_t,this.screenBottomBoundary=e.height+_t,this.gridRightBoundary=e.width+2*_t,this.gridBottomBoundary=e.height+2*_t,this.fogState=t}placeCollisionBox(e,t,i,r,n,o,s){let a=t.projectedAnchorX,l=t.projectedAnchorY,c=t.projectedAnchorZ;const h=t.elevation,u=t.tileID;if(h&&u){const e=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),i=e.upVector(u.canonical,t.tileAnchorX,t.tileAnchorY),r=e.upVectorScale(u.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;a+=i[0]*h*r,l+=i[1]*h*r,c+=i[2]*h*r}const d=this.projectAndGetPerspectiveRatio(o,a,l,c,t.tileID),p=n*d.perspectiveRatio,f=(t.x1*e+i.x-t.padding)*p+d.point.x,m=(t.y1*e+i.y-t.padding)*p+d.point.y,_=(t.x2*e+i.x+t.padding)*p+d.point.x,g=(t.y2*e+i.y+t.padding)*p+d.point.y,y=d.perspectiveRatio<=.55||d.aboveHorizon;return!this.isInsideGrid(f,m,_,g)||!r&&this.grid.hitTest(f,m,_,g,s)||y?{box:[],offscreen:!1}:{box:[f,m,_,g],offscreen:this.isOffscreen(f,m,_,g)}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,h,u,d,p,f){const m=[],_=this.transform.elevation,g=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),y=_?_.getAtTileOffsetFunc(f,this.transform.center.lat,this.transform.worldSize,g):e=>[0,0,0],x=new e.pointGeometry(i.tileAnchorX,i.tileAnchorY),v=this.transform.projection.projectTilePoint(i.tileAnchorX,i.tileAnchorY,f.canonical),b=y(x),w=[v.x+b[0],v.y+b[1],v.z+b[2]],T=this.projectAndGetPerspectiveRatio(s,w[0],w[1],w[2],f),{perspectiveRatio:E}=T,S=(h?o/E:o*E)/e.ONE_EM,I=it(new e.pointGeometry(w[0],w[1]),a,w[2]).point,M=i.lineOffsetX*S,A=i.lineOffsetY*S,C=T.signedDistanceFromCamera>0?at(S,n,M,A,!1,I,x,i,r,a,{},_&&!h?y:null,h&&!!_,this.transform.projection,f):null;let z=!1,k=!1,P=!0;if(C&&!T.aboveHorizon){const i=.5*d*E+p,r=new e.pointGeometry(-_t,-_t),n=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Ke,s=C.first,a=C.last;let h=[];for(let e=s.path.length-1;e>=1;e--)h.push(s.path[e]);for(let e=1;e<a.path.length;e++)h.push(a.path[e]);const f=2.5*i;if(l){const e=_?h.map((e,t)=>{const i=y(t<s.path.length-1?s.tilePath[s.path.length-1-t]:a.tilePath[t-s.path.length+2]);return it(e,l,i[2])}):h.map(e=>it(e,l));h=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(h.length>0){const t=h[0].clone(),i=h[0].clone();for(let e=1;e<h.length;e++)t.x=Math.min(t.x,h[e].x),t.y=Math.min(t.y,h[e].y),i.x=Math.max(i.x,h[e].x),i.y=Math.max(i.y,h[e].y);g=t.x>=r.x&&i.x<=n.x&&t.y>=r.y&&i.y<=n.y?[h]:i.x<r.x||t.x>n.x||i.y<r.y||t.y>n.y?[]:e.clipLine([h],r.x,r.y,n.x,n.y)}for(const e of g){o.reset(e,.25*i);let r=0;r=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let e=0;e<r;e++){const n=e/Math.max(r-1,1),s=o.lerp(n),a=s.x+_t,l=s.y+_t;m.push(a,l,i,0);const h=a-i,d=l-i,p=a+i,f=l+i;if(P=P&&this.isOffscreen(h,d,p,f),k=k||this.isInsideGrid(h,d,p,f),!t&&this.grid.hitTestCircle(a,l,i,u)&&(z=!0,!c))return{circles:[],offscreen:!1,collisionDetected:z}}}}return{circles:!c&&z||!k?[]:m,offscreen:P,collisionDetected:z}}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[];let r=1/0,n=1/0,o=-1/0,s=-1/0;for(const a of t){const t=new e.pointGeometry(a.x+_t,a.y+_t);r=Math.min(r,t.x),n=Math.min(n,t.y),o=Math.max(o,t.x),s=Math.max(s,t.y),i.push(t)}const a=this.grid.query(r,n,o,s).concat(this.ignoredGrid.query(r,n,o,s)),l={},c={};for(const t of a){const r=t.key;if(void 0===l[r.bucketInstanceId]&&(l[r.bucketInstanceId]={}),l[r.bucketInstanceId][r.featureIndex])continue;const n=[new e.pointGeometry(t.x1,t.y1),new e.pointGeometry(t.x2,t.y1),new e.pointGeometry(t.x2,t.y2),new e.pointGeometry(t.x1,t.y2)];e.polygonIntersectsPolygon(i,n)&&(l[r.bucketInstanceId][r.featureIndex]=!0,void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]=[]),c[r.bucketInstanceId].push(r.featureIndex))}return c}insertCollisionBox(e,t,i,r,n){const o={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};(t?this.ignoredGrid:this.grid).insert(o,e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n){const o=t?this.ignoredGrid:this.grid,s={bucketInstanceId:i,featureIndex:r,collisionGroupID:n};for(let t=0;t<e.length;t+=4)o.insertCircle(s,e[t],e[t+1],e[t+2])}projectAndGetPerspectiveRatio(t,i,r,n,o){const s=[i,r,n||0,1];let a=!1;if(n||this.transform.pitch>0){e.transformMat4$1(s,s,t);let l=!1;if(this.fogState&&o){l=function(t,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return e.transformMat4(l,l,a),S(t,l,s.pitch,s._fov)}(this.fogState,i,r,n||0,o.toUnwrapped(),this.transform)>E}a=s[2]>s[3]||l}else mt(s,s,t);return{point:new e.pointGeometry((s[0]/s[3]+1)/2*this.transform.width+_t,(-s[1]/s[3]+1)/2*this.transform.height+_t),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/s[3]*.5,1.5),signedDistanceFromCamera:s[3],aboveHorizon:a}}isOffscreen(e,t,i,r){return i<_t||e>=this.screenRightBoundary||r<_t||t>this.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e<this.gridRightBoundary&&r>=0&&t<this.gridBottomBoundary}getViewportMatrix(){const t=e.identity([]);return e.translate(t,t,[-_t,-_t,0]),t}}class yt{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class xt{constructor(e,t,i,r,n,o=!1){this.text=new yt(e?e.text:null,t,i,n),this.icon=new yt(e?e.icon:null,t,r,n),this.clipped=o}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class vt{constructor(e,t,i,r=!1){this.text=e,this.icon=t,this.skipFade=i,this.clipped=r}}class bt{constructor(){this.invProjMatrix=e.create(),this.viewportMatrix=e.create(),this.circles=[]}}class wt{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class Tt{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 Et(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.getAnchorAlignment(t),l=-(s-.5)*i,c=-(a-.5)*r,h=e.evaluateVariableOffset(t,n);return new e.pointGeometry(l+h[0]*o,c+h[1]*o)}function St(t,i,r,n,o){const s=new e.pointGeometry(t,i);return r&&s._rotate(n?o:-o),s}class It{constructor(e,t,i,r,n){this.transform=e.clone(),this.collisionIndex=new gt(this.transform,n),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Tt(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=r.collisionBoxArray,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/e.EXTENT,u=r.tileID.toUnwrapped(),d=this.transform.calculateProjMatrix(u),p="map"===a.get("text-pitch-alignment"),f="map"===a.get("text-rotation-alignment");i.compileFilter();const m=i.dynamicFilter(),_=i.dynamicFilterNeedsFeature(),g=this.transform.calculatePixelsToTileUnitsMatrix(r),y=et(d,r.tileID.canonical,p,f,this.transform,g);let x=null;if(p){const t=tt(d,r.tileID.canonical,p,f,this.transform,g);x=e.multiply$1([],this.transform.labelPlaneMatrix,t)}let v=null;m&&r.latestFeatureIndex&&(v={unwrappedTileID:u,dynamicFilter:m,dynamicFilterNeedsFeature:_,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new wt(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const b={bucket:o,layout:a,posMatrix:d,textLabelPlaneMatrix:y,labelToScreenMatrix:x,clippingData:v,scale:c,textPixelRatio:h,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const e of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:b})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:b})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m,_,g){const y=[u.textOffset0,u.textOffset1],x=Et(e,i,r,y,n),v=this.collisionIndex.placeCollisionBox(n,t,St(x.x,x.y,o,s,this.transform.angle),h,a,l,c.predicate);if(m){if(0===this.collisionIndex.placeCollisionBox(p.getSymbolInstanceIconSize(g,this.transform.zoom,d),m,St(x.x,x.y,o,s,this.transform.angle),h,a,l,c.predicate).box.length)return}if(v.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(t=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:y,width:i,height:r,anchor:e,textScale:n,prevAnchor:t},this.markUsedJustification(p,e,u,f),p.allowVerticalPlacement&&(this.markUsedOrientation(p,f,u),this.placedOrientations[u.crossTileID]=f),{shift:x,placedGlyphBoxes:v}}}placeLayerBucketPart(t,i,r,n){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:d,collisionBoxArray:p,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=s.get("text-optional"),y=s.get("icon-optional"),x=s.get("text-allow-overlap"),v=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),T="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order"),S=x&&(v||!o.hasIconData()||y),I=v&&(x||!o.hasTextData()||g);!o.collisionArrays&&p&&o.deserializeCollisionBoxes(p),r&&n&&o.updateCollisionDebugBuffers(this.transform.zoom,p);const M=(t,n,p)=>{if(h){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let n=null;if(h.dynamicFilterNeedsFeature){const e=h.featureIndex,i=this.retainedQueryData[o.bucketInstanceId];n=e.loadFeature({featureIndex:t.featureIndex,bucketIndex:i.bucketIndex,sourceLayerIndex:i.sourceLayerIndex,layoutVertexArrayOffset:0})}const s=this.retainedQueryData[o.bucketInstanceId].tileID.canonical;if(!(0,h.dynamicFilter)(r,n,s,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[t.crossTileID]=new vt(!1,!1,!1,!0),void(i[t.crossTileID]=!0)}if(i[t.crossTileID])return;if(d)return void(this.placements[t.crossTileID]=new vt(!1,!1,!1));let E=!1,M=!1,A=!0,C=null,z={box:null,offscreen:null},k={box:null,offscreen:null},P=null,D=null,L=null,B=0,R=0,F=0;p.textFeatureIndex?B=p.textFeatureIndex:t.useRuntimeCollisionCircles&&(B=t.featureIndex),p.verticalTextFeatureIndex&&(R=p.verticalTextFeatureIndex);const O=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},U=p.textBox;if(U){O(U);const i=i=>{let r=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(i,r)=>{if(o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&p.verticalTextBox){for(const t of o.writingModes)if(t===e.WritingMode.vertical?(z=r(),k=z):z=i(),z&&z.box&&z.box.length)break}else z=i()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor)).unshift(e.anchor)}const c=(e,i,r)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),c=(e.x2-e.x1)*s+2*e.padding,h=(e.y2-e.y1)*s+2*e.padding,d=T&&!v?i:null;d&&O(d);let p={box:[],offscreen:!1};const g=x?2*l.length:l.length;for(let i=0;i<g;++i){const g=l[i%l.length],y=i>=l.length,x=this.attemptAnchorPlacement(g,e,c,h,s,b,w,u,a,_,y,t,n,o,r,d,f,m);if(x&&(p=x.placedGlyphBoxes)&&p.box&&p.box.length){E=!0,C=x.shift;break}}return p};r(()=>c(U,p.iconBox,e.WritingMode.horizontal),()=>{const i=p.verticalTextBox;i&&O(i);const r=z&&z.box&&z.box.length;return o.allowVerticalPlacement&&!r&&t.numVerticalGlyphVertices>0&&i?c(i,p.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null}}),z&&(E=z.box,A=z.offscreen);const h=i(z&&z.box);if(!E&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(o,e.anchor,t,h))}}else{const s=(i,r)=>{const s=o.getSymbolInstanceTextSize(f,t,this.transform.zoom,n),l=this.collisionIndex.placeCollisionBox(s,i,new e.pointGeometry(0,0),x,u,a,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[t.crossTileID]=r),l};r(()=>s(U,e.WritingMode.horizontal),()=>{const i=p.verticalTextBox;return o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?(O(i),s(i,e.WritingMode.vertical)):{box:null,offscreen:null}}),i(z&&z.box&&z.box.length)}}if(E=(P=z)&&P.box&&P.box.length>0,A=P&&P.offscreen,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,n=o.text.placedSymbolArray.get(i),h=e.evaluateSizeForFeature(o.textSizeData,f,n),u=s.get("text-padding"),d=t.collisionCircleDiameter*h/e.ONE_EM;D=this.collisionIndex.placeCollisionCircles(x,n,o.lineVertexArray,o.glyphOffsetArray,h,a,l,c,r,w,_.predicate,d,u,this.retainedQueryData[o.bucketInstanceId].tileID),E=x||D.circles.length>0&&!D.collisionDetected,A=A&&D.offscreen}if(p.iconFeatureIndex&&(F=p.iconFeatureIndex),p.iconBox){const t=t=>{O(t);const i=T&&C?St(C.x,C.y,b,w,this.transform.angle):new e.pointGeometry(0,0),r=o.getSymbolInstanceIconSize(m,this.transform.zoom,n);return this.collisionIndex.placeCollisionBox(r,t,i,v,u,a,_.predicate)};M=k&&k.box&&k.box.length&&p.verticalIconBox?(L=t(p.verticalIconBox)).box.length>0:(L=t(p.iconBox)).box.length>0,A=A&&L.offscreen}const V=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,N=y||0===t.numIconVertices;if(V||N?N?V||(M=M&&E):E=M&&E:M=E=M&&E,E&&P&&P.box&&(k&&k.box&&R?this.collisionIndex.insertCollisionBox(P.box,s.get("text-ignore-placement"),o.bucketInstanceId,R,_.ID):this.collisionIndex.insertCollisionBox(P.box,s.get("text-ignore-placement"),o.bucketInstanceId,B,_.ID)),M&&L&&this.collisionIndex.insertCollisionBox(L.box,s.get("icon-ignore-placement"),o.bucketInstanceId,F,_.ID),D&&(E&&this.collisionIndex.insertCollisionCircles(D.circles,s.get("text-ignore-placement"),o.bucketInstanceId,B,_.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new bt);for(let e=0;e<D.circles.length;e+=4)t.circles.push(D.circles[e+0]),t.circles.push(D.circles[e+1]),t.circles.push(D.circles[e+2]),t.circles.push(D.collisionDetected?1:0)}this.placements[t.crossTileID]=new vt(E||S,M||I,A||o.justReloaded),i[t.crossTileID]=!0};if(E){const e=o.getSortedSymbolIndexes(this.transform.angle);for(let t=e.length-1;t>=0;--t){const i=e[t];M(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)M(o.symbolInstances.get(e),e,o.collisionArrays[e]);if(r&&o.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[o.bucketInstanceId];e.invert(t.invProjMatrix,a),t.viewportMatrix=this.collisionIndex.getViewportMatrix()}o.justReloaded=!1}markUsedJustification(t,i,r,n){const o={left:r.leftJustifiedTextSymbolIndex,center:r.centerJustifiedTextSymbolIndex,right:r.rightJustifiedTextSymbolIndex};let s;s=n===e.WritingMode.vertical?r.verticalPlacedTextSymbolIndex:o[e.getAnchorJustification(i)];const a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex,r.verticalPlacedTextSymbolIndex];for(const e of a)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=s>=0&&e!==s?0:r.crossTileID)}markUsedOrientation(t,i,r){const n=i===e.WritingMode.horizontal||i===e.WritingMode.horizontalOnly?i:0,o=i===e.WritingMode.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const e of s)t.text.placedSymbolArray.get(e).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new xt(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new xt(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new xt(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,i=i||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,i,r.collisionBoxArray)}}updateBucketOpacities(t,i,r){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 n=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),s=new xt(null,0,!1,!1,!0),a=n.get("text-allow-overlap"),l=n.get("icon-allow-overlap"),c=n.get("text-variable-anchor"),h="map"===n.get("text-rotation-alignment"),u="map"===n.get("text-pitch-alignment"),d="none"!==n.get("icon-text-fit"),p=new xt(null,0,a&&(l||!t.hasIconData()||n.get("icon-optional")),l&&(a||!t.hasTextData()||n.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const f=(e,t,i)=>{for(let r=0;r<t/4;r++)e.opacityVertexArray.emplaceBack(i)};let m=0;for(let r=0;r<t.symbolInstances.length;r++){const n=t.symbolInstances.get(r),{numHorizontalGlyphVertices:a,numVerticalGlyphVertices:l,crossTileID:_}=n,g=i[_];let y=this.opacities[_];g?y=s:y||(y=p,this.opacities[_]=y),i[_]=!0;const x=a>0||l>0,v=n.numIconVertices>0,b=this.placedOrientations[n.crossTileID],w=b===e.WritingMode.vertical,T=b===e.WritingMode.horizontal||b===e.WritingMode.horizontalOnly;if(!x&&!v||y.isHidden()||m++,x){const e=Bt(y.text),i=w?Rt:e;f(t.text,a,i);const r=T?Rt:e;f(t.text,l,r);const o=y.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach(e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=o||w?1:0)}),n.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=o||T?1:0);const s=this.variableOffsets[n.crossTileID];s&&this.markUsedJustification(t,s.anchor,n,b);const c=this.placedOrientations[n.crossTileID];c&&(this.markUsedJustification(t,"left",n,c),this.markUsedOrientation(t,c,n))}if(v){const e=Bt(y.icon);if(n.placedIconSymbolIndex>=0){const i=w?Rt:e;f(t.icon,n.numIconVertices,i),t.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=y.icon.isHidden()}if(n.verticalPlacedIconSymbolIndex>=0){const i=T?Rt:e;f(t.icon,n.numVerticalIconVertices,i),t.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=y.icon.isHidden()}}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let r=new e.pointGeometry(0,0),n=!0;if(i.textBox||i.verticalTextBox){if(c){const e=this.variableOffsets[_];e?(r=Et(e.anchor,e.width,e.height,e.textOffset,e.textScale),h&&r._rotate(u?this.transform.angle:-this.transform.angle)):n=!1}o&&(n=!y.clipped),i.textBox&&Mt(t.textCollisionBox.collisionVertexArray,y.text.placed,!n||w,r.x,r.y),i.verticalTextBox&&Mt(t.textCollisionBox.collisionVertexArray,y.text.placed,!n||T,r.x,r.y)}const s=n&&Boolean(!T&&i.verticalIconBox);i.iconBox&&Mt(t.iconCollisionBox.collisionVertexArray,y.icon.placed,s,d?r.x:0,d?r.y:0),i.verticalIconBox&&Mt(t.iconCollisionBox.collisionVertexArray,y.icon.placed,!s,d?r.x:0,d?r.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.lastPlacementChangeTime<this.fadeDuration}stillRecent(e,t){const i=this.zoomAtLastRecencyCheck===t?1-this.zoomAdjustment(t):1;return this.zoomAtLastRecencyCheck=t,this.commitTime+this.fadeDuration*i>e}setStale(){this.stale=!0}}function Mt(e,t,i,r,n){e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0),e.emplaceBack(t?1:0,i?1:0,r||0,n||0)}const At=Math.pow(2,25),Ct=Math.pow(2,24),zt=Math.pow(2,17),kt=Math.pow(2,16),Pt=Math.pow(2,9),Dt=Math.pow(2,8),Lt=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,i=Math.floor(127*e.opacity);return i*At+t*Ct+i*zt+t*kt+i*Pt+t*Dt+i*Lt+t}const Rt=0;class Ft{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={},this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndex<e.length;){const i=e[this._currentTileIndex];if(t.getBucketParts(o,r,i,this._sortAcrossTiles),this._currentTileIndex++,n())return!0}for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,o.sort((e,t)=>e.sortKey-t.sortKey));this._currentPartIndex<o.length;){const e=o[this._currentPartIndex];if(t.placeLayerBucketPart(e,this._seenCrossTileIDs,i,0===e.symbolInstanceStart),this._currentPartIndex++,n())return!0}return!1}}class Ot{constructor(e,t,i,r,n,o,s,a){this.placement=new It(e,n,o,s,a),this._currentPlacementIndex=t.length-1,this._forceFullPlacement=i,this._showCollisionBoxes=r,this._done=!1}isDone(){return this._done}continuePlacement(t,i,r){const n=e.exported.now(),o=()=>{const t=e.exported.now()-n;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=i[t[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=n)&&(!e.maxzoom||e.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Ft(e)),this._inProgressLayer.continuePlacement(r[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ut=512/e.EXTENT/2;class Vt{constructor(e,t,i){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let i=0;i<t.length;i++){const r=t.get(i),n=r.key;this.indexedSymbolInstances[n]||(this.indexedSymbolInstances[n]=[]),this.indexedSymbolInstances[n].push({crossTileID:r.crossTileID,coord:this.getScaledCoordinates(r,e)})}}getScaledCoordinates(t,i){const r=i.canonical.z-this.tileID.canonical.z,n=Ut/Math.pow(2,r);return{x:Math.floor((i.canonical.x*e.EXTENT+t.tileAnchorX)*n),y:Math.floor((i.canonical.y*e.EXTENT+t.tileAnchorY)*n)}}findMatches(e,t,i){const r=this.tileID.canonical.z<t.canonical.z?1:Math.pow(2,this.tileID.canonical.z-t.canonical.z);for(let n=0;n<e.length;n++){const o=e.get(n);if(o.crossTileID)continue;const s=this.indexedSymbolInstances[o.key];if(!s)continue;const a=this.getScaledCoordinates(o,t);for(const e of s)if(Math.abs(e.coord.x-a.x)<=r&&Math.abs(e.coord.y-a.y)<=r&&!i[e.crossTileID]){i[e.crossTileID]=!0,o.crossTileID=e.crossTileID;break}}}}class Nt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class jt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){if(this.indexes[e.overscaledZ]&&this.indexes[e.overscaledZ][e.key]){if(this.indexes[e.overscaledZ][e.key].bucketInstanceId===t.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(e.overscaledZ,this.indexes[e.overscaledZ][e.key])}for(let e=0;e<t.symbolInstances.length;e++){t.symbolInstances.get(e).crossTileID=0}this.usedCrossTileIDs[e.overscaledZ]||(this.usedCrossTileIDs[e.overscaledZ]={});const r=this.usedCrossTileIDs[e.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>e.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e<t.symbolInstances.length;e++){const n=t.symbolInstances.get(e);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[e.overscaledZ]&&(this.indexes[e.overscaledZ]={}),this.indexes[e.overscaledZ][e.key]=new Vt(e,t.symbolInstances,t.bucketInstanceId),!0}removeBucketCrossTileIDs(e,t){for(const i in t.indexedSymbolInstances)for(const r of t.indexedSymbolInstances[i])delete this.usedCrossTileIDs[e][r.crossTileID]}removeStaleBuckets(e){let t=!1;for(const i in this.indexes){const r=this.indexes[i];for(const n in r)e[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],t=!0)}return t}}class Gt{constructor(){this.layerIndexes={},this.crossTileIDs=new Nt,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(e,t,i,r){let n=this.layerIndexes[e.id];void 0===n&&(n=this.layerIndexes[e.id]=new jt);let o=!1;const s={};"globe"!==r.name&&n.handleWrapJump(i);for(const i of t){const t=i.getBucket(e);t&&e.id===t.layerIds[0]&&(t.bucketInstanceId||(t.bucketInstanceId=++this.maxBucketInstanceId),n.addBucket(i.tileID,t,this.crossTileIDs)&&(o=!0),s[t.bucketInstanceId]=!0)}return n.removeStaleBuckets(s)&&(o=!0),o}pruneUnusedLayers(e){const t={};e.forEach(e=>{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Zt=(t,i)=>e.emitValidationErrors(t,i&&i.filter(e=>"source.canvas"!==e.identifier)),$t=e.pick(Ne,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),qt=e.pick(Ne,["setCenter","setZoom","setBearing","setPitch"]),Xt=function(){const t={},i=e.spec.$version;for(const r in e.spec.$root){const n=e.spec.$root[r];if(n.required){let e=null;null!=(e="version"===r?i:"array"===n.type?[]:{})&&(t[r]=e)}}return t}(),Wt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ht extends e.Evented{constructor(t,i={}){super(),this.map=t,this.dispatcher=new z(Oe(),this),this.imageManager=new f,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,i.localFontFamily?e.LocalGlyphMode.all:i.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.lineAtlas=new e.LineAtlas(256,512),this.crossTileSymbolIndex=new Gt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new e.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const r=this;this._rtlTextPluginCallback=Ht.registerForPluginStateChange(t=>{const i={pluginStatus:t.pluginStatus,pluginURL:t.pluginURL};r.dispatcher.broadcast("syncRTLPluginState",i,(t,i)=>{if(e.triggerPluginCompletionEvent(t),i){if(i.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||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 e in this._layers){const i=this._layers[e];i.source===t.id&&this._validateLayer(i)}})}loadURL(t,i={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,i.accessToken);const n=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(n,(t,i)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):i&&this._load(i,r)})}loadJSON(t,i={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Xt,!1)}_updateLayerCount(e,t){const i=t?1:-1;e.is3D()&&(this._num3DLayers+=i),"circle"===e.type&&(this._numCircleLayers+=i),"symbol"===e.type&&(this._numSymbolLayers+=i)}_load(t,i){if(i&&Zt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=t,this.updateProjection();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 r=Ve(this.stylesheet.layers);this._order=r.map(e=>e.id),this._layers={},this._serializedLayers={};for(let t of r)(t=e.createStyleLayer(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 g(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,y.elevated),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&&this.terrain.drapeRenderMode===y.deferred}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const e=this.map.transform.projection,t=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),i=this.map.transform.projection;if(this._loaded)if(i.requiresDraping){this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping()}else this.terrainSetForDrapingOnly()&&this.setTerrain(null);if(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),t){if(i.isReprojectedInTileSpace||e.isReprojectedInTileSpace){this.map.painter.clearBackgroundTiles();for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles()}else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(t){this._spriteRequest=function(t,i,r){let n,o,s;const a=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.ResourceType.SpriteJSON),(e,t)=>{l=null,s||(s=e,n=t,h())}),c=e.getImage(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.ResourceType.SpriteImage),(e,t)=>{c=null,s||(s=e,o=t,h())});function h(){if(s)r(s);else if(n&&o){const t=e.exported.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:d,content:p}=n[r],f=new e.RGBAImage({width:o,height:s});e.RGBAImage.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[r]={data:f,pixelRatio:h,sdf:c,stretchX:u,stretchY:d,content:p}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(i)for(const e in i)this.imageManager.addImage(e,i[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 i=this.getSource(t.source);if(!i)return;const r=t.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${r}" `+`does not exist on source "${i.id}" `+`as specified by style layer "${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 i of e){const e=this._layers[i];"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&&Wt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const i=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const r={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];r[e]=t.used,t.used=!1}for(const e of this._order){const i=this._layers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this._getLayerSourceCache(i);e&&(e.used=!0)}const r=this.map.painter;if(r){const e=i.getProgramIds();if(!e)continue;const n=i.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,n)}}for(const t in r){const i=this._sourceCaches[t];r[t]!==i.used&&i.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.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),i&&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(t){if(this._checkLoaded(),Zt(this,e.validateStyle(t)))return!1;(t=e.clone$1(t)).layers=Ve(t.layers);const i=He(this.serialize(),t).filter(e=>!(e.command in qt));if(0===i.length)return!1;const r=i.filter(e=>!(e.command in $t));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);return i.forEach(e=>{"setTransition"!==e.command&&this[e.command].apply(this,e.args)}),this.stylesheet=t,this.updateProjection(),!0}addImage(t,i){if(this.getImage(t))return this.fire(new e.ErrorEvent(new Error("An image with this name already exists.")));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){if(!this.getImage(t))return this.fire(new e.ErrorEvent(new Error("No image with this name exists.")));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_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,i,r={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(e.validateStyle.source,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=Ce(t,i,this.dispatcher,this);n.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:n.serialize(),sourceId:t}));const o=i=>{const r=(i?"symbol:":"other:")+t,o=this._sourceCaches[r]=new e.SourceCache(r,n,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const i=this.getSource(t);if(void 0===i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(t);for(const t of r)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this.getLayer(n))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(Zt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.clone$1(t),t=e.extend(t,{source:n})),this._validate(e.validateStyle.layer,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[n]&&o.source&&a&&"custom"!==o.type){const e=this._removedLayers[n];delete this._removedLayers[n],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const r=this._order.indexOf(t);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(n,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.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,i,r){this._checkLoaded();const n=this.getLayer(t);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(t,i,r={}){this._checkLoaded();const n=this.getLayer(t);if(n){if(!o(n.filter,i))return null==i?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(e.validateStyle.filter,`layers.${n.id}.filter`,i,{layerType:n.type},r)||(n.filter=e.clone$1(i),this._updateLayer(n)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){return e.clone$1(this.getLayer(t).filter)}setLayoutProperty(t,i,r,n={}){this._checkLoaded();const s=this.getLayer(t);s?o(s.getLayoutProperty(i),r)||(s.setLayoutProperty(i,r,n),this._updateLayer(s)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,i){const r=this.getLayer(t);if(r)return r.getLayoutProperty(i);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(t,i,r,n={}){this._checkLoaded();const s=this.getLayer(t);s?o(s.getPaintProperty(i),r)||(s.setPaintProperty(i,r,n)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[t]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(t,i){this._checkLoaded();const r=t.source,n=t.sourceLayer,o=this.getSource(r);if(void 0===o)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&n)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)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 a=this._getSourceCaches(r);for(const e of a)e.setFeatureState(n,t.id,i)}removeFeatureState(t,i){this._checkLoaded();const r=t.source,n=this.getSource(r);if(void 0===n)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"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 a=this._getSourceCaches(r);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){this._checkLoaded();const i=t.source,r=t.sourceLayer,n=this.getSource(i);if(void 0!==n){if("vector"!==n.type||r)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(r,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 '${i}' 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 i=this._sourceCaches[e].getSource();t[i.id]||(t[i.id]=i.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.stylesheet.terrain,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,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,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(t(o)){i[o]=n;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]<o)break;n.push(t),r.pop()}else for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t.feature)}}return n}queryRenderedFeatures(t,i,r){i&&i.filter&&this._validate(e.validateStyle.filter,"queryRenderedFeatures.filter",i.filter,null,i);const n={};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];n[i.source]=!0}}const o=[];i.availableImages=this._availableImages;const s=i&&i.layers?i.layers.some(e=>{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),a=xe.createFromScreenPoints(t,r);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;i.layers&&!n[t]||o.push(ke(this._sourceCaches[e],this._layers,this._serializedLayers,a,i,r,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(De);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,n.filter,n.layers,n.availableImages,e);for(const e in r){const t=a[e]=a[e]||[],n=r[e];n.sort((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of n)t.push(e)}}for(const t in a)a[t].forEach(r=>{const n=r.feature,o=e[t],s=i(o).getFeatureState(n.layer["source-layer"],n.id);n.source=n.layer.source,n.layer["source-layer"]&&(n.sourceLayer=n.layer["source-layer"]),n.state=s});return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,i){i&&i.filter&&this._validate(e.validateStyle.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this._getSourceCaches(t);let n=[];for(const e of r)n=n.concat(Pe(e,i));return n}addSourceType(e,t,i){return Ht.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Ht.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const r=this.light.getLight();let n=!1;for(const e in t)if(!o(t[e],r[e])){n=!0;break}if(!n)return;const s={now:e.exported.now(),transition:e.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,i),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===y.elevated?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},y.deferred)}setTerrain(t,i=y.elevated){if(this._checkLoaded(),!t)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(i===y.elevated){if("object"==typeof t.source){const i="terrain-dem-src";this.addSource(i,t.source),t=e.clone$1(t),t=e.extend(t,{source:i})}if(this._validate(e.validateStyle.terrain,"terrain",t))return}if(!this.terrain||this.terrain&&i!==this.terrain.drapeRenderMode)this._createTerrain(t,i);else{const i=this.terrain,r=i.get();for(const n in t)if(!o(t[n],r[n])){i.set(t),this.stylesheet.terrain=t;const r={now:e.exported.now(),transition:e.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const i=this.fog=new C(t,this.map.transform);this.stylesheet.fog=t;const r={now:e.exported.now(),transition:e.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r)}_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(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,r=i.get();for(const n in t)if(!o(t[n],r[n])){i.set(t),this.stylesheet.fog=t;const r={now:e.exported.now(),transition:e.extend({duration:0},this.stylesheet.transition)};i.updateTransitions(r);break}}else this._createFog(t);this._markersNeedUpdate=!0}_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(t,i){const r=this.terrain=new b(t,i);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const n={now:e.exported.now(),transition:e.extend({duration:0},this.stylesheet.transition)};r.updateTransitions(n)}_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,i,r,n,o={}){return(!o||!1!==o.validate)&&Zt(this,t.call(e.validateStyle,e.extend({key:i,style:this.serialize(),value:r,styleSpec:e.spec},n)))}_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 e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),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,i,r,n,o=!1){let s=!1,a=!1;const l={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!l[i.source]){const e=this._getLayerSourceCache(i);if(!e)continue;l[i.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 r=this.crossTileSymbolIndex.addLayer(i,l[i.source],t.center.lng,t.projection);s=s||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.Event("neworder")),o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom)){const e=this.fog&&t.projection.supportsFog?this.fog.state:null;this.pauseablePlacement=new Ot(t,this._order,o,i,r,n,this.placement,e),this._layerOrderChanged=!1}if(this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[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,i){this.imageManager.getImages(t.icons,i),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,r){return e.makeRequest(i,r)}_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}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)}}Ht.getSourceType=function(e){return Ae[e]},Ht.setSourceType=function(e,t){Ae[e]=t},Ht.registerForPluginStateChange=e.registerForPluginStateChange;var Kt="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}\n#endif",Jt="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}";let Yt={},Qt={};Yt=oi("","\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\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) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nfloat unpack_depth(vec4 rgba_depth)\n{const vec4 bit_shift=vec4(1.0/(256.0*256.0*256.0),1.0/(256.0*256.0),1.0/256.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\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;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",!0),Qt=oi("#ifdef FOG\nuniform float u_fog_temporal_offset;float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif","#ifdef FOG\nuniform mat4 u_fog_matrix;vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",!0);const ei=oi("\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;}\n#ifdef TERRAIN\nhighp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(256.0*256.0*256.0,256.0*256.0,256.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/256.0,1.0/256.0,1.0/256.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}\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;}vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(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) {\n#if defined(PROJECTION_GLOBE_VIEW) && !defined(PROJECTED_POS_ON_VIEWPORT)\nreturn mix(globe,mercator,t);\n#else\nreturn globe;\n#endif\n}\n#ifdef PROJECTION_GLOBE_VIEW\nmat3 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."),ti=Kt,ii="\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",ri="\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 ni={background:oi("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:oi("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:oi("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform 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;attribute float a_scale;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);\n#ifdef PROJECTION_GLOBE_VIEW\nvec2 scaled_extrude=extrude*a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=scaled_extrude.x*surface_vectors[0]+scaled_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);vec4 world_center=vec4(pos,1);\n#else \nmat3 surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);vec4 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\n#if defined(SCALE_WITH_MAP) && defined(PROJECTION_GLOBE_VIEW)\nview_scale*=a_scale;\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();\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);vec4 occlusion_world_center=vec4(circle_center,cantilevered_height,1);vec4 occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nvec4 occlusion_world_center=world_center;vec4 occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,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:oi("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:oi("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\ngl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;attribute float a_scale;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);\n#ifdef PROJECTION_GLOBE_VIEW\nextrude*=a_scale;vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\nvec3 pos=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:oi("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:oi("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:oi("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:oi("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:oi("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:oi("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:oi("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:oi("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:oi("varying vec4 v_color;void main() {vec4 color=v_color;\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\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#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 pos=vec3(pos_nx.xy,h);\n#else\nvec3 pos=vec3(pos_nx.xy,t > 0.0 ? height : base);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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*(pos.z+lift));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);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:oi("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\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_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;float ele=elevation(pos_nx.xy);float c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;float h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);vec3 p=vec3(pos_nx.xy,h);\n#else\nvec3 p=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_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_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:oi("#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);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=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+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:oi("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:oi("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\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_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nvec4 out_color=texture2D(u_gradient_image,v_uv);\n#else\nvec4 out_color=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\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#ifdef RENDER_LINE_GRADIENT\nattribute vec3 a_packed;\n#else\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;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;varying highp vec2 v_uv;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\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_from\n#pragma mapbox: initialize lowp vec4 dash_to\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#ifdef RENDER_LINE_GRADIENT\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];float a_linesofar=a_packed[2];highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.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:oi("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform 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_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_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:oi("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform 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:oi("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_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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_minFontScale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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_minFontScale,fontScale)+a_pxoffset/16.0);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));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_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:oi("#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_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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 PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;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:oi("#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_z_tile_anchor;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_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[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}float anchorZ=a_z_tile_anchor.x;vec2 tileAnchor=a_z_tile_anchor.yz;vec3 h=elevationVector(tileAnchor)*elevation(tileAnchor);vec3 mercator_pos=mercator_tile_position(u_inv_rot_matrix,tileAnchor,u_tile_id,u_merc_center);vec3 world_pos=mix_globe_mercator(vec3(a_pos,anchorZ)+h,mercator_pos,u_zoom_transition);vec4 projectedPoint=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),anchorZ,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec3 proj_pos=mix_globe_mercator(vec3(a_projected_pos.xy,anchorZ),mercator_pos,u_zoom_transition);\n#ifdef PROJECTED_POS_ON_VIEWPORT\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xy,0.0,1.0);\n#else\nvec4 projected_pos=u_label_plane_matrix*vec4(proj_pos.xyz+h,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);\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\nfloat occlusion_fade=occlusionFade(projectedPoint);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projectedPoint.w <=0.0 || occlusion_fade==0.0));float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));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:oi("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n}"),terrainDepth:oi("#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;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:oi("\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}",Jt),skyboxGradient:oi("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}",Jt),skyboxCapture:oi("\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:oi("uniform sampler2D u_image0;varying vec2 v_pos0;void main() {gl_FragColor=texture2D(u_image0,v_pos0);\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_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;attribute vec3 a_globe_pos;attribute vec2 a_merc_pos;attribute vec2 a_uv;varying vec2 v_pos0;const float wireframeOffset=1e3;void main() {v_pos0=a_uv;vec2 uv=a_uv*EXTENT;vec4 up_vector=vec4(elevationVector(uv),1.0);float height=elevation(uv);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nvec4 globe=u_globe_matrix*vec4(a_globe_pos+up_vector.xyz*height,1.0);vec4 mercator=vec4(0.0);if (u_zoom_transition > 0.0) {mercator=vec4(a_merc_pos,height,1.0);mercator.xy-=u_merc_center;mercator.x=wrap(mercator.x,-0.5,0.5);mercator=u_merc_matrix*mercator;}vec3 position=mix(globe.xyz,mercator.xyz,u_zoom_transition);gl_Position=u_proj_matrix*vec4(position,1.0);}"),globeAtmosphere:oi("uniform vec2 u_center;uniform float u_radius;uniform vec2 u_screen_size;uniform float u_opacity;uniform highp float u_fadeout_range;uniform vec3 u_start_color;uniform vec3 u_end_color;uniform float u_pixel_ratio;void main() {highp vec2 fragCoord=gl_FragCoord.xy/u_pixel_ratio;fragCoord.y=u_screen_size.y-fragCoord.y;float distFromCenter=length(fragCoord-u_center);float normDistFromCenter=length(fragCoord-u_center)/u_radius;if (normDistFromCenter < 1.0)\ndiscard;float t=clamp(1.0-sqrt(normDistFromCenter-1.0)/u_fadeout_range,0.0,1.0);vec3 color=mix(u_start_color,u_end_color,1.0-t);gl_FragColor=vec4(color*t*u_opacity,u_opacity);}","attribute vec3 a_pos;void main() {gl_Position=vec4(a_pos,1.0);}")};function oi(e,t,i){const r=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,o=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),s=e.match(n),a=t.match(n),l=Kt.match(n);let c=a?a.concat(s):s;i||(Yt.staticUniforms&&(c=Yt.staticUniforms.concat(c)),Qt.staticUniforms&&(c=Qt.staticUniforms.concat(c))),c&&(c=c.concat(l));const h={};return{fragmentSource:e=e.replace(r,(e,t,i,r,n)=>(h[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`)),vertexSource:t=t.replace(r,(e,t,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return h[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`}),staticAttributes:o,staticUniforms:c}}class si{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(l=!0);const c=!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==i||l||this.boundIndexBuffer!==n||this.boundVertexOffset!==o||this.boundDynamicVertexBuffer!==s||this.boundDynamicVertexBuffer2!==a;!e.extVertexArrayObject||c?this.freshBind(t,i,r,n,o,s,a):(e.bindVertexArrayOES.set(this.vao),s&&s.bind(),n&&n.dynamicDraw&&n.bind(),a&&a.bind())}freshBind(e,t,i,r,n,o,s){let a;const l=e.numAttributes,c=this.context,h=c.gl;if(c.extVertexArrayObject)this.vao&&this.destroy(),this.vao=c.extVertexArrayObject.createVertexArrayOES(),c.bindVertexArrayOES.set(this.vao),a=0,this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=o,this.boundDynamicVertexBuffer2=s;else{a=c.currentNumAttributes||0;for(let e=l;e<a;e++)h.disableVertexAttribArray(e)}t.enableAttributes(h,e);for(const t of i)t.enableAttributes(h,e);o&&o.enableAttributes(h,e),s&&s.enableAttributes(h,e),t.bind(),t.setVertexAttribPointers(h,e,n);for(const t of i)t.bind(),t.setVertexAttribPointers(h,e,n);o&&(o.bind(),o.setVertexAttribPointers(h,e,n)),r&&r.bind(),s&&(s.bind(),s.setVertexAttribPointers(h,e,n)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}const ai=(e,t,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:ci(e,t.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:n,u_highlight:o,u_accent:s}},li=(t,i)=>{const r=i.stride,n=e.create();return e.ortho(n,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(n,n,[0,-e.EXTENT,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:i.unpackVector}};function ci(t,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new e.MercatorCoordinate(0,n/r).toLngLat().lat,new e.MercatorCoordinate(0,(n+1)/r).toLngLat().lat]}function hi(t,i,r,n,o,s,a){const l=t.context,c=l.gl,h=r.fbo;if(!h)return;t.prepareDrawTile(i);const u=t.useProgram("hillshade");l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,h.colorAttachment.get());const d=ai(t,r,n,t.terrain?i.projMatrix:null);t.prepareDrawProgram(l,u,i.toUnwrapped());const{tileBoundsBuffer:p,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=t.getTileBoundsBuffers(r);u.draw(l,c.TRIANGLES,o,s,a,e.CullFaceMode.disabled,d,n.id,p,f,m)}function ui(t,i,r){if(!i.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1);const s=r.stride;i.demTexture=i.demTexture||t.getTileTexture(s);const a=r.getPixels();i.demTexture?i.demTexture.update(a,{premultiply:!1}):i.demTexture=new e.Texture(n,a,o.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function di(t,i,r,n,o,s){const a=t.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),ui(t,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const h=c.dim;a.activeTexture.set(l.TEXTURE0);let u=i.fbo;if(!u){const t=new e.Texture(a,{width:h,height:h,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),(u=i.fbo=a.createFramebuffer(h,h,!0)).colorAttachment.set(t.texture)}a.bindFramebuffer.set(u.framebuffer),a.viewport.set([0,0,h,h]);const{tileBoundsBuffer:d,tileBoundsIndexBuffer:p,tileBoundsSegments:f}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,o,s,e.CullFaceMode.disabled,li(i.tileID,c),r.id,d,p,f),i.needsHillshadePrepare=!1}const pi=(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image0:new e.Uniform1i(t,i.u_image0),u_skirt_height:new e.Uniform1f(t,i.u_skirt_height)}),fi=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),mi=(e,t,i,r,n)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_merc_matrix:i,u_zoom_transition:r,u_merc_center:n,u_image0:0}),_i=(e,t,i,r,n,o,s,a)=>({u_center:e,u_radius:t,u_screen_size:i,u_pixel_ratio:r,u_opacity:n,u_fadeout_range:o,u_start_color:s,u_end_color:a});function gi(e,t){return null!=e&&null!=t&&(!(!e.hasData()||!t.hasData())&&(null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key))}const yi=new class{constructor(){this.operations={}}newMorphing(e,t,i,r,n){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==i.tileID.key&&(t.queued=i)}else this.operations[e]={startTime:r,phase:0,duration:n,from:t,to:i,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 i=this.operations[t];for(i.phase=(e-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,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()}},xi=0,vi=1,bi=2,wi=250,Ti={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Ei(t,i,r,n,o){if("globe"===t.transform.projection.name)!function(t,i,r,n,o){const s=t.context,a=s.gl;let l,c;const h=t.options.showTerrainWireframe?bi:xi,u=(e,i)=>{if(c===e)return;const r=[];i&&r.push(Ti[h]),r.push(Ti[e]),r.push("PROJECTION_GLOBE_VIEW"),l=t.useProgram("globeRaster",null,r),c=e},d=t.colorModeForRenderPass(),p=new e.DepthMode(a.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);yi.update(o);const f=t.transform,m=e.calculateGlobeMatrix(f,f.worldSize),_=e.calculateGlobeMercatorMatrix(f),g=[e.mercatorXfromLng(f.center.lng),e.mercatorYfromLat(f.center.lat)],y=h?[!1,!0]:[!1],x=t.globeSharedBuffers;y.forEach(h=>{c=-1;const y=h?a.LINES:a.TRIANGLES;for(const c of n){const n=r.getTile(c),v=Math.pow(2,c.canonical.z),b=e.globeVertexBufferForTileMesh(t,n,c),w=e.StencilMode.disabled,T=i.prevTerrainTileForTile[c.key],E=i.terrainTileForTile[c.key];gi(T,E)&&yi.newMorphing(c.key,T,E,o,wi),s.activeTexture.set(a.TEXTURE0),n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const S=yi.getMorphValuesForProxy(c.key),I=S?vi:xi,M={};S&&e.extend$1(M,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.easeCubicInOut(S.phase)}});const A=e.globeMatrixForTile(c.canonical,m),C=mi(f.projMatrix,A,_,e.globeToMercatorTransition(f.zoom),g);if(u(I,h),i.setupElevationDraw(n,l,M),t.prepareDrawProgram(s,l,c.toUnwrapped()),x){const[i,r]=h?x.getWirefameBuffer(t.context):[x.gridIndexBuffer,x.gridSegments];l.draw(s,y,p,w,d,e.CullFaceMode.backCCW,C,"globe_raster",b,i,r)}if(!h&&x){const t=(t,i)=>{const[r,n]=x.getPoleBuffersForTile(c.canonical.z,i);if(n){const o=e.globePoleMatrixForTile(c.canonical,i,f),a=mi(f.projMatrix,o,o,0,g);t.draw(s,y,p,w,d,e.CullFaceMode.disabled,a,"globe_pole_raster",r,x.poleIndexBuffer,n)}};0===c.canonical.y&&t(l,!0),c.canonical.y===v-1&&t(l,!1)}}})}(t,i,r,n,o);else{const a=t.context,l=a.gl;let c,h;const u=t.options.showTerrainWireframe?bi:xi,d=(e,i)=>{if(h===e)return;const r=[Ti[e]];i&&r.push(Ti[u]),c=t.useProgram("terrainRaster",null,r),h=e},p=t.colorModeForRenderPass(),f=new e.DepthMode(l.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);yi.update(o);const m=t.transform,_=(s=m.zoom,6*Math.pow(1.5,22-s)*i.exaggeration());(u?[!1,!0]:[!1]).forEach(s=>{h=-1;const u=s?l.LINES:l.TRIANGLES,[g,y]=s?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const h of n){const n=r.getTile(h),x=e.StencilMode.disabled,v=i.prevTerrainTileForTile[h.key],b=i.terrainTileForTile[h.key];gi(v,b)&&yi.newMorphing(h.key,v,b,o,wi),a.activeTexture.set(l.TEXTURE0),n.texture.bind(l.LINEAR,l.CLAMP_TO_EDGE,l.LINEAR_MIPMAP_NEAREST);const w=yi.getMorphValuesForProxy(h.key),T=w?vi:xi;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=fi(h.projMatrix,Si(h.canonical,m.renderWorldCopies)?_/10:_);d(T,s),i.setupElevationDraw(n,c,E),t.prepareDrawProgram(a,c,h.toUnwrapped()),c.draw(a,u,f,x,p,e.CullFaceMode.backCCW,S,"terrain_raster",i.gridBuffer,g,y)}})}var s}function Si(e,t){const i=1<<e.z;return!t&&(0===e.x||e.x===i-1)||0===e.y||e.y===i-1}const Ii=e=>({u_matrix:e});function Mi(t,i,r,n,o){if(o>0){const s=e.exported.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),h=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(t.tileID.overscaledZ-h),d=u&&t.refreshedUponExpiration?1:e.clamp(u?a:1-l,0,1);return t.refreshedUponExpiration&&a>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}const Ai=128,Ci=5,zi=50;class ki extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},i=new z(Oe(),null),r=Ce("mock-dem",t,i,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Pi extends e.SourceCache{constructor(e){const t=Ce("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new z(Oe(),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,i,r){if(t.freezeTileCoverage)return;this.transform=t;const n=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((i,r)=>{if(i[r.key]="",!this._tiles[r.key]){const i=new e.Tile(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom);i.state="loaded",this._tiles[r.key]=i}return i},{});for(const e in this._tiles)e in n||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const i=Object.values(t);this.renderCachePool.push(...i),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Di extends e.OverscaledTileID{constructor(e,t,i){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=i}}class Li extends e.Elevation{constructor(t,i){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=function(t){const i=new e.StructArrayLayout4i8,r=new e.StructArrayLayout3ui6,n=t+2;i.reserve(n*n),r.reserve((n-1)*(n-1)*2);const o=e.EXTENT/(t-1),s=e.EXTENT+o/2,a=s+o;for(let t=-o;t<a;t+=o)for(let r=-o;r<a;r+=o){const n=r<0||r>s||t<0||t>s?24575:0,o=e.clamp(Math.round(r),0,e.EXTENT),a=e.clamp(Math.round(t),0,e.EXTENT);i.emplaceBack(o+n,a,o,a)}const l=(n-3)*(n-3)*2,c=(e,t)=>{const i=t*n+e;r.emplaceBack(i+1,i,i+n),r.emplaceBack(i+n,i+n+1,i+1)};for(let e=1;e<n-2;e++)for(let t=1;t<n-2;t++)c(t,e);return[0,n-2].forEach(e=>{for(let t=0;t<n-1;t++)c(t,e),c(e,t)}),[i,r,l]}(Ai+1),s=t.context;this.gridBuffer=s.createVertexBuffer(r,e.boundsAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.SegmentVector.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Pi(i.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,0,e.EXTENT,0,e.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new e.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new ki(i.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(t,i,r){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const n=t.terrain.properties,o=t.terrain.drapeRenderMode===y.deferred;this.sourceCache=o?this._mockSourceCache:t._getSourceCache(n.get("source")),this._exaggeration=n.get("exaggeration");const s=()=>{this.sourceCache.used&&e.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\n`+"This 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(i,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,s(),this._initializing=!0),s(),i.updateElevation(!r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/Ai*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 (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${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(),delete this._depthFBO,delete this._depthTexture)}_source(){return this.enabled?this.sourceCache:null}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const 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 i=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new e.pointGeometry(r.x,r.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const r=new e.pointGeometry(t.canonical.x+(1<<t.canonical.z)*t.wrap,t.canonical.y),o=new e.pointGeometry(i.canonical.x+(1<<i.canonical.z)*i.wrap,i.canonical.y),s=n.mult(1<<t.canonical.z);return s.x-=.5,s.y-=.5,s.distSqr(r)-s.distSqr(o)})}(n,this.painter),this._previousZoom=r.zoom;const o=this.proxyToSource||{};this.proxyToSource={},n.forEach(e=>{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map(e=>new Di(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(n),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const a={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const i=t.tileID.key;i in a||(this._visibleDemTiles.push(t),a[i]=i)}}_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 i in this.terrainTileForTile){const r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),ui(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=t.tileID.canonical,s=Math.pow(2,o.z-n.z),a=r||"";return i[`u_dem_tl${a}`]=[n.x*s%1,n.y*s%1],i[`u_dem_scale${a}`]=s,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,i=t.gl;if(!this._emptyDepthBufferTexture){const r={width:1,height:1,data:new Uint8Array([255,255,255,255])};this._emptyDepthBufferTexture=new e.Texture(t,r,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce((t,i)=>{if(!i.dem)return t;const r=i.dem.tree.minimums[0];return r>0&&e++,t+=r},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),n={width:1,height:1,data:new Uint8Array(e.DEMData.pack(r,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,n,i.RGBA,{premultiply:!1}),o}setupElevationDraw(t,i,r){const n=this.painter.context,o=n.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(a),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0,u_tile_tl_up:[0,0,1],u_tile_tr_up:[0,0,1],u_tile_br_up:[0,0,1],u_tile_bl_up:[0,0,1],u_tile_up_scale:1});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();const l=this.painter.transform,c=l.projection.createTileTransform(l,l.worldSize),h=t.tileID.canonical;s.u_tile_tl_up=c.upVector(h,0,0),s.u_tile_tr_up=c.upVector(h,e.EXTENT,0),s.u_tile_br_up=c.upVector(h,e.EXTENT,e.EXTENT),s.u_tile_bl_up=c.upVector(h,0,e.EXTENT),s.u_tile_up_scale=c.upVectorScale(h,l.center.lat,l.worldSize).metersToTile;let u=null,d=null,p=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,i=r.morphing.dstDemTile;p=r.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(d=e),this._prepareDemTileUniforms(t,i,s)&&(u=i))}if(d&&u)n.activeTexture.set(o.TEXTURE2),u.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),n.activeTexture.set(o.TEXTURE4),d.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=p;else{u=this.terrainTileForTile[t.tileID.key],n.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,u,s)?u.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)}if(n.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height]):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&u){const t=(1<<u.tileID.canonical.z)*e.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;s.u_meter_to_dem=t}r&&r.labelPlaneMatrixInv&&(s.u_label_plane_matrix_inv=r.labelPlaneMatrixInv),i.setTerrainUniformValues(n,s)}renderToBackBuffer(e){const t=this.painter,i=this.painter.context;0!==e.length&&(i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height]),this.renderingToTexture=!1,Ei(t,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,e.splice(0,e.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const i=this.painter,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=[],l=i.style.order;let c=0;for(const h of o){const o=n.getTileByID(h.proxyTileKey),u=n.proxyCachedFBO[h.key]?n.proxyCachedFBO[h.key][t]:void 0,d=void 0!==u?n.renderCache[u]:this.pool[c++],p=void 0!==u;if(o.texture=d.tex,p&&!d.dirty){a.push(o.tileID);continue}let f;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.Color.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._layers[l[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style._getLayerSourceCache(t),o=n?this.proxyToSource[h.key][n.id]:[h];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}this.renderedToTile?(d.dirty=!0,a.push(o.tileID)):p||--c,c===Ci&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let i,r=0,n=0,o=!1;for(let s=0;s<t;++s){const t=e._layers[e.order[s]];this._style.isLayerDraped(t)?(o&&++r,++n):o||(o=!0,i=t.id)}return 0===n?{efficiency:100}:{efficiency:100*(1-r/n),firstUndrapedLayer:i}}getMinElevationBelowMSL(){let e=0;return this._visibleDemTiles.filter(e=>e.dem).forEach(t=>{const i=t.dem.tree;e=Math.min(e,i.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,i){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter(e=>e.dem).map(r=>{const n=r.tileID,o=Math.pow(2,n.overscaledZ),{x:s,y:a}=n.canonical,l=s/o,c=(s+1)/o,h=a/o,u=(a+1)/o;return{minx:l,miny:h,maxx:c,maxy:u,t:r.dem.tree.raycastRoot(l,h,c,u,e,t,i),tile:r}});r.sort((e,t)=>{return(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE)});for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,i=t.gl,r=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const n=new e.Texture(t,{width:r[0],height:r[1],data:null},i.RGBA);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(n.texture),o.depthAttachment=new _e(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:n,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(Ci,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const e in this._style._sourceCaches)if(this._style._sourceCaches[e].hasTransition())return!0;return this._style.order.some(e=>{const t=this._style._layers[e],i=t.isHidden(this.painter.transform.zoom),r=t.getCrossfadeParameters(),n=!!r&&1!==r.t,o=t.hasTransition();return"custom"!==t.type&&!i&&(n||o)})}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof Ee){e=!0;break}if(e)for(let e=0;e<this._style.order.length;++e){const t=this._style._layers[this._style.order[e]],i=t.isHidden(this.painter.transform.zoom),r=this._style._getLayerSourceCache(t);if("raster"!==t.type||i||!r)continue;const n=t.paint.get("raster-fade-duration");for(const e of this.proxyCoords){const t=this.proxyToSource[e.key][r.id];if(t)for(const e of t){const t=Mi(r.getTile(e),r.findLoadedParent(e,0),r,this.painter.transform,n);(1!==t.opacity||0!==t.mix)&&this._clearRenderCacheForTile(r.id,e)}}}}_setupDrapedRenderBatches(){const e=this._style.order,t=e.length;if(0===t)return;const i=[];let r,n=0,o=this._style._layers[e[n]];for(;!this._style.isLayerDraped(o)&&o.isHidden(this.painter.transform.zoom)&&++n<t;)o=this._style._layers[e[n]];for(;n<t;++n){const t=this._style._layers[e[n]];t.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(t)?void 0===r&&(r=n):void 0!==r&&(i.push({start:r,end:n-1}),r=void 0))}void 0!==r&&i.push({start:r,end:n-1}),this._style.map._optimizeForTerrain,this._drapedRenderBatches=i}_setupRenderCache(e){const t=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,t.renderCache.length>t.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let i=0;i<e.length;++i){const r=Object.values(e[i]);t.renderCachePool.push(...r)}}return}this._clearRasterFadeFromRenderCache();const i=this.proxyCoords,r=this._tilesDirty;for(let n=i.length-1;n>=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort((e,t)=>{const i=e.end-e.start;return t.end-t.start-i});for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.key])continue;let i=t.renderCachePool.pop();void 0===i&&t.renderCache.length<zi&&(i=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==i&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(e.fb,i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.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,i){const r=this.painter,n=this.painter.context,o=n.gl;r._tileClippingMaskIDs={},n.setColorMode(e.ColorMode.disabled),n.setDepthMode(e.DepthMode.disabled);const s=r.useProgram("clippingMask");for(const a of t){const t=r._tileClippingMaskIDs[a.key]=--i;s.draw(n,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Ii(a.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){const i=this.painter.transform;if(t.x<0||t.x>i.width||t.y<0||t.y>i.height)return null;const r=[t.x,t.y,1,1];e.transformMat4$1(r,r,i.pixelMatrixInverse),e.scale$1(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=e.mercatorZfromAltitude(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.subtract([],r.slice(0,3),s);e.normalize(a,a);const l=this._exaggeration,c=this.raycast(s,a,l);return null!==c&&c?(e.scaleAndAdd(s,s,a,c),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const t=this.painter,i=t.context,r=this.proxySourceCache,n=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===n&&this._depthFBO.height===o||(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const t=i.gl,r=i.createFramebuffer(n,o,!0);i.activeTexture.set(t.TEXTURE0);const s=new e.Texture(i,{width:n,height:o,data:null},t.RGBA);s.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,n,o);r.depthAttachment.set(a),this._depthFBO=r,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,n,o]),function(t,i,r,n){if("globe"===t.transform.projection.name)return;const o=t.context,s=o.gl;o.clear({depth:1});const a=t.useProgram("terrainDepth"),l=new e.DepthMode(s.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of n){const n=r.getTile(t),c=fi(t.projMatrix,0);i.setupElevationDraw(n,a),a.draw(o,s.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,i){if(e.getSource()instanceof Me)return this._setupProxiedCoordsForImageSource(e,t,i);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],n=this.proxyCoords;for(let t=0;t<n.length;t++){const o=n[t],s=this._findTileCoveringTileID(o,e);if(s){const t=this._createProxiedId(o,s,i[o.key]&&i[o.key][e.id]);r.push(t),this.proxyToSource[o.key][e.id]=[t]}}let o=!1;for(let n=0;n<t.length;n++){const s=e.getTile(t[n]);if(!s||!s.hasData())continue;const a=this._findTileCoveringTileID(s.tileID,this.proxySourceCache);if(a&&a.tileID.canonical.z!==s.tileID.canonical.z){const t=this.proxyToSource[a.tileID.key][e.id],n=this._createProxiedId(a.tileID,s,i[a.tileID.key]&&i[a.tileID.key][e.id]);t?t.splice(t.length-1,0,n):this.proxyToSource[a.tileID.key][e.id]=[n],r.push(n),o=!0}}this._sourceTilesOverlap[e.id]=o}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=new e.pointGeometry(s.tileID.x,s.tileID.y)._div(1<<s.tileID.z),l=s.coordinates.map(e.MercatorCoordinate.fromLngLat).reduce((e,t)=>(e.min.x=Math.min(e.min.x,t.x-a.x),e.min.y=Math.min(e.min.y,t.y-a.y),e.max.x=Math.max(e.max.x,t.x-a.x),e.max.y=Math.max(e.max.y,t.y-a.y),e),{min:new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(t,i)=>{const r=t.wrap+t.canonical.x/(1<<t.canonical.z),n=t.canonical.y/(1<<t.canonical.z),o=e.EXTENT/(1<<t.canonical.z),s=i.wrap+i.canonical.x/(1<<i.canonical.z),a=i.canonical.y/(1<<i.canonical.z);return r+o<s+l.min.x||r>s+l.max.x||n+o<a+l.min.y||n>a+l.max.y};for(let e=0;e<o.length;e++){const s=o[e];for(let e=0;e<i.length;e++){const o=t.getTile(i[e]);if(!o||!o.hasData())continue;if(c(s,o.tileID))continue;const a=this._createProxiedId(s,o,r[s.key]&&r[s.key][t.id]),l=this.proxyToSource[s.key][t.id];l?l.push(a):this.proxyToSource[s.key][t.id]=[a],n.push(a)}}}_createProxiedId(t,i,r){let n=this.orthoMatrix;if(r){const e=r.find(e=>e.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const r=t.canonical.z-i.tileID.canonical.z;let o,s,a;n=e.create();const l=i.tileID.wrap-t.wrap<<t.overscaledZ;r>0?(s=(o=e.EXTENT>>r)*((i.tileID.canonical.x<<r)-t.canonical.x+l),a=o*((i.tileID.canonical.y<<r)-t.canonical.y)):(o=e.EXTENT<<-r,s=e.EXTENT*(i.tileID.canonical.x-(t.canonical.x+l<<-r)),a=e.EXTENT*(i.tileID.canonical.y-(t.canonical.y<<-r))),e.ortho(n,0,o,0,o,0,1),e.translate(n,n,[s,a,0])}return new Di(i.tileID,t.key,n)}_findTileCoveringTileID(t,i){let r=i.getTile(t);if(r&&r.hasData())return r;const n=this._findCoveringTileCache[i.id],o=n[t.key];if((r=o?i.getTileByID(o):null)&&r.hasData()||null===o)return r;let s=r?r.tileID:t,a=s.overscaledZ;const l=i.getSource().minzoom,c=[];if(!o){const n=i.getSource().maxzoom;if(t.canonical.z>=n){const r=t.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.OverscaledTileID(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(a=n,s=new e.OverscaledTileID(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r))}s.key!==t.key&&(c.push(s.key),r=i.getTile(s))}const h=e=>{c.forEach(t=>{n[t]=e}),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&h(r.tileID.key);const e=s.calculateScaledKey(a);if((r=i.getTileByID(e))&&r.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):r=i.getTileByID(t)}return h(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(e){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let i=this._tilesDirty[e];i||(i=this._tilesDirty[e]={}),i[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let i,r,n;const o=new e.StructArrayLayout2ui4,s=t+2;for(r=1;r<t;r++){for(i=1;i<t;i++)n=r*s+i,o.emplaceBack(n,n+1),o.emplaceBack(n,n+s),o.emplaceBack(n+1,n+s),r===t-1&&o.emplaceBack(n+s,n+s+1);o.emplaceBack(n+1,n+1+s)}return o}(Ai+1);this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}const Bi=(t,i)=>({u_dem:new e.Uniform1i(t,i.u_dem),u_dem_prev:new e.Uniform1i(t,i.u_dem_prev),u_dem_unpack:new e.Uniform4f(t,i.u_dem_unpack),u_dem_tl:new e.Uniform2f(t,i.u_dem_tl),u_dem_scale:new e.Uniform1f(t,i.u_dem_scale),u_dem_tl_prev:new e.Uniform2f(t,i.u_dem_tl_prev),u_dem_scale_prev:new e.Uniform1f(t,i.u_dem_scale_prev),u_dem_size:new e.Uniform1f(t,i.u_dem_size),u_dem_lerp:new e.Uniform1f(t,i.u_dem_lerp),u_exaggeration:new e.Uniform1f(t,i.u_exaggeration),u_depth:new e.Uniform1i(t,i.u_depth),u_depth_size_inv:new e.Uniform2f(t,i.u_depth_size_inv),u_meter_to_dem:new e.Uniform1f(t,i.u_meter_to_dem),u_label_plane_matrix_inv:new e.UniformMatrix4f(t,i.u_label_plane_matrix_inv),u_tile_tl_up:new e.Uniform3f(t,i.u_tile_tl_up),u_tile_tr_up:new e.Uniform3f(t,i.u_tile_tr_up),u_tile_br_up:new e.Uniform3f(t,i.u_tile_br_up),u_tile_bl_up:new e.Uniform3f(t,i.u_tile_bl_up),u_tile_up_scale:new e.Uniform1f(t,i.u_tile_up_scale)});const Ri=(t,i)=>({u_fog_matrix:new e.UniformMatrix4f(t,i.u_fog_matrix),u_fog_range:new e.Uniform2f(t,i.u_fog_range),u_fog_color:new e.Uniform4f(t,i.u_fog_color),u_fog_horizon_blend:new e.Uniform1f(t,i.u_fog_horizon_blend),u_fog_temporal_offset:new e.Uniform1f(t,i.u_fog_temporal_offset)}),Fi=(e,t,i,r)=>{const n=t.properties.get("color"),o=e.frameCounter/1e3%1,s=[n.r/n.a,n.g/n.a,n.b/n.a,r];return{u_fog_matrix:i?e.transform.calculateFogTileMatrix(i):e.identityMat,u_fog_range:t.getFovAdjustedRange(e.transform._fov),u_fog_color:s,u_fog_horizon_blend:t.properties.get("horizon-blend"),u_fog_temporal_offset:o}};function Oi(e){const t=[];for(let i=0;i<e.length;i++){if(null===e[i])continue;const r=e[i].split(" ");t.push(r.pop())}return t}class Ui{static cacheKey(e,t,i){let r=`${e}${i?i.cacheKey:""}`;for(const e of t)r+=`/${e}`;return r}constructor(e,t,i,r,n,o){const s=e.gl;this.program=s.createProgram();const a=Oi(i.staticAttributes),l=r?r.getBinderAttributes():[],c=a.concat(l),h=i.staticUniforms?Oi(i.staticUniforms):[],u=r?r.getBinderUniforms():[],d=h.concat(u),p=[];for(const e of d)p.indexOf(e)<0&&p.push(e);let f=r?r.defines():[];const m=(f=f.concat(o.map(e=>`#define ${e}`))).concat(ri,ti,ei.fragmentSource,Qt.fragmentSource,i.fragmentSource).join("\n"),_=f.concat(ii,ti,ei.vertexSource,Qt.vertexSource,Yt.vertexSource,i.vertexSource).join("\n"),g=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(g,m),s.compileShader(g),s.attachShader(this.program,g);const y=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(y,_),s.compileShader(y),s.attachShader(this.program,y),this.attributes={};const x={};this.numAttributes=c.length;for(let e=0;e<this.numAttributes;e++)c[e]&&(s.bindAttribLocation(this.program,e,c[e]),this.attributes[c[e]]=e);s.linkProgram(this.program),s.deleteShader(y),s.deleteShader(g);for(let e=0;e<p.length;e++){const t=p[e];if(t&&!x[t]){const e=s.getUniformLocation(this.program,t);e&&(x[t]=e)}}this.fixedUniforms=n(e,x),this.binderUniforms=r?r.getUniforms(e,x):[],-1!==o.indexOf("TERRAIN")&&(this.terrainUniforms=Bi(e,x)),-1!==o.indexOf("FOG")&&(this.fogUniforms=Ri(e,x))}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].location&&i[e].set(t[e])}}draw(e,t,i,r,n,o,s,a,l,c,h,u,d,p,f,m){const _=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(s[e]);p&&p.setUniforms(e,this.binderUniforms,u,{zoom:d});const g={[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];for(const i of h.get()){const r=i.vaos||(i.vaos={});(r[a]||(r[a]=new si)).bind(e,this,l,p?p.getPaintVertexBuffers():[],c,i.vertexOffset,f,m),_.drawElements(t,i.primitiveLength*g,_.UNSIGNED_SHORT,i.primitiveOffset*g*2)}}}function Vi(e,t,i){const r=1/k(i,1,t.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/n,s=o*(i.tileID.canonical.x+i.tileID.wrap*n),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a]}}const Ni=(t,i,r,n)=>{const o=i.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=e.create$1();"viewport"===o.properties.get("anchor")&&(e.fromRotation(l,-i.transform.angle),e.transformMat3(a,a,l));const c=o.properties.get("color");return{u_matrix:t,u_lightpos:a,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+r,u_opacity:n}},ji=(t,i,r,n,o,s,a)=>e.extend(Ni(t,i,r,n),Vi(s,i,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Gi=e=>({u_matrix:e}),Zi=(t,i,r,n)=>e.extend(Gi(t),Vi(r,i,n)),$i=(e,t)=>({u_matrix:e,u_world:t}),qi=(t,i,r,n,o)=>e.extend(Zi(t,i,r,n),{u_world:o}),Xi=(t,i,r,n)=>{const o=t.transform;let s;return s="map"===n.paint.get("circle-pitch-alignment")?o.calculatePixelsToTileUnitsMatrix(r):new Float32Array([o.pixelsToGLUnits[0],0,0,o.pixelsToGLUnits[1]]),{u_camera_to_center_distance:o.cameraToCenterDistance,u_matrix:t.translatePosMatrix(i.projMatrix,r,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:s}},Wi=e=>{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},Hi=(t,i,r)=>{const n=e.EXTENT/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:i.cameraToCenterDistance,u_extrude_scale:[i.pixelsToGLUnits[0]/n,i.pixelsToGLUnits[1]/n]}},Ki=(e,t,i)=>({u_matrix:e,u_inv_matrix:t,u_camera_to_center_distance:i.cameraToCenterDistance,u_viewport_size:[i.width,i.height]}),Ji=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),Yi=(e,t,i,r)=>({u_matrix:e,u_extrude_scale:k(t,1,i),u_intensity:r}),Qi=(e,t,i,r)=>({u_image:i,u_color_ramp:r,u_opacity:t.paint.get("heatmap-opacity")}),er=(t,i,r,n,o,s)=>{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(i),c={u_matrix:rr(t,i,r,o),u_pixels_to_tile_units:l,u_device_pixel_ratio:e.exported.devicePixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:s,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(or(r)){const e=ir(i,t.transform);c.u_texsize=i.lineAtlasTexture.size,c.u_scale=[e,n.fromScale,n.toScale],c.u_mix=n.t}return c},tr=(t,i,r,n,o)=>{const s=t.transform,a=ir(i,s);return{u_matrix:rr(t,i,r,o),u_texsize:i.imageAtlasTexture.size,u_pixels_to_tile_units:s.calculatePixelsToTileUnitsMatrix(i),u_device_pixel_ratio:e.exported.devicePixelRatio,u_image:0,u_scale:[a,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function ir(e,t){return 1/k(e,1,t.tileZoom)}function rr(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const nr=e=>{const t=[];or(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-pattern").constantOr(1),r=1!==e.paint.get("line-opacity").constantOr(1);return!i&&r&&t.push("RENDER_LINE_ALPHA_DISCARD"),t};function or(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const sr=(e,t,i,r,n,o)=>({u_matrix:e,u_tl_parent:t,u_scale_parent:i,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:cr(n.paint.get("raster-saturation")),u_contrast_factor:lr(n.paint.get("raster-contrast")),u_spin_weights:ar(n.paint.get("raster-hue-rotate")),u_perspective_transform:o});function ar(e){e*=Math.PI/180;const t=Math.sin(e),i=Math.cos(e);return[(2*i+1)/3,(-Math.sqrt(3)*t-i+1)/3,(Math.sqrt(3)*t-i+1)/3]}function lr(e){return e>0?1/(1-e):1+e}function cr(e){return e>0?1-1/(1.001-e):-e}const hr=(e,t,i,r,n,o,s,a,l,c,h,u,d,p)=>{const f=n.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:f.cameraToCenterDistance,u_pitch:f.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:f.width/f.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:o,u_label_plane_matrix:s,u_coord_matrix:a,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_tile_id:h,u_zoom_transition:u,u_inv_rot_matrix:d,u_merc_center:p,u_texture:0}},ur=(t,i,r,n,o,s,a,l,c,h,u,d,p,f,m)=>{const{cameraToCenterDistance:_,_pitch:g}=o.transform;return e.extend(hr(t,i,r,n,o,s,a,l,c,h,d,p,f,m),{u_gamma_scale:n?_*Math.cos(o.terrain?0:g):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+u})},dr=(t,i,r,n,o,s,a,l,c,h,u,d,p,f)=>e.extend(ur(t,i,r,n,o,s,a,l,!0,c,!0,u,d,p,f),{u_texsize_icon:h,u_texture_icon:1}),pr=(e,t,i)=>({u_matrix:e,u_opacity:t,u_color:i}),fr=(t,i,r,n,o,s)=>e.extend(function(e,t,i,r){const n=i.imageManager.getPattern(e.from.toString()),o=i.imageManager.getPattern(e.to.toString()),{width:s,height:a}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,a],u_mix:t.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/k(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(n,s,r,o),{u_matrix:t,u_opacity:i}),mr=(e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:i,u_opacity:r,u_temporal_offset:n}),_r=(t,i,r,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.degToRad(r),u_opacity:n,u_temporal_offset:o}),gr=(e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}),yr={fillExtrusion:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_lightpos:new e.Uniform3f(t,i.u_lightpos),u_lightintensity:new e.Uniform1f(t,i.u_lightintensity),u_lightcolor:new e.Uniform3f(t,i.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,i.u_vertical_gradient),u_opacity:new e.Uniform1f(t,i.u_opacity)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_lightpos:new e.Uniform3f(t,i.u_lightpos),u_lightintensity:new e.Uniform1f(t,i.u_lightintensity),u_lightcolor:new e.Uniform3f(t,i.u_lightcolor),u_vertical_gradient:new e.Uniform1f(t,i.u_vertical_gradient),u_height_factor:new e.Uniform1f(t,i.u_height_factor),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade),u_opacity:new e.Uniform1f(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_world:new e.Uniform2f(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_world:new e.Uniform2f(t,i.u_world),u_image:new e.Uniform1i(t,i.u_image),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_extrude_scale:new e.UniformMatrix2f(t,i.u_extrude_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),collisionBox:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_extrude_scale:new e.Uniform2f(t,i.u_extrude_scale)}),collisionCircle:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_inv_matrix:new e.UniformMatrix4f(t,i.u_inv_matrix),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_viewport_size:new e.Uniform2f(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.UniformColor(t,i.u_color),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_overlay:new e.Uniform1i(t,i.u_overlay),u_overlay_scale:new e.Uniform1f(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.Uniform1f(t,i.u_extrude_scale),u_intensity:new e.Uniform1f(t,i.u_intensity),u_matrix:new e.UniformMatrix4f(t,i.u_matrix)}),heatmapTexture:(t,i)=>({u_image:new e.Uniform1i(t,i.u_image),u_color_ramp:new e.Uniform1i(t,i.u_color_ramp),u_opacity:new e.Uniform1f(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_latrange:new e.Uniform2f(t,i.u_latrange),u_light:new e.Uniform2f(t,i.u_light),u_shadow:new e.UniformColor(t,i.u_shadow),u_highlight:new e.UniformColor(t,i.u_highlight),u_accent:new e.UniformColor(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_image:new e.Uniform1i(t,i.u_image),u_dimension:new e.Uniform2f(t,i.u_dimension),u_zoom:new e.Uniform1f(t,i.u_zoom),u_unpack:new e.Uniform4f(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_pixels_to_tile_units:new e.UniformMatrix2f(t,i.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.Uniform2f(t,i.u_units_to_pixels),u_dash_image:new e.Uniform1i(t,i.u_dash_image),u_gradient_image:new e.Uniform1i(t,i.u_gradient_image),u_image_height:new e.Uniform1f(t,i.u_image_height),u_texsize:new e.Uniform2f(t,i.u_texsize),u_scale:new e.Uniform3f(t,i.u_scale),u_mix:new e.Uniform1f(t,i.u_mix),u_alpha_discard_threshold:new e.Uniform1f(t,i.u_alpha_discard_threshold)}),linePattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_texsize:new e.Uniform2f(t,i.u_texsize),u_pixels_to_tile_units:new e.UniformMatrix2f(t,i.u_pixels_to_tile_units),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_image:new e.Uniform1i(t,i.u_image),u_units_to_pixels:new e.Uniform2f(t,i.u_units_to_pixels),u_scale:new e.Uniform3f(t,i.u_scale),u_fade:new e.Uniform1f(t,i.u_fade),u_alpha_discard_threshold:new e.Uniform1f(t,i.u_alpha_discard_threshold)}),raster:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_tl_parent:new e.Uniform2f(t,i.u_tl_parent),u_scale_parent:new e.Uniform1f(t,i.u_scale_parent),u_fade_t:new e.Uniform1f(t,i.u_fade_t),u_opacity:new e.Uniform1f(t,i.u_opacity),u_image0:new e.Uniform1i(t,i.u_image0),u_image1:new e.Uniform1i(t,i.u_image1),u_brightness_low:new e.Uniform1f(t,i.u_brightness_low),u_brightness_high:new e.Uniform1f(t,i.u_brightness_high),u_saturation_factor:new e.Uniform1f(t,i.u_saturation_factor),u_contrast_factor:new e.Uniform1f(t,i.u_contrast_factor),u_spin_weights:new e.Uniform3f(t,i.u_spin_weights),u_perspective_transform:new e.Uniform2f(t,i.u_perspective_transform)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_pitch:new e.Uniform1f(t,i.u_pitch),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_texture:new e.Uniform1i(t,i.u_texture)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_pitch:new e.Uniform1f(t,i.u_pitch),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_texture:new e.Uniform1i(t,i.u_texture),u_gamma_scale:new e.Uniform1f(t,i.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_tile_id:new e.Uniform3f(t,i.u_tile_id),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_inv_rot_matrix:new e.UniformMatrix4f(t,i.u_inv_rot_matrix),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_is_halo:new e.Uniform1i(t,i.u_is_halo)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.Uniform1i(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.Uniform1i(t,i.u_is_size_feature_constant),u_size_t:new e.Uniform1f(t,i.u_size_t),u_size:new e.Uniform1f(t,i.u_size),u_camera_to_center_distance:new e.Uniform1f(t,i.u_camera_to_center_distance),u_pitch:new e.Uniform1f(t,i.u_pitch),u_rotate_symbol:new e.Uniform1i(t,i.u_rotate_symbol),u_aspect_ratio:new e.Uniform1f(t,i.u_aspect_ratio),u_fade_change:new e.Uniform1f(t,i.u_fade_change),u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_label_plane_matrix:new e.UniformMatrix4f(t,i.u_label_plane_matrix),u_coord_matrix:new e.UniformMatrix4f(t,i.u_coord_matrix),u_is_text:new e.Uniform1i(t,i.u_is_text),u_pitch_with_map:new e.Uniform1i(t,i.u_pitch_with_map),u_texsize:new e.Uniform2f(t,i.u_texsize),u_texsize_icon:new e.Uniform2f(t,i.u_texsize_icon),u_texture:new e.Uniform1i(t,i.u_texture),u_texture_icon:new e.Uniform1i(t,i.u_texture_icon),u_gamma_scale:new e.Uniform1f(t,i.u_gamma_scale),u_device_pixel_ratio:new e.Uniform1f(t,i.u_device_pixel_ratio),u_is_halo:new e.Uniform1i(t,i.u_is_halo)}),background:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_opacity:new e.Uniform1f(t,i.u_opacity),u_color:new e.UniformColor(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_opacity:new e.Uniform1f(t,i.u_opacity),u_image:new e.Uniform1i(t,i.u_image),u_pattern_tl_a:new e.Uniform2f(t,i.u_pattern_tl_a),u_pattern_br_a:new e.Uniform2f(t,i.u_pattern_br_a),u_pattern_tl_b:new e.Uniform2f(t,i.u_pattern_tl_b),u_pattern_br_b:new e.Uniform2f(t,i.u_pattern_br_b),u_texsize:new e.Uniform2f(t,i.u_texsize),u_mix:new e.Uniform1f(t,i.u_mix),u_pattern_size_a:new e.Uniform2f(t,i.u_pattern_size_a),u_pattern_size_b:new e.Uniform2f(t,i.u_pattern_size_b),u_scale_a:new e.Uniform1f(t,i.u_scale_a),u_scale_b:new e.Uniform1f(t,i.u_scale_b),u_pixel_coord_upper:new e.Uniform2f(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.Uniform2f(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.Uniform1f(t,i.u_tile_units_to_pixels)}),terrainRaster:pi,terrainDepth:pi,skybox:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_sun_direction:new e.Uniform3f(t,i.u_sun_direction),u_cubemap:new e.Uniform1i(t,i.u_cubemap),u_opacity:new e.Uniform1f(t,i.u_opacity),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset)}),skyboxGradient:(t,i)=>({u_matrix:new e.UniformMatrix4f(t,i.u_matrix),u_color_ramp:new e.Uniform1i(t,i.u_color_ramp),u_center_direction:new e.Uniform3f(t,i.u_center_direction),u_radius:new e.Uniform1f(t,i.u_radius),u_opacity:new e.Uniform1f(t,i.u_opacity),u_temporal_offset:new e.Uniform1f(t,i.u_temporal_offset)}),skyboxCapture:(t,i)=>({u_matrix_3f:new e.UniformMatrix3f(t,i.u_matrix_3f),u_sun_direction:new e.Uniform3f(t,i.u_sun_direction),u_sun_intensity:new e.Uniform1f(t,i.u_sun_intensity),u_color_tint_r:new e.Uniform4f(t,i.u_color_tint_r),u_color_tint_m:new e.Uniform4f(t,i.u_color_tint_m),u_luminance:new e.Uniform1f(t,i.u_luminance)}),globeRaster:(t,i)=>({u_proj_matrix:new e.UniformMatrix4f(t,i.u_proj_matrix),u_globe_matrix:new e.UniformMatrix4f(t,i.u_globe_matrix),u_merc_matrix:new e.UniformMatrix4f(t,i.u_merc_matrix),u_zoom_transition:new e.Uniform1f(t,i.u_zoom_transition),u_merc_center:new e.Uniform2f(t,i.u_merc_center),u_image0:new e.Uniform1i(t,i.u_image0)}),globeAtmosphere:(t,i)=>({u_center:new e.Uniform2f(t,i.u_center),u_radius:new e.Uniform1f(t,i.u_radius),u_screen_size:new e.Uniform2f(t,i.u_screen_size),u_pixel_ratio:new e.Uniform1f(t,i.u_pixel_ratio),u_opacity:new e.Uniform1f(t,i.u_opacity),u_fadeout_range:new e.Uniform1f(t,i.u_fadeout_range),u_start_color:new e.Uniform3f(t,i.u_start_color),u_end_color:new e.Uniform3f(t,i.u_end_color)})};let xr;function vr(t,i,r,n,o,s,a){const l=t.context,c=l.gl,h=t.useProgram("collisionBox"),u=[];let d=0,p=0;for(let f=0;f<n.length;f++){const m=n[f],_=i.getTile(m),g=_.getBucket(r);if(!g)continue;let y=m.projMatrix;0===o[0]&&0===o[1]||(y=t.translatePosMatrix(m.projMatrix,_,o,s));const x=a?g.textCollisionBox:g.iconCollisionBox,v=g.collisionCircleArray;if(v.length>0){const i=e.create(),r=y;e.mul(i,g.placementInvProjMatrix,t.transform.glCoordMatrix),e.mul(i,i,g.placementViewportMatrix),u.push({circleArray:v,circleOffset:p,transform:r,invTransform:i}),p=d+=v.length/4}x&&(t.terrain&&t.terrain.setupElevationDraw(_,h),h.draw(l,c.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,Hi(y,t.transform,_),r.id,x.layoutVertexBuffer,x.indexBuffer,x.segments,null,t.transform.zoom,null,x.collisionVertexBuffer,x.collisionVertexBufferExt))}if(!a||!u.length)return;const f=t.useProgram("collisionCircle"),m=new e.StructArrayLayout2f1f2i16;m.resize(4*d),m._trim();let _=0;for(const e of u)for(let t=0;t<e.circleArray.length/4;t++){const i=4*t,r=e.circleArray[i+0],n=e.circleArray[i+1],o=e.circleArray[i+2],s=e.circleArray[i+3];m.emplace(_++,r,n,o,s,0),m.emplace(_++,r,n,o,s,1),m.emplace(_++,r,n,o,s,2),m.emplace(_++,r,n,o,s,3)}(!xr||xr.length<2*d)&&(xr=function(t){const i=2*t,r=new e.StructArrayLayout3ui6;r.resize(i),r._trim();for(let e=0;e<i;e++){const t=6*e;r.uint16[t+0]=4*e+0,r.uint16[t+1]=4*e+1,r.uint16[t+2]=4*e+2,r.uint16[t+3]=4*e+2,r.uint16[t+4]=4*e+3,r.uint16[t+5]=4*e+0}return r}(d));const g=l.createIndexBuffer(xr,!0),y=l.createVertexBuffer(m,e.collisionCircleLayout.members,!0);for(const i of u){const n=Ki(i.transform,i.invTransform,t.transform);f.draw(l,c.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,n,r.id,y,g,e.SegmentVector.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}y.destroy(),g.destroy()}const br=e.identity(new Float32Array(16));function wr(t,i,r,n,o,s){const{horizontalAlign:a,verticalAlign:l}=e.getAnchorAlignment(t),c=-(a-.5)*i,h=-(l-.5)*r,u=e.evaluateVariableOffset(t,n);return new e.pointGeometry((c/o+u[0])*s,(h/o+u[1])*s)}function Tr(t,i,r,n,o,s,a,l,c,h,u,d){const p=t.text.placedSymbolArray,f=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,_={},g=l.projMatrix,y=s.elevation,x=d.upVectorScale(l.canonical,s.center.lat,s.worldSize);f.clear();for(let m=0;m<p.length;m++){const v=p.get(m),b=t.allowVerticalPlacement&&!v.placedOrientation,w=v.hidden||!v.crossTileID||b?null:n[v.crossTileID];if(w){const n=new e.pointGeometry(v.tileAnchorX,v.tileAnchorY),p=d.upVector(l.canonical,n.x,n.y),m=y?y.getAtTileOffset(l,n.x,n.y):0,b=rt([v.projectedAnchorX+m*p[0]*x.metersToTile,v.projectedAnchorY+m*p[1]*x.metersToTile,v.projectedAnchorZ+m*p[2]*x.metersToTile],r?g:a),T=nt(s.cameraToCenterDistance,b.signedDistanceFromCamera);let E=o.evaluateSizeForFeature(t.textSizeData,h,v)*T/e.ONE_EM;r&&(E*=t.tilePixelRatio/c);const{width:S,height:I,anchor:M,textOffset:A,textScale:C}=w,z=wr(M,S,I,A,C,E),k=r?it(n.add(z),a,m*x.metersToLabelSpace).point:b.point.add(i?z.rotate(-s.angle):z),P=t.allowVerticalPlacement&&v.placedOrientation===e.WritingMode.vertical?Math.PI/2:0;for(let t=0;t<v.numGlyphs;t++)e.addDynamicAttributes(f,k,P);u&&v.associatedIconIndex>=0&&(_[v.associatedIconIndex]={shiftedAnchor:k,angle:P})}else ft(v.numGlyphs,f)}if(u){m.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const r=i.get(t);if(r.hidden)ft(r.numGlyphs,m);else{const i=_[t];if(i)for(let t=0;t<r.numGlyphs;t++)e.addDynamicAttributes(m,i.shiftedAnchor,i.angle);else ft(r.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(f)}function Er(e,t,i){return i.iconsInText&&t?"symbolTextAndIcon":e?"symbolSDF":"symbolIcon"}function Sr(t,i,r,n,o,s,a,l,c,h,u,d){const p=t.context,f=p.gl,m=t.transform,_=m.projection.createTileTransform(m,m.worldSize),g="map"===l,y="map"===c,x=g&&"point"!==r.layout.get("symbol-placement"),v=g&&!y&&!x,b=void 0!==r.layout.get("symbol-sort-key").constantOr(1);let w=!1;const T=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),E=[e.mercatorXfromLng(m.center.lng),e.mercatorYfromLat(m.center.lat)],S=r.layout.get("text-variable-anchor"),I="globe"===m.projection.name,M=I?e.globeToMercatorTransition(m.zoom):0,A=[],C=[];t.terrain&&y&&C.push("PITCH_WITH_MAP_TERRAIN"),I&&C.push("PROJECTION_GLOBE_VIEW");for(const l of n){const n=i.getTile(l),c=n.getBucket(r);if(!c||c.projection!==m.projection.name)continue;const u=o?c.text:c.icon;if(!u||c.fullyClipped||!u.segments.get().length)continue;const d=u.programConfigurations.get(r.id),p=o||c.sdfIcons,T=o?c.textSizeData:c.iconSizeData,I=y||0!==m.pitch,z=e.evaluateSizeForZoom(T,m.zoom),k=[l.canonical.x,l.canonical.y,1<<l.canonical.z];let P,D,L,B,R=[0,0],F=null;if(o){if(D=n.glyphAtlasTexture,L=f.LINEAR,P=n.glyphAtlasTexture.size,c.iconsInText){R=n.imageAtlasTexture.size,F=n.imageAtlasTexture;const e="composite"===T.kind||"camera"===T.kind;B=I||t.options.rotating||t.options.zooming||e?f.LINEAR:f.NEAREST}}else{const e=1!==r.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;D=n.imageAtlasTexture,L=p||t.options.rotating||t.options.zooming||e||I?f.LINEAR:f.NEAREST,P=n.imageAtlasTexture.size}const O=t.transform.calculatePixelsToTileUnitsMatrix(n),U=et(l.projMatrix,n.tileID.canonical,y,g,t.transform,O),V=t.terrain&&y&&x?e.invert(new Float32Array(16),U):br,N=tt(l.projMatrix,n.tileID.canonical,y,g,t.transform,O),j=S&&c.hasTextData(),G="none"!==r.layout.get("icon-text-fit")&&j&&c.hasIconData();if(x){const e=m.elevation,i=e?e.getAtTileOffsetFunc(l,m.center.lat,m.worldSize,_):e=>[0,0,0];st(c,l.projMatrix,t,o,U,N,y,h,i,l)}const Z=x||o&&S||G,$=t.translatePosMatrix(l.projMatrix,n,s,a),q=Z?br:U,X=t.translatePosMatrix(N,n,s,a,!0),W=Z?C.concat(["PROJECTED_POS_ON_VIEWPORT"]):C,H=p&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let K;const J=_.createInversionMatrix(l.toUnwrapped());K=p?c.iconsInText?dr(T.kind,z,v,y,t,$,q,X,P,R,k,M,J,E):ur(T.kind,z,v,y,t,$,q,X,o,P,!0,k,M,J,E):hr(T.kind,z,v,y,t,$,q,X,o,P,k,M,J,E);const Y={program:t.useProgram(Er(p,o,c),d,W),buffers:u,uniformValues:K,atlasTexture:D,atlasTextureIcon:F,atlasInterpolation:L,atlasInterpolationIcon:B,isSDF:p,hasHalo:H,tile:n,labelPlaneMatrixInv:V};if(b&&c.canOverlap){w=!0;const t=u.segments.get();for(const i of t)A.push({segments:new e.SegmentVector([i]),sortKey:i.sortKey,state:Y})}else A.push({segments:u.segments,sortKey:0,state:Y})}w&&A.sort((e,t)=>e.sortKey-t.sortKey);for(const e of A){const i=e.state;if(t.terrain){const e={useDepthForOcclusion:!I,labelPlaneMatrixInv:i.labelPlaneMatrixInv};t.terrain.setupElevationDraw(i.tile,i.program,e)}if(p.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Ir(i.buffers,e.segments,r,t,i.program,T,u,d,n)),n.u_is_halo=0}Ir(i.buffers,e.segments,r,t,i.program,T,u,d,i.uniformValues)}}function Ir(t,i,r,n,o,s,a,l,c){const h=n.context,u=h.gl;o.draw(h,u.TRIANGLES,s,a,l,e.CullFaceMode.disabled,c,r.id,t.layoutVertexBuffer,t.indexBuffer,i,r.paint,n.transform.zoom,t.programConfigurations.get(r.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Mr(t,i,r,n,o,s,a){const l=t.context.gl,c=r.paint.get("fill-pattern"),h=c&&c.constantOr(1),u=r.getCrossfadeParameters();let d,p,f,m,_;a?(p=h&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=l.LINES):(p=h?"fillPattern":"fill",d=l.TRIANGLES);for(const g of n){const n=i.getTile(g);if(h&&!n.patternsLoaded())continue;const y=n.getBucket(r);if(!y)continue;t.prepareDrawTile(g);const x=y.programConfigurations.get(r.id),v=t.useProgram(p,x);h&&(t.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),x.updatePaintBuffers(u));const b=c.constantOr(null);if(b&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[b.to.toString()],i=e.patternPositions[b.from.toString()];t&&i&&x.setConstantPatternPositions(t,i)}const w=t.translatePosMatrix(g.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(a){m=y.indexBuffer2,_=y.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===p&&h?qi(w,t,u,n,e):$i(w,e)}else m=y.indexBuffer,_=y.segments,f=h?Zi(w,t,u,n):Gi(w);t.prepareDrawProgram(t.context,v,g.toUnwrapped()),v.draw(t.context,d,o,t.stencilModeForClipping(g),s,e.CullFaceMode.disabled,f,r.id,y.layoutVertexBuffer,m,_,r.paint,t.transform.zoom,x)}}function Ar(t,i,r,n,o,s,a){const l=t.context,c=l.gl,h=r.paint.get("fill-extrusion-pattern"),u=h.constantOr(1),d=r.getCrossfadeParameters(),p=r.paint.get("fill-extrusion-opacity");for(const f of n){const n=i.getTile(f),m=n.getBucket(r);if(!m)continue;const _=m.programConfigurations.get(r.id),g=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",_);if(t.terrain){const e=t.terrain;if(!m.enableTerrain)continue;if(e.setupElevationDraw(n,g,{useMeterToDem:!0}),Cr(l,i,f,m,r,e),!m.centroidVertexBuffer){const e=g.attributes.a_centroid_pos;void 0!==e&&c.vertexAttrib2f(e,0,0)}}u&&(t.context.activeTexture.set(c.TEXTURE0),n.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),_.updatePaintBuffers(d));const y=h.constantOr(null);if(y&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[y.to.toString()],i=e.patternPositions[y.from.toString()];t&&i&&_.setConstantPatternPositions(t,i)}const x=t.translatePosMatrix(f.projMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),v=r.paint.get("fill-extrusion-vertical-gradient"),b=u?ji(x,t,v,p,f,d,n):Ni(x,t,v,p);t.prepareDrawProgram(l,g,f.toUnwrapped()),g.draw(l,l.gl.TRIANGLES,o,s,a,e.CullFaceMode.backCCW,b,r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,r.paint,t.transform.zoom,_,t.terrain?m.centroidVertexBuffer:null)}}function Cr(t,i,r,n,o,s){const a=[t=>{let i=t.canonical.x-1,r=t.wrap;return i<0&&(i=(1<<t.canonical.z)-1,r--),new e.OverscaledTileID(t.overscaledZ,r,t.canonical.z,i,t.canonical.y)},t=>{let i=t.canonical.x+1,r=t.wrap;return i===1<<t.canonical.z&&(i=0,r++),new e.OverscaledTileID(t.overscaledZ,r,t.canonical.z,i,t.canonical.y)},t=>new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<<t.canonical.z:t.canonical.y)-1),t=>new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<<t.canonical.z)-1?0:t.canonical.y+1)],l=e=>{const t=i.getSource().maxzoom,r=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)};let n,s,a;return(e.overscaledZ===e.canonical.z||e.overscaledZ>=t)&&(n=r(e.key)),e.overscaledZ>=t&&(s=r(e.calculateScaledKey(e.overscaledZ+1))),e.overscaledZ>t&&(a=r(e.calculateScaledKey(e.overscaledZ-1))),n||s||a},c=[0,0,0],h=(t,i)=>(c[0]=Math.min(t.min.y,i.min.y),c[1]=Math.max(t.max.y,i.max.y),c[2]=e.EXTENT-i.min.x>t.max.x?i.min.x-e.EXTENT:t.max.x,c),u=(t,i)=>(c[0]=Math.min(t.min.x,i.min.x),c[1]=Math.max(t.max.x,i.max.x),c[2]=e.EXTENT-i.min.y>t.max.y?i.min.y-e.EXTENT:t.max.y,c),d=[(e,t)=>h(e,t),(e,t)=>h(t,e),(e,t)=>u(e,t),(e,t)=>u(t,e)],p=new e.pointGeometry(0,0);let f,m,_;const g=(t,i,n,o,a)=>{const l=[[o?n:t,o?t:n,0],[o?n:i,o?i:n,0]],c=a<0?e.EXTENT+a:a,h=[o?c:(t+i)/2,o?(t+i)/2:c,0];return 0===n&&a<0||0!==n&&a>0?s.getForTilePoints(_,[h],!0,m):l.push(h),s.getForTilePoints(r,l,!0,f),Math.max(l[0][2],l[1][2],h[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=n.borders[t];if(0===i.length&&(n.borderDone[t]=!0),n.borderDone[t])continue;const o=_=a[t](r),c=l(o);if(!c||!c.enableTerrain)continue;if(!(m=s.findDEMTileFor(o))||!m.dem)continue;if(!f){const e=s.findDEMTileFor(r);if(!e||!e.dem)return;f=e}const h=(t<2?1:5)-t,u=c.borders[h];let y=0;for(let r=0;r<i.length;r++){const o=n.featuresOnBorder[i[r]],s=o.borders[t];let a;for(;y<u.length;){if((a=c.featuresOnBorder[u[y]]).borders[h][1]>s[0]+3)break;c.borderDone[h]||c.encodeCentroid(void 0,a,!1),y++}if(a&&y<u.length){const i=y;let r=0;for(;;){if(a.borders[h][0]>s[1]-3)break;if(r++,++y===u.length)break;a=c.featuresOnBorder[u[y]]}if(a=c.featuresOnBorder[u[i]],o.intersectsCount()>1||a.intersectsCount()>1||1!==r){1!==r&&(y=i),n.encodeCentroid(void 0,o,!1),c.borderDone[h]||c.encodeCentroid(void 0,a,!1);continue}const l=d[t](o,a),f=t%2?e.EXTENT-1:0;p.x=g(l[0],Math.min(e.EXTENT-1,l[1]),f,t<2,l[2]),p.y=0,n.encodeCentroid(p,o,!1),c.borderDone[h]||c.encodeCentroid(p,a,!1)}else n.encodeCentroid(void 0,o,!1)}n.borderDone[t]=n.needsCentroidUpdate=!0,c.borderDone[h]||(c.borderDone[h]=c.needsCentroidUpdate=!0)}(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const zr=new e.Color(1,0,0,1),kr=new e.Color(0,1,0,1),Pr=new e.Color(0,0,1,1),Dr=new e.Color(1,0,1,1),Lr=new e.Color(0,1,1,1);function Br(e){const t=e.transform.padding;Rr(e,e.transform.height-(t.top||0),3,zr),Rr(e,t.bottom||0,3,kr),Fr(e,t.left||0,3,Pr),Fr(e,e.transform.width-(t.right||0),3,Dr);const i=e.transform.centerPoint;!function(e,t,i,r){Or(e,t-1,i-10,2,20,r),Or(e,t-10,i-1,20,2,r)}(e,i.x,e.transform.height-i.y,Lr)}function Rr(e,t,i,r){Or(e,0,t+i/2,e.transform.width,i,r)}function Fr(e,t,i,r){Or(e,t-i/2,0,i,e.transform.height,r)}function Or(t,i,r,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,n*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}function Ur(t,i,r){const n=t.context,o=n.gl,s=r.projMatrix,a=t.useProgram("debug"),l=i.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(l,a);const c=e.DepthMode.disabled,h=e.StencilMode.disabled,u=t.colorModeForRenderPass();n.activeTexture.set(o.TEXTURE0),t.emptyTexture.bind(o.LINEAR,o.CLAMP_TO_EDGE),l._makeDebugTileBoundsBuffers(t.context,t.transform.projection);const d=l._tileDebugBuffer||t.debugBuffer,p=l._tileDebugIndexBuffer||t.debugIndexBuffer,f=l._tileDebugSegments||t.debugSegments;a.draw(n,o.LINE_STRIP,c,h,u,e.CullFaceMode.disabled,Ji(s,e.Color.red),"$debug",d,p,f);const m=l.latestRawTileData,_=m&&m.byteLength||0,g=Math.floor(_/1024),y=i.getTile(r).tileSize,x=512/Math.min(y,512)*(r.overscaledZ/t.transform.zoom)*.5;let v=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(v+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${v} ${g}kb`),a.draw(n,o.TRIANGLES,c,h,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Ji(s,e.Color.transparent,x),"$debug",t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments)}const Vr=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Nr,size:jr,alignment:Gr}=Vr;function Zr(e,t,i,r){e.emplaceBack(t,i,r)}class $r{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Zr(this.vertexArray,-1,-1,1),Zr(this.vertexArray,1,-1,1),Zr(this.vertexArray,-1,1,1),Zr(this.vertexArray,1,1,1),Zr(this.vertexArray,-1,-1,-1),Zr(this.vertexArray,1,-1,-1),Zr(this.vertexArray,-1,1,-1),Zr(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,Nr),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}const qr=7,Xr=8;function Wr(t,i,r,n,o,s){const a=t.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),h=i.paint.get("sky-atmosphere-sun-intensity"),u=gr(e.fromMat4([],n),o,h,l,c),d=a.TEXTURE_CUBE_MAP_POSITIVE_X+s;a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,d,i.skyboxTexture,0),r.draw(t,a.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,u,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Hr={symbol:function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const s=e.StencilMode.disabled,a=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(t,i,r,n,o,s,a){const l=i.transform,c="map"===o,h="map"===s,u=l.projection.createTileTransform(l,l.worldSize);for(const o of t){const t=n.getTile(o),s=t.getBucket(r);if(!s||s.projection!==l.projection.name||!s.text||!s.text.segments.get().length)continue;const d=s.textSizeData,p=e.evaluateSizeForZoom(d,l.zoom),f=i.transform.calculatePixelsToTileUnitsMatrix(t),m=et(o.projMatrix,t.tileID.canonical,h,c,i.transform,f),_="none"!==r.layout.get("icon-text-fit")&&s.hasIconData();if(p){const i=Math.pow(2,l.zoom-t.tileID.overscaledZ);Tr(s,c,h,a,e.symbolSize,l,m,o,i,p,_,u)}}}(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&Sr(t,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),s,a),0!==r.paint.get("text-opacity").constantOr(1)&&Sr(t,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(vr(t,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),vr(t,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=t.context,h=c.gl,u=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),d=e.StencilMode.disabled,p=t.colorModeForRenderPass(),f=[];for(let o=0;o<n.length;o++){const s=n[o],a=i.getTile(s),c=a.getBucket(r);if(!c)continue;const h=c.programConfigurations.get(r.id),u=Wi(r),d={programConfiguration:h,program:t.useProgram("circle",h,u),layoutVertexBuffer:c.layoutVertexBuffer,indexBuffer:c.indexBuffer,uniformValues:Xi(t,s,a,r),tile:a};if(l){const t=c.segments.get();for(const i of t)f.push({segments:new e.SegmentVector([i]),sortKey:i.sortKey,state:d})}else f.push({segments:c.segments,sortKey:0,state:d})}l&&f.sort((e,t)=>e.sortKey-t.sortKey);const m={useDepthForOcclusion:!("globe"===t.transform.projection.name)};for(const i of f){const{programConfiguration:n,program:o,layoutVertexBuffer:s,indexBuffer:a,uniformValues:l,tile:f}=i.state,_=i.segments;t.terrain&&t.terrain.setupElevationDraw(f,o,m),t.prepareDrawProgram(c,o,f.tileID.toUnwrapped()),o.draw(c,h.TRIANGLES,u,d,p,e.CullFaceMode.disabled,l,r.id,s,a,_,r.paint,t.transform.zoom,n)}},heatmap:function(t,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=e.StencilMode.disabled,l=new e.ColorMode([s.ONE,s.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,i){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,t.width/4,t.height/4]);let n=i.heatmapFbo;if(n)r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),e.bindFramebuffer.set(n.framebuffer);else{const o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),n=i.heatmapFbo=e.createFramebuffer(t.width/4,t.height/4,!1),function(e,t,i,r){const n=e.gl,o=e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:n.UNSIGNED_BYTE;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t.width/4,t.height/4,0,n.RGBA,o,null),r.colorAttachment.set(i)}(e,t,o,n)}}(o,t,r),o.clear({color:e.Color.transparent});for(let c=0;c<n.length;c++){const h=n[c];if(i.hasRenderableParent(h))continue;const u=i.getTile(h),d=u.getBucket(r);if(!d)continue;const p=d.programConfigurations.get(r.id),f=t.useProgram("heatmap",p),{zoom:m}=t.transform;t.terrain&&t.terrain.setupElevationDraw(u,f),t.prepareDrawProgram(o,f,h.toUnwrapped()),f.draw(o,s.TRIANGLES,e.DepthMode.disabled,a,l,e.CullFaceMode.disabled,Yi(h.projMatrix,u,m,r.paint.get("heatmap-intensity")),r.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,r.paint,t.transform.zoom,p)}o.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){const r=t.context,n=r.gl,o=i.heatmapFbo;if(!o)return;r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),r.activeTexture.set(n.TEXTURE1);let s=i.colorRampTexture;s||(s=i.colorRampTexture=new e.Texture(r,i.colorRamp,n.RGBA)),s.bind(n.LINEAR,n.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(r,n.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,Qi(t,i,0,1),i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,r))},line:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),c=r.paint.get("line-dasharray"),h=c.constantOr(1),u=r.layout.get("line-cap"),d=r.paint.get("line-pattern"),p=d.constantOr(1),f=r.paint.get("line-gradient"),m=r.getCrossfadeParameters(),_=p?"linePattern":"line",g=t.context,y=g.gl,x=nr(r);let v=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(v=!1);for(const o of n){const n=i.getTile(o);if(p&&!n.patternsLoaded())continue;const s=n.getBucket(r);if(!s)continue;t.prepareDrawTile(o);const b=s.programConfigurations.get(r.id),w=t.useProgram(_,b,x),T=d.constantOr(null);if(T&&n.imageAtlas){const e=n.imageAtlas,t=e.patternPositions[T.to.toString()],i=e.patternPositions[T.from.toString()];t&&i&&b.setConstantPatternPositions(t,i)}const E=c.constantOr(null),S=u.constantOr(null);if(!p&&E&&S&&n.lineAtlas){const e=n.lineAtlas,t=e.getDash(E.to,S),i=e.getDash(E.from,S);t&&i&&b.setConstantPatternPositions(t,i)}const I=t.terrain?o.projMatrix:null,M=p?tr(t,n,r,m,I):er(t,n,r,m,I,s.lineClipsArray.length);if(f){const n=s.gradients[r.id];let a=n.texture;if(r.gradientVersion!==n.version){let l=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<t.transform.maxZoom-o.canonical.z):1,a=s.maxLineLength/e.EXTENT*1024*n;l=e.clamp(e.nextPowerOfTwo(a),256,g.maxTextureSize)}n.gradient=e.renderColorRamp({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:n.gradient||void 0,clips:s.lineClipsArray}),n.texture?n.texture.update(n.gradient):n.texture=new e.Texture(g,n.gradient,y.RGBA),n.version=r.gradientVersion,a=n.texture}g.activeTexture.set(y.TEXTURE1),a.bind(r.stepInterpolant?y.NEAREST:y.LINEAR,y.CLAMP_TO_EDGE)}h&&(g.activeTexture.set(y.TEXTURE0),n.lineAtlasTexture.bind(y.LINEAR,y.REPEAT),b.updatePaintBuffers(m)),p&&(g.activeTexture.set(y.TEXTURE0),n.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),b.updatePaintBuffers(m)),t.prepareDrawProgram(g,w,o.toUnwrapped());const A=i=>{w.draw(g,y.TRIANGLES,a,i,l,e.CullFaceMode.disabled,M,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,t.transform.zoom,b,s.layoutVertexBuffer2)};if(v){const i=t.stencilModeForClipping(o).ref;0===i&&t.terrain&&g.clear({stencil:0});const r={func:y.EQUAL,mask:255};M.u_alpha_discard_threshold=.8,A(new e.StencilMode(r,i,255,y.KEEP,y.KEEP,y.INVERT)),M.u_alpha_discard_threshold=0,A(new e.StencilMode(r,i,255,y.KEEP,y.KEEP,y.KEEP))}else A(t.stencilModeForClipping(o))}v&&(t.resetStencilClippingMasks(),t.terrain&&g.clear({stencil:0}))},fill:function(t,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=t.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(t.renderPass===c){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);Mr(t,i,r,n,o,a,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const o=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);Mr(t,i,r,n,o,a,!0)}},"fill-extrusion":function(t,i,r,n){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const s=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))Ar(t,i,r,n,s,e.StencilMode.disabled,e.ColorMode.disabled),Ar(t,i,r,n,s,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();Ar(t,i,r,n,s,e.StencilMode.disabled,o)}}},hillshade:function(t,i,r,n){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),a=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[c,h]="translucent"!==t.renderPass||l?[{},n]:t.stencilConfigForOverlap(n);for(const n of h){const o=i.getTile(n);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)di(t,o,r,s,e.StencilMode.disabled,a);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(n):c[n.overscaledZ];hi(t,n,o,r,s,e,a)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!n.length)return;const a=t.context,l=a.gl,c=i.getSource(),h=t.useProgram("raster"),u=t.colorModeForRenderPass(),d=t.terrain&&t.terrain.renderingToTexture,[p,f]=c instanceof Me||d?[{},n]:t.stencilConfigForOverlap(n),m=f[f.length-1].overscaledZ,_=!t.options.moving;for(const n of f){const o=d?e.DepthMode.disabled:t.depthModeForSublayer(n.overscaledZ-m,1===r.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),f=n.toUnwrapped(),g=i.getTile(n);if(d&&(!g||!g.hasData()))continue;const y=d?n.projMatrix:t.transform.calculateProjMatrix(f,_),x=t.terrain&&d?t.terrain.stencilModeForRTTOverlap(n):p[n.overscaledZ],v=s?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(v);const b=i.findLoadedParent(n,0),w=Mi(g,b,i,t.transform,v);let T,E;t.terrain&&t.terrain.prepareDrawTile(n);const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),E=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(S,l.CLAMP_TO_EDGE);const I=c instanceof Me?c.perspectiveTransform:[0,0],M=sr(y,E||[0,0],T||1,w,r,I);if(t.prepareDrawProgram(a,h,f),c instanceof Me)h.draw(a,l.TRIANGLES,o,e.StencilMode.disabled,u,e.CullFaceMode.disabled,M,r.id,c.boundsBuffer,t.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:n,tileBoundsSegments:s}=t.getTileBoundsBuffers(g);h.draw(a,l.TRIANGLES,o,x,u,e.CullFaceMode.disabled,M,r.id,i,n,s)}}t.resetStencilClippingMasks()},background:function(t,i,r,n){const o=r.paint.get("background-color"),s=r.paint.get("background-opacity");if(0===s)return;const a=t.context,l=a.gl,c=t.transform,h=c.tileSize,u=r.paint.get("background-pattern");if(t.isPatternMissing(u))return;const d=!u&&1===o.a&&1===s&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==d)return;const p=e.StencilMode.disabled,f=t.depthModeForSublayer(0,"opaque"===d?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),_=t.useProgram(u?"backgroundPattern":"background");let g,y=n;y||(g=t.getBackgroundTiles(),y=Object.values(g).map(e=>e.tileID)),u&&(a.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));const x=r.getCrossfadeParameters();for(const d of y){const y=d.toUnwrapped(),v=n?d.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile(d);const b=i?i.getTile(d):g?g[d.key]:new e.Tile(d,h,c.zoom,t),w=u?fr(v,s,t,u,{tileID:d,tileSize:h},x):pr(v,s,o);t.prepareDrawProgram(a,_,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:E,tileBoundsSegments:S}=t.getTileBoundsBuffers(b);_.draw(a,l.TRIANGLES,f,p,m,e.CullFaceMode.disabled,w,r.id,T,E,S)}},sky:function(t,i,r){const n=t.transform,o="mercator"===n.projection.name||"globe"===n.projection.name?1:e.smoothstep(qr,Xr,n.zoom),s=r.paint.get("sky-opacity")*o;if(0===s)return;const a=t.context,l=r.paint.get("sky-type"),c=new e.DepthMode(a.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),h=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,i,r,n){const o=t.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(r,n,!1),i.skyboxGeometry=new $r(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let e=0;e<6;++e){const t=s.TEXTURE_CUBE_MAP_POSITIVE_X+e;s.texImage2D(t,0,s.RGBA,r,n,0,s.RGBA,s.UNSIGNED_BYTE,null)}}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,r,n]);const l=i.getCenter(t,!0),c=t.useProgram("skyboxCapture"),h=new Float64Array(16);e.identity(h),e.rotateY(h,h,.5*-Math.PI),Wr(o,i,c,h,l,0),e.identity(h),e.rotateY(h,h,.5*Math.PI),Wr(o,i,c,h,l,1),e.identity(h),e.rotateX(h,h,.5*-Math.PI),Wr(o,i,c,h,l,2),e.identity(h),e.rotateX(h,h,.5*Math.PI),Wr(o,i,c,h,l,3),e.identity(h),Wr(o,i,c,h,l,4),e.identity(h),e.rotateY(h,h,Math.PI),Wr(o,i,c,h,l,5),o.viewport.set([0,0,t.width,t.height])}(t,r,32,32),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const h=mr(l.skyboxMatrix,i.getCenter(t,!1),0,n,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,r,c,s,h):"gradient"===l&&"sky"===t.renderPass&&function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new $r(s)),s.activeTexture.set(a.TEXTURE0);let h=i.colorRampTexture;h||(h=i.colorRampTexture=new e.Texture(s,i.colorRamp,a.RGBA)),h.bind(a.LINEAR,a.CLAMP_TO_EDGE);const u=_r(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),n,o);t.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,u,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,r,c,s,h)},debug:function(e,t,i){for(let r=0;r<i.length;r++)Ur(e,t,i[r])},custom:function(t,i,r){const n=t.context,o=r.implementation;if(t.transform.projection.unsupportedLayers&&t.transform.projection.unsupportedLayers.includes("custom"))e.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===t.renderPass){const e=o.prerender;e&&(t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),e.call(o,n.gl,t.transform.customLayerMatrix()),n.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),n.setColorMode(t.colorModeForRenderPass()),n.setStencilMode(e.StencilMode.disabled);const i="3d"===o.renderingMode?new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,e.DepthMode.ReadOnly);n.setDepthMode(i),o.render(n.gl,t.transform.customLayerMatrix()),n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(null)}}};class Kr{constructor(t,i){this.context=new ye(t),this.transform=i,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.crossTileSymbolIndex=new Gt,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(e,t){const i=!!e&&!!e.terrain&&this.transform.projection.supportsTerrain;if(!(i||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Li(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t)}_updateFog(e){const t=e.fog;if(!t||t.getOpacity(this.transform.pitch)<1||t.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[i,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,i){if(this.width=t*e.exported.devicePixelRatio,this.height=i*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,i=new e.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(e.EXTENT,0),i.emplaceBack(0,e.EXTENT),i.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const r=new e.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(e.EXTENT,0),r.emplaceBack(0,e.EXTENT),r.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const n=new e.StructArrayLayout2i4;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const s=new e.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);const a=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])a.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(a),this.emptyTexture=new e.Texture(t,{width:1,height:1,data:new Uint8Array([0,0,0,0])},t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){if(e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer){return{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}}return this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,i.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,Ii(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,i,r){if(!i||this.currentStencilSource===i.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=i.id;const n=this.context,o=n.gl;this.nextStencilID+r.length>256&&this.clearStencil(),n.setColorMode(e.ColorMode.disabled),n.setDepthMode(e.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of r){const r=i.getTile(t),a=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:h}=this.getTileBoundsBuffers(r);s.draw(n,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Ii(t.projMatrix),"$clipping",l,c,h)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,i=this.context.gl;return new e.StencilMode({func:i.NOTEQUAL,mask:255},t,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const i=this.context.gl;return new e.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(t){const i=this.context.gl,r=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=r[r.length-1].overscaledZ,o=r[0].overscaledZ-n+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let r=0;r<o;r++)t[r+n]=new e.StencilMode({func:i.GEQUAL,mask:255},r+this.nextStencilID,255,i.KEEP,i.KEEP,i.REPLACE);return this.nextStencilID+=o,[t,r]}return[{[n]:e.StencilMode.disabled},r]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new e.ColorMode([t.CONSTANT_COLOR,t.ONE],new e.Color(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?e.ColorMode.unblended:e.ColorMode.alphaBlended}depthModeForSublayer(t,i,r){if(!this.opaquePassEnabledForLayer())return e.DepthMode.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new e.DepthMode(r||this.context.gl.LEQUAL,i,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.exported.now()),this.imageManager.beginFrame();const r=this.style.order,n=this.style._sourceCaches;for(const e in n){const t=n[e];t.used&&t.prepare(this.context)}const o={},s={},a={};for(const e in n){const t=n[e];o[e]=t.getVisibleCoordinates(),s[e]=o[e].slice().reverse(),a[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<r.length;e++){const t=r[e];if(this.style._layers[t].is3D()){this.opaquePassCutoff=e;break}}if(this.terrain&&(this.terrain.updateTileBinding(a),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new e.GlobeSharedBuffers(this.context)),!e.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const e of r){const i=this.style._layers[e],r=t._getLayerSourceCache(i);if(!i.hasOffscreenPass()||i.isHidden(this.transform.zoom))continue;const n=r?s[r.id]:void 0;("custom"===i.type||i.isSky()||n&&n.length)&&this.renderLayer(this,r,i,n)}this.depthRangeFor3D=[0,1-(t.order.length+2)*this.numSublayers*this.depthEpsilon],this.terrain&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&this.terrain.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]);let l=e.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(l=this.style.fog.properties.get("color")),this.context.clear({color:i.showOverdrawInspector?e.Color.black:l,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=r.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky())continue;const n=i?s[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}if(this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<r.length;this.currentLayer++){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(!e.isSky())continue;const n=i?s[i.id]:void 0;this.renderLayer(this,i,e,n)}for("globe"===this.transform.projection.name&&function(t){const i=t.context,r=i.gl,n=t.transform,o=new e.DepthMode(r.LEQUAL,e.DepthMode.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere"),a=n._camera.getWorldToCamera(n.worldSize,1),l=n._camera.getCameraToClipPerspective(n._fov,n.width/n.height,n._nearZ,n._farZ),c=e.mul([],a,e.calculateGlobeMatrix(n,n.worldSize)),h=e.mul([],n.labelPlaneMatrix,l),u=e.transformMat4([],[0,0,0],c),d=e.add([],u,[n.worldSize/Math.PI/2,0,0]),p=e.transformMat4([],u,h),f=e.transformMat4([],d,h),m=e.length(e.sub([],f,p)),_=1-e.globeToMercatorTransition(n.zoom);let g={r:1,g:1,b:1,a:1},y={r:.0118,g:.7451,b:.9882,a:1},x=2;const v=n.projection.atmosphere;v&&(g=e.Color.parse(v["gradient-inner-color"])||g,y=e.Color.parse(v["gradient-outer-color"])||y,x=v["gradient-outer-radius"]||x);const b=_i(p,m,[n.width,n.height],e.exported.devicePixelRatio,_,x,[g.r,g.g,g.b],[y.r,y.g,y.b]);t.prepareDrawProgram(i,s);const w=t.globeSharedBuffers;w&&s.draw(i,r.TRIANGLES,o,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,b,"skybox",w.atmosphereVertexBuffer,w.atmosphereIndexBuffer,w.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<r.length;){const e=this.style._layers[r[this.currentLayer]],i=t._getLayerSourceCache(e);if(e.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(e)){if(e.isHidden(this.transform.zoom)){++this.currentLayer;continue}const t=this.terrain;this.currentLayer,this.currentLayer=t.renderBatch(this.currentLayer);continue}const n=i?("symbol"===e.type?a:s)[i.id]:void 0;this._renderTileClippingMasks(e,i,i?o[i.id]:void 0),this.renderLayer(this,i,e,n),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let i=null;e.values(this.style._layers).forEach(e=>{const r=t._getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom<r.getSource().maxzoom)&&(i=r)}),i&&this.options.showTileBoundaries&&Hr.debug(this,i,i.getVisibleCoordinates())}this.options.showPadding&&Br(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(e.window.performance.now()),this.saveCanvasCopy())}renderLayer(e,t,i,r){i.isHidden(this.transform.zoom)||("background"===i.type||"sky"===i.type||"custom"===i.type||r&&r.length)&&(this.id=i.id,this.gpuTimingStart(i),e.transform.projection.unsupportedLayers&&e.transform.projection.unsupportedLayers.includes(i.type)||Hr[i.type](e,t,i,r,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(e){if(!this.options.gpuTiming)return;const t=this.context.extTimerQuery;let i=this.gpuTimers[e.id];i||(i=this.gpuTimers[e.id]={calls:0,cpuTime:0,query:t.createQueryEXT()}),i.calls++,t.beginQueryEXT(t.TIME_ELAPSED_EXT,i.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const e=this.context.extTimerQuery;e.endQueryEXT(e.TIME_ELAPSED_EXT)}collectGpuTimers(){const e=this.gpuTimers;return this.gpuTimers={},e}queryGpuTimers(e){const t={};for(const i in e){const r=e[i],n=this.context.extTimerQuery,o=n.getQueryObjectEXT(r.query,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(r.query),t[i]=o}return t}translatePosMatrix(t,i,r,n,o){if(!r[0]&&!r[1])return t;const s=o?"map"===n?this.transform.angle:0:"viewport"===n?-this.transform.angle:0;if(s){const e=Math.sin(s),t=Math.cos(s);r=[r[0]*t-r[1]*e,r[0]*e+r[1]*t]}const a=[o?r[0]:k(i,r[0],this.transform.zoom),o?r[1]:k(i,r[1],this.transform.zoom),0],l=new Float32Array(16);return e.translate(l,t,a),l}saveTileTexture(e){const t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}currentGlobalDefines(){const e=this.terrain&&!this.terrain.renderingToTexture,t=this.terrain&&this.terrain.renderingToTexture,i=this.style&&this.style.fog,r=[];return e&&r.push("TERRAIN"),i&&!t&&0!==i.getOpacity(this.transform.pitch)&&r.push("FOG"),t&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}useProgram(e,t,i){this.cache=this.cache||{};const r=i||[],n=this.currentGlobalDefines().concat(r),o=Ui.cacheKey(e,n,t);return this.cache[o]||(this.cache[o]=new Ui(this.context,e,ni[e],t,yr[e],n)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const 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(){if(null==this.debugOverlayCanvas){this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512;const t=this.context.gl;this.debugOverlayTexture=new e.Texture(this.context,this.debugOverlayCanvas,t.RGBA)}}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(e){this.terrain&&this.terrain.prepareDrawTile(e)}prepareDrawProgram(e,t,i){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const n=r.getOpacity(this.transform.pitch);0!==n&&t.setFogUniformValues(e,Fi(this,r,i,n))}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),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,i=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const n of r)i[n.key]=t[n.key]||new e.Tile(n,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Jr{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.number(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.number(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.number(t.right,i.right,r)),this}getCenter(t,i){const r=e.clamp((this.left+t-this.right)/2,0,t),n=e.clamp((this.top+i-this.bottom)/2,0,i);return new e.pointGeometry(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Jr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Yr(t,i){const r=e.getColumn(t,3);e.fromQuat(t,i),e.setColumn(t,3,r)}function Qr(t,i){e.setColumn(t,3,[i[0],i[1],i[2],1])}function en(t,i){const r=e.identity$1([]);return e.rotateZ$1(r,r,-i),e.rotateX$1(r,r,-t),r}function tn(t,i){const r=[t[0],t[1],0],n=[i[0],i[1],0];if(e.length(r)>=1e-15){const t=e.normalize([],r);e.scale$2(n,t,e.dot(n,t)),i[0]=n[0],i[1]=n[1]}const o=e.cross([],i,t);if(e.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return en(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}class rn{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){this._position=this._renderWorldCopies?function(t){if(!t)return;const i=Array.isArray(t)?new e.MercatorCoordinate(t[0],t[1],t[2]):t;return i.x=e.wrap(i.x,0,1),i}(t):t}lookAtPoint(t,i){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,n=this.position,o=e.MercatorCoordinate.fromLngLat(t,r),s=[o.x-n.x,o.y-n.y,o.z-n.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=tn(s,i)}setPitchBearing(t,i){this.orientation=en(e.degToRad(t),e.degToRad(-i))}}class nn{constructor(t,i){this._transform=e.identity([]),this._orientation=e.identity$1([]),i&&(this._orientation=i,Yr(this._transform,this._orientation)),t&&Qr(this._transform,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(e){Qr(this._transform,e)}get orientation(){return this._orientation}set orientation(e){this._orientation=e,Yr(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=en(e,t),Yr(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,i){const r=new Float64Array(16);return e.invert(r,this.getWorldToCamera(t,i)),r}getWorldToCameraPosition(t,i,r){const n=this.position;e.scale$2(n,n,-t);const o=new Float64Array(16);return e.fromScaling(o,[r,r,r]),e.translate(o,o,n),o[10]*=i,o}getWorldToCamera(t,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.conjugate(n,this._orientation),e.scale$2(o,o,-t),e.fromQuat(r,n),e.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(t,i,r,n){const o=new Float64Array(16);return e.perspective(o,t,i,r,n),o}getDistanceToElevation(t){const i=0===t?0:e.mercatorZfromAltitude(t,this.position[1]),r=this.forward();return(i-this.position[2])/r[2]}clone(){return new nn([...this.position],[...this.orientation])}}function on(t,i){const r=an(t),n=function(t,i,r,n,o){const s=new e.LngLat(r.lng-180*ln,r.lat),a=new e.LngLat(r.lng+180*ln,r.lat),l=t.project(s.lng,s.lat),c=t.project(a.lng,a.lat),h=c.x-l.x,u=c.y-l.y,d=-Math.atan2(u,h),p=e.MercatorCoordinate.fromLngLat(r);p.y=e.clamp(p.y,-1+ln,1-ln);const f=p.toLngLat(),m=t.project(f.lng,f.lat),_=e.MercatorCoordinate.fromLngLat(f);_.x+=ln;const g=_.toLngLat(),y=t.project(g.lng,g.lat),x=y.x-m.x,v=y.y-m.y,b=hn(x,v,d),w=e.MercatorCoordinate.fromLngLat(f);w.y+=ln;const T=w.toLngLat(),E=t.project(T.lng,T.lat),S=E.x-m.x,I=E.y-m.y,M=hn(S,I,d),A=Math.abs(b.x)/Math.abs(M.y),C=e.identity([]);e.rotateZ(C,C,-d*(1-(o?0:n)));const z=e.identity([]);return e.scale(z,z,[1,1-(1-A)*n,1]),z[4]=-M.x/M.y*n,e.rotateZ(z,z,d),e.multiply$1(z,C,z),z}(t.projection,t.zoom,t.center,r,i),o=sn(t);return e.scale(n,n,[o,o,1]),n}function sn(t){const i=t.projection,r=an(t),n=cn(i,t.center),o=cn(i,e.LngLat.convert(i.center));return Math.pow(2,n*r+(1-r)*o)}function an(t){const i=t.projection.range;if(!i)return 0;const r=Math.max(t.width,t.height),n=Math.log(r/1024)/Math.LN2,o=i[0]+n,s=i[1]+n;return e.smoothstep(o,s,t.zoom)}const ln=25e-6;function cn(t,i){const r=e.clamp(i.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),n=new e.LngLat(i.lng-180*ln,r),o=new e.LngLat(i.lng+180*ln,r),s=t.project(n.lng,r),a=t.project(o.lng,r),l=e.MercatorCoordinate.fromLngLat(n),c=e.MercatorCoordinate.fromLngLat(o),h=a.x-s.x,u=a.y-s.y,d=c.x-l.x,p=c.y-l.y,f=Math.sqrt((d*d+p*p)/(h*h+u*u));return Math.log(f)/Math.LN2}function hn(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}const un=3,dn=0;class pn{constructor(t,i,r,n,o){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||dn,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==n?60:n,this.setProjection(),this.setMaxBounds(),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 Jr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new nn,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const e=new pn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.setProjection(this.getProjection()),e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e.tileSize=this.tileSize,e.setMaxBounds(this.getMaxBounds()),e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._cameraZoom=this._cameraZoom,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}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,e?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(e){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),e&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels","atmosphere"])}setProjection(t){null==t&&(t={name:"mercator"}),this.projectionOptions=t;const i=this.projection?this.getProjection():void 0;return this.projection=e.getProjection(t),!o(i,this.getProjection())&&(this._calcMatrices(),!0)}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 cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.pointGeometry(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 i=-t*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l+o*a,e[1]=n*l+s*a,e[2]=r*-a+o*l,e[3]=n*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const i=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices()}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._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const e=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return-1===e?(this._cameraZoom=null,!1):(this._centerAltitude=e,!0)}_updateCameraOnTerrain(){const e=this.cameraToCenterDistance,t=this.pixelsPerMeter*this._centerAltitude;this._cameraZoom=this._zoomFromMercatorZ((t+e)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s<i.length;s++){const a=new e.pointGeometry(i[s][0]*this.width,r+i[s][1]*(this.height-r)),l=t.pointCoordinate(a);if(!l)continue;const c=1/Math.hypot(l[0]-this._camera.position[0],l[1]-this._camera.position[1]);n+=l[3]*c,o+=c}return 0===o?NaN:n/o}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._terrainEnabled()&&("ground"===this.cameraElevationReference?this._updateCenterElevation()?this._updateCameraOnTerrain():this._cameraZoom=null:this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(null==this._cameraZoom||!this._elevation)return;const e=this._cameraZoom,t=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),i=this.pixelsPerMeter/this.worldSize*t,r=this._mercatorZfromZoom(e),n=this._mercatorZfromZoom(this._maxZoom),o=Math.max(r-i,n);this._setZoom(this._zoomFromMercatorZ(o))}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}computeZoomRelativeTo(t){const i=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,t.toAltitude()));let r;r=t.z<this._camera.position[2]?[i.x,i.y,i.z]:[t.x,t.y,t.z];const n=e.length(e.sub([],this._camera.position,r));return e.clamp(this._zoomFromMercatorZ(n),this._minZoom,this._maxZoom)}setFreeCameraOptions(t){if(!this.height)return;if(!t.position&&!t.orientation)return;this._updateCameraState();let i=!1;if(t.orientation&&!e.exactEquals(t.orientation,this._camera.orientation)&&(i=this._setCameraOrientation(t.orientation)),t.position){const r=[t.position.x,t.position.y,t.position.z];e.exactEquals$1(r,this._camera.position)||(this._setCameraPosition(r),i=!0)}i&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const t=this._camera.position,i=new rn;return i.position=new e.MercatorCoordinate(t[0],t[1],t[2]),i.orientation=this._camera.orientation,i._elevation=this.elevation,i._renderWorldCopies=this.renderWorldCopies,i}_setCameraOrientation(t){if(!e.length$1(t))return!1;e.normalize$1(t,t);const i=e.transformQuat([],[0,0,-1],t),r=e.transformQuat([],[0,-1,0],t);if(r[2]<0)return!1;const n=tn(i,r);return!!n&&(this._camera.orientation=n,!0)}_setCameraPosition(t){const i=this.zoomScale(this.minZoom)*this.tileSize,r=this.zoomScale(this.maxZoom)*this.tileSize,n=this.cameraToCenterDistance;t[2]=e.clamp(t[2],n/r,n/i),this._camera.position=t}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const t=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,t)}getVisibleUnwrappedCoordinates(t){const i=[new e.UnwrappedTileID(0,t)];if(this.renderWorldCopies){const r=this.pointCoordinate(new e.pointGeometry(0,0)),n=this.pointCoordinate(new e.pointGeometry(this.width,0)),o=this.pointCoordinate(new e.pointGeometry(this.width,this.height)),s=this.pointCoordinate(new e.pointGeometry(0,this.height)),a=Math.floor(Math.min(r.x,n.x,o.x,s.x)),l=Math.floor(Math.max(r.x,n.x,o.x,s.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new e.UnwrappedTileID(r,t))}return i}coveringTiles(t){let i=this.coveringZoomLevel(t);const r=i,n=this.elevation&&!t.isTerrainDEM,o="mercator"===this.projection.name;if(void 0!==t.minzoom&&i<t.minzoom)return[];void 0!==t.maxzoom&&i>t.maxzoom&&(i=t.maxzoom);const s=this.locationCoordinate(this.center),a=1<<i,l=[a*s.x,a*s.y,0],c="globe"!==this.projection.name,h=e.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,i,c),u=this.pointCoordinate(this.getCameraPoint()),d=a*e.mercatorZfromAltitude(1,this.center.lat),p=this._camera.position[2]/e.mercatorZfromAltitude(1,this.center.lat),f=[a*u.x,a*u.y,p],m=this.cameraToCenterDistance/t.tileSize*(t.roundZoom?1:.502),_=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?i:0,g=t.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,y=t.isTerrainDEM?-g:this._elevation?this._elevation.getMinElevationBelowMSL():0,x=this.projection.isReprojectedInTileSpace?sn(this):1,v=t=>{const i=new e.MercatorCoordinate(t.x+25e-6,t.y,t.z),r=new e.MercatorCoordinate(t.x,t.y+25e-6,t.z),n=t.toLngLat(),o=i.toLngLat(),s=r.toLngLat(),a=this.locationCoordinate(n),l=this.locationCoordinate(o),c=this.locationCoordinate(s),h=Math.hypot(l.x-a.x,l.y-a.y),u=Math.hypot(c.x-a.x,c.y-a.y);return Math.sqrt(h*u)*x/25e-6},b=t=>{const i=g,r=y;return{aabb:e.tileAABB(this,a,0,0,0,t,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:t,fullyVisible:!1}},w=[];let T=[];const E=i,S=t.reparseOverscaled?r:i,I=e=>e*e,M=I((p-this._centerAltitude)*d),A=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),i=e.aabb;t?(i.min[2]=t.min,i.max[2]=t.max,i.center[2]=(i.min[2]+i.max[2])/2):(e.shouldSplit=C(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},C=t=>{if(t.zoom<_)return!0;if(t.zoom===E)return!1;if(null!=t.shouldSplit)return t.shouldSplit;const i=t.aabb.distanceX(f),o=t.aabb.distanceY(f);let s=M;n&&(s=I(t.aabb.distanceZ(f)*d));let a=1;if(this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,t.zoom),r=v(new e.MercatorCoordinate((t.x+.5)/i,(t.y+.5)/i));a=r>.85?1:r}const l=i*i+o*o+s,c=(1<<E-t.zoom)*m*a;return l<I(c*((e,t)=>{if(t*I(.707)<e)return 1;const i=Math.sqrt(t/e),r=i-1/.707;return i/(1/.707+(Math.pow(1.1,r+1)-1)/(1.1-1)-1)})(Math.max(s,M),l))};if(this.renderWorldCopies)for(let e=1;e<=un;e++)w.push(b(-e)),w.push(b(e));for(w.push(b(0));w.length>0;){const r=w.pop(),s=r.x,c=r.y;let u=r.fullyVisible;if(!u){const e=r.aabb.intersects(h);if(0===e)continue;u=2===e}if(r.zoom!==E&&C(r))for(let t=0;t<4;t++){const i=(s<<1)+t%2,l=(c<<1)+(t>>1),h={aabb:o?r.aabb.quadrant(t):e.tileAABB(this,a,r.zoom+1,i,l,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:l,wrap:r.wrap,fullyVisible:u,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};n&&(h.tileID=new e.OverscaledTileID(r.zoom+1===E?S:r.zoom+1,r.wrap,r.zoom+1,i,l),A(h)),w.push(h)}else{const n=r.zoom===E?S:r.zoom;if(t.minzoom&&t.minzoom>n)continue;const o=l[0]-(.5+s+(r.wrap<<r.zoom))*(1<<i-r.zoom),a=l[1]-.5-c,h=r.tileID?r.tileID:new e.OverscaledTileID(n,r.wrap,r.zoom,s,c);T.push({tileID:h,distanceSq:o*o+a*a})}}if(this.fogCullDistSq){const i=this.fogCullDistSq,r=this.horizonLineFromTop();T=T.filter(n=>{const o=[0,0,0,1],s=[e.EXTENT,e.EXTENT,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.transformMat4$1(o,o,a),e.transformMat4$1(s,s,a);const l=e.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const h=this._elevation;if(h&&l>i&&0!==r){const i=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=h.getMinMaxForTile(n.tileID)),o||(o={min:y,max:g});const s=e.furthestTileCorner(this.rotation),a=[s[0]*e.EXTENT,s[1]*e.EXTENT,o.max];e.transformMat4(a,a,i),c=(1-a[1])*this.height*.5<r}return l<i||c})}return T.sort((e,t)=>e.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 i=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=this.projection.project(t.lng,i);return new e.pointGeometry(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,i){const r=this.pointCoordinate(i),n=this.pointCoordinate(this.centerPoint),o=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(o.x-(r.x-n.x),o.y-(r.y-n.y)))}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._coordinatePoint(this.locationCoordinate(e),!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,i){const r=i?e.mercatorZfromAltitude(i,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(n.x,n.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const r=null!=i?i:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const s=n[3],a=o[3];e.scale$1(n,n,1/s),e.scale$1(o,o,1/a);const l=n[2],c=o[2];return{p0:n,p1:o,t:l===c?0:(r-l)/(c-l)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(r,r,this.pixelMatrixInverse),e.scale$1(i,i,1/i[3]),e.scale$1(r,r,1/r[3]),i[2]=e.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,r[2]=e.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,e.scale$1(i,i,1/this.worldSize),e.scale$1(r,r,1/this.worldSize),new e.Ray([i[0],i[1],i[2]],e.normalize([],e.sub([],r,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:r,t:n}=t,o=e.mercatorZfromAltitude(i[2],this._center.lat),s=e.mercatorZfromAltitude(r[2],this._center.lat);return new e.MercatorCoordinate(e.number(i[0],r[0],n)/this.worldSize,e.number(i[1],r[1],n)/this.worldSize,e.number(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);const i=this.elevation;let r=this.elevation.pointCoordinate(t);if(r)return new e.MercatorCoordinate(r[0],r[1],r[2]);let n=0,o=this.horizonLineFromTop();if(t.y>o)return this.pointCoordinate(t);const s=.02*o,a=t.clone();for(let t=0;t<10&&o-n>s;t++){a.y=e.number(n,o,.66);const t=i.pointCoordinate(a);t?(o=a.y,r=t):n=a.y}return r?new e.MercatorCoordinate(r[0],r[1],r[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){if(this.elevation)return!this.elevation.pointCoordinate(e);{const t=this.horizonLineFromTop();return e.y<t}}_coordinatePoint(t,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.transformMat4$1(n,n,this.pixelMatrix),n[3]>0?new e.pointGeometry(n[0]/n[3],n[1]/n[3]):new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(t,i){const r=new e.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),n=new e.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new e.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new e.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let a=this.pointCoordinate(r,t),l=this.pointCoordinate(n,t);const c=this.pointCoordinate(o,i),h=this.pointCoordinate(s,i),u=(e,t)=>(t.y-e.y)/(t.x-e.x);return a.y>1&&l.y>=0?a=new e.MercatorCoordinate((1-h.y)/u(h,a)+h.x,1):a.y<0&&l.y<=1&&(a=new e.MercatorCoordinate(-h.y/u(h,a)+h.x,0)),l.y>1&&a.y>=0?l=new e.MercatorCoordinate((1-c.y)/u(c,l)+c.x,1):l.y<0&&a.y<=1&&(l=new e.MercatorCoordinate(-c.y/u(c,l)+c.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(a)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(c))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length)return this._getBounds(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const i=t.dem.tree;e.min=Math.min(e.min,i.minimums[0]),e.max=Math.max(e.max,i.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,i):i}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.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=e.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=e.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=e.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=e.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(e,t){return this.projection.createTileTransform(this,t).createTileMatrix(e)}calculateDistanceTileData(t){const i=t.key,r=this._distanceTileDataCache;if(r[i])return r[i];const n=t.canonical,o=1/this.height,s=this.cameraWorldSize/this.zoomScale(n.z),a=(n.x+Math.pow(2,n.z)*t.wrap)*s,l=n.y*s,c=this.point,h=this.angle,u=Math.sin(-h),d=-Math.cos(-h),p=(c.x-a)*o,f=(c.y-l)*o;return r[i]={bearing:[u,d],center:[p,f],scale:s/e.EXTENT*o},r[i]}calculateFogTileMatrix(t){const i=t.key,r=this._fogTileMatrixCache;if(r[i])return r[i];const n=this.calculatePosMatrix(t,this.cameraWorldSize);return e.multiply$1(n,this.worldToFogMatrix,n),r[i]=new Float32Array(n),r[i]}calculateProjMatrix(t,i=!1){const r=t.key,n=i?this._alignedProjMatrixCache:this._projMatrixCache;if(n[r])return n[r];const o=this.calculatePosMatrix(t,this.worldSize),s=this.projection.isReprojectedInTileSpace?this.mercatorMatrix:i?this.alignedProjMatrix:this.projMatrix;return e.multiply$1(o,s,o),n[r]=new Float32Array(o),n[r]}calculatePixelsToTileUnitsMatrix(t){const i=t.tileID.key,r=this._pixelsToTileUnitsCache;if(r[i])return r[i];const n=function(t,i){const{scale:r}=t.tileTransform,n=r*e.EXTENT/(t.tileSize*Math.pow(2,i.zoom-t.tileID.overscaledZ+t.tileID.canonical.z));return o=new Float32Array(4),s=i.inverseAdjustmentMatrix,a=[n,n],l=s[0],c=s[1],h=s[2],u=s[3],d=a[0],p=a[1],o[0]=l*d,o[1]=c*d,o[2]=h*p,o[3]=u*p,o;var o,s,a,l,c,h,u,d,p}(t,this);return r[i]=n,r[i]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const i=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=this._camera.forward(),o=e.mercatorZfromAltitude(1,this._center.lat);r[2]/=o,n[2]/=o,e.normalize(n,n);const s=t.raycast(r,n,t.exaggeration());if(s){const t=e.scaleAndAdd([],r,n,s),i=new e.MercatorCoordinate(t[0],t[1],e.mercatorZfromAltitude(t[2],e.latFromMercatorY(t[1]))),a=[i.x-r[0],i.y-r[1],i.z-r[2]*o],l=(i.z+e.length(a))*this._projectionScaler;this._cameraZoom=this._zoomFromMercatorZ(l),this._centerAltitude=i.toAltitude(),this._center=this.coordinateLocation(i),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const t=this._elevation;this._updateCameraState();const i=e.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,r=this._computeCameraPosition(i),n=t.getAtPointOrZero(new e.MercatorCoordinate(...r)),o=this._minimumHeightOverTerrain()*Math.cos(e.degToRad(this._maxPitch)),s=this.pixelsPerMeter/this.worldSize*n,a=this._camera.position[2]-s;if(a<o){const t=this.locationCoordinate(this._center,this._centerAltitude),i=[t.x-r[0],t.y-r[1],t.z-r[2]],n=e.length(i);i[2]-=(o-a)/this._projectionScaler;const s=e.length(i);if(0===s)return;e.scale$2(i,i,n/s*this._projectionScaler),this._camera.position=[t.x-i[0],t.y-i[1],t.z*this._projectionScaler-i[2]],this._camera.orientation=tn(i,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const t=this.center;return t.lat=e.clamp(t.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(t.lng=e.clamp(t.lng,this.minLng,this.maxLng)),this.center=t,void(this._constraining=!1)}const t=this._unmodified,{x:i,y:r}=this.point;let n=0,o=i,s=r;const a=this.width/2,l=this.height/2,c=this.worldMinY*this.scale,h=this.worldMaxY*this.scale;if(r-l<c&&(s=c+l),r+l>h&&(s=h-l),h-c<this.height&&(n=Math.max(n,this.height/(h-c)),s=(h+c)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const e=this.worldMinX*this.scale,t=this.worldMaxX*this.scale,r=this.worldSize/2-(e+t)/2;(o=(i+r+this.worldSize)%this.worldSize-r)-a<e&&(o=e+a),o+a>t&&(o=t-a),t-e<this.width&&(n=Math.max(n,this.width/(t-e)),o=(t+e)/2)}o===i&&s===r||(this.center=this.unproject(new e.pointGeometry(o,s))),n&&(this.zoom+=this.scaleZoom(n)),this._constrainCameraAltitude(),this._unmodified=t,this._constraining=!1}_minZoomForBounds(){let e=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(e=Math.max(e,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),e}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this._fov/2,i=this.centerOffset,r=this.pixelsPerMeter;this._projectionScaler=r/(e.mercatorZfromAltitude(1,this.center.lat)*this.worldSize),this.cameraToCenterDistance=.5/Math.tan(t)*this.height*this._projectionScaler,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const o="meters"===this.projection.zAxisUnit?r:1,s=this._camera.getWorldToCamera(this.worldSize,o),a=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);a[8]=2*-i.x/this.width,a[9]=2*i.y/this.height;let l=e.mul([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.identity([]);e.translate(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.multiply$1(i,i,on(this)),e.translate(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.multiply$1(l,l,i),this.inverseAdjustmentMatrix=function(e){const t=on(e,!0);return n([],[t[0],t[1],t[4],t[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=e.scale([],l,[this.worldSize,this.worldSize,this.worldSize/r,1]),this.projMatrix=l,this.invProjMatrix=e.invert(new Float64Array(16),this.projMatrix);const c=new Float32Array(16);e.identity(c),e.scale(c,c,[1,-1,1]),e.rotateX(c,c,this._pitch),e.rotateZ(c,c,this.angle);const h=e.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),u=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;h[8]=2*-i.x/this.width,h[9]=2*(i.y+u)/this.height,this.skyboxMatrix=e.multiply$1(c,h,c);const d=this.point,p=d.x,f=d.y,m=this.width%2/2,_=this.height%2/2,g=Math.cos(this.angle),y=Math.sin(this.angle),x=p-Math.round(p)+g*m+y*_,v=f-Math.round(f)+g*_+y*m,b=new Float64Array(l);if(e.translate(b,b,[x>.5?x-1:x,v>.5?v-1:v,0]),this.alignedProjMatrix=b,l=e.create(),e.scale(l,l,[this.width/2,-this.height/2,1]),e.translate(l,l,[1,-1,0]),this.labelPlaneMatrix=l,l=e.create(),e.scale(l,l,[1,-1,1]),e.translate(l,l,[-1,-1,0]),e.scale(l,l,[2/this.width,2/this.height,1]),this.glCoordMatrix=l,this.pixelMatrix=e.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},!(l=e.invert(new Float64Array(16),this.pixelMatrix)))throw new Error("failed to invert matrix");this.pixelMatrixInverse=l,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,i=this.cameraPixelsPerMeter,r=this._camera.position,n=1/this.height,o=[t,t,i];e.scale$2(o,o,n),e.scale$2(r,r,-1),e.multiply$2(r,r,o);const s=e.create();e.translate(s,s,r),e.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._cameraZoom?this._cameraZoom:this._zoom,o=this._mercatorZfromZoom(n)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*o,r.y/this.worldSize-i[1]*o,e/this.worldSize*this._centerAltitude-i[2]*o]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],n=t[2];let o=1;n>0&&(o=Math.min((i-r)/n,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);e.scaleAndAdd(t,t,i,a),this._pitch=e.clamp(r,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(n,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),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._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}_terrainEnabled(){return!!this._elevation&&(!!this.projection.supportsTerrain||(e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),!1))}anyCornerOffEdge(t,i){const r=Math.min(t.x,i.x),n=Math.max(t.x,i.x),o=Math.min(t.y,i.y),s=Math.max(t.y,i.y);if(o<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const a=[new e.pointGeometry(r,o),new e.pointGeometry(n,s),new e.pointGeometry(r,s),new e.pointGeometry(n,o)],l=this.renderWorldCopies?-un:0,c=this.renderWorldCopies?1+un:1;for(const e of a){const t=this.pointRayIntersection(e);if(t.t<0)return!0;const i=this.rayIntersectionCoordinate(t);if(i.x<l||i.y<0||i.x>c||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.pointGeometry(0,0),new e.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,i){const r=e.length(e.sub([],this._camera.position,t)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){const t=this._pitch,i=Math.tan(t)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.pointGeometry(0,i))}}function fn(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class mn{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=fn(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return e.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const i=this._map.getCenter(),r=Math.round(100*this._map.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=this._map.getBearing(),c=this._map.getPitch();let h="";if(h+=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`,(l||c)&&(h+=`/${Math.round(10*l)/10}`),c&&(h+=`/${Math.round(c)}`),this._hashName){const t=this._hashName;let i=!1;const r=e.window.location.hash.slice(1).split("&").map(e=>{const r=e.split("=")[0];return r===t?(i=!0,`${r}=${h}`):e}).filter(e=>e);return i||r.push(`${t}=${h}`),`#${r.join("&")}`}return`#${h}`}_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._getCurrentHash();if(e.length>=3&&!e.some(e=>isNaN(e))){const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[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)}}const _n={linearity:.3,easing:e.bezier(0,0,.3,1)},gn=e.extend({deceleration:2500,maxSpeed:1400},_n),yn=e.extend({deceleration:20,maxSpeed:1400},_n),xn=e.extend({deceleration:1e3,maxSpeed:360},_n),vn=e.extend({deceleration:1e3,maxSpeed:90},_n);class bn{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,i=e.exported.now();for(;t.length>0&&i-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new e.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)i.zoom+=e.zoomDelta||0,i.bearing+=e.bearingDelta||0,i.pitch+=e.pitchDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=Tn(i.pan.mag(),r,e.extend({},gn,t||{}));n.offset=i.pan.mult(o.amount/i.pan.mag()),n.center=this._map.transform.center,wn(n,o)}if(i.zoom){const e=Tn(i.zoom,r,yn);n.zoom=this._map.transform.zoom+e.amount,wn(n,e)}if(i.bearing){const t=Tn(i.bearing,r,xn);n.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),wn(n,t)}if(i.pitch){const e=Tn(i.pitch,r,vn);n.pitch=this._map.transform.pitch+e.amount,wn(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),e.extend(n,{noMoveStart:!0})}}function wn(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Tn(t,i,r){const{maxSpeed:n,linearity:o,deceleration:s}=r,a=e.clamp(t*o/(i/1e3),-n,n),l=Math.abs(a)/(s*o);return{easing:r.easing,duration:1e3*l,amount:a*(l/2)}}class En extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r,n={}){const o=s.mousePos(i.getCanvasContainer(),r),a=i.unproject(o);super(t,e.extend({point:o,lngLat:a,originalEvent:r},n)),this._defaultPrevented=!1,this.target=i}}class Sn extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,r){const n="touchend"===t?r.changedTouches:r.touches,o=s.touchPos(i.getCanvasContainer(),n),a=o.map(e=>i.unproject(e)),l=o.reduce((e,t,i,r)=>e.add(t.div(r.length)),new e.pointGeometry(0,0));super(t,{points:o,point:l,lngLats:a,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}}class In extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class Mn{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new In(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new En(e.type,this._map,e))}mouseup(e){this._map.fire(new En(e.type,this._map,e))}preclick(t){const i=e.extend({},t);i.type="preclick",this._map.fire(new En(i.type,this._map,i))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new En(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new En(e.type,this._map,e))}mouseover(e){this._map.fire(new En(e.type,this._map,e))}mouseout(e){this._map.fire(new En(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Sn(e.type,this._map,e))}touchmove(e){this._map.fire(new Sn(e.type,this._map,e))}touchend(e){this._map.fire(new Sn(e.type,this._map,e))}touchcancel(e){this._map.fire(new Sn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class An{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(e){this._map.fire(new En(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new En("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new En(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Cn{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&&(s.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const r=this._startPos;this._lastPos=i,this._box||(this._box=s.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",e));const n=Math.min(r.x,i.x),o=Math.max(r.x,i.x),a=Math.min(r.y,i.y),l=Math.max(r.y,i.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${n}px,${a}px)`,this._box.style.width=`${o-n}px`,this._box.style.height=`${l-a}px`)})}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const r=this._startPos,n=i;if(this.reset(),s.suppressClick(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,n,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),s.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.Event(t,{originalEvent:i}))}}function zn(e,t){const i={};for(let r=0;r<e.length;r++)i[e[r].identifier]=t[r];return i}const kn=500,Pn=500,Dn=30;class Ln{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const i=new e.pointGeometry(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=zn(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=zn(i,t);for(const e in this.touches){const t=this.touches[e],i=r[e];(!i||i.dist(t)>Dn)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>Pn)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Bn{constructor(e){this.singleTap=new Ln(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<kn,i=!this.lastTap||this.lastTap.dist(r)<Dn;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Rn{constructor(){this._zoomIn=new Bn({numTouches:1,numTaps:2}),this._zoomOut=new Bn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{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 Fn=0,On=2,Un={[Fn]:1,[On]:2};class Vn{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const i=s.mouseButton(e);this._correctButton(e,i)&&(this._lastPoint=t,this._eventButton=i)}mousemoveWindow(e,t){const i=this._lastPoint;if(i)if(e.preventDefault(),function(e,t){const i=Un[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)<this._clickTolerance))return this._moved=!0,this._lastPoint=t,this._move(i,t)}mouseupWindow(e){if(!this._lastPoint)return;s.mouseButton(e)===this._eventButton&&(this._moved&&s.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Nn extends Vn{mousedown(e,t){super.mousedown(e,t),this._lastPoint&&(this._active=!0)}_correctButton(e,t){return t===Fn&&!e.ctrlKey}_move(e,t){return{around:t,panDelta:t.sub(e)}}}class jn extends Vn{_correctButton(e,t){return t===Fn&&e.ctrlKey||t===On}_move(e,t){const i=.8*(t.x-e.x);if(i)return this._active=!0,{bearingDelta:i}}contextmenu(e){e.preventDefault()}}class Gn extends Vn{_correctButton(e,t){return t===Fn&&e.ctrlKey||t===On}_move(e,t){const i=-.5*(t.y-e.y);if(i)return this._active=!0,{pitchDelta:i}}contextmenu(e){e.preventDefault()}}class Zn{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._minTouches=1,this._clickTolerance=i.clickTolerance||1,this.reset(),e.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new e.pointGeometry(0,0)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active&&!(i.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===i.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return e.preventDefault(),this._calculateTransform(e,t,i)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&i.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,r){r.length>0&&(this._active=!0);const n=zn(r,i),o=new e.pointGeometry(0,0),s=new e.pointGeometry(0,0);let a=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,n[e]=t)}if(this._touches=n,a<this._minTouches||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:o.div(a),panDelta:l}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=s.create("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show")},500)}}class $n{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(e){}_move(e,t,i){return{}}touchstart(e,t,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,i){if(!this._firstTwoTouches)return;e.preventDefault();const[r,n]=this._firstTwoTouches,o=qn(i,t,r),s=qn(i,t,n);if(!o||!s)return;const a=this._aroundCenter?null:o.add(s).div(2);return this._move([o,s],a,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=qn(i,t,r),a=qn(i,t,n);o&&a||(this._active&&s.suppressClick(),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 qn(e,t,i){for(let r=0;r<e.length;r++)if(e[r].identifier===i)return t[r]}const Xn=.1;function Wn(e,t){return Math.log(e/t)/Math.LN2}class Hn extends $n{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){const i=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(Wn(this._distance,this._startDistance))<Xn))return this._active=!0,{zoomDelta:Wn(this._distance,i),pinchAround:t}}}const Kn=25;function Jn(e,t){return 180*e.angleWith(t)/Math.PI}class Yn extends $n{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t){const i=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Jn(this._vector,i),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());const t=Math.PI*this._minDiameter,i=Kn/t*360,r=Jn(e,this._startVector);return Math.abs(r)<i}}function Qn(e){return Math.abs(e.y)>Math.abs(e.x)}const eo=100;class to extends $n{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(e){this._lastPoints=e,Qn(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){const r=e[0].sub(this._lastPoints[0]),n=e[1].sub(this._lastPoints[1]);if(this._map._cooperativeGestures&&i.touches.length<3)return;if(this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),!this._valid)return;this._lastPoints=e,this._active=!0;return{pitchDelta:-.5*((r.y+n.y)/2)}}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<eo&&void 0;const o=e.y>0==t.y>0;return Qn(e)&&Qn(t)&&o}}const io={panStep:100,bearingStep:15,pitchStep:10};class ro{constructor(){const e=io;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,i=0,r=0,n=0,o=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?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:no,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent: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 no(e){return e*(2-e)}const oo=4.000244140625,so=.01,ao=1/450,lo=2;class co{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=so,this._wheelZoomRate=ao,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen"],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()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.exported.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%oo==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),t.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=t,this._delta-=i,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=s.mousePos(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,i=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>oo?this._wheelZoomRate:this._defaultZoomRate;let r=lo/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=i(),this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.number(n,r,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=r,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.ease;if(this._prevEase){const t=this._prevEase,r=(e.exported.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.bezier(o,s,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=s.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),/(Mac|iPad)/i.test(e.window.navigator.userAgent)?this._alertContainer.textContent=this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._alertContainer.textContent=this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!e.window.document.fullscreenElement}_showBlockerAlert(){"hidden"===this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="visible"),this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show")},200)}}class ho{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 uo{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(e.shiftKey?-1:1),around:i.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class po{constructor(){this._tap=new Bn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(e,t,i){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>kn&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=t[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(e,t,i))}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{this._tap.touchend(e,t,i)&&(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 fo{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}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 mo{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class _o{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,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 go=e=>e.zoom||e.drag||e.pitch||e.rotate;class yo extends e.Event{}class xo{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const r=e.sub([],i,t);r[2]<0?this.radius=e.length(e.div([],r,this.constants)):this.radius=e.length([r[0],r[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const i=e.scale$2([],t,this.radius);if(i[2]>0){const t=e.scale$2([],[0,0,1],e.dot(i,[0,0,1])),r=e.scale$2([],e.normalize([],[i[0],i[1],0]),this.radius),n=e.add([],i,e.scale$2([],e.sub([],e.add([],r,t),i),2));i[0]=n[0],i[1]=n[1]}return i}}function vo(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class bo{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new bn(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new xo,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[t,i,r]of this._listeners){const n=t===e.window.document?this.handleWindowEvent:this.handleEvent;t.addEventListener(i,n,r)}}destroy(){for(const[t,i,r]of this._listeners){const n=t===e.window.document?this.handleWindowEvent:this.handleEvent;t.removeEventListener(i,n,r)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Mn(t,e));const r=t.boxZoom=new Cn(t,e);this._add("boxZoom",r);const n=new Rn,o=new uo;t.doubleClickZoom=new ho(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new po;this._add("tapDragZoom",s);const a=t.touchPitch=new to(t);this._add("touchPitch",a);const l=new jn(e),c=new Gn(e);t.dragRotate=new mo(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Nn(e),u=new Zn(t,e);t.dragPan=new fo(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const d=new Yn,p=new Hn;t.touchZoomRotate=new _o(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new An(t));const f=t.scrollZoom=new co(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new ro;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,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),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 Boolean(go(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,`${e.type}Window`)}_getMapTouches(e){const t=[];for(const i of e){const e=i.target;this._el.contains(e)&&t.push(i)}return t}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},a={},l=e.touches?this._getMapTouches(e.touches):void 0,c=l?s.touchPos(this._el,l):i?void 0:s.mousePos(this._el,e);for(const{handlerName:i,handler:s,allowed:h}of this._handlers){if(!s.isEnabled())continue;let u;this._blockedByActive(a,h,i)?s.reset():s[t||e.type]&&(u=s[t||e.type](e,c,l),this.mergeHandlerResult(n,o,u,i,r),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||s.isActive())&&(a[i]=s)}const h={};for(const e in this._previousActiveHandlers)a[e]||(h[e]=r);this._previousActiveHandlers=a,(Object.keys(h).length||vo(n))&&(this._changes.push([n,o,h]),this._triggerRenderFrame()),(Object.keys(a).length||vo(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(t,i,r,n,o){if(!r)return;e.extend(t,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.pointGeometry(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),e.extend(i,o),e.extend(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress[e];return t&&!this._handlersById[t.handlerName].isActive()})("drag")&&!vo(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(!vo(t))return this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,aroundCoord:d,pinchAround:p}=t;void 0!==p&&(u=p),(e=>{return i[e]&&!this._eventsInProgress[e]})("drag")&&u&&(this._dragOrigin=s(o.pointCoordinate3D(u)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),u=u||n.transform.centerPoint,c&&(o.bearing+=c),h&&(o.pitch+=h),o._updateCameraState();const f=[0,0,0];if(a){const e=o.pointCoordinate(u),t=o.pointCoordinate(u.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}const m=o.zoom,_=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(u)),i={dir:e.normalize([],e.sub([],t,o._camera.position))};if(i.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.scale$2(_,i.dir,r)}}const g=e.add(f,f,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(i,r,!0)}_fireEvents(t,i,r){const n=go(this._eventsInProgress),o=go(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const a={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||r,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=go(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap<e&&e<this._bearingSnap;t?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),this._map.easeTo(t,{originalEvent:l})):(this._map.fire(new e.Event("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.Event(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(e=>{delete this._frameId,this.handleEvent(new yo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const wo="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class To extends e.Evented{constructor(t,i){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,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,i,r){return t=e.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},i),r)}panTo(t,i,r){return this.easeTo(e.extend({center:t},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,i,r){return this.easeTo(e.extend({zoom:t},i),r)}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,i,r){return this.easeTo(e.extend({bearing:t},i),r)}resetNorth(t,i){return this.rotateTo(0,e.extend({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}cameraForBounds(t,i){t=e.LngLatBounds.convert(t);const r=i&&i.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),r,i)}_extendCameraOptions(t){const i={top:0,bottom:0,right:0,left:0};if("number"==typeof(t=e.extend({padding:i,offset:[0,0],maxZoom:this.transform.maxZoom},t)).padding){const e=t.padding;t.padding={top:e,bottom:e,right:e,left:e}}return t.padding=e.extend(i,t.padding),t}_cameraForBoxAndBearing(t,i,r,n){const o=this._extendCameraOptions(n),s=this.transform,a=s.padding,l=s.project(e.LngLat.convert(t)),c=s.project(e.LngLat.convert(i)),h=l.rotate(-e.degToRad(r)),u=c.rotate(-e.degToRad(r)),d=new e.pointGeometry(Math.max(h.x,u.x),Math.max(h.y,u.y)),p=new e.pointGeometry(Math.min(h.x,u.x),Math.min(h.y,u.y)),f=d.sub(p),m=(s.width-(a.left+a.right+o.padding.left+o.padding.right))/f.x,_=(s.height-(a.top+a.bottom+o.padding.top+o.padding.bottom))/f.y;if(_<0||m<0)return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const g=Math.min(s.scaleZoom(s.scale*Math.min(m,_)),o.maxZoom),y="number"==typeof o.offset.x?new e.pointGeometry(o.offset.x,o.offset.y):e.pointGeometry.convert(o.offset),x=(o.padding.left-o.padding.right)/2,v=(o.padding.top-o.padding.bottom)/2,b=new e.pointGeometry(x,v).rotate(r*Math.PI/180),w=y.add(b).mult(s.scale/s.zoomScale(g));return{center:s.unproject(l.add(c).div(2).sub(w)),zoom:g,bearing:r}}_cameraForBox(t,i,r,n,o){const s=this._extendCameraOptions(o);r=r||0,n=n||0,t=e.LngLat.convert(t),i=e.LngLat.convert(i);const a=this.transform.clone();a.padding=s.padding;const l=this.getFreeCameraOptions(),c=new e.LngLat(.5*(t.lng+i.lng),.5*(t.lat+i.lat)),h=.5*(r+n);if(a._camera.position[2]<e.mercatorZfromAltitude(h,c.lat))return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");l.lookAtPoint(c),a.setFreeCameraOptions(l);const u=e.MercatorCoordinate.fromLngLat(t),d=e.MercatorCoordinate.fromLngLat(i),p=a.pointRayIntersection(a.centerPoint,h),f=(e=>[e.x,e.y,e.z])(a.rayIntersectionCoordinate(p)),m=a.screenPointToMercatorRay(a.centerPoint),_="globe"!==a.projection.name;let g,y=0;do{const t=Math.floor(a.zoom),i=1<<t,o=Math.min(i*u.x,i*d.x),s=Math.min(i*u.y,i*d.y),l=Math.max(i*u.x,i*d.x),c=Math.max(i*u.y,i*d.y),h=new e.Aabb([o,s,r],[l,c,n]),p=e.Frustum.fromInvProjectionMatrix(a.invProjMatrix,a.worldSize,t,_);if(2!==h.intersects(p)){g&&(a._camera.position=e.scaleAndAdd([],a._camera.position,m.dir,-g),a._updateStateFromCamera());break}const y=e.sub([],a._camera.position,f);g=.5*e.length(y),a._camera.position=e.scaleAndAdd([],a._camera.position,m.dir,g);try{a._updateStateFromCamera()}catch(t){return void e.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++y<10);return{center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch}}fitBounds(e,t,i){return this._fitInternal(this.cameraForBounds(e,t),t,i)}_raycastElevationBox(t,i){const r=this.transform.elevation;if(!r)return;const n=new e.pointGeometry(t.x,i.y),o=new e.pointGeometry(i.x,t.y),s=r.pointCoordinate(t);if(!s)return;const a=r.pointCoordinate(i);if(!a)return;const l=r.pointCoordinate(n);if(!l)return;const c=r.pointCoordinate(o);if(!c)return;const h=new e.MercatorCoordinate(s[0],s[1]).toLngLat(),u=new e.MercatorCoordinate(a[0],a[1]).toLngLat(),d=new e.MercatorCoordinate(l[0],l[1]).toLngLat(),p=new e.MercatorCoordinate(c[0],c[1]).toLngLat(),f=Math.min(h.lng,Math.min(u.lng,Math.min(d.lng,p.lng))),m=Math.min(h.lat,Math.min(u.lat,Math.min(d.lat,p.lat))),_=Math.max(h.lng,Math.max(u.lng,Math.max(d.lng,p.lng))),g=Math.max(h.lat,Math.max(u.lat,Math.max(d.lat,p.lat))),y=Math.min(s[3],Math.min(a[3],Math.min(l[3],c[3]))),x=Math.max(s[3],Math.max(a[3],Math.max(l[3],c[3])));return{minLngLat:new e.LngLat(f,m),maxLngLat:new e.LngLat(_,g),minAltitude:y,maxAltitude:x}}fitScreenCoordinates(t,i,r,n,o){let s,a,l,c;const h=e.pointGeometry.convert(t),u=e.pointGeometry.convert(i),d=this._raycastElevationBox(h,u);if(d)s=d.minLngLat,a=d.maxLngLat,l=d.minAltitude,c=d.maxAltitude;else{if(this.transform.anyCornerOffEdge(h,u))return this;s=this.transform.pointLocation(h),a=this.transform.pointLocation(u)}return 0===this.transform.pitch?this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(e.pointGeometry.convert(t)),this.transform.pointLocation(e.pointGeometry.convert(i)),r,n),n,o):this._fitInternal(this._cameraForBox(s,a,l,c,n),n,o)}_fitInternal(t,i,r){return t?(delete(i=e.extend(t,i)).padding,i.linear?this.easeTo(i,r):this.flyTo(i,r)):this}jumpTo(t,i){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(n=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.LngLat.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(s=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.Event("movestart",i)).fire(new e.Event("move",i)),n&&this.fire(new e.Event("zoomstart",i)).fire(new e.Event("zoom",i)).fire(new e.Event("zoomend",i)),o&&this.fire(new e.Event("rotatestart",i)).fire(new e.Event("rotate",i)).fire(new e.Event("rotateend",i)),s&&this.fire(new e.Event("pitchstart",i)).fire(new e.Event("pitch",i)).fire(new e.Event("pitchend",i)),this.fire(new e.Event("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(wo),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const r=this.transform;if(!r.projection.supportsFreeCamera)return void e.warnOnce(wo);this.stop();const n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(t);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new e.Event("movestart",i)).fire(new e.Event("move",i)),a&&this.fire(new e.Event("zoomstart",i)).fire(new e.Event("zoom",i)).fire(new e.Event("zoomend",i)),c&&this.fire(new e.Event("rotatestart",i)).fire(new e.Event("rotate",i)).fire(new e.Event("rotateend",i)),l&&this.fire(new e.Event("pitchstart",i)).fire(new e.Event("pitch",i)).fire(new e.Event("pitchend",i)),this.fire(new e.Event("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||!t.essential&&e.exported.prefersReducedMotion)&&(t.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,h="pitch"in t?+t.pitch:s,u="padding"in t?t.padding:r.padding,d=e.pointGeometry.convert(t.offset);let p=r.centerPoint.add(d);const f="globe"===r.projection.name?r.pointCoordinate(p).toLngLat():r.pointLocation(p),m=e.LngLat.convert(t.center||f);this._normalizeCenter(m);const _=r.project(f),g=r.project(m).sub(_),y=r.zoomScale(l-n);let x,v;t.around&&(x=e.LngLat.convert(t.around),v=r.locationPoint(x));const b=this._zooming||l!==n,w=this._rotating||o!==c,T=this._pitching||h!==s,E=!r.isPaddingEqual(u),S=r=>f=>{if(b&&(r.zoom=e.number(n,l,f)),w&&(r.bearing=e.number(o,c,f)),T&&(r.pitch=e.number(s,h,f)),E&&(r.interpolatePadding(a,u,f),p=r.centerPoint.add(d)),x)r.setLocationAtPoint(x,v);else{const e=r.zoomScale(r.zoom-n),t=l>n?Math.min(2,y):Math.max(.5,y),i=Math.pow(t,1-f),o=r.unproject(_.add(g.mult(f*i)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(S,t.duration,r);return this._preloadTiles(e),this}const I={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=b,this._rotating=w,this._pitching=T,this._padding=E,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,I),this._ease(S(r),e=>{r.recenterOnTerrain(),this._afterEase(i,e)},t),this}_prepareEase(t,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||r.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!r.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,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.Event("zoomend",t)),n&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,i){if(!t.essential&&e.exported.prefersReducedMotion){const r=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,r.minZoom,r.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,h="pitch"in t?+t.pitch:s,u="padding"in t?t.padding:r.padding,d=r.zoomScale(l-n),p=e.pointGeometry.convert(t.offset);let f=r.centerPoint.add(p);const m=r.pointLocation(f),_=e.LngLat.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let x=t.curve;const v=Math.max(r.width,r.height),b=v/d,w=y.mag();if("minZoom"in t){const i=e.clamp(Math.min(t.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);x=Math.sqrt(o/w*2)}const T=x*x;function E(e){const t=(b*b-v*v+(e?-1:1)*T*T*w*w)/(2*(e?b:v)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function I(e){return(Math.exp(e)+Math.exp(-e))/2}const M=E(0);let A=function(e){return I(M)/I(M+x*e)},C=function(e){return v*((I(M)*(S(t=M+x*e)/I(t))-S(M))/T)/w;var t},z=(E(1)-M)/x;if(Math.abs(w)<1e-6||!isFinite(z)){if(Math.abs(v-b)<1e-6)return this.easeTo(t,i);const e=b<v?-1:1;z=Math.abs(Math.log(b/v))/x,C=function(){return 0},A=function(t){return Math.exp(e*x*t)}}if("duration"in t)t.duration=+t.duration;else{const e="screenSpeed"in t?+t.screenSpeed/x:+t.speed;t.duration=1e3*z/e}t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0);const k=o!==c,P=h!==s,D=!r.isPaddingEqual(u),L=r=>d=>{const m=d*z,x=1/A(m);r.zoom=1===d?l:n+r.scaleZoom(x),k&&(r.bearing=e.number(o,c,d)),P&&(r.pitch=e.number(s,h,d)),D&&(r.interpolatePadding(a,u,d),f=r.centerPoint.add(p));const v=1===d?_:r.unproject(g.add(y.mult(C(m))).mult(x));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCenterElevation(),t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(L,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=k,this._pitching=P,this._padding=D,this._prepareEase(i,!1),this._ease(L(r),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=e.exported.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,i){t=e.wrap(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)<r&&(t-=360),Math.abs(t+360-i)<r&&(t+=360),t}_normalizeCenter(e){const t=this.transform;if(!t.renderWorldCopies||t.maxBounds)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}}class Eo{constructor(t={}){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=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=s.create("button","mapboxgl-ctrl-attrib-button",this._container),s.create("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden",!0),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=s.create("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 i=this._map._getUIString(`AttributionControl.${t}`);e.setAttribute("aria-label",i),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}_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 i=[{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 r=i.reduce((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${r<i.length-1?"&":""}`),e),"?");t.href=`${e.config.FEEDBACK_URL}/${r}${this._map._hash?this._map._hash.getHashString(!0):""}`,t.rel="noopener nofollow",this._setElementTitle(t,"MapFeedback")}}_updateData(e){!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let e=[];if(this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style._sourceCaches;for(const i in t){const r=t[i];if(r.used){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let r=i+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class So{constructor(){e.bindAll(["_updateLogo"],this),e.bindAll(["_updateCompact"],this)}onAdd(e){this._map=e,this._container=s.create("div","mapboxgl-ctrl");const t=s.create("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 i=e[t].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.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 Io{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,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Mo(t,i,r){if(t=new e.LngLat(t.lng,t.lat),i){const n=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),s=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),a=r.locationPoint(t).distSqr(i),l=i.x<0||i.y<0||i.x>r.width||i.y>r.height;r.locationPoint(n).distSqr(i)<a&&(l||Math.abs(n.lng-r.center.lng)<s)?t=n:r.locationPoint(o).distSqr(i)<a&&(l||Math.abs(o.lng-r.center.lng)<s)&&(t=o)}for(;Math.abs(t.lng-r.center.lng)>180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const Ao={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%)"},Co=.2;class zo extends e.Evented{constructor(t,i){if(super(),(t instanceof e.window.HTMLElement||i)&&(t=e.extend({element:t},i)),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&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this._updateMoving=(()=>this._update(!0)),t&&t.element)this._element=t.element,this._offset=e.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create("div");const i=41,r=27,n=s.createSVG("svg",{display:"block",height:`${i*this._scale}px`,width:`${r*this._scale}px`,viewBox:`0 0 ${r} ${i}`},this._element),o=s.createSVG("radialGradient",{id:"shadowGradient"},s.createSVG("defs",{},n));s.createSVG("stop",{offset:"10%","stop-opacity":.4},o),s.createSVG("stop",{offset:"100%","stop-opacity":.05},o),s.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},n),s.createSVG("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"},n),s.createSVG("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"},n),s.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},n),this._offset=e.pointGeometry.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 r=this._element.classList;for(const e in Ao)r.remove(`mapboxgl-marker-anchor-${e}`);r.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(e){return e===this._map?this:(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(),this._map.on("click",this._onMapClick),this)}remove(){return this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._updateMoving),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._map.off("remove",this._clearFadeTimer),this._map._removeMarker(this),delete this._map),this._clearFadeTimer(),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,i=13.5,r=Math.sqrt(Math.pow(i,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,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,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.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")):(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_evaluateOpacity(){const e=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(e))return void this._clearFadeTimer();const t=this._map.unproject(e);let i=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const e=this._map.getFreeCameraOptions();if(e.position){const r=e.position.toLngLat();i=r.distanceTo(t)<.9*r.distanceTo(this._lngLat)}}const r=(1-this._map._queryFogOpacity(t))*(i?Co:1);this._element.style.opacity=`${r}`,this._popup&&this._popup._setOpacity(`${r}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(e){const t=this._map.transform;return!!e&&e.x>=0&&e.x<t.width&&e.y>=0&&e.y<t.height}_updateDOM(){const t=this._pos||new e.pointGeometry(0,0),i=this._calculatePitch(),r=this._calculateRotation();this._element.style.transform=`${Ao[this._anchor]} translate(${t.x}px, ${t.y}px) rotateX(${i}deg) rotateZ(${r}deg)`}_calculatePitch(){return"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?0:"map"===this._pitchAlignment?this._map.getPitch():0}_calculateRotation(){return"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?this._rotation:"map"===this._rotationAlignment?this._rotation-this._map.getBearing():0}_update(t){e.window.cancelAnimationFrame(this._updateFrameId),this._map&&(this._map.transform.renderWorldCopies&&(this._lngLat=Mo(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._transformedOffset()),!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(),this._map._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),!this._map.getTerrain()&&!this._map.getFog()||this._fadeTimer||(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}_transformedOffset(){if(!this._defaultMarker)return this._offset;const e=this._map.transform,t=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&t._rotate(e.angle),"map"===this._pitchAlignment&&(t.y*=Math.cos(e._pitch)),t}getOffset(){return this._offset}setOffset(t){return this._offset=e.pointGeometry.convert(t),this._update(),this}_onMove(t){if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.Event("dragstart"))),this.fire(new e.Event("drag")))}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e.Event("dragend")),this._state="inactive"}_addDragHandler(e){this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}class ko{constructor(e){this.jumpTo(e)}getValue(t){if(t<=this._startTime)return this._start;if(t>=this._endTime)return this._end;const i=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}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,i){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+i}}const Po={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},{HTMLImageElement:Do,HTMLElement:Lo,ImageBitmap:Bo}=e.window,Ro=500,Fo=300,Oo=1,Uo=1e-4,Vo=-2,No=22,jo=0,Go=85,Zo={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:Vo,maxZoom:No,minPitch:jo,maxPitch:Go,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function $o(e){e.parentNode&&e.parentNode.removeChild(e)}const qo={showCompass:!0,showZoom:!0,visualizePitch:!1};class Xo{constructor(t,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new jn({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new Gn({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),s.disableDrag()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}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(){s.enableDrag(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),s.mousePos(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,s.mousePos(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=s.touchPos(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=s.touchPos(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)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const Wo={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1};let Ho;let Ko=0,Jo=!1;const Yo={maxWidth:100,unit:"metric"};function Qo(e,t,i){const r=i&&i.maxWidth||100,n=e._containerHeight/2,o=e.unproject([0,n]),s=e.unproject([r,n]),a=o.distanceTo(s);if(i&&"imperial"===i.unit){const i=3.2808*a;if(i>5280){es(t,r,i/5280,e._getUIString("ScaleControl.Miles"),e)}else es(t,r,i,e._getUIString("ScaleControl.Feet"),e)}else if(i&&"nautical"===i.unit){es(t,r,a/1852,e._getUIString("ScaleControl.NauticalMiles"),e)}else a>=1e3?es(t,r,a/1e3,e._getUIString("ScaleControl.Kilometers"),e):es(t,r,a,e._getUIString("ScaleControl.Meters"),e)}function es(e,t,i,r,n){const o=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i),s=o/i;n._requestDomTask(()=>{e.style.width=`${t*s}px`,e.innerHTML=`${o}&nbsp;${r}`})}const ts={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},is=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");const rs={version:e.version,supported:t,setRTLTextPlugin:e.setRTLTextPlugin,getRTLTextPluginStatus:e.getRTLTextPluginStatus,Map:class extends To{constructor(t){if(null!=(t=e.extend({},Zo,t)).minZoom&&null!=t.maxZoom&&t.minZoom>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<jo)throw new Error(`minPitch must be greater than or equal to ${jo}`);if(null!=t.maxPitch&&t.maxPitch>Go)throw new Error(`maxPitch must be less than or equal to ${Go}`);if(super(new pn(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._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._renderTaskQueue=new Io,this._domRenderTaskQueue=new Io,this._controls=[],this._markers=[],this._mapId=e.uniqueId(),this._locale=e.extend({},Po,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new ko(0),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 '${t.container}' not found.`)}else{if(!(t.container instanceof Lo))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","_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)),this.handlers=new bo(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);const i="string"==typeof t.hash&&t.hash||void 0;this._hash=t.hash&&new mn(i).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 Eo({customAttribution:t.customAttribution})),this._logoControl=new So,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(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.Event(`${t.dataType}dataloading`,t))})}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(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 i=!this._moving;return i&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),i&&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?Vo:t)>=Vo&&t<=this.transform.maxZoom)return this.transform.minZoom=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(`minZoom must be between ${Vo} and the current maxZoom, inclusive`)}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?No:t)>=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?jo:t)<jo)throw new Error(`minPitch must be greater than or equal to ${jo}`);if(t>=jo&&t<=this.transform.maxPitch)return this.transform.minPitch=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(`minPitch must be between ${jo} and the current maxPitch, inclusive`)}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?Go:t)>Go)throw new Error(`maxPitch must be less than or equal to ${Go}`);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 the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this._update()}getProjection(){return this.transform.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),"string"==typeof e&&(e={name:e}),this._runtimeProjection=e,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.pointGeometry.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter(e=>this.getLayer(e)),s=o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new En(e,this,n.originalEvent,{features:s}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter(e=>this.getLayer(e));(o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new En(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new En(e,this,t.originalEvent)))};return{layers:new Set(t),listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),n=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:new Set(t),listener:i,delegates:{[e]:r}}}}on(e,t,i){if(void 0===i)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,i){if(void 0===i)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){if(void 0===i)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const i of e)if(!t.has(i))return!1;return!0},n=e=>{for(let n=0;n<e.length;n++){const o=e[n];if(o.listener===i&&r(o.layers,t)){for(const e in o.delegates)this.off(e,o.delegates[e]);return e.splice(n,1),this}}},o=this._delegatedListeners?this._delegatedListeners[e]:void 0;return o&&n(o),this}queryRenderedFeatures(t,i){return this.style?(void 0!==i||void 0===t||t instanceof e.pointGeometry||Array.isArray(t)||(i=t,t=void 0),i=i||{},t=t||[[0,0],[this.transform.width,this.transform.height]],this.style.queryRenderedFeatures(t,i,this.transform)):[]}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}queryTerrainElevation(t,i){const r=this.transform.elevation;return r?(i=e.extend({},{exaggerated:!0},i),r.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,i.exaggerated)):null}setStyle(t,i){return!1!==(i=e.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&i.localFontFamily===this._localFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,this._updateStyle(t,i))}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){return this.style&&(this.style.setEventedParent(null),this.style._remove(),delete this.style),e&&(this.style=new Ht(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e):this.style.loadJSON(e)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ht(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){const r=this._requestManager.normalizeStyleURL(t),n=this._requestManager.transformRequest(r,e.ResourceType.Style);e.getJSON(n,(t,r)=>{t?this.fire(new e.ErrorEvent(t)):r&&this._updateDiff(r,i)})}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t)&&this._update(!0)}catch(r){e.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.warnOnce("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(t){const i=this.style&&this.style._getSourceCaches(t);if(0!==i.length)return i.every(e=>e.loaded());this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`)))}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const i=e[t]._tiles;for(const e in i){const t=i[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,i){return this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,i,{pixelRatio:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof Do||Bo&&i instanceof Bo){const{width:l,height:c,data:h}=e.exported.getImageData(i);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},h),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0})}else{if(void 0===i.width||void 0===i.height)return this.fire(new 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`")));{const{width:l,height:c,data:h}=i,u=i;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:c},new Uint8Array(h)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,userImage:u}),u.onAdd&&u.onAdd(this,t)}}}updateImage(t,i){const r=this.style.getImage(t);if(!r)return 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 n=i instanceof Do||Bo&&i instanceof Bo?e.exported.getImageData(i):i,{width:o,height:s,data:a}=n;if(void 0===o||void 0===s)return 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`")));if(o!==r.data.width||s!==r.data.height)return this.fire(new e.ErrorEvent(new Error("The width and height of the updated image must be that same as the previous version of the image")));const l=!(i instanceof Do||Bo&&i instanceof Bo);r.data.replace(a,l),this.style.updateImage(t,r)}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,i){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),(t,r)=>{i(t,r instanceof Do?e.exported.getImageData(r):r)})}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,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){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)}_updateProjection(){const t=this.transform.projection,i=this.transform.zoom;"globe"===t.name&&i>=e.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe?(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0):this._transitionFromGlobe&&i<e.GLOBE_ZOOM_THRESHOLD_MAX&&this.setProjection({name:"globe"})}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,i=this._container.getBoundingClientRect().height||300;let r,n=this._container;for(;n&&!r;){const t=e.window.getComputedStyle(n).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", ")),n=n.parentElement}r?(this._containerWidth=r[0]&&"0"!==r[0]?Math.abs(t/r[0]):t,this._containerHeight=r[3]&&"0"!==r[3]?Math.abs(i/r[3]):i):(this._containerWidth=t,this._containerHeight=i)}_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=s.create("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=s.create("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=s.create("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","Map"),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=s.create("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=s.create("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const r=e.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(i),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${i}px`}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_setupPainter(){const i=e.extend({},t.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",i)||this._canvas.getContext("experimental-webgl",i);r?(e.storeAuthState(r,!0),this.painter=new Kr(r,this.transform),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.exported$1.testSupport(r)):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 i;const r=this.painter.context.extTimerQuery,n=e.exported.now();this.listens("gpu-timing-frame")&&(i=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,i));let o=this._updateAverageElevation(n);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjection();let s=!1;const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,r=e.exported.now();this.style.zoomHistory.update(t,r);const n=new e.EvaluationParameters(t,{now:r,fadeDuration:a,pitch:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=n.crossFadingFactor();1===o&&o===this._crossFadingFactor||(s=!0,this._crossFadingFactor=o),this.style.update(n)}if(this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0),this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),this.style._updateSources(this.transform),this._forceMarkerUpdate()),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&(this.style.hasTransitions()||s)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const t=e.exported.now()-n;r.endQueryEXT(r.TIME_ELAPSED_EXT,i),setTimeout(()=>{const n=r.getQueryObjectEXT(i,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(i),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:n}))},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:i}))},50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||o;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(o=this._updateAverageElevation(n,!0)),o)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}}return!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const e of this._markers)e._update()}_updateAverageElevation(e,t=!1){const i=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((t||e-this._averageElevationLastSampledAt>Ro)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation();isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const n=Math.abs(t-r);if(n>Oo){if(this._isInitialLoad)return this._averageElevation.jumpTo(r),i(r);this._averageElevation.easeTo(r,e,Fo)}else if(n>Uo)return this._averageElevation.jumpTo(r),i(r)}return!!this._averageElevation.isEasing(e)&&i(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 So&&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(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const i=this.painter.context.gl,r=i.createFramebuffer();function n(e){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0);const t=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,t),t}return i.bindFramebuffer(i.FRAMEBUFFER,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o<t.length;o++){const s=t[o];let a=0;for(let t=0;t<s.length;t+=4)s[t]===e[t]&&s[t+1]===e[t+1]&&s[t+2]===e[t+2]&&s[t+3]===e[t+3]&&(a+=1);r+=(i[o+2]-i[o+1])*(1-a/n)}return r}remove(){this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),void 0!==e.window&&(e.window.removeEventListener("resize",this._onWindowResize,!1),e.window.removeEventListener("orientationchange",this._onWindowResize,!1),e.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.removeEventListener("online",this._onWindowOnline,!1));const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),$o(this._canvasContainer),$o(this._controlContainer),$o(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),e.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new e.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(t){this._renderNextFrame=this._renderNextFrame||t,this.style&&!this._frame&&(this._frame=e.exported.frame(e=>{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const i=this.style&&Object.values(this.style._sourceCaches)||[];return e.asyncAll(i,(e,i)=>e._preloadTiles(t,i),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}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()}_setCacheLimits(t,i){e.setCacheLimits(t,i)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},qo,t),this._container=s.create("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.zoomIn({},{originalEvent:e})),s.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),s.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=s.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())}_rotateCompassArrow(){const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._map._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=e)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Xo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=s.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_setButtonTitle(e,t){const i=this._map._getUIString(`NavigationControl.${t}`);e.setAttribute("aria-label",i),e.firstElementChild&&e.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({},Wo,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation"],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=fn(this._updateMarkerRotation,20)}onAdd(t){var i;return this._map=t,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),i=this._setupUI,void 0!==Ho?i(Ho):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then(e=>{Ho="denied"!==e.state,i(Ho)}):(Ho=!!e.window.navigator.geolocation,i(Ho)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(e.window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,Ko=0,Jo=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitude<t.getWest()||i.longitude>t.getEast()||i.latitude<t.getSouth()||i.latitude>t.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 i=new e.LngLat(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=e.extend({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map._containerHeight/2,t=this._map.unproject([0,e]),i=this._map.unproject([100,e]),r=t.distanceTo(i)/100,n=Math.ceil(2*this._accuracy/r);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_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&&Jo)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(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=s.create("button","mapboxgl-ctrl-geolocate",this._container),s.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),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=s.create("div","mapboxgl-user-location"),this._dotElement.appendChild(s.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(s.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new zo({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=s.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new zo({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=>{const i=t.originalEvent&&"resize"===t.originalEvent.type;t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||(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":Ko--,Jo=!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 t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++Ko>1?(t={maximumAge:6e5,timeout:0},Jo=!0):(t=this.options.positionOptions,Jo=!1),this._geolocationWatchID=e.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else e.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{"ondeviceorientationabsolute"in e.window?e.window.addEventListener("deviceorientationabsolute",this._onDeviceOrientationListener):e.window.addEventListener("deviceorientation",this._onDeviceOrientationListener)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&t()}).catch(console.error):t()}_clearWatch(){e.window.navigator.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),e.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientationListener),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:Eo,ScaleControl:class{constructor(t){this.options=e.extend({},Yo,t),e.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){Qo(this._map,this._container,this.options)}onAdd(e){return this._map=e,this._container=s.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}setUnit(e){this.options.unit=e,Qo(this._map,this._container,this.options)}},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=s.create("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=s.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);s.create("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden",!0),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(ts),t),e.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag"],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&&this._map.on("preclick",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")):this._map.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){return this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),delete this._map),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._map._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._map._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const i=e.window.document.createDocumentFragment(),r=e.window.document.createElement("body");let n;for(r.innerHTML=t;n=r.firstChild;)i.appendChild(n);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=s.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._container&&this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._container&&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._container&&this._updateClassList(),t}_createCloseButton(){this.options.closeButton&&(this._closeButton=s.create("button","mapboxgl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.setAttribute("aria-hidden","true"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(e){this._update(e.point)}_onMouseMove(e){this._update(e.point)}_onDrag(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._pos,i=this._container.offsetWidth,r=this._container.offsetHeight;let n;return n=t.y+e.bottom.y<r?["top"]:t.y>this._map.transform.height-r?["bottom"]:[],t.x<i/2?n.push("left"):t.x>this._map.transform.width-i/2&&n.push("right"),0===n.length?"bottom":n.join("-")}_updateClassList(){const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),this._container.className=e.join(" ")}_update(t){const i=this._lngLat||this._trackPointer;if(this._map&&i&&this._content){if(this._container||(this._container=s.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=s.create("div","m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment