mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 22:56:11 +03:00
61 lines
889 KiB
JavaScript
61 lines
889 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[634],{6158:function(b,c,a){var d=a(3454);!function(c,a){b.exports=a()}(this,function(){"use strict";var c,e,b;function a(g,a){if(c){if(e){var f="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 = {}; ("+c+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",d={};c(d),b=a(d),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(b.workerUrl=window.URL.createObjectURL(new Blob([f],{type:"text/javascript"})))}else e=a}else c=a}return a(["exports"],function(a){var bq="2.7.0",eG=H;function H(a,c,d,b){this.cx=3*a,this.bx=3*(d-a)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*c,this.by=3*(b-c)-this.cy,this.ay=1-this.cy-this.by,this.p1x=a,this.p1y=b,this.p2x=d,this.p2y=b}H.prototype.sampleCurveX=function(a){return((this.ax*a+this.bx)*a+this.cx)*a},H.prototype.sampleCurveY=function(a){return((this.ay*a+this.by)*a+this.cy)*a},H.prototype.sampleCurveDerivativeX=function(a){return(3*this.ax*a+2*this.bx)*a+this.cx},H.prototype.solveCurveX=function(c,e){var b,d,a,f,g;for(void 0===e&&(e=1e-6),a=c,g=0;g<8;g++){if(Math.abs(f=this.sampleCurveX(a)-c)<e)return a;var h=this.sampleCurveDerivativeX(a);if(1e-6>Math.abs(h))break;a-=f/h}if((a=c)<(b=0))return b;if(a>(d=1))return d;for(;b<d&&!(Math.abs((f=this.sampleCurveX(a))-c)<e);)c>f?b=a:d=a,a=.5*(d-b)+b;return a},H.prototype.solve=function(a,b){return this.sampleCurveY(this.solveCurveX(a,b))};var aF=aG;function aG(a,b){this.x=a,this.y=b}aG.prototype={clone:function(){return new aG(this.x,this.y)},add:function(a){return this.clone()._add(a)},sub:function(a){return this.clone()._sub(a)},multByPoint:function(a){return this.clone()._multByPoint(a)},divByPoint:function(a){return this.clone()._divByPoint(a)},mult:function(a){return this.clone()._mult(a)},div:function(a){return this.clone()._div(a)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,b){return this.clone()._rotateAround(a,b)},matMult:function(a){return this.clone()._matMult(a)},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(a){return this.x===a.x&&this.y===a.y},dist:function(a){return Math.sqrt(this.distSqr(a))},distSqr:function(a){var b=a.x-this.x,c=a.y-this.y;return b*b+c*c},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(a){return Math.atan2(this.y-a.y,this.x-a.x)},angleWith:function(a){return this.angleWithSep(a.x,a.y)},angleWithSep:function(a,b){return Math.atan2(this.x*b-this.y*a,this.x*a+this.y*b)},_matMult:function(a){var b=a[2]*this.x+a[3]*this.y;return this.x=a[0]*this.x+a[1]*this.y,this.y=b,this},_add:function(a){return this.x+=a.x,this.y+=a.y,this},_sub:function(a){return this.x-=a.x,this.y-=a.y,this},_mult:function(a){return this.x*=a,this.y*=a,this},_div:function(a){return this.x/=a,this.y/=a,this},_multByPoint:function(a){return this.x*=a.x,this.y*=a.y,this},_divByPoint:function(a){return this.x/=a.x,this.y/=a.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var a=this.y;return this.y=this.x,this.x=-a,this},_rotate:function(a){var b=Math.cos(a),c=Math.sin(a),d=c*this.x+b*this.y;return this.x=b*this.x-c*this.y,this.y=d,this},_rotateAround:function(b,a){var c=Math.cos(b),d=Math.sin(b),e=a.y+d*(this.x-a.x)+c*(this.y-a.y);return this.x=a.x+c*(this.x-a.x)-d*(this.y-a.y),this.y=e,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},aG.convert=function(a){return a instanceof aG?a:Array.isArray(a)?new aG(a[0],a[1]):a};var s="undefined"!=typeof self?self:{},I="undefined"!=typeof Float32Array?Float32Array:Array;function aH(){var a=new I(9);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a}function aI(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function aJ(a,b,c){var h=b[0],i=b[1],j=b[2],k=b[3],l=b[4],m=b[5],n=b[6],o=b[7],p=b[8],q=b[9],r=b[10],s=b[11],t=b[12],u=b[13],v=b[14],w=b[15],d=c[0],e=c[1],f=c[2],g=c[3];return a[0]=d*h+e*l+f*p+g*t,a[1]=d*i+e*m+f*q+g*u,a[2]=d*j+e*n+f*r+g*v,a[3]=d*k+e*o+f*s+g*w,a[4]=(d=c[4])*h+(e=c[5])*l+(f=c[6])*p+(g=c[7])*t,a[5]=d*i+e*m+f*q+g*u,a[6]=d*j+e*n+f*r+g*v,a[7]=d*k+e*o+f*s+g*w,a[8]=(d=c[8])*h+(e=c[9])*l+(f=c[10])*p+(g=c[11])*t,a[9]=d*i+e*m+f*q+g*u,a[10]=d*j+e*n+f*r+g*v,a[11]=d*k+e*o+f*s+g*w,a[12]=(d=c[12])*h+(e=c[13])*l+(f=c[14])*p+(g=c[15])*t,a[13]=d*i+e*m+f*q+g*u,a[14]=d*j+e*n+f*r+g*v,a[15]=d*k+e*o+f*s+g*w,a}function br(b,a,f){var r,g,h,i,j,k,l,m,n,o,p,q,c=f[0],d=f[1],e=f[2];return a===b?(b[12]=a[0]*c+a[4]*d+a[8]*e+a[12],b[13]=a[1]*c+a[5]*d+a[9]*e+a[13],b[14]=a[2]*c+a[6]*d+a[10]*e+a[14],b[15]=a[3]*c+a[7]*d+a[11]*e+a[15]):(g=a[1],h=a[2],i=a[3],j=a[4],k=a[5],l=a[6],m=a[7],n=a[8],o=a[9],p=a[10],q=a[11],b[0]=r=a[0],b[1]=g,b[2]=h,b[3]=i,b[4]=j,b[5]=k,b[6]=l,b[7]=m,b[8]=n,b[9]=o,b[10]=p,b[11]=q,b[12]=r*c+j*d+n*e+a[12],b[13]=g*c+k*d+o*e+a[13],b[14]=h*c+l*d+p*e+a[14],b[15]=i*c+m*d+q*e+a[15]),b}function bs(a,b,f){var c=f[0],d=f[1],e=f[2];return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a[4]=b[4]*d,a[5]=b[5]*d,a[6]=b[6]*d,a[7]=b[7]*d,a[8]=b[8]*e,a[9]=b[9]*e,a[10]=b[10]*e,a[11]=b[11]*e,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a}function bt(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[4],g=b[5],h=b[6],i=b[7],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[4]=f*d+j*c,a[5]=g*d+k*c,a[6]=h*d+l*c,a[7]=i*d+m*c,a[8]=j*d-f*c,a[9]=k*d-g*c,a[10]=l*d-h*c,a[11]=m*d-i*c,a}function bu(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[8],k=b[9],l=b[10],m=b[11];return b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d-j*c,a[1]=g*d-k*c,a[2]=h*d-l*c,a[3]=i*d-m*c,a[8]=f*c+j*d,a[9]=g*c+k*d,a[10]=h*c+l*d,a[11]=i*c+m*d,a}Math.hypot||(Math.hypot=function(){for(var b=0,a=arguments.length;a--;)b+=arguments[a]*arguments[a];return Math.sqrt(b)});var bv=aJ;function aK(){var a=new I(3);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a}function eH(b){var a=new I(3);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a}function aL(a){return Math.hypot(a[0],a[1],a[2])}function Q(b,c,d){var a=new I(3);return a[0]=b,a[1]=c,a[2]=d,a}function bw(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a}function aM(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a}function aN(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a}function eI(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a}function bx(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a}function by(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a}function bz(c,a){var d=a[0],e=a[1],f=a[2],b=d*d+e*e+f*f;return b>0&&(b=1/Math.sqrt(b)),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function bA(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function bB(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a}function bC(b,g,a){var c=g[0],d=g[1],e=g[2],f=a[3]*c+a[7]*d+a[11]*e+a[15];return b[0]=(a[0]*c+a[4]*d+a[8]*e+a[12])/(f=f||1),b[1]=(a[1]*c+a[5]*d+a[9]*e+a[13])/f,b[2]=(a[2]*c+a[6]*d+a[10]*e+a[14])/f,b}function bD(a,h,b){var c=b[0],d=b[1],e=b[2],i=h[0],j=h[1],k=h[2],l=d*k-e*j,f=e*i-c*k,g=c*j-d*i,p=d*g-e*f,n=e*l-c*g,o=c*f-d*l,m=2*b[3];return f*=m,g*=m,n*=2,o*=2,a[0]=i+(l*=m)+(p*=2),a[1]=j+f+n,a[2]=k+g+o,a}var J,bE=aM;function bF(b,c,a){var d=c[0],e=c[1],f=c[2],g=c[3];return b[0]=a[0]*d+a[4]*e+a[8]*f+a[12]*g,b[1]=a[1]*d+a[5]*e+a[9]*f+a[13]*g,b[2]=a[2]*d+a[6]*e+a[10]*f+a[14]*g,b[3]=a[3]*d+a[7]*e+a[11]*f+a[15]*g,b}function aO(){var a=new I(4);return I!=Float32Array&&(a[0]=0,a[1]=0,a[2]=0),a[3]=1,a}function bG(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a}function bH(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+i*c,a[1]=g*d+h*c,a[2]=h*d-g*c,a[3]=i*d-f*c,a}function eJ(a,b){return a[0]===b[0]&&a[1]===b[1]}aK(),J=new I(4),I!=Float32Array&&(J[0]=0,J[1]=0,J[2]=0,J[3]=0),aK(),Q(1,0,0),Q(0,1,0),aO(),aO(),aH(),lr=new I(2),I!=Float32Array&&(lr[0]=0,lr[1]=0);const aP=Math.PI/180,eK=180/Math.PI;function bI(a){return a*aP}function bJ(a){return a*eK}const eL=[[0,0],[1,0],[1,1],[0,1],];function bK(a){if(a<=0)return 0;if(a>=1)return 1;const b=a*a,c=b*a;return 4*(a<.5?c:3*(a-b)+c-.75)}function aQ(a,b,c,d){const e=new eG(a,b,c,d);return function(a){return e.solve(a)}}const bL=aQ(.25,.1,.25,1);function bM(a,b,c){return Math.min(c,Math.max(b,a))}function bN(b,c,a){return(a=bM((a-b)/(c-b),0,1))*a*(3-2*a)}function bO(e,a,c){const b=c-a,d=((e-a)%b+b)%b+a;return d===a?c:d}function bP(a,c,b){if(!a.length)return b(null,[]);let d=a.length;const e=Array(a.length);let f=null;a.forEach((a,g)=>{c(a,(a,c)=>{a&&(f=a),e[g]=c,0== --d&&b(f,e)})})}function bQ(a){const b=[];for(const c in a)b.push(a[c]);return b}function bR(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}let eM=1;function bS(){return eM++}function eN(){return function b(a){return a?(a^16*Math.random()>>a/4).toString(16):([1e7]+ -[1e3]+ -4e3+ -8e3+ -1e11).replace(/[018]/g,b)}()}function bT(a){return a<=1?1:Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function eO(a){return!!a&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(a)}function bU(a,b){a.forEach(a=>{b[a]&&(b[a]=b[a].bind(b))})}function bV(a,b){return -1!==a.indexOf(b,a.length-b.length)}function eP(a,d,e){const c={};for(const b in a)c[b]=d.call(e||this,a[b],b,a);return c}function bW(a,d,e){const c={};for(const b in a)d.call(e||this,a[b],b,a)&&(c[b]=a[b]);return c}function bX(a){return Array.isArray(a)?a.map(bX):"object"==typeof a&&a?eP(a,bX):a}const eQ={};function bY(a){eQ[a]||("undefined"!=typeof console&&console.warn(a),eQ[a]=!0)}function eR(a,b,c){return(c.y-a.y)*(b.x-a.x)>(b.y-a.y)*(c.x-a.x)}function eS(a){let e=0;for(let b,c,d=0,f=a.length,g=f-1;d<f;g=d++)b=a[d],c=a[g],e+=(c.x-b.x)*(b.y+c.y);return e}function bZ(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}function eT(c){const a={};if(c.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(f,c,d,e)=>{const b=d||e;return a[c]=!b||b.toLowerCase(),""}),a["max-age"]){const b=parseInt(a["max-age"],10);isNaN(b)?delete a["max-age"]:a["max-age"]=b}return a}let eU,af,eV,eW=null;function eX(b){if(null==eW){const a=b.navigator?b.navigator.userAgent:null;eW=!!b.safari||!(!a||!(/\b(iPad|iPhone|iPod)\b/.test(a)||a.match("Safari")&&!a.match("Chrome")))}return eW}function eY(b){try{const a=s[b];return a.setItem("_mapbox_test_",1),a.removeItem("_mapbox_test_"),!0}catch(c){return!1}}const b$={now:()=>void 0!==eV?eV:s.performance.now(),setNow(a){eV=a},restoreNow(){eV=void 0},frame(a){const b=s.requestAnimationFrame(a);return{cancel:()=>s.cancelAnimationFrame(b)}},getImageData(a,b=0){const c=s.document.createElement("canvas"),d=c.getContext("2d");if(!d)throw Error("failed to create canvas 2d context");return c.width=a.width,c.height=a.height,d.drawImage(a,0,0,a.width,a.height),d.getImageData(-b,-b,a.width+2*b,a.height+2*b)},resolveURL:a=>(eU||(eU=s.document.createElement("a")),eU.href=a,eU.href),get devicePixelRatio(){return s.devicePixelRatio},get prefersReducedMotion(){return!!s.matchMedia&&(null==af&&(af=s.matchMedia("(prefers-reduced-motion: reduce)")),af.matches)}};let R;const b_={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==R){const aR=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{R=null!=d.env.API_URL_REGEX?RegExp(d.env.API_URL_REGEX):aR}catch(eZ){R=aR}}return R},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},b0={supported:!1,testSupport:function(a){!e_&&ag&&(e0?e1(a):e$=a)}};let e$,ag,e_=!1,e0=!1;function e1(a){const b=a.createTexture();a.bindTexture(a.TEXTURE_2D,b);try{if(a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,ag),a.isContextLost())return;b0.supported=!0}catch(c){}a.deleteTexture(b),e_=!0}s.document&&((ag=s.document.createElement("img")).onload=function(){e$&&e1(e$),e$=null,e0=!0},ag.onerror=function(){e_=!0,e$=null},ag.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const b1="NO_ACCESS_TOKEN";function b2(a){return 0===a.indexOf("mapbox:")}function e2(a){return b_.API_URL_REGEX.test(a)}const e3=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function e4(b){const a=b.match(e3);if(!a)throw Error("Unable to parse URL object");return{protocol:a[1],authority:a[2],path:a[3]||"/",params:a[4]?a[4].split("&"):[]}}function e5(a){const b=a.params.length?`?${a.params.join("&")}`:"";return`${a.protocol}://${a.authority}${a.path}${b}`}function e6(b){if(!b)return null;const a=b.split(".");if(!a||3!==a.length)return null;try{return JSON.parse(decodeURIComponent(s.atob(a[1]).split("").map(a=>"%"+("00"+a.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(c){return null}}class e7{constructor(a){this.type=a,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(c){const a=e6(b_.ACCESS_TOKEN);let b="";return b=a&&a.u?s.btoa(encodeURIComponent(a.u).replace(/%([0-9A-F]{2})/g,(b,a)=>String.fromCharCode(Number("0x"+a)))):b_.ACCESS_TOKEN||"",c?`mapbox.eventData.${c}:${b}`:`mapbox.eventData:${b}`}fetchEventData(){const c=eY("localStorage"),d=this.getStorageKey(),e=this.getStorageKey("uuid");if(c)try{const a=s.localStorage.getItem(d);a&&(this.eventData=JSON.parse(a));const b=s.localStorage.getItem(e);b&&(this.anonId=b)}catch(f){bY("Unable to read from LocalStorage")}}saveEventData(){const a=eY("localStorage"),b=this.getStorageKey(),c=this.getStorageKey("uuid");if(a)try{s.localStorage.setItem(c,this.anonId),Object.keys(this.eventData).length>=1&&s.localStorage.setItem(b,JSON.stringify(this.eventData))}catch(d){bY("Unable to write to LocalStorage")}}processRequests(a){}postEvent(d,a,h,e){if(!b_.EVENTS_URL)return;const b=e4(b_.EVENTS_URL);b.params.push(`access_token=${e||b_.ACCESS_TOKEN||""}`);const c={event:this.type,created:new Date(d).toISOString(),sdkIdentifier:"mapbox-gl-js",sdkVersion:bq,skuId:"01",userId:this.anonId},f=a?bR(c,a):c,g={url:e5(b),headers:{"Content-Type":"text/plain"},body:JSON.stringify([f])};this.pendingRequest=fj(g,a=>{this.pendingRequest=null,h(a),this.saveEventData(),this.processRequests(e)})}queueRequest(a,b){this.queue.push(a),this.processRequests(b)}}const aS=new class extends e7{constructor(a){super("appUserTurnstile"),this._customAccessToken=a}postTurnstileEvent(a,b){b_.EVENTS_URL&&b_.ACCESS_TOKEN&&Array.isArray(a)&&a.some(a=>b2(a)||e2(a))&&this.queueRequest(Date.now(),b)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const c=e6(b_.ACCESS_TOKEN),f=c?c.u:b_.ACCESS_TOKEN;let a=f!==this.eventData.tokenU;eO(this.anonId)||(this.anonId=eN(),a=!0);const b=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),h=new Date(b),d=(b-this.eventData.lastSuccess)/864e5;a=a||d>=1||d< -1||g.getDate()!==h.getDate()}else a=!0;if(!a)return this.processRequests();this.postEvent(b,{"enabled.telemetry":!1},a=>{a||(this.eventData.lastSuccess=b,this.eventData.tokenU=f)},e)}},b3=aS.postTurnstileEvent.bind(aS),aT=new class extends e7{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.EVENTS_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||(this.anonId||this.fetchEventData(),eO(this.anonId)||(this.anonId=eN()),this.postEvent(c,{skuToken:this.skuToken},b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b))}},b4=aT.postMapLoadEvent.bind(aT),aU=new class extends e7{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,b,f,c){if(!b_.API_URL||!b_.SESSION_PATH)return;const a=e4(b_.API_URL+b_.SESSION_PATH);a.params.push(`sku=${b||""}`),a.params.push(`access_token=${c||b_.ACCESS_TOKEN||""}`);const d={url:e5(a),headers:{"Content-Type":"text/plain"}};this.pendingRequest=fk(d,a=>{this.pendingRequest=null,f(a),this.saveEventData(),this.processRequests(c)})}getSessionAPI(b,c,a,d){this.skuToken=c,this.errorCb=d,b_.SESSION_PATH&&b_.API_URL&&(a||b_.ACCESS_TOKEN?this.queueRequest({id:b,timestamp:Date.now()},a):this.errorCb(Error(b1)))}processRequests(b){if(this.pendingRequest||0===this.queue.length)return;const{id:a,timestamp:c}=this.queue.shift();a&&this.success[a]||this.getSession(c,this.skuToken,b=>{b?this.errorCb(b):a&&(this.success[a]=!0)},b)}},b5=aU.getSessionAPI.bind(aU),e8=new Set,e9="mapbox-tiles";let fa,fb,fc=500,fd=50;function fe(){s.caches&&!fa&&(fa=s.caches.open(e9))}function ff(a){const b=a.indexOf("?");return b<0?a:a.slice(0,b)}let fg=1/0;const aV={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(aV);class fh extends Error{constructor(a,b,c){401===b&&e2(c)&&(a+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(a),this.status=b,this.url=c}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const b6=bZ()?()=>self.worker&&self.worker.referrer:()=>("blob:"===s.location.protocol?s.parent:s).location.href,b7=function(a,b){var c;if(!(/^file:/.test(c=a.url)||/^file:/.test(b6())&&!/^\w+:/.test(c))){if(s.fetch&&s.Request&&s.AbortController&&s.Request.prototype.hasOwnProperty("signal"))return function(a,g){var c;const e=new s.AbortController,b=new s.Request(a.url,{method:a.method||"GET",body:a.body,credentials:a.credentials,headers:a.headers,referrer:b6(),signal:e.signal});let h=!1,i=!1;const f=(c=b.url).indexOf("sku=")>0&&e2(c);"json"===a.type&&b.headers.set("Accept","application/json");const d=(c,d,e)=>{if(i)return;if(c&&"SecurityError"!==c.message&&bY(c),d&&e)return j(d);const h=Date.now();s.fetch(b).then(b=>{if(b.ok){const c=f?b.clone():null;return j(b,c,h)}return g(new fh(b.statusText,b.status,a.url))}).catch(a=>{20!==a.code&&g(Error(a.message))})},j=(c,d,e)=>{("arrayBuffer"===a.type?c.arrayBuffer():"json"===a.type?c.json():c.text()).then(a=>{i||(d&&e&&function(e,a,c){if(fe(),!fa)return;const d={status:a.status,statusText:a.statusText,headers:new s.Headers};a.headers.forEach((a,b)=>d.headers.set(b,a));const b=eT(a.headers.get("Cache-Control")||"");b["no-store"]||(b["max-age"]&&d.headers.set("Expires",new Date(c+1e3*b["max-age"]).toUTCString()),new Date(d.headers.get("Expires")).getTime()-c<42e4||function(a,b){if(void 0===fb)try{new Response(new ReadableStream),fb=!0}catch(c){fb=!1}fb?b(a.body):a.blob().then(b)}(a,a=>{const b=new s.Response(a,d);fe(),fa&&fa.then(a=>a.put(ff(e.url),b)).catch(a=>bY(a.message))}))}(b,d,e),h=!0,g(null,a,c.headers.get("Cache-Control"),c.headers.get("Expires")))}).catch(a=>{i||g(Error(a.message))})};return f?function(b,a){if(fe(),!fa)return a(null);const c=ff(b.url);fa.then(b=>{b.match(c).then(d=>{const e=function(a){if(!a)return!1;const b=new Date(a.headers.get("Expires")||0),c=eT(a.headers.get("Cache-Control")||"");return b>Date.now()&&!c["no-cache"]}(d);b.delete(c),e&&b.put(c,d.clone()),a(null,d,e)}).catch(a)}).catch(a)}(b,d):d(null,null),{cancel(){i=!0,h||e.abort()}}}(a,b);if(bZ()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",a,b,void 0,!0)}return function(b,d){const a=new s.XMLHttpRequest;for(const c in a.open(b.method||"GET",b.url,!0),"arrayBuffer"===b.type&&(a.responseType="arraybuffer"),b.headers)a.setRequestHeader(c,b.headers[c]);return"json"===b.type&&(a.responseType="text",a.setRequestHeader("Accept","application/json")),a.withCredentials="include"===b.credentials,a.onerror=()=>{d(Error(a.statusText))},a.onload=()=>{if((a.status>=200&&a.status<300||0===a.status)&&null!==a.response){let c=a.response;if("json"===b.type)try{c=JSON.parse(a.response)}catch(e){return d(e)}d(null,c,a.getResponseHeader("Cache-Control"),a.getResponseHeader("Expires"))}else d(new fh(a.statusText,a.status,b.url))},a.send(b.body),{cancel:()=>a.abort()}}(a,b)},fi=function(a,b){return b7(bR(a,{type:"arrayBuffer"}),b)},fj=function(a,b){return b7(bR(a,{method:"POST"}),b)},fk=function(a,b){return b7(bR(a,{method:"GET"}),b)};function fl(b){const a=s.document.createElement("a");return a.href=b,a.protocol===s.document.location.protocol&&a.host===s.document.location.host}const fm="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let b8,b9;b8=[],b9=0;const ca=function(a,c){if(b0.supported&&(a.headers||(a.headers={}),a.headers.accept="image/webp,*/*"),b9>=b_.MAX_PARALLEL_IMAGE_REQUESTS){const b={requestParameters:a,callback:c,cancelled:!1,cancel(){this.cancelled=!0}};return b8.push(b),b}b9++;let d=!1;const e=()=>{if(!d)for(d=!0,b9--;b8.length&&b9<b_.MAX_PARALLEL_IMAGE_REQUESTS;){const a=b8.shift(),{requestParameters:b,callback:c,cancelled:e}=a;e||(a.cancel=ca(b,c).cancel)}},f=fi(a,(b,a,d,f)=>{e(),b?c(b):a&&(s.createImageBitmap?function(a,c){const b=new s.Blob([new Uint8Array(a)],{type:"image/png"});s.createImageBitmap(b).then(a=>{c(null,a)}).catch(a=>{c(Error(`Could not load image because of ${a.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(a,(a,b)=>c(a,b,d,f)):function(b,e){const a=new s.Image,c=s.URL;a.onload=()=>{e(null,a),c.revokeObjectURL(a.src),a.onload=null,s.requestAnimationFrame(()=>{a.src=fm})},a.onerror=()=>e(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 d=new s.Blob([new Uint8Array(b)],{type:"image/png"});a.src=b.byteLength?c.createObjectURL(d):fm}(a,(a,b)=>c(a,b,d,f)))});return{cancel(){f.cancel(),e()}}};function fn(a,c,b){b[a]&& -1!==b[a].indexOf(c)||(b[a]=b[a]||[],b[a].push(c))}function fo(b,d,a){if(a&&a[b]){const c=a[b].indexOf(d);-1!==c&&a[b].splice(c,1)}}class aW{constructor(a,b={}){bR(this,b),this.type=a}}class cb extends aW{constructor(a,b={}){super("error",bR({error:a},b))}}class S{on(a,b){return this._listeners=this._listeners||{},fn(a,b,this._listeners),this}off(a,b){return fo(a,b,this._listeners),fo(a,b,this._oneTimeListeners),this}once(b,a){return a?(this._oneTimeListeners=this._oneTimeListeners||{},fn(b,a,this._oneTimeListeners),this):new Promise(a=>this.once(b,a))}fire(a,e){"string"==typeof a&&(a=new aW(a,e||{}));const b=a.type;if(this.listens(b)){a.target=this;const f=this._listeners&&this._listeners[b]?this._listeners[b].slice():[];for(const g of f)g.call(this,a);const h=this._oneTimeListeners&&this._oneTimeListeners[b]?this._oneTimeListeners[b].slice():[];for(const c of h)fo(b,c,this._oneTimeListeners),c.call(this,a);const d=this._eventedParent;d&&(bR(a,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),d.fire(a))}else a instanceof cb&&console.error(a.error);return this}listens(a){return!!(this._listeners&&this._listeners[a]&&this._listeners[a].length>0||this._oneTimeListeners&&this._oneTimeListeners[a]&&this._oneTimeListeners[a].length>0||this._eventedParent&&this._eventedParent.listens(a))}setEventedParent(a,b){return this._eventedParent=a,this._eventedParentData=b,this}}var b=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}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{}},"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"]}]}},"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 cc{constructor(b,a,d,c){this.message=(b?`${b}: `:"")+d,c&&(this.identifier=c),null!=a&&a.__line__&&(this.line=a.__line__)}}function cd(a){const b=a.value;return b?[new cc(a.key,b,"constants have been deprecated as of v8"),]:[]}function ce(a,...d){for(const b of d)for(const c in b)a[c]=b[c];return a}function fp(a){return a instanceof Number||a instanceof String||a instanceof Boolean?a.valueOf():a}function fq(a){if(Array.isArray(a))return a.map(fq);if(a instanceof Object&&!(a instanceof Number||a instanceof String||a instanceof Boolean)){const b={};for(const c in a)b[c]=fq(a[c]);return b}return fp(a)}class fr extends Error{constructor(b,a){super(a),this.message=a,this.key=b}}class fs{constructor(a,b=[]){for(const[c,d]of(this.parent=a,this.bindings={},b))this.bindings[c]=d}concat(a){return new fs(this,a)}get(a){if(this.bindings[a])return this.bindings[a];if(this.parent)return this.parent.get(a);throw Error(`${a} not found in scope.`)}has(a){return!!this.bindings[a]|| !!this.parent&&this.parent.has(a)}}const cf={kind:"null"},f={kind:"number"},i={kind:"string"},h={kind:"boolean"},y={kind:"color"},K={kind:"object"},l={kind:"value"},cg={kind:"collator"},ch={kind:"formatted"},ci={kind:"resolvedImage"};function z(a,b){return{kind:"array",itemType:a,N:b}}function ft(a){if("array"===a.kind){const b=ft(a.itemType);return"number"==typeof a.N?`array<${b}, ${a.N}>`:"value"===a.itemType.kind?"array":`array<${b}>`}return a.kind}const fu=[cf,f,i,h,y,ch,K,z(l),ci];function fv(b,a){if("error"===a.kind)return null;if("array"===b.kind){if("array"===a.kind&&(0===a.N&&"value"===a.itemType.kind||!fv(b.itemType,a.itemType))&&("number"!=typeof b.N||b.N===a.N))return null}else{if(b.kind===a.kind)return null;if("value"===b.kind){for(const c of fu)if(!fv(c,a))return null}}return`Expected ${ft(b)} but found ${ft(a)} instead.`}function fw(b,a){return a.some(a=>a.kind===b.kind)}function fx(b,a){return a.some(a=>"null"===a?null===b:"array"===a?Array.isArray(b):"object"===a?b&&!Array.isArray(b)&&"object"==typeof b:a===typeof b)}function ah(b){var a={exports:{}};return b(a,a.exports),a.exports}var fy=ah(function(b,a){var c={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 d(a){return(a=Math.round(a))<0?0:a>255?255:a}function e(a){return d("%"===a[a.length-1]?parseFloat(a)/100*255:parseInt(a))}function f(a){var b;return(b="%"===a[a.length-1]?parseFloat(a)/100:parseFloat(a))<0?0:b>1?1:b}function g(b,c,a){return a<0?a+=1:a>1&&(a-=1),6*a<1?b+(c-b)*a*6:2*a<1?c:3*a<2?b+(c-b)*(2/3-a)*6:b}try{a.parseCSSColor=function(q){var a,b=q.replace(/ /g,"").toLowerCase();if(b in c)return c[b].slice();if("#"===b[0])return 4===b.length?(a=parseInt(b.substr(1),16))>=0&&a<=4095?[(3840&a)>>4|(3840&a)>>8,240&a|(240&a)>>4,15&a|(15&a)<<4,1,]:null:7===b.length&&(a=parseInt(b.substr(1),16))>=0&&a<=16777215?[(16711680&a)>>16,(65280&a)>>8,255&a,1,]:null;var j=b.indexOf("("),p=b.indexOf(")");if(-1!==j&&p+1===b.length){var r=b.substr(0,j),h=b.substr(j+1,p-(j+1)).split(","),k=1;switch(r){case"rgba":if(4!==h.length)break;k=f(h.pop());case"rgb":return 3!==h.length?null:[e(h[0]),e(h[1]),e(h[2]),k,];case"hsla":if(4!==h.length)break;k=f(h.pop());case"hsl":if(3!==h.length)break;var m=(parseFloat(h[0])%360+360)%360/360,n=f(h[1]),i=f(h[2]),l=i<=.5?i*(n+1):i+n-i*n,o=2*i-l;return[d(255*g(o,l,m+1/3)),d(255*g(o,l,m)),d(255*g(o,l,m-1/3)),k,]}}return null}}catch(h){}});class m{constructor(a,b,c,d=1){this.r=a,this.g=b,this.b=c,this.a=d}static parse(b){if(!b)return;if(b instanceof m)return b;if("string"!=typeof b)return;const a=fy.parseCSSColor(b);return a?new m(a[0]/255*a[3],a[1]/255*a[3],a[2]/255*a[3],a[3]):void 0}toString(){const[a,b,c,d]=this.toArray();return`rgba(${Math.round(a)},${Math.round(b)},${Math.round(c)},${d})`}toArray(){const{r:b,g:c,b:d,a:a}=this;return 0===a?[0,0,0,0]:[255*b/a,255*c/a,255*d/a,a,]}}m.black=new m(0,0,0,1),m.white=new m(1,1,1,1),m.transparent=new m(0,0,0,0),m.red=new m(1,0,0,1),m.blue=new m(0,0,1,1);class fz{constructor(b,a,c){this.sensitivity=b?a?"variant":"case":a?"accent":"base",this.locale=c,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(a,b){return this.collator.compare(a,b)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class fA{constructor(a,b,c,d,e){this.text=a.normalize?a.normalize():a,this.image=b,this.scale=c,this.fontStack=d,this.textColor=e}}class fB{constructor(a){this.sections=a}static fromString(a){return new fB([new fA(a,null,null,null,null),])}isEmpty(){return 0===this.sections.length||!this.sections.some(a=>0!==a.text.length||a.image&&0!==a.image.name.length)}static factory(a){return a instanceof fB?a:fB.fromString(a)}toString(){return 0===this.sections.length?"":this.sections.map(a=>a.text).join("")}serialize(){const b=["format"];for(const a of this.sections){if(a.image){b.push(["image",a.image.name]);continue}b.push(a.text);const c={};a.fontStack&&(c["text-font"]=["literal",a.fontStack.split(","),]),a.scale&&(c["font-scale"]=a.scale),a.textColor&&(c["text-color"]=["rgba"].concat(a.textColor.toArray())),b.push(c)}return b}}class cj{constructor(a){this.name=a.name,this.available=a.available}toString(){return this.name}static fromString(a){return a?new cj({name:a,available:!1}):null}serialize(){return["image",this.name]}}function fC(b,c,d,a){return"number"==typeof b&&b>=0&&b<=255&&"number"==typeof c&&c>=0&&c<=255&&"number"==typeof d&&d>=0&&d<=255?void 0===a||"number"==typeof a&&a>=0&&a<=1?null:`Invalid rgba value [${[b,c,d,a].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof a?[b,c,d,a]:[b,c,d]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function fD(a){if(null===a||"string"==typeof a||"boolean"==typeof a||"number"==typeof a||a instanceof m||a instanceof fz||a instanceof fB||a instanceof cj)return!0;if(Array.isArray(a)){for(const b of a)if(!fD(b))return!1;return!0}if("object"==typeof a){for(const c in a)if(!fD(a[c]))return!1;return!0}return!1}function fE(a){if(null===a)return cf;if("string"==typeof a)return i;if("boolean"==typeof a)return h;if("number"==typeof a)return f;if(a instanceof m)return y;if(a instanceof fz)return cg;if(a instanceof fB)return ch;if(a instanceof cj)return ci;if(Array.isArray(a)){const d=a.length;let b;for(const e of a){const c=fE(e);if(b){if(b===c)continue;b=l;break}b=c}return z(b||l,d)}return K}function fF(a){const b=typeof a;return null===a?"":"string"===b||"number"===b||"boolean"===b?String(a):a instanceof m||a instanceof fB||a instanceof cj?a.toString():JSON.stringify(a)}class ck{constructor(a,b){this.type=a,this.value=b}static parse(b,d){if(2!==b.length)return d.error(`'literal' expression requires exactly one argument, but found ${b.length-1} instead.`);if(!fD(b[1]))return d.error("invalid value");const e=b[1];let c=fE(e);const a=d.expectedType;return"array"===c.kind&&0===c.N&&a&&"array"===a.kind&&("number"!=typeof a.N||0===a.N)&&(c=a),new ck(c,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof m?["rgba"].concat(this.value.toArray()):this.value instanceof fB?this.value.serialize():this.value}}class fG{constructor(a){this.name="ExpressionEvaluationError",this.message=a}toJSON(){return this.message}}const fH={string:i,number:f,boolean:h,object:K};class L{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");let e,b=1;const g=a[0];if("array"===g){let f,h;if(a.length>2){const d=a[1];if("string"!=typeof d||!(d in fH)||"object"===d)return c.error('The item type argument of "array" must be one of string, number, boolean',1);f=fH[d],b++}else f=l;if(a.length>3){if(null!==a[2]&&("number"!=typeof a[2]||a[2]<0||a[2]!==Math.floor(a[2])))return c.error('The length argument to "array" must be a positive integer literal',2);h=a[2],b++}e=z(f,h)}else e=fH[g];const i=[];for(;b<a.length;b++){const j=c.parse(a[b],b,l);if(!j)return null;i.push(j)}return new L(e,i)}evaluate(c){for(let a=0;a<this.args.length;a++){const b=this.args[a].evaluate(c);if(!fv(this.type,fE(b)))return b;if(a===this.args.length-1)throw new fG(`Expected value to be of type ${ft(this.type)}, but found ${ft(fE(b))} instead.`)}return null}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=this.type,c=[a.kind];if("array"===a.kind){const b=a.itemType;if("string"===b.kind||"number"===b.kind||"boolean"===b.kind){c.push(b.kind);const d=a.N;("number"==typeof d||this.args.length>1)&&c.push(d)}}return c.concat(this.args.map(a=>a.serialize()))}}class cl{constructor(a){this.type=ch,this.sections=a}static parse(c,b){if(c.length<2)return b.error("Expected at least one argument.");const m=c[1];if(!Array.isArray(m)&&"object"==typeof m)return b.error("First argument must be an image or text section.");const d=[];let h=!1;for(let e=1;e<=c.length-1;++e){const a=c[e];if(h&&"object"==typeof a&&!Array.isArray(a)){h=!1;let n=null;if(a["font-scale"]&&!(n=b.parse(a["font-scale"],1,f)))return null;let o=null;if(a["text-font"]&&!(o=b.parse(a["text-font"],1,z(i))))return null;let p=null;if(a["text-color"]&&!(p=b.parse(a["text-color"],1,y)))return null;const j=d[d.length-1];j.scale=n,j.font=o,j.textColor=p}else{const k=b.parse(c[e],1,l);if(!k)return null;const g=k.type.kind;if("string"!==g&&"value"!==g&&"null"!==g&&"resolvedImage"!==g)return b.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,d.push({content:k,scale:null,font:null,textColor:null})}}return new cl(d)}evaluate(a){return new fB(this.sections.map(b=>{const c=b.content.evaluate(a);return fE(c)===ci?new fA("",c,null,null,null):new fA(fF(c),null,b.scale?b.scale.evaluate(a):null,b.font?b.font.evaluate(a).join(","):null,b.textColor?b.textColor.evaluate(a):null)}))}eachChild(b){for(const a of this.sections)b(a.content),a.scale&&b(a.scale),a.font&&b(a.font),a.textColor&&b(a.textColor)}outputDefined(){return!1}serialize(){const c=["format"];for(const a of this.sections){c.push(a.content.serialize());const b={};a.scale&&(b["font-scale"]=a.scale.serialize()),a.font&&(b["text-font"]=a.font.serialize()),a.textColor&&(b["text-color"]=a.textColor.serialize()),c.push(b)}return c}}class cm{constructor(a){this.type=ci,this.input=a}static parse(b,a){if(2!==b.length)return a.error("Expected two arguments.");const c=a.parse(b[1],1,i);return c?new cm(c):a.error("No image name provided.")}evaluate(a){const c=this.input.evaluate(a),b=cj.fromString(c);return b&&a.availableImages&&(b.available=a.availableImages.indexOf(c)> -1),b}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const fI={"to-boolean":h,"to-color":y,"to-number":f,"to-string":i};class T{constructor(a,b){this.type=a,this.args=b}static parse(a,c){if(a.length<2)return c.error("Expected at least one argument.");const d=a[0];if(("to-boolean"===d||"to-string"===d)&&2!==a.length)return c.error("Expected one argument.");const g=fI[d],e=[];for(let b=1;b<a.length;b++){const f=c.parse(a[b],b,l);if(!f)return null;e.push(f)}return new T(g,e)}evaluate(b){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(b));if("color"===this.type.kind){let a,c;for(const g of this.args){if(a=g.evaluate(b),c=null,a instanceof m)return a;if("string"==typeof a){const e=b.parseColor(a);if(e)return e}else if(Array.isArray(a)&&!(c=a.length<3||a.length>4?`Invalid rbga value ${JSON.stringify(a)}: expected an array containing either three or four numeric values.`:fC(a[0],a[1],a[2],a[3])))return new m(a[0]/255,a[1]/255,a[2]/255,a[3])}throw new fG(c||`Could not parse color from value '${"string"==typeof a?a:String(JSON.stringify(a))}'`)}if("number"===this.type.kind){let d=null;for(const h of this.args){if(null===(d=h.evaluate(b)))return 0;const f=Number(d);if(!isNaN(f))return f}throw new fG(`Could not convert ${JSON.stringify(d)} to number.`)}return"formatted"===this.type.kind?fB.fromString(fF(this.args[0].evaluate(b))):"resolvedImage"===this.type.kind?cj.fromString(fF(this.args[0].evaluate(b))):fF(this.args[0].evaluate(b))}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){if("formatted"===this.type.kind)return new cl([{content:this.args[0],scale:null,font:null,textColor:null},]).serialize();if("resolvedImage"===this.type.kind)return new cm(this.args[0]).serialize();const a=[`to-${this.type.kind}`];return this.eachChild(b=>{a.push(b.serialize())}),a}}const fJ=["Unknown","Point","LineString","Polygon",];class fK{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?fJ[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 a=this.featureDistanceData.center,b=this.featureDistanceData.scale,{x:c,y:d}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(c*b-a[0])+this.featureDistanceData.bearing[1]*(d*b-a[1])}return 0}parseColor(a){let b=this._parseColorCache[a];return b||(b=this._parseColorCache[a]=m.parse(a)),b}}class aX{constructor(a,b,c,d){this.name=a,this.type=b,this._evaluate=c,this.args=d}evaluate(a){return this._evaluate(a,this.args)}eachChild(a){this.args.forEach(a)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(a=>a.serialize()))}static parse(f,c){const j=f[0],b=aX.definitions[j];if(!b)return c.error(`Unknown expression "${j}". If you wanted a literal array, use ["literal", [...]].`,0);const q=Array.isArray(b)?b[0]:b.type,m=Array.isArray(b)?[[b[1],b[2]]]:b.overloads,h=m.filter(([a])=>!Array.isArray(a)||a.length===f.length-1);let e=null;for(const[a,r]of h){e=new f1(c.registry,c.path,null,c.scope);const d=[];let n=!1;for(let i=1;i<f.length;i++){const s=f[i],t=Array.isArray(a)?a[i-1]:a.type,o=e.parse(s,1+d.length,t);if(!o){n=!0;break}d.push(o)}if(!n){if(Array.isArray(a)&&a.length!==d.length)e.error(`Expected ${a.length} arguments, but found ${d.length} instead.`);else{for(let g=0;g<d.length;g++){const u=Array.isArray(a)?a[g]:a.type,v=d[g];e.concat(g+1).checkSubtype(u,v.type)}if(0===e.errors.length)return new aX(j,q,r,d)}}}if(1===h.length)c.errors.push(...e.errors);else{const w=(h.length?h:m).map(([b])=>{var a;return Array.isArray(a=b)?`(${a.map(ft).join(", ")})`:`(${ft(a.type)}...)`}).join(" | "),k=[];for(let l=1;l<f.length;l++){const p=c.parse(f[l],1+k.length);if(!p)return null;k.push(ft(p.type))}c.error(`Expected arguments of type ${w}, but found (${k.join(", ")}) instead.`)}return null}static register(b,a){for(const c in aX.definitions=a,a)b[c]=aX}}class cn{constructor(a,b,c){this.type=cg,this.locale=c,this.caseSensitive=a,this.diacriticSensitive=b}static parse(c,b){if(2!==c.length)return b.error("Expected one argument.");const a=c[1];if("object"!=typeof a||Array.isArray(a))return b.error("Collator options argument must be an object.");const d=b.parse(void 0!==a["case-sensitive"]&&a["case-sensitive"],1,h);if(!d)return null;const e=b.parse(void 0!==a["diacritic-sensitive"]&&a["diacritic-sensitive"],1,h);if(!e)return null;let f=null;return!a.locale||(f=b.parse(a.locale,1,i))?new cn(d,e,f):null}evaluate(a){return new fz(this.caseSensitive.evaluate(a),this.diacriticSensitive.evaluate(a),this.locale?this.locale.evaluate(a):null)}eachChild(a){a(this.caseSensitive),a(this.diacriticSensitive),this.locale&&a(this.locale)}outputDefined(){return!1}serialize(){const a={};return a["case-sensitive"]=this.caseSensitive.serialize(),a["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(a.locale=this.locale.serialize()),["collator",a]}}function fL(a,b){a[0]=Math.min(a[0],b[0]),a[1]=Math.min(a[1],b[1]),a[2]=Math.max(a[2],b[0]),a[3]=Math.max(a[3],b[1])}function fM(a,b){return!(a[0]<=b[0]||a[2]>=b[2]||a[1]<=b[1]||a[3]>=b[3])}function fN(a,c){const d=(180+a[0])/360,e=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a[1]*Math.PI/360)))/360,b=Math.pow(2,c.z);return[Math.round(d*b*8192),Math.round(e*b*8192),]}function fO(a,b,c){const d=a[0]-b[0],e=a[1]-b[1],f=a[0]-c[0],g=a[1]-c[1];return d*g-f*e==0&&d*f<=0&&e*g<=0}function fP(h,i){var d,b,e;let f=!1;for(let g=0,j=i.length;g<j;g++){const c=i[g];for(let a=0,k=c.length;a<k-1;a++){if(fO(h,c[a],c[a+1]))return!1;(b=c[a])[1]>(d=h)[1]!=(e=c[a+1])[1]>d[1]&&d[0]<(e[0]-b[0])*(d[1]-b[1])/(e[1]-b[1])+b[0]&&(f=!f)}}return f}function fQ(c,b){for(let a=0;a<b.length;a++)if(fP(c,b[a]))return!0;return!1}function fR(b,c,a,d){const e=d[0]-a[0],f=d[1]-a[1],g=(b[0]-a[0])*f-e*(b[1]-a[1]),h=(c[0]-a[0])*f-e*(c[1]-a[1]);return g>0&&h<0||g<0&&h>0}function fS(i,j,k){var a,b,c,d,g,h;for(const f of k)for(let e=0;e<f.length-1;++e)if(0!=(g=[(d=f[e+1])[0]-(c=f[e])[0],d[1]-c[1],])[0]*(h=[(b=j)[0]-(a=i)[0],b[1]-a[1],])[1]-g[1]*h[0]&&fR(a,b,c,d)&&fR(c,d,a,b))return!0;return!1}function fT(a,d){for(let c=0;c<a.length;++c)if(!fP(a[c],d))return!1;for(let b=0;b<a.length-1;++b)if(fS(a[b],a[b+1],d))return!1;return!0}function fU(c,b){for(let a=0;a<b.length;a++)if(fT(c,b[a]))return!0;return!1}function fV(b,g,h){const d=[];for(let a=0;a<b.length;a++){const e=[];for(let c=0;c<b[a].length;c++){const f=fN(b[a][c],h);fL(g,f),e.push(f)}d.push(e)}return d}function fW(b,d,e){const c=[];for(let a=0;a<b.length;a++){const f=fV(b[a],d,e);c.push(f)}return c}function fX(a,f,b,c){if(a[0]<b[0]||a[0]>b[2]){const d=.5*c;let e=a[0]-b[0]>d?-c:b[0]-a[0]>d?c:0;0===e&&(e=a[0]-b[2]>d?-c:b[2]-a[0]>d?c:0),a[0]+=e}fL(f,a)}function fY(f,g,h,a){const i=8192*Math.pow(2,a.z),b=[8192*a.x,8192*a.y],c=[];for(const j of f)for(const d of j){const e=[d.x+b[0],d.y+b[1]];fX(e,g,h,i),c.push(e)}return c}function fZ(j,a,k,c){var b;const e=8192*Math.pow(2,c.z),f=[8192*c.x,8192*c.y],d=[];for(const l of j){const g=[];for(const h of l){const i=[h.x+f[0],h.y+f[1]];fL(a,i),g.push(i)}d.push(g)}if(a[2]-a[0]<=e/2)for(const m of((b=a)[0]=b[1]=1/0,b[2]=b[3]=-1/0,d))for(const n of m)fX(n,a,k,e);return d}class co{constructor(a,b){this.type=h,this.geojson=a,this.geometries=b}static parse(b,d){if(2!==b.length)return d.error(`'within' expression requires exactly one argument, but found ${b.length-1} instead.`);if(fD(b[1])){const a=b[1];if("FeatureCollection"===a.type)for(let c=0;c<a.features.length;++c){const e=a.features[c].geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new co(a,a.features[c].geometry)}else if("Feature"===a.type){const f=a.geometry.type;if("Polygon"===f||"MultiPolygon"===f)return new co(a,a.geometry)}else if("Polygon"===a.type||"MultiPolygon"===a.type)return new co(a,a)}return d.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(a){if(null!=a.geometry()&&null!=a.canonicalID()){if("Point"===a.geometryType())return function(e,b){const c=[1/0,1/0,-1/0,-1/0,],a=[1/0,1/0,-1/0,-1/0,],d=e.canonicalID();if("Polygon"===b.type){const f=fV(b.coordinates,a,d),g=fY(e.geometry(),c,a,d);if(!fM(c,a))return!1;for(const h of g)if(!fP(h,f))return!1}if("MultiPolygon"===b.type){const i=fW(b.coordinates,a,d),j=fY(e.geometry(),c,a,d);if(!fM(c,a))return!1;for(const k of j)if(!fQ(k,i))return!1}return!0}(a,this.geometries);if("LineString"===a.geometryType())return function(e,b){const c=[1/0,1/0,-1/0,-1/0,],a=[1/0,1/0,-1/0,-1/0,],d=e.canonicalID();if("Polygon"===b.type){const f=fV(b.coordinates,a,d),g=fZ(e.geometry(),c,a,d);if(!fM(c,a))return!1;for(const h of g)if(!fT(h,f))return!1}if("MultiPolygon"===b.type){const i=fW(b.coordinates,a,d),j=fZ(e.geometry(),c,a,d);if(!fM(c,a))return!1;for(const k of j)if(!fU(k,i))return!1}return!0}(a,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}function f$(a){if(a instanceof aX&&("get"===a.name&&1===a.args.length||"feature-state"===a.name||"has"===a.name&&1===a.args.length||"properties"===a.name||"geometry-type"===a.name||"id"===a.name||/^filter-/.test(a.name))||a instanceof co)return!1;let b=!0;return a.eachChild(a=>{b&&!f$(a)&&(b=!1)}),b}function f_(a){if(a instanceof aX&&"feature-state"===a.name)return!1;let b=!0;return a.eachChild(a=>{b&&!f_(a)&&(b=!1)}),b}function f0(a,b){if(a instanceof aX&&b.indexOf(a.name)>=0)return!1;let c=!0;return a.eachChild(a=>{c&&!f0(a,b)&&(c=!1)}),c}class cp{constructor(b,a){this.type=a.type,this.name=b,this.boundExpression=a}static parse(c,b){if(2!==c.length||"string"!=typeof c[1])return b.error("'var' expression requires exactly one string literal argument.");const a=c[1];return b.scope.has(a)?new cp(a,b.scope.get(a)):b.error(`Unknown variable "${a}". Make sure "${a}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(a){return this.boundExpression.evaluate(a)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}class f1{constructor(b,a=[],c,d=new fs,e=[]){this.registry=b,this.path=a,this.key=a.map(a=>`[${a}]`).join(""),this.scope=d,this.errors=e,this.expectedType=c}parse(a,b,d,e,c={}){return b?this.concat(b,d,e)._parse(a,c):this._parse(a,c)}_parse(a,f){function g(a,b,c){return"assert"===c?new L(b,[a]):"coerce"===c?new T(b,[a]):a}if(null!==a&&"string"!=typeof a&&"boolean"!=typeof a&&"number"!=typeof a||(a=["literal",a]),Array.isArray(a)){if(0===a.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const d=a[0];if("string"!=typeof d)return this.error(`Expression name must be a string, but found ${typeof d} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[d];if(h){let b=h.parse(a,this);if(!b)return null;if(this.expectedType){const c=this.expectedType,e=b.type;if("string"!==c.kind&&"number"!==c.kind&&"boolean"!==c.kind&&"object"!==c.kind&&"array"!==c.kind||"value"!==e.kind){if("color"!==c.kind&&"formatted"!==c.kind&&"resolvedImage"!==c.kind||"value"!==e.kind&&"string"!==e.kind){if(this.checkSubtype(c,e))return null}else b=g(b,c,f.typeAnnotation||"coerce")}else b=g(b,c,f.typeAnnotation||"assert")}if(!(b instanceof ck)&&"resolvedImage"!==b.type.kind&&f2(b)){const i=new fK;try{b=new ck(b.type,b.evaluate(i))}catch(j){return this.error(j.message),null}}return b}return this.error(`Unknown expression "${d}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===a?"'undefined' value invalid. Use null instead.":"object"==typeof a?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof a} instead.`)}concat(a,c,b){const d="number"==typeof a?this.path.concat(a):this.path,e=b?this.scope.concat(b):this.scope;return new f1(this.registry,d,c||null,e,this.errors)}error(a,...b){const c=`${this.key}${b.map(a=>`[${a}]`).join("")}`;this.errors.push(new fr(c,a))}checkSubtype(b,c){const a=fv(b,c);return a&&this.error(a),a}}function f2(a){if(a instanceof cp)return f2(a.boundExpression);if(a instanceof aX&&"error"===a.name||a instanceof cn||a instanceof co)return!1;const c=a instanceof T||a instanceof L;let b=!0;return a.eachChild(a=>{b=c?b&&f2(a):b&&a instanceof ck}),!!b&&f$(a)&&f0(a,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center",])}function f3(b,c){const g=b.length-1;let d,h,e=0,f=g,a=0;for(;e<=f;)if(d=b[a=Math.floor((e+f)/2)],h=b[a+1],d<=c){if(a===g||c<h)return a;e=a+1}else{if(!(d>c))throw new fG("Input is not a number.");f=a-1}return 0}class cq{constructor(a,b,c){for(const[d,e]of(this.type=a,this.input=b,this.labels=[],this.outputs=[],c))this.labels.push(d),this.outputs.push(e)}static parse(b,a){if(b.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if((b.length-1)%2!=0)return a.error("Expected an even number of arguments.");const i=a.parse(b[1],1,f);if(!i)return null;const d=[];let e=null;a.expectedType&&"value"!==a.expectedType.kind&&(e=a.expectedType);for(let c=1;c<b.length;c+=2){const g=1===c?-1/0:b[c],k=b[c+1],j=c,l=c+1;if("number"!=typeof g)return a.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',j);if(d.length&&d[d.length-1][0]>=g)return a.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',j);const h=a.parse(k,l,e);if(!h)return null;e=e||h.type,d.push([g,h])}return new cq(e,i,d)}evaluate(a){const b=this.labels,c=this.outputs;if(1===b.length)return c[0].evaluate(a);const d=this.input.evaluate(a);if(d<=b[0])return c[0].evaluate(a);const e=b.length;return d>=b[e-1]?c[e-1].evaluate(a):c[f3(b,d)].evaluate(a)}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){const b=["step",this.input.serialize()];for(let a=0;a<this.labels.length;a++)a>0&&b.push(this.labels[a]),b.push(this.outputs[a].serialize());return b}}function aY(b,c,a){return b*(1-a)+c*a}var f4=Object.freeze({__proto__:null,number:aY,color:function(a,b,c){return new m(aY(a.r,b.r,c),aY(a.g,b.g,c),aY(a.b,b.b,c),aY(a.a,b.a,c))},array:function(a,b,c){return a.map((a,d)=>aY(a,b[d],c))}});const f5=4/29,aZ=6/29,f6=3*aZ*aZ,f7=Math.PI/180,f8=180/Math.PI;function f9(a){return a>.008856451679035631?Math.pow(a,1/3):a/f6+f5}function ga(a){return a>aZ?a*a*a:f6*(a-f5)}function gb(a){return 255*(a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055)}function gc(a){return(a/=255)<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}function cr(a){const b=gc(a.r),c=gc(a.g),d=gc(a.b),f=f9((.4124564*b+.3575761*c+.1804375*d)/.95047),e=f9((.2126729*b+.7151522*c+.072175*d)/1);return{l:116*e-16,a:500*(f-e),b:200*(e-f9((.0193339*b+.119192*c+.9503041*d)/1.08883)),alpha:a.a}}function cs(b){let a=(b.l+16)/116,c=isNaN(b.a)?a:a+b.a/500,d=isNaN(b.b)?a:a-b.b/200;return a=1*ga(a),c=.95047*ga(c),d=1.08883*ga(d),new m(gb(3.2404542*c-1.5371385*a-.4985314*d),gb(-0.969266*c+1.8760108*a+.041556*d),gb(.0556434*c-.2040259*a+1.0572252*d),b.alpha)}const ct={forward:cr,reverse:cs,interpolate:function(a,b,c){return{l:aY(a.l,b.l,c),a:aY(a.a,b.a,c),b:aY(a.b,b.b,c),alpha:aY(a.alpha,b.alpha,c)}}},cu={forward:function(d){const{l:e,a:a,b:b}=cr(d),c=Math.atan2(b,a)*f8;return{h:c<0?c+360:c,c:Math.sqrt(a*a+b*b),l:e,alpha:d.a}},reverse:function(a){const b=a.h*f7,c=a.c;return cs({l:a.l,a:Math.cos(b)*c,b:Math.sin(b)*c,alpha:a.alpha})},interpolate:function(a,b,c){return{h:function(b,c,d){const a=c-b;return b+d*(a>180||a< -180?a-360*Math.round(a/360):a)}(a.h,b.h,c),c:aY(a.c,b.c,c),l:aY(a.l,b.l,c),alpha:aY(a.alpha,b.alpha,c)}}};var gd=Object.freeze({__proto__:null,lab:ct,hcl:cu});class ai{constructor(a,b,c,d,e){for(const[f,g]of(this.type=a,this.operator=b,this.interpolation=c,this.input=d,this.labels=[],this.outputs=[],e))this.labels.push(f),this.outputs.push(g)}static interpolationFactor(a,d,e,f){let b=0;if("exponential"===a.name)b=ge(d,a.base,e,f);else if("linear"===a.name)b=ge(d,1,e,f);else if("cubic-bezier"===a.name){const c=a.controlPoints;b=new eG(c[0],c[1],c[2],c[3]).solve(ge(d,1,e,f))}return b}static parse(g,a){let[h,b,i,...j]=g;if(!Array.isArray(b)||0===b.length)return a.error("Expected an interpolation type expression.",1);if("linear"===b[0])b={name:"linear"};else if("exponential"===b[0]){const n=b[1];if("number"!=typeof n)return a.error("Exponential interpolation requires a numeric base.",1,1);b={name:"exponential",base:n}}else{if("cubic-bezier"!==b[0])return a.error(`Unknown interpolation type ${String(b[0])}`,1,0);{const k=b.slice(1);if(4!==k.length||k.some(a=>"number"!=typeof a||a<0||a>1))return a.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);b={name:"cubic-bezier",controlPoints:k}}}if(g.length-1<4)return a.error(`Expected at least 4 arguments, but found only ${g.length-1}.`);if((g.length-1)%2!=0)return a.error("Expected an even number of arguments.");if(!(i=a.parse(i,2,f)))return null;const e=[];let c=null;"interpolate-hcl"===h||"interpolate-lab"===h?c=y:a.expectedType&&"value"!==a.expectedType.kind&&(c=a.expectedType);for(let d=0;d<j.length;d+=2){const l=j[d],p=j[d+1],o=d+3,q=d+4;if("number"!=typeof l)return a.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(e.length&&e[e.length-1][0]>=l)return a.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',o);const m=a.parse(p,q,c);if(!m)return null;c=c||m.type,e.push([l,m])}return"number"===c.kind||"color"===c.kind||"array"===c.kind&&"number"===c.itemType.kind&&"number"==typeof c.N?new ai(c,h,b,i,e):a.error(`Type ${ft(c)} is not interpolatable.`)}evaluate(b){const a=this.labels,c=this.outputs;if(1===a.length)return c[0].evaluate(b);const d=this.input.evaluate(b);if(d<=a[0])return c[0].evaluate(b);const i=a.length;if(d>=a[i-1])return c[i-1].evaluate(b);const e=f3(a,d),f=ai.interpolationFactor(this.interpolation,d,a[e],a[e+1]),g=c[e].evaluate(b),h=c[e+1].evaluate(b);return"interpolate"===this.operator?f4[this.type.kind.toLowerCase()](g,h,f):"interpolate-hcl"===this.operator?cu.reverse(cu.interpolate(cu.forward(g),cu.forward(h),f)):ct.reverse(ct.interpolate(ct.forward(g),ct.forward(h),f))}eachChild(a){for(const b of(a(this.input),this.outputs))a(b)}outputDefined(){return this.outputs.every(a=>a.outputDefined())}serialize(){let b;b="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 c=[this.operator,b,this.input.serialize(),];for(let a=0;a<this.labels.length;a++)c.push(this.labels[a],this.outputs[a].serialize());return c}}function ge(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}class cv{constructor(a,b){this.type=a,this.args=b}static parse(f,d){if(f.length<2)return d.error("Expectected at least one argument.");let a=null;const b=d.expectedType;b&&"value"!==b.kind&&(a=b);const c=[];for(const g of f.slice(1)){const e=d.parse(g,1+c.length,a,void 0,{typeAnnotation:"omit"});if(!e)return null;a=a||e.type,c.push(e)}const h=b&&c.some(a=>fv(b,a.type));return new cv(h?l:a,c)}evaluate(d){let b,a=null,c=0;for(const e of this.args){if(c++,(a=e.evaluate(d))&&a instanceof cj&&!a.available&&(b||(b=a),a=null,c===this.args.length))return b;if(null!==a)break}return a}eachChild(a){this.args.forEach(a)}outputDefined(){return this.args.every(a=>a.outputDefined())}serialize(){const a=["coalesce"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cw{constructor(b,a){this.type=a.type,this.bindings=[].concat(b),this.result=a}evaluate(a){return this.result.evaluate(a)}eachChild(a){for(const b of this.bindings)a(b[1]);a(this.result)}static parse(a,c){if(a.length<4)return c.error(`Expected at least 3 arguments, but found ${a.length-1} instead.`);const e=[];for(let b=1;b<a.length-1;b+=2){const d=a[b];if("string"!=typeof d)return c.error(`Expected string, but found ${typeof d} instead.`,b);if(/[^a-zA-Z0-9_]/.test(d))return c.error("Variable names must contain only alphanumeric characters or '_'.",b);const f=c.parse(a[b+1],b+1);if(!f)return null;e.push([d,f])}const g=c.parse(a[a.length-1],a.length-1,c.expectedType,e);return g?new cw(e,g):null}outputDefined(){return this.result.outputDefined()}serialize(){const a=["let"];for(const[b,c]of this.bindings)a.push(b,c.serialize());return a.push(this.result.serialize()),a}}class cx{constructor(a,b,c){this.type=a,this.index=b,this.input=c}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const d=b.parse(a[1],1,f),c=b.parse(a[2],2,z(b.expectedType||l));return d&&c?new cx(c.type.itemType,d,c):null}evaluate(c){const a=this.index.evaluate(c),b=this.input.evaluate(c);if(a<0)throw new fG(`Array index out of bounds: ${a} < 0.`);if(a>=b.length)throw new fG(`Array index out of bounds: ${a} > ${b.length-1}.`);if(a!==Math.floor(a))throw new fG(`Array index must be an integer, but found ${a} instead.`);return b[a]}eachChild(a){a(this.index),a(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize(),]}}class cy{constructor(a,b){this.type=h,this.needle=a,this.haystack=b}static parse(a,b){if(3!==a.length)return b.error(`Expected 2 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);return c&&d?fw(c.type,[h,i,f,cf,l])?new cy(c,d):b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`):null}evaluate(c){const b=this.needle.evaluate(c),a=this.haystack.evaluate(c);if(!a)return!1;if(!fx(b,["boolean","string","number","null",]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(b))} instead.`);if(!fx(a,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(a))} instead.`);return a.indexOf(b)>=0}eachChild(a){a(this.needle),a(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize(),]}}class cz{constructor(a,b,c){this.type=f,this.needle=a,this.haystack=b,this.fromIndex=c}static parse(a,b){if(a.length<=2||a.length>=5)return b.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const c=b.parse(a[1],1,l),d=b.parse(a[2],2,l);if(!c||!d)return null;if(!fw(c.type,[h,i,f,cf,l]))return b.error(`Expected first argument to be of type boolean, string, number or null, but found ${ft(c.type)} instead`);if(4===a.length){const e=b.parse(a[3],3,f);return e?new cz(c,d,e):null}return new cz(c,d)}evaluate(c){const a=this.needle.evaluate(c),b=this.haystack.evaluate(c);if(!fx(a,["boolean","string","number","null",]))throw new fG(`Expected first argument to be of type boolean, string, number or null, but found ${ft(fE(a))} instead.`);if(!fx(b,["string","array"]))throw new fG(`Expected second argument to be of type array or string, but found ${ft(fE(b))} instead.`);if(this.fromIndex){const d=this.fromIndex.evaluate(c);return b.indexOf(a,d)}return b.indexOf(a)}eachChild(a){a(this.needle),a(this.haystack),this.fromIndex&&a(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&& void 0!==this.fromIndex){const a=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),a,]}return["index-of",this.needle.serialize(),this.haystack.serialize(),]}}class cA{constructor(a,b,c,d,e,f){this.inputType=a,this.type=b,this.input=c,this.cases=d,this.outputs=e,this.otherwise=f}static parse(b,c){if(b.length<5)return c.error(`Expected at least 4 arguments, but found only ${b.length-1}.`);if(b.length%2!=1)return c.error("Expected an even number of arguments.");let g,d;c.expectedType&&"value"!==c.expectedType.kind&&(d=c.expectedType);const j={},k=[];for(let e=2;e<b.length-1;e+=2){let h=b[e];const o=b[e+1];Array.isArray(h)||(h=[h]);const f=c.concat(e);if(0===h.length)return f.error("Expected at least one branch label.");for(const a of h){if("number"!=typeof a&&"string"!=typeof a)return f.error("Branch labels must be numbers or strings.");if("number"==typeof a&&Math.abs(a)>Number.MAX_SAFE_INTEGER)return f.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof a&&Math.floor(a)!==a)return f.error("Numeric branch labels must be integer values.");if(g){if(f.checkSubtype(g,fE(a)))return null}else g=fE(a);if(void 0!==j[String(a)])return f.error("Branch labels must be unique.");j[String(a)]=k.length}const m=c.parse(o,e,d);if(!m)return null;d=d||m.type,k.push(m)}const i=c.parse(b[1],1,l);if(!i)return null;const n=c.parse(b[b.length-1],b.length-1,d);return n?"value"!==i.type.kind&&c.concat(1).checkSubtype(g,i.type)?null:new cA(g,d,i,j,k,n):null}evaluate(a){const b=this.input.evaluate(a);return(fE(b)===this.inputType&&this.outputs[this.cases[b]]||this.otherwise).evaluate(a)}eachChild(a){a(this.input),this.outputs.forEach(a),a(this.otherwise)}outputDefined(){return this.outputs.every(a=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const b=["match",this.input.serialize()],h=Object.keys(this.cases).sort(),c=[],e={};for(const a of h){const f=e[this.cases[a]];void 0===f?(e[this.cases[a]]=c.length,c.push([this.cases[a],[a]])):c[f][1].push(a)}const g=a=>"number"===this.inputType.kind?Number(a):a;for(const[i,d]of c)b.push(1===d.length?g(d[0]):d.map(g)),b.push(this.outputs[i].serialize());return b.push(this.otherwise.serialize()),b}}class cB{constructor(a,b,c){this.type=a,this.branches=b,this.otherwise=c}static parse(a,b){if(a.length<4)return b.error(`Expected at least 3 arguments, but found only ${a.length-1}.`);if(a.length%2!=0)return b.error("Expected an odd number of arguments.");let c;b.expectedType&&"value"!==b.expectedType.kind&&(c=b.expectedType);const f=[];for(let d=1;d<a.length-1;d+=2){const g=b.parse(a[d],d,h);if(!g)return null;const e=b.parse(a[d+1],d+1,c);if(!e)return null;f.push([g,e]),c=c||e.type}const i=b.parse(a[a.length-1],a.length-1,c);return i?new cB(c,f,i):null}evaluate(a){for(const[b,c]of this.branches)if(b.evaluate(a))return c.evaluate(a);return this.otherwise.evaluate(a)}eachChild(a){for(const[b,c]of this.branches)a(b),a(c);a(this.otherwise)}outputDefined(){return this.branches.every(([b,a])=>a.outputDefined())&&this.otherwise.outputDefined()}serialize(){const a=["case"];return this.eachChild(b=>{a.push(b.serialize())}),a}}class cC{constructor(a,b,c,d){this.type=a,this.input=b,this.beginIndex=c,this.endIndex=d}static parse(a,c){if(a.length<=2||a.length>=5)return c.error(`Expected 3 or 4 arguments, but found ${a.length-1} instead.`);const b=c.parse(a[1],1,l),d=c.parse(a[2],2,f);if(!b||!d)return null;if(!fw(b.type,[z(l),i,l]))return c.error(`Expected first argument to be of type array or string, but found ${ft(b.type)} instead`);if(4===a.length){const e=c.parse(a[3],3,f);return e?new cC(b.type,b,d,e):null}return new cC(b.type,b,d)}evaluate(b){const a=this.input.evaluate(b),c=this.beginIndex.evaluate(b);if(!fx(a,["string","array"]))throw new fG(`Expected first argument to be of type array or string, but found ${ft(fE(a))} instead.`);if(this.endIndex){const d=this.endIndex.evaluate(b);return a.slice(c,d)}return a.slice(c)}eachChild(a){a(this.input),a(this.beginIndex),this.endIndex&&a(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&& void 0!==this.endIndex){const a=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),a,]}return["slice",this.input.serialize(),this.beginIndex.serialize(),]}}function gf(b,a){return"=="===b||"!="===b?"boolean"===a.kind||"string"===a.kind||"number"===a.kind||"null"===a.kind||"value"===a.kind:"string"===a.kind||"number"===a.kind||"value"===a.kind}function cD(d,a,b,c){return 0===c.compare(a,b)}function A(a,b,c){const d="=="!==a&&"!="!==a;return class e{constructor(a,b,c){this.type=h,this.lhs=a,this.rhs=b,this.collator=c,this.hasUntypedArgument="value"===a.type.kind||"value"===b.type.kind}static parse(f,c){if(3!==f.length&&4!==f.length)return c.error("Expected two or three arguments.");const g=f[0];let a=c.parse(f[1],1,l);if(!a)return null;if(!gf(g,a.type))return c.concat(1).error(`"${g}" comparisons are not supported for type '${ft(a.type)}'.`);let b=c.parse(f[2],2,l);if(!b)return null;if(!gf(g,b.type))return c.concat(2).error(`"${g}" comparisons are not supported for type '${ft(b.type)}'.`);if(a.type.kind!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error(`Cannot compare types '${ft(a.type)}' and '${ft(b.type)}'.`);d&&("value"===a.type.kind&&"value"!==b.type.kind?a=new L(b.type,[a]):"value"!==a.type.kind&&"value"===b.type.kind&&(b=new L(a.type,[b])));let h=null;if(4===f.length){if("string"!==a.type.kind&&"string"!==b.type.kind&&"value"!==a.type.kind&&"value"!==b.type.kind)return c.error("Cannot use collator to compare non-string types.");if(!(h=c.parse(f[3],3,cg)))return null}return new e(a,b,h)}evaluate(e){const f=this.lhs.evaluate(e),g=this.rhs.evaluate(e);if(d&&this.hasUntypedArgument){const h=fE(f),i=fE(g);if(h.kind!==i.kind||"string"!==h.kind&&"number"!==h.kind)throw new fG(`Expected arguments for "${a}" to be (string, string) or (number, number), but found (${h.kind}, ${i.kind}) instead.`)}if(this.collator&&!d&&this.hasUntypedArgument){const j=fE(f),k=fE(g);if("string"!==j.kind||"string"!==k.kind)return b(e,f,g)}return this.collator?c(e,f,g,this.collator.evaluate(e)):b(e,f,g)}eachChild(a){a(this.lhs),a(this.rhs),this.collator&&a(this.collator)}outputDefined(){return!0}serialize(){const b=[a];return this.eachChild(a=>{b.push(a.serialize())}),b}}}const cE=A("==",function(c,a,b){return a===b},cD),cF=A("!=",function(c,a,b){return a!==b},function(d,a,b,c){return!cD(0,a,b,c)}),cG=A("<",function(c,a,b){return a<b},function(d,a,b,c){return 0>c.compare(a,b)}),cH=A(">",function(c,a,b){return a>b},function(d,a,b,c){return c.compare(a,b)>0}),cI=A("<=",function(c,a,b){return a<=b},function(d,a,b,c){return 0>=c.compare(a,b)}),cJ=A(">=",function(c,a,b){return a>=b},function(d,a,b,c){return c.compare(a,b)>=0});class cK{constructor(a,b,c,d,e){this.type=i,this.number=a,this.locale=b,this.currency=c,this.minFractionDigits=d,this.maxFractionDigits=e}static parse(c,b){if(3!==c.length)return b.error("Expected two arguments.");const d=b.parse(c[1],1,f);if(!d)return null;const a=c[2];if("object"!=typeof a||Array.isArray(a))return b.error("NumberFormat options argument must be an object.");let e=null;if(a.locale&&!(e=b.parse(a.locale,1,i)))return null;let g=null;if(a.currency&&!(g=b.parse(a.currency,1,i)))return null;let h=null;if(a["min-fraction-digits"]&&!(h=b.parse(a["min-fraction-digits"],1,f)))return null;let j=null;return!a["max-fraction-digits"]||(j=b.parse(a["max-fraction-digits"],1,f))?new cK(d,e,g,h,j):null}evaluate(a){return new Intl.NumberFormat(this.locale?this.locale.evaluate(a):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(a):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(a):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(a):void 0}).format(this.number.evaluate(a))}eachChild(a){a(this.number),this.locale&&a(this.locale),this.currency&&a(this.currency),this.minFractionDigits&&a(this.minFractionDigits),this.maxFractionDigits&&a(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const a={};return this.locale&&(a.locale=this.locale.serialize()),this.currency&&(a.currency=this.currency.serialize()),this.minFractionDigits&&(a["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(a["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),a,]}}class cL{constructor(a){this.type=f,this.input=a}static parse(b,c){if(2!==b.length)return c.error(`Expected 1 argument, but found ${b.length-1} instead.`);const a=c.parse(b[1],1);return a?"array"!==a.type.kind&&"string"!==a.type.kind&&"value"!==a.type.kind?c.error(`Expected argument of type string or array, but found ${ft(a.type)} instead.`):new cL(a):null}evaluate(b){const a=this.input.evaluate(b);if("string"==typeof a||Array.isArray(a))return a.length;throw new fG(`Expected value to be of type string or array, but found ${ft(fE(a))} instead.`)}eachChild(a){a(this.input)}outputDefined(){return!1}serialize(){const a=["length"];return this.eachChild(b=>{a.push(b.serialize())}),a}}const U={"==":cE,"!=":cF,">":cH,"<":cG,">=":cJ,"<=":cI,array:L,at:cx,boolean:L,case:cB,coalesce:cv,collator:cn,format:cl,image:cm,in:cy,"index-of":cz,interpolate:ai,"interpolate-hcl":ai,"interpolate-lab":ai,length:cL,let:cw,literal:ck,match:cA,number:L,"number-format":cK,object:L,slice:cC,step:cq,string:L,"to-boolean":T,"to-color":T,"to-number":T,"to-string":T,var:cp,within:co};function a$(b,[c,d,e,f]){c=c.evaluate(b),d=d.evaluate(b),e=e.evaluate(b);const a=f?f.evaluate(b):1,g=fC(c,d,e,a);if(g)throw new fG(g);return new m(c/255*a,d/255*a,e/255*a,a)}function gg(b,c){const a=c[b];return void 0===a?null:a}function x(a){return{type:a}}function gh(a){return{result:"success",value:a}}function gi(a){return{result:"error",value:a}}function gj(a){return"data-driven"===a["property-type"]||"cross-faded-data-driven"===a["property-type"]}function gk(a){return!!a.expression&&a.expression.parameters.indexOf("zoom")> -1}function gl(a){return!!a.expression&&a.expression.interpolated}function gm(a){return a instanceof Number?"number":a instanceof String?"string":a instanceof Boolean?"boolean":Array.isArray(a)?"array":null===a?"null":typeof a}function gn(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function go(a){return a}function gp(a,e){const r="color"===e.type,g=a.stops&&"object"==typeof a.stops[0][0],s=g||!(g|| void 0!==a.property),b=a.type||(gl(e)?"exponential":"interval");if(r&&((a=ce({},a)).stops&&(a.stops=a.stops.map(a=>[a[0],m.parse(a[1]),])),a.default=m.parse(a.default?a.default:e.default)),a.colorSpace&&"rgb"!==a.colorSpace&&!gd[a.colorSpace])throw Error(`Unknown color space: ${a.colorSpace}`);let f,j,t;if("exponential"===b)f=gt;else if("interval"===b)f=gs;else if("categorical"===b){for(const k of(f=gr,j=Object.create(null),a.stops))j[k[0]]=k[1];t=typeof a.stops[0][0]}else{if("identity"!==b)throw Error(`Unknown function type "${b}"`);f=gu}if(g){const c={},l=[];for(let h=0;h<a.stops.length;h++){const i=a.stops[h],d=i[0].zoom;void 0===c[d]&&(c[d]={zoom:d,type:a.type,property:a.property,default:a.default,stops:[]},l.push(d)),c[d].stops.push([i[0].value,i[1]])}const n=[];for(const o of l)n.push([c[o].zoom,gp(c[o],e)]);const p={name:"linear"};return{kind:"composite",interpolationType:p,interpolationFactor:ai.interpolationFactor.bind(void 0,p),zoomStops:n.map(a=>a[0]),evaluate:({zoom:b},c)=>gt({stops:n,base:a.base},e,b).evaluate(b,c)}}if(s){const q="exponential"===b?{name:"exponential",base:void 0!==a.base?a.base:1}:null;return{kind:"camera",interpolationType:q,interpolationFactor:ai.interpolationFactor.bind(void 0,q),zoomStops:a.stops.map(a=>a[0]),evaluate:({zoom:b})=>f(a,e,b,j,t)}}return{kind:"source",evaluate(d,b){const c=b&&b.properties?b.properties[a.property]:void 0;return void 0===c?gq(a.default,e.default):f(a,e,c,j,t)}}}function gq(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:void 0}function gr(b,c,a,d,e){return gq(typeof a===e?d[a]:void 0,b.default,c.default)}function gs(a,d,b){if("number"!==gm(b))return gq(a.default,d.default);const c=a.stops.length;if(1===c||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[c-1][0])return a.stops[c-1][1];const e=f3(a.stops.map(a=>a[0]),b);return a.stops[e][1]}function gt(a,e,b){const h=void 0!==a.base?a.base:1;if("number"!==gm(b))return gq(a.default,e.default);const d=a.stops.length;if(1===d||b<=a.stops[0][0])return a.stops[0][1];if(b>=a.stops[d-1][0])return a.stops[d-1][1];const c=f3(a.stops.map(a=>a[0]),b),i=function(e,a,c,f){const b=f-c,d=e-c;return 0===b?0:1===a?d/b:(Math.pow(a,d)-1)/(Math.pow(a,b)-1)}(b,h,a.stops[c][0],a.stops[c+1][0]),f=a.stops[c][1],j=a.stops[c+1][1];let g=f4[e.type]||go;if(a.colorSpace&&"rgb"!==a.colorSpace){const k=gd[a.colorSpace];g=(a,b)=>k.reverse(k.interpolate(k.forward(a),k.forward(b),i))}return"function"==typeof f.evaluate?{evaluate(...a){const b=f.evaluate.apply(void 0,a),c=j.evaluate.apply(void 0,a);if(void 0!==b&& void 0!==c)return g(b,c,i)}}:g(f,j,i)}function gu(c,b,a){return"color"===b.type?a=m.parse(a):"formatted"===b.type?a=fB.fromString(a.toString()):"resolvedImage"===b.type?a=cj.fromString(a.toString()):gm(a)===b.type||"enum"===b.type&&b.values[a]||(a=void 0),gq(a,c.default,b.default)}aX.register(U,{error:[{kind:"error"},[i],(a,[b])=>{throw new fG(b.evaluate(a))},],typeof:[i,[l],(a,[b])=>ft(fE(b.evaluate(a))),],"to-rgba":[z(f,4),[y],(a,[b])=>b.evaluate(a).toArray(),],rgb:[y,[f,f,f],a$],rgba:[y,[f,f,f,f],a$],has:{type:h,overloads:[[[i],(a,[d])=>{var b,c;return b=d.evaluate(a),c=a.properties(),b in c},],[[i,K],(a,[b,c])=>b.evaluate(a) in c.evaluate(a),],]},get:{type:l,overloads:[[[i],(a,[b])=>gg(b.evaluate(a),a.properties()),],[[i,K],(a,[b,c])=>gg(b.evaluate(a),c.evaluate(a)),],]},"feature-state":[l,[i],(a,[b])=>gg(b.evaluate(a),a.featureState||{}),],properties:[K,[],a=>a.properties()],"geometry-type":[i,[],a=>a.geometryType()],id:[l,[],a=>a.id()],zoom:[f,[],a=>a.globals.zoom],pitch:[f,[],a=>a.globals.pitch||0],"distance-from-center":[f,[],a=>a.distanceFromCenter(),],"heatmap-density":[f,[],a=>a.globals.heatmapDensity||0,],"line-progress":[f,[],a=>a.globals.lineProgress||0,],"sky-radial-progress":[f,[],a=>a.globals.skyRadialProgress||0,],accumulated:[l,[],a=>void 0===a.globals.accumulated?null:a.globals.accumulated,],"+":[f,x(f),(b,c)=>{let a=0;for(const d of c)a+=d.evaluate(b);return a},],"*":[f,x(f),(b,c)=>{let a=1;for(const d of c)a*=d.evaluate(b);return a},],"-":{type:f,overloads:[[[f,f],(a,[b,c])=>b.evaluate(a)-c.evaluate(a),],[[f],(a,[b])=>-b.evaluate(a)],]},"/":[f,[f,f],(a,[b,c])=>b.evaluate(a)/c.evaluate(a),],"%":[f,[f,f],(a,[b,c])=>b.evaluate(a)%c.evaluate(a),],ln2:[f,[],()=>Math.LN2],pi:[f,[],()=>Math.PI],e:[f,[],()=>Math.E],"^":[f,[f,f],(a,[b,c])=>Math.pow(b.evaluate(a),c.evaluate(a)),],sqrt:[f,[f],(a,[b])=>Math.sqrt(b.evaluate(a)),],log10:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN10,],ln:[f,[f],(a,[b])=>Math.log(b.evaluate(a))],log2:[f,[f],(a,[b])=>Math.log(b.evaluate(a))/Math.LN2,],sin:[f,[f],(a,[b])=>Math.sin(b.evaluate(a)),],cos:[f,[f],(a,[b])=>Math.cos(b.evaluate(a)),],tan:[f,[f],(a,[b])=>Math.tan(b.evaluate(a)),],asin:[f,[f],(a,[b])=>Math.asin(b.evaluate(a)),],acos:[f,[f],(a,[b])=>Math.acos(b.evaluate(a)),],atan:[f,[f],(a,[b])=>Math.atan(b.evaluate(a)),],min:[f,x(f),(b,a)=>Math.min(...a.map(a=>a.evaluate(b))),],max:[f,x(f),(b,a)=>Math.max(...a.map(a=>a.evaluate(b))),],abs:[f,[f],(a,[b])=>Math.abs(b.evaluate(a)),],round:[f,[f],(b,[c])=>{const a=c.evaluate(b);return a<0?-Math.round(-a):Math.round(a)},],floor:[f,[f],(a,[b])=>Math.floor(b.evaluate(a)),],ceil:[f,[f],(a,[b])=>Math.ceil(b.evaluate(a)),],"filter-==":[h,[i,l],(a,[b,c])=>a.properties()[b.value]===c.value,],"filter-id-==":[h,[l],(a,[b])=>a.id()===b.value,],"filter-type-==":[h,[i],(a,[b])=>a.geometryType()===b.value,],"filter-<":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<b},],"filter-id-<":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<b},],"filter->":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>b},],"filter-id->":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>b},],"filter-<=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a<=b},],"filter-id-<=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a<=b},],"filter->=":[h,[i,l],(c,[d,e])=>{const a=c.properties()[d.value],b=e.value;return typeof a==typeof b&&a>=b},],"filter-id->=":[h,[l],(c,[d])=>{const a=c.id(),b=d.value;return typeof a==typeof b&&a>=b},],"filter-has":[h,[l],(a,[b])=>b.value in a.properties(),],"filter-has-id":[h,[],a=>null!==a.id()&& void 0!==a.id(),],"filter-type-in":[h,[z(i)],(a,[b])=>b.value.indexOf(a.geometryType())>=0,],"filter-id-in":[h,[z(l)],(a,[b])=>b.value.indexOf(a.id())>=0,],"filter-in-small":[h,[i,z(l)],(a,[b,c])=>c.value.indexOf(a.properties()[b.value])>=0,],"filter-in-large":[h,[i,z(l)],(b,[c,a])=>(function(d,e,b,c){for(;b<=c;){const a=b+c>>1;if(e[a]===d)return!0;e[a]>d?c=a-1:b=a+1}return!1})(b.properties()[c.value],a.value,0,a.value.length-1),],all:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)&&c.evaluate(a),],[x(h),(a,b)=>{for(const c of b)if(!c.evaluate(a))return!1;return!0},],]},any:{type:h,overloads:[[[h,h],(a,[b,c])=>b.evaluate(a)||c.evaluate(a),],[x(h),(a,b)=>{for(const c of b)if(c.evaluate(a))return!0;return!1},],]},"!":[h,[h],(a,[b])=>!b.evaluate(a)],"is-supported-script":[h,[i],(a,[c])=>{const b=a.globals&&a.globals.isSupportedScript;return!b||b(c.evaluate(a))},],upcase:[i,[i],(a,[b])=>b.evaluate(a).toUpperCase(),],downcase:[i,[i],(a,[b])=>b.evaluate(a).toLowerCase(),],concat:[i,x(l),(b,a)=>a.map(a=>fF(a.evaluate(b))).join(""),],"resolved-locale":[i,[cg],(a,[b])=>b.evaluate(a).resolvedLocale(),]});class cM{constructor(c,b){var a;this.expression=c,this._warningHistory={},this._evaluator=new fK,this._defaultValue=b?"color"===(a=b).type&&gn(a.default)?new m(0,0,0,0):"color"===a.type?m.parse(a.default)||null:void 0===a.default?null:a.default:null,this._enumValues=b&&"enum"===b.type?b.values:null}evaluateWithoutErrorHandling(a,b,c,d,e,f,g,h){return this._evaluator.globals=a,this._evaluator.feature=b,this._evaluator.featureState=c,this._evaluator.canonical=d,this._evaluator.availableImages=e||null,this._evaluator.formattedSection=f,this._evaluator.featureTileCoord=g||null,this._evaluator.featureDistanceData=h||null,this.expression.evaluate(this._evaluator)}evaluate(c,d,e,f,g,h,i,j){this._evaluator.globals=c,this._evaluator.feature=d||null,this._evaluator.featureState=e||null,this._evaluator.canonical=f,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=h||null,this._evaluator.featureTileCoord=i||null,this._evaluator.featureDistanceData=j||null;try{const a=this.expression.evaluate(this._evaluator);if(null==a||"number"==typeof a&&a!=a)return this._defaultValue;if(this._enumValues&&!(a in this._enumValues))throw new fG(`Expected value to be one of ${Object.keys(this._enumValues).map(a=>JSON.stringify(a)).join(", ")}, but found ${JSON.stringify(a)} instead.`);return a}catch(b){return this._warningHistory[b.message]||(this._warningHistory[b.message]=!0,"undefined"!=typeof console&&console.warn(b.message)),this._defaultValue}}}function gv(a){return Array.isArray(a)&&a.length>0&&"string"==typeof a[0]&&a[0]in U}function cN(d,a){const b=new f1(U,[],a?function(a){const b={color:y,string:i,number:f,enum:i,boolean:h,formatted:ch,resolvedImage:ci};return"array"===a.type?z(b[a.value]||l,a.length):b[a.type]}(a):void 0),c=b.parse(d,void 0,void 0,void 0,a&&"string"===a.type?{typeAnnotation:"coerce"}:void 0);return c?gh(new cM(c,a)):gi(b.errors)}class cO{constructor(a,b){this.kind=a,this._styleExpression=b,this.isStateDependent="constant"!==a&&!f_(b.expression)}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}}class cP{constructor(a,b,c,d){this.kind=a,this.zoomStops=c,this._styleExpression=b,this.isStateDependent="camera"!==a&&!f_(b.expression),this.interpolationType=d}evaluateWithoutErrorHandling(a,b,c,d,e,f){return this._styleExpression.evaluateWithoutErrorHandling(a,b,c,d,e,f)}evaluate(a,b,c,d,e,f){return this._styleExpression.evaluate(a,b,c,d,e,f)}interpolationFactor(a,b,c){return this.interpolationType?ai.interpolationFactor(this.interpolationType,a,b,c):0}}function gw(b,c){if("error"===(b=cN(b,c)).result)return b;const d=b.value.expression,e=f$(d);if(!e&&!gj(c))return gi([new fr("","data expressions not supported"),]);const f=f0(d,["zoom","pitch","distance-from-center",]);if(!f&&!gk(c))return gi([new fr("","zoom expressions not supported"),]);const a=gx(d);return a||f?a instanceof fr?gi([a]):a instanceof ai&&!gl(c)?gi([new fr("",'"interpolate" expressions cannot be used with this property'),]):gh(a?new cP(e?"camera":"composite",b.value,a.labels,a instanceof ai?a.interpolation:void 0):new cO(e?"constant":"source",b.value)):gi([new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'),])}class cQ{constructor(a,b){this._parameters=a,this._specification=b,ce(this,gp(this._parameters,this._specification))}static deserialize(a){return new cQ(a._parameters,a._specification)}static serialize(a){return{_parameters:a._parameters,_specification:a._specification}}}function gx(a){let b=null;if(a instanceof cw)b=gx(a.result);else if(a instanceof cv){for(const c of a.args)if(b=gx(c))break}else(a instanceof cq||a instanceof ai)&&a.input instanceof aX&&"zoom"===a.input.name&&(b=a);return b instanceof fr||a.eachChild(c=>{const a=gx(c);a instanceof fr?b=a:!b&&a?b=new fr("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):b&&a&&b!==a&&(b=new fr("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),b}function cR(c){const d=c.key,a=c.value,b=c.valueSpec||{},f=c.objectElementValidators||{},l=c.style,m=c.styleSpec;let g=[];const k=gm(a);if("object"!==k)return[new cc(d,a,`object expected, ${k} found`),];for(const e in a){const j=e.split(".")[0],n=b[j]||b["*"];let h;if(f[j])h=f[j];else if(b[j])h=gR;else if(f["*"])h=f["*"];else{if(!b["*"]){g.push(new cc(d,a[e],`unknown property "${e}"`));continue}h=gR}g=g.concat(h({key:(d?`${d}.`:d)+e,value:a[e],valueSpec:n,style:l,styleSpec:m,object:a,objectKey:e},a))}for(const i in b)f[i]||b[i].required&& void 0===b[i].default&& void 0===a[i]&&g.push(new cc(d,a,`missing required property "${i}"`));return g}function cS(c){const b=c.value,a=c.valueSpec,i=c.style,h=c.styleSpec,e=c.key,j=c.arrayElementValidator||gR;if("array"!==gm(b))return[new cc(e,b,`array expected, ${gm(b)} found`),];if(a.length&&b.length!==a.length)return[new cc(e,b,`array length ${a.length} expected, length ${b.length} found`),];if(a["min-length"]&&b.length<a["min-length"])return[new cc(e,b,`array length at least ${a["min-length"]} expected, length ${b.length} found`),];let f={type:a.value,values:a.values,minimum:a.minimum,maximum:a.maximum};h.$version<7&&(f.function=a.function),"object"===gm(a.value)&&(f=a.value);let g=[];for(let d=0;d<b.length;d++)g=g.concat(j({array:b,arrayIndex:d,value:b[d],valueSpec:f,style:i,styleSpec:h,key:`${e}[${d}]`}));return g}function cT(c){const e=c.key,a=c.value,b=c.valueSpec;let d=gm(a);if("number"===d&&a!=a&&(d="NaN"),"number"!==d)return[new cc(e,a,`number expected, ${d} found`),];if("minimum"in b){let f=b.minimum;if("array"===gm(b.minimum)&&(f=b.minimum[c.arrayIndex]),a<f)return[new cc(e,a,`${a} is less than the minimum value ${f}`),]}if("maximum"in b){let g=b.maximum;if("array"===gm(b.maximum)&&(g=b.maximum[c.arrayIndex]),a>g)return[new cc(e,a,`${a} is greater than the maximum value ${g}`),]}return[]}function cU(a){const f=a.valueSpec,c=fp(a.value.type);let g,h,i,j={};const d="categorical"!==c&& void 0===a.value.property,e="array"===gm(a.value.stops)&&"array"===gm(a.value.stops[0])&&"object"===gm(a.value.stops[0][0]),b=cR({key:a.key,value:a.value,valueSpec:a.styleSpec.function,style:a.style,styleSpec:a.styleSpec,objectElementValidators:{stops:function(a){if("identity"===c)return[new cc(a.key,a.value,'identity function may not have a "stops" property'),];let b=[];const d=a.value;return b=b.concat(cS({key:a.key,value:d,valueSpec:a.valueSpec,style:a.style,styleSpec:a.styleSpec,arrayElementValidator:k})),"array"===gm(d)&&0===d.length&&b.push(new cc(a.key,d,"array must have at least one stop")),b},default:function(a){return gR({key:a.key,value:a.value,valueSpec:f,style:a.style,styleSpec:a.styleSpec})}}});return"identity"===c&&d&&b.push(new cc(a.key,a.value,'missing required property "property"')),"identity"===c||a.value.stops||b.push(new cc(a.key,a.value,'missing required property "stops"')),"exponential"===c&&a.valueSpec.expression&&!gl(a.valueSpec)&&b.push(new cc(a.key,a.value,"exponential functions not supported")),a.styleSpec.$version>=8&&(d||gj(a.valueSpec)?d&&!gk(a.valueSpec)&&b.push(new cc(a.key,a.value,"zoom functions not supported")):b.push(new cc(a.key,a.value,"property functions not supported"))),("categorical"===c||e)&& void 0===a.value.property&&b.push(new cc(a.key,a.value,'"property" property is required')),b;function k(c){let d=[];const a=c.value,b=c.key;if("array"!==gm(a))return[new cc(b,a,`array expected, ${gm(a)} found`),];if(2!==a.length)return[new cc(b,a,`array length 2 expected, length ${a.length} found`),];if(e){if("object"!==gm(a[0]))return[new cc(b,a,`object expected, ${gm(a[0])} found`),];if(void 0===a[0].zoom)return[new cc(b,a,"object stop key must have zoom"),];if(void 0===a[0].value)return[new cc(b,a,"object stop key must have value"),];if(i&&i>fp(a[0].zoom))return[new cc(b,a[0].zoom,"stop zoom values must appear in ascending order"),];fp(a[0].zoom)!==i&&(i=fp(a[0].zoom),h=void 0,j={}),d=d.concat(cR({key:`${b}[0]`,value:a[0],valueSpec:{zoom:{}},style:c.style,styleSpec:c.styleSpec,objectElementValidators:{zoom:cT,value:l}}))}else d=d.concat(l({key:`${b}[0]`,value:a[0],valueSpec:{},style:c.style,styleSpec:c.styleSpec},a));return gv(fq(a[1]))?d.concat([new cc(`${b}[1]`,a[1],"expressions are not allowed in function stops."),]):d.concat(gR({key:`${b}[1]`,value:a[1],valueSpec:f,style:c.style,styleSpec:c.styleSpec}))}function l(a,k){const b=gm(a.value),d=fp(a.value),e=null!==a.value?a.value:k;if(g){if(b!==g)return[new cc(a.key,e,`${b} stop domain type must match previous stop domain type ${g}`),]}else g=b;if("number"!==b&&"string"!==b&&"boolean"!==b)return[new cc(a.key,e,"stop domain value must be a number, string, or boolean"),];if("number"!==b&&"categorical"!==c){let i=`number expected, ${b} found`;return gj(f)&& void 0===c&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new cc(a.key,e,i)]}return"categorical"!==c||"number"!==b||isFinite(d)&&Math.floor(d)===d?"categorical"!==c&&"number"===b&& void 0!==h&&d<h?[new cc(a.key,e,"stop domain values must appear in ascending order"),]:(h=d,"categorical"===c&&d in j?[new cc(a.key,e,"stop domain values must be unique"),]:(j[d]=!0,[])):[new cc(a.key,e,`integer expected, found ${d}`),]}}function gy(a){const c=("property"===a.expressionContext?gw:cN)(fq(a.value),a.valueSpec);if("error"===c.result)return c.value.map(b=>new cc(`${a.key}${b.key}`,a.value,b.message));const b=c.value.expression||c.value._styleExpression.expression;if("property"===a.expressionContext&&"text-font"===a.propertyKey&&!b.outputDefined())return[new cc(a.key,a.value,`Invalid data expression for "${a.propertyKey}". Output values must be contained as literals within the expression.`),];if("property"===a.expressionContext&&"layout"===a.propertyType&&!f_(b))return[new cc(a.key,a.value,'"feature-state" data expressions are not supported with layout properties.'),];if("filter"===a.expressionContext)return gz(b,a);if(a.expressionContext&&0===a.expressionContext.indexOf("cluster")){if(!f0(b,["zoom","feature-state"]))return[new cc(a.key,a.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.'),];if("cluster-initial"===a.expressionContext&&!f$(b))return[new cc(a.key,a.value,"Feature data expressions are not supported with initial expression part of cluster properties."),]}return[]}function gz(b,a){const c=new Set(["zoom","feature-state","pitch","distance-from-center",]);for(const d of a.valueSpec.expression.parameters)c.delete(d);if(0===c.size)return[];const e=[];return b instanceof aX&&c.has(b.name)?[new cc(a.key,a.value,`["${b.name}"] expression is not supported in a filter for a ${a.object.type} layer with id: ${a.object.id}`),]:(b.eachChild(b=>{e.push(...gz(b,a))}),e)}function cV(c){const e=c.key,a=c.value,b=c.valueSpec,d=[];return Array.isArray(b.values)?-1===b.values.indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${b.values.join(", ")}], ${JSON.stringify(a)} found`)):-1===Object.keys(b.values).indexOf(fp(a))&&d.push(new cc(e,a,`expected one of [${Object.keys(b.values).join(", ")}], ${JSON.stringify(a)} found`)),d}function gA(a){if(!0===a|| !1===a)return!0;if(!Array.isArray(a)||0===a.length)return!1;switch(a[0]){case"has":return a.length>=2&&"$id"!==a[1]&&"$type"!==a[1];case"in":return a.length>=3&&("string"!=typeof a[1]||Array.isArray(a[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==a.length||Array.isArray(a[1])||Array.isArray(a[2]);case"any":case"all":for(const b of a.slice(1))if(!gA(b)&&"boolean"!=typeof b)return!1;return!0;default:return!0}}function gB(a,k="fill"){if(null==a)return{filter:()=>!0,needGeometry:!1,needFeature:!1};gA(a)||(a=gI(a));const c=a;let d=!0;try{d=function(a){if(!gE(a))return a;let b=fq(a);return gD(b),b=gC(b)}(c)}catch(l){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
|
|
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
|
|
and paste the contents of this message in the report.
|
|
Thank you!
|
|
Filter Expression:
|
|
${JSON.stringify(c,null,2)}
|
|
`)}const f=b[`filter_${k}`],g=cN(d,f);let h=null;if("error"===g.result)throw Error(g.value.map(a=>`${a.key}: ${a.message}`).join(", "));h=(a,b,c)=>g.value.evaluate(a,b,{},c);let i=null,j=null;if(d!==c){const e=cN(c,f);if("error"===e.result)throw Error(e.value.map(a=>`${a.key}: ${a.message}`).join(", "));i=(a,b,c,d,f)=>e.value.evaluate(a,b,{},c,void 0,void 0,d,f),j=!f$(e.value.expression)}return{filter:h,dynamicFilter:i||void 0,needGeometry:gH(d),needFeature:!!j}}function gC(a){if(!Array.isArray(a))return a;const b=function(a){if(gF.has(a[0])){for(let b=1;b<a.length;b++)if(gE(a[b]))return!0}return a}(a);return!0===b?b:b.map(a=>gC(a))}function gD(a){let b=!1;const c=[];if("case"===a[0]){for(let d=1;d<a.length-1;d+=2)b=b||gE(a[d]),c.push(a[d+1]);c.push(a[a.length-1])}else if("match"===a[0]){b=b||gE(a[1]);for(let e=2;e<a.length-1;e+=2)c.push(a[e+1]);c.push(a[a.length-1])}else if("step"===a[0]){b=b||gE(a[1]);for(let f=1;f<a.length-1;f+=2)c.push(a[f+1])}b&&(a.length=0,a.push("any",...c));for(let g=1;g<a.length;g++)gD(a[g])}function gE(a){var c;if(!Array.isArray(a))return!1;if("pitch"===(c=a[0])||"distance-from-center"===c)return!0;for(let b=1;b<a.length;b++)if(gE(a[b]))return!0;return!1}const gF=new Set(["in","==","!=",">",">=","<","<=","to-boolean",]);function gG(a,b){return a<b?-1:a>b?1:0}function gH(a){if(!Array.isArray(a))return!1;if("within"===a[0])return!0;for(let b=1;b<a.length;b++)if(gH(a[b]))return!0;return!1}function gI(a){if(!a)return!0;const b=a[0];return a.length<=1?"any"!==b:"=="===b?gJ(a[1],a[2],"=="):"!="===b?gM(gJ(a[1],a[2],"==")):"<"===b||">"===b||"<="===b||">="===b?gJ(a[1],a[2],b):"any"===b?["any"].concat(a.slice(1).map(gI)):"all"===b?["all"].concat(a.slice(1).map(gI)):"none"===b?["all"].concat(a.slice(1).map(gI).map(gM)):"in"===b?gK(a[1],a.slice(2)):"!in"===b?gM(gK(a[1],a.slice(2))):"has"===b?gL(a[1]):"!has"===b?gM(gL(a[1])):"within"!==b||a}function gJ(c,a,b){switch(c){case"$type":return[`filter-type-${b}`,a];case"$id":return[`filter-id-${b}`,a];default:return[`filter-${b}`,c,a]}}function gK(b,a){if(0===a.length)return!1;switch(b){case"$type":return["filter-type-in",["literal",a]];case"$id":return["filter-id-in",["literal",a]];default:return a.length>200&&!a.some(b=>typeof b!=typeof a[0])?["filter-in-large",b,["literal",a.sort(gG)],]:["filter-in-small",b,["literal",a],]}}function gL(a){switch(a){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",a]}}function gM(a){return["!",a]}function a_(a){if(gA(fq(a.value))){const b=fq(a.layerType);return gy(ce({},a,{expressionContext:"filter",valueSpec:a.styleSpec[`filter_${b||"fill"}`]}))}return gN(a)}function gN(e){const a=e.value,c=e.key;if("array"!==gm(a))return[new cc(c,a,`array expected, ${gm(a)} found`),];const h=e.styleSpec;let d,b=[];if(a.length<1)return[new cc(c,a,"filter array must have at least 1 element"),];switch(b=b.concat(cV({key:`${c}[0]`,value:a[0],valueSpec:h.filter_operator,style:e.style,styleSpec:e.styleSpec})),fp(a[0])){case"<":case"<=":case">":case">=":a.length>=2&&"$type"===fp(a[1])&&b.push(new cc(c,a,`"$type" cannot be use with operator "${a[0]}"`));case"==":case"!=":3!==a.length&&b.push(new cc(c,a,`filter array for operator "${a[0]}" must have 3 elements`));case"in":case"!in":a.length>=2&&"string"!==(d=gm(a[1]))&&b.push(new cc(`${c}[1]`,a[1],`string expected, ${d} found`));for(let f=2;f<a.length;f++)d=gm(a[f]),"$type"===fp(a[1])?b=b.concat(cV({key:`${c}[${f}]`,value:a[f],valueSpec:h.geometry_type,style:e.style,styleSpec:e.styleSpec})):"string"!==d&&"number"!==d&&"boolean"!==d&&b.push(new cc(`${c}[${f}]`,a[f],`string, number, or boolean expected, ${d} found`));break;case"any":case"all":case"none":for(let g=1;g<a.length;g++)b=b.concat(gN({key:`${c}[${g}]`,value:a[g],style:e.style,styleSpec:e.styleSpec}));break;case"has":case"!has":d=gm(a[1]),2!==a.length?b.push(new cc(c,a,`filter array for "${a[0]}" operator must have 2 elements`)):"string"!==d&&b.push(new cc(`${c}[1]`,a[1],`string expected, ${d} found`));break;case"within":d=gm(a[1]),2!==a.length?b.push(new cc(c,a,`filter array for "${a[0]}" operator must have 2 elements`)):"object"!==d&&b.push(new cc(`${c}[1]`,a[1],`object expected, ${d} found`))}return b}function gO(b,i){const d=b.key,e=b.style,f=b.styleSpec,a=b.value,c=b.objectKey,g=f[`${i}_${b.layerType}`];if(!g)return[];const j=c.match(/^(.*)-transition$/);if("paint"===i&&j&&g[j[1]]&&g[j[1]].transition)return gR({key:d,value:a,valueSpec:f.transition,style:e,styleSpec:f});const h=b.valueSpec||g[c];if(!h)return[new cc(d,a,`unknown property "${c}"`),];let l;if("string"===gm(a)&&gj(h)&&!h.tokens&&(l=/^{([^}]+)}$/.exec(a)))return[new cc(d,a,`"${c}" does not support interpolation syntax
|
|
Use an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(l[1])} }\`.`),];const k=[];return"symbol"===b.layerType&&("text-field"===c&&e&&!e.glyphs&&k.push(new cc(d,a,'use of "text-field" requires a style "glyphs" property')),"text-font"===c&&gn(fq(a))&&"identity"===fp(a.type)&&k.push(new cc(d,a,'"text-font" does not support identity functions'))),k.concat(gR({key:b.key,value:a,valueSpec:h,style:e,styleSpec:f,expressionContext:"property",propertyType:i,propertyKey:c}))}function cW(a){return gO(a,"paint")}function cX(a){return gO(a,"layout")}function a0(d){let b=[];const a=d.value,c=d.key,g=d.style,l=d.styleSpec;a.type||a.ref||b.push(new cc(c,a,'either "type" or "ref" is required'));let e=fp(a.type);const m=fp(a.ref);if(a.id){const n=fp(a.id);for(let i=0;i<d.arrayIndex;i++){const k=g.layers[i];fp(k.id)===n&&b.push(new cc(c,a.id,`duplicate layer id "${a.id}", previously used at line ${k.id.__line__}`))}}if("ref"in a){let j;["type","source","source-layer","filter","layout",].forEach(d=>{d in a&&b.push(new cc(c,a[d],`"${d}" is prohibited for ref layers`))}),g.layers.forEach(a=>{fp(a.id)===m&&(j=a)}),j?j.ref?b.push(new cc(c,a.ref,"ref cannot reference another ref layer")):e=fp(j.type):b.push(new cc(c,a.ref,`ref layer "${m}" not found`))}else if("background"!==e&&"sky"!==e){if(a.source){const h=g.sources&&g.sources[a.source],f=h&&fp(h.type);h?"vector"===f&&"raster"===e?b.push(new cc(c,a.source,`layer "${a.id}" requires a raster source`)):"raster"===f&&"raster"!==e?b.push(new cc(c,a.source,`layer "${a.id}" requires a vector source`)):"vector"!==f||a["source-layer"]?"raster-dem"===f&&"hillshade"!==e?b.push(new cc(c,a.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"===e&&a.paint&&a.paint["line-gradient"]&&("geojson"!==f||!h.lineMetrics)&&b.push(new cc(c,a,`layer "${a.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):b.push(new cc(c,a,`layer "${a.id}" must specify a "source-layer"`)):b.push(new cc(c,a.source,`source "${a.source}" not found`))}else b.push(new cc(c,a,'missing required property "source"'))}return b=b.concat(cR({key:c,value:a,valueSpec:l.layer,style:d.style,styleSpec:d.styleSpec,objectElementValidators:{"*":()=>[],type:()=>gR({key:`${c}.type`,value:a.type,valueSpec:l.layer.type,style:d.style,styleSpec:d.styleSpec,object:a,objectKey:"type"}),filter:a=>a_(ce({layerType:e},a)),layout:b=>cR({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>cX(ce({layerType:e},a))}}),paint:b=>cR({layer:a,key:b.key,value:b.value,style:b.style,styleSpec:b.styleSpec,objectElementValidators:{"*":a=>cW(ce({layerType:e},a))}})}}))}function cY(a){const b=a.value,d=a.key,c=gm(b);return"string"!==c?[new cc(d,b,`string expected, ${c} found`)]:[]}const gP={promoteId:function({key:b,value:a}){if("string"===gm(a))return cY({key:b,value:a});{const c=[];for(const d in a)c.push(...cY({key:`${b}.${d}`,value:a[d]}));return c}}};function a1(d){const a=d.value,b=d.key,c=d.styleSpec,e=d.style;if(!a.type)return[new cc(b,a,'"type" is required')];const i=fp(a.type);let f;switch(i){case"vector":case"raster":case"raster-dem":return cR({key:b,value:a,valueSpec:c[`source_${i.replace("-","_")}`],style:d.style,styleSpec:c,objectElementValidators:gP});case"geojson":if(f=cR({key:b,value:a,valueSpec:c.source_geojson,style:e,styleSpec:c,objectElementValidators:gP}),a.cluster)for(const g in a.clusterProperties){const[h,j]=a.clusterProperties[g],k="string"==typeof h?[h,["accumulated"],["get",g],]:h;f.push(...gy({key:`${b}.${g}.map`,value:j,expressionContext:"cluster-map"})),f.push(...gy({key:`${b}.${g}.reduce`,value:k,expressionContext:"cluster-reduce"}))}return f;case"video":return cR({key:b,value:a,valueSpec:c.source_video,style:e,styleSpec:c});case"image":return cR({key:b,value:a,valueSpec:c.source_image,style:e,styleSpec:c});case"canvas":return[new cc(b,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas"),];default:return cV({key:`${b}.type`,value:a.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image",]},style:e,styleSpec:c})}}function a2(f){const b=f.value,d=f.styleSpec,e=d.light,h=f.style;let c=[];const i=gm(b);if(void 0===b)return c;if("object"!==i)return c.concat([new cc("light",b,`object expected, ${i} found`),]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?gR({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?gR({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new cc(a,b[a],`unknown property "${a}"`),])}return c}function a3(d){const a=d.value,h=d.key,e=d.style,f=d.styleSpec,g=f.terrain;let c=[];const k=gm(a);if(void 0===a)return c;if("object"!==k)return c.concat([new cc("terrain",a,`object expected, ${k} found`),]);for(const b in a){const i=b.match(/^(.*)-transition$/);c=c.concat(i&&g[i[1]]&&g[i[1]].transition?gR({key:b,value:a[b],valueSpec:f.transition,style:e,styleSpec:f}):g[b]?gR({key:b,value:a[b],valueSpec:g[b],style:e,styleSpec:f}):[new cc(b,a[b],`unknown property "${b}"`),])}if(a.source){const j=e.sources&&e.sources[a.source],l=j&&fp(j.type);j?"raster-dem"!==l&&c.push(new cc(h,a.source,`terrain cannot be used with a source of type ${l}, it only be used with a "raster-dem" source type`)):c.push(new cc(h,a.source,`source "${a.source}" not found`))}else c.push(new cc(h,a,'terrain is missing required property "source"'));return c}function a4(f){const b=f.value,h=f.style,d=f.styleSpec,e=d.fog;let c=[];const i=gm(b);if(void 0===b)return c;if("object"!==i)return c.concat([new cc("fog",b,`object expected, ${i} found`),]);for(const a in b){const g=a.match(/^(.*)-transition$/);c=c.concat(g&&e[g[1]]&&e[g[1]].transition?gR({key:a,value:b[a],valueSpec:d.transition,style:h,styleSpec:d}):e[a]?gR({key:a,value:b[a],valueSpec:e[a],style:h,styleSpec:d}):[new cc(a,b[a],`unknown property "${a}"`),])}return c}const gQ={"*":()=>[],array:cS,boolean:function(a){const b=a.value,d=a.key,c=gm(b);return"boolean"!==c?[new cc(d,b,`boolean expected, ${c} found`),]:[]},number:cT,color:function(b){const c=b.key,a=b.value,d=gm(a);return"string"!==d?[new cc(c,a,`color expected, ${d} found`),]:null===fy.parseCSSColor(a)?[new cc(c,a,`color expected, "${a}" found`),]:[]},constants:cd,enum:cV,filter:a_,function:cU,layer:a0,object:cR,source:a1,light:a2,terrain:a3,fog:a4,string:cY,formatted:function(a){return 0===cY(a).length?[]:gy(a)},resolvedImage:function(a){return 0===cY(a).length?[]:gy(a)},projection:function(c){const b=c.value,f=c.styleSpec,g=f.projection,h=c.style;let a=[];const d=gm(b);if("object"===d)for(const e in b)a=a.concat(gR({key:e,value:b[e],valueSpec:g[e],style:h,styleSpec:f}));else"string"!==d&&(a=a.concat([new cc("projection",b,`object or string expected, ${d} found`),]));return a}};function gR(b){const c=b.value,a=b.valueSpec,d=b.styleSpec;return a.expression&&gn(fp(c))?cU(b):a.expression&&gv(fq(c))?gy(b):a.type&&gQ[a.type]?gQ[a.type](b):cR(ce({},b,{valueSpec:a.type?d[a.type]:a}))}function gS(c){const a=c.value,d=c.key,b=cY(c);return b.length||(-1===a.indexOf("{fontstack}")&&b.push(new cc(d,a,'"glyphs" url must include a "{fontstack}" token')),-1===a.indexOf("{range}")&&b.push(new cc(d,a,'"glyphs" url must include a "{range}" token'))),b}function t(a,d=b){let c=[];return c=c.concat(gR({key:"",value:a,valueSpec:d.$root,styleSpec:d,style:a,objectElementValidators:{glyphs:gS,"*":()=>[]}})),a.constants&&(c=c.concat(cd({key:"constants",value:a.constants,style:a,styleSpec:d}))),gT(c)}function gT(a){return[].concat(a).sort((a,b)=>a.line-b.line)}function v(a){return function(...b){return gT(a.apply(this,b))}}t.source=v(a1),t.light=v(a2),t.terrain=v(a3),t.fog=v(a4),t.layer=v(a0),t.filter=v(a_),t.paintProperty=v(cW),t.layoutProperty=v(cX);const M=t,cZ=M.light,c$=M.fog,gU=M.paintProperty,gV=M.layoutProperty;function c_(c,a){let b=!1;if(a&&a.length)for(const d of a)c.fire(new cb(Error(d.message))),b=!0;return b}var aj=u;function u(b,c,d){var e=this.cells=[];if(b instanceof ArrayBuffer){this.arrayBuffer=b;var a=new Int32Array(this.arrayBuffer);b=a[0],this.d=(c=a[1])+2*(d=a[2]);for(var f=0;f<this.d*this.d;f++){var g=a[3+f],h=a[3+f+1];e.push(g===h?null:a.subarray(g,h))}var i=a[3+e.length+1];this.keys=a.subarray(a[3+e.length],i),this.bboxes=a.subarray(i),this.insert=this._insertReadonly}else{this.d=c+2*d;for(var j=0;j<this.d*this.d;j++)e.push([]);this.keys=[],this.bboxes=[]}this.n=c,this.extent=b,this.padding=d,this.scale=c/b,this.uid=0;var k=d/c*b;this.min=-k,this.max=b+k}u.prototype.insert=function(e,a,b,c,d){this._forEachCell(a,b,c,d,this._insertCell,this.uid++),this.keys.push(e),this.bboxes.push(a),this.bboxes.push(b),this.bboxes.push(c),this.bboxes.push(d)},u.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},u.prototype._insertCell=function(c,d,e,f,a,b){this.cells[a].push(b)},u.prototype.query=function(a,b,c,d,e){var f=this.min,g=this.max;if(a<=f&&b<=f&&g<=c&&g<=d&&!e)return Array.prototype.slice.call(this.keys);var h=[];return this._forEachCell(a,b,c,d,this._queryCell,h,{},e),h},u.prototype._queryCell=function(h,i,j,k,l,m,d,g){var e=this.cells[l];if(null!==e)for(var n=this.keys,a=this.bboxes,f=0;f<e.length;f++){var c=e[f];if(void 0===d[c]){var b=4*c;(g?g(a[b+0],a[b+1],a[b+2],a[b+3]):h<=a[b+2]&&i<=a[b+3]&&j>=a[b+0]&&k>=a[b+1])?(d[c]=!0,m.push(n[c])):d[c]=!1}}},u.prototype._forEachCell=function(d,e,f,g,h,i,j,c){for(var k=this._convertToCellCoord(d),l=this._convertToCellCoord(e),m=this._convertToCellCoord(f),n=this._convertToCellCoord(g),a=k;a<=m;a++)for(var b=l;b<=n;b++){var o=this.d*b+a;if((!c||c(this._convertFromCellCoord(a),this._convertFromCellCoord(b),this._convertFromCellCoord(a+1),this._convertFromCellCoord(b+1)))&&h.call(this,d,e,f,g,o,i,j,c))return}},u.prototype._convertFromCellCoord=function(a){return(a-this.padding)/this.scale},u.prototype._convertToCellCoord=function(a){return Math.max(0,Math.min(this.d-1,Math.floor(a*this.scale)+this.padding))},u.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var c=this.cells,f=3+this.cells.length+1+1,g=0,e=0;e<this.cells.length;e++)g+=this.cells[e].length;var a=new Int32Array(f+g+this.keys.length+this.bboxes.length);a[0]=this.extent,a[1]=this.n,a[2]=this.padding;for(var b=f,d=0;d<c.length;d++){var h=c[d];a[3+d]=b,a.set(h,b),b+=h.length}return a[3+c.length]=b,a.set(this.keys,b),a[3+c.length+1]=b+=this.keys.length,a.set(this.bboxes,b),b+=this.bboxes.length,a.buffer};const{ImageData:gW,ImageBitmap:gX}=s,gY={};function c(a,b,c={}){Object.defineProperty(b,"_classRegistryKey",{value:a,writeable:!1}),gY[a]={klass:b,omit:c.omit||[],shallow:c.shallow||[]}}for(const ak in c("Object",Object),aj.serialize=function(c,a){const b=c.toArrayBuffer();return a&&a.push(b),{buffer:b}},aj.deserialize=function(a){return new aj(a.buffer)},c("Grid",aj),c("Color",m),c("Error",Error),c("ResolvedImage",cj),c("StylePropertyFunction",cQ),c("StyleExpression",cM,{omit:["_evaluator"]}),c("ZoomDependentExpression",cP),c("ZoomConstantExpression",cO),c("CompoundExpression",aX,{omit:["_evaluate"]}),U)U[ak]._classRegistryKey||c(`Expression_${ak}`,U[ak]);function gZ(a){return a&&"undefined"!=typeof ArrayBuffer&&(a instanceof ArrayBuffer||a.constructor&&"ArrayBuffer"===a.constructor.name)}function g$(a){return gX&&a instanceof gX}function g_(a,b){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp)return a;if(gZ(a)||g$(a))return b&&b.push(a),a;if(ArrayBuffer.isView(a)){const g=a;return b&&b.push(g.buffer),g}if(a instanceof gW)return b&&b.push(a.data.buffer),a;if(Array.isArray(a)){const h=[];for(const j of a)h.push(g_(j,b));return h}if("object"==typeof a){const f=a.constructor,c=f._classRegistryKey;if(!c)throw Error("can't serialize object of unregistered class");const d=f.serialize?f.serialize(a,b):{};if(!f.serialize){for(const e in a){if(!a.hasOwnProperty(e)||gY[c].omit.indexOf(e)>=0)continue;const i=a[e];d[e]=gY[c].shallow.indexOf(e)>=0?i:g_(i,b)}a instanceof Error&&(d.message=a.message)}if(d.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==c&&(d.$name=c),d}throw Error("can't serialize object of type "+typeof a)}function g0(a){if(null==a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||a instanceof Boolean||a instanceof Number||a instanceof String||a instanceof Date||a instanceof RegExp||gZ(a)||g$(a)||ArrayBuffer.isView(a)||a instanceof gW)return a;if(Array.isArray(a))return a.map(g0);if("object"==typeof a){const d=a.$name||"Object",{klass:b}=gY[d];if(!b)throw Error(`can't deserialize unregistered class ${d}`);if(b.deserialize)return b.deserialize(a);const e=Object.create(b.prototype);for(const c of Object.keys(a)){if("$name"===c)continue;const f=a[c];e[c]=gY[d].shallow.indexOf(c)>=0?f:g0(f)}return e}throw Error("can't deserialize object of type "+typeof a)}class c0{constructor(){this.first=!0}update(b,c){const a=Math.floor(b);return this.first?(this.first=!1,this.lastIntegerZoom=a,this.lastIntegerZoomTime=0,this.lastZoom=b,this.lastFloorZoom=a,!0):(this.lastFloorZoom>a?(this.lastIntegerZoom=a+1,this.lastIntegerZoomTime=c):this.lastFloorZoom<a&&(this.lastIntegerZoom=a,this.lastIntegerZoomTime=c),b!==this.lastZoom&&(this.lastZoom=b,this.lastFloorZoom=a,!0))}}const g1=a=>a>=1536&&a<=1791,g2=a=>a>=1872&&a<=1919,g3=a=>a>=2208&&a<=2303,g4=a=>a>=11904&&a<=12031,g5=a=>a>=12032&&a<=12255,g6=a=>a>=12272&&a<=12287,g7=a=>a>=12288&&a<=12351,g8=a=>a>=12352&&a<=12447,g9=a=>a>=12448&&a<=12543,ha=a=>a>=12544&&a<=12591,hb=a=>a>=12704&&a<=12735,hc=a=>a>=12736&&a<=12783,hd=a=>a>=12784&&a<=12799,he=a=>a>=12800&&a<=13055,hf=a=>a>=13056&&a<=13311,hg=a=>a>=13312&&a<=19903,hh=a=>a>=19968&&a<=40959,hi=a=>a>=40960&&a<=42127,hj=a=>a>=42128&&a<=42191,hk=a=>a>=44032&&a<=55215,hl=a=>a>=63744&&a<=64255,hm=a=>a>=64336&&a<=65023,hn=a=>a>=65040&&a<=65055,ho=a=>a>=65072&&a<=65103,hp=a=>a>=65104&&a<=65135,hq=a=>a>=65136&&a<=65279,hr=a=>a>=65280&&a<=65519;function hs(a){for(const b of a)if(hv(b.charCodeAt(0)))return!0;return!1}function ht(a){for(const b of a)if(!hu(b.charCodeAt(0)))return!1;return!0}function hu(a){return!(g1(a)||g2(a)||g3(a)||hm(a)||hq(a))}function hv(a){var b,c,d,e,f,g,h,i;return!(746!==a&&747!==a&&(a<4352||!(hb(a)||ha(a)||ho(a)&&!(a>=65097&&a<=65103)||hl(a)||hf(a)||g4(a)||hc(a)||!(!g7(a)||a>=12296&&a<=12305||a>=12308&&a<=12319||12336===a)||hg(a)||hh(a)||he(a)||(b=a)>=12592&&b<=12687||(c=a)>=43360&&c<=43391||(d=a)>=55216&&d<=55295||(e=a)>=4352&&e<=4607||hk(a)||g8(a)||g6(a)||(f=a)>=12688&&f<=12703||g5(a)||hd(a)||g9(a)&&12540!==a||!(!hr(a)||65288===a||65289===a||65293===a||a>=65306&&a<=65310||65339===a||65341===a||65343===a||a>=65371&&a<=65503||65507===a||a>=65512&&a<=65519)||!(!hp(a)||a>=65112&&a<=65118||a>=65123&&a<=65126)||(g=a)>=5120&&g<=5759||(h=a)>=6320&&h<=6399||hn(a)||(i=a)>=19904&&i<=19967||hi(a)||hj(a))))}function hw(b){var a,c,d,e,f,g,h,i,j,k,l,m,n;return!(hv(b)||(c=a=b)>=128&&c<=255&&(167===a||169===a||174===a||177===a||188===a||189===a||190===a||215===a||247===a)||(d=a)>=8192&&d<=8303&&(8214===a||8224===a||8225===a||8240===a||8241===a||8251===a||8252===a||8258===a||8263===a||8264===a||8265===a||8273===a)||(e=a)>=8448&&e<=8527||(f=a)>=8528&&f<=8591||(g=a)>=8960&&g<=9215&&(a>=8960&&a<=8967||a>=8972&&a<=8991||a>=8996&&a<=9e3||9003===a||a>=9085&&a<=9114||a>=9150&&a<=9165||9167===a||a>=9169&&a<=9179||a>=9186&&a<=9215)||(h=a)>=9216&&h<=9279&&9251!==a||(i=a)>=9280&&i<=9311||(j=a)>=9312&&j<=9471||(k=a)>=9632&&k<=9727||(l=a)>=9728&&l<=9983&&!(a>=9754&&a<=9759)||(m=a)>=11008&&m<=11263&&(a>=11026&&a<=11055||a>=11088&&a<=11097||a>=11192&&a<=11243)||g7(a)||g9(a)||(n=a)>=57344&&n<=63743||ho(a)||hp(a)||hr(a)||8734===a||8756===a||8757===a||a>=9984&&a<=10087||a>=10102&&a<=10131||65532===a||65533===a)}function hx(a){return a>=1424&&a<=2303||hm(a)||hq(a)}function hy(a,c){var b;return!(!c&&hx(a)||a>=2304&&a<=3583||a>=3840&&a<=4255||(b=a)>=6016&&b<=6143)}function hz(a){for(const b of a)if(hx(b.charCodeAt(0)))return!0;return!1}const hA="deferred",hB="loading",hC="loaded";let hD=null,hE="unavailable",hF=null;const c1=function(a){a&&"string"==typeof a&&a.indexOf("NetworkError")> -1&&(hE="error"),hD&&hD(a)};function hG(){c2.fire(new aW("pluginStateChange",{pluginStatus:hE,pluginURL:hF}))}const c2=new S,c3=function(){return hE},hH=function(){if(hE!==hA||!hF)throw Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");hE=hB,hG(),hF&&fi({url:hF},a=>{a?c1(a):(hE=hC,hG())})},c4={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>hE===hC||null!=c4.applyArabicShaping,isLoading:()=>hE===hB,setState(a){hE=a.pluginStatus,hF=a.pluginURL},isParsed:()=>null!=c4.applyArabicShaping&&null!=c4.processBidirectionalText&&null!=c4.processStyledBidirectionalText,getPluginURL:()=>hF};class c5{constructor(b,a){this.zoom=b,a?(this.now=a.now,this.fadeDuration=a.fadeDuration,this.zoomHistory=a.zoomHistory,this.transition=a.transition,this.pitch=a.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new c0,this.transition={},this.pitch=0)}isSupportedScript(a){return function(a,b){for(const c of a)if(!hy(c.charCodeAt(0),b))return!1;return!0}(a,c4.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const a=this.zoom,b=a-Math.floor(a),c=this.crossFadingFactor();return a>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:b+(1-b)*c}:{fromScale:.5,toScale:1,t:1-(1-c)*b}}}class hI{constructor(a,b){this.property=a,this.value=b,this.expression=function(a,b){if(gn(a))return new cQ(a,b);if(gv(a)){const c=gw(a,b);if("error"===c.result)throw Error(c.value.map(a=>`${a.key}: ${a.message}`).join(", "));return c.value}{let d=a;return"string"==typeof a&&"color"===b.type&&(d=m.parse(a)),{kind:"constant",evaluate:()=>d}}}(void 0===b?a.specification.default:b,a.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(a,b,c){return this.property.possiblyEvaluate(this,a,b,c)}}class hJ{constructor(a){this.property=a,this.value=new hI(a,void 0)}transitioned(a,b){return new hK(this.property,this.value,b,bR({},a.transition,this.transition),a.now)}untransitioned(){return new hK(this.property,this.value,null,{},0)}}class c6{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitionablePropertyValues)}getValue(a){return bX(this._values[a].value.value)}setValue(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new hJ(this._values[a].property)),this._values[a].value=new hI(this._values[a].property,null===b?void 0:bX(b))}getTransition(a){return bX(this._values[a].transition)}setTransition(a,b){this._values.hasOwnProperty(a)||(this._values[a]=new hJ(this._values[a].property)),this._values[a].transition=bX(b)||void 0}serialize(){const b={};for(const a of Object.keys(this._values)){const c=this.getValue(a);void 0!==c&&(b[a]=c);const d=this.getTransition(a);void 0!==d&&(b[`${a}-transition`]=d)}return b}transitioned(c,d){const b=new hL(this._properties);for(const a of Object.keys(this._values))b._values[a]=this._values[a].transitioned(c,d._values[a]);return b}untransitioned(){const a=new hL(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].untransitioned();return a}}class hK{constructor(c,d,e,a,b){const f=a.delay||0,g=a.duration||0;b=b||0,this.property=c,this.value=d,this.begin=b+f,this.end=this.begin+g,c.specification.transition&&(a.delay||a.duration)&&(this.prior=e)}possiblyEvaluate(a,b,c){const d=a.now||0,e=this.value.possiblyEvaluate(a,b,c),f=this.prior;if(f){if(d>this.end||this.value.isDataDriven())return this.prior=null,e;if(d<this.begin)return f.possiblyEvaluate(a,b,c);{const g=(d-this.begin)/(this.end-this.begin);return this.property.interpolate(f.possiblyEvaluate(a,b,c),e,bK(g))}}return e}}class hL{constructor(a){this._properties=a,this._values=Object.create(a.defaultTransitioningPropertyValues)}possiblyEvaluate(c,d,e){const a=new hN(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].possiblyEvaluate(c,d,e);return a}hasTransition(){for(const a of Object.keys(this._values))if(this._values[a].prior)return!0;return!1}}class hM{constructor(a,b,c){this.property=a,this.value=b,this.parameters=c}isConstant(){return"constant"===this.value.kind}constantOr(a){return"constant"===this.value.kind?this.value.value:a}evaluate(a,b,c,d){return this.property.evaluate(this.value,this.parameters,a,b,c,d)}}class hN{constructor(a){this._properties=a,this._values=Object.create(a.defaultPossiblyEvaluatedValues)}get(a){return this._values[a]}}class e{constructor(a){this.specification=a}possiblyEvaluate(a,b){return a.expression.evaluate(b)}interpolate(a,c,d){const b=f4[this.specification.type];return b?b(a,c,d):a}}class g{constructor(a,b){this.specification=a,this.overrides=b}possiblyEvaluate(a,b,c,d){return new hM(this,"constant"===a.expression.kind||"camera"===a.expression.kind?{kind:"constant",value:a.expression.evaluate(b,null,{},c,d)}:a.expression,b)}interpolate(a,b,d){if("constant"!==a.value.kind||"constant"!==b.value.kind)return a;if(void 0===a.value.value|| void 0===b.value.value)return new hM(this,{kind:"constant",value:void 0},a.parameters);const c=f4[this.specification.type];return c?new hM(this,{kind:"constant",value:c(a.value.value,b.value.value,d)},a.parameters):a}evaluate(a,b,c,d,e,f){return"constant"===a.kind?a.value:a.evaluate(b,c,d,e,f)}}class N extends g{possiblyEvaluate(b,a,e,f){if(void 0===b.value)return new hM(this,{kind:"constant",value:void 0},a);if("constant"===b.expression.kind){const c=b.expression.evaluate(a,null,{},e,f),d="resolvedImage"===b.property.specification.type&&"string"!=typeof c?c.name:c,g=this._calculate(d,d,d,a);return new hM(this,{kind:"constant",value:g},a)}if("camera"===b.expression.kind){const h=this._calculate(b.expression.evaluate({zoom:a.zoom-1}),b.expression.evaluate({zoom:a.zoom}),b.expression.evaluate({zoom:a.zoom+1}),a);return new hM(this,{kind:"constant",value:h},a)}return new hM(this,b.expression,a)}evaluate(a,b,c,d,f,g){if("source"===a.kind){const e=a.evaluate(b,c,d,f,g);return this._calculate(e,e,e,b)}return"composite"===a.kind?this._calculate(a.evaluate({zoom:Math.floor(b.zoom)-1},c,d),a.evaluate({zoom:Math.floor(b.zoom)},c,d),a.evaluate({zoom:Math.floor(b.zoom)+1},c,d),b):a.value}_calculate(a,b,c,d){return d.zoom>d.zoomHistory.lastIntegerZoom?{from:a,to:b,other:c}:{from:c,to:b,other:a}}interpolate(a){return a}}class a5{constructor(a){this.specification=a}possiblyEvaluate(b,a,d,e){if(void 0!==b.value){if("constant"===b.expression.kind){const c=b.expression.evaluate(a,null,{},d,e);return this._calculate(c,c,c,a)}return this._calculate(b.expression.evaluate(new c5(Math.floor(a.zoom-1),a)),b.expression.evaluate(new c5(Math.floor(a.zoom),a)),b.expression.evaluate(new c5(Math.floor(a.zoom+1),a)),a)}}_calculate(c,a,d,b){return b.zoom>b.zoomHistory.lastIntegerZoom?{from:c,to:a}:{from:d,to:a}}interpolate(a){return a}}class V{constructor(a){this.specification=a}possiblyEvaluate(a,b,c,d){return!!a.expression.evaluate(b,null,{},c,d)}interpolate(){return!1}}class n{constructor(b){for(const a in this.properties=b,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[],b){const c=b[a];c.specification.overridable&&this.overridableProperties.push(a);const d=this.defaultPropertyValues[a]=new hI(c,void 0),e=this.defaultTransitionablePropertyValues[a]=new hJ(c);this.defaultTransitioningPropertyValues[a]=e.untransitioned(),this.defaultPossiblyEvaluatedValues[a]=d.possiblyEvaluate({})}}}function hO(a,b){return 256*(a=bM(Math.floor(a),0,255))+bM(Math.floor(b),0,255)}c("DataDrivenProperty",g),c("DataConstantProperty",e),c("CrossFadedDataDrivenProperty",N),c("CrossFadedProperty",a5),c("ColorRampProperty",V);const hP={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class O{constructor(a,b){this._structArray=a,this._pos1=b*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class k{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(a,b){return a._trim(),b&&(a.isTransferred=!0,b.push(a.arrayBuffer)),{length:a.length,arrayBuffer:a.arrayBuffer}}static deserialize(b){const a=Object.create(this.prototype);return a.arrayBuffer=b.arrayBuffer,a.length=b.length,a.capacity=b.arrayBuffer.byteLength/a.bytesPerElement,a._refreshViews(),a}_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(a){this.reserve(a),this.length=a}reserve(a){if(a>this.capacity){this.capacity=Math.max(a,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const b=this.uint8;this._refreshViews(),b&&this.uint8.set(b)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function j(b,a=1){let c=0,d=0;return{members:b.map(b=>{const e=hP[b.type].BYTES_PER_ELEMENT,g=c=hQ(c,Math.max(a,e)),f=b.components||1;return d=Math.max(d,e),c+=e*f,{name:b.name,type:b.type,components:f,offset:g}}),size:hQ(c,Math.max(d,a)),alignment:a}}function hQ(b,a){return Math.ceil(b/a)*a}class al extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.int16[b+0]=c,this.int16[b+1]=d,a}}al.prototype.bytesPerElement=4,c("StructArrayLayout2i4",al);class am extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,b}}am.prototype.bytesPerElement=8,c("StructArrayLayout4i8",am);class a6 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(a,d,e,f,g,h,i,j){const c=6*a,b=12*a,k=3*a;return this.int16[c+0]=d,this.int16[c+1]=e,this.uint8[b+4]=f,this.uint8[b+5]=g,this.uint8[b+6]=h,this.uint8[b+7]=i,this.float32[k+2]=j,a}}a6.prototype.bytesPerElement=12,c("StructArrayLayout2i4ub1f12",a6);class an extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,b}}an.prototype.bytesPerElement=12,c("StructArrayLayout3f12",an);class w extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k)}emplace(b,c,d,e,f,g,h,i,j,k,l){const a=10*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.uint16[a+8]=k,this.uint16[a+9]=l,b}}w.prototype.bytesPerElement=20,c("StructArrayLayout10ui20",w);class W extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i)}emplace(b,c,d,e,f,g,h,i,j){const a=8*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,this.uint16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,b}}W.prototype.bytesPerElement=16,c("StructArrayLayout8ui16",W);class a7 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q)}emplace(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){const a=16*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+3]=f,this.uint16[a+4]=g,this.uint16[a+5]=h,this.uint16[a+6]=i,this.uint16[a+7]=j,this.int16[a+8]=k,this.int16[a+9]=l,this.int16[a+10]=m,this.int16[a+11]=n,this.int16[a+12]=o,this.int16[a+13]=p,this.int16[a+14]=q,this.int16[a+15]=r,b}}a7.prototype.bytesPerElement=32,c("StructArrayLayout4i4ui4i4i32",a7);class a8 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint32[1*a+0]=b,a}}a8.prototype.bytesPerElement=4,c("StructArrayLayout1ul4",a8);class ao extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p){const a=20*c,b=10*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.int16[a+3]=g,this.int16[a+4]=h,this.float32[b+3]=i,this.float32[b+4]=j,this.float32[b+5]=k,this.float32[b+6]=l,this.int16[a+14]=m,this.uint32[b+8]=n,this.uint16[a+18]=o,this.uint16[a+19]=p,c}}ao.prototype.bytesPerElement=40,c("StructArrayLayout5i4f1i1ul2ui40",ao);class a9 extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=8*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,this.int16[a+4]=f,this.int16[a+5]=g,this.int16[a+6]=h,this.int16[a+7]=i,b}}a9.prototype.bytesPerElement=16,c("StructArrayLayout3i2i2i16",a9);class ap extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f)}emplace(a,d,e,f,g,h){const b=4*a,c=8*a;return this.float32[b+0]=d,this.float32[b+1]=e,this.float32[b+2]=f,this.int16[c+6]=g,this.int16[c+7]=h,a}}ap.prototype.bytesPerElement=16,c("StructArrayLayout2f1f2i16",ap);class ba extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,d,e,f,g){const b=12*a,c=3*a;return this.uint8[b+0]=d,this.uint8[b+1]=e,this.float32[c+1]=f,this.float32[c+2]=g,a}}ba.prototype.bytesPerElement=12,c("StructArrayLayout2ub2f12",ba);class aq extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.uint16[a+0]=c,this.uint16[a+1]=d,this.uint16[a+2]=e,b}}aq.prototype.bytesPerElement=6,c("StructArrayLayout3ui6",aq);class ar extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)}emplace(c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y){const a=30*c,b=15*c,d=60*c;return this.int16[a+0]=e,this.int16[a+1]=f,this.int16[a+2]=g,this.float32[b+2]=h,this.float32[b+3]=i,this.uint16[a+8]=j,this.uint16[a+9]=k,this.uint32[b+5]=l,this.uint32[b+6]=m,this.uint32[b+7]=n,this.uint16[a+16]=o,this.uint16[a+17]=p,this.uint16[a+18]=q,this.float32[b+10]=r,this.float32[b+11]=s,this.uint8[d+48]=t,this.uint8[d+49]=u,this.uint8[d+50]=v,this.uint32[b+13]=w,this.int16[a+28]=x,this.uint8[d+58]=y,c}}ar.prototype.bytesPerElement=60,c("StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60",ar);class as extends k{_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(b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E)}emplace(c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G){const a=38*c,b=19*c;return this.int16[a+0]=d,this.int16[a+1]=e,this.int16[a+2]=f,this.float32[b+2]=g,this.float32[b+3]=h,this.int16[a+8]=i,this.int16[a+9]=j,this.int16[a+10]=k,this.int16[a+11]=l,this.int16[a+12]=m,this.int16[a+13]=n,this.uint16[a+14]=o,this.uint16[a+15]=p,this.uint16[a+16]=q,this.uint16[a+17]=r,this.uint16[a+18]=s,this.uint16[a+19]=t,this.uint16[a+20]=u,this.uint16[a+21]=v,this.uint16[a+22]=w,this.uint16[a+23]=x,this.uint16[a+24]=y,this.uint16[a+25]=z,this.uint16[a+26]=A,this.uint16[a+27]=B,this.uint16[a+28]=C,this.uint32[b+15]=D,this.float32[b+16]=E,this.float32[b+17]=F,this.float32[b+18]=G,c}}as.prototype.bytesPerElement=76,c("StructArrayLayout3i2f6i15ui1ul3f76",as);class X extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.float32[1*a+0]=b,a}}X.prototype.bytesPerElement=4,c("StructArrayLayout1f4",X);class at extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(b,c,d){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d)}emplace(b,c,d,e){const a=3*b;return this.int16[a+0]=c,this.int16[a+1]=d,this.int16[a+2]=e,b}}at.prototype.bytesPerElement=6,c("StructArrayLayout3i6",at);class bb extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e,f,g,h){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e,f,g,h)}emplace(b,c,d,e,f,g,h,i){const a=7*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,this.float32[a+4]=g,this.float32[a+5]=h,this.float32[a+6]=i,b}}bb.prototype.bytesPerElement=28,c("StructArrayLayout7f28",bb);class au extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(a,c,d,e,f){const b=6*a;return this.uint32[3*a+0]=c,this.uint16[b+2]=d,this.uint16[b+3]=e,this.uint16[b+4]=f,a}}au.prototype.bytesPerElement=12,c("StructArrayLayout1ul3ui12",au);class Y extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.uint16[b+0]=c,this.uint16[b+1]=d,a}}Y.prototype.bytesPerElement=4,c("StructArrayLayout2ui4",Y);class av extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(b){const a=this.length;return this.resize(a+1),this.emplace(a,b)}emplace(a,b){return this.uint16[1*a+0]=b,a}}av.prototype.bytesPerElement=2,c("StructArrayLayout1ui2",av);class Z extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c){const a=this.length;return this.resize(a+1),this.emplace(a,b,c)}emplace(a,c,d){const b=2*a;return this.float32[b+0]=c,this.float32[b+1]=d,a}}Z.prototype.bytesPerElement=8,c("StructArrayLayout2f8",Z);class aw extends k{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(b,c,d,e){const a=this.length;return this.resize(a+1),this.emplace(a,b,c,d,e)}emplace(b,c,d,e,f){const a=4*b;return this.float32[a+0]=c,this.float32[a+1]=d,this.float32[a+2]=e,this.float32[a+3]=f,b}}aw.prototype.bytesPerElement=16,c("StructArrayLayout4f16",aw);class c7 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]}}c7.prototype.size=40;class c8 extends ao{get(a){return new c7(this,a)}}c("CollisionBoxArray",c8);class c9 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(a){this._structArray.uint8[this._pos1+49]=a}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(a){this._structArray.uint8[this._pos1+50]=a}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(a){this._structArray.uint32[this._pos4+13]=a}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(a){this._structArray.uint8[this._pos1+58]=a}}c9.prototype.size=60;class da extends ar{get(a){return new c9(this,a)}}c("PlacedSymbolArray",da);class db 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(a){this._structArray.uint32[this._pos4+15]=a}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]}}db.prototype.size=76;class dc extends as{get(a){return new db(this,a)}}c("SymbolInstanceArray",dc);class dd extends X{getoffsetX(a){return this.float32[1*a+0]}}c("GlyphOffsetArray",dd);class de extends at{getx(a){return this.int16[3*a+0]}gety(a){return this.int16[3*a+1]}gettileUnitDistanceFromAnchor(a){return this.int16[3*a+2]}}c("SymbolLineVertexArray",de);class df 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]}}df.prototype.size=12;class dg extends au{get(a){return new df(this,a)}}c("FeatureIndexArray",dg);class dh extends O{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}dh.prototype.size=4;class di extends Y{get(a){return new dh(this,a)}}c("FillExtrusionCentroidArray",di);const hR=j([{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"},]),hS=j([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"},]);var bc=ah(function(a){a.exports=function(c,j){var g,h,a,i,e,f,b,d;for(h=c.length-(g=3&c.length),a=j,e=3432918353,f=461845907,d=0;d<h;)b=255&c.charCodeAt(d)|(255&c.charCodeAt(++d))<<8|(255&c.charCodeAt(++d))<<16|(255&c.charCodeAt(++d))<<24,++d,a=27492+(65535&(i=5*(65535&(a=(a^=b=(65535&(b=(b=(65535&b)*e+(((b>>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295)<<13|a>>>19))+((5*(a>>>16)&65535)<<16)&4294967295))+((58964+(i>>>16)&65535)<<16);switch(b=0,g){case 3:b^=(255&c.charCodeAt(d+2))<<16;case 2:b^=(255&c.charCodeAt(d+1))<<8;case 1:a^=b=(65535&(b=(b=(65535&(b^=255&c.charCodeAt(d)))*e+(((b>>>16)*e&65535)<<16)&4294967295)<<15|b>>>17))*f+(((b>>>16)*f&65535)<<16)&4294967295}return a^=c.length,a=2246822507*(65535&(a^=a>>>16))+((2246822507*(a>>>16)&65535)<<16)&4294967295,a=3266489909*(65535&(a^=a>>>13))+((3266489909*(a>>>16)&65535)<<16)&4294967295,(a^=a>>>16)>>>0}}),dj=ah(function(a){a.exports=function(b,f){for(var d,e=b.length,a=f^e,c=0;e>=4;)d=1540483477*(65535&(d=255&b.charCodeAt(c)|(255&b.charCodeAt(++c))<<8|(255&b.charCodeAt(++c))<<16|(255&b.charCodeAt(++c))<<24))+((1540483477*(d>>>16)&65535)<<16),a=1540483477*(65535&a)+((1540483477*(a>>>16)&65535)<<16)^(d=1540483477*(65535&(d^=d>>>24))+((1540483477*(d>>>16)&65535)<<16)),e-=4,++c;switch(e){case 3:a^=(255&b.charCodeAt(c+2))<<16;case 2:a^=(255&b.charCodeAt(c+1))<<8;case 1:a=1540483477*(65535&(a^=255&b.charCodeAt(c)))+((1540483477*(a>>>16)&65535)<<16)}return a=1540483477*(65535&(a^=a>>>13))+((1540483477*(a>>>16)&65535)<<16),(a^=a>>>15)>>>0}}),bd=bc;bd.murmur3=bc,bd.murmur2=dj;class dk{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(a,b,c,d){this.ids.push(hT(a)),this.positions.push(b,c,d)}getPositions(f){const d=hT(f);let a=0,b=this.ids.length-1;for(;a<b;){const c=a+b>>1;this.ids[c]>=d?b=c:a=c+1}const e=[];for(;this.ids[a]===d;)e.push({index:this.positions[3*a],start:this.positions[3*a+1],end:this.positions[3*a+2]}),a++;return e}static serialize(c,d){const a=new Float64Array(c.ids),b=new Uint32Array(c.positions);return hU(a,b,0,a.length-1),d&&d.push(a.buffer,b.buffer),{ids:a,positions:b}}static deserialize(b){const a=new dk;return a.ids=b.ids,a.positions=b.positions,a.indexed=!0,a}}function hT(b){const a=+b;return!isNaN(a)&&Number.MIN_SAFE_INTEGER<=a&&a<=Number.MAX_SAFE_INTEGER?a:bd(String(b))}function hU(c,f,d,e){for(;d<e;){const g=c[d+e>>1];let b=d-1,a=e+1;for(;;){do b++;while(c[b]<g)do a--;while(c[a]>g)if(b>=a)break;hV(c,b,a),hV(f,3*b,3*a),hV(f,3*b+1,3*a+1),hV(f,3*b+2,3*a+2)}a-d<e-a?(hU(c,f,d,a),d=a+1):(hU(c,f,a+1,e),e=a)}}function hV(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}c("FeaturePositionMap",dk);class ax{constructor(a,b){this.gl=a.gl,this.location=b}}class dl extends ax{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1f(this.location,a))}}class dm extends ax{constructor(a,b){super(a,b),this.current=[0,0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]&&a[3]===this.current[3]||(this.current=a,this.gl.uniform4f(this.location,a[0],a[1],a[2],a[3]))}}class dn extends ax{constructor(a,b){super(a,b),this.current=m.transparent}set(a){a.r===this.current.r&&a.g===this.current.g&&a.b===this.current.b&&a.a===this.current.a||(this.current=a,this.gl.uniform4f(this.location,a.r,a.g,a.b,a.a))}}const hW=new Float32Array(16),hX=new Float32Array(9),hY=new Float32Array(4);function hZ(a){return[hO(255*a.r,255*a.g),hO(255*a.b,255*a.a),]}class dp{constructor(a,b,c){this.value=a,this.uniformNames=b.map(a=>`u_${a}`),this.type=c}setUniform(a,c,b){a.set(b.constantOr(this.value))}getBinding(a,b,c){return"color"===this.type?new dn(a,b):new dl(a,b)}}class dq{constructor(b,a){this.uniformNames=a.map(a=>`u_${a}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(a,b){this.pixelRatioFrom=b.pixelRatio,this.pixelRatioTo=a.pixelRatio,this.patternFrom=b.tl.concat(b.br),this.patternTo=a.tl.concat(a.br)}setUniform(c,d,e,a){const b="u_pattern_to"===a||"u_dash_to"===a?this.patternTo:"u_pattern_from"===a||"u_dash_from"===a?this.patternFrom:"u_pixel_ratio_to"===a?this.pixelRatioTo:"u_pixel_ratio_from"===a?this.pixelRatioFrom:null;b&&c.set(b)}getBinding(b,c,a){return"u_pattern_from"===a||"u_pattern_to"===a||"u_dash_from"===a||"u_dash_to"===a?new dm(b,c):new dl(b,c)}}class dr{constructor(a,b,c,d){this.expression=a,this.type=c,this.maxValue=0,this.paintVertexAttributes=b.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?2:1,offset:0})),this.paintVertexArray=new d}populatePaintArray(a,b,h,c,d,e){const f=this.paintVertexArray.length,g=this.expression.evaluate(new c5(0),b,{},d,c,e);this.paintVertexArray.resize(a),this._setPaintValue(f,a,g)}updatePaintArray(a,b,c,d,e){const f=this.expression.evaluate({zoom:0},c,d,void 0,e);this._setPaintValue(a,b,f)}_setPaintValue(d,e,a){if("color"===this.type){const f=hZ(a);for(let b=d;b<e;b++)this.paintVertexArray.emplace(b,f[0],f[1])}else{for(let c=d;c<e;c++)this.paintVertexArray.emplace(c,a);this.maxValue=Math.max(this.maxValue,Math.abs(a))}}upload(a){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=a.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class ds{constructor(b,a,c,d,e,f){this.expression=b,this.uniformNames=a.map(a=>`u_${a}_t`),this.type=c,this.useIntegerZoom=d,this.zoom=e,this.maxValue=0,this.paintVertexAttributes=a.map(a=>({name:`a_${a}`,type:"Float32",components:"color"===c?4:2,offset:0})),this.paintVertexArray=new f}populatePaintArray(a,b,i,c,d,e){const f=this.expression.evaluate(new c5(this.zoom),b,{},d,c,e),g=this.expression.evaluate(new c5(this.zoom+1),b,{},d,c,e),h=this.paintVertexArray.length;this.paintVertexArray.resize(a),this._setPaintValue(h,a,f,g)}updatePaintArray(d,e,a,b,c){const f=this.expression.evaluate({zoom:this.zoom},a,b,void 0,c),g=this.expression.evaluate({zoom:this.zoom+1},a,b,void 0,c);this._setPaintValue(d,e,f,g)}_setPaintValue(e,f,a,b){if("color"===this.type){const g=hZ(a),h=hZ(b);for(let c=e;c<f;c++)this.paintVertexArray.emplace(c,g[0],g[1],h[0],h[1])}else{for(let d=e;d<f;d++)this.paintVertexArray.emplace(d,a,b);this.maxValue=Math.max(this.maxValue,Math.abs(a),Math.abs(b))}}upload(a){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=a.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(b,a){const c=this.useIntegerZoom?Math.floor(a.zoom):a.zoom,d=bM(this.expression.interpolationFactor(c,this.zoom,this.zoom+1),0,1);b.set(d)}getBinding(a,b,c){return new dl(a,b)}}class dt{constructor(d,e,a,f,g,b,h){this.expression=d,this.type=a,this.useIntegerZoom=f,this.zoom=g,this.layerId=h,this.paintVertexAttributes=("array"===a?hS:hR).members;for(let c=0;c<e.length;++c);this.zoomInPaintVertexArray=new b,this.zoomOutPaintVertexArray=new b}populatePaintArray(a,b,c){const d=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(a),this.zoomOutPaintVertexArray.resize(a),this._setPaintValues(d,a,b.patterns&&b.patterns[this.layerId],c)}updatePaintArray(b,c,a,e,f,d){this._setPaintValues(b,c,a.patterns&&a.patterns[this.layerId],d)}_setPaintValues(g,h,d,a){if(!a||!d)return;const{min:i,mid:j,max:k}=d,e=a[i],c=a[j],f=a[k];if(e&&c&&f)for(let b=g;b<h;b++)this._setPaintValue(this.zoomInPaintVertexArray,b,c,e),this._setPaintValue(this.zoomOutPaintVertexArray,b,c,f)}_setPaintValue(c,d,a,b){c.emplace(d,a.tl[0],a.tl[1],a.br[0],a.br[1],b.tl[0],b.tl[1],b.br[0],b.br[1],a.pixelRatio,b.pixelRatio)}upload(a){this.zoomInPaintVertexArray&&this.zoomInPaintVertexArray.arrayBuffer&&this.zoomOutPaintVertexArray&&this.zoomOutPaintVertexArray.arrayBuffer&&(this.zoomInPaintVertexBuffer=a.createVertexBuffer(this.zoomInPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=a.createVertexBuffer(this.zoomOutPaintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class du{constructor(e,i,n=()=>!0){this.binders={},this._buffers=[];const g=[];for(const a in e.paint._values){if(!n(a))continue;const c=e.paint.get(a);if(!(c instanceof hM&&gj(c.property.specification)))continue;const f=h_(a,e.type),b=c.value,d=c.property.specification.type,j=c.property.useIntegerZoom,k=c.property.specification["property-type"],h="cross-faded"===k||"cross-faded-data-driven"===k,l="line-dasharray"===String(a)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==b.kind||l){if("source"===b.kind||l||h){const m=h2(a,d,"source");this.binders[a]=h?new dt(b,f,d,j,i,m,e.id):new dr(b,f,d,m),g.push(`/a_${a}`)}else{const o=h2(a,d,"composite");this.binders[a]=new ds(b,f,d,j,i,o),g.push(`/z_${a}`)}}else this.binders[a]=h?new dq(b.value,f):new dp(b.value,f,d),g.push(`/u_${a}`)}this.cacheKey=g.sort().join("")}getMaxValue(b){const a=this.binders[b];return a instanceof dr||a instanceof ds?a.maxValue:0}populatePaintArrays(b,c,d,e,f,g){for(const h in this.binders){const a=this.binders[h];(a instanceof dr||a instanceof ds||a instanceof dt)&&a.populatePaintArray(b,c,d,e,f,g)}}setConstantPatternPositions(b,c){for(const d in this.binders){const a=this.binders[d];a instanceof dq&&a.setConstantPatternPositions(b,c)}}updatePaintArrays(c,g,h,i,j,k){let d=!1;for(const e in c){const l=g.getPositions(e);for(const b of l){const m=h.feature(b.index);for(const f in this.binders){const a=this.binders[f];if((a instanceof dr||a instanceof ds||a instanceof dt)&& !0===a.expression.isStateDependent){const n=i.paint.get(f);a.expression=n.value,a.updatePaintArray(b.start,b.end,m,c[e],j,k),d=!0}}}}return d}defines(){const b=[];for(const c in this.binders){const a=this.binders[c];(a instanceof dp||a instanceof dq)&&b.push(...a.uniformNames.map(a=>`#define HAS_UNIFORM_${a}`))}return b}getBinderAttributes(){const c=[];for(const d in this.binders){const a=this.binders[d];if(a instanceof dr||a instanceof ds||a instanceof dt)for(let b=0;b<a.paintVertexAttributes.length;b++)c.push(a.paintVertexAttributes[b].name)}return c}getBinderUniforms(){const b=[];for(const c in this.binders){const a=this.binders[c];if(a instanceof dp||a instanceof dq||a instanceof ds)for(const d of a.uniformNames)b.push(d)}return b}getPaintVertexBuffers(){return this._buffers}getUniforms(f,c){const d=[];for(const e in this.binders){const a=this.binders[e];if(a instanceof dp||a instanceof dq||a instanceof ds){for(const b of a.uniformNames)if(c[b]){const g=a.getBinding(f,c[b],b);d.push({name:b,property:e,binding:g})}}}return d}setUniforms(g,b,c,d){for(const{name:e,property:a,binding:f}of b)this.binders[a].setUniform(f,d,c.get(a),e)}updatePaintBuffers(b){for(const d in this._buffers=[],this.binders){const a=this.binders[d];if(b&&a instanceof dt){const c=2===b.fromScale?a.zoomInPaintVertexBuffer:a.zoomOutPaintVertexBuffer;c&&this._buffers.push(c)}else(a instanceof dr||a instanceof ds)&&a.paintVertexBuffer&&this._buffers.push(a.paintVertexBuffer)}}upload(b){for(const c in this.binders){const a=this.binders[c];(a instanceof dr||a instanceof ds||a instanceof dt)&&a.upload(b)}this.updatePaintBuffers()}destroy(){for(const b in this.binders){const a=this.binders[b];(a instanceof dr||a instanceof ds||a instanceof dt)&&a.destroy()}}}class dv{constructor(b,c,d=()=>!0){for(const a of(this.programConfigurations={},b))this.programConfigurations[a.id]=new du(a,c,d);this.needsUpload=!1,this._featureMap=new dk,this._bufferOffset=0}populatePaintArrays(a,b,c,d,e,f,g){for(const h in this.programConfigurations)this.programConfigurations[h].populatePaintArrays(a,b,d,e,f,g);void 0!==b.id&&this._featureMap.add(b.id,c,this._bufferOffset,a),this._bufferOffset=a,this.needsUpload=!0}updatePaintArrays(b,c,d,e,f){for(const a of d)this.needsUpload=this.programConfigurations[a.id].updatePaintArrays(b,this._featureMap,c,a,e,f)||this.needsUpload}get(a){return this.programConfigurations[a]}upload(a){if(this.needsUpload){for(const b in this.programConfigurations)this.programConfigurations[b].upload(a);this.needsUpload=!1}}destroy(){for(const a in this.programConfigurations)this.programConfigurations[a].destroy()}}const h$={"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 h_(a,b){return h$[a]||[a.replace(`${b}-`,"").replace(/-/g,"_"),]}const h0={"line-pattern":{source:w,composite:w},"fill-pattern":{source:w,composite:w},"fill-extrusion-pattern":{source:w,composite:w},"line-dasharray":{source:W,composite:W}},h1={color:{source:Z,composite:aw},number:{source:X,composite:Z}};function h2(c,d,a){const b=h0[c];return b&&b[a]||h1[d][a]}c("ConstantBinder",dp),c("CrossFadedConstantBinder",dq),c("SourceExpressionBinder",dr),c("CrossFadedCompositeBinder",dt),c("CompositeExpressionBinder",ds),c("ProgramConfiguration",du,{omit:["_buffers"]}),c("ProgramConfigurationSet",dv);const h3="-transition";class be extends S{constructor(a,b){if(super(),this.id=a.id,this.type=a.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==a.type&&(this.metadata=a.metadata,this.minzoom=a.minzoom,this.maxzoom=a.maxzoom,"background"!==a.type&&"sky"!==a.type&&(this.source=a.source,this.sourceLayer=a["source-layer"],this.filter=a.filter),b.layout&&(this._unevaluatedLayout=new class{constructor(a){this._properties=a,this._values=Object.create(a.defaultPropertyValues)}getValue(a){return bX(this._values[a].value)}setValue(a,b){this._values[a]=new hI(this._values[a].property,null===b?void 0:bX(b))}serialize(){const a={};for(const b of Object.keys(this._values)){const c=this.getValue(b);void 0!==c&&(a[b]=c)}return a}possiblyEvaluate(c,d,e){const a=new hN(this._properties);for(const b of Object.keys(this._values))a._values[b]=this._values[b].possiblyEvaluate(c,d,e);return a}}(b.layout)),b.paint)){for(const c in this._transitionablePaint=new c6(b.paint),a.paint)this.setPaintProperty(c,a.paint[c],{validate:!1});for(const d in a.layout)this.setLayoutProperty(d,a.layout[d],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new hN(b.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(a){return"visibility"===a?this.visibility:this._unevaluatedLayout.getValue(a)}setLayoutProperty(a,b,c={}){null!=b&&this._validate(gV,`layers.${this.id}.layout.${a}`,a,b,c)||("visibility"!==a?this._unevaluatedLayout.setValue(a,b):this.visibility=b)}getPaintProperty(a){return bV(a,h3)?this._transitionablePaint.getTransition(a.slice(0,-h3.length)):this._transitionablePaint.getValue(a)}setPaintProperty(a,b,e={}){if(null!=b&&this._validate(gU,`layers.${this.id}.paint.${a}`,a,b,e))return!1;if(bV(a,h3))return this._transitionablePaint.setTransition(a.slice(0,-h3.length),b||void 0),!1;{const c=this._transitionablePaint._values[a],f="cross-faded-data-driven"===c.property.specification["property-type"],g=c.value.isDataDriven(),h=c.value;this._transitionablePaint.setValue(a,b),this._handleSpecialPaintPropertyUpdate(a);const d=this._transitionablePaint._values[a].value;return d.isDataDriven()||g||f||this._handleOverridablePaintPropertyUpdate(a,h,d)}}_handleSpecialPaintPropertyUpdate(a){}getProgramIds(){return null}getProgramConfiguration(a){return null}_handleOverridablePaintPropertyUpdate(a,b,c){return!1}isHidden(a){return!!(this.minzoom&&a<this.minzoom)||!!(this.maxzoom&&a>=this.maxzoom)||"none"===this.visibility}updateTransitions(a){this._transitioningPaint=this._transitionablePaint.transitioned(a,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(a,b){a.getCrossfadeParameters&&(this._crossfadeParameters=a.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(a,void 0,b)),this.paint=this._transitioningPaint.possiblyEvaluate(a,void 0,b)}serialize(){const a={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&&(a.layout=a.layout||{},a.layout.visibility=this.visibility),bW(a,(a,b)=>!(void 0===a||"layout"===b&&!Object.keys(a).length||"paint"===b&&!Object.keys(a).length))}_validate(c,d,e,f,a={}){return(!a|| !1!==a.validate)&&c_(this,c.call(M,{key:d,layerType:this.type,objectKey:e,value:f,styleSpec:b,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const b in this.paint._values){const a=this.paint.get(b);if(a instanceof hM&&gj(a.property.specification)&&("source"===a.value.kind||"composite"===a.value.kind)&&a.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=gB(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const dw=j([{name:"a_pos",components:2,type:"Int16"},],4),{members:h4}=dw;class ay{constructor(a=[]){this.segments=a}prepareSegment(b,d,e,c){let a=this.segments[this.segments.length-1];return b>ay.MAX_VERTEX_ARRAY_LENGTH&&bY(`Max vertices per segment is ${ay.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${b}`),(!a||a.vertexLength+b>ay.MAX_VERTEX_ARRAY_LENGTH||a.sortKey!==c)&&(a={vertexOffset:d.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0},void 0!==c&&(a.sortKey=c),this.segments.push(a)),a}get(){return this.segments}destroy(){for(const a of this.segments)for(const b in a.vaos)a.vaos[b].destroy()}static simpleSegment(a,b,c,d){return new ay([{vertexOffset:a,primitiveOffset:b,vertexLength:c,primitiveLength:d,vaos:{},sortKey:0},])}}ay.MAX_VERTEX_ARRAY_LENGTH=65535,c("SegmentVector",ay);class dx{constructor(a,b){a&&(b?this.setSouthWest(a).setNorthEast(b):4===a.length?this.setSouthWest([a[0],a[1],]).setNorthEast([a[2],a[3]]):this.setSouthWest(a[0]).setNorthEast(a[1]))}setNorthEast(a){return this._ne=a instanceof dy?new dy(a.lng,a.lat):dy.convert(a),this}setSouthWest(a){return this._sw=a instanceof dy?new dy(a.lng,a.lat):dy.convert(a),this}extend(a){const d=this._sw,e=this._ne;let b,c;if(a instanceof dy)b=a,c=a;else{if(!(a instanceof dx))return Array.isArray(a)?4===a.length||a.every(Array.isArray)?this.extend(dx.convert(a)):this.extend(dy.convert(a)):this;if(b=a._sw,c=a._ne,!b||!c)return this}return d||e?(d.lng=Math.min(b.lng,d.lng),d.lat=Math.min(b.lat,d.lat),e.lng=Math.max(c.lng,e.lng),e.lat=Math.max(c.lat,e.lat)):(this._sw=new dy(b.lng,b.lat),this._ne=new dy(c.lng,c.lat)),this}getCenter(){return new dy((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 dy(this.getWest(),this.getNorth())}getSouthEast(){return new dy(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(d){const{lng:a,lat:b}=dy.convert(d);let c=this._sw.lng<=a&&a<=this._ne.lng;return this._sw.lng>this._ne.lng&&(c=this._sw.lng>=a&&a>=this._ne.lng),this._sw.lat<=b&&b<=this._ne.lat&&c}static convert(a){return!a||a instanceof dx?a:new dx(a)}}class dy{constructor(a,b){if(isNaN(a)||isNaN(b))throw Error(`Invalid LngLat object: (${a}, ${b})`);if(this.lng=+a,this.lat=+b,this.lat>90||this.lat< -90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new dy(bO(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(b){const a=Math.PI/180,c=this.lat*a,d=b.lat*a,e=Math.sin(c)*Math.sin(d)+Math.cos(c)*Math.cos(d)*Math.cos((b.lng-this.lng)*a);return 6371008.8*Math.acos(Math.min(e,1))}toBounds(c=0){const a=360*c/40075017,b=a/Math.cos(Math.PI/180*this.lat);return new dx(new dy(this.lng-b,this.lat-a),new dy(this.lng+b,this.lat+a))}static convert(a){if(a instanceof dy)return a;if(Array.isArray(a)&&(2===a.length||3===a.length))return new dy(Number(a[0]),Number(a[1]));if(!Array.isArray(a)&&"object"==typeof a&&null!==a)return new dy(Number("lng"in a?a.lng:a.lon),Number(a.lat));throw 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 h5=2*Math.PI*6371008.8;function h6(a){return h5*Math.cos(a*Math.PI/180)}function dz(a){return(180+a)/360}function dA(a){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+a*Math.PI/360)))/360}function dB(a,b){return a/h6(b)}function h7(a){return 360*a-180}function dC(a){return 360/Math.PI*Math.atan(Math.exp((180-360*a)*Math.PI/180))-90}function h8(a,b){return a*h6(dC(b))}class dD{constructor(a,b,c=0){this.x=+a,this.y=+b,this.z=+c}static fromLngLat(b,c=0){const a=dy.convert(b);return new dD(dz(a.lng),dA(a.lat),dB(c,a.lat))}toLngLat(){return new dy(h7(this.x),dC(this.y))}toAltitude(){return h8(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/h5*(1/Math.cos(dC(this.y)*Math.PI/180))}}function h9(c,i,j,k,l,d,b,e,f){const g=(i+k)/2,h=(j+l)/2,a=new aF(g,h);e(a),function(e,f,a,b,g,h){const c=a-g,d=b-h;return Math.abs((b-f)*c-(a-e)*d)/Math.hypot(c,d)}(a.x,a.y,d.x,d.y,b.x,b.y)>=f?(h9(c,i,j,g,h,d,a,e,f),h9(c,g,h,k,l,a,b,e,f)):c.push(b)}function ia(i,d,j){const b=[];let e,f,c;for(const a of i){const{x:g,y:h}=a;d(a),c?h9(b,e,f,g,h,c,a,d,j):b.push(a),e=g,f=h,c=a}return b}function ib(a,d){const b=Math.round(a.x*d),c=Math.round(a.y*d);return a.x=bM(b,-16384,16383),a.y=bM(c,-16384,16383),(b<a.x||b>a.x+1||c<a.y||c>a.y+1)&&bY("Geometry exceeds allowed extent, reduce your vector tile buffer size"),a}function ic(d,g,e){const a=d.loadGeometry(),f=d.extent,j=8192/f;if(g&&e&&e.projection.isReprojectedInTileSpace){const m=1<<g.z,{scale:n,x:o,y:p,projection:q}=e,h=a=>{const c=h7((g.x+a.x/f)/m),d=dC((g.y+a.y/f)/m),b=q.project(c,d);a.x=(b.x*n-o)*f,a.y=(b.y*n-p)*f};for(let b=0;b<a.length;b++)if(1!==d.type)a[b]=ia(a[b],h,1);else{const i=[];for(const c of a[b])c.x<0||c.x>=f||c.y<0||c.y>=f||(h(c),i.push(c));a[b]=i}}for(const k of a)for(const l of k)ib(l,j);return a}function id(a,b){return{type:a.type,id:a.id,properties:a.properties,geometry:b?ic(a):[]}}function ie(a,b,c,d,e){a.emplaceBack(2*b+(d+1)/2,2*c+(e+1)/2)}class bf{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new al,this.indexArray=new aq,this.segments=new ay,this.programConfigurations=new dv(a.layers,a.zoom),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(g,h,a,m){const i=this.layers[0],d=[];let b=null;for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of("circle"===i.type&&(b=i.layout.get("circle-sort-key")),g)){const j=this.layers[0]._featureFilter.needGeometry,e=id(c,j);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),e,a))continue;const q=b?b.evaluate(e,{},a):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:j?e.geometry:ic(c,a,m),patterns:{},sortKey:q};d.push(r)}for(const k of(b&&d.sort((a,b)=>a.sortKey-b.sortKey),d)){const{geometry:l,index:f,sourceLayerIndex:s}=k,t=g[f].feature;this.addFeature(k,l,f,h.availableImages,a),h.featureIndex.insert(t,l,f,s,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,h4),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,g,h,i,j){for(const k of g)for(const f of k){const a=f.x,b=f.y;if(a<0||a>=8192||b<0||b>=8192)continue;const d=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),c=d.vertexLength;ie(this.layoutVertexArray,a,b,-1,-1),ie(this.layoutVertexArray,a,b,1,-1),ie(this.layoutVertexArray,a,b,1,1),ie(this.layoutVertexArray,a,b,-1,1),this.indexArray.emplaceBack(c,c+1,c+2),this.indexArray.emplaceBack(c,c+3,c+2),d.vertexLength+=4,d.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,h,{},i,j)}}function dE(a,b){for(let c=0;c<a.length;c++)if(ip(b,a[c]))return!0;for(let d=0;d<b.length;d++)if(ip(a,b[d]))return!0;return!!ij(a,b)}function ig(a,b,c){return!!ip(a,b)||!!il(b,a,c)}function ih(a,b){if(1===a.length)return io(b,a[0]);for(let c=0;c<b.length;c++){const g=b[c];for(let d=0;d<g.length;d++)if(ip(a,g[d]))return!0}for(let e=0;e<a.length;e++)if(io(b,a[e]))return!0;for(let f=0;f<b.length;f++)if(ij(a,b[f]))return!0;return!1}function ii(a,b,e){if(a.length>1){if(ij(a,b))return!0;for(let c=0;c<b.length;c++)if(il(b[c],a,e))return!0}for(let d=0;d<a.length;d++)if(il(a[d],b,e))return!0;return!1}function ij(a,b){if(0===a.length||0===b.length)return!1;for(let c=0;c<a.length-1;c++){const e=a[c],f=a[c+1];for(let d=0;d<b.length-1;d++)if(ik(e,f,b[d],b[d+1]))return!0}return!1}function ik(a,b,c,d){return eR(a,c,d)!==eR(b,c,d)&&eR(a,b,c)!==eR(a,b,d)}function il(c,a,d){const e=d*d;if(1===a.length)return c.distSqr(a[0])<e;for(let b=1;b<a.length;b++)if(im(c,a[b-1],a[b])<e)return!0;return!1}function im(c,a,b){const e=a.distSqr(b);if(0===e)return c.distSqr(a);const d=((c.x-a.x)*(b.x-a.x)+(c.y-a.y)*(b.y-a.y))/e;return c.distSqr(d<0?a:d>1?b:b.sub(a)._mult(d)._add(a))}function io(h,c){let b,a,d,e=!1;for(let f=0;f<h.length;f++){b=h[f];for(let g=0,i=b.length-1;g<b.length;i=g++)a=b[g],d=b[i],a.y>c.y!=d.y>c.y&&c.x<(d.x-a.x)*(c.y-a.y)/(d.y-a.y)+a.x&&(e=!e)}return e}function ip(b,c){let d=!1;for(let e=0,g=b.length-1;e<b.length;g=e++){const a=b[e],f=b[g];a.y>c.y!=f.y>c.y&&c.x<(f.x-a.x)*(c.y-a.y)/(f.y-a.y)+a.x&&(d=!d)}return d}function dF(a,d,e,f,g){for(const b of a)if(d<=b.x&&e<=b.y&&f>=b.x&&g>=b.y)return!0;const h=[new aF(d,e),new aF(d,g),new aF(f,g),new aF(f,e),];if(a.length>2){for(const i of h)if(ip(a,i))return!0}for(let c=0;c<a.length-1;c++)if(iq(a[c],a[c+1],h))return!0;return!1}function iq(a,b,c){const d=c[0],e=c[2];if(a.x<d.x&&b.x<d.x||a.x>e.x&&b.x>e.x||a.y<d.y&&b.y<d.y||a.y>e.y&&b.y>e.y)return!1;const f=eR(a,b,c[0]);return f!==eR(a,b,c[1])||f!==eR(a,b,c[2])||f!==eR(a,b,c[3])}function ir(a,b,d){const c=b.paint.get(a).value;return"constant"===c.kind?c.value:d.programConfigurations.get(b.id).getMaxValue(a)}function is(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])}function it(a,b,f,g,h){if(!b[0]&&!b[1])return a;const d=aF.convert(b)._mult(h);"viewport"===f&&d._rotate(-g);const e=[];for(let c=0;c<a.length;c++)e.push(a[c].sub(d));return e}function iu(b,c,d,e){const a=aF.convert(b)._mult(e);return"viewport"===c&&a._rotate(-d),a}c("CircleBucket",bf,{omit:["layers"]});const dG=new n({"circle-sort-key":new g(b.layout_circle["circle-sort-key"])});var iv={paint:new n({"circle-radius":new g(b.paint_circle["circle-radius"]),"circle-color":new g(b.paint_circle["circle-color"]),"circle-blur":new g(b.paint_circle["circle-blur"]),"circle-opacity":new g(b.paint_circle["circle-opacity"]),"circle-translate":new e(b.paint_circle["circle-translate"]),"circle-translate-anchor":new e(b.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new e(b.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new e(b.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new g(b.paint_circle["circle-stroke-width"]),"circle-stroke-color":new g(b.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new g(b.paint_circle["circle-stroke-opacity"])}),layout:dG};class dH{constructor(a,b){this.points=a,this.planes=b}static fromInvProjectionMatrix(d,e,a,f){const g=Math.pow(2,a),b=[[-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(j=>{var a,b,c;const h=bF([],j,d),i=1/h[3]/e*g;return a=h,b=h,c=[i,i,f?1/h[3]:i,i],a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a}),c=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5],].map(a=>{const c=bz([],bB([],bE([],b[a[0]],b[a[1]]),bE([],b[a[2]],b[a[1]]))),d=-bA(c,b[a[1]]);return c.concat(d)});return new dH(b,c)}}class B{constructor(a,b){this.min=a,this.max=b,this.center=bx([],bw([],this.min,this.max),.5)}quadrant(d){const b=[d%2==0,d<2],e=eH(this.min),c=eH(this.max);for(let a=0;a<b.length;a++)e[a]=b[a]?this.min[a]:this.center[a],c[a]=b[a]?this.center[a]:this.max[a];return c[2]=this.max[2],new B(e,c)}distanceX(a){return Math.max(Math.min(this.max[0],a[0]),this.min[0])-a[0]}distanceY(a){return Math.max(Math.min(this.max[1],a[1]),this.min[1])-a[1]}distanceZ(a){return Math.max(Math.min(this.max[2],a[2]),this.min[2])-a[2]}getCorners(){const a=this.min,b=this.max;return[[a[0],a[1],a[2]],[b[0],a[1],a[2]],[b[0],b[1],a[2]],[a[0],b[1],a[2]],[a[0],a[1],b[2]],[b[0],a[1],b[2]],[b[0],b[1],b[2]],[a[0],b[1],b[2]],]}intersects(b){const c=this.getCorners();let j=!0;for(let d=0;d<b.planes.length;d++){const k=b.planes[d];let e=0;for(let f=0;f<c.length;f++)e+=bA(k,c[f])+k[3]>=0;if(0===e)return 0;e!==c.length&&(j=!1)}if(j)return 2;for(let a=0;a<3;a++){let g=Number.MAX_VALUE,h=-Number.MAX_VALUE;for(let i=0;i<b.points.length;i++){const l=b.points[i][a]-this.min[a];g=Math.min(g,l),h=Math.max(h,l)}if(h<0||g>this.max[a]-this.min[a])return 0}return 1}}function iw(b,l,c,g,h,a,i,m,d){if(a&&b.queryGeometry.isAboveHorizon)return!1;for(const n of(a&&(d*=b.pixelToTileUnitsFactor),l))for(const f of n){const e=f.add(m),j=h&&c.elevation?c.elevation.exaggeration()*h.getElevationAt(e.x,e.y,!0):0,o=a?e:ix(e,j,g),p=a?b.tilespaceRays.map(a=>iA(a,j)):b.queryGeometry.screenGeometry,k=bF([],[f.x,f.y,j,1],g);if(!i&&a?d*=k[3]/c.cameraToCenterDistance:i&&!a&&(d*=c.cameraToCenterDistance/k[3]),ig(p,o,d))return!0}return!1}function ix(b,c,d){const a=bF([],[b.x,b.y,c,1],d);return new aF(a[0]/a[3],a[1]/a[3])}const iy=Q(0,0,0),iz=Q(0,0,1);function iA(b,c){const a=aK();return iy[2]=c,b.intersectsPlane(iy,iz,a),new aF(a[0],a[1])}class dI extends bf{}function iB(b,{width:c,height:d},e,a){if(a){if(a instanceof Uint8ClampedArray)a=new Uint8Array(a.buffer);else if(a.length!==c*d*e)throw RangeError("mismatched image size")}else a=new Uint8Array(c*d*e);return b.width=c,b.height=d,b.data=a,b}function iC(a,{width:b,height:c},d){if(b===a.width&&c===a.height)return;const e=iB({},{width:b,height:c},d);iD(a,e,{x:0,y:0},{x:0,y:0},{width:Math.min(a.width,b),height:Math.min(a.height,c)},d),a.width=b,a.height=c,a.data=e.data}function iD(c,b,d,e,a,h){if(0===a.width||0===a.height)return b;if(a.width>c.width||a.height>c.height||d.x>c.width-a.width||d.y>c.height-a.height)throw RangeError("out of range source coordinates for image copy");if(a.width>b.width||a.height>b.height||e.x>b.width-a.width||e.y>b.height-a.height)throw RangeError("out of range destination coordinates for image copy");const i=c.data,j=b.data;for(let f=0;f<a.height;f++){const k=((d.y+f)*c.width+d.x)*h,l=((e.y+f)*b.width+e.x)*h;for(let g=0;g<a.width*h;g++)j[l+g]=i[k+g]}return b}c("HeatmapBucket",dI,{omit:["layers"]});class dJ{constructor(a,b){iB(this,a,1,b)}resize(a){iC(this,a,1)}clone(){return new dJ({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(a,b,c,d,e){iD(a,b,c,d,e,1)}}class bg{constructor(a,b){iB(this,a,4,b)}resize(a){iC(this,a,4)}replace(a,b){b?this.data.set(a):this.data=a instanceof Uint8ClampedArray?new Uint8Array(a.buffer):a}clone(){return new bg({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(a,b,c,d,e){iD(a,b,c,d,e,4)}}c("AlphaImage",dJ),c("RGBAImage",bg);var iE={paint:new n({"heatmap-radius":new g(b.paint_heatmap["heatmap-radius"]),"heatmap-weight":new g(b.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new e(b.paint_heatmap["heatmap-intensity"]),"heatmap-color":new V(b.paint_heatmap["heatmap-color"]),"heatmap-opacity":new e(b.paint_heatmap["heatmap-opacity"])})};function dK(a){const o={},b=a.resolution||256,f=a.clips?a.clips.length:1,l=a.image||new bg({width:b,height:f}),g=(c,d,e)=>{o[a.evaluationKey]=e;const b=a.expression.evaluate(o);l.data[c+d+0]=Math.floor(255*b.r/b.a),l.data[c+d+1]=Math.floor(255*b.g/b.a),l.data[c+d+2]=Math.floor(255*b.b/b.a),l.data[c+d+3]=Math.floor(255*b.a)};if(a.clips)for(let c=0,h=0;c<f;++c,h+=4*b)for(let d=0,i=0;d<b;d++,i+=4){const j=d/(b-1),{start:m,end:n}=a.clips[c];g(h,i,m*(1-j)+n*j)}else for(let e=0,k=0;e<b;e++,k+=4)g(0,k,e/(b-1));return l}var iF={paint:new n({"hillshade-illumination-direction":new e(b.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new e(b.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new e(b.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new e(b.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new e(b.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new e(b.paint_hillshade["hillshade-accent-color"])})};const dL=j([{name:"a_pos",components:2,type:"Int16"},],4),{members:iG}=dL;var dM=az;function az(b,f,a){a=a||2;var d,e,g,h,i,j,k,n=f&&f.length,o=n?f[0]*a:b.length,c=iH(b,0,o,a,!0),m=[];if(!c||c.next===c.prev)return m;if(n&&(c=function(h,e,b,f){var a,g,c,d=[];for(a=0,g=e.length;a<g;a++)(c=iH(h,e[a]*f,a<g-1?e[a+1]*f:h.length,f,!1))===c.next&&(c.steiner=!0),d.push(iS(c));for(d.sort(iO),a=0;a<d.length;a++)b=iI(b=iP(d[a],b),b.next);return b}(b,f,c,a)),b.length>80*a){d=g=b[0],e=h=b[1];for(var l=a;l<o;l+=a)(i=b[l])<d&&(d=i),(j=b[l+1])<e&&(e=j),i>g&&(g=i),j>h&&(h=j);k=0!==(k=Math.max(g-d,h-e))?1/k:0}return iJ(c,m,a,d,e,k),m}function iH(c,e,f,d,g){var a,b;if(g===i3(c,e,f,d)>0)for(a=e;a<f;a+=d)b=i0(a,c[a],c[a+1],b);else for(a=f-d;a>=e;a-=d)b=i0(a,c[a],c[a+1],b);return b&&iW(b,b.next)&&(i1(b),b=b.next),b}function iI(c,b){if(!c)return c;b||(b=c);var d,a=c;do if(d=!1,a.steiner|| !iW(a,a.next)&&0!==iV(a.prev,a,a.next))a=a.next;else{if(i1(a),(a=b=a.prev)===a.next)break;d=!0}while(d||a!==b)return b}function iJ(a,b,c,e,f,d,h){if(a){!h&&d&&function(b,c,d,e){var a=b;do null===a.z&&(a.z=iR(a.x,a.y,c,d,e)),a.prevZ=a.prev,a.nextZ=a.next,a=a.next;while(a!==b)a.prevZ.nextZ=null,a.prevZ=null,function(g){var h,b,a,c,d,i,e,f,j=1;do{for(b=g,g=null,d=null,i=0;b;){for(i++,a=b,e=0,h=0;h<j&&(e++,a=a.nextZ);h++);for(f=j;e>0||f>0&&a;)0!==e&&(0===f||!a||b.z<=a.z)?(c=b,b=b.nextZ,e--):(c=a,a=a.nextZ,f--),d?d.nextZ=c:g=c,c.prevZ=d,d=c;b=a}d.nextZ=null,j*=2}while(i>1)}(a)}(a,e,f,d);for(var i,g,j=a;a.prev!==a.next;)if(i=a.prev,g=a.next,d?iL(a,e,f,d):iK(a))b.push(i.i/c),b.push(a.i/c),b.push(g.i/c),i1(a),a=g.next,j=g.next;else if((a=g)===j){h?1===h?iJ(a=iM(iI(a),b,c),b,c,e,f,d,2):2===h&&iN(a,b,c,e,f,d):iJ(iI(a),b,c,e,f,d,1);break}}}function iK(b){var c=b.prev,d=b,e=b.next;if(iV(c,d,e)>=0)return!1;for(var a=b.next.next;a!==b.prev;){if(iT(c.x,c.y,d.x,d.y,e.x,e.y,a.x,a.y)&&iV(a.prev,a,a.next)>=0)return!1;a=a.next}return!0}function iL(f,g,h,i){var d=f.prev,e=f,a=f.next;if(iV(d,e,a)>=0)return!1;for(var l=d.x>e.x?d.x>a.x?d.x:a.x:e.x>a.x?e.x:a.x,m=d.y>e.y?d.y>a.y?d.y:a.y:e.y>a.y?e.y:a.y,j=iR(d.x<e.x?d.x<a.x?d.x:a.x:e.x<a.x?e.x:a.x,d.y<e.y?d.y<a.y?d.y:a.y:e.y<a.y?e.y:a.y,g,h,i),k=iR(l,m,g,h,i),b=f.prevZ,c=f.nextZ;b&&b.z>=j&&c&&c.z<=k;){if(b!==f.prev&&b!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&iV(b.prev,b,b.next)>=0||(b=b.prevZ,c!==f.prev&&c!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&iV(c.prev,c,c.next)>=0))return!1;c=c.nextZ}for(;b&&b.z>=j;){if(b!==f.prev&&b!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,b.x,b.y)&&iV(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;c&&c.z<=k;){if(c!==f.prev&&c!==f.next&&iT(d.x,d.y,e.x,e.y,a.x,a.y,c.x,c.y)&&iV(c.prev,c,c.next)>=0)return!1;c=c.nextZ}return!0}function iM(d,e,f){var a=d;do{var c=a.prev,b=a.next.next;!iW(c,b)&&iX(c,a,a.next,b)&&i$(c,b)&&i$(b,c)&&(e.push(c.i/f),e.push(a.i/f),e.push(b.i/f),i1(a),i1(a.next),a=d=b),a=a.next}while(a!==d)return iI(a)}function iN(d,e,f,g,h,i){var a=d;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&iU(a,b)){var c=i_(a,b);return a=iI(a,a.next),c=iI(c,c.next),iJ(a,e,f,g,h,i),void iJ(c,e,f,g,h,i)}b=b.next}a=a.next}while(a!==d)}function iO(a,b){return a.x-b.x}function iP(c,b){var a=function(h,k){var b,a=k,d=h.x,c=h.y,e=-1/0;do{if(c<=a.y&&c>=a.next.y&&a.next.y!==a.y){var f=a.x+(c-a.y)*(a.next.x-a.x)/(a.next.y-a.y);if(f<=d&&f>e){if(e=f,f===d){if(c===a.y)return a;if(c===a.next.y)return a.next}b=a.x<a.next.x?a:a.next}}a=a.next}while(a!==k)if(!b)return null;if(d===e)return b;var g,m=b,l=b.x,i=b.y,j=1/0;a=b;do d>=a.x&&a.x>=l&&d!==a.x&&iT(c<i?d:e,c,l,i,c<i?e:d,c,a.x,a.y)&&(g=Math.abs(c-a.y)/(d-a.x),i$(a,h)&&(g<j||g===j&&(a.x>b.x||a.x===b.x&&iQ(b,a)))&&(b=a,j=g)),a=a.next;while(a!==m)return b}(c,b);if(!a)return b;var d=i_(a,c),e=iI(a,a.next);return iI(d,d.next),b===a?e:b}function iQ(a,b){return 0>iV(a.prev,a,b.prev)&&0>iV(b.next,a,a.next)}function iR(a,b,d,e,c){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-d)*c)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-e)*c)|b<<8))|b<<4))|b<<2))|b<<1))<<1}function iS(c){var a=c,b=c;do(a.x<b.x||a.x===b.x&&a.y<b.y)&&(b=a),a=a.next;while(a!==c)return b}function iT(c,d,e,f,g,h,a,b){return(g-a)*(d-b)-(c-a)*(h-b)>=0&&(c-a)*(f-b)-(e-a)*(d-b)>=0&&(e-a)*(h-b)-(g-a)*(f-b)>=0}function iU(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(b,c){var a=b;do{if(a.i!==b.i&&a.next.i!==b.i&&a.i!==c.i&&a.next.i!==c.i&&iX(a,a.next,b,c))return!0;a=a.next}while(a!==b)return!1}(a,b)&&(i$(a,b)&&i$(b,a)&&function(b,e){var a=b,c=!1,f=(b.x+e.x)/2,d=(b.y+e.y)/2;do a.y>d!=a.next.y>d&&a.next.y!==a.y&&f<(a.next.x-a.x)*(d-a.y)/(a.next.y-a.y)+a.x&&(c=!c),a=a.next;while(a!==b)return c}(a,b)&&(iV(a.prev,a,b.prev)||iV(a,b.prev,b))||iW(a,b)&&iV(a.prev,a,a.next)>0&&iV(b.prev,b,b.next)>0)}function iV(b,a,c){return(a.y-b.y)*(c.x-a.x)-(a.x-b.x)*(c.y-a.y)}function iW(a,b){return a.x===b.x&&a.y===b.y}function iX(a,b,c,d){var e=iZ(iV(a,b,c)),f=iZ(iV(a,b,d)),g=iZ(iV(c,d,a)),h=iZ(iV(c,d,b));return e!==f&&g!==h||!(0!==e||!iY(a,c,b))||!(0!==f||!iY(a,d,b))||!(0!==g||!iY(c,a,d))||!(0!==h||!iY(c,b,d))}function iY(a,b,c){return b.x<=Math.max(a.x,c.x)&&b.x>=Math.min(a.x,c.x)&&b.y<=Math.max(a.y,c.y)&&b.y>=Math.min(a.y,c.y)}function iZ(a){return a>0?1:a<0?-1:0}function i$(a,b){return 0>iV(a.prev,a,a.next)?iV(a,b,a.next)>=0&&iV(a,a.prev,b)>=0:0>iV(a,b,a.prev)||0>iV(a,a.next,b)}function i_(a,b){var d=new i2(a.i,a.x,a.y),c=new i2(b.i,b.x,b.y),e=a.next,f=b.prev;return a.next=b,b.prev=a,d.next=e,e.prev=d,c.next=d,d.prev=c,f.next=c,c.prev=f,c}function i0(c,d,e,b){var a=new i2(c,d,e);return b?(a.next=b.next,a.prev=b,b.next.prev=a,b.next=a):(a.prev=a,a.next=a),a}function i1(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function i2(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function i3(b,g,d,e){for(var f=0,a=g,c=d-e;a<d;a+=e)f+=(b[c]-b[a])*(b[a+1]+b[c+1]),c=a;return f}function i4(a,b,c,d,e){i5(a,b,c||0,d||a.length-1,e||i7)}function i5(a,e,b,d,g){for(;d>b;){if(d-b>600){var f=d-b+1,k=e-b+1,l=Math.log(f),i=.5*Math.exp(2*l/3),m=.5*Math.sqrt(l*i*(f-i)/f)*(k-f/2<0?-1:1);i5(a,e,Math.max(b,Math.floor(e-k*i/f+m)),Math.min(d,Math.floor(e+(f-k)*i/f+m)),g)}var j=a[e],h=b,c=d;for(i6(a,b,e),g(a[d],j)>0&&i6(a,b,d);h<c;){for(i6(a,h,c),h++,c--;0>g(a[h],j);)h++;for(;g(a[c],j)>0;)c--}0===g(a[b],j)?i6(a,b,c):i6(a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function i6(a,b,c){var d=a[b];a[b]=a[c],a[c]=d}function i7(a,b){return a<b?-1:a>b?1:0}function i8(c,f){const i=c.length;if(i<=1)return[c];const a=[];let d,h;for(let e=0;e<i;e++){const g=eS(c[e]);0!==g&&(c[e].area=Math.abs(g),void 0===h&&(h=g<0),h===g<0?(d&&a.push(d),d=[c[e]]):d.push(c[e]))}if(d&&a.push(d),f>1)for(let b=0;b<a.length;b++)a[b].length<=f||(i4(a[b],f,1,a[b].length-1,i9),a[b]=a[b].slice(0,f));return a}function i9(a,b){return b.area-a.area}function ja(e,f,g){const c=g.patternDependencies;let a=!1;for(const h of f){const d=h.paint.get(`${e}-pattern`);d.isConstant()||(a=!0);const b=d.constantOr(null);b&&(a=!0,c[b.to]=!0,c[b.from]=!0)}return a}function jb(j,k,d,g,e){const h=e.patternDependencies;for(const i of k){const f=i.paint.get(`${j}-pattern`).value;if("constant"!==f.kind){let a=f.evaluate({zoom:g-1},d,{},e.availableImages),b=f.evaluate({zoom:g},d,{},e.availableImages),c=f.evaluate({zoom:g+1},d,{},e.availableImages);a=a&&a.name?a.name:a,b=b&&b.name?b.name:b,c=c&&c.name?c.name:c,h[a]=!0,h[b]=!0,h[c]=!0,d.patterns[i.id]={min:a,mid:b,max:c}}}return d}az.deviation=function(a,d,c,e){var i=d&&d.length,f=Math.abs(i3(a,0,i?d[0]*c:a.length,c));if(i)for(var b=0,j=d.length;b<j;b++)f-=Math.abs(i3(a,d[b]*c,b<j-1?d[b+1]*c:a.length,c));var h=0;for(b=0;b<e.length;b+=3){var g=e[b]*c,k=e[b+1]*c,l=e[b+2]*c;h+=Math.abs((a[g]-a[l])*(a[k+1]-a[g+1])-(a[g]-a[k])*(a[l+1]-a[g+1]))}return 0===f&&0===h?0:Math.abs((h-f)/f)},az.flatten=function(b){for(var f=b[0][0].length,c={vertices:[],holes:[],dimensions:f},g=0,a=0;a<b.length;a++){for(var d=0;d<b[a].length;d++)for(var e=0;e<f;e++)c.vertices.push(b[a][d][e]);a>0&&c.holes.push(g+=b[a-1].length)}return c},dM.default=az;class dN{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new al,this.indexArray=new aq,this.indexArray2=new Y,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.segments2=new ay,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(i,a,b,l){this.hasPattern=ja("fill",this.layers,a);const d=this.layers[0].layout.get("fill-sort-key"),e=[];for(const{feature:c,id:m,index:n,sourceLayerIndex:o}of i){const j=this.layers[0]._featureFilter.needGeometry,f=id(c,j);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),f,b))continue;const p=d?d.evaluate(f,{},b,a.availableImages):void 0,q={id:m,properties:c.properties,type:c.type,sourceLayerIndex:o,index:n,geometry:j?f.geometry:ic(c,b,l),patterns:{},sortKey:p};e.push(q)}for(const g of(d&&e.sort((a,b)=>a.sortKey-b.sortKey),e)){const{geometry:k,index:h,sourceLayerIndex:r}=g;if(this.hasPattern){const s=jb("fill",this.layers,g,this.zoom,a);this.patternFeatures.push(s)}else this.addFeature(g,k,h,b,{},a.availableImages);a.featureIndex.insert(i[h].feature,k,h,r,this.index)}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,iG),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.indexBuffer2=a.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(a),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(m,n,o,p,q,r=[]){for(const g of i8(n,500)){let h=0;for(const s of g)h+=s.length;const i=this.segments.prepareSegment(h,this.layoutVertexArray,this.indexArray),j=i.vertexLength,c=[],l=[];for(const a of g){if(0===a.length)continue;a!==g[0]&&l.push(c.length/2);const k=this.segments2.prepareSegment(a.length,this.layoutVertexArray,this.indexArray2),f=k.vertexLength;this.layoutVertexArray.emplaceBack(a[0].x,a[0].y),this.indexArray2.emplaceBack(f+a.length-1,f),c.push(a[0].x),c.push(a[0].y);for(let b=1;b<a.length;b++)this.layoutVertexArray.emplaceBack(a[b].x,a[b].y),this.indexArray2.emplaceBack(f+b-1,f+b),c.push(a[b].x),c.push(a[b].y);k.vertexLength+=a.length,k.primitiveLength+=a.length}const d=dM(c,l);for(let e=0;e<d.length;e+=3)this.indexArray.emplaceBack(j+d[e],j+d[e+1],j+d[e+2]);i.vertexLength+=h,i.primitiveLength+=d.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,m,o,q,r,p)}}c("FillBucket",dN,{omit:["layers","patternFeatures"]});const dO=new n({"fill-sort-key":new g(b.layout_fill["fill-sort-key"])});var jc={paint:new n({"fill-antialias":new e(b.paint_fill["fill-antialias"]),"fill-opacity":new g(b.paint_fill["fill-opacity"]),"fill-color":new g(b.paint_fill["fill-color"]),"fill-outline-color":new g(b.paint_fill["fill-outline-color"]),"fill-translate":new e(b.paint_fill["fill-translate"]),"fill-translate-anchor":new e(b.paint_fill["fill-translate-anchor"]),"fill-pattern":new N(b.paint_fill["fill-pattern"])}),layout:dO};const dP=j([{name:"a_pos_normal_ed",components:4,type:"Int16"},]),jd=j([{name:"a_centroid_pos",components:2,type:"Uint16"},]),{members:je}=dP;var dQ=$;function $(a,b,c,d,e){this.properties={},this.extent=c,this.type=0,this._pbf=a,this._geometry=-1,this._keys=d,this._values=e,a.readFields(jf,this,b)}function jf(a,b,c){1==a?b.id=c.readVarint():2==a?function(a,b){for(var c=a.readVarint()+a.pos;a.pos<c;){var d=b._keys[a.readVarint()],e=b._values[a.readVarint()];b.properties[d]=e}}(c,b):3==a?b.type=c.readVarint():4==a&&(b._geometry=c.pos)}function jg(a){for(var c,d,e=0,b=0,f=a.length,g=f-1;b<f;g=b++)e+=((d=a[g]).x-(c=a[b]).x)*(c.y+d.y);return e}$.types=["Unknown","Point","LineString","Polygon",],$.prototype.loadGeometry=function(){var b=this._pbf;b.pos=this._geometry;for(var a,i=b.readVarint()+b.pos,c=1,d=0,f=0,g=0,e=[];b.pos<i;){if(d<=0){var h=b.readVarint();c=7&h,d=h>>3}if(d--,1===c||2===c)f+=b.readSVarint(),g+=b.readSVarint(),1===c&&(a&&e.push(a),a=[]),a.push(new aF(f,g));else{if(7!==c)throw Error("unknown command "+c);a&&a.push(a[0].clone())}}return a&&e.push(a),e},$.prototype.bbox=function(){var a=this._pbf;a.pos=this._geometry;for(var k=a.readVarint()+a.pos,b=1,e=0,c=0,d=0,f=1/0,g=-1/0,h=1/0,i=-1/0;a.pos<k;){if(e<=0){var j=a.readVarint();b=7&j,e=j>>3}if(e--,1===b||2===b)(c+=a.readSVarint())<f&&(f=c),c>g&&(g=c),(d+=a.readSVarint())<h&&(h=d),d>i&&(i=d);else if(7!==b)throw Error("unknown command "+b)}return[f,h,g,i]},$.prototype.toGeoJSON=function(h,i,j){var a,c,k=this.extent*Math.pow(2,j),l=this.extent*h,m=this.extent*i,b=this.loadGeometry(),d=$.types[this.type];function e(b){for(var a=0;a<b.length;a++){var c=b[a];b[a]=[360*(c.x+l)/k-180,360/Math.PI*Math.atan(Math.exp((180-360*(c.y+m)/k)*Math.PI/180))-90,]}}switch(this.type){case 1:var f=[];for(a=0;a<b.length;a++)f[a]=b[a][0];e(b=f);break;case 2:for(a=0;a<b.length;a++)e(b[a]);break;case 3:for(b=function(b){var g=b.length;if(g<=1)return[b];for(var a,d,e=[],c=0;c<g;c++){var f=jg(b[c]);0!==f&&(void 0===d&&(d=f<0),d===f<0?(a&&e.push(a),a=[b[c]]):a.push(b[c]))}return a&&e.push(a),e}(b),a=0;a<b.length;a++)for(c=0;c<b[a].length;c++)e(b[a][c])}1===b.length?b=b[0]:d="Multi"+d;var g={type:"Feature",geometry:{type:d,coordinates:b},properties:this.properties};return"id"in this&&(g.id=this.id),g};var dR=dS;function dS(a,b){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=a,this._keys=[],this._values=[],this._features=[],a.readFields(jh,this,b),this.length=this._features.length}function jh(a,b,c){15===a?b.version=c.readVarint():1===a?b.name=c.readString():5===a?b.extent=c.readVarint():2===a?b._features.push(c.pos):3===a?b._keys.push(c.readString()):4===a&&b._values.push(function(a){for(var c=null,d=a.readVarint()+a.pos;a.pos<d;){var b=a.readVarint()>>3;c=1===b?a.readString():2===b?a.readFloat():3===b?a.readDouble():4===b?a.readVarint64():5===b?a.readVarint():6===b?a.readSVarint():7===b?a.readBoolean():null}return c}(c))}function ji(c,d,a){if(3===c){var b=new dR(a,a.readVarint()+a.pos);b.length&&(d[b.name]=b)}}dS.prototype.feature=function(a){if(a<0||a>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[a];var b=this._pbf.readVarint()+this._pbf.pos;return new dQ(this._pbf,b,this.extent,this._keys,this._values)};var _={VectorTile:function(a,b){this.layers=a.readFields(ji,{},b)},VectorTileFeature:dQ,VectorTileLayer:dR};const jj=_.VectorTileFeature.types;function jk(a,b,c,d,e,f,g,h){a.emplaceBack((b<<1)+g,(c<<1)+f,(Math.floor(8192*d)<<1)+e,Math.round(h))}class dT{constructor(){this.acc=new aF(0,0),this.polyCount=[]}startRing(a){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new aF(a.x,a.y),this.max=new aF(a.x,a.y))}append(a,c){this.currentPolyCount.edges++,this.acc._add(a);let b=!!this.borders;const d=this.min,e=this.max;a.x<d.x?(d.x=a.x,b=!0):a.x>e.x&&(e.x=a.x,b=!0),a.y<d.y?(d.y=a.y,b=!0):a.y>e.y&&(e.y=a.y,b=!0),((0===a.x||8192===a.x)&&a.x===c.x)!=((0===a.y||8192===a.y)&&a.y===c.y)&&this.processBorderOverlap(a,c),b&&this.checkBorderIntersection(a,c)}checkBorderIntersection(b,a){a.x<0!=b.x<0&&this.addBorderIntersection(0,aY(a.y,b.y,(0-a.x)/(b.x-a.x))),a.x>8192!=b.x>8192&&this.addBorderIntersection(1,aY(a.y,b.y,(8192-a.x)/(b.x-a.x))),a.y<0!=b.y<0&&this.addBorderIntersection(2,aY(a.x,b.x,(0-a.y)/(b.y-a.y))),a.y>8192!=b.y>8192&&this.addBorderIntersection(3,aY(a.x,b.x,(8192-a.y)/(b.y-a.y)))}addBorderIntersection(c,a){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 b=this.borders[c];a<b[0]&&(b[0]=a),a>b[1]&&(b[1]=a)}processBorderOverlap(a,b){if(a.x===b.x){if(a.y===b.y)return;const c=0===a.x?0:1;this.addBorderIntersection(c,b.y),this.addBorderIntersection(c,a.y)}else{const d=0===a.y?2:3;this.addBorderIntersection(d,b.x),this.addBorderIntersection(d,a.x)}}centroid(){const a=this.polyCount.reduce((a,b)=>a+b.edges,0);return 0!==a?this.acc.div(a)._round():new aF(0,0)}span(){return new aF(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((a,b)=>a+ +(b[0]!==Number.MAX_VALUE),0)}}class dU{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.layoutVertexArray=new am,this.centroidVertexArray=new di,this.indexArray=new aq,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.enableTerrain=a.enableTerrain}populate(i,b,c,j){for(const{feature:a,id:k,index:e,sourceLayerIndex:f}of(this.features=[],this.hasPattern=ja("fill-extrusion",this.layers,b),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDone=[!1,!1,!1,!1],this.tileToMeter=function(a){const b=Math.exp(Math.PI*(1-a.y/(1<<a.z)*2));return 80150034*b/(b*b+1)/8192/(1<<a.z)}(c),i)){const g=this.layers[0]._featureFilter.needGeometry,h=id(a,g);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),h,c))continue;const d={id:k,sourceLayerIndex:f,index:e,geometry:g?h.geometry:ic(a,c,j),properties:a.properties,type:a.type,patterns:{}},l=this.layoutVertexArray.length;this.hasPattern?this.features.push(jb("fill-extrusion",this.layers,d,this.zoom,b)):this.addFeature(d,d.geometry,e,c,{},b.availableImages),b.featureIndex.insert(a,d.geometry,e,f,this.index,l)}this.sortBorders()}addFeatures(f,b,c,d){for(const a of this.features){const{geometry:e}=a;this.addFeature(a,e,a.index,b,c,d)}this.sortBorders()}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,je),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}uploadCentroid(a){0!==this.centroidVertexArray.length&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=a.createVertexBuffer(this.centroidVertexArray,jd.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(y,B,C,D,E,F){var l;const a=this.enableTerrain?new dT:null;for(const e of i8(B,500)){let m=0,b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);if(0===e.length||(l=e[0]).every(a=>a.x<=0)||l.every(a=>a.x>=8192)||l.every(a=>a.y<=0)||l.every(a=>a.y>=8192))continue;for(let u=0;u<e.length;u++){const g=e[u];if(0===g.length)continue;m+=g.length;let f=0;a&&a.startRing(g[0]);for(let i=0;i<g.length;i++){const c=g[i];if(i>=1){const d=g[i-1];if(!jl(c,d)){a&&a.append(c,d),b.vertexLength+4>ay.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const n=c.sub(d)._perp(),o=n.x/(Math.abs(n.x)+Math.abs(n.y)),p=n.y>0?1:0,z=d.dist(c);f+z>32768&&(f=0),jk(this.layoutVertexArray,c.x,c.y,o,p,0,0,f),jk(this.layoutVertexArray,c.x,c.y,o,p,0,1,f),f+=z,jk(this.layoutVertexArray,d.x,d.y,o,p,0,0,f),jk(this.layoutVertexArray,d.x,d.y,o,p,0,1,f);const h=b.vertexLength;this.indexArray.emplaceBack(h,h+2,h+1),this.indexArray.emplaceBack(h+1,h+2,h+3),b.vertexLength+=4,b.primitiveLength+=2}}}}if(b.vertexLength+m>ay.MAX_VERTEX_ARRAY_LENGTH&&(b=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray)),"Polygon"!==jj[y.type])continue;const q=[],A=[],v=b.vertexLength;for(let w=0;w<e.length;w++){const r=e[w];if(0!==r.length){r!==e[0]&&A.push(q.length/2);for(let x=0;x<r.length;x++){const s=r[x];jk(this.layoutVertexArray,s.x,s.y,0,0,1,1,0),q.push(s.x),q.push(s.y),a&&a.currentPolyCount.top++}}}const j=dM(q,A);for(let k=0;k<j.length;k+=3)this.indexArray.emplaceBack(v+j[k],v+j[k+2],v+j[k+1]);b.primitiveLength+=j.length/3,b.vertexLength+=m}if(a&&a.polyCount.length>0){if(a.borders){a.vertexArrayOffset=this.centroidVertexArray.length;const G=a.borders,H=this.featuresOnBorder.push(a)-1;for(let t=0;t<4;t++)G[t][0]!==Number.MAX_VALUE&&this.borders[t].push(H)}this.encodeCentroid(a.borders?void 0:a.centroid(),a)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,y,C,E,F,D)}sortBorders(){for(let a=0;a<4;a++)this.borders[a].sort((b,c)=>this.featuresOnBorder[b].borders[a][0]-this.featuresOnBorder[c].borders[a][0])}encodeCentroid(b,e,f=!0){let c,a;if(b){if(0!==b.y){const h=e.span()._mult(this.tileToMeter);c=(Math.max(b.x,1)<<3)+Math.min(7,Math.round(h.x/10)),a=(Math.max(b.y,1)<<3)+Math.min(7,Math.round(h.y/10))}else c=Math.ceil(7*(b.x+450)),a=0}else c=0,a=+f;let g=f?this.centroidVertexArray.length:e.vertexArrayOffset;for(const d of e.polyCount){f&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*d.edges+d.top);for(let i=0;i<2*d.edges;i++)this.centroidVertexArray.emplace(g++,0,a),this.centroidVertexArray.emplace(g++,c,a);for(let j=0;j<d.top;j++)this.centroidVertexArray.emplace(g++,c,a)}}}function jl(a,b){return a.x===b.x&&(a.x<0||a.x>8192)||a.y===b.y&&(a.y<0||a.y>8192)}c("FillExtrusionBucket",dU,{omit:["layers","features"]}),c("PartMetadata",dT);var jm={paint:new n({"fill-extrusion-opacity":new e(b["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new g(b["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new e(b["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new e(b["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new N(b["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new g(b["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new g(b["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new e(b["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function jn(a,b){return a.x*b.x+a.y*b.y}function jo(i,a){if(1===i.length){let b=0;const c=a[b++];let d;for(;!d||c.equals(d);)if(!(d=a[b++]))return 1/0;for(;b<a.length;b++){const j=a[b],t=i[0],e=d.sub(c),f=j.sub(c),k=t.sub(c),l=jn(e,e),g=jn(e,f),m=jn(f,f),n=jn(k,e),o=jn(k,f),p=l*m-g*g,q=(m*n-g*o)/p,r=(l*o-g*n)/p,s=c.z*(1-q-r)+d.z*q+j.z*r;if(isFinite(s))return s}return 1/0}{let h=1/0;for(const u of a)h=Math.min(h,u.z);return h}}function jp(a){const b=new aF(a[0],a[1]);return b.z=a[2],b}function jq(h,i,c,e,f,a,d,j){const b=d*f.getElevationAt(h,i,!0,!0),g=0!==a[0],k=g?0===a[1]?d*(a[0]/7-450):d*function(e,f,s){var b,c,d,k,g;const i=Math.floor(f[0]/8),j=Math.floor(f[1]/8),l=10*(f[0]-8*i),m=10*(f[1]-8*j),t=e.getElevationAt(i,j,!0,!0),h=e.getMeterToDEM(s),n=Math.floor(.5*(l*h-1)),o=Math.floor(.5*(m*h-1)),p=e.tileCoordToPixel(i,j),q=2*n+1,r=2*o+1,a=(b=e,c=p.x-n,d=p.y-o,k=q,g=r,[b.getElevationAtPixel(c,d,!0),b.getElevationAtPixel(c+g,d,!0),b.getElevationAtPixel(c,d+g,!0),b.getElevationAtPixel(c+k,d+g,!0),]),u=Math.abs(a[0]-a[1]),v=Math.abs(a[2]-a[3]),w=Math.abs(a[0]-a[2])+Math.abs(a[1]-a[3]),x=Math.min(.25,.5*h*(u+v)/q),y=Math.min(.25,.5*h*w/r);return t+Math.max(x*l,y*m)}(f,a,j):b;return{base:b+(0===c)?-1:c,top:g?Math.max(k+e,b+c+2):b+e}}const dV=j([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"},],4),{members:jr}=dV,dW=j([{name:"a_packed",components:3,type:"Float32"},]),{members:js}=dW,jt=_.VectorTileFeature.types,ju=Math.cos(Math.PI/180*37.5);class dX{constructor(a){this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(a=>{this.gradients[a.id]={}}),this.layoutVertexArray=new a6,this.layoutVertexArray2=new an,this.indexArray=new aq,this.programConfigurations=new dv(a.layers,a.zoom),this.segments=new ay,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id)}populate(j,a,b,m){this.hasPattern=ja("line",this.layers,a);const e=this.layers[0].layout.get("line-sort-key"),f=[];for(const{feature:c,id:n,index:o,sourceLayerIndex:p}of j){const k=this.layers[0]._featureFilter.needGeometry,g=id(c,k);if(!this.layers[0]._featureFilter.filter(new c5(this.zoom),g,b))continue;const q=e?e.evaluate(g,{},b):void 0,r={id:n,properties:c.properties,type:c.type,sourceLayerIndex:p,index:o,geometry:k?g.geometry:ic(c,b,m),patterns:{},sortKey:q};f.push(r)}e&&f.sort((a,b)=>a.sortKey-b.sortKey);const{lineAtlas:h,featureIndex:s}=a,t=this.addConstantDashes(h);for(const d of f){const{geometry:l,index:i,sourceLayerIndex:u}=d;if(t&&this.addFeatureDashes(d,h),this.hasPattern){const v=jb("line",this.layers,d,this.zoom,a);this.patternFeatures.push(v)}else this.addFeature(d,l,i,b,h.positions,a.availableImages);s.insert(j[i].feature,l,i,u,this.index)}}addConstantDashes(b){let d=!1;for(const e of this.layers){const f=e.paint.get("line-dasharray").value,g=e.layout.get("line-cap").value;if("constant"!==f.kind||"constant"!==g.kind)d=!0;else{const c=g.value,a=f.value;if(!a)continue;b.addDash(a.from,c),b.addDash(a.to,c),a.other&&b.addDash(a.other,c)}}return d}addFeatureDashes(a,b){const c=this.zoom;for(const m of this.layers){const d=m.paint.get("line-dasharray").value,e=m.layout.get("line-cap").value;if("constant"===d.kind&&"constant"===e.kind)continue;let g,h,i,j,k,l;if("constant"===d.kind){const f=d.value;if(!f)continue;g=f.other||f.to,h=f.to,i=f.from}else g=d.evaluate({zoom:c-1},a),h=d.evaluate({zoom:c},a),i=d.evaluate({zoom:c+1},a);"constant"===e.kind?j=k=l=e.value:(j=e.evaluate({zoom:c-1},a),k=e.evaluate({zoom:c},a),l=e.evaluate({zoom:c+1},a)),b.addDash(g,j),b.addDash(h,k),b.addDash(i,l);const n=b.getKey(g,j),o=b.getKey(h,k),p=b.getKey(i,l);a.patterns[m.id]={min:n,mid:o,max:p}}}update(a,b,c,d){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(a,b,this.stateDependentLayers,c,d)}addFeatures(e,b,c,d){for(const a of this.patternFeatures)this.addFeature(a,a.geometry,a.index,b,c,d)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(a){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=a.createVertexBuffer(this.layoutVertexArray2,js)),this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,jr),this.indexBuffer=a.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(a),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(a){if(a.properties&&a.properties.hasOwnProperty("mapbox_clip_start")&&a.properties.hasOwnProperty("mapbox_clip_end"))return{start:+a.properties.mapbox_clip_start,end:+a.properties.mapbox_clip_end}}addFeature(a,c,d,e,f,g){const b=this.layers[0].layout,h=b.get("line-join").evaluate(a,{}),i=b.get("line-cap").evaluate(a,{}),j=b.get("line-miter-limit"),k=b.get("line-round-limit");for(const l of(this.lineClips=this.lineFeatureClips(a),c))this.addLine(l,a,h,i,j,k);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,a,d,f,g,e)}addLine(g,K,A,L,v,M){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let q=0;q<g.length-1;q++)this.totalDistance+=g[q].dist(g[q+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const r="Polygon"===jt[K.type];let i=g.length;for(;i>=2&&g[i-1].equals(g[i-2]);)i--;let l=0;for(;l<i-1&&g[l].equals(g[l+1]);)l++;if(i<(r?3:2))return;"bevel"===A&&(v=1.05);const s=this.overscaling<=16?122880/(512*this.overscaling):0,c=this.segments.prepareSegment(10*i,this.layoutVertexArray,this.indexArray);let a,h,j,d,b;this.e1=this.e2=-1,r&&(a=g[i-2],b=g[l].sub(a)._unit()._perp());for(let m=l;m<i;m++){if((j=m===i-1?r?g[l+1]:void 0:g[m+1])&&g[m].equals(j))continue;b&&(d=b),a&&(h=a),a=g[m],b=j?j.sub(a)._unit()._perp():d;let f=(d=d||b).add(b);0===f.x&&0===f.y||f._unit();const o=d.x*b.x+d.y*b.y,t=f.x*b.x+f.y*b.y,k=0!==t?1/t:1/0,N=2*Math.sqrt(2-2*t),B=t<ju&&h&&j,p=d.x*b.y-d.y*b.x>0;if(B&&m>l){const C=a.dist(h);if(C>2*s){const w=a.sub(a.sub(h)._mult(s/C)._round());this.updateDistance(h,w),this.addCurrentVertex(w,d,0,0,c),h=w}}const D=h&&j;let e=D?A:r?"butt":L;if(D&&"round"===e&&(k<M?e="miter":k<=2&&(e="fakeround")),"miter"===e&&k>v&&(e="bevel"),"bevel"===e&&(k>2&&(e="flipbevel"),k<v&&(e="miter")),h&&this.updateDistance(h,a),"miter"===e)f._mult(k),this.addCurrentVertex(a,f,0,0,c);else if("flipbevel"===e){if(k>100)f=b.mult(-1);else{const O=k*d.add(b).mag()/d.sub(b).mag();f._perp()._mult(O*(p?-1:1))}this.addCurrentVertex(a,f,0,0,c),this.addCurrentVertex(a,f.mult(-1),0,0,c)}else if("bevel"===e||"fakeround"===e){const E=-Math.sqrt(k*k-1),F=p?E:0,G=p?0:E;if(h&&this.addCurrentVertex(a,d,F,G,c),"fakeround"===e){const H=Math.round(180*N/Math.PI/20);for(let x=1;x<H;x++){let n=x/H;if(.5!==n){const y=n-.5;n+=n*y*(n-1)*((1.0904+o*(o*(3.55645-1.43519*o)-3.2452))*y*y+(.848013+o*(.215638*o-1.06021)))}const I=b.sub(d)._mult(n)._add(d)._unit()._mult(p?-1:1);this.addHalfVertex(a,I.x,I.y,!1,p,0,c)}}j&&this.addCurrentVertex(a,b,-F,-G,c)}else if("butt"===e)this.addCurrentVertex(a,f,0,0,c);else if("square"===e){const u=h?1:-1;h||this.addCurrentVertex(a,f,u,u,c),this.addCurrentVertex(a,f,0,0,c),h&&this.addCurrentVertex(a,f,u,u,c)}else"round"===e&&(h&&(this.addCurrentVertex(a,d,0,0,c),this.addCurrentVertex(a,d,1,1,c,!0)),j&&(this.addCurrentVertex(a,b,-1,-1,c,!0),this.addCurrentVertex(a,b,0,0,c)));if(B&&m<i-1){const J=a.dist(j);if(J>2*s){const z=a.add(j.sub(a)._mult(s/J)._round());this.updateDistance(a,z),this.addCurrentVertex(z,b,0,0,c),a=z}}}}addCurrentVertex(d,a,b,c,e,f=!1){const g=a.y*c-a.x,h=-a.y-a.x*c;this.addHalfVertex(d,a.x+a.y*b,a.y-a.x*b,f,!1,b,e),this.addHalfVertex(d,g,h,f,!0,-c,e)}addHalfVertex({x:e,y:f},g,h,i,b,c,d){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(f<<1)+(b?1:0),Math.round(63*g)+128,Math.round(63*h)+128,1+(0===c?0:c<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineSoFar);const a=d.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,a),d.primitiveLength++),b?this.e2=a:this.e1=a}updateScaledDistance(){if(this.lineClips){const a=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=a*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(a,b){this.distance+=a.dist(b),this.updateScaledDistance()}}c("LineBucket",dX,{omit:["layers","patternFeatures"]});const dY=new n({"line-cap":new g(b.layout_line["line-cap"]),"line-join":new g(b.layout_line["line-join"]),"line-miter-limit":new e(b.layout_line["line-miter-limit"]),"line-round-limit":new e(b.layout_line["line-round-limit"]),"line-sort-key":new g(b.layout_line["line-sort-key"])});var dZ={paint:new n({"line-opacity":new g(b.paint_line["line-opacity"]),"line-color":new g(b.paint_line["line-color"]),"line-translate":new e(b.paint_line["line-translate"]),"line-translate-anchor":new e(b.paint_line["line-translate-anchor"]),"line-width":new g(b.paint_line["line-width"]),"line-gap-width":new g(b.paint_line["line-gap-width"]),"line-offset":new g(b.paint_line["line-offset"]),"line-blur":new g(b.paint_line["line-blur"]),"line-dasharray":new N(b.paint_line["line-dasharray"]),"line-pattern":new N(b.paint_line["line-pattern"]),"line-gradient":new V(b.paint_line["line-gradient"])}),layout:dY};const d$=new class extends g{possiblyEvaluate(b,a){return a=new c5(Math.floor(a.zoom),{now:a.now,fadeDuration:a.fadeDuration,zoomHistory:a.zoomHistory,transition:a.transition}),super.possiblyEvaluate(b,a)}evaluate(b,a,c,d){return a=bR({},a,{zoom:Math.floor(a.zoom)}),super.evaluate(b,a,c,d)}}(dZ.paint.properties["line-width"].specification);function jv(a,b){return b>0?b+2*a:a}d$.useIntegerZoom=!0;const jw=j([{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),jx=j([{name:"a_projected_pos",components:3,type:"Float32"},],4);j([{name:"a_fade_opacity",components:1,type:"Uint32"},],4);const jy=j([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},]),jz=j([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},]);j([{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 jA=j([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"},],4),d_=j([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"},],4);function d0(e,i){const{expression:a}=i;if("constant"===a.kind)return{kind:"constant",layoutSize:a.evaluate(new c5(e+1))};if("source"===a.kind)return{kind:"source"};{const{zoomStops:b,interpolationType:h}=a;let c=0;for(;c<b.length&&b[c]<=e;)c++;let d=c=Math.max(0,c-1);for(;d<b.length&&b[d]<e+1;)d++;d=Math.min(b.length-1,d);const f=b[c],g=b[d];return"composite"===a.kind?{kind:"composite",minZoom:f,maxZoom:g,interpolationType:h}:{kind:"camera",minZoom:f,maxZoom:g,minSize:a.evaluate(new c5(f)),maxSize:a.evaluate(new c5(g)),interpolationType:h}}}function bh(a,{uSize:c,uSizeT:d},{lowerSize:b,upperSize:e}){return"source"===a.kind?b/128:"composite"===a.kind?aY(b/128,e/128,d):c}function bi(a,f){let c=0,b=0;if("constant"===a.kind)b=a.layoutSize;else if("source"!==a.kind){const{interpolationType:d,minZoom:g,maxZoom:h}=a,e=d?bM(ai.interpolationFactor(d,f,g,h),0,1):0;"camera"===a.kind?b=aY(a.minSize,a.maxSize,e):c=e}return{uSizeT:c,uSize:b}}j([{name:"triangle",components:3,type:"Uint16"},]),j([{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"},]),j([{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"},]),j([{type:"Float32",name:"offsetX"},]),j([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"},]);var d1=Object.freeze({__proto__:null,getSizeData:d0,evaluateSizeForFeature:bh,evaluateSizeForZoom:bi,SIZE_PACK_FACTOR:128});function jB(a,b,c){return a.sections.forEach(a=>{a.text=function(a,c,d){const b=c.layout.get("text-transform").evaluate(d,{});return"uppercase"===b?a=a.toLocaleUpperCase():"lowercase"===b&&(a=a.toLocaleLowerCase()),c4.applyArabicShaping&&(a=c4.applyArabicShaping(a)),a}(a.text,b,c)}),a}const jC={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xa2":"\uFFE0","\xa3":"\uFFE1","\xa5":"\uFFE5","\xa6":"\uFFE4","\xac":"\uFFE2","\xaf":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42"};function jD(a){return"\uFE36"===a||"\uFE48"===a||"\uFE38"===a||"\uFE44"===a||"\uFE42"===a||"\uFE3E"===a||"\uFE3C"===a||"\uFE3A"===a||"\uFE18"===a||"\uFE40"===a||"\uFE10"===a||"\uFE13"===a||"\uFE14"===a||"\uFF40"===a||"\uFFE3"===a||"\uFE11"===a||"\uFE12"===a}function jE(a){return"\uFE35"===a||"\uFE47"===a||"\uFE37"===a||"\uFE43"===a||"\uFE41"===a||"\uFE3D"===a||"\uFE3B"===a||"\uFE39"===a||"\uFE17"===a||"\uFE3F"===a}var jF=function(g,h,j,e,k){var a,c,l=8*k-e-1,m=(1<<l)-1,n=m>>1,b=-7,d=j?k-1:0,i=j?-1:1,f=g[h+d];for(d+=i,a=f&(1<< -b)-1,f>>=-b,b+=l;b>0;a=256*a+g[h+d],d+=i,b-=8);for(c=a&(1<< -b)-1,a>>=-b,b+=e;b>0;c=256*c+g[h+d],d+=i,b-=8);if(0===a)a=1-n;else{if(a===m)return c?NaN:1/0*(f?-1:1);c+=Math.pow(2,e),a-=n}return(f?-1:1)*c*Math.pow(2,a-e)},jG=function(j,b,k,m,c,n){var a,d,e,h=8*n-c-1,i=(1<<h)-1,f=i>>1,o=23===c?5960464477539062e-23:0,g=m?0:n-1,l=m?1:-1,p=b<0||0===b&&1/b<0?1:0;for(isNaN(b=Math.abs(b))||b===1/0?(d=isNaN(b)?1:0,a=i):(a=Math.floor(Math.log(b)/Math.LN2),b*(e=Math.pow(2,-a))<1&&(a--,e*=2),(b+=a+f>=1?o/e:o*Math.pow(2,1-f))*e>=2&&(a++,e/=2),a+f>=i?(d=0,a=i):a+f>=1?(d=(b*e-1)*Math.pow(2,c),a+=f):(d=b*Math.pow(2,f-1)*Math.pow(2,c),a=0));c>=8;j[k+g]=255&d,g+=l,d/=256,c-=8);for(a=a<<c|d,h+=c;h>0;j[k+g]=255&a,g+=l,a/=256,h-=8);j[k+g-l]|=128*p},d2=P;function P(a){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(a)?a:new Uint8Array(a||0),this.pos=0,this.type=0,this.length=this.buf.length}P.Varint=0,P.Fixed64=1,P.Bytes=2,P.Fixed32=5;var jH="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function jI(a){return a.type===P.Bytes?a.readVarint()+a.pos:a.pos+1}function jJ(e,a,b){var d=a<=16383?1:a<=2097151?2:a<=268435455?3:Math.floor(Math.log(a)/(7*Math.LN2));b.realloc(d);for(var c=b.pos-1;c>=e;c--)b.buf[c+d]=b.buf[c]}function jK(b,c){for(var a=0;a<b.length;a++)c.writeVarint(b[a])}function jL(b,c){for(var a=0;a<b.length;a++)c.writeSVarint(b[a])}function jM(b,c){for(var a=0;a<b.length;a++)c.writeFloat(b[a])}function jN(b,c){for(var a=0;a<b.length;a++)c.writeDouble(b[a])}function jO(b,c){for(var a=0;a<b.length;a++)c.writeBoolean(b[a])}function jP(b,c){for(var a=0;a<b.length;a++)c.writeFixed32(b[a])}function jQ(b,c){for(var a=0;a<b.length;a++)c.writeSFixed32(b[a])}function jR(b,c){for(var a=0;a<b.length;a++)c.writeFixed64(b[a])}function jS(b,c){for(var a=0;a<b.length;a++)c.writeSFixed64(b[a])}function jT(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+16777216*a[b+3]}function jU(a,b,c){a[c]=b,a[c+1]=b>>>8,a[c+2]=b>>>16,a[c+3]=b>>>24}function jV(a,b){return(a[b]|a[b+1]<<8|a[b+2]<<16)+(a[b+3]<<24)}function jW(b,a,c){a.glyphs=[],1===b&&c.readMessage(jX,a)}function jX(a,b,c){if(3===a){const{id:f,bitmap:g,width:d,height:e,left:h,top:i,advance:j}=c.readMessage(jY,{});b.glyphs.push({id:f,bitmap:new dJ({width:d+6,height:e+6},g),metrics:{width:d,height:e,left:h,top:i,advance:j}})}else 4===a?b.ascender=c.readSVarint():5===a&&(b.descender=c.readSVarint())}function jY(a,b,c){1===a?b.id=c.readVarint():2===a?b.bitmap=c.readBytes():3===a?b.width=c.readVarint():4===a?b.height=c.readVarint():5===a?b.left=c.readSVarint():6===a?b.top=c.readSVarint():7===a&&(b.advance=c.readVarint())}function d3(g){let h=0,i=0;for(const j of g)h+=j.w*j.h,i=Math.max(i,j.w);g.sort((a,b)=>b.h-a.h);const c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(h/.95)),i),h:1/0},];let e=0,f=0;for(const a of g)for(let d=c.length-1;d>=0;d--){const b=c[d];if(!(a.w>b.w||a.h>b.h)){if(a.x=b.x,a.y=b.y,f=Math.max(f,a.y+a.h),e=Math.max(e,a.x+a.w),a.w===b.w&&a.h===b.h){const k=c.pop();d<c.length&&(c[d]=k)}else a.h===b.h?(b.x+=a.w,b.w-=a.w):a.w===b.w?(b.y+=a.h,b.h-=a.h):(c.push({x:b.x+a.w,y:b.y,w:b.w-a.w,h:a.h}),b.y+=a.h,b.h-=a.h);break}}return{w:e,h:f,fill:h/(e*f)||0}}P.prototype={destroy:function(){this.buf=null},readFields:function(d,c,a){for(a=a||this.length;this.pos<a;){var b=this.readVarint(),e=b>>3,f=this.pos;this.type=7&b,d(e,c,this),this.pos===f&&this.skip(b)}return c},readMessage:function(a,b){return this.readFields(a,b,this.readVarint()+this.pos)},readFixed32:function(){var a=jT(this.buf,this.pos);return this.pos+=4,a},readSFixed32:function(){var a=jV(this.buf,this.pos);return this.pos+=4,a},readFixed64:function(){var a=jT(this.buf,this.pos)+4294967296*jT(this.buf,this.pos+4);return this.pos+=8,a},readSFixed64:function(){var a=jT(this.buf,this.pos)+4294967296*jV(this.buf,this.pos+4);return this.pos+=8,a},readFloat:function(){var a=jF(this.buf,this.pos,!0,23,4);return this.pos+=4,a},readDouble:function(){var a=jF(this.buf,this.pos,!0,52,8);return this.pos+=8,a},readVarint:function(d){var a,b,c=this.buf;return a=127&(b=c[this.pos++]),b<128?a:(a|=(127&(b=c[this.pos++]))<<7,b<128?a:(a|=(127&(b=c[this.pos++]))<<14,b<128?a:(a|=(127&(b=c[this.pos++]))<<21,b<128?a:function(g,h,b){var e,f,c,a,d=b.buf;if(c=(112&(a=d[b.pos++]))>>4,a<128||(c|=(127&(a=d[b.pos++]))<<3,a<128)||(c|=(127&(a=d[b.pos++]))<<10,a<128)||(c|=(127&(a=d[b.pos++]))<<17,a<128)||(c|=(127&(a=d[b.pos++]))<<24,a<128)||(c|=(1&(a=d[b.pos++]))<<31,a<128))return e=g,f=c,h?4294967296*f+(e>>>0):4294967296*(f>>>0)+(e>>>0);throw Error("Expected varint not more than 10 bytes")}(a|=(15&(b=c[this.pos]))<<28,d,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var a=this.readVarint();return a%2==1?-((a+1)/2):a/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var c,d,e,a=this.readVarint()+this.pos,b=this.pos;return this.pos=a,a-b>=12&&jH?(c=this.buf,d=b,e=a,jH.decode(c.subarray(d,e))):function(d,k,j){for(var h="",b=k;b<j;){var f,g,i,c=d[b],a=null,e=c>239?4:c>223?3:c>191?2:1;if(b+e>j)break;1===e?c<128&&(a=c):2===e?128==(192&(f=d[b+1]))&&(a=(31&c)<<6|63&f)<=127&&(a=null):3===e?(g=d[b+2],128==(192&(f=d[b+1]))&&128==(192&g)&&((a=(15&c)<<12|(63&f)<<6|63&g)<=2047||a>=55296&&a<=57343)&&(a=null)):4===e&&(g=d[b+2],i=d[b+3],128==(192&(f=d[b+1]))&&128==(192&g)&&128==(192&i)&&((a=(15&c)<<18|(63&f)<<12|(63&g)<<6|63&i)<=65535||a>=1114112)&&(a=null)),null===a?(a=65533,e=1):a>65535&&(a-=65536,h+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),h+=String.fromCharCode(a),b+=e}return h}(this.buf,b,a)},readBytes:function(){var a=this.readVarint()+this.pos,b=this.buf.subarray(this.pos,a);return this.pos=a,b},readPackedVarint:function(a,b){if(this.type!==P.Bytes)return a.push(this.readVarint(b));var c=jI(this);for(a=a||[];this.pos<c;)a.push(this.readVarint(b));return a},readPackedSVarint:function(a){if(this.type!==P.Bytes)return a.push(this.readSVarint());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readSVarint());return a},readPackedBoolean:function(a){if(this.type!==P.Bytes)return a.push(this.readBoolean());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readBoolean());return a},readPackedFloat:function(a){if(this.type!==P.Bytes)return a.push(this.readFloat());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readFloat());return a},readPackedDouble:function(a){if(this.type!==P.Bytes)return a.push(this.readDouble());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readDouble());return a},readPackedFixed32:function(a){if(this.type!==P.Bytes)return a.push(this.readFixed32());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readFixed32());return a},readPackedSFixed32:function(a){if(this.type!==P.Bytes)return a.push(this.readSFixed32());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readSFixed32());return a},readPackedFixed64:function(a){if(this.type!==P.Bytes)return a.push(this.readFixed64());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readFixed64());return a},readPackedSFixed64:function(a){if(this.type!==P.Bytes)return a.push(this.readSFixed64());var b=jI(this);for(a=a||[];this.pos<b;)a.push(this.readSFixed64());return a},skip:function(b){var a=7&b;if(a===P.Varint)for(;this.buf[this.pos++]>127;);else if(a===P.Bytes)this.pos=this.readVarint()+this.pos;else if(a===P.Fixed32)this.pos+=4;else{if(a!==P.Fixed64)throw Error("Unimplemented type: "+a);this.pos+=8}},writeTag:function(a,b){this.writeVarint(a<<3|b)},realloc:function(c){for(var a=this.length||16;a<this.pos+c;)a*=2;if(a!==this.length){var b=new Uint8Array(a);b.set(this.buf),this.buf=b,this.length=a}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(a){this.realloc(4),jU(this.buf,a,this.pos),this.pos+=4},writeSFixed32:function(a){this.realloc(4),jU(this.buf,a,this.pos),this.pos+=4},writeFixed64:function(a){this.realloc(8),jU(this.buf,-1&a,this.pos),jU(this.buf,Math.floor(23283064365386963e-26*a),this.pos+4),this.pos+=8},writeSFixed64:function(a){this.realloc(8),jU(this.buf,-1&a,this.pos),jU(this.buf,Math.floor(23283064365386963e-26*a),this.pos+4),this.pos+=8},writeVarint:function(a){(a=+a||0)>268435455||a<0?function(e,h){var f,g,d,c,a,b,i;if(e>=0?(f=e%4294967296|0,g=e/4294967296|0):(g=~(-e/4294967296),4294967295^(f=~(-e%4294967296))?f=f+1|0:(f=0,g=g+1|0)),e>=18446744073709552e3||e< -18446744073709552e3)throw Error("Given varint doesn't fit into 10 bytes");h.realloc(10),d=f,(c=h).buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,d>>>=7,c.buf[c.pos++]=127&d|128,c.buf[c.pos]=127&(d>>>=7),a=g,b=h,i=(7&a)<<4,b.buf[b.pos++]|=i|((a>>>=3)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a|((a>>>=7)?128:0),a&&(b.buf[b.pos++]=127&a)))))}(a,this):(this.realloc(4),this.buf[this.pos++]=127&a|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=127&(a>>>=7)|(a>127?128:0),a<=127||(this.buf[this.pos++]=a>>>7&127))))},writeSVarint:function(a){this.writeVarint(a<0?-(2*a)-1:2*a)},writeBoolean:function(a){this.writeVarint(Boolean(a))},writeString:function(a){a=String(a),this.realloc(4*a.length),this.pos++;var c=this.pos;this.pos=function(c,f,b){for(var a,d,e=0;e<f.length;e++){if((a=f.charCodeAt(e))>55295&&a<57344){if(!d){a>56319||e+1===f.length?(c[b++]=239,c[b++]=191,c[b++]=189):d=a;continue}if(a<56320){c[b++]=239,c[b++]=191,c[b++]=189,d=a;continue}a=d-55296<<10|a-56320|65536,d=null}else d&&(c[b++]=239,c[b++]=191,c[b++]=189,d=null);a<128?c[b++]=a:(a<2048?c[b++]=a>>6|192:(a<65536?c[b++]=a>>12|224:(c[b++]=a>>18|240,c[b++]=a>>12&63|128),c[b++]=a>>6&63|128),c[b++]=63&a|128)}return b}(this.buf,a,this.pos);var b=this.pos-c;b>=128&&jJ(c,b,this),this.pos=c-1,this.writeVarint(b),this.pos+=b},writeFloat:function(a){this.realloc(4),jG(this.buf,a,this.pos,!0,23,4),this.pos+=4},writeDouble:function(a){this.realloc(8),jG(this.buf,a,this.pos,!0,52,8),this.pos+=8},writeBytes:function(c){var a=c.length;this.writeVarint(a),this.realloc(a);for(var b=0;b<a;b++)this.buf[this.pos++]=c[b]},writeRawMessage:function(c,d){this.pos++;var b=this.pos;c(d,this);var a=this.pos-b;a>=128&&jJ(b,a,this),this.pos=b-1,this.writeVarint(a),this.pos+=a},writeMessage:function(a,b,c){this.writeTag(a,P.Bytes),this.writeRawMessage(b,c)},writePackedVarint:function(b,a){a.length&&this.writeMessage(b,jK,a)},writePackedSVarint:function(b,a){a.length&&this.writeMessage(b,jL,a)},writePackedBoolean:function(b,a){a.length&&this.writeMessage(b,jO,a)},writePackedFloat:function(b,a){a.length&&this.writeMessage(b,jM,a)},writePackedDouble:function(b,a){a.length&&this.writeMessage(b,jN,a)},writePackedFixed32:function(b,a){a.length&&this.writeMessage(b,jP,a)},writePackedSFixed32:function(b,a){a.length&&this.writeMessage(b,jQ,a)},writePackedFixed64:function(b,a){a.length&&this.writeMessage(b,jR,a)},writePackedSFixed64:function(b,a){a.length&&this.writeMessage(b,jS,a)},writeBytesField:function(a,b){this.writeTag(a,P.Bytes),this.writeBytes(b)},writeFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeFixed32(b)},writeSFixed32Field:function(a,b){this.writeTag(a,P.Fixed32),this.writeSFixed32(b)},writeFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeFixed64(b)},writeSFixed64Field:function(a,b){this.writeTag(a,P.Fixed64),this.writeSFixed64(b)},writeVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeVarint(b)},writeSVarintField:function(a,b){this.writeTag(a,P.Varint),this.writeSVarint(b)},writeStringField:function(a,b){this.writeTag(a,P.Bytes),this.writeString(b)},writeFloatField:function(a,b){this.writeTag(a,P.Fixed32),this.writeFloat(b)},writeDoubleField:function(a,b){this.writeTag(a,P.Fixed64),this.writeDouble(b)},writeBooleanField:function(a,b){this.writeVarintField(a,Boolean(b))}};class bj{constructor(a,{pixelRatio:b,version:c,stretchX:d,stretchY:e,content:f}){this.paddedRect=a,this.pixelRatio=b,this.stretchX=d,this.stretchY=e,this.content=f,this.version=c}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1,]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1,]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio,]}}class d4{constructor(g,h){const i={},j={};this.haveRenderCallbacks=[];const k=[];this.addImages(g,i,k),this.addImages(h,j,k);const{w:q,h:r}=d3(k),b=new bg({width:q||1,height:r||1});for(const l in g){const m=g[l],n=i[l].paddedRect;bg.copy(m.data,b,{x:0,y:0},{x:n.x+1,y:n.y+1},m.data)}for(const o in h){const a=h[o],p=j[o].paddedRect,c=p.x+1,d=p.y+1,e=a.data.width,f=a.data.height;bg.copy(a.data,b,{x:0,y:0},{x:c,y:d},a.data),bg.copy(a.data,b,{x:0,y:f-1},{x:c,y:d-1},{width:e,height:1}),bg.copy(a.data,b,{x:0,y:0},{x:c,y:d+f},{width:e,height:1}),bg.copy(a.data,b,{x:e-1,y:0},{x:c-1,y:d},{width:1,height:f}),bg.copy(a.data,b,{x:0,y:0},{x:c+e,y:d},{width:1,height:f})}this.image=b,this.iconPositions=i,this.patternPositions=j}addImages(c,e,f){for(const b in c){const a=c[b],d={x:0,y:0,w:a.data.width+2,h:a.data.height+2};f.push(d),e[b]=new bj(d,a),a.hasRenderCallback&&this.haveRenderCallbacks.push(b)}}patchUpdatedImages(a,c){for(const b in a.dispatchRenderCallbacks(this.haveRenderCallbacks),a.updatedImages)this.patchUpdatedImage(this.iconPositions[b],a.getImage(b),c),this.patchUpdatedImage(this.patternPositions[b],a.getImage(b),c)}patchUpdatedImage(a,b,c){if(!a||!b||a.version===b.version)return;a.version=b.version;const[d,e]=a.tl;c.update(b.data,void 0,{x:d,y:e})}}c("ImagePosition",bj),c("ImageAtlas",d4);const d5={horizontal:1,vertical:2,horizontalOnly:3};class jZ{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(b,c){const a=new jZ;return a.scale=b||1,a.fontStack=c,a}static forImage(b){const a=new jZ;return a.imageName=b,a}}class j${constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(d,e){const a=new j$;for(let b=0;b<d.sections.length;b++){const c=d.sections[b];c.image?a.addImageSection(c):a.addTextSection(c,e)}return a}length(){return this.text.length}getSection(a){return this.sections[this.sectionIndex[a]]}getSections(){return this.sections}getSectionIndex(a){return this.sectionIndex[a]}getCharCode(a){return this.text.charCodeAt(a)}verticalizePunctuation(a){this.text=function(b,f){let c="";for(let a=0;a<b.length;a++){const d=b.charCodeAt(a+1)||null,e=b.charCodeAt(a-1)||null;c+=!f&&(d&&hw(d)&&!jC[b[a+1]]||e&&hw(e)&&!jC[b[a-1]])||!jC[b[a]]?b[a]:jC[b[a]]}return c}(this.text,a)}trim(){let a=0;for(let c=0;c<this.text.length&&j0[this.text.charCodeAt(c)];c++)a++;let d=this.text.length;for(let b=this.text.length-1;b>=0&&b>=a&&j0[this.text.charCodeAt(b)];b--)d--;this.text=this.text.substring(a,d),this.sectionIndex=this.sectionIndex.slice(a,d)}substring(b,c){const a=new j$;return a.text=this.text.substring(b,c),a.sectionIndex=this.sectionIndex.slice(b,c),a.sections=this.sections,a}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((a,b)=>Math.max(a,this.sections[b].scale),0)}addTextSection(a,c){this.text+=a.text,this.sections.push(jZ.forText(a.scale,a.fontStack||c));const d=this.sections.length-1;for(let b=0;b<a.text.length;++b)this.sectionIndex.push(d)}addImageSection(a){const b=a.image?a.image.name:"";if(0===b.length)return void bY("Can't add FormattedSection with an empty image.");const c=this.getNextImageSectionCharCode();c?(this.text+=String.fromCharCode(c),this.sections.push(jZ.forImage(b)),this.sectionIndex.push(this.sections.length-1)):bY("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function j_(u,c,v,d,w,i,x,y,z,e,f,j,m,k,l,A){const a=j$.fromFeature(u,w);let b;j===d5.vertical&&a.verticalizePunctuation(m);const{processBidirectionalText:n,processStyledBidirectionalText:o}=c4;if(n&&1===a.sections.length){b=[];const B=n(a.toString(),j7(a,e,i,c,d,k,l));for(const p of B){const g=new j$;g.text=p,g.sections=a.sections;for(let q=0;q<p.length;q++)g.sectionIndex.push(0);b.push(g)}}else if(o){b=[];const C=o(a.text,a.sectionIndex,j7(a,e,i,c,d,k,l));for(const r of C){const h=new j$;h.text=r[0],h.sectionIndex=r[1],h.sections=a.sections,b.push(h)}}else b=function(b,f){const c=[],d=b.text;let a=0;for(const e of f)c.push(b.substring(a,e)),a=e;return a<d.length&&c.push(b.substring(a,d.length)),c}(a,j7(a,e,i,c,d,k,l));const s=[],t={positionedLines:s,text:a.toString(),top:f[1],bottom:f[1],left:f[0],right:f[0],writingMode:j,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(b,H,U,V,I,t,W,J,X,v,K,Y){var m;let h=0,n=0,o=0;const w="right"===J?1:"left"===J?0:.5;let i=!1;for(const Z of I){const $=Z.getSections();for(const L of $){if(L.imageName)continue;const x=H[L.fontStack];if(x&&!(i=void 0!==x.ascender&& void 0!==x.descender))break}if(!i)break}let y=0;for(const f of I){f.trim();const j=f.getMaxScale(),_=(j-1)*24,z={positionedGlyphs:[],lineOffset:0};b.positionedLines[y]=z;const p=z.positionedGlyphs;let k=0;if(!f.length()){n+=t,++y;continue}let M=0,N=0;for(let q=0;q<f.length();q++){const e=f.getSection(q),O=f.getSectionIndex(q),c=f.getCharCode(q);let a=e.scale,d=null,u=null,A=null,B=24,r=0;const s=!(X===d5.horizontal|| !K&&!hv(c)||K&&(j0[c]||g1(m=c)||g2(m)||g3(m)||hm(m)||hq(m)));if(e.imageName){const C=V[e.imageName];if(!C)continue;A=e.imageName,b.iconsInText=b.iconsInText||!0,u=C.paddedRect;const g=C.displaySize;a=24*a/Y,d={width:g[0],height:g[1],left:1,top:-3,advance:s?g[1]:g[0],localGlyph:!1},r=i?-d.height*a:24*j-17-g[1]*a,B=d.advance;const D=(s?g[0]:g[1])*a-24*j;D>0&&D>k&&(k=D)}else{const E=U[e.fontStack];if(!E)continue;E[c]&&(u=E[c]);const l=H[e.fontStack];if(!l)continue;const P=l.glyphs[c];if(!P)continue;if(d=P.metrics,B=8203!==c?24:0,i){const F=void 0!==l.ascender?Math.abs(l.ascender):0,Q=void 0!==l.descender?Math.abs(l.descender):0,R=(F+Q)*a;M<R&&(M=R,N=(F-Q)/2*a),r=-F*a}else r=(j-a)*24-17}s?(b.verticalizable=!0,p.push({glyph:c,imageName:A,x:h,y:n+r,vertical:s,scale:a,localGlyph:d.localGlyph,fontStack:e.fontStack,sectionIndex:O,metrics:d,rect:u}),h+=B*a+v):(p.push({glyph:c,imageName:A,x:h,y:n+r,vertical:s,scale:a,localGlyph:d.localGlyph,fontStack:e.fontStack,sectionIndex:O,metrics:d,rect:u}),h+=d.advance*a+v)}0!==p.length&&(o=Math.max(h-v,o),i?j8(p,w,k,N,t*j/2):j8(p,w,k,0,t/2)),h=0;const aa=t*j+k;z.lineOffset=Math.max(k,_),n+=aa,++y}const G=n,{horizontalAlign:S,verticalAlign:T}=d6(W);(function(b,c,d,e,f,g){const h=(c-d)*f,i=-g*e;for(const j of b)for(const a of j.positionedGlyphs)a.x+=h,a.y+=i})(b.positionedLines,w,S,T,o,G),b.top+=-T*G,b.bottom=b.top+G,b.left+=-S*o,b.right=b.left+o,b.hasBaseline=i}(t,c,v,d,b,x,y,z,j,e,m,A),!function(a){for(const b of a)if(0!==b.positionedGlyphs.length)return!1;return!0}(s)&&t}const j0={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},j1={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 j2(f,a,g,h,b,i){if(a.imageName){const c=h[a.imageName];return c?c.displaySize[0]*a.scale*24/i+b:0}{const d=g[a.fontStack],e=d&&d.glyphs[f];return e?e.metrics.advance*a.scale+b:0}}function j3(b,c,d,e){const a=Math.pow(b-c,2);return e?b<c?a/2:2*a:a+Math.abs(d)*d}function j4(b,c,d){let a=0;return 10===b&&(a-=1e4),d&&(a+=150),40!==b&&65288!==b||(a+=50),41!==c&&65289!==c||(a+=50),a}function j5(i,a,d,j,e,f){let g=null,b=j3(a,d,e,f);for(const c of j){const h=j3(a-c.x,d,e,f)+c.badness;h<=b&&(g=c,b=h)}return{index:i,x:a,priorBreak:g,badness:b}}function j6(a){return a?j6(a.priorBreak).concat(a.index):[]}function j7(b,g,n,h,i,o,j){var a;if("point"!==o||!b)return[];const e=[],k=function(b,d,e,f,g,h){let c=0;for(let a=0;a<b.length();a++){const i=b.getSection(a);c+=j2(b.getCharCode(a),i,f,g,d,h)}return c/Math.max(1,Math.ceil(c/e))}(b,g,n,h,i,j),p=b.text.indexOf("\u200B")>=0;let f=0;for(let c=0;c<b.length();c++){const l=b.getSection(c),d=b.getCharCode(c);if(j0[d]||(f+=j2(d,l,h,i,g,j)),c<b.length()-1){const m=!((a=d)<11904||!(hb(a)||ha(a)||ho(a)||hl(a)||hf(a)||g4(a)||hc(a)||g7(a)||hg(a)||hh(a)||he(a)||hr(a)||g8(a)||g6(a)||g5(a)||hd(a)||g9(a)||hn(a)||hj(a)||hi(a)));(j1[d]||m||l.imageName)&&e.push(j5(c+1,f,k,e,j4(d,b.getCharCode(c+1),m&&p),!1))}}return j6(j5(b.length(),f,k,e,0,!0))}function d6(c){let a=.5,b=.5;switch(c){case"right":case"top-right":case"bottom-right":a=1;break;case"left":case"top-left":case"bottom-left":a=0}switch(c){case"bottom":case"bottom-right":case"bottom-left":b=1;break;case"top":case"top-right":case"top-left":b=0}return{horizontalAlign:a,verticalAlign:b}}function j8(a,d,e,f,g){if(!(d||e||f||g))return;const h=a.length-1,c=a[h],i=(c.x+c.metrics.advance*c.scale)*d;for(let b=0;b<=h;b++)a[b].x-=i,a[b].y+=e+f+g}function j9(a,b,e){const{horizontalAlign:f,verticalAlign:g}=d6(e),c=b[0]-a.displaySize[0]*f,d=b[1]-a.displaySize[1]*g;return{image:a,top:d,bottom:d+a.displaySize[1],left:c,right:c+a.displaySize[0]}}function ka(r,c,d,e,b,f){const a=r.image;let m;if(a.content){const g=a.content,h=a.pixelRatio||1;m=[g[0]/h,g[1]/h,a.displaySize[0]-g[2]/h,a.displaySize[1]-g[3]/h,]}const n=c.left*f,o=c.right*f;let i,j,k,l;"width"===d||"both"===d?(l=b[0]+n-e[3],j=b[0]+o+e[1]):j=(l=b[0]+(n+o-a.displaySize[0])/2)+a.displaySize[0];const p=c.top*f,q=c.bottom*f;return"height"===d||"both"===d?(i=b[1]+p-e[0],k=b[1]+q+e[2]):k=(i=b[1]+(p+q-a.displaySize[1])/2)+a.displaySize[1],{image:a,top:i,right:j,bottom:k,left:l,collisionPadding:m}}class d7 extends aF{constructor(b,c,d,e,a){super(b,c),this.angle=e,this.z=d,void 0!==a&&(this.segment=a)}clone(){return new d7(this.x,this.y,this.z,this.angle,this.segment)}}function kb(b,e,j,l,m){if(void 0===e.segment)return!0;let k=e,a=e.segment+1,c=0;for(;c> -j/2;){if(--a<0)return!1;c-=b[a].dist(k),k=b[a]}c+=b[a].dist(b[a+1]),a++;const f=[];let g=0;for(;c<j/2;){const h=b[a],i=b[a+1];if(!i)return!1;let d=b[a-1].angleTo(h)-h.angleTo(i);for(d=Math.abs((d+3*Math.PI)%(2*Math.PI)-Math.PI),f.push({distance:c,angleDelta:d}),g+=d;c-f[0].distance>l;)g-=f.shift().angleDelta;if(g>m)return!1;a++,c+=h.dist(i)}return!0}function kc(b){let c=0;for(let a=0;a<b.length-1;a++)c+=b[a].dist(b[a+1]);return c}function kd(a,b,c){return a?.6*b*c:0}function ke(a,b){return Math.max(a?a.right-a.left:0,b?b.right-b.left:0)}function kf(a,m,g,n,o,h){const i=kd(g,o,h),p=ke(g,n)*h;let e=0;const j=kc(a)/2;for(let b=0;b<a.length-1;b++){const c=a[b],d=a[b+1],f=c.dist(d);if(e+f>j){const k=(j-e)/f,q=aY(c.x,d.x,k),r=aY(c.y,d.y,k),l=new d7(q,r,0,d.angleTo(c),b);return!i||kb(a,l,p,i,m)?l:void 0}e+=f}}function kg(b,a,k,f,l,g,c,h,d){const m=kd(f,g,c),i=ke(f,l),e=i*c,j=0===b[0].x||b[0].x===d||0===b[0].y||b[0].y===d;return a-e<a/4&&(a=e+a/4),kh(b,j?a/2*h%a:(i/2+2*g)*c*h%a,a,m,k,e,j,!1,d)}function kh(a,t,d,i,p,j,q,u,k){const r=j/2,v=kc(a);let e=0,b=t-d,f=[];for(let c=0;c<a.length-1;c++){const g=a[c],h=a[c+1],l=g.dist(h),w=h.angleTo(g);for(;b+d<e+l;){b+=d;const s=(b-e)/l,m=aY(g.x,h.x,s),n=aY(g.y,h.y,s);if(m>=0&&m<k&&n>=0&&n<k&&b-r>=0&&b+r<=v){const o=new d7(m,n,0,w,c);o._round(),i&&!kb(a,o,j,i,p)||f.push(o)}}e+=l}return u||f.length||q||(f=kh(a,e/2,d,i,p,j,q,!0,k)),f}function d8(k,c,d,e,f){const l=[];for(let i=0;i<k.length;i++){const j=k[i];let g;for(let h=0;h<j.length-1;h++){let a=j[h],b=j[h+1];a.x<c&&b.x<c||(a.x<c?a=new aF(c,a.y+(c-a.x)/(b.x-a.x)*(b.y-a.y))._round():b.x<c&&(b=new aF(c,a.y+(c-a.x)/(b.x-a.x)*(b.y-a.y))._round()),a.y<d&&b.y<d||(a.y<d?a=new aF(a.x+(d-a.y)/(b.y-a.y)*(b.x-a.x),d)._round():b.y<d&&(b=new aF(a.x+(d-a.y)/(b.y-a.y)*(b.x-a.x),d)._round()),a.x>=e&&b.x>=e||(a.x>=e?a=new aF(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round():b.x>=e&&(b=new aF(e,a.y+(e-a.x)/(b.x-a.x)*(b.y-a.y))._round()),a.y>=f&&b.y>=f||(a.y>=f?a=new aF(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round():b.y>=f&&(b=new aF(a.x+(f-a.y)/(b.y-a.y)*(b.x-a.x),f)._round()),g&&a.equals(g[g.length-1])||(g=[a],l.push(g)),g.push(b)))))}}return l}function ki(f,a,b,g,h,c,i,j,k){for(let d=a;d<a+g;d++)kj(f,b*c+d,c,h,i,j,k);for(let e=b;e<b+h;e++)kj(f,e*c+a,1,g,i,j,k)}function kj(h,i,l,m,d,f,b){f[0]=0,b[0]=-1e20,b[1]=1e20,d[0]=h[i];for(let a=1,c=0,j=0;a<m;a++){d[a]=h[i+a*l];const p=a*a;do{const g=f[c];j=(d[a]-d[g]+p-g*g)/(a-g)/2}while(j<=b[c]&& --c> -1)f[++c]=a,b[c]=j,b[c+1]=1e20}for(let e=0,k=0;e<m;e++){for(;b[k+1]<e;)k++;const n=f[k],o=e-n;h[i+e*l]=d[n]+o*o}}c("Anchor",d7);const d9={none:0,ideographs:1,all:2};class aA{constructor(a,b,c){this.requestManager=a,this.localGlyphMode=b,this.localFontFamily=c,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(a){this.url=a}getGlyphs(a,e){const b=[];for(const c in a)for(const d of a[c])b.push({stack:c,id:d});bP(b,({stack:b,id:c},f)=>{let a=this.entries[b];a||(a=this.entries[b]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let d=a.glyphs[c];if(void 0!==d)return void f(null,{stack:b,id:c,glyph:d});if(d=this._tinySDF(a,b,c))return a.glyphs[c]=d,void f(null,{stack:b,id:c,glyph:d});const e=Math.floor(c/256);if(256*e>65535)return void f(Error("glyphs > 65535 not supported"));if(a.ranges[e])return void f(null,{stack:b,id:c,glyph:d});let g=a.requests[e];g||(g=a.requests[e]=[],aA.loadGlyphRange(b,e,this.url,this.requestManager,(d,b)=>{if(b){for(const c in a.ascender=b.ascender,a.descender=b.descender,b.glyphs)this._doesCharSupportLocalGlyph(+c)||(a.glyphs[+c]=b.glyphs[+c]);a.ranges[e]=!0}for(const f of g)f(d,b);delete a.requests[e]})),g.push((a,d)=>{a?f(a):d&&f(null,{stack:b,id:c,glyph:d.glyphs[c]||null})})},(d,f)=>{if(d)e(d);else if(f){const b={};for(const{stack:a,id:g,glyph:c}of f)void 0===b[a]&&(b[a]={}),void 0===b[a].glyphs&&(b[a].glyphs={}),b[a].glyphs[g]=c&&{id:c.id,bitmap:c.bitmap.clone(),metrics:c.metrics},b[a].ascender=this.entries[a].ascender,b[a].descender=this.entries[a].descender;e(null,b)}})}_doesCharSupportLocalGlyph(a){return this.localGlyphMode!==d9.none&&(this.localGlyphMode===d9.all?!!this.localFontFamily:!!this.localFontFamily&&(hh(a)||hk(a)||g8(a)||g9(a))||g7(a))}_tinySDF(e,d,a){const f=this.localFontFamily;if(!f||!this._doesCharSupportLocalGlyph(a))return;let b=e.tinySDF;if(!b){let c="400";/bold/i.test(d)?c="900":/medium/i.test(d)?c="500":/light/i.test(d)&&(c="200"),(b=e.tinySDF=new aA.TinySDF({fontFamily:f,fontWeight:c,fontSize:48,buffer:6,radius:16})).fontWeight=c}if(this.localGlyphs[b.fontWeight][a])return this.localGlyphs[b.fontWeight][a];const g=String.fromCharCode(a),{data:h,width:i,height:j,glyphWidth:k,glyphHeight:l,glyphLeft:m,glyphTop:n,glyphAdvance:o}=b.draw(g);return this.localGlyphs[b.fontWeight][a]={id:a,bitmap:new dJ({width:i,height:j},h),metrics:{width:k/2,height:l/2,left:m/2,top:n/2-27,advance:o/2,localGlyph:!0}}}}function kk(c,D,E,o){const h=[],b=c.image,F=b.pixelRatio,i=b.paddedRect.w-2,j=b.paddedRect.h-2,G=c.right-c.left,H=c.bottom-c.top,d=b.stretchX||[[0,i]],e=b.stretchY||[[0,j]],p=(b,a)=>b+a[1]-a[0],k=d.reduce(p,0),l=e.reduce(p,0),q=i-k,r=j-l;let s=0,t=k,u=0,v=l,x=0,y=q,z=0,A=r;if(b.content&&o){const a=b.content;s=kl(d,0,a[0]),u=kl(e,0,a[1]),t=kl(d,a[0],a[2]),v=kl(e,a[1],a[3]),x=a[0]-s,z=a[1]-u,y=a[2]-a[0]-t,A=a[3]-a[1]-v}const w=(a,d,e,f)=>{const i=(a.stretch-s)/t*G+c.left,J=a.fixed-x-y*a.stretch/k,j=(d.stretch-u)/v*H+c.top,K=d.fixed-z-A*d.stretch/l,m=(e.stretch-s)/t*G+c.left,L=e.fixed-x-y*e.stretch/k,n=(f.stretch-u)/v*H+c.top,M=f.fixed-z-A*f.stretch/l,o=new aF(i,j),p=new aF(m,j),q=new aF(m,n),r=new aF(i,n),N=new aF(J/F,K/F),O=new aF(L/F,M/F),h=D*Math.PI/180;if(h){const w=Math.sin(h),B=Math.cos(h),g=[B,-w,w,B];o._matMult(g),p._matMult(g),r._matMult(g),q._matMult(g)}const C=a.stretch+a.fixed,I=d.stretch+d.fixed;return{tl:o,tr:p,bl:r,br:q,tex:{x:b.paddedRect.x+1+C,y:b.paddedRect.y+1+I,w:e.stretch+e.fixed-C,h:f.stretch+f.fixed-I},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:N,pixelOffsetBR:O,minFontScaleX:y/F/G,minFontScaleY:A/F/H,isSDF:E}};if(o&&(b.stretchX||b.stretchY)){const m=km(d,q,k),n=km(e,r,l);for(let f=0;f<m.length-1;f++){const B=m[f],C=m[f+1];for(let g=0;g<n.length-1;g++)h.push(w(B,n[g],C,n[g+1]))}}else h.push(w({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:i+1},{fixed:0,stretch:j+1}));return h}function kl(e,a,b){let c=0;for(const d of e)c+=Math.max(a,Math.min(b,d[1]))-Math.max(a,Math.min(b,d[0]));return c}function km(d,e,f){const a=[{fixed:-1,stretch:0},];for(const[c,g]of d){const b=a[a.length-1];a.push({fixed:c-b.stretch,stretch:b.stretch}),a.push({fixed:c-b.stretch,stretch:b.stretch+(g-c)})}return a.push({fixed:e+1,stretch:f}),a}function kn(b,c,d,a){const e=c+b.positionedLines[a].lineOffset;return 0===a?d+e/2:d+(e+(c+b.positionedLines[a-1].lineOffset))/2}aA.loadGlyphRange=function(c,d,e,a,g){const b=256*d,f=a.transformRequest(a.normalizeGlyphsURL(e).replace("{fontstack}",c).replace("{range}",`${b}-${b+255}`),aV.Glyphs);fi(f,(b,c)=>{if(b)g(b);else if(c){var d;const e={},a=(d=c,new d2(d).readFields(jW,{}));for(const f of a.glyphs)e[f.id]=f;g(null,{glyphs:e,ascender:a.ascender,descender:a.descender})}})},aA.TinySDF=class{constructor({fontSize:c=24,buffer:d=3,radius:e=8,cutoff:f=.25,fontFamily:g="sans-serif",fontWeight:h="normal",fontStyle:i="normal"}){this.buffer=d,this.cutoff=f,this.radius=e;const a=this.size=c+4*d,j=this._createCanvas(a),b=this.ctx=j.getContext("2d",{willReadFrequently:!0});b.font=`${i} ${h} ${c}px ${g}`,b.textBaseline="alphabetic",b.textAlign="left",b.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(b){const a=document.createElement("canvas");return a.width=a.height=b,a}draw(p){const{width:u,actualBoundingBoxAscent:q,actualBoundingBoxDescent:v,actualBoundingBoxLeft:w,actualBoundingBoxRight:x}=this.ctx.measureText(p),r=Math.floor(q),b=Math.min(this.size-this.buffer,Math.ceil(x-w)),c=Math.min(this.size-this.buffer,Math.ceil(q)+Math.ceil(v)),d=b+2*this.buffer,m=c+2*this.buffer,i=d*m,s=new Uint8ClampedArray(i),t={data:s,width:d,height:m,glyphWidth:b,glyphHeight:c,glyphTop:r,glyphLeft:0,glyphAdvance:u};if(0===b||0===c)return t;const{ctx:n,buffer:a,gridInner:f,gridOuter:g}=this;n.clearRect(a,a,b,c),n.fillText(p,a,a+r+1);const y=n.getImageData(a,a,b,c);g.fill(1e20,0,i),f.fill(0,0,i);for(let j=0;j<c;j++)for(let k=0;k<b;k++){const o=y.data[4*(j*b+k)+3]/255;if(0===o)continue;const l=(j+a)*d+k+a;if(1===o)g[l]=0,f[l]=1e20;else{const e=.5-o;g[l]=e>0?e*e:0,f[l]=e<0?e*e:0}}ki(g,0,0,d,m,d,this.f,this.v,this.z),ki(f,a,a,b,c,d,this.f,this.v,this.z);for(let h=0;h<i;h++){const z=Math.sqrt(g[h])-Math.sqrt(f[h]);s[h]=Math.round(255-255*(z/this.radius+this.cutoff))}return t}};class ko{constructor(b=[],c=function(a,b){return a<b?-1:a>b?1:0}){if(this.data=b,this.length=this.data.length,this.compare=c,this.length>0)for(let a=(this.length>>1)-1;a>=0;a--)this._down(a)}push(a){this.data.push(a),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const a=this.data[0],b=this.data.pop();return this.length--,this.length>0&&(this.data[0]=b,this._down(0)),a}peek(){return this.data[0]}_up(a){const{data:b,compare:f}=this,c=b[a];for(;a>0;){const d=a-1>>1,e=b[d];if(f(c,e)>=0)break;b[a]=e,a=d}b[a]=c}_down(a){const{data:b,compare:f}=this,h=this.length>>1,g=b[a];for(;a<h;){let c=1+(a<<1),d=b[c];const e=c+1;if(e<this.length&&0>f(b[e],d)&&(c=e,d=b[e]),f(d,g)>=0)break;b[a]=d,a=c}b[a]=g}}function kp(e,r=1,p=!1){let h=1/0,i=1/0,j=-1/0,k=-1/0;const q=e[0];for(let f=0;f<q.length;f++){const c=q[f];(!f||c.x<h)&&(h=c.x),(!f||c.y<i)&&(i=c.y),(!f||c.x>j)&&(j=c.x),(!f||c.y>k)&&(k=c.y)}const l=Math.min(j-h,k-i);let a=l/2;const d=new ko([],kq);if(0===l)return new aF(h,i);for(let m=h;m<j;m+=l)for(let n=i;n<k;n+=l)d.push(new kr(m+a,n+a,a,e));let g=function(g){let c=0,h=0,i=0;const d=g[0];for(let e=0,j=d.length,k=j-1;e<j;k=e++){const a=d[e],b=d[k],f=a.x*b.y-b.x*a.y;h+=(a.x+b.x)*f,i+=(a.y+b.y)*f,c+=3*f}return new kr(h/c,i/c,0,g)}(e),o=d.length;for(;d.length;){const b=d.pop();(b.d>g.d||!g.d)&&(g=b,p&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,o)),b.max-g.d<=r||(a=b.h/2,d.push(new kr(b.p.x-a,b.p.y-a,a,e)),d.push(new kr(b.p.x+a,b.p.y-a,a,e)),d.push(new kr(b.p.x-a,b.p.y+a,a,e)),d.push(new kr(b.p.x+a,b.p.y+a,a,e)),o+=4)}return p&&(console.log(`num probes: ${o}`),console.log(`best distance: ${g.d}`)),g.p}function kq(a,b){return b.max-a.max}function kr(a,b,c,d){this.p=new aF(a,b),this.h=c,this.d=function(b,i){let d=!1,e=1/0;for(let f=0;f<i.length;f++){const g=i[f];for(let h=0,j=g.length,k=j-1;h<j;k=h++){const a=g[h],c=g[k];a.y>b.y!=c.y>b.y&&b.x<(c.x-a.x)*(b.y-a.y)/(c.y-a.y)+a.x&&(d=!d),e=Math.min(e,im(b,a,c))}}return(d?1:-1)*Math.sqrt(e)}(this.p,d),this.max=this.d+this.h*Math.SQRT2}const ks=Number.POSITIVE_INFINITY,kt=Math.sqrt(2);function ea(b,a){return a[1]!==ks?function(e,a,b){let c=0,d=0;switch(a=Math.abs(a),b=Math.abs(b),e){case"top-right":case"top-left":case"top":d=b-7;break;case"bottom-right":case"bottom-left":case"bottom":d=7-b}switch(e){case"top-right":case"bottom-right":case"right":c=-a;break;case"top-left":case"bottom-left":case"left":c=a}return[c,d]}(b,a[0],a[1]):function(e,a){let b=0,c=0;a<0&&(a=0);const d=a/kt;switch(e){case"top-right":case"top-left":c=d-7;break;case"bottom-right":case"bottom-left":c=7-d;break;case"bottom":c=7-a;break;case"top":c=a-7}switch(e){case"top-right":case"bottom-right":b=-d;break;case"top-left":case"bottom-left":b=d;break;case"left":b=a;break;case"right":b=-a}return[b,c]}(b,a[0])}function ku(a,w,x,y,n,M,N,b,o,O){a.createArrays(),a.tilePixelRatio=8192/(512*a.overscaling),a.compareText={},a.iconsNeedLinear=!1;const d=a.layers[0].layout,g=a.layers[0]._unevaluatedLayout._values,e={};if("composite"===a.textSizeData.kind){const{minZoom:P,maxZoom:Q}=a.textSizeData;e.compositeTextSizes=[g["text-size"].possiblyEvaluate(new c5(P),b),g["text-size"].possiblyEvaluate(new c5(Q),b),]}if("composite"===a.iconSizeData.kind){const{minZoom:R,maxZoom:S}=a.iconSizeData;e.compositeIconSizes=[g["icon-size"].possiblyEvaluate(new c5(R),b),g["icon-size"].possiblyEvaluate(new c5(S),b),]}e.layoutTextSize=g["text-size"].possiblyEvaluate(new c5(o+1),b),e.layoutIconSize=g["icon-size"].possiblyEvaluate(new c5(o+1),b),e.textMaxSize=g["text-size"].possiblyEvaluate(new c5(18),b);const z="map"===d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),T=d.get("text-size");for(const c of a.features){const A=d.get("text-font").evaluate(c,{},b).join(","),B=T.evaluate(c,{},b),p=e.layoutTextSize.evaluate(c,{},b),f=(e.layoutIconSize.evaluate(c,{},b),{horizontal:{},vertical:void 0}),k=c.text;let q,l=[0,0];if(k){const C=k.toString(),U=24*d.get("text-letter-spacing").evaluate(c,{},b),D=24*d.get("text-line-height").evaluate(c,{},b),E=ht(C)?U:0,r=d.get("text-anchor").evaluate(c,{},b),s=d.get("text-variable-anchor");if(!s){const F=d.get("text-radial-offset").evaluate(c,{},b);l=F?ea(r,[24*F,ks]):d.get("text-offset").evaluate(c,{},b).map(a=>24*a)}let h=z?"center":d.get("text-justify").evaluate(c,{},b);const i=d.get("symbol-placement"),V="point"===i,G="point"===i?24*d.get("text-max-width").evaluate(c,{},b):0,H=b=>{a.allowVerticalPlacement&&hs(C)&&(f.vertical=j_(k,w,x,n,A,G,D,r,b,E,l,d5.vertical,!0,i,p,B))};if(!z&&s){const I="auto"===h?s.map(a=>eb(a)):[h];let J=!1;for(let t=0;t<I.length;t++){const m=I[t];if(!f.horizontal[m]){if(J)f.horizontal[m]=f.horizontal[0];else{const u=j_(k,w,x,n,A,G,D,"center",m,E,l,d5.horizontal,!1,i,p,B);u&&(f.horizontal[m]=u,J=1===u.positionedLines.length)}}}H("left")}else{if("auto"===h&&(h=eb(r)),V||d.get("text-writing-mode").indexOf("horizontal")>=0||!hs(C)){const K=j_(k,w,x,n,A,G,D,r,h,E,l,d5.horizontal,!1,i,p,B);K&&(f.horizontal[h]=K)}H("point"===i?"left":h)}}let L=!1;if(c.icon&&c.icon.name){const j=y[c.icon.name];j&&(q=j9(n[c.icon.name],d.get("icon-offset").evaluate(c,{},b),d.get("icon-anchor").evaluate(c,{},b)),L=j.sdf,void 0===a.sdfIcons?a.sdfIcons=j.sdf:a.sdfIcons!==j.sdf&&bY("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(j.pixelRatio!==a.pixelRatio||0!==d.get("icon-rotate").constantOr(1))&&(a.iconsNeedLinear=!0))}const v=ky(f.horizontal)||f.vertical;a.iconsInText||(a.iconsInText=!!v&&v.iconsInText),(v||q)&&kv(a,c,f,q,y,e,p,0,l,L,N,b,O)}M&&a.generateCollisionDebugBuffers(o,a.collisionBoxArray)}function eb(a){switch(a){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function kv(c,b,e,f,F,A,n,G,H,I,J,d,K){let i=A.textMaxSize.evaluate(b,{},d);void 0===i&&(i=n);const a=c.layers[0].layout,o=a.get("icon-offset").evaluate(b,{},d),g=ky(e.horizontal)||e.vertical,p=n/24,q=c.tilePixelRatio*i/24,r=c.tilePixelRatio*a.get("symbol-spacing"),L=a.get("text-padding")*c.tilePixelRatio,M=a.get("icon-padding")*c.tilePixelRatio,s=a.get("text-max-angle")*aP,N="map"===a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement"),O="map"===a.get("icon-rotation-alignment")&&"point"!==a.get("symbol-placement"),t=a.get("symbol-placement"),B=r/2,j=a.get("icon-text-fit");let C;f&&"none"!==j&&(c.allowVerticalPlacement&&e.vertical&&(C=ka(f,e.vertical,j,a.get("icon-text-fit-padding"),o,p)),g&&(f=ka(f,g,j,a.get("icon-text-fit-padding"),o,p)));const h=(g,a,h)=>{if(a.x<0||a.x>=8192||a.y<0||a.y>=8192)return;const{x:i,y:j,z:k}=K.projectTilePoint(a.x,a.y,h),l=new d7(i,j,k,0,void 0);!function(a,d,e,aa,h,z,H,j,f,r,m,s,t,I,u,v,ac,J,K,L,b,w,M,x,c){const k=a.addToLineVertexArray(d,aa);let l,n,o,y,N,O,P,Q=0,R=0,S=0,T=0,A=-1,B=-1;const g={};let U=bd(""),C=0,D=0;if(void 0===f._unevaluatedLayout.getValue("text-radial-offset")?[C,D]=f.layout.get("text-offset").evaluate(b,{},c).map(a=>24*a):(C=24*f.layout.get("text-radial-offset").evaluate(b,{},c),D=ks),a.allowVerticalPlacement&&h.vertical){const V=h.vertical;if(u)O=kA(V),j&&(P=kA(j));else{const W=f.layout.get("text-rotate").evaluate(b,{},c)+90;o=kz(r,e,d,m,s,t,V,I,W,v),j&&(y=kz(r,e,d,m,s,t,j,J,W))}}if(z){const E=f.layout.get("icon-rotate").evaluate(b,{},c),X="none"!==f.layout.get("icon-text-fit"),Y=kk(z,E,M,X),F=j?kk(j,E,M,X):void 0;n=kz(r,e,d,m,s,t,z,J,E),Q=4*Y.length;const Z=a.iconSizeData;let p=null;"source"===Z.kind?(p=[128*f.layout.get("icon-size").evaluate(b,{},c),])[0]>kw&&bY(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`):"composite"===Z.kind&&((p=[128*w.compositeIconSizes[0].evaluate(b,{},c),128*w.compositeIconSizes[1].evaluate(b,{},c),])[0]>kw||p[1]>kw)&&bY(`${a.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`),a.addSymbols(a.icon,Y,p,L,K,b,!1,e,d,k.lineStartIndex,k.lineLength,-1,x,c),A=a.icon.placedSymbolArray.length-1,F&&(R=4*F.length,a.addSymbols(a.icon,F,p,L,K,b,d5.vertical,e,d,k.lineStartIndex,k.lineLength,-1,x,c),B=a.icon.placedSymbolArray.length-1)}for(const $ in h.horizontal){const q=h.horizontal[$];l||(U=bd(q.text),u?N=kA(q):l=kz(r,e,d,m,s,t,q,I,f.layout.get("text-rotate").evaluate(b,{},c),v));const _=1===q.positionedLines.length;if(S+=kx(a,e,d,q,H,f,u,b,v,k,h.vertical?d5.horizontal:d5.horizontalOnly,_?Object.keys(h.horizontal):[$],g,A,w,x,c),_)break}h.vertical&&(T+=kx(a,e,d,h.vertical,H,f,u,b,v,k,d5.vertical,["vertical"],g,B,w,x,c));let i=-1;const G=(a,b)=>a?Math.max(a,b):b;i=G(N,i),i=G(O,i),i=G(P,i);const ab=i> -1?1:0;a.glyphOffsetArray.length>=aB.MAX_GLYPHS&&bY("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&a.addToSortKeyRanges(a.symbolInstances.length,b.sortKey),a.symbolInstances.emplaceBack(e.x,e.y,e.z,d.x,d.y,g.right>=0?g.right:-1,g.center>=0?g.center:-1,g.left>=0?g.left:-1,g.vertical>=0?g.vertical:-1,A,B,U,void 0!==l?l:a.collisionBoxArray.length,void 0!==l?l+1:a.collisionBoxArray.length,void 0!==o?o:a.collisionBoxArray.length,void 0!==o?o+1:a.collisionBoxArray.length,void 0!==n?n:a.collisionBoxArray.length,void 0!==n?n+1:a.collisionBoxArray.length,y||a.collisionBoxArray.length,y?y+1:a.collisionBoxArray.length,m,S,T,Q,R,ab,0,C,D,i)}(c,a,l,g,e,f,F,C,c.layers[0],c.collisionBoxArray,b.index,b.sourceLayerIndex,c.index,L,N,H,0,M,O,o,b,A,I,J,d)};if("line"===t)for(const u of d8(b.geometry,0,0,8192,8192)){const D=kg(u,r,s,e.vertical||g,f,24,q,c.overscaling,8192);for(const v of D){const w=g;w&&kB(c,w.text,B,v)||h(u,v,d)}}else if("line-center"===t){for(const k of b.geometry)if(k.length>1){const x=kf(k,s,e.vertical||g,f,24,q);x&&h(k,x,d)}}else if("Polygon"===b.type)for(const y of i8(b.geometry,0)){const z=kp(y,16);h(y[0],new d7(z.x,z.y,0,0,void 0),d)}else if("LineString"===b.type)for(const l of b.geometry)h(l,new d7(l[0].x,l[0].y,0,0,void 0),d);else if("Point"===b.type)for(const E of b.geometry)for(const m of E)h([m],new d7(m.x,m.y,0,0,void 0),d)}const kw=32640;function kx(a,l,m,n,o,e,f,b,g,h,p,q,r,s,i,t,c){const j=function(Z,c,g,M,l,N,O,B){const s=[];if(0===c.positionedLines.length)return s;const h=M.layout.get("text-rotate").evaluate(N,{})*Math.PI/180,m=function(c){const a=c[0],b=c[1],d=a*b;return d>0?[a,-b]:d<0?[-a,b]:0===a?[b,a]:[b,-a]}(g);let C=Math.abs(c.top-c.bottom);for(const P of c.positionedLines)C-=P.lineOffset;const D=c.positionedLines.length,Q=C/D;let t=c.top-g[1];for(let n=0;n<D;++n){const R=c.positionedLines[n];for(const a of(t=kn(c,Q,t,n),R.positionedGlyphs)){if(!a.rect)continue;const S=a.rect||{};let d=4,E=!0,u=1,v=0;if(a.imageName){const w=O[a.imageName];if(!w)continue;if(w.sdf){bY("SDF images are not supported in formatted text and will be ignored.");continue}E=!1,d=1/(u=w.pixelRatio)}const F=(l||B)&&a.vertical,e=a.metrics.advance*a.scale/2,f=a.metrics,i=a.rect;if(null===i)continue;B&&c.verticalizable&&(v=a.imageName?e-a.metrics.width*a.scale/2:0);const T=l?[a.x+e,a.y]:[0,0];let j=[0,0],G=[0,0],H=!1;l||(F?(G=[a.x+e+m[0],a.y+m[1]-v,],H=!0):j=[a.x+e+g[0],a.y+g[1]-v,]);const x=i.w*a.scale/(u*(a.localGlyph?2:1)),o=i.h*a.scale/(u*(a.localGlyph?2:1));let b,p,q,r;if(F){const I=a.y-t,U=new aF(-e,e-I),V=-Math.PI/2,W=new aF(...G);(b=new aF(-e+j[0],j[1]))._rotateAround(V,U)._add(W),b.x+=-I+e,b.y-=(f.left-d)*a.scale;const y=a.imageName?f.advance*a.scale:24*a.scale,J=String.fromCharCode(a.glyph);jD(J)?b.x+=(1-d)*a.scale:jE(J)?b.x+=y-f.height*a.scale+(-d-1)*a.scale:b.x+=a.imageName||f.width+2*d===i.w&&f.height+2*d===i.h?(y-o)/2:(y-(f.height+2*d)*a.scale)/2,p=new aF(b.x,b.y-x),q=new aF(b.x+o,b.y),r=new aF(b.x+o,b.y-x)}else{const z=(f.left-d)*a.scale-e+j[0],A=(-f.top-d)*a.scale+j[1],K=z+x,L=A+o;b=new aF(z,A),p=new aF(K,A),q=new aF(z,L),r=new aF(K,L)}if(h){let k;k=l?new aF(0,0):H?new aF(m[0],m[1]):new aF(g[0],g[1]),b._rotateAround(h,k),p._rotateAround(h,k),q._rotateAround(h,k),r._rotateAround(h,k)}const X=new aF(0,0),Y=new aF(0,0);s.push({tl:b,tr:p,bl:q,br:r,tex:S,writingMode:c.writingMode,glyphOffset:T,sectionIndex:a.sectionIndex,isSDF:E,pixelOffsetTL:X,pixelOffsetBR:Y,minFontScaleX:0,minFontScaleY:0})}}return s}(0,n,g,e,f,b,o,a.allowVerticalPlacement),k=a.textSizeData;let d=null;for(const u of("source"===k.kind?(d=[128*e.layout.get("text-size").evaluate(b,{},c),])[0]>kw&&bY(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`):"composite"===k.kind&&((d=[128*i.compositeTextSizes[0].evaluate(b,{},c),128*i.compositeTextSizes[1].evaluate(b,{},c),])[0]>kw||d[1]>kw)&&bY(`${a.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`),a.addSymbols(a.text,j,d,g,f,b,p,l,m,h.lineStartIndex,h.lineLength,s,t,c),q))r[u]=a.text.placedSymbolArray.length-1;return 4*j.length}function ky(a){for(const b in a)return a[b];return null}function kz(o,m,p,r,s,t,a,u,q,n){let b=a.top,c=a.bottom,d=a.left,e=a.right;const f=a.collisionPadding;if(f&&(d-=f[0],b-=f[1],e+=f[2],c+=f[3]),q){const g=new aF(d,b),h=new aF(e,b),i=new aF(d,c),j=new aF(e,c),l=q*aP;let k=new aF(0,0);n&&(k=new aF(n[0],n[1])),g._rotateAround(l,k),h._rotateAround(l,k),i._rotateAround(l,k),j._rotateAround(l,k),d=Math.min(g.x,h.x,i.x,j.x),e=Math.max(g.x,h.x,i.x,j.x),b=Math.min(g.y,h.y,i.y,j.y),c=Math.max(g.y,h.y,i.y,j.y)}return o.emplaceBack(m.x,m.y,m.z,p.x,p.y,d,b,e,c,u,r,s,t),o.length-1}function kA(a){a.collisionPadding&&(a.top-=a.collisionPadding[1],a.bottom+=a.collisionPadding[3]);const b=a.bottom-a.top;return b>0?Math.max(10,b):null}function kB(f,a,g,d){const b=f.compareText;if(a in b){const e=b[a];for(let c=e.length-1;c>=0;c--)if(d.dist(e[c])<g)return!0}else b[a]=[];return b[a].push(d),!1}const kC=_.VectorTileFeature.types,kD=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0},];function kE(b,c,d,e,f,g,h,i,j,k,a,l,m,n,o,p){const q=a?Math.min(kw,Math.round(a[0])):0,r=a?Math.min(kw,Math.round(a[1])):0;b.emplaceBack(c,d,Math.round(32*h),Math.round(32*i),j,k,(q<<1)+(l?1:0),r,16*m,16*n,256*o,256*p,e,f,g,0)}function bk(b,a,c){b.emplaceBack(a.x,a.y,c),b.emplaceBack(a.x,a.y,c),b.emplaceBack(a.x,a.y,c),b.emplaceBack(a.x,a.y,c)}function kF(a){for(const b of a.sections)if(hz(b.text))return!0;return!1}class ec{constructor(a){this.layoutVertexArray=new a7,this.indexArray=new aq,this.programConfigurations=a,this.segments=new ay,this.dynamicLayoutVertexArray=new an,this.opacityVertexArray=new a8,this.placedSymbolArray=new da}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(a,c,b,d){this.isEmpty()||(b&&(this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,jw.members),this.indexBuffer=a.createIndexBuffer(this.indexArray,c),this.dynamicLayoutVertexBuffer=a.createVertexBuffer(this.dynamicLayoutVertexArray,jx.members,!0),this.opacityVertexBuffer=a.createVertexBuffer(this.opacityVertexArray,kD,!0),this.opacityVertexBuffer.itemSize=1),(b||d)&&this.programConfigurations.upload(a))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}c("SymbolBuffers",ec);class ed{constructor(a,b,c){this.layoutVertexArray=new a,this.layoutAttributes=b,this.indexArray=new c,this.segments=new ay,this.collisionVertexArray=new ba,this.collisionVertexArrayExt=new an}upload(a){this.layoutVertexBuffer=a.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=a.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=a.createVertexBuffer(this.collisionVertexArray,jy.members,!0),this.collisionVertexBufferExt=a.createVertexBuffer(this.collisionVertexArrayExt,jz.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}c("CollisionBuffers",ed);class aB{constructor(a){this.collisionBoxArray=a.collisionBoxArray,this.zoom=a.zoom,this.overscaling=a.overscaling,this.layers=a.layers,this.layerIds=this.layers.map(a=>a.id),this.index=a.index,this.pixelRatio=a.pixelRatio,this.sourceLayerIndex=a.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=aI([]),this.placementViewportMatrix=aI([]);const d=this.layers[0]._unevaluatedLayout._values;this.textSizeData=d0(this.zoom,d["text-size"]),this.iconSizeData=d0(this.zoom,d["icon-size"]);const b=this.layers[0].layout,e=b.get("symbol-sort-key"),c=b.get("symbol-z-order");this.canOverlap=b.get("text-allow-overlap")||b.get("icon-allow-overlap")||b.get("text-ignore-placement")||b.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==c&& void 0!==e.constantOr(1),this.sortFeaturesByY=("viewport-y"===c||"auto"===c&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=b.get("text-writing-mode").map(a=>d5[a]),this.stateDependentLayerIds=this.layers.filter(a=>a.isStateDependent()).map(a=>a.id),this.sourceID=a.sourceID}createArrays(){this.text=new ec(new dv(this.layers,this.zoom,a=>/^text/.test(a))),this.icon=new ec(new dv(this.layers,this.zoom,a=>/^icon/.test(a))),this.glyphOffsetArray=new dd,this.lineVertexArray=new de,this.symbolInstances=new dc}calculateGlyphDependencies(b,c,g,e,f){for(let a=0;a<b.length;a++)if(c[b.charCodeAt(a)]=!0,e&&f){const d=jC[b.charAt(a)];d&&(c[d.charCodeAt(0)]=!0)}}populate(v,j,c,w){const d=this.layers[0],b=d.layout,k=b.get("text-font"),g=b.get("text-field"),l=b.get("icon-image"),n=("constant"!==g.value.kind||g.value.value instanceof fB&&!g.value.value.isEmpty()||g.value.value.toString().length>0)&&("constant"!==k.value.kind||k.value.value.length>0),o="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,x=b.get("symbol-sort-key");if(this.features=[],!n&&!o)return;const p=j.iconDependencies,q=j.glyphDependencies,r=j.availableImages,y=new c5(this.zoom);for(const{feature:h,id:z,index:A,sourceLayerIndex:B}of v){const s=d._featureFilter.needGeometry,a=id(h,s);if(!d._featureFilter.filter(y,a,c))continue;let e,f;if(s||(a.geometry=ic(h,c,w)),n){const C=d.getValueAndResolveTokens("text-field",a,c,r),t=fB.factory(C);kF(t)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===c3()||this.hasRTLText&&c4.isParsed())&&(e=jB(t,d,a))}if(o){const m=d.getValueAndResolveTokens("icon-image",a,c,r);f=m instanceof cj?m:cj.fromString(m)}if(!e&&!f)continue;const D=this.sortFeaturesByKey?x.evaluate(a,{},c):void 0;if(this.features.push({id:z,text:e,icon:f,index:A,sourceLayerIndex:B,geometry:a.geometry,properties:h.properties,type:kC[h.type],sortKey:D}),f&&(p[f.name]=!0),e){const E=k.evaluate(a,{},c).join(","),F="map"===b.get("text-rotation-alignment")&&"point"!==b.get("symbol-placement");for(const i of(this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(d5.vertical)>=0,e.sections))if(i.image)p[i.image.name]=!0;else{const G=hs(e.toString()),u=i.fontStack||E,H=q[u]=q[u]||{};this.calculateGlyphDependencies(i.text,H,F,this.allowVerticalPlacement,G)}}}"line"===b.get("symbol-placement")&&(this.features=function(k){const d={},c={},g=[];let l=0;function m(a){g.push(k[a]),l++}function n(b,d,e){const a=c[b];return delete c[b],c[d]=a,g[a].geometry[0].pop(),g[a].geometry[0]=g[a].geometry[0].concat(e[0]),a}function o(c,b,e){const a=d[b];return delete d[b],d[c]=a,g[a].geometry[0].shift(),g[a].geometry[0]=e[0].concat(g[a].geometry[0]),a}function i(c,a,d){const b=d?a[0][a[0].length-1]:a[0][0];return`${c}:${b.x}:${b.y}`}for(let e=0;e<k.length;e++){const j=k[e],f=j.geometry,h=j.text?j.text.toString():null;if(!h){m(e);continue}const a=i(h,f),b=i(h,f,!0);if(a in c&&b in d&&c[a]!==d[b]){const p=o(a,b,f),q=n(a,b,g[p].geometry);delete d[a],delete c[b],c[i(h,g[q].geometry,!0)]=q,g[p].geometry=null}else a in c?n(a,b,f):b in d?o(a,b,f):(m(e),d[a]=l-1,c[b]=l-1)}return g.filter(a=>a.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((a,b)=>a.sortKey-b.sortKey)}update(a,b,c,d){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(a,b,this.layers,c,d),this.icon.programConfigurations.updatePaintArrays(a,b,this.layers,c,d))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(a){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(a),this.iconCollisionBox.upload(a)),this.text.upload(a,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(a,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(d,a){const h=this.lineVertexArray.length;if(void 0!==d.segment){let i=d.dist(a[d.segment+1]),j=d.dist(a[d.segment]);const e={};for(let b=d.segment+1;b<a.length;b++)e[b]={x:a[b].x,y:a[b].y,tileUnitDistanceFromAnchor:i},b<a.length-1&&(i+=a[b+1].dist(a[b]));for(let c=d.segment||0;c>=0;c--)e[c]={x:a[c].x,y:a[c].y,tileUnitDistanceFromAnchor:j},c>0&&(j+=a[c-1].dist(a[c]));for(let f=0;f<a.length;f++){const g=e[f];this.lineVertexArray.emplaceBack(g.x,g.y,g.tileUnitDistanceFromAnchor)}}return{lineStartIndex:h,lineLength:this.lineVertexArray.length-h}}addSymbols(e,h,d,s,J,i,t,a,c,C,D,E,F,G){const r=e.indexArray,f=e.layoutVertexArray,k=e.segments.prepareSegment(4*h.length,f,r,this.canOverlap?i.sortKey:void 0),u=this.glyphOffsetArray.length,H=k.vertexLength,I=this.allowVerticalPlacement&&t===d5.vertical?Math.PI/2:0,v=i.text&&i.text.sections;for(let j=0;j<h.length;j++){const{tl:w,tr:x,bl:y,br:z,tex:b,pixelOffsetTL:l,pixelOffsetBR:m,minFontScaleX:n,minFontScaleY:o,glyphOffset:A,isSDF:p,sectionIndex:B}=h[j],g=k.vertexLength,q=A[1];kE(f,a.x,a.y,a.z,c.x,c.y,w.x,q+w.y,b.x,b.y,d,p,l.x,l.y,n,o),kE(f,a.x,a.y,a.z,c.x,c.y,x.x,q+x.y,b.x+b.w,b.y,d,p,m.x,l.y,n,o),kE(f,a.x,a.y,a.z,c.x,c.y,y.x,q+y.y,b.x,b.y+b.h,d,p,l.x,m.y,n,o),kE(f,a.x,a.y,a.z,c.x,c.y,z.x,q+z.y,b.x+b.w,b.y+b.h,d,p,m.x,m.y,n,o),bk(e.dynamicLayoutVertexArray,a,I),r.emplaceBack(g,g+1,g+2),r.emplaceBack(g+1,g+2,g+3),k.vertexLength+=4,k.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(A[0]),j!==h.length-1&&B===h[j+1].sectionIndex||e.programConfigurations.populatePaintArrays(f.length,i,i.index,{},F,G,v&&v[B])}e.placedSymbolArray.emplaceBack(a.x,a.y,a.z,c.x,c.y,u,this.glyphOffsetArray.length-u,H,C,D,c.segment,d?d[0]:0,d?d[1]:0,s[0],s[1],t,0,!1,0,E,0)}_commitLayoutVertex(b,c,d,e,f,g,a){b.emplaceBack(c,d,e,f,g,Math.round(a.x),Math.round(a.y))}_addCollisionDebugVertices(a,d,b,e,f,g,l){const k=b.segments.prepareSegment(4,b.layoutVertexArray,b.indexArray),c=k.vertexLength,h=l.tileAnchorX,i=l.tileAnchorY;for(let m=0;m<4;m++)b.collisionVertexArray.emplaceBack(0,0,0,0);b.collisionVertexArrayExt.emplaceBack(d,-a.padding,-a.padding),b.collisionVertexArrayExt.emplaceBack(d,a.padding,-a.padding),b.collisionVertexArrayExt.emplaceBack(d,a.padding,a.padding),b.collisionVertexArrayExt.emplaceBack(d,-a.padding,a.padding),this._commitLayoutVertex(b.layoutVertexArray,e,f,g,h,i,new aF(a.x1,a.y1)),this._commitLayoutVertex(b.layoutVertexArray,e,f,g,h,i,new aF(a.x2,a.y1)),this._commitLayoutVertex(b.layoutVertexArray,e,f,g,h,i,new aF(a.x2,a.y2)),this._commitLayoutVertex(b.layoutVertexArray,e,f,g,h,i,new aF(a.x1,a.y2)),k.vertexLength+=4;const j=b.indexArray;j.emplaceBack(c,c+1),j.emplaceBack(c+1,c+2),j.emplaceBack(c+2,c+3),j.emplaceBack(c+3,c),k.primitiveLength+=4}_addTextDebugCollisionBoxes(d,e,f,g,h,c){for(let a=g;a<h;a++){const b=f.get(a),i=this.getSymbolInstanceTextSize(d,c,e,a);this._addCollisionDebugVertices(b,i,this.textCollisionBox,b.projectedAnchorX,b.projectedAnchorY,b.projectedAnchorZ,c)}}_addIconDebugCollisionBoxes(c,d,e,f,g,h){for(let a=f;a<g;a++){const b=e.get(a),i=this.getSymbolInstanceIconSize(c,d,a);this._addCollisionDebugVertices(b,i,this.iconCollisionBox,b.projectedAnchorX,b.projectedAnchorY,b.projectedAnchorZ,h)}}generateCollisionDebugBuffers(b,c){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new ed(a9,jA.members,Y),this.iconCollisionBox=new ed(a9,jA.members,Y);const e=bi(this.iconSizeData,b),f=bi(this.textSizeData,b);for(let d=0;d<this.symbolInstances.length;d++){const a=this.symbolInstances.get(d);this._addTextDebugCollisionBoxes(f,b,c,a.textBoxStartIndex,a.textBoxEndIndex,a),this._addTextDebugCollisionBoxes(f,b,c,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a),this._addIconDebugCollisionBoxes(e,b,c,a.iconBoxStartIndex,a.iconBoxEndIndex,a),this._addIconDebugCollisionBoxes(e,b,c,a.verticalIconBoxStartIndex,a.verticalIconBoxEndIndex,a)}}getSymbolInstanceTextSize(b,a,f,c){const d=this.text.placedSymbolArray.get(a.rightJustifiedTextSymbolIndex>=0?a.rightJustifiedTextSymbolIndex:a.centerJustifiedTextSymbolIndex>=0?a.centerJustifiedTextSymbolIndex:a.leftJustifiedTextSymbolIndex>=0?a.leftJustifiedTextSymbolIndex:a.verticalPlacedTextSymbolIndex>=0?a.verticalPlacedTextSymbolIndex:c),e=bh(this.textSizeData,b,d)/24;return this.tilePixelRatio*e}getSymbolInstanceIconSize(a,e,b){const c=this.icon.placedSymbolArray.get(b),d=bh(this.iconSizeData,a,c);return this.tilePixelRatio*d}_commitDebugCollisionVertexUpdate(b,c,a){b.emplaceBack(c,-a,-a),b.emplaceBack(c,a,-a),b.emplaceBack(c,a,a),b.emplaceBack(c,-a,a)}_updateTextDebugCollisionBoxes(b,c,d,e,f,g){for(let a=e;a<f;a++){const h=d.get(a),i=this.getSymbolInstanceTextSize(b,g,c,a);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,i,h.padding)}}_updateIconDebugCollisionBoxes(b,c,d,e,f){for(let a=e;a<f;a++){const g=d.get(a),h=this.getSymbolInstanceIconSize(b,c,a);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,h,g.padding)}}updateCollisionDebugBuffers(b,c){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const e=bi(this.iconSizeData,b),f=bi(this.textSizeData,b);for(let d=0;d<this.symbolInstances.length;d++){const a=this.symbolInstances.get(d);this._updateTextDebugCollisionBoxes(f,b,c,a.textBoxStartIndex,a.textBoxEndIndex,a),this._updateTextDebugCollisionBoxes(f,b,c,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a),this._updateIconDebugCollisionBoxes(e,b,c,a.iconBoxStartIndex,a.iconBoxEndIndex),this._updateIconDebugCollisionBoxes(e,b,c,a.verticalIconBoxStartIndex,a.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(f,k,l,m,n,o,p,q,r){const e={};for(let g=k;g<l;g++){const a=f.get(g);e.textBox={x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2,padding:a.padding,projectedAnchorX:a.projectedAnchorX,projectedAnchorY:a.projectedAnchorY,projectedAnchorZ:a.projectedAnchorZ,tileAnchorX:a.tileAnchorX,tileAnchorY:a.tileAnchorY},e.textFeatureIndex=a.featureIndex;break}for(let h=m;h<n;h++){const b=f.get(h);e.verticalTextBox={x1:b.x1,y1:b.y1,x2:b.x2,y2:b.y2,padding:b.padding,projectedAnchorX:b.projectedAnchorX,projectedAnchorY:b.projectedAnchorY,projectedAnchorZ:b.projectedAnchorZ,tileAnchorX:b.tileAnchorX,tileAnchorY:b.tileAnchorY},e.verticalTextFeatureIndex=b.featureIndex;break}for(let i=o;i<p;i++){const c=f.get(i);e.iconBox={x1:c.x1,y1:c.y1,x2:c.x2,y2:c.y2,padding:c.padding,projectedAnchorX:c.projectedAnchorX,projectedAnchorY:c.projectedAnchorY,projectedAnchorZ:c.projectedAnchorZ,tileAnchorX:c.tileAnchorX,tileAnchorY:c.tileAnchorY},e.iconFeatureIndex=c.featureIndex;break}for(let j=q;j<r;j++){const d=f.get(j);e.verticalIconBox={x1:d.x1,y1:d.y1,x2:d.x2,y2:d.y2,padding:d.padding,projectedAnchorX:d.projectedAnchorX,projectedAnchorY:d.projectedAnchorY,projectedAnchorZ:d.projectedAnchorZ,tileAnchorX:d.tileAnchorX,tileAnchorY:d.tileAnchorY},e.verticalIconFeatureIndex=d.featureIndex;break}return e}deserializeCollisionBoxes(c){this.collisionArrays=[];for(let b=0;b<this.symbolInstances.length;b++){const a=this.symbolInstances.get(b);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(c,a.textBoxStartIndex,a.textBoxEndIndex,a.verticalTextBoxStartIndex,a.verticalTextBoxEndIndex,a.iconBoxStartIndex,a.iconBoxEndIndex,a.verticalIconBoxStartIndex,a.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(b,d){const c=b.placedSymbolArray.get(d),e=c.vertexStartIndex+4*c.numGlyphs;for(let a=c.vertexStartIndex;a<e;a+=4)b.indexArray.emplaceBack(a,a+1,a+2),b.indexArray.emplaceBack(a+1,a+2,a+3)}getSortedSymbolIndexes(b){if(this.sortedAngle===b&& void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(b),f=Math.cos(b),g=[],h=[],c=[];for(let a=0;a<this.symbolInstances.length;++a){c.push(a);const d=this.symbolInstances.get(a);g.push(0|Math.round(e*d.tileAnchorX+f*d.tileAnchorY)),h.push(d.featureIndex)}return c.sort((a,b)=>g[a]-g[b]||h[b]-h[a]),c}addToSortKeyRanges(a,c){const b=this.sortKeyRanges[this.sortKeyRanges.length-1];b&&b.sortKey===c?b.symbolInstanceEnd=a+1:this.sortKeyRanges.push({sortKey:c,symbolInstanceStart:a,symbolInstanceEnd:a+1})}sortFeatures(b){if(this.sortFeaturesByY&&this.sortedAngle!==b&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){for(const c of(this.symbolInstanceIndexes=this.getSortedSymbolIndexes(b),this.sortedAngle=b,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[],this.symbolInstanceIndexes)){const a=this.symbolInstances.get(c);this.featureSortOrder.push(a.featureIndex),[a.rightJustifiedTextSymbolIndex,a.centerJustifiedTextSymbolIndex,a.leftJustifiedTextSymbolIndex,].forEach((a,b,c)=>{a>=0&&c.indexOf(a)===b&&this.addIndicesForPlacedSymbol(this.text,a)}),a.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,a.verticalPlacedTextSymbolIndex),a.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.placedIconSymbolIndex),a.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,a.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}c("SymbolBucket",aB,{omit:["layers","collisionBoxArray","features","compareText",]}),aB.MAX_GLYPHS=65535,aB.addDynamicAttributes=bk;const ee=new n({"symbol-placement":new e(b.layout_symbol["symbol-placement"]),"symbol-spacing":new e(b.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new e(b.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new g(b.layout_symbol["symbol-sort-key"]),"symbol-z-order":new e(b.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new e(b.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new e(b.layout_symbol["icon-ignore-placement"]),"icon-optional":new e(b.layout_symbol["icon-optional"]),"icon-rotation-alignment":new e(b.layout_symbol["icon-rotation-alignment"]),"icon-size":new g(b.layout_symbol["icon-size"]),"icon-text-fit":new e(b.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new e(b.layout_symbol["icon-text-fit-padding"]),"icon-image":new g(b.layout_symbol["icon-image"]),"icon-rotate":new g(b.layout_symbol["icon-rotate"]),"icon-padding":new e(b.layout_symbol["icon-padding"]),"icon-keep-upright":new e(b.layout_symbol["icon-keep-upright"]),"icon-offset":new g(b.layout_symbol["icon-offset"]),"icon-anchor":new g(b.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new e(b.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new e(b.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new e(b.layout_symbol["text-rotation-alignment"]),"text-field":new g(b.layout_symbol["text-field"]),"text-font":new g(b.layout_symbol["text-font"]),"text-size":new g(b.layout_symbol["text-size"]),"text-max-width":new g(b.layout_symbol["text-max-width"]),"text-line-height":new g(b.layout_symbol["text-line-height"]),"text-letter-spacing":new g(b.layout_symbol["text-letter-spacing"]),"text-justify":new g(b.layout_symbol["text-justify"]),"text-radial-offset":new g(b.layout_symbol["text-radial-offset"]),"text-variable-anchor":new e(b.layout_symbol["text-variable-anchor"]),"text-anchor":new g(b.layout_symbol["text-anchor"]),"text-max-angle":new e(b.layout_symbol["text-max-angle"]),"text-writing-mode":new e(b.layout_symbol["text-writing-mode"]),"text-rotate":new g(b.layout_symbol["text-rotate"]),"text-padding":new e(b.layout_symbol["text-padding"]),"text-keep-upright":new e(b.layout_symbol["text-keep-upright"]),"text-transform":new g(b.layout_symbol["text-transform"]),"text-offset":new g(b.layout_symbol["text-offset"]),"text-allow-overlap":new e(b.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new e(b.layout_symbol["text-ignore-placement"]),"text-optional":new e(b.layout_symbol["text-optional"])});var kG={paint:new n({"icon-opacity":new g(b.paint_symbol["icon-opacity"]),"icon-color":new g(b.paint_symbol["icon-color"]),"icon-halo-color":new g(b.paint_symbol["icon-halo-color"]),"icon-halo-width":new g(b.paint_symbol["icon-halo-width"]),"icon-halo-blur":new g(b.paint_symbol["icon-halo-blur"]),"icon-translate":new e(b.paint_symbol["icon-translate"]),"icon-translate-anchor":new e(b.paint_symbol["icon-translate-anchor"]),"text-opacity":new g(b.paint_symbol["text-opacity"]),"text-color":new g(b.paint_symbol["text-color"],{runtimeType:y,getOverride:a=>a.textColor,hasOverride:a=>!!a.textColor}),"text-halo-color":new g(b.paint_symbol["text-halo-color"]),"text-halo-width":new g(b.paint_symbol["text-halo-width"]),"text-halo-blur":new g(b.paint_symbol["text-halo-blur"]),"text-translate":new e(b.paint_symbol["text-translate"]),"text-translate-anchor":new e(b.paint_symbol["text-translate-anchor"])}),layout:ee};class ef{constructor(a){this.type=a.property.overrides?a.property.overrides.runtimeType:cf,this.defaultValue=a}evaluate(a){if(a.formattedSection){const b=this.defaultValue.property.overrides;if(b&&b.hasOverride(a.formattedSection))return b.getOverride(a.formattedSection)}return a.feature&&a.featureState?this.defaultValue.evaluate(a.feature,a.featureState):this.defaultValue.property.specification.default}eachChild(a){this.defaultValue.isConstant()||a(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}c("FormatSectionOverride",ef,{omit:["defaultValue"]});class eg extends be{constructor(a){super(a,kG)}recalculate(d,e){super.recalculate(d,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const b=this.layout.get("text-writing-mode");if(b){const a=[];for(const c of b)0>a.indexOf(c)&&a.push(c);this.layout._values["text-writing-mode"]=a}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(b,c,e,f){var g;const a=this.layout.get(b).evaluate(c,{},e,f),d=this._unevaluatedLayout._values[b];return d.isDataDriven()||gv(d.value)||!a?a:(g=c.properties,a.replace(/{([^{}]+)}/g,(b,a)=>a in g?String(g[a]):""))}createBucket(a){return new aB(a)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const b of kG.paint.overridableProperties){if(!eg.hasPaintOverride(this.layout,b))continue;const a=this.paint.get(b),e=new ef(a),c=new cM(e,a.property.specification);let d=null;d="constant"===a.value.kind||"source"===a.value.kind?new cO("source",c):new cP("composite",c,a.value.zoomStops,a.value._interpolationType),this.paint._values[b]=new hM(a.property,d,a.parameters)}}_handleOverridablePaintPropertyUpdate(a,b,c){return!(!this.layout||b.isDataDriven()||c.isDataDriven())&&eg.hasPaintOverride(this.layout,a)}static hasPaintOverride(c,d){const a=c.get("text-field"),h=kG.paint.properties[d];let e=!1;const f=a=>{for(const b of a)if(h.overrides&&h.overrides.hasOverride(b))return void(e=!0)};if("constant"===a.value.kind&&a.value.value instanceof fB)f(a.value.value.sections);else if("source"===a.value.kind){const g=a=>{e||(a instanceof ck&&fE(a.value)===ch?f(a.value.sections):a instanceof cl?f(a.sections):a.eachChild(g))},b=a.value;b._styleExpression&&g(b._styleExpression.expression)}return e}getProgramConfiguration(a){return new du(this,a)}}var kH={paint:new n({"background-color":new e(b.paint_background["background-color"]),"background-pattern":new a5(b.paint_background["background-pattern"]),"background-opacity":new e(b.paint_background["background-opacity"])})},kI={paint:new n({"raster-opacity":new e(b.paint_raster["raster-opacity"]),"raster-hue-rotate":new e(b.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new e(b.paint_raster["raster-brightness-min"]),"raster-brightness-max":new e(b.paint_raster["raster-brightness-max"]),"raster-saturation":new e(b.paint_raster["raster-saturation"]),"raster-contrast":new e(b.paint_raster["raster-contrast"]),"raster-resampling":new e(b.paint_raster["raster-resampling"]),"raster-fade-duration":new e(b.paint_raster["raster-fade-duration"])})};class kJ extends be{constructor(a){super(a,{}),this.implementation=a}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){}serialize(){}onAdd(a){this.implementation.onAdd&&this.implementation.onAdd(a,a.painter.context.gl)}onRemove(a){this.implementation.onRemove&&this.implementation.onRemove(a,a.painter.context.gl)}}var kK={paint:new n({"sky-type":new e(b.paint_sky["sky-type"]),"sky-atmosphere-sun":new e(b.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new e(b.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new e(b.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new e(b.paint_sky["sky-gradient-radius"]),"sky-gradient":new V(b.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new e(b.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new e(b.paint_sky["sky-atmosphere-color"]),"sky-opacity":new e(b.paint_sky["sky-opacity"])})};function kL(l,m,n){var a,b,f,h,i,j,k,c,d;const g=Q(0,0,1),e=bG(aO());return a=e,b=e,f=n?-(l*aP)+Math.PI:l*aP,f*=.5,h=b[0],i=b[1],j=b[2],k=b[3],c=Math.sin(f),d=Math.cos(f),a[0]=h*d-j*c,a[1]=i*d+k*c,a[2]=j*d+h*c,a[3]=k*d-i*c,bH(e,e,-(m*aP)),bD(g,g,e),bz(g,g)}const kM={circle:class extends be{constructor(a){super(a,iv)}createBucket(a){return new bf(a)}queryRadius(b){const a=b;return ir("circle-radius",this,a)+ir("circle-stroke-width",this,a)+is(this.paint.get("circle-translate"))}queryIntersectsFeature(a,b,c,e,j,d,f,g){const h=iu(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),d.angle,a.pixelToTileUnitsFactor),i=this.paint.get("circle-radius").evaluate(b,c)+this.paint.get("circle-stroke-width").evaluate(b,c);return iw(a,e,d,f,g,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),h,i)}getProgramIds(){return["circle"]}getProgramConfiguration(a){return new du(this,a)}},heatmap:class extends be{createBucket(a){return new dI(a)}constructor(a){super(a,iE),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"heatmap-color"===a&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=dK({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(a){return ir("heatmap-radius",this,a)}queryIntersectsFeature(a,b,c,d,i,e,f,g){const h=this.paint.get("heatmap-radius").evaluate(b,c);return iw(a,d,e,f,g,!0,!0,new aF(0,0),h)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(a){return new du(this,a)}},hillshade:class extends be{constructor(a){super(a,iF)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare",]}getProgramConfiguration(a){return new du(this,a)}},fill:class extends be{constructor(a){super(a,jc)}getProgramIds(){const a=this.paint.get("fill-pattern"),b=a&&a.constantOr(1),c=[b?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&c.push(b&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),c}getProgramConfiguration(a){return new du(this,a)}recalculate(b,c){super.recalculate(b,c);const a=this.paint._values["fill-outline-color"];"constant"===a.value.kind&& void 0===a.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(a){return new dN(a)}queryRadius(){return is(this.paint.get("fill-translate"))}queryIntersectsFeature(a,d,e,b,f,c){return!a.queryGeometry.isAboveHorizon&&ih(it(a.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),c.angle,a.pixelToTileUnitsFactor),b)}isTileClipped(){return!0}},"fill-extrusion":class extends be{constructor(a){super(a,jm)}createBucket(a){return new dU(a)}queryRadius(){return is(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion",]}getProgramConfiguration(a){return new du(this,a)}queryIntersectsFeature(c,k,l,v,C,a,w,m,x){var d,e,f,g,h,i,n,o,p;const y=iu(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,c.pixelToTileUnitsFactor),z=this.paint.get("fill-extrusion-height").evaluate(k,l),A=this.paint.get("fill-extrusion-base").evaluate(k,l),b=[0,0],q=m&&a.elevation,B=a.elevation?a.elevation.exaggeration():1;if(q){const r=c.tile.getBucket(this).centroidVertexArray,s=x+1;if(s<r.length){const t=r.get(s);b[0]=t.a_centroid_pos0,b[1]=t.a_centroid_pos1}}if(0===b[0]&&1===b[1])return!1;const u=(d=v,e=A,f=z,g=y,h=w,i=q?m:null,n=b,o=B,p=a.center.lat,i?function(l,m,n,d,e,o,p,q,r){const f=[],g=[],a=[0,0,0,1];for(const s of l){const h=[],i=[];for(const j of s){const b=j.x+d.x,c=j.y+d.y,k=jq(b,c,m,n,o,p,q,r);a[0]=b,a[1]=c,a[2]=k.base,a[3]=1,bF(a,a,e),a[3]=Math.max(a[3],1e-5);const t=jp([a[0]/a[3],a[1]/a[3],a[2]/a[3],]);a[0]=b,a[1]=c,a[2]=k.top,a[3]=1,bF(a,a,e),a[3]=Math.max(a[3],1e-5);const u=jp([a[0]/a[3],a[1]/a[3],a[2]/a[3],]);h.push(t),i.push(u)}f.push(h),g.push(i)}return[f,g]}(d,e,f,g,h,i,n,o,p):function(t,b,c,h,a){const i=[],j=[],u=a[8]*b,v=a[9]*b,w=a[10]*b,x=a[11]*b,y=a[8]*c,z=a[9]*c,A=a[10]*c,B=a[11]*c;for(const C of t){const k=[],l=[];for(const m of C){const d=m.x+h.x,e=m.y+h.y,n=a[0]*d+a[4]*e+a[12],o=a[1]*d+a[5]*e+a[13],p=a[2]*d+a[6]*e+a[14],q=a[3]*d+a[7]*e+a[15],D=n+u,E=o+v,F=p+w,f=Math.max(q+x,1e-5),G=n+y,H=o+z,I=p+A,g=Math.max(q+B,1e-5),r=new aF(D/f,E/f);r.z=F/f,k.push(r);const s=new aF(G/g,H/g);s.z=I/g,l.push(s)}i.push(k),j.push(l)}return[i,j]}(d,e,f,g,h)),j=c.queryGeometry;return function(j,c,d){let b=1/0;ih(d,c)&&(b=jo(d,c[0]));for(let e=0;e<c.length;e++){const f=c[e],g=j[e];for(let a=0;a<f.length-1;a++){const h=f[a],i=[h,f[a+1],g[a+1],g[a],h,];dE(d,i)&&(b=Math.min(b,jo(d,i)))}}return b!==1/0&&b}(u[0],u[1],j.isPointQuery()?j.screenBounds:j.screenGeometry)}},line:class extends be{constructor(a){super(a,dZ),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(b){if("line-gradient"===b){const a=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=a._styleExpression&&a._styleExpression.expression instanceof cq,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(a,b){super.recalculate(a,b),this.paint._values["line-floorwidth"]=d$.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,a)}createBucket(a){return new dX(a)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line",]}getProgramConfiguration(a){return new du(this,a)}queryRadius(b){const a=b,c=jv(ir("line-width",this,a),ir("line-gap-width",this,a)),d=ir("line-offset",this,a);return c/2+Math.abs(d)+is(this.paint.get("line-translate"))}queryIntersectsFeature(a,b,c,d,i,f){if(a.queryGeometry.isAboveHorizon)return!1;const g=it(a.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),f.angle,a.pixelToTileUnitsFactor),h=a.pixelToTileUnitsFactor/2*jv(this.paint.get("line-width").evaluate(b,c),this.paint.get("line-gap-width").evaluate(b,c)),e=this.paint.get("line-offset").evaluate(b,c);return e&&(d=function(g,k){const h=[],i=new aF(0,0);for(let d=0;d<g.length;d++){const b=g[d],j=[];for(let a=0;a<b.length;a++){const l=b[a-1],e=b[a],m=b[a+1],n=0===a?i:e.sub(l)._unit()._perp(),f=a===b.length-1?i:m.sub(e)._unit()._perp(),c=n._add(f)._unit();c._mult(1/(c.x*f.x+c.y*f.y)),j.push(c._mult(k)._add(e))}h.push(j)}return h}(d,e*a.pixelToTileUnitsFactor)),function(a,e,f){for(let b=0;b<e.length;b++){const c=e[b];if(a.length>=3){for(let d=0;d<c.length;d++)if(ip(a,c[d]))return!0}if(ii(a,c,f))return!0}return!1}(g,d,h)}isTileClipped(){return!0}},symbol:eg,background:class extends be{constructor(a){super(a,kH)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background",]}},raster:class extends be{constructor(a){super(a,kI)}getProgramIds(){return["raster"]}},sky:class extends be{constructor(a){super(a,kK),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(a){"sky-gradient"===a?this._updateColorRamp():"sky-atmosphere-sun"!==a&&"sky-atmosphere-halo-color"!==a&&"sky-atmosphere-color"!==a&&"sky-atmosphere-sun-intensity"!==a||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=dK({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(b){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const a=b.style.light.properties.get("position");return this._lightPosition.azimuthal!==a.azimuthal||this._lightPosition.polar!==a.polar}}getCenter(h,a){const c=this.paint.get("sky-type");if("atmosphere"===c){const b=this.paint.get("sky-atmosphere-sun"),d=!b,e=h.style.light,f=e.properties.get("position");return d&&"viewport"===e.properties.get("anchor")&&bY("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),d?kL(f.azimuthal,90-f.polar,a):kL(b[0],90-b[1],a)}if("gradient"===c){const g=this.paint.get("sky-gradient-center");return kL(g[0],90-g[1],a)}}is3D(){return!1}isSky(){return!0}markSkyboxValid(a){this._skyboxInvalidated=!1,this._lightPosition=a.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const a=this.paint.get("sky-type");return"atmosphere"===a?["skyboxCapture","skybox"]:"gradient"===a?["skyboxGradient"]:null}}},{HTMLImageElement:kN,HTMLCanvasElement:kO,HTMLVideoElement:kP,ImageData:kQ,ImageBitmap:kR}=s;class eh{constructor(a,b,c,d){this.context=a,this.format=c,this.texture=a.gl.createTexture(),this.update(b,d)}update(b,c,g){const{width:d,height:e}=b,{context:f}=this,{gl:a}=f;if(a.bindTexture(a.TEXTURE_2D,this.texture),f.pixelStoreUnpackFlipY.set(!1),f.pixelStoreUnpack.set(1),f.pixelStoreUnpackPremultiplyAlpha.set(this.format===a.RGBA&&(!c|| !1!==c.premultiply)),g||this.size&&this.size[0]===d&&this.size[1]===e){const{x:h,y:i}=g||{x:0,y:0};b instanceof kN||b instanceof kO||b instanceof kP||b instanceof kQ||kR&&b instanceof kR?a.texSubImage2D(a.TEXTURE_2D,0,h,i,a.RGBA,a.UNSIGNED_BYTE,b):a.texSubImage2D(a.TEXTURE_2D,0,h,i,d,e,a.RGBA,a.UNSIGNED_BYTE,b.data)}else this.size=[d,e],b instanceof kN||b instanceof kO||b instanceof kP||b instanceof kQ||kR&&b instanceof kR?a.texImage2D(a.TEXTURE_2D,0,this.format,this.format,a.UNSIGNED_BYTE,b):a.texImage2D(a.TEXTURE_2D,0,this.format,d,e,0,this.format,a.UNSIGNED_BYTE,b.data);this.useMipmap=Boolean(c&&c.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&a.generateMipmap(a.TEXTURE_2D)}bind(b,c){const{context:d}=this,{gl:a}=d;a.bindTexture(a.TEXTURE_2D,this.texture),b!==this.filter&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,this.useMipmap?b===a.NEAREST?a.NEAREST_MIPMAP_NEAREST:a.LINEAR_MIPMAP_NEAREST:b),this.filter=b),c!==this.wrap&&(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,c),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,c),this.wrap=c)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:a}=this.context;a.deleteTexture(this.texture),this.texture=null}}class bl{constructor(a,b){this.width=a,this.height=b,this.nextRow=0,this.image=new dJ({width:a,height:b}),this.positions={},this.uploaded=!1}getDash(a,b){const c=this.getKey(a,b);return this.positions[c]}trim(){const a=this.width,b=this.height=bT(this.nextRow);this.image.resize({width:a,height:b})}getKey(a,b){return a.join(",")+b}getDashRanges(a,j,b){const d=[];let e=a.length%2==1?-a[a.length-1]*b:0,f=a[0]*b,c=!0;d.push({left:e,right:f,isDash:c,zeroLength:0===a[0]});let g=a[0];for(let h=1;h<a.length;h++){c=!c;const i=a[h];e=g*b,g+=i,f=g*b,d.push({left:e,right:f,isDash:c,zeroLength:0===i})}return d}addRoundDash(i,l,c){const f=l/2;for(let d=-c;d<=c;d++){const m=this.width*(this.nextRow+c+d);let j=0,b=i[j];for(let a=0;a<this.width;a++){a/b.right>1&&(b=i[++j]);const n=Math.abs(a-b.left),o=Math.abs(a-b.right),e=Math.min(n,o);let g;const h=d/c*(f+1);if(b.isDash){const k=f-Math.abs(h);g=Math.sqrt(e*e+k*k)}else g=f-Math.sqrt(e*e+h*h);this.image.data[m+a]=Math.max(0,Math.min(255,g+128))}}}addRegularDash(a,k){for(let b=a.length-1;b>=0;--b){const e=a[b],f=a[b+1];e.zeroLength?a.splice(b,1):f&&f.isDash===e.isDash&&(f.left=e.left,a.splice(b,1))}const g=a[0],h=a[a.length-1];g.isDash===h.isDash&&(g.left=h.left-this.width,h.right=g.right+this.width);const l=this.width*this.nextRow;let i=0,d=a[i];for(let c=0;c<this.width;c++){c/d.right>1&&(d=a[++i]);const m=Math.abs(c-d.left),n=Math.abs(c-d.right),j=Math.min(m,n);this.image.data[l+c]=Math.max(0,Math.min(255,(d.isDash?j:-j)+k+128))}}addDash(a,e){const f=this.getKey(a,e);if(this.positions[f])return this.positions[f];const h="round"===e,c=h?7:0,i=2*c+1;if(this.nextRow+i>this.height)return bY("LineAtlas out of space"),null;0===a.length&&a.push(1);let d=0;for(let b=0;b<a.length;b++)a[b]<0&&(bY("Negative value is found in line dasharray, replacing values with 0"),a[b]=0),d+=a[b];if(0!==d){const g=this.width/d,j=this.getDashRanges(a,this.width,g);h?this.addRoundDash(j,g,c):this.addRegularDash(j,"square"===e?.5*g:0)}const l=this.nextRow+c;this.nextRow+=i;const k={tl:[l,c],br:[d,0]};return this.positions[f]=k,k}}c("LineAtlas",bl);const kS=s.performance;function ei(a){const b=a?a.url.toString():void 0;return kS.getEntriesByName(b)}function kT(b,c,d){var a=2*Math.PI*6378137/256/Math.pow(2,d);return[b*a-2*Math.PI*6378137/2,c*a-2*Math.PI*6378137/2,]}class bm{constructor(a,b,c){this.z=a,this.x=b,this.y=c,this.key=kU(0,a,a,b,c)}equals(a){return this.z===a.z&&this.x===a.x&&this.y===a.y}url(f,g){var b,a,c,d,e;const h=(b=this.x,a=this.y,d=kT(256*b,256*(a=Math.pow(2,c=this.z)-a-1),c),e=kT(256*(b+1),256*(a+1),c),d[0]+","+d[1]+","+e[0]+","+e[1]),i=function(d,e,f){let b,c="";for(let a=d;a>0;a--)c+=(e&(b=1<<a-1)?1:0)+(f&b?2:0);return c}(this.z,this.x,this.y);return f[(this.x+this.y)%f.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"===g?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",i).replace("{bbox-epsg-3857}",h)}toString(){return`${this.z}/${this.x}/${this.y}`}}class ej{constructor(b,a){this.wrap=b,this.canonical=a,this.key=kU(b,a.z,a.z,a.x,a.y)}}class bn{constructor(a,b,c,d,e){this.overscaledZ=a,this.wrap=b,this.canonical=new bm(c,+d,+e),this.key=0===b&&a===c?this.canonical.key:kU(b,a,c,d,e)}equals(a){return this.overscaledZ===a.overscaledZ&&this.wrap===a.wrap&&this.canonical.equals(a.canonical)}scaledTo(a){const b=this.canonical.z-a;return a>this.canonical.z?new bn(a,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new bn(a,this.wrap,a,this.canonical.x>>b,this.canonical.y>>b)}calculateScaledKey(a,b=!0){if(this.overscaledZ===a&&b)return this.key;if(a>this.canonical.z)return kU(this.wrap*+b,a,this.canonical.z,this.canonical.x,this.canonical.y);{const c=this.canonical.z-a;return kU(this.wrap*+b,a,a,this.canonical.x>>c,this.canonical.y>>c)}}isChildOf(a){if(a.wrap!==this.wrap)return!1;const b=this.canonical.z-a.canonical.z;return 0===a.overscaledZ||a.overscaledZ<this.overscaledZ&&a.canonical.x===this.canonical.x>>b&&a.canonical.y===this.canonical.y>>b}children(d){if(this.overscaledZ>=d)return[new bn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y),];const a=this.canonical.z+1,b=2*this.canonical.x,c=2*this.canonical.y;return[new bn(a,this.wrap,a,b,c),new bn(a,this.wrap,a,b+1,c),new bn(a,this.wrap,a,b,c+1),new bn(a,this.wrap,a,b+1,c+1),]}isLessThan(a){return this.wrap<a.wrap|| !(this.wrap>a.wrap)&&(this.overscaledZ<a.overscaledZ|| !(this.overscaledZ>a.overscaledZ)&&(this.canonical.x<a.canonical.x|| !(this.canonical.x>a.canonical.x)&&this.canonical.y<a.canonical.y))}wrapped(){return new bn(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(a){return new bn(this.overscaledZ,a,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new ej(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function kU(c,e,a,f,g){const b=1<<Math.min(a,22);let d=b*(g%b)+f%b;return c&&a<22&&(d+=b*b*((c<0?-2*c-1:2*c)%(1<<2*(22-a)))),16*(32*d+a)+(e-a)}c("CanonicalTileID",bm),c("OverscaledTileID",bn,{omit:["projMatrix"]});class C{constructor(a,b,c){this.func=a,this.mask=b,this.range=c}}C.ReadOnly=!1,C.ReadWrite=!0,C.disabled=new C(519,C.ReadOnly,[0,1]);class aC{constructor(a,b,c,d,e,f){this.test=a,this.ref=b,this.mask=c,this.fail=d,this.depthFail=e,this.pass=f}}aC.disabled=new aC({func:519,mask:0},0,0,7680,7680,7680);class r{constructor(a,b,c){this.blendFunction=a,this.blendColor=b,this.mask=c}}r.Replace=[1,0],r.disabled=new r(r.Replace,m.transparent,[!1,!1,!1,!1,]),r.unblended=new r(r.Replace,m.transparent,[!0,!0,!0,!0,]),r.alphaBlended=new r([1,771],m.transparent,[!0,!0,!0,!0]);class o{constructor(a,b,c){this.enable=a,this.mode=b,this.frontFace=c}}o.disabled=new o(!1,1029,2305),o.backCCW=new o(!0,1029,2305),o.backCW=new o(!0,1029,2304),o.frontCW=new o(!0,1028,2304),o.frontCCW=new o(!0,1028,2305);class kV{constructor(b){this._stringToNumber={},this._numberToString=[];for(let a=0;a<b.length;a++){const c=b[a];this._stringToNumber[c]=a,this._numberToString[a]=c}}encode(a){return this._stringToNumber[a]}decode(a){return this._numberToString[a]}}class kW{constructor(a,b,c,d,e){this.type="Feature",this._vectorTileFeature=a,a._z=b,a._x=c,a._y=d,this.properties=a.properties,this.id=e}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(a){this._geometry=a}toJSON(){const b={geometry:this.geometry};for(const a in this)"_geometry"!==a&&"_vectorTileFeature"!==a&&(b[a]=this[a]);return b}}class kX{constructor(a){this.size=a,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(b,c){const a=this.toIdx(b,c);return{min:this.minimums[a],max:this.maximums[a]}}isLeaf(a,b){return this.leaves[this.toIdx(a,b)]}toIdx(a,b){return b*this.size+a}}function kY(g,h,d,i){let e=0,f=Number.MAX_VALUE;for(let a=0;a<3;a++)if(1e-15>Math.abs(i[a])){if(d[a]<g[a]||d[a]>h[a])return null}else{const j=1/i[a];let b=(g[a]-d[a])*j,c=(h[a]-d[a])*j;if(b>c){const k=b;b=c,c=k}if(b>e&&(e=b),c<f&&(f=c),e>f)return null}return e}function kZ(b,c,d,y,z,A,B,C,D,e,a){const f=y-b,g=z-c,h=A-d,i=B-b,j=C-c,k=D-d,q=a[1]*k-a[2]*j,r=a[2]*i-a[0]*k,s=a[0]*j-a[1]*i,t=f*q+g*r+h*s;if(1e-15>Math.abs(t))return null;const l=1/t,m=e[0]-b,n=e[1]-c,o=e[2]-d,p=(m*q+n*r+o*s)*l;if(p<0||p>1)return null;const u=n*h-o*g,v=o*f-m*h,w=m*g-n*f,x=(a[0]*u+a[1]*v+a[2]*w)*l;return x<0||p+x>1?null:(i*u+j*v+k*w)*l}function k$(d,e,j,b,c,k,l,f,g){const a=1<<j,h=k-b,i=l-c;f[0]=(d+0)/a*h+b,f[1]=(e+0)/a*i+c,g[0]=(d+1)/a*h+b,g[1]=(e+1)/a*i+c}class ek{constructor(d){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=d,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1],],!this.dem)return;const a=function(e){const t=Math.ceil(Math.log2(e.dim/8)),f=[];let b=Math.ceil(Math.pow(2,t));const u=1/b,i=(c,d,a,f,b)=>{const e=f?1:0,g=(c+1)*a-e,h=d*a,i=(d+1)*a-e;b[0]=c*a,b[1]=h,b[2]=g,b[3]=i};let c=new kX(b);const a=[];for(let g=0;g<b*b;g++){i(g%b,Math.floor(g/b),u,!1,a);const j=k0(a[0],a[1],e),k=k0(a[2],a[1],e),l=k0(a[2],a[3],e),m=k0(a[0],a[3],e);c.minimums.push(Math.min(j,k,l,m)),c.maximums.push(Math.max(j,k,l,m)),c.leaves.push(1)}for(f.push(c),b/=2;b>=1;b/=2){const d=f[f.length-1];c=new kX(b);for(let h=0;h<b*b;h++){i(h%b,Math.floor(h/b),2,!0,a);const n=d.getElevation(a[0],a[1]),o=d.getElevation(a[2],a[1]),p=d.getElevation(a[2],a[3]),q=d.getElevation(a[0],a[3]),v=d.isLeaf(a[0],a[1]),w=d.isLeaf(a[2],a[1]),x=d.isLeaf(a[2],a[3]),y=d.isLeaf(a[0],a[3]),r=Math.min(n.min,o.min,p.min,q.min),s=Math.max(n.max,o.max,p.max,q.max),z=v&&w&&x&&y;c.maximums.push(s),c.minimums.push(r),c.leaves.push(s-r<=5&&z?1:0)}f.push(c)}return f}(this.dem),c=a.length-1,b=a[c];this._addNode(b.minimums[0],b.maximums[0],b.leaves[0]),this._construct(a,0,0,c,0)}raycastRoot(a,b,c,d,e,f,g=1){return kY([a,b,-100],[c,d,this.maximums[0]*g],e,f)}raycast(o,p,q,r,e,f,d=1){if(!this.nodeCount)return null;const A=this.raycastRoot(o,p,q,r,e,f,d);if(null==A)return null;const s=[],i=[],a=[],b=[],t=[{idx:0,t:A,nodex:0,nodey:0,depth:0},];for(;t.length>0;){const{idx:u,t:B,nodex:g,nodey:h,depth:j}=t.pop();if(this.leaves[u]){k$(g,h,j,o,p,q,r,a,b);const k=1<<j,C=(g+0)/k,D=(g+1)/k,E=(h+0)/k,F=(h+1)/k,v=k0(C,E,this.dem)*d,G=k0(D,E,this.dem)*d,w=k0(D,F,this.dem)*d,H=k0(C,F,this.dem)*d,I=kZ(a[0],a[1],v,b[0],a[1],G,b[0],b[1],w,e,f),J=kZ(b[0],b[1],w,a[0],b[1],H,a[0],a[1],v,e,f),K=Math.min(null!==I?I:Number.MAX_VALUE,null!==J?J:Number.MAX_VALUE);if(K!==Number.MAX_VALUE)return K;{var L,M;const x=by([],e,f,B);if(k_(v,G,H,w,(x[0]-(L=a[0]))/(b[0]-L),(x[1]-(M=a[1]))/(b[1]-M))>=x[2])return B}continue}let l=0;for(let c=0;c<this._siblingOffset.length;c++){k$((g<<1)+this._siblingOffset[c][0],(h<<1)+this._siblingOffset[c][1],j+1,o,p,q,r,a,b),a[2]=-100,b[2]=this.maximums[this.childOffsets[u]+c]*d;const N=kY(a,b,e,f);if(null!=N){const O=N;s[c]=O;let y=!1;for(let m=0;m<l&&!y;m++)O>=s[i[m]]&&(i.splice(m,0,c),y=!0);y||(i[l]=c),l++}}for(let z=0;z<l;z++){const n=i[z];t.push({idx:this.childOffsets[u]+n,t:s[n],nodex:(g<<1)+this._siblingOffset[n][0],nodey:(h<<1)+this._siblingOffset[n][1],depth:j+1})}}return null}_addNode(a,b,c){return this.minimums.push(a),this.maximums.push(b),this.leaves.push(c),this.childOffsets.push(0),this.nodeCount++}_construct(c,d,e,g,h){if(1===c[g].isLeaf(d,e))return;this.childOffsets[h]||(this.childOffsets[h]=this.nodeCount);const i=g-1,j=c[i];let f,k=0;for(let b=0;b<this._siblingOffset.length;b++){const l=2*d+this._siblingOffset[b][0],m=2*e+this._siblingOffset[b][1],n=j.getElevation(l,m),o=j.isLeaf(l,m),p=this._addNode(n.min,n.max,o);o&&(k|=1<<b),f||(f=p)}for(let a=0;a<this._siblingOffset.length;a++)k&1<<a||this._construct(c,2*d+this._siblingOffset[a][0],2*e+this._siblingOffset[a][1],i,f+a)}}function k_(b,c,d,e,f,a){return aY(aY(b,d,a),aY(c,e,a),f)}function k0(i,j,b){const a=b.dim,e=bM(i*a-.5,0,a-1),f=bM(j*a-.5,0,a-1),c=Math.floor(e),d=Math.floor(f),g=Math.min(c+1,a-1),h=Math.min(d+1,a-1);return k_(b.get(c,d),b.get(g,d),b.get(c,h),b.get(g,h),e-c,f-d)}const k1={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};class bo{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(f,c,d,e=!1,g=!1){if(this.uid=f,c.height!==c.width)throw RangeError("DEM tiles must be square");if(d&&"mapbox"!==d&&"terrarium"!==d)return bY(`"${d}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=c.height;const a=this.dim=c.height-2;if(this.data=new Uint32Array(c.data.buffer),this.encoding=d||"mapbox",this.borderReady=e,!e){for(let b=0;b<a;b++)this.data[this._idx(-1,b)]=this.data[this._idx(0,b)],this.data[this._idx(a,b)]=this.data[this._idx(a-1,b)],this.data[this._idx(b,-1)]=this.data[this._idx(b,0)],this.data[this._idx(b,a)]=this.data[this._idx(b,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],g&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new ek(this)}get(a,b,e=!1){const c=new Uint8Array(this.data.buffer);e&&(a=bM(a,-1,this.dim),b=bM(b,-1,this.dim));const d=4*this._idx(a,b);return("terrarium"===this.encoding?this._unpackTerrarium:this._unpackMapbox)(c[d],c[d+1],c[d+2])}static getUnpackVector(a){return k1[a]}get unpackVector(){return k1[this.encoding]}_idx(a,b){if(a< -1||a>=this.dim+1||b< -1||b>=this.dim+1)throw RangeError("out of range source coordinates for DEM data");return(b+1)*this.stride+(a+1)}_unpackMapbox(a,b,c){return(256*a*256+256*b+c)/10-1e4}_unpackTerrarium(a,b,c){return 256*a+b+c/256-32768}static pack(d,e){const b=[0,0,0,0],c=bo.getUnpackVector(e);let a=Math.floor((d+c[3])/c[2]);return b[2]=a%256,a=Math.floor(a/256),b[1]=a%256,a=Math.floor(a/256),b[0]=a,b}getPixels(){return new bg({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(i,a,b){if(this.dim!==i.dim)throw Error("dem dimension mismatch");let e=a*this.dim,f=a*this.dim+this.dim,g=b*this.dim,h=b*this.dim+this.dim;switch(a){case -1:e=f-1;break;case 1:f=e+1}switch(b){case -1:g=h-1;break;case 1:h=g+1}const j=-a*this.dim,k=-b*this.dim;for(let c=g;c<h;c++)for(let d=e;d<f;d++)this.data[this._idx(d,c)]=i.data[this._idx(d+j,c+k)]}onDeserialize(){this._tree&&(this._tree.dem=this)}}c("DEMData",bo),c("DemMinMaxQuadTree",ek,{omit:["dem"]});class aD extends S{constructor(b,a,c){super(),this.id=b,this._onlySymbols=c,a.on("data",a=>{"source"===a.dataType&&"metadata"===a.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===a.dataType&&"content"===a.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),a.on("error",()=>{this._sourceErrored=!0}),this._source=a,this._tiles={},this._cache=new class{constructor(a,b){this.max=a,this.onRemove=b,this.reset()}reset(){for(const b in this.data)for(const a of this.data[b])a.timeout&&clearTimeout(a.timeout),this.onRemove(a.value);return this.data={},this.order=[],this}add(e,f,b){const a=e.wrapped().key;void 0===this.data[a]&&(this.data[a]=[]);const c={value:f,timeout:void 0};if(void 0!==b&&(c.timeout=setTimeout(()=>{this.remove(e,c)},b)),this.data[a].push(c),this.order.push(a),this.order.length>this.max){const d=this._getAndRemoveByKey(this.order[0]);d&&this.onRemove(d)}return this}has(a){return a.wrapped().key in this.data}getAndRemove(a){return this.has(a)?this._getAndRemoveByKey(a.wrapped().key):null}_getAndRemoveByKey(a){const b=this.data[a].shift();return b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.order.splice(this.order.indexOf(a),1),b.value}getByKey(b){const a=this.data[b];return a?a[0].value:null}get(a){return this.has(a)?this.data[a.wrapped().key][0].value:null}remove(c,d){if(!this.has(c))return this;const a=c.wrapped().key,e=void 0===d?0:this.data[a].indexOf(d),b=this.data[a][e];return this.data[a].splice(e,1),b.timeout&&clearTimeout(b.timeout),0===this.data[a].length&&delete this.data[a],this.onRemove(b.value),this.order.splice(this.order.indexOf(a),1),this}setMaxSize(b){for(this.max=b;this.order.length>this.max;){const a=this._getAndRemoveByKey(this.order[0]);a&&this.onRemove(a)}return this}filter(d){const a=[];for(const e in this.data)for(const b of this.data[e])d(b.value)||a.push(b);for(const c of a)this.remove(c.value.tileID,c)}}(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=null,this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new class{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(a,g,c){const b=String(g);if(this.stateChanges[a]=this.stateChanges[a]||{},this.stateChanges[a][b]=this.stateChanges[a][b]||{},bR(this.stateChanges[a][b],c),null===this.deletedStates[a])for(const d in this.deletedStates[a]={},this.state[a])d!==b&&(this.deletedStates[a][d]=null);else if(this.deletedStates[a]&&null===this.deletedStates[a][b])for(const e in this.deletedStates[a][b]={},this.state[a][b])c[e]||(this.deletedStates[a][b][e]=null);else for(const f in c)this.deletedStates[a]&&this.deletedStates[a][b]&&null===this.deletedStates[a][b][f]&&delete this.deletedStates[a][b][f]}removeFeatureState(a,d,c){if(null===this.deletedStates[a])return;const b=String(d);if(this.deletedStates[a]=this.deletedStates[a]||{},c&& void 0!==d)null!==this.deletedStates[a][b]&&(this.deletedStates[a][b]=this.deletedStates[a][b]||{},this.deletedStates[a][b][c]=null);else if(void 0!==d){if(this.stateChanges[a]&&this.stateChanges[a][b])for(c in this.deletedStates[a][b]={},this.stateChanges[a][b])this.deletedStates[a][b][c]=null;else this.deletedStates[a][b]=null}else this.deletedStates[a]=null}getState(a,b){const c=String(b),d=bR({},(this.state[a]||{})[c],(this.stateChanges[a]||{})[c]);if(null===this.deletedStates[a])return{};if(this.deletedStates[a]){const e=this.deletedStates[a][b];if(null===e)return{};for(const f in e)delete d[f]}return d}initializeTileState(a,b){a.setFeatureState(this.state,b)}coalesceChanges(g,j){const c={};for(const b in this.stateChanges){this.state[b]=this.state[b]||{};const h={};for(const d in this.stateChanges[b])this.state[b][d]||(this.state[b][d]={}),bR(this.state[b][d],this.stateChanges[b][d]),h[d]=this.state[b][d];c[b]=h}for(const a in this.deletedStates){this.state[a]=this.state[a]||{};const f={};if(null===this.deletedStates[a])for(const i in this.state[a])f[i]={},this.state[a][i]={};else for(const e in this.deletedStates[a]){if(null===this.deletedStates[a][e])this.state[a][e]={};else for(const k of Object.keys(this.deletedStates[a][e]))delete this.state[a][e][k];f[e]=this.state[a][e]}c[a]=c[a]||{},bR(c[a],f)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(c).length)for(const l in g)g[l].setFeatureState(c,j)}}}onAdd(a){this.map=a,this._minTileCacheSize=a?a._minTileCacheSize:null,this._maxTileCacheSize=a?a._maxTileCacheSize:null}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const b in this._tiles){const a=this._tiles[b];if("loaded"!==a.state&&"errored"!==a.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const a=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,a&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(a,b){return a.isSymbolTile=this._onlySymbols,this._source.loadTile(a,b)}_unloadTile(a){if(this._source.unloadTile)return this._source.unloadTile(a,()=>{})}_abortTile(a){if(this._source.abortTile)return this._source.abortTile(a,()=>{})}serialize(){return this._source.serialize()}prepare(b){for(const c in this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._tiles){const a=this._tiles[c];a.upload(b),a.prepare(this.map.style.imageManager)}}getIds(){return bQ(this._tiles).map(a=>a.tileID).sort(k2).map(a=>a.key)}getRenderableIds(b){const a=[];for(const c in this._tiles)this._isIdRenderable(+c,b)&&a.push(this._tiles[c]);return b?a.sort((e,f)=>{const a=e.tileID,b=f.tileID,c=new aF(a.canonical.x,a.canonical.y)._rotate(this.transform.angle),d=new aF(b.canonical.x,b.canonical.y)._rotate(this.transform.angle);return a.overscaledZ-b.overscaledZ||d.y-c.y||d.x-c.x}).map(a=>a.tileID.key):a.map(a=>a.tileID).sort(k2).map(a=>a.key)}hasRenderableParent(b){const a=this.findLoadedParent(b,0);return!!a&&this._isIdRenderable(a.tileID.key)}_isIdRenderable(a,b){return this._tiles[a]&&this._tiles[a].hasData()&&!this._coveredTiles[a]&&(b||!this._tiles[a].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else for(const a in this._cache.reset(),this._tiles)"errored"!==this._tiles[a].state&&this._reloadTile(+a,"reloading")}_reloadTile(b,c){const a=this._tiles[b];a&&("loading"!==a.state&&(a.state=c),this._loadTile(a,this._tileLoaded.bind(this,a,b,c)))}_tileLoaded(a,d,e,b){if(b){if(a.state="errored",404!==b.status)this._source.fire(new cb(b,{tile:a}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const c=this.map.painter.terrain;this.update(this.transform,c.getScaledDemTileSize(),!0),c.resetTileLookupCache(this.id)}else this.update(this.transform)}else a.timeAdded=b$.now(),"expired"===e&&(a.refreshedUponExpiration=!0),this._setTileReloadTimer(d,a),"raster-dem"===this._source.type&&a.dem&&this._backfillDEM(a),this._state.initializeTileState(a,this.map?this.map.painter:null),this._source.fire(new aW("data",{dataType:"source",tile:a,coord:a.tileID,sourceCacheId:this.id}))}_backfillDEM(a){const c=this.getRenderableIds();for(let b=0;b<c.length;b++){const d=c[b];if(a.neighboringTiles&&a.neighboringTiles[d]){const e=this.getTileByID(d);f(a,e),f(e,a)}}function f(a,c){if(!a.dem||a.dem.borderReady)return;a.needsHillshadePrepare=!0,a.needsDEMTextureUpload=!0;let b=c.tileID.canonical.x-a.tileID.canonical.x;const e=c.tileID.canonical.y-a.tileID.canonical.y,d=Math.pow(2,a.tileID.canonical.z),f=c.tileID.key;0===b&&0===e||Math.abs(e)>1||(Math.abs(b)>1&&(1===Math.abs(b+d)?b+=d:1===Math.abs(b-d)&&(b-=d)),c.dem&&a.dem&&(a.dem.backfillBorder(c.dem,b,e),a.neighboringTiles&&a.neighboringTiles[f]&&(a.neighboringTiles[f].backfilled=!0)))}}getTile(a){return this.getTileByID(a.key)}getTileByID(a){return this._tiles[a]}_retainLoadedChildren(h,d,i,e){for(const f in this._tiles){let a=this._tiles[f];if(e[f]||!a.hasData()||a.tileID.overscaledZ<=d||a.tileID.overscaledZ>i)continue;let b=a.tileID;for(;a&&a.tileID.overscaledZ>d+1;){const g=a.tileID.scaledTo(a.tileID.overscaledZ-1);(a=this._tiles[g.key])&&a.hasData()&&(b=g)}let c=b;for(;c.overscaledZ>d;)if(h[(c=c.scaledTo(c.overscaledZ-1)).key]){e[b.key]=b;break}}}findLoadedParent(a,d){if(a.key in this._loadedParentTiles){const b=this._loadedParentTiles[a.key];return b&&b.tileID.overscaledZ>=d?b:null}for(let c=a.overscaledZ-1;c>=d;c--){const f=a.scaledTo(c),e=this._getLoadedTile(f);if(e)return e}}_getLoadedTile(a){const b=this._tiles[a.key];return b&&b.hasData()?b:this._cache.getByKey(this._source.reparseOverscaled?a.wrapped().key:a.canonical.key)}updateCacheSize(b,a){a=a||this._source.tileSize;const e=Math.ceil(b.width/a)+1,f=Math.ceil(b.height/a)+1,c=Math.floor(e*f*5),d="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,c):c,g="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,d):d;this._cache.setMaxSize(g)}handleWrapJump(b){const c=Math.round((b-(void 0===this._prevLng?b:this._prevLng))/360);if(this._prevLng=b,c){const d={};for(const g in this._tiles){const a=this._tiles[g];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+c),d[a.tileID.key]=a}for(const e in this._tiles=d,this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const f in this._tiles)this._setTileReloadTimer(+f,this._tiles[f])}}update(e,n,o){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!o)return;let a;this.updateCacheSize(e,n),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?a=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(a=>new bn(a.canonical.z,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y)):(a=e.coveringTiles({tileSize:n||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!o,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(a=a.filter(a=>this._source.hasTile(a)))):a=[];const b=this._updateRetainedTiles(a);if(k3(this._source.type)&&0!==a.length){const h={},p={},s=Object.keys(b);for(const i of s){const j=b[i],k=this._tiles[i];if(!k||k.fadeEndTime&&k.fadeEndTime<=b$.now())continue;const f=this.findLoadedParent(j,Math.max(j.overscaledZ-aD.maxOverzooming,this._source.minzoom));f&&(this._addTile(f.tileID),h[f.tileID.key]=f.tileID),p[i]=j}const t=a[a.length-1].overscaledZ;for(const l in this._tiles){const m=this._tiles[l];if(b[l]||!m.hasData())continue;let c=m.tileID;for(;c.overscaledZ>t;){c=c.scaledTo(c.overscaledZ-1);const q=this._tiles[c.key];if(q&&q.hasData()&&p[c.key]){b[l]=m.tileID;break}}}for(const g in h)b[g]||(this._coveredTiles[g]=!0,b[g]=h[g])}for(const u in b)this._tiles[u].clearFadeHold();const v=function(c,d){const a=[];for(const b in c)b in d||a.push(b);return a}(this._tiles,b);for(const r of v){const d=this._tiles[r];d.hasSymbolBuckets&&!d.holdingForFade()?d.setHoldDuration(this.map._fadeDuration):d.hasSymbolBuckets&&!d.symbolFadeFinished()||this._removeTile(+r)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const a in this._tiles)this._tiles[a].holdingForFade()&&this._removeTile(+a)}_updateRetainedTiles(e){const a={};if(0===e.length)return a;const j={},k=e.reduce((a,b)=>Math.min(a,b.overscaledZ),1/0),l=e[0].overscaledZ,p=Math.max(l-aD.maxOverzooming,this._source.minzoom),q=Math.max(l+aD.maxUnderzooming,this._source.minzoom),m={};for(const f of e){const r=this._addTile(f);a[f.key]=f,r.hasData()||k<this._source.maxzoom&&(m[f.key]=f)}for(const c of(this._retainLoadedChildren(m,k,q,a),e)){let b=this._tiles[c.key];if(b.hasData())continue;if(c.canonical.z>=this._source.maxzoom){const h=c.children(this._source.maxzoom)[0],n=this.getTile(h);if(n&&n.hasData()){a[h.key]=h;continue}}else{const g=c.children(this._source.maxzoom);if(a[g[0].key]&&a[g[1].key]&&a[g[2].key]&&a[g[3].key])continue}let o=b.wasRequested();for(let i=c.overscaledZ-1;i>=p;--i){const d=c.scaledTo(i);if(j[d.key]||(j[d.key]=!0,(b=this.getTile(d))||!o||(b=this._addTile(d)),b&&(a[d.key]=d,o=b.wasRequested(),b.hasData())))break}}return a}_updateLoadedParentTileCache(){for(const e in this._loadedParentTiles={},this._tiles){const c=[];let b,a=this._tiles[e].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){b=this._loadedParentTiles[a.key];break}c.push(a.key);const d=a.scaledTo(a.overscaledZ-1);if(b=this._getLoadedTile(d))break;a=d}for(const f of c)this._loadedParentTiles[f]=b}}_addTile(b){let a=this._tiles[b.key];if(a)return a;(a=this._cache.getAndRemove(b))&&(this._setTileReloadTimer(b.key,a),a.tileID=b,this._state.initializeTileState(a,this.map?this.map.painter:null),this._cacheTimers[b.key]&&(clearTimeout(this._cacheTimers[b.key]),delete this._cacheTimers[b.key],this._setTileReloadTimer(b.key,a)));const c=Boolean(a);if(!c){const d=this.map?this.map.painter:null,e="raster"===this._source.type||"raster-dem"===this._source.type;a=new eq(b,this._source.tileSize*b.overscaleFactor(),this.transform.tileZoom,d,e),this._loadTile(a,this._tileLoaded.bind(this,a,b.key,a.state))}return a?(a.uses++,this._tiles[b.key]=a,c||this._source.fire(new aW("dataloading",{tile:a,coord:a.tileID,dataType:"source"})),a):null}_setTileReloadTimer(a,c){a in this._timers&&(clearTimeout(this._timers[a]),delete this._timers[a]);const b=c.getExpiryTimeout();b&&(this._timers[a]=setTimeout(()=>{this._reloadTile(a,"expired"),delete this._timers[a]},b))}_removeTile(b){const a=this._tiles[b];a&&(a.uses--,delete this._tiles[b],this._timers[b]&&(clearTimeout(this._timers[b]),delete this._timers[b]),a.uses>0||(a.hasData()&&"reloading"!==a.state?this._cache.add(a.tileID,a,a.getExpiryTimeout()):(a.aborted=!0,this._abortTile(a),this._unloadTile(a))))}clearTiles(){for(const a in this._shouldReloadOnResume=!1,this._paused=!1,this._tiles)this._removeTile(+a);this._source._clear&&this._source._clear(),this._cache.reset()}tilesIn(e,f,g){const a=[],c=this.transform;if(!c)return a;for(const h in this._tiles){const b=this._tiles[h];if(g&&b.clearQueryDebugViz(),b.holdingForFade())continue;const d=e.containsTile(b,c,f);d&&a.push(d)}return a}getVisibleCoordinates(c){const a=this.getRenderableIds(c).map(a=>this._tiles[a].tileID);for(const b of a)b.projMatrix=this.transform.calculateProjMatrix(b.toUnwrapped());return a}hasTransition(){if(this._source.hasTransition())return!0;if(k3(this._source.type))for(const b in this._tiles){const a=this._tiles[b];if(void 0!==a.fadeEndTime&&a.fadeEndTime>=b$.now())return!0}return!1}setFeatureState(a,b,c){this._state.updateState(a=a||"_geojsonTileLayer",b,c)}removeFeatureState(a,b,c){this._state.removeFeatureState(a=a||"_geojsonTileLayer",b,c)}getFeatureState(a,b){return this._state.getState(a=a||"_geojsonTileLayer",b)}setDependencies(b,c,d){const a=this._tiles[b];a&&a.setDependencies(c,d)}reloadTilesForDependencies(b,c){for(const a in this._tiles)this._tiles[a].hasDependency(b,c)&&this._reloadTile(+a,"reloading");this._cache.filter(a=>!a.hasDependency(b,c))}_preloadTiles(a,f){const b=new Map,g=Array.isArray(a)?a:[a],c=this.map.painter.terrain,h=this.usedForTerrain&&c?c.getScaledDemTileSize():this._source.tileSize;for(const d of g){const i=d.coveringTiles({tileSize:h,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 i)b.set(e.key,e);this.usedForTerrain&&d.updateElevation(!1)}const j=Array.from(b.values()),k="raster"===this._source.type||"raster-dem"===this._source.type;bP(j,(a,c)=>{const b=new eq(a,this._source.tileSize*a.overscaleFactor(),this.transform.tileZoom,this.map.painter,k);this._loadTile(b,a=>{"raster-dem"===this._source.type&&b.dem&&this._backfillDEM(b),c(a,b)})},f)}}function k2(a,b){const c=Math.abs(2*a.wrap)- +(a.wrap<0),d=Math.abs(2*b.wrap)- +(b.wrap<0);return a.overscaledZ-b.overscaledZ||d-c||b.canonical.y-a.canonical.y||b.canonical.x-a.canonical.x}function k3(a){return"raster"===a||"image"===a||"video"===a}aD.maxOverzooming=10,aD.maxUnderzooming=3;class k4{constructor(a,b,c){this._demTile=a,this._dem=this._demTile.dem,this._scale=b,this._offset=c}static create(f,b,g){const a=g||f.findDEMTileFor(b);if(!a||!a.dem)return;const e=a.dem,c=a.tileID,d=1<<b.canonical.z-c.canonical.z;return new k4(a,a.tileSize/8192/d,[(b.canonical.x/d-c.canonical.x)*e.dim,(b.canonical.y/d-c.canonical.y)*e.dim,])}tileCoordToPixel(a,b){const c=b*this._scale+this._offset[1],d=Math.floor(a*this._scale+this._offset[0]);return new aF(d,Math.floor(c))}getElevationAt(g,h,i,a){const f=g*this._scale+this._offset[0],e=h*this._scale+this._offset[1],c=Math.floor(f),b=Math.floor(e),d=this._dem;return a=!!a,i?aY(aY(d.get(c,b,a),d.get(c,b+1,a),e-b),aY(d.get(c+1,b,a),d.get(c+1,b+1,a),e-b),f-c):d.get(c,b,a)}getElevationAtPixel(a,b,c){return this._dem.get(a,b,!!c)}getMeterToDEM(a){return(1<<this._demTile.tileID.canonical.z)*dB(1,a)*this._dem.stride}}class el{constructor(a,b){this.tileID=a,this.x=a.canonical.x,this.y=a.canonical.y,this.z=a.canonical.z,this.grid=new aj(8192,16,0),this.featureIndexArray=new dg,this.promoteId=b}insert(m,e,g,h,i,j=0){const k=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(g,h,i,j);const l=this.grid;for(let c=0;c<e.length;c++){const f=e[c],a=[1/0,1/0,-1/0,-1/0];for(let d=0;d<f.length;d++){const b=f[d];a[0]=Math.min(a[0],b.x),a[1]=Math.min(a[1],b.y),a[2]=Math.max(a[2],b.x),a[3]=Math.max(a[3],b.y)}a[0]<8192&&a[1]<8192&&a[2]>=0&&a[3]>=0&&l.insert(k,a[0],a[1],a[2],a[3])}}loadVTLayers(){if(!this.vtLayers)for(const a in this.vtLayers=new _.VectorTile(new d2(this.rawTileData)).layers,this.sourceLayerCoder=new kV(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={},this.vtLayers)this.vtFeatures[a]=[];return this.vtLayers}query(c,j,k,l){this.loadVTLayers();const d=c.params||{},m=gB(d.filter),n=c.tileResult,g=c.transform,a=n.bufferedTilespaceBounds,b=this.grid.query(a.min.x,a.min.y,a.max.x,a.max.y,(a,b,c,d)=>dF(n.bufferedTilespaceGeometry,a,b,c,d));b.sort(k6);let o=null;g.elevation&&b.length>0&&(o=k4.create(g.elevation,this.tileID));const h={};let i;for(let e=0;e<b.length;e++){const f=b[e];if(f===i)continue;i=f;const p=this.featureIndexArray.get(f);let q=null;this.loadMatchingFeature(h,p,m,d.layers,d.availableImages,j,k,l,(a,b,d,e=0)=>(q||(q=ic(a,this.tileID.canonical,c.tileTransform)),b.queryIntersectsFeature(n,a,d,q,this.z,c.transform,c.pixelPosMatrix,o,e)))}return h}loadMatchingFeature(l,t,g,e,m,u,v,n,o){const{featureIndex:p,bucketIndex:w,sourceLayerIndex:x,layoutVertexArrayOffset:y}=t,h=this.bucketLayerIDs[w];if(e&&!function(b,c){for(let a=0;a<b.length;a++)if(c.indexOf(b[a])>=0)return!0;return!1}(e,h))return;const q=this.sourceLayerCoder.decode(x),a=this.vtLayers[q].feature(p);if(g.needGeometry){const z=id(a,!0);if(!g.filter(new c5(this.tileID.overscaledZ),z,this.tileID.canonical))return}else if(!g.filter(new c5(this.tileID.overscaledZ),a))return;const i=this.getId(a,q);for(let j=0;j<h.length;j++){const b=h[j];if(e&&0>e.indexOf(b))continue;const c=u[b];if(!c)continue;let f={};void 0!==i&&n&&(f=n.getState(c.sourceLayer||"_geojsonTileLayer",i));const d=bR({},v[b]);d.paint=k5(d.paint,c.paint,a,f,m),d.layout=k5(d.layout,c.layout,a,f,m);const r=!o||o(a,c,f,y);if(!r)continue;const s=new kW(a,this.z,this.x,this.y,i);s.layer=d;let k=l[b];void 0===k&&(k=l[b]=[]),k.push({featureIndex:p,feature:s,intersectionZ:r})}}lookupSymbolFeatures(b,c,d,e,f,g,h,i){const a={};this.loadVTLayers();const j=gB(f);for(const k of b)this.loadMatchingFeature(a,{bucketIndex:d,sourceLayerIndex:e,featureIndex:k,layoutVertexArrayOffset:0},j,g,h,i,c);return a}loadFeature(e){const{featureIndex:a,sourceLayerIndex:f}=e;this.loadVTLayers();const c=this.sourceLayerCoder.decode(f),b=this.vtFeatures[c];if(b[a])return b[a];const d=this.vtLayers[c].feature(a);return b[a]=d,d}hasLayer(a){for(const b of this.bucketLayerIDs)for(const c of b)if(a===c)return!0;return!1}getId(b,c){let a=b.id;return this.promoteId&&"boolean"==typeof(a=b.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[c]])&&(a=Number(a)),a}}function k5(a,b,c,d,e){return eP(a,(g,f)=>{const a=b instanceof hN?b.get(f):null;return a&&a.evaluate?a.evaluate(c,d,e):a})}function k6(a,b){return b-a}c("FeatureIndex",el,{omit:["rawTileData","sourceLayerCoder"]});var em=j([{name:"a_pos",type:"Int16",components:2},]);const aa=new Uint16Array(8184);for(let ab=0;ab<2046;ab++){let aE=ab+2,D=0,E=0,F=0,G=0,ac=0,ad=0;for(1&aE?F=G=ac=32:D=E=ad=32;(aE>>=1)>1;){const en=D+F>>1,eo=E+G>>1;1&aE?(F=D,G=E,D=ac,E=ad):(D=F,E=G,F=ac,G=ad),ac=en,ad=eo}const ae=4*ab;aa[ae+0]=D,aa[ae+1]=E,aa[ae+2]=F,aa[ae+3]=G}const k7=new Uint16Array(2178),k8=new Uint8Array(1089),k9=new Uint16Array(1089);function la(a){return 0===a?-0.03125:32===a?.03125:0}var ep=j([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2},]);const lb={type:2,extent:8192,loadGeometry:()=>[[new aF(0,0),new aF(8193,0),new aF(8193,8193),new aF(0,8193),new aF(0,0),],]};class eq{constructor(b,c,d,a,e){this.tileID=b,this.uid=bS(),this.uses=0,this.tileSize=c,this.tileZoom=d,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=e,this.expiredRequestCount=0,this.state="loading",a&&a.transform&&(this.projection=a.transform.projection)}registerFadeDuration(b){const a=b+this.timeAdded;a<b$.now()||this.fadeEndTime&&a<this.fadeEndTime||(this.fadeEndTime=a)}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}get tileTransform(){return this._tileTransform||(this._tileTransform=ew(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(a,b,f){if(this.unloadVectorData(),this.state="loaded",a){for(const g in a.featureIndex&&(this.latestFeatureIndex=a.featureIndex,a.rawTileData?(this.latestRawTileData=a.rawTileData,this.latestFeatureIndex.rawTileData=a.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=a.collisionBoxArray,this.buckets=function(d,e){const b={};if(!e)return b;for(const a of d){const c=a.layerIds.map(a=>e.getLayer(a)).filter(Boolean);if(0!==c.length)for(const f of(a.layers=c,a.stateDependentLayerIds&&(a.stateDependentLayers=a.stateDependentLayerIds.map(a=>c.filter(b=>b.id===a)[0])),c))b[f.id]=a}return b}(a.buckets,b.style),this.hasSymbolBuckets=!1,this.buckets){const c=this.buckets[g];if(c instanceof aB){if(this.hasSymbolBuckets=!0,!f)break;c.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const h in this.buckets){const d=this.buckets[h];if(d instanceof aB&&d.hasRTLText){this.hasRTLText=!0,c4.isLoading()||c4.isLoaded()||"deferred"!==c3()||hH();break}}for(const e in this.queryPadding=0,this.buckets){const i=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,b.style.getLayer(e).queryRadius(i))}a.imageAtlas&&(this.imageAtlas=a.imageAtlas),a.glyphAtlasImage&&(this.glyphAtlasImage=a.glyphAtlasImage),a.lineAtlas&&(this.lineAtlas=a.lineAtlas)}else this.collisionBoxArray=new c8}unloadVectorData(){if(this.hasData()){for(const a in this.buckets)this.buckets[a].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.globePoleBuffer&&(this.globePoleBuffer.destroy(),this.globePoleBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(a){return this.buckets[a.id]}upload(a){for(const d in this.buckets){const c=this.buckets[d];c.uploadPending()&&c.upload(a)}const b=a.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new eh(a,this.imageAtlas.image,b.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new eh(a,this.glyphAtlasImage,b.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new eh(a,this.lineAtlas.image,b.ALPHA),this.lineAtlas.uploaded=!0)}prepare(a){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(a,this.imageAtlasTexture)}queryRenderedFeatures(a,b,c,d,e,f,g,h){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:d,pixelPosMatrix:g,transform:f,params:e,tileTransform:this.tileTransform},a,b,c):{}}querySourceFeatures(m,a){const b=this.latestFeatureIndex;if(!b||!b.rawTileData)return;const g=b.loadVTLayers(),h=a?a.sourceLayer:"",d=g._geojsonTileLayer||g[h];if(!d)return;const e=gB(a&&a.filter),{z:i,x:j,y:k}=this.tileID.canonical,n={z:i,x:j,y:k};for(let f=0;f<d.length;f++){const c=d.feature(f);if(e.needGeometry){const o=id(c,!0);if(!e.filter(new c5(this.tileID.overscaledZ),o,this.tileID.canonical))continue}else if(!e.filter(new c5(this.tileID.overscaledZ),c))continue;const p=b.getId(c,h),l=new kW(c,i,j,k,p);l.tile=n,m.push(l)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(b){const c=this.expirationTime;if(b.cacheControl){const d=eT(b.cacheControl);d["max-age"]&&(this.expirationTime=Date.now()+1e3*d["max-age"])}else b.expires&&(this.expirationTime=new Date(b.expires).getTime());if(this.expirationTime){const e=Date.now();let a=!1;if(this.expirationTime>e)a=!1;else if(c){if(this.expirationTime<c)a=!0;else{const f=this.expirationTime-c;f?this.expirationTime=e+Math.max(f,3e4):a=!0}}else a=!0;a?(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(),2147483647)}setFeatureState(e,a){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||0===Object.keys(e).length||!a)return;const j=this.latestFeatureIndex.loadVTLayers(),k=a.style.listImages();for(const c in this.buckets){if(!a.style.hasLayer(c))continue;const b=this.buckets[c],f=b.layers[0].sourceLayer||"_geojsonTileLayer",g=j[f],d=e[f];if(!g||!d||0===Object.keys(d).length)continue;if(b.update(d,g,k,this.imageAtlas&&this.imageAtlas.patternPositions||{}),b instanceof dX||b instanceof dN){const h=a.style._getSourceCache(b.layers[0].source);a._terrain&&a._terrain.enabled&&h&&b.programConfigurations.needsUpload&&a._terrain._clearRenderCacheForTile(h.id,this.tileID)}const i=a&&a.style&&a.style.getLayer(c);i&&(this.queryPadding=Math.max(this.queryPadding,i.queryRadius(b)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<b$.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(a){this.symbolFadeHoldUntil=b$.now()+a}setDependencies(b,c){const a={};for(const d of c)a[d]=!0;this.dependencies[b]=a}hasDependency(b,c){for(const d of b){const a=this.dependencies[d];if(a){for(const e of c)if(a[e])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(d,e){if(!e||"mercator"===e.name||this._tileDebugBuffer)return;const f=ic(lb,this.tileID.canonical,this.tileTransform)[0],c=new al,a=new av;for(let b=0;b<f.length;b++){const{x:g,y:h}=f[b];c.emplaceBack(g,h),a.emplaceBack(b)}a.emplaceBack(0),this._tileDebugIndexBuffer=d.createIndexBuffer(a),this._tileDebugBuffer=d.createVertexBuffer(c,ep.members),this._tileDebugSegments=ay.simpleSegment(0,0,c.length,a.length)}_makeTileBoundsBuffers(f,e){if(this._tileBoundsBuffer||!e||"mercator"===e.name)return;const h=ic(lb,this.tileID.canonical,this.tileTransform)[0];let a,b;if(this.isRaster){const g=function(d,n){const e=ew(d,n),o=Math.pow(2,d.z);for(let b=0;b<33;b++)for(let c=0;c<33;c++){const w=h7((d.x+(c+la(c))/32)/o),x=dC((d.y+(b+la(b))/32)/o),p=n.project(w,x),q=33*b+c;k7[2*q+0]=Math.round((p.x*e.scale-e.x)*8192),k7[2*q+1]=Math.round((p.y*e.scale-e.y)*8192)}k8.fill(0),k9.fill(0);for(let f=2045;f>=0;f--){const g=4*f,h=aa[g+0],i=aa[g+1],j=aa[g+2],k=aa[g+3],l=h+j>>1,m=i+k>>1,r=l+m-i,s=m+h-l,t=33*i+h,u=33*k+j,a=33*m+l,y=Math.hypot((k7[2*t+0]+k7[2*u+0])/2-k7[2*a+0],(k7[2*t+1]+k7[2*u+1])/2-k7[2*a+1])>=16;if(k8[a]=k8[a]||(y?1:0),f<1022){const z=(i+s>>1)*33+(h+r>>1),A=(k+s>>1)*33+(j+r>>1);k8[a]=k8[a]||k8[z]||k8[A]}}const B=new am,C=new aq;let D=0;function E(b,c){const a=33*c+b;return 0===k9[a]&&(B.emplaceBack(k7[2*a+0],k7[2*a+1],8192*b/32,8192*c/32),k9[a]=++D),k9[a]-1}function v(a,b,e,f,c,d){const g=a+e>>1,h=b+f>>1;if(Math.abs(a-c)+Math.abs(b-d)>1&&k8[33*h+g])v(c,d,a,b,g,h),v(e,f,c,d,g,h);else{const i=E(a,b),j=E(e,f),k=E(c,d);C.emplaceBack(i,j,k)}}return v(0,0,32,32,32,0),v(32,32,0,0,0,32),{vertices:B,indices:C}}(this.tileID.canonical,e);a=g.vertices,b=g.indices}else{for(const{x:i,y:j}of(a=new am,b=new aq,h))a.emplaceBack(i,j,0,0);const d=dM(a.int16,void 0,4);for(let c=0;c<d.length;c+=3)b.emplaceBack(d[c],d[c+1],d[c+2])}this._tileBoundsBuffer=f.createVertexBuffer(a,ep.members),this._tileBoundsIndexBuffer=f.createIndexBuffer(b),this._tileBoundsSegments=ay.simpleSegment(0,0,a.length,b.length)}}const er=j([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_merc_pos",components:2},{type:"Float32",name:"a_uv",components:2},]),lc=j([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2},]),{members:ld}=er;function le(a,d){const c=a.fovAboveCenter,e=a.elevation?a.elevation.getMinElevationBelowMSL()*d:0,b=(a._camera.position[2]*a.worldSize-e)/Math.cos(a._pitch),f=Math.sin(c)*b/Math.sin(Math.max(Math.PI/2-a._pitch-c,.01)),g=Math.sin(a._pitch)*f+b;return Math.min(1.01*g,b*(1/a._horizonShift))}const bp=8192/Math.PI/2,p=-bp,q=bp,lf=[new B([p,p,p],[q,q,q]),new B([p,p,p],[0,0,q]),new B([0,p,p],[q,0,q]),new B([p,0,p],[0,q,q]),new B([0,0,p],[q,q,q]),];function es(d){if(d.z<=1)return lf[d.z+2*d.y+d.x];const[e,f]=lg(d),g=[li(e[0],e[1]),li(e[0],f[1]),li(f[0],e[1]),li(f[0],f[1]),],a=[q,q,q],b=[p,p,p];for(const c of g)a[0]=Math.min(a[0],c[0]),a[1]=Math.min(a[1],c[1]),a[2]=Math.min(a[2],c[2]),b[0]=Math.max(b[0],c[0]),b[1]=Math.max(b[1],c[1]),b[2]=Math.max(b[2],c[2]);return new B(a,b)}function lg(a){const b=Math.pow(2,a.z),c=a.x/b,d=(a.x+1)/b,e=(a.y+1)/b;return[[dC(a.y/b),h7(c)],[dC(e),h7(d)],]}function lh(c,d,b,a){return b*=aP,a||(a=bp),[c*Math.sin(b)*a,-d*a,c*Math.cos(b)*a,]}function li(a,b,c){return lh(Math.cos(a*aP),Math.sin(a*aP),b,c)}function lj(a){return 16383/Math.max(...bE([],a.max,a.min))}function et(c){const a=aI(new Float64Array(16)),b=1/lj(c);return br(a,a,c.min),bs(a,a,[b,b,b]),a}function eu(b,c,d){const e=c/(2*Math.PI)/(8192/(2*Math.PI));if(!d){const f=bM(b.center.lat,-85.051129,85.051129);d=[dz(b.center.lng)*c,dA(f)*c]}const a=aI(new Float64Array(16));return br(a,a,[d[0],d[1],-(c/(2*Math.PI))]),bs(a,a,[e,e,e]),bt(a,a,-b._center.lat*aP),bu(a,a,-b._center.lng*aP),a}class ev{constructor(b){const d=this._createGridIndices();this.gridIndexBuffer=b.createIndexBuffer(d,!0),this.gridSegments=ay.simpleSegment(0,0,4225,8192);const e=this._createPoleTriangleIndices();this.poleIndexBuffer=b.createIndexBuffer(e,!0),this.poleSegments=ay.simpleSegment(0,0,66,64);const a=new bb;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 c=new aq;c.emplaceBack(0,1,2),c.emplaceBack(2,3,0),this.atmosphereVertexBuffer=b.createVertexBuffer(a,lc.members),this.atmosphereIndexBuffer=b.createIndexBuffer(c),this.atmosphereSegments=ay.simpleSegment(0,0,4,2)}destroy(){this.poleIndexBuffer.destroy(),this.gridIndexBuffer.destroy(),this.poleSegments.destroy(),this.gridSegments.destroy(),this.atmosphereVertexBuffer.destroy(),this.atmosphereIndexBuffer.destroy(),this.atmosphereSegments.destroy(),this.wireframeIndexBuffer&&(this.wireframeIndexBuffer.destroy(),this.wireframeSegments.destroy())}static createPoleTriangleVertices(h,i,d){var e;const a=new bb,f=i/Math.PI/2;a.emplaceBack(0,-f,0,0,0,.5,d?0:1);const j=360/h,k=Math.cos(85*aP),l=Math.sin(85*aP);for(let b=0;b<=64;b++){const g=b/64,c=lh(k,l,0*(1-(e=g))+j*e,f);a.emplaceBack(c[0],c[1],c[2],0,0,g,d?0:1)}return a}_createPoleTriangleIndices(){const b=new aq;for(let a=0;a<=64;a++)b.emplaceBack(0,a+1,a+2);return b}static createGridVertices(b){const r=Math.pow(2,b.z),[g,h]=lg(b),c=new bb,s=function(e){var b,c;const a=aI(new Float64Array(16)),d=lj(e);return bs(a,a,[d,d,d]),br(a,a,((b=[])[0]=-(c=e.min)[0],b[1]=-c[1],b[2]=-c[2],b)),a}(es(b));c.reserve(4096);for(let d=0;d<65;d++){var i,j,k,l,m,n;const e=(i=g[0],j=h[0],i*(1-(k=d/64))+j*k),o=dA(e),t=o*r-b.y,u=Math.sin(e*aP),v=Math.cos(e*aP);for(let f=0;f<65;f++){const p=f/64,q=(l=g[1],m=h[1],l*(1-(n=p))+m*n),a=lh(v,u,q);bC(a,a,s);const w=dz(q);c.emplaceBack(a[0],a[1],a[2],w,o,p,t)}}return c}_createGridIndices(){const c=new aq,d=(b,d)=>{const a=65*d+b;c.emplaceBack(a+1,a,a+65),c.emplaceBack(a+65,a+65+1,a+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}getWirefameBuffer(b){if(!this.wireframeSegments){const a=this._createWireframeGrid();this.wireframeIndexBuffer=b.createIndexBuffer(a),this.wireframeSegments=ay.simpleSegment(0,0,4096,a.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}_createWireframeGrid(){const c=new Y,d=(b,d)=>{const a=65*d+b;c.emplaceBack(a,a+1),c.emplaceBack(a,a+65),c.emplaceBack(a,a+65+1)};for(let a=0;a<64;a++)for(let b=0;b<64;b++)d(b,a);return c}}function ew(a,b){if(!b.isReprojectedInTileSpace)return{scale:1<<a.z,x:a.x,y:a.y,x2:a.x+1,y2:a.y+1,projection:b};const g=Math.pow(2,-a.z),h=a.x*g,i=(a.x+1)*g,j=a.y*g,k=(a.y+1)*g,s=h7(h),t=h7(i),u=dC(j),v=dC(k),c=b.project(s,u),d=b.project(t,u),e=b.project(t,v),f=b.project(s,v);let o=Math.min(c.x,d.x,e.x,f.x),p=Math.min(c.y,d.y,e.y,f.y),q=Math.max(c.x,d.x,e.x,f.x),r=Math.max(c.y,d.y,e.y,f.y);const m=g/16;function n(i,j,e,f,g,h){const c=(e+g)/2,d=(f+h)/2,a=b.project(h7(c),dC(d)),k=Math.max(0,o-a.x,p-a.y,a.x-q,a.y-r);o=Math.min(o,a.x),q=Math.max(q,a.x),p=Math.min(p,a.y),r=Math.max(r,a.y),k>m&&(n(i,a,e,f,c,d),n(a,j,c,d,g,h))}n(c,d,h,j,i,j),n(d,e,i,j,i,k),n(e,f,i,k,h,k),n(f,c,h,k,h,j),o-=m,p-=m,q+=m,r+=m;const l=1/Math.max(q-o,r-p);return{scale:l,x:o*l,y:p*l,x2:q*l,y2:r*l,projection:b}}class ex{constructor(c){const d={},e=[];for(const f in c){const g=c[f],q=d[f]={};for(const h in g.glyphs){const a=g.glyphs[+h];if(!a||0===a.bitmap.width||0===a.bitmap.height)continue;const i=a.metrics.localGlyph?2:1,j={x:0,y:0,w:a.bitmap.width+2*i,h:a.bitmap.height+2*i};e.push(j),q[h]=j}}const{w:r,h:s}=d3(e),k=new dJ({width:r||1,height:s||1});for(const l in c){const m=c[l];for(const n in m.glyphs){const b=m.glyphs[+n];if(!b||0===b.bitmap.width||0===b.bitmap.height)continue;const o=d[l][n],p=b.metrics.localGlyph?2:1;dJ.copy(b.bitmap,k,{x:0,y:0},{x:o.x+p,y:o.y+p},b.bitmap)}}this.image=k,this.positions=d}}c("GlyphAtlas",ex);class lk{constructor(a){this.tileID=new bn(a.tileID.overscaledZ,a.tileID.wrap,a.tileID.canonical.z,a.tileID.canonical.x,a.tileID.canonical.y),this.tileZoom=a.tileZoom,this.uid=a.uid,this.zoom=a.zoom,this.canonical=a.tileID.canonical,this.pixelRatio=a.pixelRatio,this.tileSize=a.tileSize,this.source=a.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=a.showCollisionBoxes,this.collectResourceTiming=!!a.collectResourceTiming,this.returnDependencies=!!a.returnDependencies,this.promoteId=a.promoteId,this.enableTerrain=!!a.enableTerrain,this.isSymbolTile=a.isSymbolTile,this.tileTransform=ew(a.tileID.canonical,a.projection),this.projection=a.projection}parse(h,v,i,j,E){this.status="parsing",this.data=h,this.collisionBoxArray=new c8;const w=new kV(Object.keys(h.layers).sort()),c=new el(this.tileID,this.promoteId);c.bucketLayerIDs=[];const x={},m=new bl(256,256),d={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:m,availableImages:i},k=v.familiesBySource[this.source];for(const b in k){const e=h.layers[b];if(!e)continue;let n=!1,o=!1;for(const y of k[b])"symbol"===y[0].type?n=!0:o=!0;if(!0===this.isSymbolTile&&!n|| !1===this.isSymbolTile&&!o)continue;1===e.version&&bY(`Vector tile source "${this.source}" layer "${b}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const p=w.encode(b),q=[];for(let f=0;f<e.length;f++){const r=e.feature(f),z=c.getId(r,b);q.push({feature:r,id:z,index:f,sourceLayerIndex:p})}for(const g of k[b]){const a=g[0];void 0!==this.isSymbolTile&&"symbol"===a.type!==this.isSymbolTile||a.minzoom&&this.zoom<Math.floor(a.minzoom)||a.maxzoom&&this.zoom>=a.maxzoom||"none"!==a.visibility&&(ll(g,this.zoom,i),(x[a.id]=a.createBucket({index:c.bucketLayerIDs.length,layers:g,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:p,sourceID:this.source,enableTerrain:this.enableTerrain,availableImages:i})).populate(q,d,this.tileID.canonical,this.tileTransform),c.bucketLayerIDs.push(g.map(a=>a.id)))}}let F,A,B,C;m.trim();const l={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},s=eP(d.glyphDependencies,a=>Object.keys(a).map(Number));Object.keys(s).length?j.send("getGlyphs",{uid:this.uid,stacks:s},(a,b)=>{F||(F=a,A=b,D.call(this))},void 0,!1,l):A={};const t=Object.keys(d.iconDependencies);t.length?j.send("getImages",{icons:t,source:this.source,tileID:this.tileID,type:"icons"},(a,b)=>{F||(F=a,B=b,D.call(this))},void 0,!1,l):B={};const u=Object.keys(d.patternDependencies);function D(){if(F)return E(F);if(A&&B&&C){const b=new ex(A),e=new d4(B,C);for(const f in x){const a=x[f];a instanceof aB?(ll(a.layers,this.zoom,i),ku(a,A,b.positions,B,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection),a.projection=this.projection.name):a.hasPattern&&(a instanceof dX||a instanceof dN||a instanceof dU)&&(ll(a.layers,this.zoom,i),a.addFeatures(d,this.tileID.canonical,e.patternPositions,i))}this.status="done",E(null,{buckets:bQ(x).filter(a=>!a.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:b.image,lineAtlas:m,imageAtlas:e,glyphMap:this.returnDependencies?A:null,iconMap:this.returnDependencies?B:null,glyphPositions:this.returnDependencies?b.positions:null})}}u.length?j.send("getImages",{icons:u,source:this.source,tileID:this.tileID,type:"patterns"},(a,b)=>{F||(F=a,C=b,D.call(this))},void 0,!1,l):C={},D.call(this)}}function ll(a,b,c){const d=new c5(b);for(const e of a)e.recalculate(d,c)}class ey{constructor(a){this.entries={},this.scheduler=a}request(b,d,e,c){const a=this.entries[b]=this.entries[b]||{callbacks:[]};if(a.result){const[f,g]=a.result;return this.scheduler?this.scheduler.add(()=>{c(f,g)},d):c(f,g),()=>{}}return a.callbacks.push(c),a.cancel||(a.cancel=e((c,e)=>{for(const f of(a.result=[c,e],a.callbacks))this.scheduler?this.scheduler.add(()=>{f(c,e)},d):f(c,e);setTimeout(()=>delete this.entries[b],3e3)})),()=>{a.result||(a.callbacks=a.callbacks.filter(a=>a!==c),a.callbacks.length||(a.cancel(),delete this.entries[b]))}}}function ez(a,c,d){const b=JSON.stringify(a.request);return a.data&&(this.deduped.entries[b]={result:[null,a.data]}),this.deduped.request(b,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom},b=>{const c=fi(a.request,(c,a,e,f)=>{c?b(c):a&&b(null,{vectorTile:d?void 0:new _.VectorTile(new d2(a)),rawData:a,cacheControl:e,expires:f})});return()=>{c.cancel(),b()}},c)}const lm=aI(new Float64Array(16));class ln{constructor(a,b){this._tr=a,this._worldSize=b}createInversionMatrix(){return lm}createTileMatrix(e){let a,f,g;const c=e.canonical,b=aI(new Float64Array(16)),h=this._tr.projection;if(h.isReprojectedInTileSpace){const d=ew(c,h);a=1,f=d.x+e.wrap*d.scale,g=d.y,bs(b,b,[a/d.scale,a/d.scale,this._tr.pixelsPerMeter/this._worldSize,])}else a=this._worldSize/this._tr.zoomScale(c.z),f=(c.x+Math.pow(2,c.z)*e.wrap)*a,g=c.y*a;return br(b,b,[f,g,0]),bs(b,b,[a/8192,a/8192,1]),b}pointCoordinate(a,b,c){const d=this._tr.horizonLineFromTop(!1),e=new aF(a,Math.max(d,b));return this._tr.rayIntersectionCoordinate(this._tr.pointRayIntersection(e,c))}upVector(){return[0,0,1]}upVectorScale(){return 1}}var eA={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&&eJ(this.parallels,this.constants.parallels))return;const a=Math.sin(this.parallels[0]*aP),b=(a+Math.sin(this.parallels[1]*aP))/2,c=1+a*(2*b-a),d=Math.sqrt(c)/b;this.constants={n:b,c:c,r0:d,parallels:this.parallels}},project(d,e){this.initializeConstants();const b=(d-this.center[0])*aP,{n:a,c:f,r0:g}=this.constants,c=Math.sqrt(f-2*a*Math.sin(e*aP))/a;return{x:c*Math.sin(b*a),y:c*Math.cos(b*a)-g,z:0}},unproject(c,f){this.initializeConstants();const{n:a,c:g,r0:h}=this.constants,b=h+f;let d=Math.atan2(c,Math.abs(b))*Math.sign(b);b*a<0&&(d-=Math.PI*Math.sign(c)*Math.sign(b));const e=this.center[0]*aP*a;d=bO(d,-Math.PI-e,Math.PI-e);const i=d/a*eK+this.center[0],j=Math.asin(bM((g-(c*c+b*b)*a*a)/(2*a),-1,1)),k=bM(j*eK,-85.051129,85.051129);return new dy(i,k)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const lo=Math.sqrt(3)/2;var eB={name:"equalEarth",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(c,d){d=d/180*Math.PI,c=c/180*Math.PI;const b=Math.asin(lo*Math.sin(d)),a=b*b,e=a*a*a;return{x:.5*(c*Math.cos(b)/(lo*(1.340264+ -0.24331799999999998*a+e*(.0062510000000000005+.034164*a)))/Math.PI+.5),y:1-.5*(b*(1.340264+ -0.081106*a+e*(893e-6+.003796*a))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,a=b*b,c=a*a*a;for(let f,g,h,i=0;i<12&&(g=b*(1.340264+ -0.081106*a+c*(893e-6+.003796*a))-e,h=1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a),f=g/h,b=bM(b-f,-Math.PI/3,Math.PI/3),a=b*b,c=a*a*a,!(1e-12>Math.abs(f)));++i);const j=lo*d*(1.340264+ -0.24331799999999998*a+c*(.0062510000000000005+.034164*a))/Math.cos(b),k=Math.asin(Math.sin(b)/lo),l=bM(180*j/Math.PI,-180,180),m=bM(180*k/Math.PI,-85.051129,85.051129);return new dy(l,m)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)},eC={name:"equirectangular",supportsWorldCopies:!0,center:[0,0],range:[3.5,7],zAxisUnit:"meters",wrap:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project:(a,b)=>({x:.5+a/360,y:.5-b/360,z:0}),unproject(a,b){const c=bM(360*(.5-b),-85.051129,85.051129);return new dy(360*(a-.5),c)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const lp=Math.PI/2;function lq(a){return Math.tan((lp+a)/2)}var lr,eD={name:"lambertConformalConic",range:[3.5,7],zAxisUnit:"meters",center:[0,30],parallels:[30,30],conic:!0,isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],initializeConstants(){if(this.constants&&eJ(this.parallels,this.constants.parallels))return;const a=this.parallels[0]*aP,b=this.parallels[1]*aP,d=Math.cos(a),c=a===b?Math.sin(a):Math.log(d/Math.cos(b))/Math.log(lq(b)/lq(a)),e=d*Math.pow(lq(a),c)/c;this.constants={n:c,f:e,parallels:this.parallels}},project(b,a){this.initializeConstants(),a*=aP,b=(b-this.center[0])*aP;const{n:c,f:d}=this.constants;d>0?a< -lp+1e-6&&(a=-lp+1e-6):a>lp-1e-6&&(a=lp-1e-6);const e=d/Math.pow(lq(a),c),f=e*Math.sin(c*b),g=d-e*Math.cos(c*b);return{x:.5*(f/Math.PI+.5),y:1-.5*(g/Math.PI+.5),z:0}},unproject(a,d){this.initializeConstants(),a=(2*a-.5)*Math.PI,d=(2*(1-d)-.5)*Math.PI;const{n:c,f:e}=this.constants,b=e-d,f=Math.sign(b),h=Math.sign(c)*Math.sqrt(a*a+b*b);let g=Math.atan2(a,Math.abs(b))*f;b*c<0&&(g-=Math.PI*Math.sign(a)*f);const i=bM(g/c*eK+this.center[0],-180,180),j=bM((2*Math.atan(Math.pow(e/h,1/c))-lp)*eK,-85.051129,85.051129);return new dy(i,j)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)},eE={name:"mercator",wrap:!0,requiresDraping:!1,supportsWorldCopies:!0,supportsTerrain:!0,supportsFog:!0,supportsFreeCamera:!0,zAxisUnit:"meters",center:[0,0],project:(a,b)=>({x:dz(a),y:dA(b),z:0}),unproject(a,b){const c=h7(a),d=dC(b);return new dy(c,d)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const ls=85.051129*aP;var eF={name:"naturalEarth",center:[0,0],range:[3.5,7],isReprojectedInTileSpace:!0,zAxisUnit:"meters",unsupportedLayers:["custom"],project(d,c){const a=(c*=aP)*c,b=a*a;return{x:.5*((d*=aP)*(.8707-.131979*a+b*(b*(.003971*a-.001529*b)-.013791))/Math.PI+.5),y:1-.5*(c*(1.007226+a*(.015085+b*(.028874*a-.044475-.005916*b)))/Math.PI+1),z:0}},unproject(d,e){d=(2*d-.5)*Math.PI;let b=e=(2*(1-e)-1)*Math.PI,g=25,f=0,a=b*b;do{a=b*b;const c=a*a;f=(b*(1.007226+a*(.015085+c*(.028874*a-.044475-.005916*c)))-e)/(1.007226+a*(.045255+c*(.259866*a-.311325-.06507600000000001*c))),b=bM(b-f,-ls,ls)}while(Math.abs(f)>1e-6&& --g>0)a=b*b;const h=bM(d/(.8707+a*(a*(a*a*a*(.003971-.001529*a)-.013791)-.131979))*eK,-180,180),i=b*eK;return new dy(h,i)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)};const lt=85.051129*aP,lu={albers:eA,equalEarth:eB,equirectangular:eC,lambertConformalConic:eD,mercator:eE,naturalEarth:eF,winkelTripel:{name:"winkelTripel",center:[0,0],range:[3.5,7],zAxisUnit:"meters",isReprojectedInTileSpace:!0,unsupportedLayers:["custom"],project(a,b){b*=aP,a*=aP;const c=Math.cos(b),d=Math.acos(c*Math.cos(a/2)),e=Math.sin(d)/d,f=.5*(a*(2/Math.PI)+2*c*Math.sin(a/2)/e)||0,g=.5*(b+Math.sin(b)/e)||0;return{x:.5*(f/Math.PI+.5),y:1-.5*(g/Math.PI+1),z:0}},unproject(j,k){let b=j=(2*j-.5)*Math.PI,c=k=(2*(1-k)-1)*Math.PI,z=25,l=0,m=0;do{const a=Math.cos(c),d=Math.sin(c),o=2*d*a,p=d*d,n=a*a,e=Math.cos(b/2),f=Math.sin(b/2),q=2*e*f,r=f*f,h=1-n*e*e,i=h?1/h:0,g=h?Math.acos(a*e)*Math.sqrt(1/h):0,s=.5*(2*g*a*f+2*b/Math.PI)-j,t=.5*(g*d+c)-k,u=.5*i*(n*r+g*a*e*p)+1/Math.PI,v=i*(q*o/4-g*d*f),w=.125*i*(o*f-g*d*n*q),x=.5*i*(p*e+g*r*a)+.5,y=v*w-x*u;l=(t*v-s*x)/y,m=(s*w-t*u)/y,b=bM(b-l,-Math.PI,Math.PI),c=bM(c-m,-lt,lt)}while((Math.abs(l)>1e-6||Math.abs(m)>1e-6)&& --z>0)return new dy(b*eK,c*eK)},projectTilePoint:(a,b)=>({x:a,y:b,z:0}),locationPoint:(a,b)=>a._coordinatePoint(a.locationCoordinate(b),!1),pixelsPerMeter:(a,b)=>dB(1,a)*b,farthestPixelDistance(a){return le(a,this.pixelsPerMeter(a.center.lat,a.worldSize))},createTileTransform:(a,b)=>new ln(a,b)}};a.ARRAY_TYPE=I,a.AUTH_ERR_MSG=b1,a.Aabb=B,a.Actor=class{constructor(a,b,c){this.target=a,this.parent=b,this.mapId=c,this.callbacks={},this.cancelCallbacks={},bU(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=bZ()?a:s,this.scheduler=new class{constructor(){this.tasks={},this.taskQueue=[],bU(["process"],this),this.invoker=new class{constructor(a){this._callback=a,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=()=>{}}}(this.process),this.nextId=0}add(b,c){const a=this.nextId++,d=function({type:b,isSymbolTile:c,zoom:a}){return a=a||0,"message"===b?0:"maybePrepare"!==b||c?"parseTile"!==b||c?"parseTile"===b&&c?300-a:"maybePrepare"===b&&c?400-a:500:200-a:100-a}(c);return 0===d?(bZ(),b(),{cancel(){}}):(this.tasks[a]={fn:b,metadata:c,priority:d,id:a},this.taskQueue.push(a),this.invoker.trigger(),{cancel:()=>{delete this.tasks[a]}})}process(){bZ();{if(this.taskQueue=this.taskQueue.filter(a=>!!this.tasks[a]),!this.taskQueue.length)return;const a=this.pick();if(null===a)return;const b=this.tasks[a];if(delete this.tasks[a],this.taskQueue.length&&this.invoker.trigger(),!b)return;b.fn()}}pick(){let a=null,c=1/0;for(let b=0;b<this.taskQueue.length;b++){const d=this.tasks[this.taskQueue[b]];d.priority<c&&(c=d.priority,a=b)}if(null===a)return null;const e=this.taskQueue[a];return this.taskQueue.splice(a,1),e}remove(){this.invoker.remove()}}}send(d,e,a,f,g=!1,h){const b=Math.round(1e18*Math.random()).toString(36).substring(0,10);a&&(a.metadata=h,this.callbacks[b]=a);const c=eX(this.globalScope)?void 0:[];return this.target.postMessage({id:b,type:d,hasCallback:!!a,targetMapId:f,mustQueue:g,sourceMapId:this.mapId,data:g_(e,c)},c),{cancel:()=>{a&&delete this.callbacks[b],this.target.postMessage({id:b,type:"<cancel>",targetMapId:f,sourceMapId:this.mapId})}}}receive(e){const a=e.data,b=a.id;if(b&&(!a.targetMapId||this.mapId===a.targetMapId)){if("<cancel>"===a.type){const c=this.cancelCallbacks[b];delete this.cancelCallbacks[b],c&&c.cancel()}else if(a.mustQueue||bZ()){const d=this.callbacks[b];this.cancelCallbacks[b]=this.scheduler.add(()=>this.processTask(b,a),d&&d.metadata||{type:"message"})}else this.processTask(b,a)}}processTask(e,a){if("<response>"===a.type){const b=this.callbacks[e];delete this.callbacks[e],b&&(a.error?b(g0(a.error)):b(null,g0(a.data)))}else{const g=eX(this.globalScope)?void 0:[],c=a.hasCallback?(a,b)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"<response>",sourceMapId:this.mapId,error:a?g_(a):null,data:g_(b,g)},g)}:a=>{},d=g0(a.data);if(this.parent[a.type])this.parent[a.type](a.sourceMapId,d,c);else if(this.parent.getWorkerSource){const f=a.type.split(".");this.parent.getWorkerSource(a.sourceMapId,f[0],d.source)[f[1]](d,c)}else c(Error(`Could not find function ${a.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},a.CanonicalTileID=bm,a.Color=m,a.ColorMode=r,a.CullFaceMode=o,a.DEMData=bo,a.DataConstantProperty=e,a.DedupedRequest=ey,a.DepthMode=C,a.EXTENT=8192,a.Elevation=class{getAtPointOrZero(a,b=0){return this.getAtPoint(a,b)||0}getAtPoint(a,f,o=!0){null==f&&(f=null);const i=this._source();if(!i||a.y<0||a.y>1)return f;const g=i.getSource().maxzoom,j=1<<g,k=Math.floor(a.x),l=a.x-k,p=new bn(g,k,g,Math.floor(l*j),Math.floor(a.y*j)),b=this.findDEMTileFor(p);if(!b||!b.dem)return f;const c=b.dem,m=1<<b.tileID.canonical.z,n=(l*m-b.tileID.canonical.x)*c.dim,h=(a.y*m-b.tileID.canonical.y)*c.dim,e=Math.floor(n),d=Math.floor(h);return(o?this.exaggeration():1)*aY(aY(c.get(e,d),c.get(e,d+1),h-d),aY(c.get(e+1,d),c.get(e+1,d+1),h-d),n-e)}getAtTileOffset(a,c,d){const b=1<<a.canonical.z;return this.getAtPointOrZero(new dD(a.wrap+(a.canonical.x+c/8192)/b,(a.canonical.y+d/8192)/b))}getAtTileOffsetFunc(a,b){return c=>{const e=this.getAtTileOffset(a,c.x,c.y),d=b.upVector(a.canonical,c.x,c.y);return bx(d,d,e*b.upVectorScale(a.canonical)),d}}getForTilePoints(a,b,e,c){const d=k4.create(this,a,c);return!!d&&(b.forEach(a=>{a[2]=this.exaggeration()*d.getElevationAt(a[0],a[1],e)}),!0)}getMinMaxForTile(a){const c=this.findDEMTileFor(a);if(!c||!c.dem)return null;const d=c.dem.tree,e=c.tileID,h=1<<a.canonical.z-e.canonical.z;let f=a.canonical.x/h-e.canonical.x,g=a.canonical.y/h-e.canonical.y,b=0;for(let i=0;i<a.canonical.z-e.canonical.z&&!d.leaves[b];i++){f*=2,g*=2;const j=2*Math.floor(g)+Math.floor(f);b=d.childOffsets[b]+j,f%=1,g%=1}return{min:this.exaggeration()*d.minimums[b],max:this.exaggeration()*d.maximums[b]}}getMinElevationBelowMSL(){throw Error("Pure virtual method called.")}raycast(a,b,c){throw Error("Pure virtual method called.")}pointCoordinate(a){throw Error("Pure virtual method called.")}_source(){throw Error("Pure virtual method called.")}exaggeration(){throw Error("Pure virtual method called.")}findDEMTileFor(a){throw Error("Pure virtual method called.")}get visibleDemTiles(){throw Error("Getter must be implemented in subclass.")}},a.ErrorEvent=cb,a.EvaluationParameters=c5,a.Event=aW,a.Evented=S,a.Frustum=dH,a.GLOBE_ZOOM_THRESHOLD_MAX=6,a.GlobeSharedBuffers=ev,a.GlyphManager=aA,a.ImagePosition=bj,a.LineAtlas=bl,a.LngLat=dy,a.LngLatBounds=dx,a.LocalGlyphMode=d9,a.MAX_MERCATOR_LATITUDE=85.051129,a.MercatorCoordinate=dD,a.ONE_EM=24,a.OverscaledTileID=bn,a.Properties=n,a.RGBAImage=bg,a.Ray=class{constructor(a,b){this.pos=a,this.dir=b}intersectsPlane(b,a,c){const e=bA(a,this.dir);if(1e-6>Math.abs(e))return!1;const d=((b[0]-this.pos[0])*a[0]+(b[1]-this.pos[1])*a[1]+(b[2]-this.pos[2])*a[2])/e;return c[0]=this.pos[0]+this.dir[0]*d,c[1]=this.pos[1]+this.dir[1]*d,c[2]=this.pos[2]+this.dir[2]*d,!0}closestPointOnSphere(i,b,a){var j,k,n,o,p,q,r,s;if(j=this.pos,k=i,n=j[0],o=j[1],p=j[2],q=k[0],r=k[1],s=k[2],Math.abs(n-q)<=1e-6*Math.max(1,Math.abs(n),Math.abs(q))&&Math.abs(o-r)<=1e-6*Math.max(1,Math.abs(o),Math.abs(r))&&Math.abs(p-s)<=1e-6*Math.max(1,Math.abs(p),Math.abs(s))||0===b)return a[0]=a[1]=a[2]=0,!1;const[f,g,h]=this.dir,c=this.pos[0]-i[0],d=this.pos[1]-i[1],e=this.pos[2]-i[2],w=f*f+g*g+h*h,l=2*(c*f+d*g+e*h),x=l*l-4*w*(c*c+d*d+e*e-b*b);if(x<0){const t=Math.max(-l/2,0),y=c+f*t,z=d+g*t,A=e+h*t,u=Math.hypot(y,z,A);return a[0]=y*b/u,a[1]=z*b/u,a[2]=A*b/u,!1}{const m=(-l-Math.sqrt(x))/(2*w);if(m<0){const v=Math.hypot(c,d,e);return a[0]=c*b/v,a[1]=d*b/v,a[2]=e*b/v,!1}return a[0]=c+f*m,a[1]=d+g*m,a[2]=e+h*m,!0}}},a.RequestManager=class{constructor(a,b,c){this._transformRequestFn=a,this._customAccessToken=b,this._silenceAuthErrors=!!c,this._createSkuToken()}_createSkuToken(){const a=function(){let a="";for(let b=0;b<10;b++)a+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1","01",a].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=a.token,this._skuTokenExpiresAt=a.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(a,b){return this._transformRequestFn&&this._transformRequestFn(a,b)||{url:a}}normalizeStyleURL(a,c){if(!b2(a))return a;const b=e4(a);return b.path=`/styles/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeGlyphsURL(a,c){if(!b2(a))return a;const b=e4(a);return b.path=`/fonts/v1${b.path}`,this._makeAPIURL(b,this._customAccessToken||c)}normalizeSourceURL(b,c){if(!b2(b))return b;const a=e4(b);return a.path=`/v4/${a.authority}.json`,a.params.push("secure"),this._makeAPIURL(a,this._customAccessToken||c)}normalizeSpriteURL(b,c,d,e){const a=e4(b);return b2(b)?(a.path=`/styles/v1${a.path}/sprite${c}${d}`,this._makeAPIURL(a,this._customAccessToken||e)):(a.path+=`${c}${d}`,e5(a))}normalizeTileURL(b,e,c){if(this._isSkuTokenExpired()&&this._createSkuToken(),b&&!b2(b))return b;const a=e4(b);a.path=a.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||c&&"raster"!==a.authority&&512===c?"@2x":""}${b0.supported?".webp":"$1"}`),"raster"===a.authority?a.path=`/${b_.RASTER_URL_PREFIX}${a.path}`:(a.path=a.path.replace(/^.+\/v4\//,"/"),a.path=`/${b_.TILE_URL_VERSION}${a.path}`);const d=this._customAccessToken||function(b){for(const c of b){const a=c.match(/^access_token=(.*)$/);if(a)return a[1]}return null}(a.params)||b_.ACCESS_TOKEN;return b_.REQUIRE_ACCESS_TOKEN&&d&&this._skuToken&&a.params.push(`sku=${this._skuToken}`),this._makeAPIURL(a,d)}canonicalizeTileURL(d,e){const a=e4(d);if(!a.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!a.path.match(/\.[\w]+$/))return d;let b="mapbox://";a.path.match(/^\/raster\/v1\//)?b+=`raster/${a.path.replace(`/${b_.RASTER_URL_PREFIX}/`,"")}`:b+=`tiles/${a.path.replace(`/${b_.TILE_URL_VERSION}/`,"")}`;let c=a.params;return e&&(c=c.filter(a=>!a.match(/^access_token=/))),c.length&&(b+=`?${c.join("&")}`),b}canonicalizeTileset(d,c){const e=!!c&&b2(c),a=[];for(const b of d.tiles||[])e2(b)?a.push(this.canonicalizeTileURL(b,e)):a.push(b);return a}_makeAPIURL(a,b){const d="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",c=e4(b_.API_URL);if(a.protocol=c.protocol,a.authority=c.authority,"http"===a.protocol){const e=a.params.indexOf("secure");e>=0&&a.params.splice(e,1)}if("/"!==c.path&&(a.path=`${c.path}${a.path}`),!b_.REQUIRE_ACCESS_TOKEN)return e5(a);if(b=b||b_.ACCESS_TOKEN,!this._silenceAuthErrors){if(!b)throw Error(`An API access token is required to use Mapbox GL. ${d}`);if("s"===b[0])throw Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${d}`)}return a.params=a.params.filter(a=>-1===a.indexOf("access_token")),a.params.push(`access_token=${b||""}`),e5(a)}},a.ResourceType=aV,a.SegmentVector=ay,a.SourceCache=aD,a.StencilMode=aC,a.StructArrayLayout1ui2=av,a.StructArrayLayout2f1f2i16=ap,a.StructArrayLayout2i4=al,a.StructArrayLayout2ui4=Y,a.StructArrayLayout3f12=an,a.StructArrayLayout3ui6=aq,a.StructArrayLayout4i8=am,a.Texture=eh,a.Tile=eq,a.Transitionable=c6,a.Uniform1f=dl,a.Uniform1i=class extends ax{constructor(a,b){super(a,b),this.current=0}set(a){this.current!==a&&(this.current=a,this.gl.uniform1i(this.location,a))}},a.Uniform2f=class extends ax{constructor(a,b){super(a,b),this.current=[0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]||(this.current=a,this.gl.uniform2f(this.location,a[0],a[1]))}},a.Uniform3f=class extends ax{constructor(a,b){super(a,b),this.current=[0,0,0]}set(a){a[0]===this.current[0]&&a[1]===this.current[1]&&a[2]===this.current[2]||(this.current=a,this.gl.uniform3f(this.location,a[0],a[1],a[2]))}},a.Uniform4f=dm,a.UniformColor=dn,a.UniformMatrix2f=class extends ax{constructor(a,b){super(a,b),this.current=hY}set(b){for(let a=0;a<4;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix2fv(this.location,!1,b);break}}},a.UniformMatrix3f=class extends ax{constructor(a,b){super(a,b),this.current=hX}set(b){for(let a=0;a<9;a++)if(b[a]!==this.current[a]){this.current=b,this.gl.uniformMatrix3fv(this.location,!1,b);break}}},a.UniformMatrix4f=class extends ax{constructor(a,b){super(a,b),this.current=hW}set(a){if(a[12]!==this.current[12]||a[0]!==this.current[0])return this.current=a,void this.gl.uniformMatrix4fv(this.location,!1,a);for(let b=1;b<16;b++)if(a[b]!==this.current[b]){this.current=a,this.gl.uniformMatrix4fv(this.location,!1,a);break}}},a.UnwrappedTileID=ej,a.ValidationError=cc,a.VectorTileWorkerSource=class extends S{constructor(a,b,c,d,e){super(),this.actor=a,this.layerIndex=b,this.availableImages=c,this.loadVectorData=e||ez,this.loading={},this.loaded={},this.deduped=new ey(a.scheduler),this.isSpriteLoaded=d,this.scheduler=a.scheduler}loadTile(a,e){const c=a.uid,b=a&&a.request,f=b&&b.collectResourceTiming,d=this.loading[c]=new lk(a);d.abort=this.loadVectorData(a,(h,g)=>{const i=!this.loading[c];if(delete this.loading[c],i||h||!g)return d.status="done",i||(this.loaded[c]=d),e(h);const k=g.rawData,j={};g.expires&&(j.expires=g.expires),g.cacheControl&&(j.cacheControl=g.cacheControl),d.vectorTile=g.vectorTile||new _.VectorTile(new d2(k));const l=()=>{d.parse(d.vectorTile,this.layerIndex,this.availableImages,this.actor,(a,c)=>{if(a||!c)return e(a);const d={};if(f){const g=ei(b);g.length>0&&(d.resourceTiming=JSON.parse(JSON.stringify(g)))}e(null,bR({rawTileData:k.slice(0)},c,j,d))})};this.isSpriteLoaded?l():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(l,{type:"parseTile",isSymbolTile:a.isSymbolTile,zoom:a.tileZoom}):l()}),this.loaded=this.loaded||{},this.loaded[c]=d})}reloadTile(b,f){const c=this.loaded,e=b.uid,g=this;if(c&&c[e]){const a=c[e];a.showCollisionBoxes=b.showCollisionBoxes,a.enableTerrain=!!b.enableTerrain,a.projection=b.projection;const d=(c,d)=>{const b=a.reloadCallback;b&&(delete a.reloadCallback,a.parse(a.vectorTile,g.layerIndex,this.availableImages,g.actor,b)),f(c,d)};"parsing"===a.status?a.reloadCallback=d:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,d):d())}}abortTile(c,d){const b=c.uid,a=this.loading[b];a&&(a.abort&&a.abort(),delete this.loading[b]),d()}removeTile(c,d){const a=this.loaded,b=c.uid;a&&a[b]&&delete a[b],d()}},a.WritingMode=d5,a.ZoomHistory=c0,a.add=bw,a.addDynamicAttributes=bk,a.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},a.asyncAll=bP,a.bezier=aQ,a.bindAll=bU,a.boundsAttributes=ep,a.bufferConvexPolygon=function(a,g){const e=[];for(let b=0;b<a.length;b++){const h=bO(b-1,-1,a.length-1),i=bO(b+1,-1,a.length-1),c=a[b],j=a[i],d=a[h].sub(c).unit(),f=j.sub(c).unit(),k=f.angleWithSep(d.x,d.y),l=d.add(f).unit().mult(-1*g/Math.sin(k/2));e.push(c.add(l))}return e},a.cacheEntryPossiblyAdded=function(a){++fg>fd&&(a.getActor().send("enforceCacheSizeLimit",fc),fg=0)},a.calculateGlobeMatrix=eu,a.calculateGlobeMercatorMatrix=function(a){const c=a.worldSize,f=bM(a.center.lat,-85.051129,85.051129),d=new aF(dz(a.center.lng)*c,dA(f)*c),g=dB(1,a.center.lat)*c,h=a.pixelsPerMeter,e=c/(g/a.pixelsPerMeter),b=aI(new Float64Array(16));return br(b,b,[d.x,d.y,0]),bs(b,b,[e,e,h]),b},a.clamp=bM,a.clearTileCache=function(a){const b=s.caches.delete(e9);a&&b.catch(a).then(()=>a())},a.clipLine=d8,a.clone=function(b){var a=new I(16);return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},a.clone$1=bX,a.collisionCircleLayout=d_,a.config=b_,a.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},a.create=function(){var a=new I(16);return I!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=0,a[12]=0,a[13]=0,a[14]=0),a[0]=1,a[5]=1,a[10]=1,a[15]=1,a},a.create$1=aH,a.createExpression=cN,a.createLayout=j,a.createStyleLayer=function(a){return"custom"===a.type?new kJ(a):new kM[a.type](a)},a.cross=bB,a.degToRad=bI,a.div=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},a.dot=bA,a.ease=bL,a.easeCubicInOut=bK,a.emitValidationErrors=c_,a.endsWith=bV,a.enforceCacheSizeLimit=function(a){fe(),fa&&fa.then(b=>{b.keys().then(d=>{for(let c=0;c<d.length-a;c++)b.delete(d[c])})})},a.evaluateSizeForFeature=bh,a.evaluateSizeForZoom=bi,a.evaluateVariableOffset=ea,a.evented=c2,a.exactEquals=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]},a.exactEquals$1=function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]},a.exported=b$,a.exported$1=b0,a.extend=bR,a.extend$1=ce,a.filterObject=bW,a.fromMat4=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[4],a[4]=b[5],a[5]=b[6],a[6]=b[8],a[7]=b[9],a[8]=b[10],a},a.fromQuat=function(a,c){var f=c[0],d=c[1],b=c[2],g=c[3],e=f+f,h=d+d,i=b+b,j=f*e,k=d*e,l=d*h,m=b*e,n=b*h,o=b*i,p=g*e,q=g*h,r=g*i;return a[0]=1-l-o,a[1]=k+r,a[2]=m-q,a[3]=0,a[4]=k-r,a[5]=1-j-o,a[6]=n+p,a[7]=0,a[8]=m+q,a[9]=n-p,a[10]=1-j-l,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},a.fromRotation=function(a,b){var c=Math.sin(b),d=Math.cos(b);return a[0]=d,a[1]=c,a[2]=0,a[3]=-c,a[4]=d,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},a.fromScaling=function(a,b){return a[0]=b[0],a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=b[1],a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=b[2],a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},a.furthestTileCorner=function(a){return eL[Math.round((a+45+360)%360/90)%4]},a.getAABBPointSquareDist=function(c,d,f){let e=0;for(let a=0;a<2;++a){const b=f?f[a]:0;c[a]>b&&(e+=(c[a]-b)*(c[a]-b)),d[a]<b&&(e+=(b-d[a])*(b-d[a]))}return e},a.getAnchorAlignment=d6,a.getAnchorJustification=eb,a.getBounds=function(f){let b=1/0,c=1/0,d=-1/0,e=-1/0;for(const a of f)b=Math.min(b,a.x),c=Math.min(c,a.y),d=Math.max(d,a.x),e=Math.max(e,a.y);return{min:new aF(b,c),max:new aF(d,e)}},a.getColumn=function(a,b){return[a[4*b],a[4*b+1],a[4*b+2],a[4*b+3],]},a.getImage=ca,a.getJSON=function(a,b){return b7(bR(a,{type:"json"}),b)},a.getMapSessionAPI=b5,a.getPerformanceMeasurement=ei,a.getProjection=function(b){const a=lu[b.name];if(!a)throw Error(`Invalid projection name: ${b.name}`);return a.conic?function(b,a){if(a.parallels&&.01>Math.abs(a.parallels[0]+a.parallels[1])){let c=function(b){const a=Math.max(.01,Math.cos(b*aP)),c=1/(2*Math.max(Math.PI*a,1/a));return{wrap:!0,supportsWorldCopies:!0,unsupportedLayers:["custom",],project(b,d){const e=b*aP*a,f=Math.sin(d*aP)/a;return{x:e*c+.5,y:-f*c+.5,z:0}},unproject(b,d){const e=-(d-.5)/c,f=bM((b-.5)/c*eK/a,-180,180),g=Math.asin(bM(e*a,-1,1)),h=bM(g*eK,-85.051129,85.051129);return new dy(f,h)}}}(a.parallels[0]);if("lambertConformalConic"===a.name){const{project:d,unproject:e}=lu.mercator;c={wrap:!0,supportsWorldCopies:!0,project:d,unproject:e}}return bR({},b,a,c)}return bR({},b,a)}(a,b):a},a.getRTLTextPluginStatus=c3,a.getReferrer=b6,a.getTilePoint=function(a,{x:b,y:c},d=0){return new aF(((b-d)*a.scale-a.x)*8192,(c*a.scale-a.y)*8192)},a.getTileVec3=function(a,b,c=0){return Q(((b.x-c)*a.scale-a.x)*8192,(b.y*a.scale-a.y)*8192,h8(b.z,b.y))},a.getVideo=function(c,e){const a=s.document.createElement("video");a.muted=!0,a.onloadstart=function(){e(null,a)};for(let b=0;b<c.length;b++){const d=s.document.createElement("source");fl(c[b])||(a.crossOrigin="Anonymous"),d.src=c[b],a.appendChild(d)}return{cancel(){}}},a.globeBuffersForTileMesh=function(d,a,e,f){const g=d.context,h=d.transform;let b=a.globeGridBuffer,c=a.globePoleBuffer;if(!b){const i=ev.createGridVertices(e.canonical);b=a.globeGridBuffer=g.createVertexBuffer(i,ld,!1)}if(!c){const j=ev.createPoleTriangleVertices(f,h.tileSize*f,0===e.canonical.y);c=a.globePoleBuffer=g.createVertexBuffer(j,ld,!1)}return[b,c]},a.globeDenormalizeECEF=et,a.globeMatrixForTile=function(d,e){var a,b;const f=et(es(d)),c=((a=new Float64Array(16))[0]=(b=e)[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a);return bv(c,c,f),c},a.globePoleMatrixForTile=function(e,g,b){const a=aI(new Float64Array(16)),c=Math.pow(2,e.z),h=(e.x-c/2)/c*Math.PI*2,f=b.point,d=b.worldSize/(b.tileSize*c);return br(a,a,[f.x,f.y,-b.worldSize/Math.PI/2,]),bs(a,a,[d,d,d]),bt(a,a,-b._center.lat*aP),bu(a,a,-b._center.lng*aP),bu(a,a,h),g&&bs(a,a,[1,-1,1]),a},a.globeTileBounds=es,a.globeToMercatorTransition=function(a){return bN(5,6,a)},a.identity=aI,a.identity$1=bG,a.invert=function(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],i=c[5],j=c[6],k=c[7],l=c[8],m=c[9],n=c[10],o=c[11],p=c[12],q=c[13],r=c[14],s=c[15],t=d*i-e*h,u=d*j-f*h,v=d*k-g*h,w=e*j-f*i,x=e*k-g*i,y=f*k-g*j,z=l*q-m*p,A=l*r-n*p,B=l*s-o*p,C=m*r-n*q,D=m*s-o*q,E=n*s-o*r,a=t*E-u*D+v*C+w*B-x*A+y*z;return a?(b[0]=(i*E-j*D+k*C)*(a=1/a),b[1]=(f*D-e*E-g*C)*a,b[2]=(q*y-r*x+s*w)*a,b[3]=(n*x-m*y-o*w)*a,b[4]=(j*B-h*E-k*A)*a,b[5]=(d*E-f*B+g*A)*a,b[6]=(r*v-p*y-s*u)*a,b[7]=(l*y-n*v+o*u)*a,b[8]=(h*D-i*B+k*z)*a,b[9]=(e*B-d*D-g*z)*a,b[10]=(p*x-q*v+s*t)*a,b[11]=(m*v-l*x-o*t)*a,b[12]=(i*A-h*C-j*z)*a,b[13]=(d*C-e*A+f*z)*a,b[14]=(q*u-p*w-r*t)*a,b[15]=(l*w-m*u+n*t)*a,b):null},a.isMapAuthenticated=function(a){return e8.has(a)},a.isMapboxURL=b2,a.latFromMercatorY=dC,a.len=aL,a.length=aL,a.length$1=function(a){return Math.hypot(a[0],a[1],a[2],a[3])},a.loadVectorTile=ez,a.makeRequest=b7,a.mercatorXfromLng=dz,a.mercatorYfromLat=dA,a.mercatorZfromAltitude=dB,a.mul=bv,a.mul$1=aN,a.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},a.multiply$1=aJ,a.multiply$2=aN,a.nextPowerOfTwo=bT,a.normalize=bz,a.normalize$1=function(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],a=d*d+e*e+f*f+g*g;return a>0&&(a=1/Math.sqrt(a)),b[0]=d*a,b[1]=e*a,b[2]=f*a,b[3]=g*a,b},a.number=aY,a.ortho=function(a,b,c,d,e,f,g){var h=1/(b-c),i=1/(d-e),j=1/(f-g);return a[0]=-2*h,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=-2*i,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=2*j,a[11]=0,a[12]=(b+c)*h,a[13]=(e+d)*i,a[14]=(g+f)*j,a[15]=1,a},a.pbf=d2,a.perspective=function(a,f,g,c,b){var d,e=1/Math.tan(f/2);return a[0]=e/g,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=e,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[11]=-1,a[12]=0,a[13]=0,a[15]=0,null!=b&&b!==1/0?(a[10]=(b+c)*(d=1/(c-b)),a[14]=2*b*c*d):(a[10]=-1,a[14]=-2*c),a},a.pick=function(c,d){const e={};for(let a=0;a<d.length;a++){const b=d[a];b in c&&(e[b]=c[b])}return e},a.plugin=c4,a.pointGeometry=aF,a.polygonIntersectsBox=dF,a.polygonIntersectsPolygon=dE,a.polygonizeBounds=function(f,g,c=0,h=!0){const d=new aF(c,c),a=f.sub(d),b=g.add(d),e=[a,new aF(b.x,a.y),b,new aF(a.x,b.y),];return h&&e.push(a),e},a.posAttributes=em,a.postMapLoadEvent=b4,a.postTurnstileEvent=b3,a.potpack=d3,a.prevPowerOfTwo=function(a){return a<=1?1:Math.pow(2,Math.floor(Math.log(a)/Math.LN2))},a.radToDeg=bJ,a.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout",],a.registerForPluginStateChange=function(a){return a({pluginStatus:hE,pluginURL:hF}),c2.on("pluginStateChange",a),a},a.removeAuthState=function(a){e8.delete(a)},a.renderColorRamp=dK,a.rotateX=bt,a.rotateX$1=bH,a.rotateY=bu,a.rotateZ=function(a,b,e){var c=Math.sin(e),d=Math.cos(e),f=b[0],g=b[1],h=b[2],i=b[3],j=b[4],k=b[5],l=b[6],m=b[7];return b!==a&&(a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]),a[0]=f*d+j*c,a[1]=g*d+k*c,a[2]=h*d+l*c,a[3]=i*d+m*c,a[4]=j*d-f*c,a[5]=k*d-g*c,a[6]=l*d-h*c,a[7]=m*d-i*c,a},a.rotateZ$1=function(a,b,e){e*=.5;var f=b[0],g=b[1],h=b[2],i=b[3],c=Math.sin(e),d=Math.cos(e);return a[0]=f*d+g*c,a[1]=g*d-f*c,a[2]=h*d+i*c,a[3]=i*d-h*c,a},a.scale=bs,a.scale$1=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a},a.scale$2=bx,a.scaleAndAdd=by,a.setCacheLimits=function(a,b){fc=a,fd=b},a.setColumn=function(a,b,c){a[4*b+0]=c[0],a[4*b+1]=c[1],a[4*b+2]=c[2],a[4*b+3]=c[3]},a.setRTLTextPlugin=function(a,b,c=!1){if(hE===hA||hE===hB||hE===hC)throw Error("setRTLTextPlugin cannot be called multiple times.");hF=b$.resolveURL(a),hE=hA,hD=b,hG(),c||hH()},a.smoothstep=bN,a.spec=b,a.storeAuthState=function(a,b){b?e8.add(a):e8.delete(a)},a.sub=bE,a.subtract=aM,a.symbolSize=d1,a.tileAABB=function(p,d,l,m,n,h,q,r,o){var i,f,g;if("globe"===o.name){const e=es(new ej(h,new bm(l,m,n)).canonical).getCorners(),b=Number.MAX_VALUE,j=[-b,-b,-b],k=[b,b,b],s=eu(p,d);for(let c=0;c<e.length;c++)bC(e[c],e[c],s),f=k,g=e[c],(i=k)[0]=Math.min(f[0],g[0]),i[1]=Math.min(f[1],g[1]),i[2]=Math.min(f[2],g[2]),eI(j,j,e[c]);return new B(k,j)}const a=ew({z:l,x:m,y:n},o);return new B([(h+a.x/a.scale)*d,d*(a.y/a.scale),q,],[(h+a.x2/a.scale)*d,d*(a.y2/a.scale),r,])},a.tileTransform=ew,a.transformMat3=function(b,c,a){var d=c[0],e=c[1],f=c[2];return b[0]=d*a[0]+e*a[3]+f*a[6],b[1]=d*a[1]+e*a[4]+f*a[7],b[2]=d*a[2]+e*a[5]+f*a[8],b},a.transformMat4=bC,a.transformMat4$1=bF,a.transformQuat=bD,a.translate=br,a.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[5];a[1]=b[3],a[2]=b[6],a[3]=c,a[5]=b[7],a[6]=d,a[7]=e}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8];return a},a.triggerPluginCompletionEvent=c1,a.uniqueId=bS,a.validateCustomStyleLayer=function(a){const b=[],c=a.id;return void 0===c&&b.push({message:`layers.${c}: missing required property "id"`}),void 0===a.render&&b.push({message:`layers.${c}: missing required method "render"`}),a.renderingMode&&"2d"!==a.renderingMode&&"3d"!==a.renderingMode&&b.push({message:`layers.${c}: property "renderingMode" must be either "2d" or "3d"`}),b},a.validateFog=c$,a.validateLight=cZ,a.validateStyle=M,a.values=bQ,a.vectorTile=_,a.version=bq,a.warnOnce=bY,a.window=s,a.wrap=bO}),a(["./shared"],function(a){function k(a){const c=typeof a;if("number"===c||"boolean"===c||"string"===c||null==a)return JSON.stringify(a);if(Array.isArray(a)){let e="[";for(const g of a)e+=`${k(g)},`;return`${e}]`}const d=Object.keys(a).sort();let f="{";for(let b=0;b<d.length;b++)f+=`${JSON.stringify(d[b])}:${k(a[d[b]])},`;return`${f}}`}function l(c){let b="";for(const d of a.refProperties)b+=`/${k(c[d])}`;return b}class m{constructor(a){this.keyCache={},a&&this.replace(a)}replace(a){this._layerConfigs={},this._layers={},this.update(a,[])}update(j,k){for(const b of j)this._layerConfigs[b.id]=b,(this._layers[b.id]=a.createStyleLayer(b)).compileFilter(),this.keyCache[b.id]&&delete this.keyCache[b.id];for(const d of k)delete this.keyCache[d],delete this._layerConfigs[d],delete this._layers[d];this.familiesBySource={};const m=function(b,c){const d={};for(let a=0;a<b.length;a++){const e=c&&c[b[a].id]||l(b[a]);c&&(c[b[a].id]=e);let f=d[e];f||(f=d[e]=[]),f.push(b[a])}const g=[];for(const h in d)g.push(d[h]);return g}(a.values(this._layerConfigs),this.keyCache);for(const n of m){const g=n.map(a=>this._layers[a.id]),e=g[0];if("none"===e.visibility)continue;const h=e.source||"";let c=this.familiesBySource[h];c||(c=this.familiesBySource[h]={});const i=e.sourceLayer||"_geojsonTileLayer";let f=c[i];f||(f=c[i]=[]),f.push(g)}}}const{ImageBitmap:n}=a.window;class o{loadTile(d,e){const{uid:f,encoding:g,rawImageData:b,padding:c,buildQuadTree:h}=d,i=n&&b instanceof n?this.getImageData(b,c):b;e(null,new a.DEMData(f,i,g,c<1,h))}getImageData(b,c){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(b.width,b.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=b.width,this.offscreenCanvas.height=b.height,this.offscreenCanvasContext.drawImage(b,0,0,b.width,b.height);const d=this.offscreenCanvasContext.getImageData(-c,-c,b.width+2*c,b.height+2*c);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new a.RGBAImage({width:d.width,height:d.height},d.data)}}var f,p=function e(b,c){var a,d=b&&b.type;if("FeatureCollection"===d)for(a=0;a<b.features.length;a++)e(b.features[a],c);else if("GeometryCollection"===d)for(a=0;a<b.geometries.length;a++)e(b.geometries[a],c);else if("Feature"===d)e(b.geometry,c);else if("Polygon"===d)q(b.coordinates,c);else if("MultiPolygon"===d)for(a=0;a<b.coordinates.length;a++)q(b.coordinates[a],c);return b};function q(a,c){if(0!==a.length){r(a[0],c);for(var b=1;b<a.length;b++)r(a[b],!c)}}function r(a,i){for(var b=0,g=0,c=0,h=a.length,e=h-1;c<h;e=c++){var d=(a[c][0]-a[e][0])*(a[e][1]+a[c][1]),f=b+d;g+=Math.abs(b)>=Math.abs(d)?b-f+d:d-f+b,b=f}b+g>=0!= !!i&&a.reverse()}const s=a.vectorTile.VectorTileFeature.prototype.toGeoJSON;class t{constructor(b){this._feature=b,this.extent=a.EXTENT,this.type=b.type,this.properties=b.tags,"id"in b&&!isNaN(b.id)&&(this.id=parseInt(b.id,10))}loadGeometry(){if(1===this._feature.type){const b=[];for(const c of this._feature.geometry)b.push([new a.pointGeometry(c[0],c[1]),]);return b}{const d=[];for(const g of this._feature.geometry){const e=[];for(const f of g)e.push(new a.pointGeometry(f[0],f[1]));d.push(e)}return d}}toGeoJSON(a,b,c){return s.call(this,a,b,c)}}class u{constructor(b){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=a.EXTENT,this.length=b.length,this._features=b}feature(a){return new t(this._features[a])}}var g=a.vectorTile.VectorTileFeature,h=i;function i(a,b){this.options=b||{},this.features=a,this.length=a.length}function b(a,b){this.id="number"==typeof a.id?a.id:void 0,this.type=a.type,this.rawGeometry=1===a.type?[a.geometry]:a.geometry,this.properties=a.tags,this.extent=b||4096}i.prototype.feature=function(a){return new b(this.features[a],this.options.extent)},b.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var c=0;c<e.length;c++){for(var d=e[c],f=[],b=0;b<d.length;b++)f.push(new a.pointGeometry(d[b][0],d[b][1]));this.geometry.push(f)}return this.geometry},b.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var h=this.geometry,b=1/0,c=-1/0,d=1/0,e=-1/0,f=0;f<h.length;f++)for(var i=h[f],g=0;g<i.length;g++){var a=i[g];b=Math.min(b,a.x),c=Math.max(c,a.x),d=Math.min(d,a.y),e=Math.max(e,a.y)}return[b,d,c,e]},b.prototype.toGeoJSON=g.prototype.toGeoJSON;var c=j;function j(c){var b=new a.pbf;return function(a,b){for(var c in a.layers)b.writeMessage(3,v,a.layers[c])}(c,b),b.finish()}function v(c,b){b.writeVarintField(15,c.version||1),b.writeStringField(1,c.name||""),b.writeVarintField(5,c.extent||4096);var a,d={keys:[],values:[],keycache:{},valuecache:{}};for(a=0;a<c.length;a++)d.feature=c.feature(a),b.writeMessage(2,w,d);var e=d.keys;for(a=0;a<e.length;a++)b.writeStringField(3,e[a]);var f=d.values;for(a=0;a<f.length;a++)b.writeMessage(4,B,f[a])}function w(c,a){var b=c.feature;void 0!==b.id&&a.writeVarintField(1,b.id),a.writeMessage(2,x,c),a.writeVarintField(3,b.type),a.writeMessage(4,A,b)}function x(b,g){var h=b.feature,i=b.keys,j=b.values,k=b.keycache,l=b.valuecache;for(var c in h.properties){var a=h.properties[c],e=k[c];if(null!==a){void 0===e&&(i.push(c),k[c]=e=i.length-1),g.writeVarint(e);var d=typeof a;"string"!==d&&"boolean"!==d&&"number"!==d&&(a=JSON.stringify(a));var m=d+":"+a,f=l[m];void 0===f&&(j.push(a),l[m]=f=j.length-1),g.writeVarint(f)}}}function y(a,b){return(b<<3)+(7&a)}function z(a){return a<<1^a>>31}function A(f,a){for(var g=f.loadGeometry(),d=f.type,h=0,i=0,n=g.length,e=0;e<n;e++){var b=g[e],j=1;1===d&&(j=b.length),a.writeVarint(y(1,j));for(var k=3===d?b.length-1:b.length,c=0;c<k;c++){1===c&&1!==d&&a.writeVarint(y(2,k-1));var l=b[c].x-h,m=b[c].y-i;a.writeVarint(z(l)),a.writeVarint(z(m)),h+=l,i+=m}3===d&&a.writeVarint(y(7,1))}}function B(a,b){var c=typeof a;"string"===c?b.writeStringField(1,a):"boolean"===c?b.writeBooleanField(7,a):"number"===c&&(a%1!=0?b.writeDoubleField(3,a):a<0?b.writeSVarintField(6,a):b.writeVarintField(5,a))}function C(c,d,e,a,b,f){if(b-a<=e)return;const g=a+b>>1;D(c,d,g,a,b,f%2),C(c,d,e,a,g-1,f+1),C(c,d,e,g+1,b,f+1)}function D(g,a,e,b,d,h){for(;d>b;){if(d-b>600){const f=d-b+1,l=e-b+1,m=Math.log(f),j=.5*Math.exp(2*m/3),n=.5*Math.sqrt(m*j*(f-j)/f)*(l-f/2<0?-1:1);D(g,a,e,Math.max(b,Math.floor(e-l*j/f+n)),Math.min(d,Math.floor(e+(f-l)*j/f+n)),h)}const k=a[2*e+h];let i=b,c=d;for(E(g,a,b,e),a[2*d+h]>k&&E(g,a,b,d);i<c;){for(E(g,a,i,c),i++,c--;a[2*i+h]<k;)i++;for(;a[2*c+h]>k;)c--}a[2*b+h]===k?E(g,a,b,c):E(g,a,++c,d),c<=e&&(b=c+1),e<=c&&(d=c-1)}}function E(d,c,a,b){F(d,a,b),F(c,2*a,2*b),F(c,2*a+1,2*b+1)}function F(a,b,c){const d=a[b];a[b]=a[c],a[c]=d}function G(c,d,e,f){const a=c-e,b=d-f;return a*a+b*b}c.fromVectorTileJs=j,c.fromGeojsonVt=function(d,b){b=b||{};var c={};for(var a in d)c[a]=new h(d[a].features,b),c[a].name=a,c[a].version=b.version,c[a].extent=b.extent;return j({layers:c})},c.GeoJSONWrapper=h;class H{constructor(b,f=a=>a[0],g=a=>a[1],e=64,h=Float64Array){this.nodeSize=e,this.points=b;const i=b.length<65536?Uint16Array:Uint32Array,c=this.ids=new i(b.length),d=this.coords=new h(2*b.length);for(let a=0;a<b.length;a++)c[a]=a,d[2*a]=f(b[a]),d[2*a+1]=g(b[a]);C(c,d,e,0,c.length-1,0)}range(a,b,c,d){return function(i,f,j,k,l,m,q){const a=[0,i.length-1,0],n=[];let b,c;for(;a.length;){const o=a.pop(),g=a.pop(),h=a.pop();if(g-h<=q){for(let d=h;d<=g;d++)b=f[2*d],c=f[2*d+1],b>=j&&b<=l&&c>=k&&c<=m&&n.push(i[d]);continue}const e=Math.floor((h+g)/2);b=f[2*e],c=f[2*e+1],b>=j&&b<=l&&c>=k&&c<=m&&n.push(i[e]);const p=(o+1)%2;(0===o?j<=b:k<=c)&&(a.push(h),a.push(e-1),a.push(p)),(0===o?l>=b:m>=c)&&(a.push(e+1),a.push(g),a.push(p))}return n}(this.ids,this.coords,a,b,c,d,this.nodeSize)}within(a,b,c){return function(j,e,f,g,b,q){const a=[0,j.length-1,0],k=[],o=b*b;for(;a.length;){const l=a.pop(),h=a.pop(),i=a.pop();if(h-i<=q){for(let c=i;c<=h;c++)G(e[2*c],e[2*c+1],f,g)<=o&&k.push(j[c]);continue}const d=Math.floor((i+h)/2),m=e[2*d],n=e[2*d+1];G(m,n,f,g)<=o&&k.push(j[d]);const p=(l+1)%2;(0===l?f-b<=m:g-b<=n)&&(a.push(i),a.push(d-1),a.push(p)),(0===l?f+b>=m:g+b>=n)&&(a.push(d+1),a.push(h),a.push(p))}return k}(this.ids,this.coords,a,b,c,this.nodeSize)}}const I=Math.fround||(f=new Float32Array(1),a=>(f[0]=+a,f[0]));class J{constructor(a){this.options=R(Object.create({minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:a=>a}),a),this.trees=Array(this.options.maxZoom+1)}load(b){const{log:c,minZoom:i,maxZoom:f,nodeSize:g}=this.options;c&&console.time("total time");const h=`prepare ${b.length} points`;c&&console.time(h),this.points=b;let a=[];for(let d=0;d<b.length;d++)b[d].geometry&&a.push(L(b[d],d));this.trees[f+1]=new H(a,S,T,g,Float32Array),c&&console.timeEnd(h);for(let e=f;e>=i;e--){const j=+Date.now();a=this._cluster(a,e),this.trees[e]=new H(a,S,T,g,Float32Array),c&&console.log("z%d: %d clusters in %dms",e,a.length,+Date.now()-j)}return c&&console.timeEnd("total time"),this}getClusters(a,d){let b=((a[0]+180)%360+360)%360-180;const e=Math.max(-90,Math.min(90,a[1]));let c=180===a[2]?180:((a[2]+180)%360+360)%360-180;const f=Math.max(-90,Math.min(90,a[3]));if(a[2]-a[0]>=360)b=-180,c=180;else if(b>c){const j=this.getClusters([b,e,180,f],d),k=this.getClusters([-180,e,c,f],d);return j.concat(k)}const h=this.trees[this._limitZoom(d)],l=h.range(O(b),P(f),O(c),P(e)),i=[];for(const m of l){const g=h.points[m];i.push(g.numPoints?M(g):this.points[g.index])}return i}getChildren(c){const h=this._getOriginId(c),g=this._getOriginZoom(c),d="No cluster with the specified id.",a=this.trees[g];if(!a)throw Error(d);const e=a.points[h];if(!e)throw Error(d);const i=this.options.radius/(this.options.extent*Math.pow(2,g-1)),j=a.within(e.x,e.y,i),f=[];for(const k of j){const b=a.points[k];b.parentId===c&&f.push(b.numPoints?M(b):this.points[b.index])}if(0===f.length)throw Error(d);return f}getLeaves(d,a,b){const c=[];return this._appendLeaves(c,d,a=a||10,b=b||0,0),c}getTile(i,d,e){const b=this.trees[this._limitZoom(i)],a=Math.pow(2,i),{extent:j,radius:k}=this.options,c=k/j,g=(e-c)/a,h=(e+1+c)/a,f={features:[]};return this._addTileFeatures(b.range((d-c)/a,g,(d+1+c)/a,h),b.points,d,e,a,f),0===d&&this._addTileFeatures(b.range(1-c/a,g,1,h),b.points,a,e,a,f),d===a-1&&this._addTileFeatures(b.range(0,g,c/a,h),b.points,-1,e,a,f),f.features.length?f:null}getClusterExpansionZoom(a){let b=this._getOriginZoom(a)-1;for(;b<=this.options.maxZoom;){const c=this.getChildren(a);if(b++,1!==c.length)break;a=c[0].properties.cluster_id}return b}_appendLeaves(c,g,e,d,a){const h=this.getChildren(g);for(const f of h){const b=f.properties;if(b&&b.cluster?a+b.point_count<=d?a+=b.point_count:a=this._appendLeaves(c,b.cluster_id,e,d,a):a<d?a++:c.push(f),c.length===e)break}return a}_addTileFeatures(j,k,l,m,g,n){for(const o of j){const a=k[o],h=a.numPoints;let c,d,e;if(h)c=N(a),d=a.x,e=a.y;else{const f=this.points[a.index];c=f.properties,d=O(f.geometry.coordinates[0]),e=P(f.geometry.coordinates[1])}const i={type:1,geometry:[[Math.round(this.options.extent*(d*g-l)),Math.round(this.options.extent*(e*g-m)),],],tags:c};let b;h?b=a.id:this.options.generateId?b=a.index:this.points[a.index].id&&(b=this.points[a.index].id),void 0!==b&&(i.id=b),n.features.push(i)}}_limitZoom(a){return Math.max(this.options.minZoom,Math.min(+a,this.options.maxZoom+1))}_cluster(n,b){const f=[],{radius:s,extent:t,reduce:j,minPoints:u}=this.options,v=s/(t*Math.pow(2,b));for(let g=0;g<n.length;g++){const a=n[g];if(a.zoom<=b)continue;a.zoom=b;const h=this.trees[b+1],k=h.within(a.x,a.y,v),e=a.numPoints||1;let c=e;for(const w of k){const o=h.points[w];o.zoom>b&&(c+=o.numPoints||1)}if(c>e&&c>=u){let p=a.x*e,q=a.y*e,i=j&&e>1?this._map(a,!0):null;const l=(g<<5)+(b+1)+this.points.length;for(const x of k){const d=h.points[x];if(d.zoom<=b)continue;d.zoom=b;const r=d.numPoints||1;p+=d.x*r,q+=d.y*r,d.parentId=l,j&&(i||(i=this._map(a,!0)),j(i,this._map(d)))}a.parentId=l,f.push(K(p/c,q/c,l,c,i))}else if(f.push(a),c>1)for(const y of k){const m=h.points[y];m.zoom<=b||(m.zoom=b,f.push(m))}}return f}_getOriginId(a){return a-this.points.length>>5}_getOriginZoom(a){return(a-this.points.length)%32}_map(a,c){if(a.numPoints)return c?R({},a.properties):a.properties;const d=this.points[a.index].properties,b=this.options.map(d);return c&&b===d?R({},b):b}}function K(a,b,c,d,e){return{x:I(a),y:I(b),zoom:1/0,id:c,parentId:-1,numPoints:d,properties:e}}function L(a,b){const[c,d]=a.geometry.coordinates;return{x:I(O(c)),y:I(P(d)),zoom:1/0,index:b,parentId:-1}}function M(a){return{type:"Feature",id:a.id,properties:N(a),geometry:{type:"Point",coordinates:[360*(a.x-.5),Q(a.y),]}}}function N(b){const a=b.numPoints,c=a>=1e4?`${Math.round(a/1e3)}k`:a>=1e3?Math.round(a/100)/10+"k":a;return R(R({},b.properties),{cluster:!0,cluster_id:b.id,point_count:a,point_count_abbreviated:c})}function O(a){return a/360+.5}function P(c){const b=Math.sin(c*Math.PI/180),a=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return a<0?0:a>1?1:a}function Q(a){return 360*Math.atan(Math.exp((180-360*a)*Math.PI/180))/Math.PI-90}function R(a,b){for(const c in b)a[c]=b[c];return a}function S(a){return a.x}function T(a){return a.y}function U(a,b,c,g){for(var d,f=g,k=c-b>>1,i=c-b,l=a[b],m=a[b+1],n=a[c],o=a[c+1],e=b+3;e<c;e+=3){var h=V(a[e],a[e+1],l,m,n,o);if(h>f)d=e,f=h;else if(h===f){var j=Math.abs(e-k);j<i&&(d=e,i=j)}}f>g&&(d-b>3&&U(a,b,d,g),a[d+2]=f,c-d>3&&U(a,d,c,g))}function V(f,g,c,d,h,i){var a=h-c,b=i-d;if(0!==a||0!==b){var e=((f-c)*a+(g-d)*b)/(a*a+b*b);e>1?(c=h,d=i):e>0&&(c+=a*e,d+=b*e)}return(a=f-c)*a+(b=g-d)*b}function W(a,c,d,e){var b={id:void 0===a?null:a,type:c,geometry:d,tags:e,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(d){var b=d.geometry,c=d.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)X(d,b);else if("Polygon"===c||"MultiLineString"===c)for(var a=0;a<b.length;a++)X(d,b[a]);else if("MultiPolygon"===c)for(a=0;a<b.length;a++)for(var e=0;e<b[a].length;e++)X(d,b[a][e])}(b),b}function X(a,c){for(var b=0;b<c.length;b+=3)a.minX=Math.min(a.minX,c[b]),a.minY=Math.min(a.minY,c[b+1]),a.maxX=Math.max(a.maxX,c[b]),a.maxY=Math.max(a.maxY,c[b+1])}function Y(i,b,e,j){if(b.geometry){var c=b.geometry.coordinates,f=b.geometry.type,g=Math.pow(e.tolerance/((1<<e.maxZoom)*e.extent),2),d=[],h=b.id;if(e.promoteId?h=b.properties[e.promoteId]:e.generateId&&(h=j||0),"Point"===f)Z(c,d);else if("MultiPoint"===f)for(var a=0;a<c.length;a++)Z(c[a],d);else if("LineString"===f)$(c,d,g,!1);else if("MultiLineString"===f){if(e.lineMetrics){for(a=0;a<c.length;a++)$(c[a],d=[],g,!1),i.push(W(h,"LineString",d,b.properties));return}_(c,d,g,!1)}else if("Polygon"===f)_(c,d,g,!0);else{if("MultiPolygon"!==f){if("GeometryCollection"===f){for(a=0;a<b.geometry.geometries.length;a++)Y(i,{id:h,geometry:b.geometry.geometries[a],properties:b.properties},e,j);return}throw Error("Input data is not a valid GeoJSON object.")}for(a=0;a<c.length;a++){var k=[];_(c[a],k,g,!0),d.push(k)}}i.push(W(h,f,d,b.properties))}}function Z(b,a){a.push(aa(b[0])),a.push(ab(b[1])),a.push(0)}function $(e,a,j,k){for(var f,g,h=0,b=0;b<e.length;b++){var c=aa(e[b][0]),d=ab(e[b][1]);a.push(c),a.push(d),a.push(0),b>0&&(h+=k?(f*d-c*g)/2:Math.sqrt(Math.pow(c-f,2)+Math.pow(d-g,2))),f=c,g=d}var i=a.length-3;a[2]=1,U(a,0,i,j),a[i+2]=1,a.size=Math.abs(h),a.start=0,a.end=a.size}function _(b,d,e,f){for(var a=0;a<b.length;a++){var c=[];$(b[a],c,e,f),d.push(c)}}function aa(a){return a/360+.5}function ab(c){var b=Math.sin(c*Math.PI/180),a=.5-.25*Math.log((1+b)/(1-b))/Math.PI;return a<0?0:a>1?1:a}function ac(j,m,e,d,f,n,o,p){if(d/=m,n>=(e/=m)&&o<d)return j;if(o<e||n>=d)return null;for(var i=[],k=0;k<j.length;k++){var c=j[k],h=c.geometry,a=c.type,q=0===f?c.minX:c.minY,r=0===f?c.maxX:c.maxY;if(q>=e&&r<d)i.push(c);else if(!(r<e||q>=d)){var b=[];if("Point"===a||"MultiPoint"===a)ad(h,b,e,d,f);else if("LineString"===a)ae(h,b,e,d,f,!1,p.lineMetrics);else if("MultiLineString"===a)ag(h,b,e,d,f,!1);else if("Polygon"===a)ag(h,b,e,d,f,!0);else if("MultiPolygon"===a)for(var g=0;g<h.length;g++){var l=[];ag(h[g],l,e,d,f,!0),l.length&&b.push(l)}if(b.length){if(p.lineMetrics&&"LineString"===a){for(g=0;g<b.length;g++)i.push(W(c.id,a,b[g],c.tags));continue}"LineString"!==a&&"MultiLineString"!==a||(1===b.length?(a="LineString",b=b[0]):a="MultiLineString"),"Point"!==a&&"MultiPoint"!==a||(a=3===b.length?"Point":"MultiPoint"),i.push(W(c.id,a,b,c.tags))}}}return i.length?i:null}function ad(b,c,e,f,g){for(var a=0;a<b.length;a+=3){var d=b[a+g];d>=e&&d<=f&&(c.push(b[a]),c.push(b[a+1]),c.push(b[a+2]))}}function ae(b,u,e,f,o,v,m){for(var n,g,a=af(b),p=0===o?ai:aj,q=b.start,h=0;h<b.length-3;h+=3){var c=b[h],d=b[h+1],s=b[h+2],j=b[h+3],k=b[h+4],l=0===o?c:d,r=0===o?j:k,t=!1;m&&(n=Math.sqrt(Math.pow(c-j,2)+Math.pow(d-k,2))),l<e?r>e&&(g=p(a,c,d,j,k,e),m&&(a.start=q+n*g)):l>f?r<f&&(g=p(a,c,d,j,k,f),m&&(a.start=q+n*g)):ah(a,c,d,s),r<e&&l>=e&&(g=p(a,c,d,j,k,e),t=!0),r>f&&l<=f&&(g=p(a,c,d,j,k,f),t=!0),!v&&t&&(m&&(a.end=q+n*g),u.push(a),a=af(b)),m&&(q+=n)}var i=b.length-3;c=b[i],d=b[i+1],s=b[i+2],(l=0===o?c:d)>=e&&l<=f&&ah(a,c,d,s),i=a.length-3,v&&i>=3&&(a[i]!==a[0]||a[i+1]!==a[1])&&ah(a,a[0],a[1],a[2]),a.length&&u.push(a)}function af(b){var a=[];return a.size=b.size,a.start=b.start,a.end=b.end,a}function ag(b,c,d,e,f,g){for(var a=0;a<b.length;a++)ae(b[a],c,d,e,f,g,!1)}function ah(a,b,c,d){a.push(b),a.push(c),a.push(d)}function ai(a,b,c,f,g,d){var e=(d-b)/(f-b);return a.push(d),a.push(c+(g-c)*e),a.push(1),e}function aj(a,b,c,f,g,d){var e=(d-c)/(g-c);return a.push(b+(f-b)*e),a.push(d),a.push(1),e}function ak(h,e){for(var i=[],f=0;f<h.length;f++){var d,a=h[f],c=a.type;if("Point"===c||"MultiPoint"===c||"LineString"===c)d=al(a.geometry,e);else if("MultiLineString"===c||"Polygon"===c){d=[];for(var b=0;b<a.geometry.length;b++)d.push(al(a.geometry[b],e))}else if("MultiPolygon"===c)for(d=[],b=0;b<a.geometry.length;b++){for(var j=[],g=0;g<a.geometry[b].length;g++)j.push(al(a.geometry[b][g],e));d.push(j)}i.push(W(a.id,c,d,a.tags))}return i}function al(a,d){var b=[];b.size=a.size,void 0!==a.start&&(b.start=a.start,b.end=a.end);for(var c=0;c<a.length;c+=3)b.push(a[c]+d,a[c+1],a[c+2]);return b}function am(b,g){if(b.transformed)return b;var f,a,d,h=1<<b.z,i=b.x,j=b.y;for(f=0;f<b.features.length;f++){var e=b.features[f],c=e.geometry,l=e.type;if(e.geometry=[],1===l)for(a=0;a<c.length;a+=2)e.geometry.push(an(c[a],c[a+1],g,h,i,j));else for(a=0;a<c.length;a++){var k=[];for(d=0;d<c[a].length;d+=2)k.push(an(c[a][d],c[a][d+1],g,h,i,j));e.geometry.push(k)}}return b.transformed=!0,b}function an(c,d,a,b,e,f){return[Math.round(a*(c*b-e)),Math.round(a*(d*b-f)),]}function ao(c,e,j,k,d){for(var l=e===d.maxZoom?0:d.tolerance/((1<<e)*d.extent),a={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:j,y:k,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},b=0;b<c.length;b++){a.numFeatures++,ap(a,c[b],l,d);var f=c[b].minX,g=c[b].minY,h=c[b].maxX,i=c[b].maxY;f<a.minX&&(a.minX=f),g<a.minY&&(a.minY=g),h>a.maxX&&(a.maxX=h),i>a.maxY&&(a.maxY=i)}return a}function ap(f,d,h,m){var b=d.geometry,c=d.type,e=[];if("Point"===c||"MultiPoint"===c)for(var a=0;a<b.length;a+=3)e.push(b[a]),e.push(b[a+1]),f.numPoints++,f.numSimplified++;else if("LineString"===c)aq(e,b,f,h,!1,!1);else if("MultiLineString"===c||"Polygon"===c)for(a=0;a<b.length;a++)aq(e,b[a],f,h,"Polygon"===c,0===a);else if("MultiPolygon"===c)for(var i=0;i<b.length;i++){var j=b[i];for(a=0;a<j.length;a++)aq(e,j[a],f,h,!0,0===a)}if(e.length){var g=d.tags||null;if("LineString"===c&&m.lineMetrics){for(var k in g={},d.tags)g[k]=d.tags[k];g.mapbox_clip_start=b.start/b.size,g.mapbox_clip_end=b.end/b.size}var l={geometry:e,type:"Polygon"===c||"MultiPolygon"===c?3:"LineString"===c||"MultiLineString"===c?2:1,tags:g};null!==d.id&&(l.id=d.id),f.features.push(l)}}function aq(h,a,e,b,f,i){var g=b*b;if(b>0&&a.size<(f?g:b))e.numPoints+=a.length/3;else{for(var d=[],c=0;c<a.length;c+=3)(0===b||a[c+2]>g)&&(e.numSimplified++,d.push(a[c]),d.push(a[c+1])),e.numPoints++;f&&function(b,f){for(var e=0,a=0,c=b.length,d=c-2;a<c;d=a,a+=2)e+=(b[a]-b[d])*(b[a+1]+b[d+1]);if(e>0===f)for(a=0,c=b.length;a<c/2;a+=2){var g=b[a],h=b[a+1];b[a]=b[c-2-a],b[a+1]=b[c-1-a],b[c-2-a]=g,b[c-1-a]=h}}(d,i),h.push(d)}}function d(j,a){var i=(a=this.options=function(a,b){for(var c in b)a[c]=b[c];return a}(Object.create(this.options),a)).debug;if(i&&console.time("preprocess data"),a.maxZoom<0||a.maxZoom>24)throw Error("maxZoom should be in the 0-24 range");if(a.promoteId&&a.generateId)throw Error("promoteId and generateId cannot be used together.");var d,e,b,c,f,g,h=function(a,d){var c=[];if("FeatureCollection"===a.type)for(var b=0;b<a.features.length;b++)Y(c,a.features[b],d,b);else Y(c,"Feature"===a.type?a:{geometry:a},d);return c}(j,a);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",a.indexMaxZoom,a.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),(h=(d=h,b=(e=a).buffer/e.extent,c=d,f=ac(d,1,-1-b,b,0,-1,2,e),g=ac(d,1,1-b,2+b,0,-1,2,e),(f||g)&&(c=ac(d,1,-b,1+b,0,-1,2,e)||[],f&&(c=ak(f,1).concat(c)),g&&(c=c.concat(ak(g,-1)))),c)).length&&this.splitTile(h,0,0,0),i&&(h.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 ar(a,b,c){return 32*((1<<a)*c+b)+a}d.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},d.prototype.splitTile=function(g,c,d,b,m,x,y){for(var f=[g,c,d,b],e=this.options,j=e.debug;f.length;){b=f.pop(),d=f.pop(),c=f.pop(),g=f.pop();var h=1<<c,u=ar(c,d,b),a=this.tiles[u];if(!a&&(j>1&&console.time("creation"),a=this.tiles[u]=ao(g,c,d,b,e),this.tileCoords.push({z:c,x:d,y:b}),j)){j>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",c,d,b,a.numFeatures,a.numPoints,a.numSimplified),console.timeEnd("creation"));var v="z"+c;this.stats[v]=(this.stats[v]||0)+1,this.total++}if(a.source=g,m){if(c===e.maxZoom||c===m)continue;var w=1<<m-c;if(d!==Math.floor(x/w)||b!==Math.floor(y/w))continue}else if(c===e.indexMaxZoom||a.numPoints<=e.indexMaxPoints)continue;if(a.source=null,0!==g.length){j>1&&console.time("clipping");var n,o,p,q,k,l,i=.5*e.buffer/e.extent,r=.5-i,s=.5+i,t=1+i;n=o=p=q=null,k=ac(g,h,d-i,d+s,0,a.minX,a.maxX,e),l=ac(g,h,d+r,d+t,0,a.minX,a.maxX,e),g=null,k&&(n=ac(k,h,b-i,b+s,1,a.minY,a.maxY,e),o=ac(k,h,b+r,b+t,1,a.minY,a.maxY,e),k=null),l&&(p=ac(l,h,b-i,b+s,1,a.minY,a.maxY,e),q=ac(l,h,b+r,b+t,1,a.minY,a.maxY,e),l=null),j>1&&console.timeEnd("clipping"),f.push(n||[],c+1,2*d,2*b),f.push(o||[],c+1,2*d,2*b+1),f.push(p||[],c+1,2*d+1,2*b),f.push(q||[],c+1,2*d+1,2*b+1)}}},d.prototype.getTile=function(a,b,g){var k=this.options,l=k.extent,h=k.debug;if(a<0||a>24)return null;var j=1<<a,i=ar(a,b=(b%j+j)%j,g);if(this.tiles[i])return am(this.tiles[i],l);h>1&&console.log("drilling down to z%d-%d-%d",a,b,g);for(var c,d=a,e=b,f=g;!c&&d>0;)d--,e=Math.floor(e/2),f=Math.floor(f/2),c=this.tiles[ar(d,e,f)];return c&&c.source?(h>1&&console.log("found parent tile z%d-%d-%d",d,e,f),h>1&&console.time("drilling down"),this.splitTile(c.source,d,e,f,a,b,g),h>1&&console.timeEnd("drilling down"),this.tiles[i]?am(this.tiles[i],l):null):null};class as extends a.VectorTileWorkerSource{constructor(b,d,e,f,a){super(b,d,e,f,function(g,b){const d=g.tileID.canonical;if(!this._geoJSONIndex)return b(null,null);const e=this._geoJSONIndex.getTile(d.z,d.x,d.y);if(!e)return b(null,null);const f=new u(e.features);let a=c(f);0===a.byteOffset&&a.byteLength===a.buffer.byteLength||(a=new Uint8Array(a)),b(null,{vectorTile:f,rawData:a.buffer})}),a&&(this.loadGeoJSON=a)}loadData(b,e){const c=b&&b.request,f=c&&c.collectResourceTiming;this.loadGeoJSON(b,(i,g)=>{if(i||!g)return e(i);if("object"!=typeof g)return e(Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));{p(g,!0);try{var j,k;if(b.filter){const l=a.createExpression(b.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===l.result)throw Error(l.value.map(a=>`${a.key}: ${a.message}`).join(", "));const n=g.features.filter(a=>l.value.evaluate({zoom:0},a));g={type:"FeatureCollection",features:n}}this._geoJSONIndex=b.cluster?new J(function({superclusterOptions:b,clusterProperties:d}){if(!d||!b)return b;const f={},g={},l={accumulated:null,zoom:0},m={properties:null},h=Object.keys(d);for(const c of h){const[e,i]=d[c],j=a.createExpression(i),k=a.createExpression("string"==typeof e?[e,["accumulated",],["get",c,],]:e);f[c]=j.value,g[c]=k.value}return b.map=c=>{m.properties=c;const a={};for(const b of h)a[b]=f[b].evaluate(l,m);return a},b.reduce=(b,c)=>{for(const a of(m.properties=c,h))l.accumulated=b[a],b[a]=g[a].evaluate(l,m)},b}(b)).load(g.features):(j=g,k=b.geojsonVtOptions,new d(j,k))}catch(o){return e(o)}this.loaded={};const h={};if(f){const m=a.getPerformanceMeasurement(c);m&&(h.resourceTiming={},h.resourceTiming[b.source]=JSON.parse(JSON.stringify(m)))}e(null,h)}})}reloadTile(a,b){const c=this.loaded;return c&&c[a.uid]?super.reloadTile(a,b):this.loadTile(a,b)}loadGeoJSON(b,c){if(b.request)a.getJSON(b.request,c);else{if("string"!=typeof b.data)return c(Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`));try{return c(null,JSON.parse(b.data))}catch(d){return c(Error(`Input data given to '${b.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(b,a){try{a(null,this._geoJSONIndex.getClusterExpansionZoom(b.clusterId))}catch(c){a(c)}}getClusterChildren(b,a){try{a(null,this._geoJSONIndex.getChildren(b.clusterId))}catch(c){a(c)}}getClusterLeaves(a,b){try{b(null,this._geoJSONIndex.getLeaves(a.clusterId,a.limit,a.offset))}catch(c){b(c)}}}class e{constructor(b){this.self=b,this.actor=new a.Actor(b,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=a.getProjection({name:"mercator"}),this.workerSourceTypes={vector:a.VectorTileWorkerSource,geojson:as},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(a,b)=>{if(this.workerSourceTypes[a])throw Error(`Worker source with name "${a}" already registered.`);this.workerSourceTypes[a]=b},this.self.registerRTLTextPlugin=b=>{if(a.plugin.isParsed())throw Error("RTL text plugin already registered.");a.plugin.applyArabicShaping=b.applyArabicShaping,a.plugin.processBidirectionalText=b.processBidirectionalText,a.plugin.processStyledBidirectionalText=b.processStyledBidirectionalText}}clearCaches(a,c,b){delete this.layerIndexes[a],delete this.availableImages[a],delete this.workerSources[a],delete this.demWorkerSources[a],b()}checkIfReady(b,c,a){a()}setReferrer(b,a){this.referrer=a}spriteLoaded(c,e){for(const f in this.isSpriteLoaded[c]=e,this.workerSources[c]){const b=this.workerSources[c][f];for(const d in b)b[d]instanceof a.VectorTileWorkerSource&&(b[d].isSpriteLoaded=e,b[d].fire(new a.Event("isSpriteLoaded")))}}setImages(a,b,d){for(const e in this.availableImages[a]=b,this.workerSources[a]){const c=this.workerSources[a][e];for(const f in c)c[f].availableImages=b}d()}enableTerrain(c,a,b){this.terrain=a,b()}setProjection(b,c){this.projections[b]=a.getProjection(c)}setLayers(a,b,c){this.getLayerIndex(a).replace(b),c()}updateLayers(b,a,c){this.getLayerIndex(b).update(a.layers,a.removedIds),c()}loadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).loadTile(d,e)}loadDEMTile(c,b,d){const e=this.enableTerrain?a.extend({buildQuadTree:this.terrain},b):b;this.getDEMWorkerSource(c,b.source).loadTile(e,d)}reloadTile(c,b,e){const d=this.enableTerrain?a.extend({enableTerrain:this.terrain},b):b;d.projection=this.projections[c]||this.defaultProjection,this.getWorkerSource(c,b.type,b.source).reloadTile(d,e)}abortTile(b,a,c){this.getWorkerSource(b,a.type,a.source).abortTile(a,c)}removeTile(b,a,c){this.getWorkerSource(b,a.type,a.source).removeTile(a,c)}removeSource(b,a,c){if(!this.workerSources[b]||!this.workerSources[b][a.type]||!this.workerSources[b][a.type][a.source])return;const d=this.workerSources[b][a.type][a.source];delete this.workerSources[b][a.type][a.source],void 0!==d.removeSource?d.removeSource(a,c):c()}loadWorkerSource(d,b,a){try{this.self.importScripts(b.url),a()}catch(c){a(c.toString())}}syncRTLPluginState(g,e,c){try{a.plugin.setState(e);const b=a.plugin.getPluginURL();if(a.plugin.isLoaded()&&!a.plugin.isParsed()&&null!=b){this.self.importScripts(b);const d=a.plugin.isParsed();c(d?void 0:Error(`RTL Text Plugin failed to import scripts from ${b}`),d)}}catch(f){c(f.toString())}}getAvailableImages(b){let a=this.availableImages[b];return a||(a=[]),a}getLayerIndex(b){let a=this.layerIndexes[b];return a||(a=this.layerIndexes[b]=new m),a}getWorkerSource(a,b,c){return this.workerSources[a]||(this.workerSources[a]={}),this.workerSources[a][b]||(this.workerSources[a][b]={}),this.workerSources[a][b][c]||(this.workerSources[a][b][c]=new this.workerSourceTypes[b]({send:(b,c,d,g,e,f)=>{this.actor.send(b,c,d,a,e,f)},scheduler:this.actor.scheduler},this.getLayerIndex(a),this.getAvailableImages(a),this.isSpriteLoaded[a])),this.workerSources[a][b][c]}getDEMWorkerSource(a,b){return this.demWorkerSources[a]||(this.demWorkerSources[a]={}),this.demWorkerSources[a][b]||(this.demWorkerSources[a][b]=new o),this.demWorkerSources[a][b]}enforceCacheSizeLimit(c,b){a.enforceCacheSizeLimit(b)}getWorkerPerformanceMetrics(b,c,a){a(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new e(self)),e}),a(["./shared"],function(a){var l=m;function m(c){var b,a;return b=c,"undefined"!=typeof window&&"undefined"!=typeof document&&!!Array.prototype&&!!Array.prototype.every&&!!Array.prototype.filter&&!!Array.prototype.forEach&&!!Array.prototype.indexOf&&!!Array.prototype.lastIndexOf&&!!Array.prototype.map&&!!Array.prototype.some&&!!Array.prototype.reduce&&!!Array.prototype.reduceRight&&!!Array.isArray&&!!Function.prototype&&!!Function.prototype.bind&&!!Object.keys&&!!Object.create&&!!Object.getPrototypeOf&&!!Object.getOwnPropertyNames&&!!Object.isSealed&&!!Object.isFrozen&&!!Object.isExtensible&&!!Object.getOwnPropertyDescriptor&&!!Object.defineProperty&&!!Object.defineProperties&&!!Object.seal&&!!Object.freeze&&!!Object.preventExtensions&&!!("JSON"in window&&"parse"in JSON&&"stringify"in JSON)&&!!function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var a,b,d=new Blob([""],{type:"text/javascript"}),c=URL.createObjectURL(d);try{b=new Worker(c),a=!0}catch(e){a=!1}return b&&b.terminate(),URL.revokeObjectURL(c),a}()&&"Uint8ClampedArray"in window&&!!ArrayBuffer.isView&&!!function(){var a=document.createElement("canvas");a.width=a.height=1;var b=a.getContext("2d");if(!b)return!1;var c=b.getImageData(0,0,1,1);return c&&c.width===a.width}()&&(void 0===B[a=b&&b.failIfMajorPerformanceCaveat]&&(B[a]=function(f){var e,c,d,b,a=(e=f,c=document.createElement("canvas"),(d=Object.create(m.webGLContextAttributes)).failIfMajorPerformanceCaveat=e,c.getContext("webgl",d)||c.getContext("experimental-webgl",d));if(!a)return!1;try{b=a.createShader(a.VERTEX_SHADER)}catch(g){return!1}return!(!b||a.isContextLost())&&(a.shaderSource(b,"void main() {}"),a.compileShader(b),!0===a.getShaderParameter(b,a.COMPILE_STATUS))}(a)),!!B[a]&&!document.documentMode)}var B={};function C(b,c){var d=c[0],e=c[1],f=c[2],g=c[3],a=d*g-f*e;return a?(b[0]=g*(a=1/a),b[1]=-e*a,b[2]=-f*a,b[3]=d*a,b):null}function D(a,b){if(Array.isArray(a)){if(!Array.isArray(b)||a.length!==b.length)return!1;for(let c=0;c<a.length;c++)if(!D(a[c],b[c]))return!1;return!0}if("object"==typeof a&&null!==a&&null!==b){if("object"!=typeof b||Object.keys(a).length!==Object.keys(b).length)return!1;for(const d in a)if(!D(a[d],b[d]))return!1;return!0}return a===b}m.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const b={create:function(e,c,d){const b=a.window.document.createElement(e);return void 0!==c&&(b.className=c),d&&d.appendChild(b),b},createSVG:function(f,c,d){const b=a.window.document.createElementNS("http://www.w3.org/2000/svg",f);for(const e of Object.keys(c))b.setAttributeNS(null,e,c[e]);return d&&d.appendChild(b),b}},h=a.window.document&&a.window.document.documentElement.style,E=h&& void 0!==h.userSelect?"userSelect":"WebkitUserSelect";let F;b.disableDrag=function(){h&&E&&(F=h[E],h[E]="none")},b.enableDrag=function(){h&&E&&(h[E]=F)};const G=function(b){b.preventDefault(),b.stopPropagation(),a.window.removeEventListener("click",G,!0)};function H(c,b,d){const e=c.offsetWidth===b.width?1:c.offsetWidth/b.width;return new a.pointGeometry((d.clientX-b.left)*e,(d.clientY-b.top)*e)}function I(b){const{userImage:a}=b;return!!(a&&a.render&&a.render())&&(b.data.replace(new Uint8Array(a.data.buffer)),!0)}b.suppressClick=function(){a.window.addEventListener("click",G,!0),a.window.setTimeout(()=>{a.window.removeEventListener("click",G,!0)},0)},b.mousePos=function(a,b){const c=a.getBoundingClientRect();return H(a,c,b)},b.touchPos=function(b,c){const e=b.getBoundingClientRect(),d=[];for(let a=0;a<c.length;a++)d.push(H(b,e,c[a]));return d},b.mouseButton=function(b){return void 0!==a.window.InstallTrigger&&2===b.button&&b.ctrlKey&&a.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:b.button};class J extends a.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new a.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(a){if(this.loaded!==a&&(this.loaded=a,a)){for(const{ids:b,callback:c}of this.requestors)this._notify(b,c);this.requestors=[]}}getImage(a){return this.images[a]}addImage(a,b){this._validate(a,b)&&(this.images[a]=b)}_validate(d,b){let c=!0;return this._validateStretch(b.stretchX,b.data&&b.data.width)||(this.fire(new a.ErrorEvent(Error(`Image "${d}" has invalid "stretchX" value`))),c=!1),this._validateStretch(b.stretchY,b.data&&b.data.height)||(this.fire(new a.ErrorEvent(Error(`Image "${d}" has invalid "stretchY" value`))),c=!1),this._validateContent(b.content,b)||(this.fire(new a.ErrorEvent(Error(`Image "${d}" has invalid "content" value`))),c=!1),c}_validateStretch(b,d){if(!b)return!0;let c=0;for(const a of b){if(a[0]<c||a[1]<a[0]||d<a[1])return!1;c=a[1]}return!0}_validateContent(a,b){return!(a&&(4!==a.length||a[0]<0||b.data.width<a[0]||a[1]<0||b.data.height<a[1]||a[2]<0||b.data.width<a[2]||a[3]<0||b.data.height<a[3]||a[2]<a[0]||a[3]<a[1]))}updateImage(a,b){b.version=this.images[a].version+1,this.images[a]=b,this.updatedImages[a]=!0}removeImage(a){const b=this.images[a];delete this.images[a],delete this.patterns[a],b.userImage&&b.userImage.onRemove&&b.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(a,b){let c=!0;if(!this.isLoaded())for(const d of a)this.images[d]||(c=!1);this.isLoaded()||c?this._notify(a,b):this.requestors.push({ids:a,callback:b})}_notify(e,f){const d={};for(const c of e){this.images[c]||this.fire(new a.Event("styleimagemissing",{id:c}));const b=this.images[c];b?d[c]={data:b.data.clone(),pixelRatio:b.pixelRatio,sdf:b.sdf,version:b.version,stretchX:b.stretchX,stretchY:b.stretchY,content:b.content,hasRenderCallback:Boolean(b.userImage&&b.userImage.render)}:a.warnOnce(`Image "${c}" 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.`)}f(null,d)}getPixelSize(){const{width:a,height:b}=this.atlasImage;return{width:a,height:b}}getPattern(d){const c=this.patterns[d],b=this.getImage(d);if(!b)return null;if(c&&c.position.version===b.version)return c.position;if(c)c.position.version=b.version;else{const e={w:b.data.width+2,h:b.data.height+2,x:0,y:0},f=new a.ImagePosition(e,b);this.patterns[d]={bin:e,position:f}}return this._updatePatternAtlas(),this.patterns[d].position}bind(c){const b=c.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new a.Texture(c,this.atlasImage,b.RGBA),this.atlasTexture.bind(b.LINEAR,b.CLAMP_TO_EDGE)}_updatePatternAtlas(){const h=[];for(const k in this.patterns)h.push(this.patterns[k].bin);const{w:l,h:m}=a.potpack(h),c=this.atlasImage;for(const i in c.resize({width:l||1,height:m||1}),this.patterns){const{bin:j}=this.patterns[i],d=j.x+1,e=j.y+1,b=this.images[i].data,f=b.width,g=b.height;a.RGBAImage.copy(b,c,{x:0,y:0},{x:d,y:e},{width:f,height:g}),a.RGBAImage.copy(b,c,{x:0,y:g-1},{x:d,y:e-1},{width:f,height:1}),a.RGBAImage.copy(b,c,{x:0,y:0},{x:d,y:e+g},{width:f,height:1}),a.RGBAImage.copy(b,c,{x:f-1,y:0},{x:d-1,y:e},{width:1,height:g}),a.RGBAImage.copy(b,c,{x:0,y:0},{x:d+f,y:e},{width:1,height:g})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(c){for(const a of c){if(this.callbackDispatchedThisFrame[a])continue;this.callbackDispatchedThisFrame[a]=!0;const b=this.images[a];I(b)&&this.updateImage(a,b)}}}const K=new a.Properties({anchor:new a.DataConstantProperty(a.spec.light.anchor),position:new class{constructor(){this.specification=a.spec.light.position}possiblyEvaluate(b,c){return function([b,d,e]){const f=a.degToRad(d+90),c=a.degToRad(e);return{x:b*Math.cos(f)*Math.sin(c),y:b*Math.sin(f)*Math.sin(c),z:b*Math.cos(c),azimuthal:d,polar:e}}(b.expression.evaluate(c))}interpolate(b,c,d){return{x:a.number(b.x,c.x,d),y:a.number(b.y,c.y,d),z:a.number(b.z,c.z,d),azimuthal:a.number(b.azimuthal,c.azimuthal,d),polar:a.number(b.polar,c.polar,d)}}},color:new a.DataConstantProperty(a.spec.light.color),intensity:new a.DataConstantProperty(a.spec.light.intensity)}),L="-transition";class M extends a.Evented{constructor(b){super(),this._transitionable=new a.Transitionable(K),this.setLight(b),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(c,e={}){if(!this._validate(a.validateLight,c,e))for(const b in c){const d=c[b];a.endsWith(b,L)?this._transitionable.setTransition(b.slice(0,-L.length),d):this._transitionable.setValue(b,d)}}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(c,d,b){return(!b|| !1!==b.validate)&&a.emitValidationErrors(this,c.call(a.validateStyle,a.extend({value:d,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}const N=new a.Properties({source:new a.DataConstantProperty(a.spec.terrain.source),exaggeration:new a.DataConstantProperty(a.spec.terrain.exaggeration)}),O="-transition";class P extends a.Evented{constructor(b,c){super(),this._transitionable=new a.Transitionable(N),this.set(b),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=c}get(){return this._transitionable.serialize()}set(c){for(const b in c){const d=c[b];a.endsWith(b,O)?this._transitionable.setTransition(b.slice(0,-O.length),d):this._transitionable.setValue(b,d)}}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}}function Q(c,e,f,g){const h=a.smoothstep(45,65,f),[d,i]=R(c,g),j=a.length(e);let b=1-Math.min(1,Math.exp(-((j-d)/(i-d)*6)));return b*=b*b,(b=Math.min(1,1.00747*b))*h*c.alpha}function R(a,c){const b=.5/Math.tan(.5*c);return[a.range[0]+b,a.range[1]+b]}const S=new a.Properties({range:new a.DataConstantProperty(a.spec.fog.range),color:new a.DataConstantProperty(a.spec.fog.color),"horizon-blend":new a.DataConstantProperty(a.spec.fog["horizon-blend"])}),T="-transition";class U extends a.Evented{constructor(b,c){super(),this._transitionable=new a.Transitionable(S),this.set(b),this._transitioning=this._transitionable.untransitioned(),this._transform=c}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(c,e={}){if(!this._validate(a.validateFog,c,e))for(const b in c){const d=c[b];a.endsWith(b,T)?this._transitionable.setTransition(b.slice(0,-T.length),d):this._transitionable.setValue(b,d)}}getOpacity(b){if(!this._transform.projection.supportsFog)return 0;const c=this.properties&&this.properties.get("color")||1;return a.smoothstep(45,65,b)*c.a}getOpacityAtLatLng(b,c){return this._transform.projection.supportsFog?function(e,f,b){const c=a.MercatorCoordinate.fromLngLat(f),g=b.elevation?b.elevation.getAtPointOrZero(c):0,d=[c.x,c.y,g];return a.transformMat4(d,d,b.mercatorFogMatrix),Q(e,d,b.pitch,b._fov)}(this.state,b,c):0}getFovAdjustedRange(a){return this._transform.projection.supportsFog?R(this.state,a):[0,1]}updateTransitions(a){this._transitioning=this._transitionable.transitioned(a,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(a){this.properties=this._transitioning.possiblyEvaluate(a)}_validate(c,d,b){return(!b|| !1!==b.validate)&&a.emitValidationErrors(this,c.call(a.validateStyle,a.extend({value:d,style:{glyphs:!0,sprite:!0},styleSpec:a.spec})))}}class n{constructor(e,f){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=a.uniqueId();const c=this.workerPool.acquire(this.id);for(let b=0;b<c.length;b++){const d=new n.Actor(c[b],f,this.id);d.name=`Worker ${b}`,this.actors.push(d)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(c,d,b){a.asyncAll(this.actors,(a,b)=>{a.send(c,d,b)},b=b||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(a=>{a.remove()}),this.actors=[],this.workerPool.release(this.id)}}function V(b,c,d){return c*(a.EXTENT/(b.tileSize*Math.pow(2,d-b.tileID.overscaledZ)))}n.Actor=a.Actor;class W{constructor(b,c,d){this.context=b;const a=b.gl;this.buffer=a.createBuffer(),this.dynamicDraw=Boolean(d),this.context.unbindVAO(),b.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.context.unbindVAO(),this.bind(),a.bufferSubData(a.ELEMENT_ARRAY_BUFFER,0,b.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const X={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Y{constructor(c,b,d,e){this.length=b.length,this.attributes=d,this.itemSize=b.bytesPerElement,this.dynamicDraw=e,this.context=c;const a=c.gl;this.buffer=a.createBuffer(),c.bindVertexBuffer.set(this.buffer),a.bufferData(a.ARRAY_BUFFER,b.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete b.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(b){const a=this.context.gl;this.bind(),a.bufferSubData(a.ARRAY_BUFFER,0,b.arrayBuffer)}enableAttributes(c,d){for(let a=0;a<this.attributes.length;a++){const b=d.attributes[this.attributes[a].name];void 0!==b&&c.enableVertexAttribArray(b)}}setVertexAttribPointers(c,e,f){for(let b=0;b<this.attributes.length;b++){const a=this.attributes[b],d=e.attributes[a.name];void 0!==d&&c.vertexAttribPointer(d,a.components,c[X[a.type]],!1,this.itemSize,a.offset+this.itemSize*(f||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class o{constructor(a){this.gl=a.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(a){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class p extends o{constructor(a,b){super(a),this.context=a,this.parent=b}getDefault(){return null}}class q extends p{attachment(){return this.gl.DEPTH_ATTACHMENT}set(a){if(a===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const b=this.gl;b.framebufferRenderbuffer(b.FRAMEBUFFER,this.attachment(),b.RENDERBUFFER,a),this.current=a,this.dirty=!1}}class Z extends q{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class ${constructor(a,c,d,e){this.context=a,this.width=c,this.height=d;const b=this.framebuffer=a.gl.createFramebuffer();this.colorAttachment=new class extends p{setDirty(){this.dirty=!0}set(b){if(b===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const a=this.gl;a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,b,0),this.current=b,this.dirty=!1}}(a,b),e&&(this.depthAttachment=new q(a,b))}destroy(){const a=this.context.gl,b=this.colorAttachment.get();if(b&&a.deleteTexture(b),this.depthAttachment){const c=this.depthAttachment.get();c&&a.deleteRenderbuffer(c)}a.deleteFramebuffer(this.framebuffer)}}class _{constructor(a,b,c,d){this.screenBounds=a,this.cameraPoint=b,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=c,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this.screenGeometry.map(a=>d.pointCoordinate3D(a)),this.cameraGeometry=this.bufferedCameraGeometry(0)}static createFromScreenPoints(b,c){let d,e;if(b instanceof a.pointGeometry||"number"==typeof b[0]){const h=a.pointGeometry.convert(b);d=[a.pointGeometry.convert(b)],e=c.isPointAboveHorizon(h)}else{const f=a.pointGeometry.convert(b[0]),g=a.pointGeometry.convert(b[1]);d=[f,g],e=a.polygonizeBounds(f,g).every(a=>c.isPointAboveHorizon(a))}return new _(d,c.getCameraPoint(),e,c)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(b){return a.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],b)}bufferedCameraGeometry(e){const d=this.screenBounds[0],b=1===this.screenBounds.length?this.screenBounds[0].add(new a.pointGeometry(1,1)):this.screenBounds[1],c=a.polygonizeBounds(d,b,0,!1);return this.cameraPoint.y>b.y&&(this.cameraPoint.x>d.x&&this.cameraPoint.x<b.x?c.splice(3,0,this.cameraPoint):this.cameraPoint.x>=b.x?c[2]=this.cameraPoint:this.cameraPoint.x<=d.x&&(c[3]=this.cameraPoint)),a.bufferConvexPolygon(c,e)}containsTile(c,d,h){var b;const f=c.queryPadding+1,i=c.tileID.wrap,e=h?this._bufferedCameraMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)):this._bufferedScreenMercator(f,d).map(b=>a.getTilePoint(c.tileTransform,b,i)),g=this.screenGeometryMercator.map(b=>a.getTileVec3(c.tileTransform,b,i)),j=g.map(b=>new a.pointGeometry(b[0],b[1])),k=d.getFreeCameraOptions().position||new a.MercatorCoordinate(0,0,0),n=a.getTileVec3(c.tileTransform,k,i),l=g.map(c=>{const b=a.sub(c,c,n);return a.normalize(b,b),new a.Ray(n,b)}),m=V(c,1,d.zoom);if(a.polygonIntersectsBox(e,0,0,a.EXTENT,a.EXTENT))return{queryGeometry:this,tilespaceGeometry:j,tilespaceRays:l,bufferedTilespaceGeometry:e,bufferedTilespaceBounds:((b=a.getBounds(e)).min.x=a.clamp(b.min.x,0,a.EXTENT),b.min.y=a.clamp(b.min.y,0,a.EXTENT),b.max.x=a.clamp(b.max.x,0,a.EXTENT),b.max.y=a.clamp(b.max.y,0,a.EXTENT),b),tile:c,tileID:c.tileID,pixelToTileUnitsFactor:m}}_bufferedScreenMercator(b,d){const a=aa(b);if(this._screenRaycastCache[a])return this._screenRaycastCache[a];{const c=this.bufferedScreenGeometry(b).map(a=>d.pointCoordinate3D(a));return this._screenRaycastCache[a]=c,c}}_bufferedCameraMercator(b,d){const a=aa(b);if(this._cameraRaycastCache[a])return this._cameraRaycastCache[a];{const c=this.bufferedCameraGeometry(b).map(a=>d.pointCoordinate3D(a));return this._cameraRaycastCache[a]=c,c}}}function aa(a){return 100*a|0}function ab(b,c,e){const d=function(g,f){if(g)return e(g);if(f){const d=a.pick(a.extend(f,b),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding",]);f.vector_layers&&(d.vectorLayers=f.vector_layers,d.vectorLayerIds=d.vectorLayers.map(a=>a.id)),d.tiles=c.canonicalizeTileset(d,b.url),e(null,d)}};return b.url?a.getJSON(c.transformRequest(c.normalizeSourceURL(b.url),a.ResourceType.Source),d):a.exported.frame(()=>d(null,b))}class ac{constructor(b,c,d){this.bounds=a.LngLatBounds.convert(this.validateBounds(b)),this.minzoom=c||0,this.maxzoom=d||24}validateBounds(a){return Array.isArray(a)&&4===a.length?[Math.max(-180,a[0]),Math.max(-90,a[1]),Math.min(180,a[2]),Math.min(90,a[3]),]:[-180,-90,180,90]}contains(b){const c=Math.pow(2,b.z),d=Math.floor(a.mercatorXfromLng(this.bounds.getWest())*c),e=Math.floor(a.mercatorYfromLat(this.bounds.getNorth())*c),f=Math.ceil(a.mercatorXfromLng(this.bounds.getEast())*c),g=Math.ceil(a.mercatorYfromLat(this.bounds.getSouth())*c);return b.x>=d&&b.x<f&&b.y>=e&&b.y<g}}class r extends a.Evented{constructor(c,b,d,e){super(),this.id=c,this.dispatcher=d,this.setEventedParent(e),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=a.extend({type:"raster"},b),a.extend(this,a.pick(b,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ab(this._options,this.map._requestManager,(c,b)=>{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ac(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(a){this.map=a,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}loadTile(b,e){const c=a.exported.devicePixelRatio>=2,d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),c,this.tileSize);b.request=a.getImage(this.map._requestManager.transformRequest(d,a.ResourceType.Tile),(g,f,h,i)=>{if(delete b.request,b.aborted)b.state="unloaded",e(null);else if(g)b.state="errored",e(g);else if(f){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const c=this.map.painter.context,d=c.gl;b.texture=this.map.painter.getTileTexture(f.width),b.texture?b.texture.update(f,{useMipmap:!0}):(b.texture=new a.Texture(c,f,d.RGBA,{useMipmap:!0}),b.texture.bind(d.LINEAR,d.CLAMP_TO_EDGE),c.extTextureFilterAnisotropic&&d.texParameterf(d.TEXTURE_2D,c.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,c.extTextureFilterAnisotropicMax)),b.state="loaded",a.cacheEntryPossiblyAdded(this.dispatcher),e(null)}})}abortTile(a,b){a.request&&(a.request.cancel(),delete a.request),b()}unloadTile(a,b){a.texture&&this.map.painter.saveTileTexture(a.texture),b()}hasTransition(){return!1}}let ad;function ae(e,f,g,h,i,j,k,l){const b=[e,g,i,f,h,j,1,1,1],c=[k,l,1],d=a.adjoint([],b),[m,n,o]=a.transformMat3(c,c,a.transpose(d,d));return a.multiply(b,[m,0,0,0,n,0,0,0,o],b)}class s extends a.Evented{constructor(b,a,c,d){super(),this.id=b,this.dispatcher=c,this.coordinates=a.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(d),this.options=a}load(b,c){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this.url=this.options.url,a.getImage(this.map._requestManager.transformRequest(this.url,a.ResourceType.Image),(d,e)=>{this._loaded=!0,d?this.fire(new a.ErrorEvent(d)):e&&(this.image=a.exported.getImageData(e),this.width=this.image.width,this.height=this.image.height,b&&(this.coordinates=b),c&&c(),this._finishLoading())})}loaded(){return this._loaded}updateImage(a){return this.image&&a.url&&(this.options.url=a.url,this.load(a.coordinates,()=>{this.texture=null})),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(a){this.map=a,this.load()}setCoordinates(b){this.coordinates=b,delete this._boundsArray;const c=b.map(a.MercatorCoordinate.fromLngLat);return this.tileID=function(i){let b=1/0,c=1/0,d=-1/0,e=-1/0;for(const f of i)b=Math.min(b,f.x),c=Math.min(c,f.y),d=Math.max(d,f.x),e=Math.max(e,f.y);const j=Math.max(d-b,e-c),g=Math.max(0,Math.floor(-Math.log(j)/Math.LN2)),h=Math.pow(2,g);return new a.CanonicalTileID(g,Math.floor((b+d)/2*h),Math.floor((c+e)/2*h))}(c),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){delete this._boundsArray}_makeBoundsArray(){const f=a.tileTransform(this.tileID,this.map.transform.projection),[b,c,d,e]=this.coordinates.map(b=>{const c=f.projection.project(b[0],b[1]);return a.getTilePoint(f,c)._round()});return this.perspectiveTransform=function(c,d,f,g,h,i,j,k,l,m){const e=ae(0,0,c,0,0,d,c,d),b=ae(f,g,h,i,j,k,l,m);return a.multiply(b,a.adjoint(e,e),b),[b[6]/b[8]*c/a.EXTENT,b[7]/b[8]*d/a.EXTENT,]}(this.width,this.height,b.x,b.y,c.x,c.y,e.x,e.y,d.x,d.y),this._boundsArray=new a.StructArrayLayout4i8,this._boundsArray.emplaceBack(b.x,b.y,0,0),this._boundsArray.emplaceBack(c.x,c.y,a.EXTENT,0),this._boundsArray.emplaceBack(e.x,e.y,0,a.EXTENT),this._boundsArray.emplaceBack(d.x,d.y,a.EXTENT,a.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const b=this.map.painter.context,c=b.gl;for(const e in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=b.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new a.Texture(b,this.image,c.RGBA),this.texture.bind(c.LINEAR,c.CLAMP_TO_EDGE)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}loadTile(a,b){this.tileID&&this.tileID.equals(a.tileID.canonical)?(this.tiles[String(a.tileID.wrap)]=a,a.buckets={},b(null)):(a.state="errored",b(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const af={vector:class extends a.Evented{constructor(c,b,d,e){if(super(),this.id=c,this.dispatcher=d,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,a.extend(this,a.pick(b,["url","scheme","tileSize","promoteId",])),this._options=a.extend({type:"vector"},b),this._collectResourceTiming=b.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(e),this._tileWorkers={},this._deduped=new a.DedupedRequest}load(){this._loaded=!1,this.fire(new a.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=ab(this._options,this.map._requestManager,(c,b)=>{this._tileJSONRequest=null,this._loaded=!0,c?this.fire(new a.ErrorEvent(c)):b&&(a.extend(this,b),b.bounds&&(this.tileBounds=new ac(b.bounds,this.minzoom,this.maxzoom)),a.postTurnstileEvent(b.tiles,this.map._requestManager._customAccessToken),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new a.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}hasTile(a){return!this.tileBounds||this.tileBounds.contains(a.canonical)}onAdd(a){this.map=a,this.load()}setSourceProperty(a){this._tileJSONRequest&&this._tileJSONRequest.cancel(),a();const b=this.map.style._getSourceCaches(this.id);for(const c of b)c.clearTiles();this.load()}setTiles(a){return this.setSourceProperty(()=>{this._options.tiles=a}),this}setUrl(a){return this.setSourceProperty(()=>{this.url=a,this._options.url=a}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return a.extend({},this._options)}loadTile(b,e){const d=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme)),c={request:this.map._requestManager.transformRequest(d,a.ResourceType.Tile),data:void 0,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,tileSize:this.tileSize*b.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:b.isSymbolTile};if(c.request.collectResourceTiming=this._collectResourceTiming,b.actor&&"expired"!==b.state)"loading"===b.state?b.reloadCallback=e:b.request=b.actor.send("reloadTile",c,g.bind(this));else if(b.actor=this._tileWorkers[d]=this._tileWorkers[d]||this.dispatcher.getActor(),this.dispatcher.ready)b.request=b.actor.send("loadTile",c,g.bind(this),void 0,!0);else{const f=a.loadVectorTile.call({deduped:this._deduped},c,(d,a)=>{d||!a?g.call(this,d):(c.data={cacheControl:a.cacheControl,expires:a.expires,rawData:a.rawData.slice(0)},b.actor&&b.actor.send("loadTile",c,g.bind(this),void 0,!0))},!0);b.request={cancel:f}}function g(d,c){return delete b.request,b.aborted?e(null):d&&404!==d.status?e(d):(c&&c.resourceTiming&&(b.resourceTiming=c.resourceTiming),this.map._refreshExpiredTiles&&c&&b.setExpiryData(c),b.loadVectorData(c,this.map.painter),a.cacheEntryPossiblyAdded(this.dispatcher),e(null),void(b.reloadCallback&&(this.loadTile(b,b.reloadCallback),b.reloadCallback=null)))}}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.actor&&a.actor.send("abortTile",{uid:a.uid,type:this.type,source:this.id})}unloadTile(a){a.unloadVectorData(),a.actor&&a.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}},raster:r,"raster-dem":class extends r{constructor(c,b,d,e){super(c,b,d,e),this.type="raster-dem",this.maxzoom=22,this._options=a.extend({type:"raster-dem"},b),this.encoding=b.encoding||"mapbox"}loadTile(b,d){const c=this.map._requestManager.normalizeTileURL(b.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function e(a,c){a&&(b.state="errored",d(a)),c&&(b.dem=c,b.dem.onDeserialize(),b.needsHillshadePrepare=!0,b.needsDEMTextureUpload=!0,b.state="loaded",d(null))}b.request=a.getImage(this.map._requestManager.transformRequest(c,a.ResourceType.Tile),(function(g,c,h,i){if(delete b.request,b.aborted)b.state="unloaded",d(null);else if(g)b.state="errored",d(g);else if(c){this.map._refreshExpiredTiles&&b.setExpiryData({cacheControl:h,expires:i});const j=a.window.ImageBitmap&&c instanceof a.window.ImageBitmap&&(null==ad&&(ad=a.window.OffscreenCanvas&&new a.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof a.window.createImageBitmap),ad),f=1-(c.width-a.prevPowerOfTwo(c.width))/2;f<1||b.neighboringTiles||(b.neighboringTiles=this._getNeighboringTiles(b.tileID));const k=j?c:a.exported.getImageData(c,f),l={uid:b.uid,coord:b.tileID,source:this.id,rawImageData:k,encoding:this.encoding,padding:f};b.actor&&"expired"!==b.state||(b.actor=this.dispatcher.getActor(),b.actor.send("loadDEMTile",l,e.bind(this),void 0,!0))}}).bind(this))}_getNeighboringTiles(c){const b=c.canonical,e=Math.pow(2,b.z),f=(b.x-1+e)%e,g=0===b.x?c.wrap-1:c.wrap,h=(b.x+1+e)%e,i=b.x+1===e?c.wrap+1:c.wrap,d={};return d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y).key]={backfilled:!1},b.y>0&&(d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,c.wrap,b.z,b.x,b.y-1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y-1).key]={backfilled:!1}),b.y+1<e&&(d[new a.OverscaledTileID(c.overscaledZ,g,b.z,f,b.y+1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,c.wrap,b.z,b.x,b.y+1).key]={backfilled:!1},d[new a.OverscaledTileID(c.overscaledZ,i,b.z,h,b.y+1).key]={backfilled:!1}),d}unloadTile(a){a.demTexture&&this.map.painter.saveTileTexture(a.demTexture),a.fbo&&(a.fbo.destroy(),delete a.fbo),a.dem&&delete a.dem,delete a.neighboringTiles,a.state="unloaded"}},geojson:class extends a.Evented{constructor(d,b,e,f){super(),this.id=d,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=e.getActor(),this.setEventedParent(f),this._data=b.data,this._options=a.extend({},b),this._collectResourceTiming=b.collectResourceTiming,void 0!==b.maxzoom&&(this.maxzoom=b.maxzoom),b.type&&(this.type=b.type),b.attribution&&(this.attribution=b.attribution),this.promoteId=b.promoteId;const c=a.EXTENT/this.tileSize;this.workerOptions=a.extend({source:this.id,cluster:b.cluster||!1,geojsonVtOptions:{buffer:(void 0!==b.buffer?b.buffer:128)*c,tolerance:(void 0!==b.tolerance?b.tolerance:.375)*c,extent:a.EXTENT,maxZoom:this.maxzoom,lineMetrics:b.lineMetrics||!1,generateId:b.generateId||!1},superclusterOptions:{maxZoom:void 0!==b.clusterMaxZoom?b.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,b.clusterMinPoints||2),extent:a.EXTENT,radius:(void 0!==b.clusterRadius?b.clusterRadius:50)*c,log:!1,generateId:b.generateId||!1},clusterProperties:b.clusterProperties,filter:b.filter},b.workerOptions)}onAdd(a){this.map=a,this.setData(this._data)}setData(a){return this._data=a,this._updateWorkerData(),this}getClusterExpansionZoom(a,b){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:a,source:this.id},b),this}getClusterChildren(a,b){return this.actor.send("geojson.getClusterChildren",{clusterId:a,source:this.id},b),this}getClusterLeaves(a,b,c,d){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:a,limit:b,offset:c},d),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new a.Event("dataloading",{dataType:"source"})),this._loaded=!1;const b=a.extend({},this.workerOptions),c=this._data;"string"==typeof c?(b.request=this.map._requestManager.transformRequest(a.exported.resolveURL(c),a.ResourceType.Source),b.request.collectResourceTiming=this._collectResourceTiming):b.data=JSON.stringify(c),this._pendingLoad=this.actor.send(`${this.type}.loadData`,b,(c,b)=>{if(this._loaded=!0,this._pendingLoad=null,c)this.fire(new a.ErrorEvent(c));else{const d={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&b&&b.resourceTiming&&b.resourceTiming[this.id]&&(d.resourceTiming=b.resourceTiming[this.id]),this.fire(new a.Event("data",d)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(b,d){const c=b.actor?"reloadTile":"loadTile";b.actor=this.actor,b.request=this.actor.send(c,{type:this.type,uid:b.uid,tileID:b.tileID,tileZoom:b.tileZoom,zoom:b.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:a.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(a,e)=>(delete b.request,b.unloadVectorData(),b.aborted?d(null):a?d(a):(b.loadVectorData(e,this.map.painter,"reloadTile"===c),d(null))),void 0,"loadTile"===c)}abortTile(a){a.request&&(a.request.cancel(),delete a.request),a.aborted=!0}unloadTile(a){a.unloadVectorData(),this.actor.send("removeTile",{uid:a.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return a.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends s{constructor(b,a,c,d){super(b,a,c,d),this.roundZoom=!0,this.type="video",this.options=a}load(){this._loaded=!1;const b=this.options;for(const c of(this.urls=[],b.urls))this.urls.push(this.map._requestManager.transformRequest(c,a.ResourceType.Source).url);a.getVideo(this.urls,(b,c)=>{this._loaded=!0,b?this.fire(new a.ErrorEvent(b)):c&&(this.video=c,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(c){if(this.video){const b=this.video.seekable;c<b.start(0)||c>b.end(0)?this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${b.start(0)} and ${b.end(0)}-second mark.`))):this.video.currentTime=c}}getVideo(){return this.video}onAdd(a){this.map||(this.map=a,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 c=this.map.painter.context,b=c.gl;for(const e in this.texture?this.video.paused||(this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,this.video)):(this.texture=new a.Texture(c,this.video,b.RGBA),this.texture.bind(b.LINEAR,b.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.tiles){const d=this.tiles[e];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:s,canvas:class extends s{constructor(c,b,d,e){super(c,b,d,e),b.coordinates?Array.isArray(b.coordinates)&&4===b.coordinates.length&&!b.coordinates.some(a=>!Array.isArray(a)||2!==a.length||a.some(a=>"number"!=typeof a))||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "coordinates"'))),b.animate&&"boolean"!=typeof b.animate&&this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'optional "animate" property must be a boolean value'))),b.canvas?"string"==typeof b.canvas||b.canvas instanceof a.window.HTMLCanvasElement||this.fire(new a.ErrorEvent(new a.ValidationError(`sources.${c}`,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 a.ErrorEvent(new a.ValidationError(`sources.${c}`,null,'missing required property "canvas"'))),this.options=b,this.animate=void 0===b.animate||b.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof a.window.HTMLCanvasElement?this.options.canvas:a.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new a.ErrorEvent(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(a){this.map=a,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let b=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,b=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,b=!0),this._hasInvalidDimensions()||0===Object.keys(this.tiles).length)return;const c=this.map.painter.context,e=c.gl;for(const f in this._boundsArray||this._makeBoundsArray(),this.boundsBuffer||(this.boundsBuffer=c.createVertexBuffer(this._boundsArray,a.boundsAttributes.members)),this.boundsSegments||(this.boundsSegments=a.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(b||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new a.Texture(c,this.canvas,e.RGBA,{premultiply:!0}),this.tiles){const d=this.tiles[f];"loaded"!==d.state&&(d.state="loaded",d.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const a of[this.canvas.width,this.canvas.height,])if(isNaN(a)||a<=0)return!0;return!1}}},ag=function(c,d,e,f){const b=new af[d.type](c,d,e,f);if(b.id!==c)throw Error(`Expected Source id to be ${c} instead of ${b.id}`);return a.bindAll(["load","abort","unload","serialize","prepare",],b),b};function ah(c,d){const b=a.identity([]);return a.scale(b,b,[.5*c.width,-(.5*c.height),1,]),a.translate(b,b,[1,-1,0]),a.multiply$1(b,b,c.calculateProjMatrix(d.toUnwrapped()))}function ai(b,g,h,i,j,k,l,d=!1){const e=b.tilesIn(i,l,d);e.sort(ak);const f=[];for(const a of e)f.push({wrappedTileID:a.tile.tileID.wrapped().key,queryResults:a.tile.queryRenderedFeatures(g,h,b._state,a,j,k,ah(b.transform,a.tile.tileID),d)});const c=function(j){const b={},d={};for(const e of j){const f=e.queryResults,g=e.wrappedTileID,h=d[g]=d[g]||{};for(const a in f){const k=f[a],i=h[a]=h[a]||{},l=b[a]=b[a]||[];for(const c of k)i[c.featureIndex]||(i[c.featureIndex]=!0,l.push(c))}}return b}(f);for(const m in c)c[m].forEach(c=>{const a=c.feature,d=b.getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=d});return c}function aj(g,h){const b=g.getRenderableIds().map(a=>g.getTileByID(a)),c=[],d={};for(let a=0;a<b.length;a++){const e=b[a],f=e.tileID.canonical.key;d[f]||(d[f]=!0,e.querySourceFeatures(c,h))}return c}function ak(c,d){const a=c.tileID,b=d.tileID;return a.overscaledZ-b.overscaledZ||a.canonical.y-b.canonical.y||a.wrap-b.wrap||a.canonical.x-b.canonical.x}function al(){return null!=A.workerClass?new A.workerClass:new a.window.Worker(A.workerUrl)}const am="mapboxgl_preloaded_worker_pool";class e{constructor(){this.active={}}acquire(a){if(!this.workers)for(this.workers=[];this.workers.length<e.workerCount;)this.workers.push(new al);return this.active[a]=!0,this.workers.slice()}release(a){delete this.active[a],0===this.numActive()&&(this.workers.forEach(a=>{a.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[am]}numActive(){return Object.keys(this.active).length}}let an;function ao(){return an||(an=new e),an}function ap(c,e){const d={};for(const b in c)"ref"!==b&&(d[b]=c[b]);return a.refProperties.forEach(a=>{a in e&&(d[a]=e[a])}),d}function aq(a){a=a.slice();const d=Object.create(null);for(let c=0;c<a.length;c++)d[a[c].id]=a[c];for(let b=0;b<a.length;b++)"ref"in a[b]&&(a[b]=ap(a[b],d[a[b].ref]));return a}e.workerCount=2;const i={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 ar(a,b,c){c.push({command:i.addSource,args:[a,b[a]]})}function as(a,b,c){b.push({command:i.removeSource,args:[a]}),c[a]=!0}function at(a,c,b,d){as(a,b,d),ar(a,c,b)}function au(c,d,b){let a;for(a in c[b])if(c[b].hasOwnProperty(a)&&"data"!==a&&!D(c[b][a],d[b][a]))return!1;for(a in d[b])if(d[b].hasOwnProperty(a)&&"data"!==a&&!D(c[b][a],d[b][a]))return!1;return!0}function av(c,b,d,e,f,g){let a;for(a in b=b||{},c=c||{})c.hasOwnProperty(a)&&(D(c[a],b[a])||d.push({command:g,args:[e,a,b[a],f]}));for(a in b)b.hasOwnProperty(a)&&!c.hasOwnProperty(a)&&(D(c[a],b[a])||d.push({command:g,args:[e,a,b[a],f]}))}function aw(a){return a.id}function ax(a,b){return a[b.id]=b,a}class ay{constructor(a,b){this.reset(a,b)}reset(b,c){this.points=b||[],this._distances=[0];for(let a=1;a<this.points.length;a++)this._distances[a]=this._distances[a-1]+this.points[a].dist(this.points[a-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(c||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(c){if(1===this.points.length)return this.points[0];c=a.clamp(c,0,1);let b=1,d=this._distances[b];const e=c*this.paddedLength+this.padding;for(;d<e&&b<this._distances.length;)d=this._distances[++b];const f=b-1,g=this._distances[f],h=d-g,i=h>0?(e-g)/h:0;return this.points[f].mult(1-i).add(this.points[b].mult(i))}}class az{constructor(a,b,c){const e=this.boxCells=[],f=this.circleCells=[];this.xCellCount=Math.ceil(a/c),this.yCellCount=Math.ceil(b/c);for(let d=0;d<this.xCellCount*this.yCellCount;d++)e.push([]),f.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=a,this.height=b,this.xScale=this.xCellCount/a,this.yScale=this.yCellCount/b,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(e,a,b,c,d){this._forEachCell(a,b,c,d,this._insertBoxCell,this.boxUid++),this.boxKeys.push(e),this.bboxes.push(a),this.bboxes.push(b),this.bboxes.push(c),this.bboxes.push(d)}insertCircle(d,b,c,a){this._forEachCell(b-a,c-a,b+a,c+a,this._insertCircleCell,this.circleUid++),this.circleKeys.push(d),this.circles.push(b),this.circles.push(c),this.circles.push(a)}_insertBoxCell(c,d,e,f,a,b){this.boxCells[a].push(b)}_insertCircleCell(c,d,e,f,a,b){this.circleCells[a].push(b)}_query(f,g,h,i,d,j){if(h<0||f>this.width||i<0||g>this.height)return!d&&[];const a=[];if(f<=0&&g<=0&&this.width<=h&&this.height<=i){if(d)return!0;for(let b=0;b<this.boxKeys.length;b++)a.push({key:this.boxKeys[b],x1:this.bboxes[4*b],y1:this.bboxes[4*b+1],x2:this.bboxes[4*b+2],y2:this.bboxes[4*b+3]});for(let c=0;c<this.circleKeys.length;c++){const k=this.circles[3*c],l=this.circles[3*c+1],e=this.circles[3*c+2];a.push({key:this.circleKeys[c],x1:k-e,y1:l-e,x2:k+e,y2:l+e})}return j?a.filter(j):a}return this._forEachCell(f,g,h,i,this._queryCell,a,{hitTest:d,seenUids:{box:{},circle:{}}},j),d?a.length>0:a}_queryCircle(b,c,a,d,j){const f=b-a,g=b+a,h=c-a,i=c+a;if(g<0||f>this.width||i<0||h>this.height)return!d&&[];const e=[];return this._forEachCell(f,h,g,i,this._queryCellCircle,e,{hitTest:d,circle:{x:b,y:c,radius:a},seenUids:{box:{},circle:{}}},j),d?e.length>0:e}query(a,b,c,d,e){return this._query(a,b,c,d,!1,e)}hitTest(a,b,c,d,e){return this._query(a,b,c,d,!0,e)}hitTestCircle(a,b,c,d){return this._queryCircle(a,b,c,!0,d)}_queryCell(l,m,n,o,p,g,k,h){const i=k.seenUids,q=this.boxCells[p];if(null!==q){const a=this.bboxes;for(const e of q)if(!i.box[e]){i.box[e]=!0;const b=4*e;if(l<=a[b+2]&&m<=a[b+3]&&n>=a[b+0]&&o>=a[b+1]&&(!h||h(this.boxKeys[e]))){if(k.hitTest)return g.push(!0),!0;g.push({key:this.boxKeys[e],x1:a[b],y1:a[b+1],x2:a[b+2],y2:a[b+3]})}}}const r=this.circleCells[p];if(null!==r){const c=this.circles;for(const f of r)if(!i.circle[f]){i.circle[f]=!0;const d=3*f;if(this._circleAndRectCollide(c[d],c[d+1],c[d+2],l,m,n,o)&&(!h||h(this.circleKeys[f]))){if(k.hitTest)return g.push(!0),!0;{const s=c[d],t=c[d+1],j=c[d+2];g.push({key:this.circleKeys[f],x1:s-j,y1:t-j,x2:s+j,y2:t+j})}}}}}_queryCellCircle(o,p,q,r,j,k,l,b){const a=l.circle,c=l.seenUids,m=this.boxCells[j];if(null!==m){const d=this.bboxes;for(const e of m)if(!c.box[e]){c.box[e]=!0;const f=4*e;if(this._circleAndRectCollide(a.x,a.y,a.radius,d[f+0],d[f+1],d[f+2],d[f+3])&&(!b||b(this.boxKeys[e])))return k.push(!0),!0}}const n=this.circleCells[j];if(null!==n){const h=this.circles;for(const g of n)if(!c.circle[g]){c.circle[g]=!0;const i=3*g;if(this._circlesCollide(h[i],h[i+1],h[i+2],a.x,a.y,a.radius)&&(!b||b(this.circleKeys[g])))return k.push(!0),!0}}}_forEachCell(c,d,e,f,g,h,i,j){const k=this._convertToXCellCoord(c),l=this._convertToYCellCoord(d),m=this._convertToXCellCoord(e),n=this._convertToYCellCoord(f);for(let a=k;a<=m;a++)for(let b=l;b<=n;b++)if(g.call(this,c,d,e,f,this.xCellCount*b+a,h,i,j))return}_convertToXCellCoord(a){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(a*this.xScale)))}_convertToYCellCoord(a){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(a*this.yScale)))}_circlesCollide(d,e,f,g,h,i){const a=g-d,b=h-e,c=f+i;return c*c>a*a+b*b}_circleAndRectCollide(j,k,a,f,g,l,m){const b=(l-f)/2,d=Math.abs(j-(f+b));if(d>b+a)return!1;const c=(m-g)/2,e=Math.abs(k-(g+c));if(e>c+a)return!1;if(d<=b||e<=c)return!0;const h=d-b,i=e-c;return h*h+i*i<=a*a}}const aA=Math.tan(85*Math.PI/180);function aB(e,f,g,h,c,i){let b=a.create();if(g){if("globe"===c.projection.name)b=a.calculateGlobeMatrix(c,c.worldSize/c._projectionScaler,[0,0]),a.multiply$1(b,b,a.globeDenormalizeECEF(a.globeTileBounds(f)));else{const d=C([],i);b[0]=d[0],b[1]=d[1],b[4]=d[2],b[5]=d[3]}h||a.rotateZ(b,b,c.angle)}else a.multiply$1(b,c.labelPlaneMatrix,e);return b}function aC(g,j,h,i,f,b){if(h){if("globe"===f.projection.name){const c=aB(g,j,h,i,f,b);return a.invert(c,c),a.multiply$1(c,g,c),c}{const d=a.clone(g),e=a.identity([]);return e[0]=b[0],e[1]=b[1],e[4]=b[2],e[5]=b[3],a.multiply$1(d,d,e),i||a.rotateZ(d,d,-f.angle),d}}return f.glCoordMatrix}function aD(d,e,f=0){const b=[d.x,d.y,f,1];f?a.transformMat4$1(b,b,e):aP(b,b,e);const c=b[3];return{point:new a.pointGeometry(b[0]/c,b[1]/c),signedDistanceFromCamera:c}}function aE(a,b){return Math.min(.5+a/b*.5,1.5)}function aF(a,b){const c=a[0]/a[3],d=a[1]/a[3];return c>= -b[0]&&c<=b[0]&&d>= -b[1]&&d<=b[1]}function aG(c,m,e,i,n,x,y,z,o,p){const q=e.transform,A=i?c.textSizeData:c.iconSizeData,G=a.evaluateSizeForZoom(A,e.transform.zoom),H=[256/e.width*2+1,256/e.height*2+1,],d=i?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;d.clear();const B=c.lineVertexArray,r=i?c.text.placedSymbolArray:c.icon.placedSymbolArray,C=e.transform.width/e.transform.height;let f=!1;for(let g=0;g<r.length;g++){const b=r.get(g);if(b.writingMode!==a.WritingMode.vertical||f||0!==g&&r.get(g-1).writingMode===a.WritingMode.horizontal||(f=!0),b.hidden||b.writingMode===a.WritingMode.vertical&&!f){aO(b.numGlyphs,d);continue}f=!1;const h=new a.pointGeometry(b.tileAnchorX,b.tileAnchorY),s=o?o(h):[0,0,0],t=q.projection.projectTilePoint(h.x,h.y,p.canonical),j=[t.x+s[0],t.y+s[1],t.z+s[2]],k=[...j,1];if(a.transformMat4$1(k,k,m),!aF(k,H)){aO(b.numGlyphs,d);continue}const D=aE(e.transform.cameraToCenterDistance,k[3]),E=a.evaluateSizeForFeature(A,G,b),F=y?E/D:E*D,u=aD(new a.pointGeometry(j[0],j[1]),n,j[2]);if(u.signedDistanceFromCamera<=0){aO(b.numGlyphs,d);continue}let v={};const w=y?null:o,l=aJ(b,F,!1,z,m,n,x,c.glyphOffsetArray,B,d,u.point,h,v,C,w,q.projection,p);f=l.useVertical,w&&l.needsFlipping&&(v={}),(l.notEnoughRoom||f||l.needsFlipping&&aJ(b,F,!0,z,m,n,x,c.glyphOffsetArray,B,d,u.point,h,v,C,w,q.projection,p).notEnoughRoom)&&aO(b.numGlyphs,d)}i?c.text.dynamicLayoutVertexBuffer.updateData(d):c.icon.dynamicLayoutVertexBuffer.updateData(d)}function aH(b,c,d,e,f,g,h,a,i,j,k,l,m,n,o){const t=a.glyphStartIndex+a.numGlyphs,p=a.lineStartIndex,q=a.lineStartIndex+a.lineLength,u=c.getoffsetX(a.glyphStartIndex),v=c.getoffsetX(t-1),r=aM(b*u,d,e,f,g,h,a.segment,p,q,i,j,k,l,m,!0,n,o);if(!r)return null;const s=aM(b*v,d,e,f,g,h,a.segment,p,q,i,j,k,l,m,!0,n,o);return s?{first:r,last:s}:null}function aI(d,b,c,e){return d.writingMode===a.WritingMode.horizontal&&Math.abs(c.y-b.y)>Math.abs(c.x-b.x)*e?{useVertical:!0}:d.writingMode===a.WritingMode.vertical?b.y<c.y?{needsFlipping:!0}:null:0!==d.flipState&&function(a,b,d){const c=(b.x-a.x)*d;return 0===c||Math.abs((b.y-a.y)/c)>aA}(b,c,e)?1===d.flipState?{needsFlipping:!0}:null:b.x>c.x?{needsFlipping:!0}:null}function aJ(b,E,c,v,m,n,w,o,d,F,p,e,q,x,r,i,j){const f=E/24,s=b.lineOffsetX*f,t=b.lineOffsetY*f;let g;if(b.numGlyphs>1){const G=b.glyphStartIndex+b.numGlyphs,H=b.lineStartIndex,I=b.lineStartIndex+b.lineLength,h=aH(f,o,s,t,c,p,e,b,d,n,q,r,!1,i,j);if(!h)return{notEnoughRoom:!0};const J=aD(h.first.point,w).point,K=aD(h.last.point,w).point;if(v&&!c){const k=aI(b,J,K,x);if(b.flipState=k&&k.needsFlipping?1:2,k)return k}g=[h.first];for(let u=b.glyphStartIndex+1;u<G-1;u++)g.push(aM(f*o.getoffsetX(u),s,t,c,p,e,b.segment,H,I,d,n,q,r,!1,!1,i,j));g.push(h.last)}else{if(v&&!c){const y=aD(e,m).point,z=b.lineStartIndex+b.segment+1,A=new a.pointGeometry(d.getx(z),d.gety(z)),B=aD(A,m),l=aI(b,y,B.signedDistanceFromCamera>0?B.point:aL(e,A,y,1,m,void 0,i,j.canonical),x);if(b.flipState=l&&l.needsFlipping?1:2,l)return l}const C=aM(f*o.getoffsetX(b.glyphStartIndex),s,t,c,p,e,b.segment,b.lineStartIndex,b.lineStartIndex+b.lineLength,d,n,q,r,!1,!1,i,j);if(!C)return{notEnoughRoom:!0};g=[C]}for(const D of g)a.addDynamicAttributes(F,D.point,D.angle);return{}}function aK(c,g,e,h,f){const b=h.projectTilePoint(c.x,c.y,g);if(!f)return aD(b,e,b.z);const d=f(c);return aD(new a.pointGeometry(b.x+d[0],b.y+d[1]),e,b.z+d[2])}function aL(a,d,b,e,f,g,h,i){const j=aK(a.add(a.sub(d)._unit()),i,f,h,g).point,c=b.sub(j);return b.add(c._mult(e/c.mag()))}function aM(p,q,r,s,t,D,u,k,E,f,F,j,v,w,G,H,I){const x=s?p-q:p+q;let h=x>0?1:-1,l=0;s&&(h*=-1,l=Math.PI),h<0&&(l+=Math.PI);let b=h>0?k+u:k+u+1,c=t,e=t,m=0,i=0;const y=Math.abs(x),n=[],g=[];let d=D;const J=()=>{const c=b-h;return 0===m?D:new a.pointGeometry(f.getx(c),f.gety(c))},z=()=>aL(J(),d,e,y-m+1,F,v,H,I.canonical);for(;m+i<=y;){if((b+=h)<k||b>=E)return null;if(e=c,n.push(c),w&&g.push(d||J()),void 0===(c=j[b])){d=new a.pointGeometry(f.getx(b),f.gety(b));const A=aK(d,I.canonical,F,H,v);c=A.signedDistanceFromCamera>0?j[b]=A.point:z()}else d=null;m+=i,i=e.dist(c)}G&&v&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),j[b]=c=void 0===j[b]?c:z(),i=e.dist(c));const B=(y-m)/i,C=c.sub(e),o=C.mult(B)._add(e);r&&o._add(C._unit()._perp()._mult(r*h));const K=l+Math.atan2(c.y-e.y,c.x-e.x);return n.push(o),w&&(d=d||new a.pointGeometry(f.getx(b),f.gety(b)),g.push(function(c,d,b){const e=1-b;return new a.pointGeometry(c.x*e+d.x*b,c.y*e+d.y*b)}(g.length>0?g[g.length-1]:d,d,B))),{point:o,angle:K,path:n,tilePath:g}}const aN=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,]);function aO(d,a){for(let b=0;b<d;b++){const c=a.length;a.resize(c+4),a.float32.set(aN,3*c)}}function aP(b,e,a){const c=e[0],d=e[1];return b[0]=a[0]*c+a[4]*d+a[12],b[1]=a[1]*c+a[5]*d+a[13],b[3]=a[3]*c+a[7]*d+a[15],b}class aQ{constructor(a,b,c,d){this.opacity=a?Math.max(0,Math.min(1,a.opacity+(a.placed?b:-b))):d&&c?1:0,this.placed=c}isHidden(){return 0===this.opacity&&!this.placed}}class aR{constructor(a,b,d,e,c,f=!1){this.text=new aQ(a?a.text:null,b,d,c),this.icon=new aQ(a?a.icon:null,b,e,c),this.clipped=f}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class aS{constructor(a,b,c,d=!1){this.text=a,this.icon=b,this.skipFade=c,this.clipped=d}}class aT{constructor(){this.invProjMatrix=a.create(),this.viewportMatrix=a.create(),this.circles=[]}}class aU{constructor(a,b,c,d,e){this.bucketInstanceId=a,this.featureIndex=b,this.sourceLayerIndex=c,this.bucketIndex=d,this.tileID=e}}function aV(b,e,f,g,c){const{horizontalAlign:h,verticalAlign:i}=a.getAnchorAlignment(b),d=a.evaluateVariableOffset(b,g);return new a.pointGeometry(-(h-.5)*e+d[0]*c,-(i-.5)*f+d[1]*c)}function aW(d,e,f,g,b){const c=new a.pointGeometry(d,e);return f&&c._rotate(g?b:-b),c}function aX(a,b,c,d,e){a.emplaceBack(b?1:0,c?1:0,d||0,e||0),a.emplaceBack(b?1:0,c?1:0,d||0,e||0),a.emplaceBack(b?1:0,c?1:0,d||0,e||0),a.emplaceBack(b?1:0,c?1:0,d||0,e||0)}function aY(a){if(0===a.opacity&&!a.placed)return 0;if(1===a.opacity&&a.placed)return 4294967295;const b=a.placed?1:0,c=Math.floor(127*a.opacity);return 33554432*c+16777216*b+131072*c+65536*b+512*c+256*b+2*c+b}class aZ{constructor(a){this._sortAcrossTiles="viewport-y"!==a.layout.get("symbol-z-order")&& void 0!==a.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(b,c,f,g,d){const a=this._bucketParts;for(;this._currentTileIndex<b.length;)if(c.getBucketParts(a,g,b[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,d())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,a.sort((a,b)=>a.sortKey-b.sortKey));this._currentPartIndex<a.length;){const e=a[this._currentPartIndex];if(c.placeLayerBucketPart(e,this._seenCrossTileIDs,f,0===e.symbolInstanceStart),this._currentPartIndex++,d())return!0}return!1}}class a${constructor(b,c,d,e,f,g,h,i){this.placement=new class{constructor(c,d,e,b,f){this.transform=c.clone(),this.collisionIndex=new class{constructor(a,b,c=new az(a.width+200,a.height+200,25),d=new az(a.width+200,a.height+200,25)){this.transform=a,this.grid=c,this.ignoredGrid=d,this.pitchfactor=Math.cos(a._pitch)*a.cameraToCenterDistance,this.screenRightBoundary=a.width+100,this.screenBottomBoundary=a.height+100,this.gridRightBoundary=a.width+200,this.gridBottomBoundary=a.height+200,this.fogState=b}placeCollisionBox(c,a,d,r,s,t,u){let n=a.projectedAnchorX,o=a.projectedAnchorY,p=a.projectedAnchorZ;const e=a.elevation,k=a.tileID;if(e&&k){const q=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),l=q.upVector(k.canonical,a.tileAnchorX,a.tileAnchorY),m=q.upVectorScale(k.canonical);n+=l[0]*e*m,o+=l[1]*e*m,p+=l[2]*e*m}const b=this.projectAndGetPerspectiveRatio(t,n,o,p,a.tileID),f=s*b.perspectiveRatio,g=(a.x1*c+d.x-a.padding)*f+b.point.x,h=(a.y1*c+d.y-a.padding)*f+b.point.y,i=(a.x2*c+d.x+a.padding)*f+b.point.x,j=(a.y2*c+d.y+a.padding)*f+b.point.y,v=b.perspectiveRatio<=.55||b.aboveHorizon;return!this.isInsideGrid(g,h,i,j)|| !r&&this.grid.hitTest(g,h,i,j,u)||v?{box:[],offscreen:!1}:{box:[g,h,i,j],offscreen:this.isOffscreen(g,h,i,j)}}placeCollisionCircles(S,f,T,U,D,V,E,W,F,q,X,Y,Z,l){const G=[],k=this.transform.elevation,$=this.transform.projection.createTileTransform(this.transform,this.transform.worldSize),H=k?k.getAtTileOffsetFunc(l,$):a=>[0,0,0],I=new a.pointGeometry(f.tileAnchorX,f.tileAnchorY),r=this.transform.projection.projectTilePoint(f.tileAnchorX,f.tileAnchorY,l.canonical),s=H(I),g=[r.x+s[0],r.y+s[1],r.z+s[2]],t=this.projectAndGetPerspectiveRatio(V,g[0],g[1],g[2],l),{perspectiveRatio:u}=t,v=(q?D/u:D*u)/a.ONE_EM,_=aD(new a.pointGeometry(g[0],g[1]),E,g[2]).point,w=t.signedDistanceFromCamera>0?aH(v,U,f.lineOffsetX*v,f.lineOffsetY*v,!1,_,I,f,T,E,{},k&&!q?H:null,q&&!!k,this.transform.projection,l):null;let m=!1,x=!1,y=!0;if(w&&!t.aboveHorizon){const c=.5*Y*u+Z,h=new a.pointGeometry(-100,-100),i=new a.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new ay,J=w.first,K=w.last;let b=[];for(let z=J.path.length-1;z>=1;z--)b.push(J.path[z]);for(let A=1;A<K.path.length;A++)b.push(K.path[A]);const aa=2.5*c;if(W){const L=b.map(k?(b,a)=>{const c=H(a<J.path.length-1?J.tilePath[J.path.length-1-a]:K.tilePath[a-J.path.length+2]);return aD(b,W,c[2])}:a=>aD(a,W));b=L.some(a=>a.signedDistanceFromCamera<=0)?[]:L.map(a=>a.point)}let M=[];if(b.length>0){const d=b[0].clone(),e=b[0].clone();for(let j=1;j<b.length;j++)d.x=Math.min(d.x,b[j].x),d.y=Math.min(d.y,b[j].y),e.x=Math.max(e.x,b[j].x),e.y=Math.max(e.y,b[j].y);M=d.x>=h.x&&e.x<=i.x&&d.y>=h.y&&e.y<=i.y?[b]:e.x<h.x||d.x>i.x||e.y<h.y||d.y>i.y?[]:a.clipLine([b],h.x,h.y,i.x,i.y)}for(const ab of M){n.reset(ab,.25*c);let B=0;B=n.length<=.5*c?1:Math.ceil(n.paddedLength/aa)+1;for(let C=0;C<B;C++){const ac=C/Math.max(B-1,1),N=n.lerp(ac),o=N.x+100,p=N.y+100;G.push(o,p,c,0);const O=o-c,P=p-c,Q=o+c,R=p+c;if(y=y&&this.isOffscreen(O,P,Q,R),x=x||this.isInsideGrid(O,P,Q,R),!S&&this.grid.hitTestCircle(o,p,c,X)&&(m=!0,!F))return{circles:[],offscreen:!1,collisionDetected:m}}}}return{circles:(F||!m)&&x?G:[],offscreen:y,collisionDetected:m}}queryRenderedSymbols(k){if(0===k.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const l=[];let e=1/0,f=1/0,g=-1/0,h=-1/0;for(const m of k){const d=new a.pointGeometry(m.x+100,m.y+100);e=Math.min(e,d.x),f=Math.min(f,d.y),g=Math.max(g,d.x),h=Math.max(h,d.y),l.push(d)}const n=this.grid.query(e,f,g,h).concat(this.ignoredGrid.query(e,f,g,h)),i={},j={};for(const c of n){const b=c.key;if(void 0===i[b.bucketInstanceId]&&(i[b.bucketInstanceId]={}),i[b.bucketInstanceId][b.featureIndex])continue;const o=[new a.pointGeometry(c.x1,c.y1),new a.pointGeometry(c.x2,c.y1),new a.pointGeometry(c.x2,c.y2),new a.pointGeometry(c.x1,c.y2),];a.polygonIntersectsPolygon(l,o)&&(i[b.bucketInstanceId][b.featureIndex]=!0,void 0===j[b.bucketInstanceId]&&(j[b.bucketInstanceId]=[]),j[b.bucketInstanceId].push(b.featureIndex))}return j}insertCollisionBox(a,b,c,d,e){(b?this.ignoredGrid:this.grid).insert({bucketInstanceId:c,featureIndex:d,collisionGroupID:e},a[0],a[1],a[2],a[3])}insertCollisionCircles(b,c,d,e,f){const g=c?this.ignoredGrid:this.grid,h={bucketInstanceId:d,featureIndex:e,collisionGroupID:f};for(let a=0;a<b.length;a+=4)g.insertCircle(h,b[a],b[a+1],b[a+2])}projectAndGetPerspectiveRatio(d,e,f,c,g){const b=[e,f,c||0,1];let h=!1;if(c||this.transform.pitch>0){a.transformMat4$1(b,b,d);let i=!1;this.fogState&&g&&(i=function(d,e,f,g,h,b){const i=b.calculateFogTileMatrix(h),c=[e,f,g];return a.transformMat4(c,c,i),Q(d,c,b.pitch,b._fov)}(this.fogState,e,f,c||0,g.toUnwrapped(),this.transform)>.9),h=b[2]>b[3]||i}else aP(b,b,d);return{point:new a.pointGeometry((b[0]/b[3]+1)/2*this.transform.width+100,(-b[1]/b[3]+1)/2*this.transform.height+100),perspectiveRatio:Math.min(.5+this.transform.cameraToCenterDistance/b[3]*.5,1.5),signedDistanceFromCamera:b[3],aboveHorizon:h}}isOffscreen(a,b,c,d){return c<100||a>=this.screenRightBoundary||d<100||b>this.screenBottomBoundary}isInsideGrid(a,b,c,d){return c>=0&&a<this.gridRightBoundary&&d>=0&&b<this.gridBottomBoundary}getViewportMatrix(){const b=a.identity([]);return a.translate(b,b,[-100,-100,0]),b}}(this.transform,f),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=d,this.retainedQueryData={},this.collisionGroups=new class{constructor(a){this.crossSourceCollisions=a,this.maxGroupID=0,this.collisionGroups={}}get(a){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[a]){const b=++this.maxGroupID;this.collisionGroups[a]={ID:b,predicate:a=>a.collisionGroupID===b}}return this.collisionGroups[a]}}(e),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(h,d,b,q){const c=b.getBucket(d),i=b.latestFeatureIndex;if(!c||!i||d.id!==c.layerIds[0])return;const e=c.layers[0].layout,r=b.collisionBoxArray,s=Math.pow(2,this.transform.zoom-b.tileID.overscaledZ),t=b.tileSize/a.EXTENT,j=b.tileID.toUnwrapped(),f=this.transform.calculateProjMatrix(j),g="map"===e.get("text-pitch-alignment"),k="map"===e.get("text-rotation-alignment");d.compileFilter();const l=d.dynamicFilter(),u=d.dynamicFilterNeedsFeature(),m=this.transform.calculatePixelsToTileUnitsMatrix(b),v=aB(f,b.tileID.canonical,g,k,this.transform,m);let n=null;if(g){const w=aC(f,b.tileID.canonical,g,k,this.transform,m);n=a.multiply$1([],this.transform.labelPlaneMatrix,w)}let o=null;l&&b.latestFeatureIndex&&(o={unwrappedTileID:j,dynamicFilter:l,dynamicFilterNeedsFeature:u,featureIndex:b.latestFeatureIndex}),this.retainedQueryData[c.bucketInstanceId]=new aU(c.bucketInstanceId,i,c.sourceLayerIndex,c.index,b.tileID);const p={bucket:c,layout:e,posMatrix:f,textLabelPlaneMatrix:v,labelToScreenMatrix:n,clippingData:o,scale:s,textPixelRatio:t,holdingForFade:b.holdingForFade(),collisionBoxArray:r,partiallyEvaluatedTextSize:a.evaluateSizeForZoom(c.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:a.evaluateSizeForZoom(c.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(c.sourceID)};if(q)for(const x of c.sortKeyRanges){const{sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A}=x;h.push({sortKey:y,symbolInstanceStart:z,symbolInstanceEnd:A,parameters:p})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:c.symbolInstances.length,parameters:p})}attemptAnchorPlacement(d,s,g,h,e,i,j,k,l,m,n,a,t,c,f,o,v,u){const p=[a.textOffset0,a.textOffset1],b=aV(d,g,h,p,e),q=this.collisionIndex.placeCollisionBox(e,s,aW(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate);if((!o||0!==this.collisionIndex.placeCollisionBox(c.getSymbolInstanceIconSize(u,this.transform.zoom,t),o,aW(b.x,b.y,i,j,this.transform.angle),n,k,l,m.predicate).box.length)&&q.box.length>0){let r;return this.prevPlacement&&this.prevPlacement.variableOffsets[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID]&&this.prevPlacement.placements[a.crossTileID].text&&(r=this.prevPlacement.variableOffsets[a.crossTileID].anchor),this.variableOffsets[a.crossTileID]={textOffset:p,width:g,height:h,anchor:d,textScale:e,prevAnchor:r},this.markUsedJustification(c,d,a,f),c.allowVerticalPlacement&&(this.markUsedOrientation(c,f,a),this.placedOrientations[a.crossTileID]=f),{shift:b,placedGlyphBoxes:q}}}placeLayerBucketPart(e,t,i,o){const{bucket:b,layout:c,posMatrix:p,textLabelPlaneMatrix:u,labelToScreenMatrix:v,clippingData:w,textPixelRatio:x,holdingForFade:y,collisionBoxArray:f,partiallyEvaluatedTextSize:z,partiallyEvaluatedIconSize:A,collisionGroup:B}=e.parameters,q=c.get("text-optional"),r=c.get("icon-optional"),j=c.get("text-allow-overlap"),k=c.get("icon-allow-overlap"),C="map"===c.get("text-rotation-alignment"),D="map"===c.get("text-pitch-alignment"),E="none"!==c.get("icon-text-fit"),s="viewport-y"===c.get("symbol-z-order"),F=j&&(k||!b.hasIconData()||r),G=k&&(j||!b.hasTextData()||q);!b.collisionArrays&&f&&b.deserializeCollisionBoxes(f),i&&o&&b.updateCollisionDebugBuffers(this.transform.zoom,f);const l=(d,ac,f)=>{if(w){const $={zoom:this.transform.zoom,pitch:this.transform.pitch};let N=null;if(w.dynamicFilterNeedsFeature){const O=this.retainedQueryData[b.bucketInstanceId];N=w.featureIndex.loadFeature({featureIndex:d.featureIndex,bucketIndex:O.bucketIndex,sourceLayerIndex:O.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,w.dynamicFilter)($,N,this.retainedQueryData[b.bucketInstanceId].tileID.canonical,new a.pointGeometry(d.tileAnchorX,d.tileAnchorY),this.transform.calculateDistanceTileData(w.unwrappedTileID)))return this.placements[d.crossTileID]=new aS(!1,!1,!1,!0),void(t[d.crossTileID]=!0)}if(t[d.crossTileID])return;if(y)return void(this.placements[d.crossTileID]=new aS(!1,!1,!1));let e=!1,l=!1,n=!0,ad=null,h={box:null,offscreen:null},s={box:null,offscreen:null},m=null,g=null,H=null,J=0,K=0,P=0;f.textFeatureIndex?J=f.textFeatureIndex:d.useRuntimeCollisionCircles&&(J=d.featureIndex),f.verticalTextFeatureIndex&&(K=f.verticalTextFeatureIndex);const _=a=>{a.tileID=this.retainedQueryData[b.bucketInstanceId].tileID,(this.transform.elevation||a.elevation)&&(a.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[b.bucketInstanceId].tileID,a.tileAnchorX,a.tileAnchorY):0)},Q=f.textBox;if(Q){_(Q);const R=f=>{let c=a.WritingMode.horizontal;if(b.allowVerticalPlacement&&!f&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[d.crossTileID];e&&(this.placedOrientations[d.crossTileID]=e,c=e,this.markUsedOrientation(b,c,d))}return c},S=(c,e)=>{if(b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const g of b.writingModes)if(g===a.WritingMode.vertical?s=h=e():h=c(),h&&h.box&&h.box.length)break}else h=c()};if(c.get("text-variable-anchor")){let L=c.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[d.crossTileID]){const T=this.prevPlacement.variableOffsets[d.crossTileID];L.indexOf(T.anchor)>0&&(L=L.filter(a=>a!==T.anchor)).unshift(T.anchor)}const ae=(a,l,m)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ac),n=(a.x2-a.x1)*g+2*a.padding,o=(a.y2-a.y1)*g+2*a.padding,h=E&&!k?l:null;h&&_(h);let c={box:[],offscreen:!1};const q=j?2*L.length:L.length;for(let f=0;f<q;++f){const i=this.attemptAnchorPlacement(L[f%L.length],a,n,o,g,C,D,x,p,B,f>=L.length,d,ac,b,m,h,z,A);if(i&&(c=i.placedGlyphBoxes)&&c.box&&c.box.length){e=!0,ad=i.shift;break}}return c};S(()=>ae(Q,f.iconBox,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return c&&_(c),b.allowVerticalPlacement&&!(h&&h.box&&h.box.length)&&d.numVerticalGlyphVertices>0&&c?ae(c,f.verticalIconBox,a.WritingMode.vertical):{box:null,offscreen:null}}),h&&(e=h.box,n=h.offscreen);const aa=R(h&&h.box);if(!e&&this.prevPlacement){const M=this.prevPlacement.variableOffsets[d.crossTileID];M&&(this.variableOffsets[d.crossTileID]=M,this.markUsedJustification(b,M.anchor,d,aa))}}else{const af=(f,e)=>{const g=b.getSymbolInstanceTextSize(z,d,this.transform.zoom,ac),c=this.collisionIndex.placeCollisionBox(g,f,new a.pointGeometry(0,0),j,x,p,B.predicate);return c&&c.box&&c.box.length&&(this.markUsedOrientation(b,e,d),this.placedOrientations[d.crossTileID]=e),c};S(()=>af(Q,a.WritingMode.horizontal),()=>{const c=f.verticalTextBox;return b.allowVerticalPlacement&&d.numVerticalGlyphVertices>0&&c?(_(c),af(c,a.WritingMode.vertical)):{box:null,offscreen:null}}),R(h&&h.box&&h.box.length)}}if(e=(m=h)&&m.box&&m.box.length>0,n=m&&m.offscreen,d.useRuntimeCollisionCircles){const U=b.text.placedSymbolArray.get(d.centerJustifiedTextSymbolIndex>=0?d.centerJustifiedTextSymbolIndex:d.verticalPlacedTextSymbolIndex),V=a.evaluateSizeForFeature(b.textSizeData,z,U),ab=c.get("text-padding");g=this.collisionIndex.placeCollisionCircles(j,U,b.lineVertexArray,b.glyphOffsetArray,V,p,u,v,i,D,B.predicate,d.collisionCircleDiameter*V/a.ONE_EM,ab,this.retainedQueryData[b.bucketInstanceId].tileID),e=j||g.circles.length>0&&!g.collisionDetected,n=n&&g.offscreen}if(f.iconFeatureIndex&&(P=f.iconFeatureIndex),f.iconBox){const W=c=>{_(c);const d=E&&ad?aW(ad.x,ad.y,C,D,this.transform.angle):new a.pointGeometry(0,0),e=b.getSymbolInstanceIconSize(A,this.transform.zoom,ac);return this.collisionIndex.placeCollisionBox(e,c,d,k,x,p,B.predicate)};l=s&&s.box&&s.box.length&&f.verticalIconBox?(H=W(f.verticalIconBox)).box.length>0:(H=W(f.iconBox)).box.length>0,n=n&&H.offscreen}const X=q||0===d.numHorizontalGlyphVertices&&0===d.numVerticalGlyphVertices,Y=r||0===d.numIconVertices;if(X||Y?Y?X||(l=l&&e):e=l&&e:l=e=l&&e,e&&m&&m.box&&this.collisionIndex.insertCollisionBox(m.box,c.get("text-ignore-placement"),b.bucketInstanceId,s&&s.box&&K?K:J,B.ID),l&&H&&this.collisionIndex.insertCollisionBox(H.box,c.get("icon-ignore-placement"),b.bucketInstanceId,P,B.ID),g&&(e&&this.collisionIndex.insertCollisionCircles(g.circles,c.get("text-ignore-placement"),b.bucketInstanceId,J,B.ID),i)){const Z=b.bucketInstanceId;let o=this.collisionCircleArrays[Z];void 0===o&&(o=this.collisionCircleArrays[Z]=new aT);for(let I=0;I<g.circles.length;I+=4)o.circles.push(g.circles[I+0]),o.circles.push(g.circles[I+1]),o.circles.push(g.circles[I+2]),o.circles.push(g.collisionDetected?1:0)}this.placements[d.crossTileID]=new aS(e||F,l||G,n||b.justReloaded),t[d.crossTileID]=!0};if(s){const m=b.getSortedSymbolIndexes(this.transform.angle);for(let g=m.length-1;g>=0;--g){const h=m[g];l(b.symbolInstances.get(h),h,b.collisionArrays[h])}}else for(let d=e.symbolInstanceStart;d<e.symbolInstanceEnd;d++)l(b.symbolInstances.get(d),d,b.collisionArrays[d]);if(i&&b.bucketInstanceId in this.collisionCircleArrays){const n=this.collisionCircleArrays[b.bucketInstanceId];a.invert(n.invProjMatrix,p),n.viewportMatrix=this.collisionIndex.getViewportMatrix()}b.justReloaded=!1}markUsedJustification(e,f,b,g){let c;c=g===a.WritingMode.vertical?b.verticalPlacedTextSymbolIndex:({left:b.leftJustifiedTextSymbolIndex,center:b.centerJustifiedTextSymbolIndex,right:b.rightJustifiedTextSymbolIndex})[a.getAnchorJustification(f)];const h=[b.leftJustifiedTextSymbolIndex,b.centerJustifiedTextSymbolIndex,b.rightJustifiedTextSymbolIndex,b.verticalPlacedTextSymbolIndex,];for(const d of h)d>=0&&(e.text.placedSymbolArray.get(d).crossTileID=c>=0&&d!==c?0:b.crossTileID)}markUsedOrientation(d,b,c){const e=b===a.WritingMode.horizontal||b===a.WritingMode.horizontalOnly?b:0,f=b===a.WritingMode.vertical?b:0,g=[c.leftJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.rightJustifiedTextSymbolIndex,];for(const h of g)d.text.placedSymbolArray.get(h).placedOrientation=e;c.verticalPlacedTextSymbolIndex&&(d.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).placedOrientation=f)}commit(f){this.commitTime=f,this.zoomAtLastRecencyCheck=this.transform.zoom;const a=this.prevPlacement;let c=!1;this.prevZoomAdjustment=a?a.zoomAdjustment(this.transform.zoom):0;const i=a?a.symbolFadeChange(f):1,j=a?a.opacities:{},m=a?a.variableOffsets:{},n=a?a.placedOrientations:{};for(const g in this.placements){const b=this.placements[g],h=j[g];h?(this.opacities[g]=new aR(h,i,b.text,b.icon,null,b.clipped),c=c||b.text!==h.text.placed||b.icon!==h.icon.placed):(this.opacities[g]=new aR(null,i,b.text,b.icon,b.skipFade,b.clipped),c=c||b.text||b.icon)}for(const k in j){const l=j[k];if(!this.opacities[k]){const o=new aR(l,i,!1,!1);o.isHidden()||(this.opacities[k]=o,c=c||l.text.placed||l.icon.placed)}}for(const d in m)this.variableOffsets[d]||!this.opacities[d]||this.opacities[d].isHidden()||(this.variableOffsets[d]=m[d]);for(const e in n)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=n[e]);c?this.lastPlacementChangeTime=f:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=a?a.lastPlacementChangeTime:f)}updateLayerOpacities(c,d){const e={};for(const a of d){const b=a.getBucket(c);b&&a.latestFeatureIndex&&c.id===b.layerIds[0]&&this.updateBucketOpacities(b,e,a.collisionBoxArray)}}updateBucketOpacities(b,s,t){b.hasTextData()&&b.text.opacityVertexArray.clear(),b.hasIconData()&&b.icon.opacityVertexArray.clear(),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexArray.clear(),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexArray.clear();const f=b.layers[0].layout,F=!!b.layers[0].dynamicFilter(),G=new aR(null,0,!1,!1,!0),u=f.get("text-allow-overlap"),v=f.get("icon-allow-overlap"),H=f.get("text-variable-anchor"),I="map"===f.get("text-rotation-alignment"),J="map"===f.get("text-pitch-alignment"),l="none"!==f.get("icon-text-fit"),K=new aR(null,0,u&&(v||!b.hasIconData()||f.get("icon-optional")),v&&(u||!b.hasTextData()||f.get("text-optional")),!0);!b.collisionArrays&&t&&(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData())&&b.deserializeCollisionBoxes(t);const m=(b,c,d)=>{for(let a=0;a<c/4;a++)b.opacityVertexArray.emplaceBack(d)};let w=0;for(let n=0;n<b.symbolInstances.length;n++){const c=b.symbolInstances.get(n),{numHorizontalGlyphVertices:x,numVerticalGlyphVertices:y,crossTileID:i}=c;let d=this.opacities[i];s[i]?d=G:d||(d=K,this.opacities[i]=d),s[i]=!0;const z=x>0||y>0,A=c.numIconVertices>0,o=this.placedOrientations[c.crossTileID],p=o===a.WritingMode.vertical,j=o===a.WritingMode.horizontal||o===a.WritingMode.horizontalOnly;if(!z&&!A||d.isHidden()||w++,z){const B=aY(d.text);m(b.text,x,p?0:B),m(b.text,y,j?0:B);const L=d.text.isHidden();[c.rightJustifiedTextSymbolIndex,c.centerJustifiedTextSymbolIndex,c.leftJustifiedTextSymbolIndex,].forEach(a=>{a>=0&&(b.text.placedSymbolArray.get(a).hidden=L||p?1:0)}),c.verticalPlacedTextSymbolIndex>=0&&(b.text.placedSymbolArray.get(c.verticalPlacedTextSymbolIndex).hidden=L||j?1:0);const C=this.variableOffsets[c.crossTileID];C&&this.markUsedJustification(b,C.anchor,c,o);const q=this.placedOrientations[c.crossTileID];q&&(this.markUsedJustification(b,"left",c,q),this.markUsedOrientation(b,q,c))}if(A){const D=aY(d.icon);c.placedIconSymbolIndex>=0&&(m(b.icon,c.numIconVertices,p?0:D),b.icon.placedSymbolArray.get(c.placedIconSymbolIndex).hidden=d.icon.isHidden()),c.verticalPlacedIconSymbolIndex>=0&&(m(b.icon,c.numVerticalIconVertices,j?0:D),b.icon.placedSymbolArray.get(c.verticalPlacedIconSymbolIndex).hidden=d.icon.isHidden())}if(b.hasIconCollisionBoxData()||b.hasTextCollisionBoxData()){const g=b.collisionArrays[n];if(g){let e=new a.pointGeometry(0,0),k=!0;if(g.textBox||g.verticalTextBox){if(H){const h=this.variableOffsets[i];h?(e=aV(h.anchor,h.width,h.height,h.textOffset,h.textScale),I&&e._rotate(J?this.transform.angle:-this.transform.angle)):k=!1}F&&(k=!d.clipped),g.textBox&&aX(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||p,e.x,e.y),g.verticalTextBox&&aX(b.textCollisionBox.collisionVertexArray,d.text.placed,!k||j,e.x,e.y)}const E=k&&Boolean(!j&&g.verticalIconBox);g.iconBox&&aX(b.iconCollisionBox.collisionVertexArray,d.icon.placed,E,l?e.x:0,l?e.y:0),g.verticalIconBox&&aX(b.iconCollisionBox.collisionVertexArray,d.icon.placed,!E,l?e.x:0,l?e.y:0)}}}if(b.fullyClipped=0===w,b.sortFeatures(this.transform.angle),this.retainedQueryData[b.bucketInstanceId]&&(this.retainedQueryData[b.bucketInstanceId].featureSortOrder=b.featureSortOrder),b.hasTextData()&&b.text.opacityVertexBuffer&&b.text.opacityVertexBuffer.updateData(b.text.opacityVertexArray),b.hasIconData()&&b.icon.opacityVertexBuffer&&b.icon.opacityVertexBuffer.updateData(b.icon.opacityVertexArray),b.hasIconCollisionBoxData()&&b.iconCollisionBox.collisionVertexBuffer&&b.iconCollisionBox.collisionVertexBuffer.updateData(b.iconCollisionBox.collisionVertexArray),b.hasTextCollisionBoxData()&&b.textCollisionBox.collisionVertexBuffer&&b.textCollisionBox.collisionVertexBuffer.updateData(b.textCollisionBox.collisionVertexArray),b.bucketInstanceId in this.collisionCircleArrays){const r=this.collisionCircleArrays[b.bucketInstanceId];b.placementInvProjMatrix=r.invProjMatrix,b.placementViewportMatrix=r.viewportMatrix,b.collisionCircleArray=r.circles,delete this.collisionCircleArrays[b.bucketInstanceId]}}symbolFadeChange(a){return 0===this.fadeDuration?1:(a-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(a){return Math.max(0,(this.transform.zoom-a)/1.5)}hasTransitions(a){return this.stale||a-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(b,a){const c=this.zoomAtLastRecencyCheck===a?1-this.zoomAdjustment(a):1;return this.zoomAtLastRecencyCheck=a,this.commitTime+this.fadeDuration*c>b}setStale(){this.stale=!0}}(b,f,g,h,i),this._currentPlacementIndex=c.length-1,this._forceFullPlacement=d,this._showCollisionBoxes=e,this._done=!1}isDone(){return this._done}continuePlacement(d,e,f){const h=a.exported.now(),g=()=>{const b=a.exported.now()-h;return!this._forceFullPlacement&&b>2};for(;this._currentPlacementIndex>=0;){const b=e[d[this._currentPlacementIndex]],c=this.placement.collisionIndex.transform.zoom;if("symbol"===b.type&&(!b.minzoom||b.minzoom<=c)&&(!b.maxzoom||b.maxzoom>c)){if(this._inProgressLayer||(this._inProgressLayer=new aZ(b)),this._inProgressLayer.continuePlacement(f[b.source],this.placement,this._showCollisionBoxes,b,g))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(a){return this.placement.commit(a),this.placement}}const a_=512/a.EXTENT/2;class a0{constructor(d,e,f){this.tileID=d,this.indexedSymbolInstances={},this.bucketInstanceId=f;for(let a=0;a<e.length;a++){const b=e.get(a),c=b.key;this.indexedSymbolInstances[c]||(this.indexedSymbolInstances[c]=[]),this.indexedSymbolInstances[c].push({crossTileID:b.crossTileID,coord:this.getScaledCoordinates(b,d)})}}getScaledCoordinates(c,b){const d=a_/Math.pow(2,b.canonical.z-this.tileID.canonical.z);return{x:Math.floor((b.canonical.x*a.EXTENT+c.tileAnchorX)*d),y:Math.floor((b.canonical.y*a.EXTENT+c.tileAnchorY)*d)}}findMatches(e,c,f){const g=this.tileID.canonical.z<c.canonical.z?1:Math.pow(2,this.tileID.canonical.z-c.canonical.z);for(let d=0;d<e.length;d++){const b=e.get(d);if(b.crossTileID)continue;const h=this.indexedSymbolInstances[b.key];if(!h)continue;const i=this.getScaledCoordinates(b,c);for(const a of h)if(Math.abs(a.coord.x-i.x)<=g&&Math.abs(a.coord.y-i.y)<=g&&!f[a.crossTileID]){f[a.crossTileID]=!0,b.crossTileID=a.crossTileID;break}}}}class a1{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(b){const c=Math.round((b-this.lng)/360);if(0!==c)for(const d in this.indexes){const e=this.indexes[d],f={};for(const g in e){const a=e[g];a.tileID=a.tileID.unwrapTo(a.tileID.wrap+c),f[a.tileID.key]=a}this.indexes[d]=f}this.lng=b}addBucket(a,b,k){if(this.indexes[a.overscaledZ]&&this.indexes[a.overscaledZ][a.key]){if(this.indexes[a.overscaledZ][a.key].bucketInstanceId===b.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(a.overscaledZ,this.indexes[a.overscaledZ][a.key])}for(let c=0;c<b.symbolInstances.length;c++)b.symbolInstances.get(c).crossTileID=0;this.usedCrossTileIDs[a.overscaledZ]||(this.usedCrossTileIDs[a.overscaledZ]={});const d=this.usedCrossTileIDs[a.overscaledZ];for(const e in this.indexes){const f=this.indexes[e];if(Number(e)>a.overscaledZ)for(const l in f){const i=f[l];i.tileID.isChildOf(a)&&i.findMatches(b.symbolInstances,a,d)}else{const j=f[a.scaledTo(Number(e)).key];j&&j.findMatches(b.symbolInstances,a,d)}}for(let g=0;g<b.symbolInstances.length;g++){const h=b.symbolInstances.get(g);h.crossTileID||(h.crossTileID=k.generate(),d[h.crossTileID]=!0)}return void 0===this.indexes[a.overscaledZ]&&(this.indexes[a.overscaledZ]={}),this.indexes[a.overscaledZ][a.key]=new a0(a,b.symbolInstances,b.bucketInstanceId),!0}removeBucketCrossTileIDs(b,a){for(const c in a.indexedSymbolInstances)for(const d of a.indexedSymbolInstances[c])delete this.usedCrossTileIDs[b][d.crossTileID]}removeStaleBuckets(e){let c=!1;for(const d in this.indexes){const a=this.indexes[d];for(const b in a)e[a[b].bucketInstanceId]||(this.removeBucketCrossTileIDs(d,a[b]),delete a[b],c=!0)}return c}}class a2{constructor(){this.layerIndexes={},this.crossTileIDs=new class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(c,g,h,i){let b=this.layerIndexes[c.id];void 0===b&&(b=this.layerIndexes[c.id]=new a1);let d=!1;const e={};for(const f of("globe"!==i.name&&b.handleWrapJump(h),g)){const a=f.getBucket(c);a&&c.id===a.layerIds[0]&&(a.bucketInstanceId||(a.bucketInstanceId=++this.maxBucketInstanceId),b.addBucket(f.tileID,a,this.crossTileIDs)&&(d=!0),e[a.bucketInstanceId]=!0)}return b.removeStaleBuckets(e)&&(d=!0),d}pruneUnusedLayers(b){const c={};for(const a in b.forEach(a=>{c[a]=!0}),this.layerIndexes)c[a]||delete this.layerIndexes[a]}}const a3=(c,b)=>a.emitValidationErrors(c,b&&b.filter(a=>"source.canvas"!==a.identifier)),a4=a.pick(i,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection",]),a5=a.pick(i,["setCenter","setZoom","setBearing","setPitch",]),a6=function(){const c={},f=a.spec.$version;for(const b in a.spec.$root){const d=a.spec.$root[b];if(d.required){let e=null;null!=(e="version"===b?f:"array"===d.type?[]:{})&&(c[b]=e)}}return c}(),a7={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class c extends a.Evented{constructor(d,b={}){super(),this.map=d,this.dispatcher=new n(ao(),this),this.imageManager=new J,this.imageManager.setEventedParent(this),this.glyphManager=new a.GlyphManager(d._requestManager,b.localFontFamily?a.LocalGlyphMode.all:b.localIdeographFontFamily?a.LocalGlyphMode.ideographs:a.LocalGlyphMode.none,b.localFontFamily||b.localIdeographFontFamily),this.lineAtlas=new a.LineAtlas(256,512),this.crossTileSymbolIndex=new a2,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new a.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",a.getReferrer());const e=this;this._rtlTextPluginCallback=c.registerForPluginStateChange(b=>{e.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(f,b)=>{if(a.triggerPluginCompletionEvent(f),b&&b.every(a=>a))for(const g in e._sourceCaches){const c=e._sourceCaches[g],d=c.getSource().type;"vector"!==d&&"geojson"!==d||c.reload()}})}),this.on("data",a=>{if("source"!==a.dataType||"metadata"!==a.sourceDataType)return;const b=this.getSource(a.sourceId);if(b&&b.vectorLayerIds)for(const d in this._layers){const c=this._layers[d];c.source===b.id&&this._validateLayer(c)}})}loadURL(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"}));const e="boolean"==typeof c.validate?c.validate:!a.isMapboxURL(b);b=this.map._requestManager.normalizeStyleURL(b,c.accessToken);const d=this.map._requestManager.transformRequest(b,a.ResourceType.Style);this._request=a.getJSON(d,(b,c)=>{this._request=null,b?this.fire(new a.ErrorEvent(b)):c&&this._load(c,e)})}loadJSON(b,c={}){this.fire(new a.Event("dataloading",{dataType:"style"})),this._request=a.exported.frame(()=>{this._request=null,this._load(b,!1!==c.validate)})}loadEmpty(){this.fire(new a.Event("dataloading",{dataType:"style"})),this._load(a6,!1)}_updateLayerCount(a,c){const b=c?1:-1;a.is3D()&&(this._num3DLayers+=b),"circle"===a.type&&(this._numCircleLayers+=b),"symbol"===a.type&&(this._numSymbolLayers+=b)}_load(c,f){if(f&&a3(this,a.validateStyle(c)))return;for(const d in this._loaded=!0,this.stylesheet=c,this.updateProjection(),c.sources)this.addSource(d,c.sources[d],{validate:!1});this._changed=!1,c.sprite?this._loadSprite(c.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(c.glyphs);const e=aq(this.stylesheet.layers);for(let b of(this._order=e.map(a=>a.id),this._layers={},this._serializedLayers={},e))(b=a.createStyleLayer(b)).setEventedParent(this,{layer:{id:b.id}}),this._layers[b.id]=b,this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new M(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new a.Event("data",{dataType:"style"})),this.fire(new a.Event("style.load"))}terrainSetForDrapingOnly(){return this.terrain&&0===this.terrain.drapeRenderMode}setProjection(a){a?this.stylesheet.projection=a:delete this.stylesheet.projection,this.updateProjection()}updateProjection(){const b=this.map.transform.projection,c=this.map.transform.setProjection(this.map._runtimeProjection||(this.stylesheet?this.stylesheet.projection:void 0)),a=this.map.transform.projection;if(this._loaded&&(a.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null)),this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),c){if(a.isReprojectedInTileSpace||b.isReprojectedInTileSpace)for(const d in this.map.painter.clearBackgroundTiles(),this._sourceCaches)this._sourceCaches[d].clearTiles();else this._forceSymbolLayerUpdate();this.map._update(!0)}}_loadSprite(b){this._spriteRequest=function(c,b,e){let f,g,h;const d=a.exported.devicePixelRatio>1?"@2x":"";let i=a.getJSON(b.transformRequest(b.normalizeSpriteURL(c,d,".json"),a.ResourceType.SpriteJSON),(a,b)=>{i=null,h||(h=a,f=b,k())}),j=a.getImage(b.transformRequest(b.normalizeSpriteURL(c,d,".png"),a.ResourceType.SpriteImage),(a,b)=>{j=null,h||(h=a,g=b,k())});function k(){if(h)e(h);else if(f&&g){const k=a.exported.getImageData(g),b={};for(const c in f){const{width:d,height:i,x:l,y:m,sdf:n,pixelRatio:o,stretchX:p,stretchY:q,content:r}=f[c],j=new a.RGBAImage({width:d,height:i});a.RGBAImage.copy(k,j,{x:l,y:m},{x:0,y:0},{width:d,height:i}),b[c]={data:j,pixelRatio:o,sdf:n,stretchX:p,stretchY:q,content:r}}e(null,b)}}return{cancel(){i&&(i.cancel(),i=null),j&&(j.cancel(),j=null)}}}(b,this.map._requestManager,(c,b)=>{if(this._spriteRequest=null,c)this.fire(new a.ErrorEvent(c));else if(b)for(const d in b)this.imageManager.addImage(d,b[d]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new a.Event("data",{dataType:"style"}))})}_validateLayer(c){const b=this.getSource(c.source);if(!b)return;const d=c.sourceLayer;d&&("geojson"===b.type||b.vectorLayerIds&& -1===b.vectorLayerIds.indexOf(d))&&this.fire(new a.ErrorEvent(Error(`Source layer "${d}" does not exist on source "${b.id}" as specified by style layer "${c.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const a in this._sourceCaches)if(!this._sourceCaches[a].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(c){const a=[];for(const d of c){const b=this._layers[d];"custom"!==b.type&&a.push(b.serialize())}return a}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const a in this._sourceCaches)if(this._sourceCaches[a].hasTransition())return!0;for(const b in this._layers)if(this._layers[b].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(a){return!!this.terrain&&a7[a.type]}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading")}update(b){if(!this._loaded)return;const p=this._changed;if(this._changed){const g=Object.keys(this._updatedLayers),h=Object.keys(this._removedLayers);for(const d in(g.length||h.length)&&this._updateWorkerLayers(g,h),this._updatedSources){const i=this._updatedSources[d];"reload"===i?this._reloadSource(d):"clear"===i&&this._clearSource(d)}for(const q in this._updateTilesForChangedImages(),this._updatedPaintProps)this._layers[q].updateTransitions(b);this.light.updateTransitions(b),this.fog&&this.fog.updateTransitions(b),this._resetUpdates()}const e={};for(const j in this._sourceCaches){const k=this._sourceCaches[j];e[j]=k.used,k.used=!1}for(const r of this._order){const c=this._layers[r];if(c.recalculate(b,this._availableImages),!c.isHidden(b.zoom)){const l=this._getLayerSourceCache(c);l&&(l.used=!0)}const m=this.map.painter;if(m){const n=c.getProgramIds();if(!n)continue;const s=c.getProgramConfiguration(b.zoom);for(const t of n)m.useProgram(t,s)}}for(const o in e){const f=this._sourceCaches[o];e[o]!==f.used&&f.getSource().fire(new a.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:f.getSource().id}))}this.light.recalculate(b),this.terrain&&this.terrain.recalculate(b),this.fog&&this.fog.recalculate(b),this.z=b.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),p&&this.fire(new a.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const a=Object.keys(this._changedImages);if(a.length){for(const b in this._sourceCaches)this._sourceCaches[b].reloadTilesForDependencies(["icons","patterns"],a);this._changedImages={}}}_updateWorkerLayers(a,b){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(a),removedIds:b})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(b){if(this._checkLoaded(),a3(this,a.validateStyle(b)))return!1;(b=a.clone$1(b)).layers=aq(b.layers);const c=(function(c,a){if(!c)return[{command:i.setStyle,args:[a]},];let b=[];try{if(!D(c.version,a.version))return[{command:i.setStyle,args:[a]},];D(c.center,a.center)||b.push({command:i.setCenter,args:[a.center]}),D(c.zoom,a.zoom)||b.push({command:i.setZoom,args:[a.zoom]}),D(c.bearing,a.bearing)||b.push({command:i.setBearing,args:[a.bearing]}),D(c.pitch,a.pitch)||b.push({command:i.setPitch,args:[a.pitch]}),D(c.sprite,a.sprite)||b.push({command:i.setSprite,args:[a.sprite]}),D(c.glyphs,a.glyphs)||b.push({command:i.setGlyphs,args:[a.glyphs]}),D(c.transition,a.transition)||b.push({command:i.setTransition,args:[a.transition]}),D(c.light,a.light)||b.push({command:i.setLight,args:[a.light]}),D(c.fog,a.fog)||b.push({command:i.setFog,args:[a.fog]}),D(c.projection,a.projection)||b.push({command:i.setProjection,args:[a.projection]});const e={},f=[];!function(c,b,d,e){let a;for(a in b=b||{},c=c||{})c.hasOwnProperty(a)&&(b.hasOwnProperty(a)||as(a,d,e));for(a in b)b.hasOwnProperty(a)&&(c.hasOwnProperty(a)?D(c[a],b[a])||("geojson"===c[a].type&&"geojson"===b[a].type&&au(c,b,a)?d.push({command:i.setGeoJSONSourceData,args:[a,b[a].data,]}):at(a,b,d,e)):ar(a,b,d))}(c.sources,a.sources,f,e);const g=[];c.layers&&c.layers.forEach(a=>{e[a.source]?b.push({command:i.removeLayer,args:[a.id]}):g.push(a)});let d=c.terrain;d&&e[d.source]&&(b.push({command:i.setTerrain,args:[void 0]}),d=void 0),b=b.concat(f),D(d,a.terrain)||b.push({command:i.setTerrain,args:[a.terrain]}),function(m,k,f){k=k||[];const n=(m=m||[]).map(aw),j=k.map(aw),p=m.reduce(ax,{}),o=k.reduce(ax,{}),g=n.slice(),q=Object.create(null);let e,h,b,d,c,l,a;for(e=0,h=0;e<n.length;e++)b=n[e],o.hasOwnProperty(b)?h++:(f.push({command:i.removeLayer,args:[b]}),g.splice(g.indexOf(b,h),1));for(e=0,h=0;e<j.length;e++)b=j[j.length-1-e],g[g.length-1-e]!==b&&(p.hasOwnProperty(b)?(f.push({command:i.removeLayer,args:[b]}),g.splice(g.lastIndexOf(b,g.length-h),1)):h++,l=g[g.length-e],f.push({command:i.addLayer,args:[o[b],l]}),g.splice(g.length-e,0,b),q[b]=!0);for(e=0;e<j.length;e++)if(d=p[b=j[e]],c=o[b],!q[b]&&!D(d,c)){if(D(d.source,c.source)&&D(d["source-layer"],c["source-layer"])&&D(d.type,c.type)){for(a in av(d.layout,c.layout,f,b,null,i.setLayoutProperty),av(d.paint,c.paint,f,b,null,i.setPaintProperty),D(d.filter,c.filter)||f.push({command:i.setFilter,args:[b,c.filter,]}),D(d.minzoom,c.minzoom)&&D(d.maxzoom,c.maxzoom)||f.push({command:i.setLayerZoomRange,args:[b,c.minzoom,c.maxzoom,]}),d)d.hasOwnProperty(a)&&"layout"!==a&&"paint"!==a&&"filter"!==a&&"metadata"!==a&&"minzoom"!==a&&"maxzoom"!==a&&(0===a.indexOf("paint.")?av(d[a],c[a],f,b,a.slice(6),i.setPaintProperty):D(d[a],c[a])||f.push({command:i.setLayerProperty,args:[b,a,c[a],]}));for(a in c)c.hasOwnProperty(a)&&!d.hasOwnProperty(a)&&"layout"!==a&&"paint"!==a&&"filter"!==a&&"metadata"!==a&&"minzoom"!==a&&"maxzoom"!==a&&(0===a.indexOf("paint.")?av(d[a],c[a],f,b,a.slice(6),i.setPaintProperty):D(d[a],c[a])||f.push({command:i.setLayerProperty,args:[b,a,c[a],]}))}else f.push({command:i.removeLayer,args:[b]}),l=g[g.lastIndexOf(b)+1],f.push({command:i.addLayer,args:[c,l,]})}}(g,a.layers,b)}catch(h){console.warn("Unable to compute style diff:",h),b=[{command:i.setStyle,args:[a]},]}return b})(this.serialize(),b).filter(a=>!(a.command in a5));if(0===c.length)return!1;const d=c.filter(a=>!(a.command in a4));if(d.length>0)throw Error(`Unimplemented: ${d.map(a=>a.command).join(", ")}.`);return c.forEach(a=>{"setTransition"!==a.command&&this[a.command].apply(this,a.args)}),this.stylesheet=b,this.updateProjection(),!0}addImage(b,c){if(this.getImage(b))return this.fire(new a.ErrorEvent(Error("An image with this name already exists.")));this.imageManager.addImage(b,c),this._afterImageUpdated(b)}updateImage(a,b){this.imageManager.updateImage(a,b)}getImage(a){return this.imageManager.getImage(a)}removeImage(b){if(!this.getImage(b))return this.fire(new a.ErrorEvent(Error("No image with this name exists.")));this.imageManager.removeImage(b),this._afterImageUpdated(b)}_afterImageUpdated(b){this._availableImages=this.imageManager.listImages(),this._changedImages[b]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new a.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(c,b,f={}){if(this._checkLoaded(),void 0!==this.getSource(c))throw Error("There is already a source with this ID");if(!b.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(b).join(", ")}.`);if(["vector","raster","geojson","video","image",].indexOf(b.type)>=0&&this._validate(a.validateStyle.source,`sources.${c}`,b,null,f))return;this.map&&this.map._collectResourceTiming&&(b.collectResourceTiming=!0);const d=ag(c,b,this.dispatcher,this);d.setEventedParent(this,()=>({isSourceLoaded:this.loaded(),source:d.serialize(),sourceId:c}));const e=b=>{const f=(b?"symbol:":"other:")+c,e=this._sourceCaches[f]=new a.SourceCache(f,d,b);(b?this._symbolSourceCaches:this._otherSourceCaches)[c]=e,e.style=this,e.onAdd(this.map)};e(!1),"vector"!==b.type&&"geojson"!==b.type||e(!0),d.onAdd&&d.onAdd(this.map),this._changed=!0}removeSource(b){this._checkLoaded();const d=this.getSource(b);if(void 0===d)throw Error("There is no source with this ID");for(const e in this._layers)if(this._layers[e].source===b)return this.fire(new a.ErrorEvent(Error(`Source "${b}" cannot be removed while layer "${e}" is using it.`)));if(this.terrain&&this.terrain.get().source===b)return this.fire(new a.ErrorEvent(Error(`Source "${b}" cannot be removed while terrain is using it.`)));const f=this._getSourceCaches(b);for(const c of f)delete this._sourceCaches[c.id],delete this._updatedSources[c.id],c.fire(new a.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:c.getSource().id})),c.setEventedParent(null),c.clearTiles();delete this._otherSourceCaches[b],delete this._symbolSourceCaches[b],d.setEventedParent(null),d.onRemove&&d.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(a,b){this._checkLoaded(),this.getSource(a).setData(b),this._changed=!0}getSource(b){const a=this._getSourceCache(b);return a&&a.getSource()}addLayer(c,e,h={}){this._checkLoaded();const d=c.id;if(this.getLayer(d))return void this.fire(new a.ErrorEvent(Error(`Layer with id "${d}" already exists on this map`)));let b;if("custom"===c.type){if(a3(this,a.validateCustomStyleLayer(c)))return;b=a.createStyleLayer(c)}else{if("object"==typeof c.source&&(this.addSource(d,c.source),c=a.clone$1(c),c=a.extend(c,{source:d})),this._validate(a.validateStyle.layer,`layers.${d}`,c,{arrayIndex:-1},h))return;b=a.createStyleLayer(c),this._validateLayer(b),b.setEventedParent(this,{layer:{id:d}}),this._serializedLayers[b.id]=b.serialize(),this._updateLayerCount(b,!0)}const f=e?this._order.indexOf(e):this._order.length;if(e&& -1===f)return void this.fire(new a.ErrorEvent(Error(`Layer with id "${e}" does not exist on this map.`)));this._order.splice(f,0,d),this._layerOrderChanged=!0,this._layers[d]=b;const g=this._getLayerSourceCache(b);if(this._removedLayers[d]&&b.source&&g&&"custom"!==b.type){const i=this._removedLayers[d];delete this._removedLayers[d],i.type!==b.type?this._updatedSources[b.source]="clear":(this._updatedSources[b.source]="reload",g.pause())}this._updateLayer(b),b.onAdd&&b.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(b,c){if(this._checkLoaded(),this._changed=!0,!this._layers[b])return void this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be moved.`)));if(b===c)return;const e=this._order.indexOf(b);this._order.splice(e,1);const d=c?this._order.indexOf(c):this._order.length;c&& -1===d?this.fire(new a.ErrorEvent(Error(`Layer with id "${c}" does not exist on this map.`))):(this._order.splice(d,0,b),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(b){this._checkLoaded();const c=this._layers[b];if(!c)return void this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style and cannot be removed.`)));c.setEventedParent(null),this._updateLayerCount(c,!1);const d=this._order.indexOf(b);this._order.splice(d,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[b]=c,delete this._layers[b],delete this._serializedLayers[b],delete this._updatedLayers[b],delete this._updatedPaintProps[b],c.onRemove&&c.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(a){return this._layers[a]}hasLayer(a){return a in this._layers}hasLayerType(a){for(const b in this._layers)if(this._layers[b].type===a)return!0;return!1}setLayerZoomRange(e,c,d){this._checkLoaded();const b=this.getLayer(e);b?b.minzoom===c&&b.maxzoom===d||(null!=c&&(b.minzoom=c),null!=d&&(b.maxzoom=d),this._updateLayer(b)):this.fire(new a.ErrorEvent(Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(d,c,e={}){this._checkLoaded();const b=this.getLayer(d);if(b){if(!D(b.filter,c))return null==c?(b.filter=void 0,void this._updateLayer(b)):void(this._validate(a.validateStyle.filter,`layers.${b.id}.filter`,c,{layerType:b.type},e)||(b.filter=a.clone$1(c),this._updateLayer(b)))}else this.fire(new a.ErrorEvent(Error(`The layer '${d}' does not exist in the map's style and cannot be filtered.`)))}getFilter(b){return a.clone$1(this.getLayer(b).filter)}setLayoutProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getLayoutProperty(d),e)||(b.setLayoutProperty(d,e,f),this._updateLayer(b)):this.fire(new a.ErrorEvent(Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(b,d){const c=this.getLayer(b);if(c)return c.getLayoutProperty(d);this.fire(new a.ErrorEvent(Error(`The layer '${b}' does not exist in the map's style.`)))}setPaintProperty(c,d,e,f={}){this._checkLoaded();const b=this.getLayer(c);b?D(b.getPaintProperty(d),e)||(b.setPaintProperty(d,e,f)&&this._updateLayer(b),this._changed=!0,this._updatedPaintProps[c]=!0):this.fire(new a.ErrorEvent(Error(`The layer '${c}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(a,b){return this.getLayer(a).getPaintProperty(b)}setFeatureState(b,g){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type;if("geojson"===f&&d)return void this.fire(new a.ErrorEvent(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===f&&!d)return void this.fire(new a.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));void 0===b.id&&this.fire(new a.ErrorEvent(Error("The feature id parameter must be provided.")));const h=this._getSourceCaches(c);for(const i of h)i.setFeatureState(d,b.id,g)}removeFeatureState(b,d){this._checkLoaded();const c=b.source,e=this.getSource(c);if(void 0===e)return void this.fire(new a.ErrorEvent(Error(`The source '${c}' does not exist in the map's style.`)));const f=e.type,g="vector"===f?b.sourceLayer:void 0;if("vector"===f&&!g)return void this.fire(new a.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")));if(d&&"string"!=typeof b.id&&"number"!=typeof b.id)return void this.fire(new a.ErrorEvent(Error("A feature id is required to remove its specific state property.")));const h=this._getSourceCaches(c);for(const i of h)i.removeFeatureState(g,b.id,d)}getFeatureState(b){this._checkLoaded();const c=b.source,d=b.sourceLayer,e=this.getSource(c);if(void 0!==e){if("vector"!==e.type||d)return void 0===b.id&&this.fire(new a.ErrorEvent(Error("The feature id parameter must be provided."))),this._getSourceCaches(c)[0].getFeatureState(d,b.id);this.fire(new a.ErrorEvent(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new a.ErrorEvent(Error(`The source '${c}' does not exist in the map's style.`)))}getTransition(){return a.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const b={};for(const d in this._sourceCaches){const c=this._sourceCaches[d].getSource();b[c.id]||(b[c.id]=c.serialize())}return a.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:b,layers:this._serializeLayers(this._order)},a=>void 0!==a)}_updateLayer(a){this._updatedLayers[a.id]=!0;const b=this._getLayerSourceCache(a);a.source&&!this._updatedSources[a.source]&&b&&"raster"!==b.getSource().type&&(this._updatedSources[a.source]="reload",b.pause()),this._changed=!0,a.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(g){var h,i;const j={},a=[];for(let b=this._order.length-1;b>=0;b--){const d=this._order[b];if(h=d,"fill-extrusion"===this._layers[h].type)for(const o of(j[d]=b,g)){const k=o[d];if(k)for(const p of k)a.push(p)}}a.sort((a,b)=>b.intersectionZ-a.intersectionZ);const e=[];for(let c=this._order.length-1;c>=0;c--){const l=this._order[c];if(i=l,"fill-extrusion"===this._layers[i].type)for(let f=a.length-1;f>=0;f--){const m=a[f].feature;if(j[m.layer.id]<c)break;e.push(m),a.pop()}else for(const q of g){const n=q[l];if(n)for(const r of n)e.push(r.feature)}}return e}queryRenderedFeatures(j,b,d){b&&b.filter&&this._validate(a.validateStyle.filter,"queryRenderedFeatures.filter",b.filter,null,b);const e={};if(b&&b.layers){if(!Array.isArray(b.layers))return this.fire(new a.ErrorEvent(Error("parameters.layers must be an Array."))),[];for(const f of b.layers){const g=this._layers[f];if(!g)return this.fire(new a.ErrorEvent(Error(`The layer '${f}' does not exist in the map's style and cannot be queried for features.`))),[];e[g.source]=!0}}const c=[];b.availableImages=this._availableImages;const k=b&&b.layers?b.layers.some(b=>{const a=this.getLayer(b);return a&&a.is3D()}):this.has3DLayers(),h=_.createFromScreenPoints(j,d);for(const i in this._sourceCaches){const l=this._sourceCaches[i].getSource().id;b.layers&&!e[l]||c.push(ai(this._sourceCaches[i],this._layers,this._serializedLayers,h,b,d,k,!!this.map._showQueryGeometry))}return this.placement&&c.push(function(i,j,r,k,c,l,m){const a={},f=l.queryRenderedSymbols(k),d=[];for(const n of Object.keys(f).map(Number))d.push(m[n]);for(const b of(d.sort(ak),d)){const g=b.featureIndex.lookupSymbolFeatures(f[b.bucketInstanceId],j,b.bucketIndex,b.sourceLayerIndex,c.filter,c.layers,c.availableImages,i);for(const e in g){const o=a[e]=a[e]||[],h=g[e];for(const p of(h.sort((c,d)=>{const a=b.featureSortOrder;if(a){const e=a.indexOf(c.featureIndex);return a.indexOf(d.featureIndex)-e}return d.featureIndex-c.featureIndex}),h))o.push(p)}}for(const q in a)a[q].forEach(b=>{const a=b.feature,c=r(i[q]).getFeatureState(a.layer["source-layer"],a.id);a.source=a.layer.source,a.layer["source-layer"]&&(a.sourceLayer=a.layer["source-layer"]),a.state=c});return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),h.screenGeometry,b,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(c)}querySourceFeatures(d,b){b&&b.filter&&this._validate(a.validateStyle.filter,"querySourceFeatures.filter",b.filter,null,b);const e=this._getSourceCaches(d);let c=[];for(const f of e)c=c.concat(aj(f,b));return c}addSourceType(a,b,d){return c.getSourceType(a)?d(Error(`A source type called "${a}" already exists.`)):(c.setSourceType(a,b),b.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:a,url:b.workerSourceURL},d):d(null,null))}getLight(){return this.light.getLight()}setLight(b,e={}){this._checkLoaded();const f=this.light.getLight();let c=!1;for(const d in b)if(!D(b[d],f[d])){c=!0;break}if(!c)return;const g={now:a.exported.now(),transition:a.extend({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(b,e),this.light.updateTransitions(g)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(b,c=1){if(this._checkLoaded(),!b)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===c){if("object"==typeof b.source){const e="terrain-dem-src";this.addSource(e,b.source),b=a.clone$1(b),b=a.extend(b,{source:e})}if(this._validate(a.validateStyle.terrain,"terrain",b))return}if(!this.terrain||this.terrain&&c!==this.terrain.drapeRenderMode)this._createTerrain(b,c);else{const d=this.terrain,g=d.get();for(const f in b)if(!D(b[f],g[f])){d.set(b),this.stylesheet.terrain=b;const h={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(h);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(b){const c=this.fog=new U(b,this.map.transform);this.stylesheet.fog=b;const d={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(d)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const a of this.map._markers)a._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(b){if(this._checkLoaded(),!b)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const c=this.fog,e=c.get();for(const d in b)if(!D(b[d],e[d])){c.set(b),this.stylesheet.fog=b;const f={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};c.updateTransitions(f);break}}else this._createFog(b);this._markersNeedUpdate=!0}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const a=this._order.filter(a=>this.isLayerDraped(this._layers[a])),b=this._order.filter(a=>!this.isLayerDraped(this._layers[a]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...a),this._drapedFirstOrder.push(...b)}_createTerrain(b,c){const d=this.terrain=new P(b,c);this.stylesheet.terrain=b,this.dispatcher.broadcast("enableTerrain",!0),this._force3DLayerUpdate();const e={now:a.exported.now(),transition:a.extend({duration:0},this.stylesheet.transition)};d.updateTransitions(e)}_force3DLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"fill-extrusion"===a.type&&this._updateLayer(a)}}_forceSymbolLayerUpdate(){for(const b in this._layers){const a=this._layers[b];"symbol"===a.type&&this._updateLayer(a)}}_validate(c,d,e,f,b={}){return(!b|| !1!==b.validate)&&a3(this,c.call(a.validateStyle,a.extend({key:d,style:this.serialize(),value:e,styleSpec:a.spec},f)))}_remove(){for(const c in this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),a.evented.off("pluginStateChange",this._rtlTextPluginCallback),this._layers)this._layers[c].setEventedParent(null);for(const b in this._sourceCaches)this._sourceCaches[b].clearTiles(),this._sourceCaches[b].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(a){const b=this._getSourceCaches(a);for(const c of b)c.clearTiles()}_reloadSource(b){const c=this._getSourceCaches(b);for(const a of c)a.resume(),a.reload()}_updateSources(a){for(const b in this._sourceCaches)this._sourceCaches[b].update(a)}_generateCollisionBoxes(){for(const b in this._sourceCaches){const a=this._sourceCaches[b];a.resume(),a.reload()}}_updatePlacement(c,k,h,l,e=!1){let f=!1,i=!1;const d={};for(const m of this._order){const b=this._layers[m];if("symbol"!==b.type)continue;if(!d[b.source]){const j=this._getLayerSourceCache(b);if(!j)continue;d[b.source]=j.getRenderableIds(!0).map(a=>j.getTileByID(a)).sort((a,b)=>b.tileID.overscaledZ-a.tileID.overscaledZ||(a.tileID.isLessThan(b.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(b,d[b.source],c.center.lng,c.projection);f=f||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),e=e||this._layerOrderChanged||0===h,this._layerOrderChanged&&this.fire(new a.Event("neworder")),(e||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(a.exported.now(),c.zoom))&&(this.pauseablePlacement=new a$(c,this._order,e,k,h,l,this.placement,this.fog&&c.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,d),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(a.exported.now()),i=!0),f&&this.pauseablePlacement.placement.setStale()),i||f)for(const o of this._order){const g=this._layers[o];"symbol"===g.type&&this.placement.updateLayerOpacities(g,d[g.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(a.exported.now())}_releaseSymbolFadeTiles(){for(const a in this._sourceCaches)this._sourceCaches[a].releaseSymbolFadeTiles()}getImages(d,a,c){this.imageManager.getImages(a.icons,c),this._updateTilesForChangedImages();const b=b=>{b&&b.setDependencies(a.tileID.key,a.type,a.icons)};b(this._otherSourceCaches[a.source]),b(this._symbolSourceCaches[a.source])}getGlyphs(c,a,b){this.glyphManager.getGlyphs(a.stacks,b)}getResource(d,b,c){return a.makeRequest(b,c)}_getSourceCache(a){return this._otherSourceCaches[a]}_getLayerSourceCache(a){return"symbol"===a.type?this._symbolSourceCaches[a.source]:this._otherSourceCaches[a.source]}_getSourceCaches(a){const b=[];return this._otherSourceCaches[a]&&b.push(this._otherSourceCaches[a]),this._symbolSourceCaches[a]&&b.push(this._symbolSourceCaches[a]),b}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)}}c.getSourceType=function(a){return af[a]},c.setSourceType=function(a,b){af[a]=b},c.registerForPluginStateChange=a.registerForPluginStateChange;var t="\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",j="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 u={},v={};u=bb("","\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),v=bb("#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 a8=bb("\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."),a9=t;var ba={background:bb("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:bb("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:bb("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:bb("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:bb("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:bb("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:bb("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:bb("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:bb("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:bb("#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:bb("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:bb("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:bb("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:bb("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:bb("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:bb("#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:bb("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:bb("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:bb("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:bb("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:bb("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:bb("#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:bb("#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:bb("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:bb("#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:bb("\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}",j),skyboxGradient:bb("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}",j),skyboxCapture:bb("\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:bb("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:bb("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 bb(c,b,h){const e=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,d=/uniform (highp |mediump |lowp )?([\w]+) ([\w]+)([\s]*)([\w]*)/g,i=b.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),f=c.match(d),g=b.match(d),j=t.match(d);let a=g?g.concat(f):f;h||(u.staticUniforms&&(a=u.staticUniforms.concat(a)),v.staticUniforms&&(a=v.staticUniforms.concat(a))),a&&(a=a.concat(j));const k={};return{fragmentSource:c=c.replace(e,(e,d,b,c,a)=>(k[a]=!0,"define"===d?`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
varying ${b} ${c} ${a};
|
|
#else
|
|
uniform ${b} ${c} u_${a};
|
|
#endif
|
|
`:`
|
|
#ifdef HAS_UNIFORM_u_${a}
|
|
${b} ${c} ${a} = u_${a};
|
|
#endif
|
|
`)),vertexSource:b=b.replace(e,(g,f,b,c,a)=>{const e="float"===c?"vec2":"vec4",d=a.match(/color/)?"color":e;return k[a]?"define"===f?`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
uniform lowp float u_${a}_t;
|
|
attribute ${b} ${e} a_${a};
|
|
varying ${b} ${c} ${a};
|
|
#else
|
|
uniform ${b} ${c} u_${a};
|
|
#endif
|
|
`:"vec4"===d?`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
${a} = a_${a};
|
|
#else
|
|
${b} ${c} ${a} = u_${a};
|
|
#endif
|
|
`:`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
${a} = unpack_mix_${d}(a_${a}, u_${a}_t);
|
|
#else
|
|
${b} ${c} ${a} = u_${a};
|
|
#endif
|
|
`:"define"===f?`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
uniform lowp float u_${a}_t;
|
|
attribute ${b} ${e} a_${a};
|
|
#else
|
|
uniform ${b} ${c} u_${a};
|
|
#endif
|
|
`:"vec4"===d?`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
${b} ${c} ${a} = a_${a};
|
|
#else
|
|
${b} ${c} ${a} = u_${a};
|
|
#endif
|
|
`:`
|
|
#ifndef HAS_UNIFORM_u_${a}
|
|
${b} ${c} ${a} = unpack_mix_${d}(a_${a}, u_${a}_t);
|
|
#else
|
|
${b} ${c} ${a} = u_${a};
|
|
#endif
|
|
`}),staticAttributes:i,staticUniforms:a}}class bc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(f,h,i,b,a,j,c,d){this.context=f;let g=this.boundPaintVertexBuffers.length!==b.length;for(let e=0;!g&&e<b.length;e++)this.boundPaintVertexBuffers[e]!==b[e]&&(g=!0);f.extVertexArrayObject&&this.vao&&this.boundProgram===h&&this.boundLayoutVertexBuffer===i&&!g&&this.boundIndexBuffer===a&&this.boundVertexOffset===j&&this.boundDynamicVertexBuffer===c&&this.boundDynamicVertexBuffer2===d?(f.bindVertexArrayOES.set(this.vao),c&&c.bind(),a&&a.dynamicDraw&&a.bind(),d&&d.bind()):this.freshBind(h,i,b,a,j,c,d)}freshBind(a,g,h,i,f,c,d){let j;const l=a.numAttributes,e=this.context,b=e.gl;if(e.extVertexArrayObject)this.vao&&this.destroy(),this.vao=e.extVertexArrayObject.createVertexArrayOES(),e.bindVertexArrayOES.set(this.vao),j=0,this.boundProgram=a,this.boundLayoutVertexBuffer=g,this.boundPaintVertexBuffers=h,this.boundIndexBuffer=i,this.boundVertexOffset=f,this.boundDynamicVertexBuffer=c,this.boundDynamicVertexBuffer2=d;else{j=e.currentNumAttributes||0;for(let k=l;k<j;k++)b.disableVertexAttribArray(k)}for(const n of(g.enableAttributes(b,a),h))n.enableAttributes(b,a);for(const m of(c&&c.enableAttributes(b,a),d&&d.enableAttributes(b,a),g.bind(),g.setVertexAttribPointers(b,a,f),h))m.bind(),m.setVertexAttribPointers(b,a,f);c&&(c.bind(),c.setVertexAttribPointers(b,a,f)),i&&i.bind(),d&&(d.bind(),d.setVertexAttribPointers(b,a,f)),e.currentNumAttributes=l}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function bd(b,e,f,g,j,k,l){const c=b.context,d=c.gl,h=f.fbo;if(!h)return;b.prepareDrawTile(e);const i=b.useProgram("hillshade");c.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,h.colorAttachment.get());const m=((c,d,b,f)=>{const g=b.paint.get("hillshade-shadow-color"),h=b.paint.get("hillshade-highlight-color"),i=b.paint.get("hillshade-accent-color");let e=b.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===b.paint.get("hillshade-illumination-anchor")&&(e-=c.transform.angle);const j=!c.options.moving;return{u_matrix:f||c.transform.calculateProjMatrix(d.tileID.toUnwrapped(),j),u_image:0,u_latrange:function(e,b){const c=Math.pow(2,b.canonical.z),d=b.canonical.y;return[new a.MercatorCoordinate(0,d/c).toLngLat().lat,new a.MercatorCoordinate(0,(d+1)/c).toLngLat().lat,]}(0,d.tileID),u_light:[b.paint.get("hillshade-exaggeration"),e,],u_shadow:g,u_highlight:h,u_accent:i}})(b,f,g,b.terrain?e.projMatrix:null);b.prepareDrawProgram(c,i,e.toUnwrapped());const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=b.getTileBoundsBuffers(f);i.draw(c,d.TRIANGLES,j,k,l,a.CullFaceMode.disabled,m,g.id,n,o,p)}function be(d,b,e){if(!b.needsDEMTextureUpload)return;const c=d.context,g=c.gl;c.pixelStoreUnpackPremultiplyAlpha.set(!1),b.demTexture=b.demTexture||d.getTileTexture(e.stride);const f=e.getPixels();b.demTexture?b.demTexture.update(f,{premultiply:!1}):b.demTexture=new a.Texture(c,f,g.RGBA,{premultiply:!1}),b.needsDEMTextureUpload=!1}function bf(f,b,j,k,l,m){const c=f.context,d=c.gl;if(!b.dem)return;const g=b.dem;if(c.activeTexture.set(d.TEXTURE1),be(f,b,g),!b.demTexture)return;b.demTexture.bind(d.NEAREST,d.CLAMP_TO_EDGE);const e=g.dim;c.activeTexture.set(d.TEXTURE0);let h=b.fbo;if(!h){const i=new a.Texture(c,{width:e,height:e,data:null},d.RGBA);i.bind(d.LINEAR,d.CLAMP_TO_EDGE),(h=b.fbo=c.createFramebuffer(e,e,!0)).colorAttachment.set(i.texture)}c.bindFramebuffer.set(h.framebuffer),c.viewport.set([0,0,e,e]);const{tileBoundsBuffer:n,tileBoundsIndexBuffer:o,tileBoundsSegments:p}=f.getMercatorTileBoundsBuffers();f.useProgram("hillshadePrepare").draw(c,d.TRIANGLES,k,l,m,a.CullFaceMode.disabled,((e,c)=>{const d=c.stride,b=a.create();return a.ortho(b,0,a.EXTENT,-a.EXTENT,0,0,1),a.translate(b,b,[0,-a.EXTENT,0]),{u_matrix:b,u_image:1,u_dimension:[d,d],u_zoom:e.overscaledZ,u_unpack:c.unpackVector}})(b.tileID,g),j.id,n,o,p),b.needsHillshadePrepare=!1}const k=(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image0:new a.Uniform1i(b,c.u_image0),u_skirt_height:new a.Uniform1f(b,c.u_skirt_height)}),bg=(a,b)=>({u_matrix:a,u_image0:0,u_skirt_height:b}),bh=(a,b,c,d,e)=>({u_proj_matrix:Float32Array.from(a),u_globe_matrix:b,u_merc_matrix:c,u_zoom_transition:d,u_merc_center:e,u_image0:0});function bi(a,b){return null!=a&&null!=b&&!(!a.hasData()||!b.hasData())&&null!=a.demTexture&&null!=b.demTexture&&a.tileID.key!==b.tileID.key}const bj=new class{constructor(){this.operations={}}newMorphing(a,d,b,e,f){if(a in this.operations){const c=this.operations[a];c.to.tileID.key!==b.tileID.key&&(c.queued=b)}else this.operations[a]={startTime:e,phase:0,duration:f,from:d,to:b,queued:null}}getMorphValuesForProxy(b){if(!(b in this.operations))return null;const a=this.operations[b];return{from:a.from,to:a.to,phase:a.phase}}update(b){for(const c in this.operations){const a=this.operations[c];for(a.phase=(b-a.startTime)/a.duration;a.phase>=1||!this._validOp(a);)if(!this._nextOp(a,b)){delete this.operations[c];break}}}_nextOp(a,b){return!!a.queued&&(a.from=a.to,a.to=a.queued,a.queued=null,a.phase=0,a.startTime=b,!0)}_validOp(a){return a.from.hasData()&&a.to.hasData()}},bk={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function bl(a,c){const b=1<<a.z;return!c&&(0===a.x||a.x===b-1)||0===a.y||a.y===b-1}const bm=a=>({u_matrix:a});function bn(b,c,k,l,d){if(d>0){const e=a.exported.now(),f=(e-b.timeAdded)/d,m=c?(e-c.timeAdded)/d:-1,g=k.getSource(),h=l.coveringZoomLevel({tileSize:g.tileSize,roundZoom:g.roundZoom}),i=!c||Math.abs(c.tileID.overscaledZ-h)>Math.abs(b.tileID.overscaledZ-h),j=i&&b.refreshedUponExpiration?1:a.clamp(i?f:1-m,0,1);return b.refreshedUponExpiration&&f>=1&&(b.refreshedUponExpiration=!1),c?{opacity:1,mix:1-j}:{opacity:j,mix:0}}return{opacity:1,mix:0}}class bo extends a.SourceCache{constructor(a){const c={type:"raster-dem",maxzoom:a.transform.maxZoom},d=new n(ao(),null),b=ag("mock-dem",c,d,a.style);super("mock-dem",b,!1),b.setEventedParent(this),this._sourceLoaded=!0}_loadTile(a,b){a.state="loaded",b(null)}}class bp extends a.SourceCache{constructor(a){const b=ag("proxy",{type:"geojson",maxzoom:a.transform.maxZoom},new n(ao(),null),a.style);super("proxy",b,!1),b.setEventedParent(this),this.map=this.getSource().map=a,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(c,e,f){if(c.freezeTileCoverage)return;this.transform=c;const d=c.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((d,b)=>{if(d[b.key]="",!this._tiles[b.key]){const e=new a.Tile(b,this._source.tileSize*b.overscaleFactor(),c.tileZoom);e.state="loaded",this._tiles[b.key]=e}return d},{});for(const b in this._tiles)b in d||(this.freeFBO(b),this._tiles[b].unloadVectorData(),delete this._tiles[b])}freeFBO(a){const b=this.proxyCachedFBO[a];if(void 0!==b){const c=Object.values(b);this.renderCachePool.push(...c),delete this.proxyCachedFBO[a]}}deallocRenderCache(){this.renderCache.forEach(a=>a.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class bq extends a.OverscaledTileID{constructor(a,b,c){super(a.overscaledZ,a.wrap,a.canonical.z,a.canonical.x,a.canonical.y),this.proxyTileKey=b,this.projMatrix=c}}class br extends a.Elevation{constructor(c,d){super(),this.painter=c,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[e,g,h]=function(o){const e=new a.StructArrayLayout4i8,i=new a.StructArrayLayout3ui6;e.reserve(17161),i.reserve(33800);const b=a.EXTENT/128,f=a.EXTENT+b/2,j=f+b;for(let c=-b;c<j;c+=b)for(let d=-b;d<j;d+=b){const m=d<0||d>f||c<0||c>f?24575:0,k=a.clamp(Math.round(d),0,a.EXTENT),l=a.clamp(Math.round(c),0,a.EXTENT);e.emplaceBack(k+m,l,k,l)}const n=(b,c)=>{const a=131*c+b;i.emplaceBack(a+1,a,a+131),i.emplaceBack(a+131,a+131+1,a+1)};for(let g=1;g<129;g++)for(let h=1;h<129;h++)n(h,g);return[0,129].forEach(b=>{for(let a=0;a<130;a++)n(a,b),n(b,a)}),[e,i,32768]}(),f=c.context;this.gridBuffer=f.createVertexBuffer(e,a.boundsAttributes.members),this.gridIndexBuffer=f.createIndexBuffer(g),this.gridSegments=a.SegmentVector.simpleSegment(0,0,e.length,g.length),this.gridNoSkirtSegments=a.SegmentVector.simpleSegment(0,0,e.length,h),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new bp(d.map),this.orthoMatrix=a.create(),a.ortho(this.orthoMatrix,0,a.EXTENT,0,a.EXTENT,0,1);const b=f.gl;this._overlapStencilMode=new a.StencilMode({func:b.GEQUAL,mask:255},0,255,b.KEEP,b.KEEP,b.REPLACE),this._previousZoom=c.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=d,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new bo(d.map)}set style(a){a.on("data",this._onStyleDataEvent.bind(this)),a.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=a,this._checkRenderCacheEfficiency()}update(b,c,f){if(b&&b.terrain){this._style!==b&&(this.style=b),this.enabled=!0;const d=b.terrain.properties;this.sourceCache=0===b.terrain.drapeRenderMode?this._mockSourceCache:b._getSourceCache(d.get("source")),this._exaggeration=d.get("exaggeration");const e=()=>{this.sourceCache.used&&a.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
|
|
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const b=this.getScaledDemTileSize();this.sourceCache.update(c,b,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,e(),this._initializing=!0),e(),c.updateElevation(!f),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(c),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(a){this._findCoveringTileCache[a]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const b=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==b.efficiency&&a.warnOnce(`Terrain render cache efficiency is not optimal (${b.efficiency}%) and performance
|
|
may be affected negatively, consider placing all background, fill and line layers before layer
|
|
with id '${b.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(a){a.coord&&"source"===a.dataType?this._clearRenderCacheForTile(a.sourceCacheId,a.coord):"style"===a.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const a in this._style._sourceCaches)this._style._sourceCaches[a].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(a=>a.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 a=2*this.proxySourceCache.getSource().tileSize;return[a,a]}set useVertexMorphing(a){this._useVertexMorphing=a}updateTileBinding(h){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,d=this.painter.transform;this._initializing&&(this._initializing=0===d._centerAltitude&& -1===this.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(d.center),-1),this._emptyDEMTextureDirty=!this._initializing);const c=this.proxyCoords=i.getIds().map(b=>{const a=i.getTileByID(b).tileID;return a.projMatrix=d.calculateProjMatrix(a.toUnwrapped()),a});(function(d,b){const c=b.transform.pointCoordinate(b.transform.getCameraPoint()),e=new a.pointGeometry(c.x,c.y);d.sort((b,c)=>{if(c.overscaledZ-b.overscaledZ)return c.overscaledZ-b.overscaledZ;const f=new a.pointGeometry(b.canonical.x+(1<<b.canonical.z)*b.wrap,b.canonical.y),g=new a.pointGeometry(c.canonical.x+(1<<c.canonical.z)*c.wrap,c.canonical.y),d=e.mult(1<<b.canonical.z);return d.x-=.5,d.y-=.5,d.distSqr(f)-d.distSqr(g)})})(c,this.painter),this._previousZoom=d.zoom;const j=this.proxyToSource||{};this.proxyToSource={},c.forEach(a=>{this.proxyToSource[a.key]={}}),this.terrainTileForTile={};const k=this._style._sourceCaches;for(const e in k){const b=k[e];if(!b.used||(b!==this.sourceCache&&this.resetTileLookupCache(b.id),this._setupProxiedCoordsForOrtho(b,h[e],j),b.usedForTerrain))continue;const m=h[e];b.getSource().reparseOverscaled&&this._assignTerrainTiles(m)}this.proxiedCoords[i.id]=c.map(a=>new bq(a,a.key,this.orthoMatrix)),this._assignTerrainTiles(c),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(j),this.renderingToTexture=!1,this._updateTimestamp=a.exported.now();const l={};for(const n of(this._visibleDemTiles=[],this.proxyCoords)){const f=this.terrainTileForTile[n.key];if(!f)continue;const g=f.tileID.key;g in l||(this._visibleDemTiles.push(f),l[g]=g)}}_assignTerrainTiles(a){this._initializing||a.forEach(a=>{if(this.terrainTileForTile[a.key])return;const b=this._findTileCoveringTileID(a,this.sourceCache);b&&(this.terrainTileForTile[a.key]=b)})}_prepareDEMTextures(){const b=this.painter.context,d=b.gl;for(const e in this.terrainTileForTile){const a=this.terrainTileForTile[e],c=a.dem;c&&(!a.demTexture||a.needsDEMTextureUpload)&&(b.activeTexture.set(d.TEXTURE1),be(this.painter,a,c))}}_prepareDemTileUniforms(f,a,d,g){if(!a||null==a.demTexture)return!1;const b=f.tileID.canonical,c=Math.pow(2,a.tileID.canonical.z-b.z),e=g||"";return d[`u_dem_tl${e}`]=[b.x*c%1,b.y*c%1,],d[`u_dem_scale${e}`]=c,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const b=this.painter.context,c=b.gl;if(!this._emptyDepthBufferTexture){const d={width:1,height:1,data:new Uint8Array([255,255,255,255,])};this._emptyDepthBufferTexture=new a.Texture(b,d,c.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let a=0;const b=this._visibleDemTiles.reduce((b,c)=>{if(!c.dem)return b;const d=c.dem.tree.minimums[0];return d>0&&a++,b+d},0);return a?b/a:0}_updateEmptyDEMTexture(){const c=this.painter.context,d=c.gl;c.activeTexture.set(d.TEXTURE2);const f=this._getLoadedAreaMinimum(),e={width:1,height:1,data:new Uint8Array(a.DEMData.pack(f,this.sourceCache.getSource().encoding))};this._emptyDEMTextureDirty=!1;let b=this._emptyDEMTexture;return b?b.update(e,{premultiply:!1}):b=this._emptyDEMTexture=new a.Texture(c,e,d.RGBA,{premultiply:!1}),b}setupElevationDraw(g,p,d){var n;const f=this.painter.context,b=f.gl,c=(n=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:a.DEMData.getUnpackVector(n),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});c.u_dem_size=this.sourceCache.getSource().tileSize,c.u_exaggeration=this.exaggeration();const j=this.painter.transform,h=j.projection.createTileTransform(j,j.worldSize),i=g.tileID.canonical;c.u_tile_tl_up=h.upVector(i,0,0),c.u_tile_tr_up=h.upVector(i,a.EXTENT,0),c.u_tile_br_up=h.upVector(i,a.EXTENT,a.EXTENT),c.u_tile_bl_up=h.upVector(i,0,a.EXTENT),c.u_tile_up_scale=h.upVectorScale(i);let e=null,k=null,o=1;if(d&&d.morphing&&this._useVertexMorphing){const l=d.morphing.srcDemTile,m=d.morphing.dstDemTile;o=d.morphing.phase,l&&m&&(this._prepareDemTileUniforms(g,l,c,"_prev")&&(k=l),this._prepareDemTileUniforms(g,m,c)&&(e=m))}if(k&&e?(f.activeTexture.set(b.TEXTURE2),e.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),f.activeTexture.set(b.TEXTURE4),k.demTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE,b.NEAREST),c.u_dem_lerp=o):(e=this.terrainTileForTile[g.tileID.key],f.activeTexture.set(b.TEXTURE2),(this._prepareDemTileUniforms(g,e,c)?e.demTexture:this.emptyDEMTexture).bind(b.NEAREST,b.CLAMP_TO_EDGE)),f.activeTexture.set(b.TEXTURE3),d&&d.useDepthForOcclusion?(this._depthTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height,]):(this.emptyDepthBufferTexture.bind(b.NEAREST,b.CLAMP_TO_EDGE),c.u_depth_size_inv=[1,1]),d&&d.useMeterToDem&&e){const q=(1<<e.tileID.canonical.z)*a.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;c.u_meter_to_dem=q}d&&d.labelPlaneMatrixInv&&(c.u_label_plane_matrix_inv=d.labelPlaneMatrixInv),p.setTerrainUniformValues(f,c)}renderToBackBuffer(b){const c=this.painter,d=this.painter.context;0!==b.length&&(d.bindFramebuffer.set(null),d.viewport.set([0,0,c.width,c.height]),this.renderingToTexture=!1,function(b,c,e,f,d){if("globe"===b.transform.projection.name)!function(b,h,i,j,d){const e=b.context,f=e.gl;let k,l;const g=b.options.showTerrainWireframe?2:0,m=(c,d)=>{if(l===c)return;const a=[];d&&a.push(bk[g]),a.push(bk[c]),a.push("PROJECTION_GLOBE_VIEW"),k=b.useProgram("globeRaster",null,a),l=c},n=b.colorModeForRenderPass(),o=new a.DepthMode(f.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bj.update(d);const c=b.transform,p=a.calculateGlobeMatrix(c,c.worldSize),q=a.calculateGlobeMercatorMatrix(c),r=[a.mercatorXfromLng(c.center.lng),a.mercatorYfromLat(c.center.lat),],s=b.globeSharedBuffers;(g?[!1,!0]:[!1]).forEach(u=>{l=-1;const x=u?f.LINES:f.TRIANGLES;for(const g of j){const v=i.getTile(g),y=Math.pow(2,g.canonical.z),[D,E]=a.globeBuffersForTileMesh(b,v,g,y),z=a.StencilMode.disabled,A=h.prevTerrainTileForTile[g.key],B=h.terrainTileForTile[g.key];bi(A,B)&&bj.newMorphing(g.key,A,B,d,250),e.activeTexture.set(f.TEXTURE0),v.texture.bind(f.LINEAR,f.CLAMP_TO_EDGE);const t=bj.getMorphValuesForProxy(g.key),F=t?1:0,C={};t&&a.extend$1(C,{morphing:{srcDemTile:t.from,dstDemTile:t.to,phase:a.easeCubicInOut(t.phase)}});const G=a.globeMatrixForTile(g.canonical,p),H=bh(c.projMatrix,G,q,a.globeToMercatorTransition(c.zoom),r);if(m(F,u),h.setupElevationDraw(v,k,C),b.prepareDrawProgram(e,k,g.toUnwrapped()),s){const[I,J]=u?s.getWirefameBuffer(b.context):[s.gridIndexBuffer,s.gridSegments,];k.draw(e,x,o,z,n,a.CullFaceMode.backCCW,H,"globe_raster",D,I,J)}if(!u){const K=[0===g.canonical.y?a.globePoleMatrixForTile(g.canonical,!1,c):null,g.canonical.y===y-1?a.globePoleMatrixForTile(g.canonical,!0,c):null,];for(const w of K){if(!w)continue;const L=bh(c.projMatrix,w,w,0,r);s&&k.draw(e,x,o,z,n,a.CullFaceMode.disabled,L,"globe_pole_raster",E,s.poleIndexBuffer,s.poleSegments)}}}})}(b,c,e,f,d);else{const g=b.context,h=g.gl;let k,l;const i=b.options.showTerrainWireframe?2:0,m=(a,d)=>{if(l===a)return;const c=[bk[a]];d&&c.push(bk[i]),k=b.useProgram("terrainRaster",null,c),l=a},n=b.colorModeForRenderPass(),o=new a.DepthMode(h.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);bj.update(d);const j=b.transform,p=6*Math.pow(1.5,22-j.zoom)*c.exaggeration();(i?[!1,!0]:[!1]).forEach(r=>{l=-1;const w=r?h.LINES:h.TRIANGLES,[x,y]=r?c.getWirefameBuffer():[c.gridIndexBuffer,c.gridSegments,];for(const i of f){const s=e.getTile(i),z=a.StencilMode.disabled,t=c.prevTerrainTileForTile[i.key],u=c.terrainTileForTile[i.key];bi(t,u)&&bj.newMorphing(i.key,t,u,d,250),g.activeTexture.set(h.TEXTURE0),s.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE,h.LINEAR_MIPMAP_NEAREST);const q=bj.getMorphValuesForProxy(i.key),A=q?1:0;let v;q&&(v={morphing:{srcDemTile:q.from,dstDemTile:q.to,phase:a.easeCubicInOut(q.phase)}});const B=bg(i.projMatrix,bl(i.canonical,j.renderWorldCopies)?p/10:p);m(A,r),c.setupElevationDraw(s,k,v),b.prepareDrawProgram(g,k,i.toUnwrapped()),k.draw(g,w,o,z,n,a.CullFaceMode.backCCW,B,"terrain_raster",c.gridBuffer,x,y)}})}}(c,this,this.proxySourceCache,b,this._updateTimestamp),this.renderingToTexture=!0,b.splice(0,b.length))}renderBatch(p){if(0===this._drapedRenderBatches.length)return p+1;this.renderingToTexture=!0;const c=this.painter,e=this.painter.context,f=this.proxySourceCache,s=this.proxiedCoords[f.id],k=this._drapedRenderBatches.shift(),h=[],t=c.style.order;let i=0;for(const g of s){const l=f.getTileByID(g.proxyTileKey),m=f.proxyCachedFBO[g.key]?f.proxyCachedFBO[g.key][p]:void 0,b=void 0!==m?f.renderCache[m]:this.pool[i++],q=void 0!==m;if(l.texture=b.tex,q&&!b.dirty){h.push(l.tileID);continue}let r;e.bindFramebuffer.set(b.fb.framebuffer),this.renderedToTile=!1,b.dirty&&(e.clear({color:a.Color.transparent,stencil:0}),b.dirty=!1);for(let n=k.start;n<=k.end;++n){const j=c.style._layers[t[n]];if(j.isHidden(c.transform.zoom))continue;const d=c.style._getLayerSourceCache(j),o=d?this.proxyToSource[g.key][d.id]:[g];if(!o)continue;const u=o;e.viewport.set([0,0,b.fb.width,b.fb.height,]),r!==(d?d.id:null)&&(this._setupStencil(b,o,j,d),r=d?d.id:null),c.renderLayer(c,d,j,u)}this.renderedToTile?(b.dirty=!0,h.push(l.tileID)):q|| --i,5===i&&(i=0,this.renderToBackBuffer(h))}return this.renderToBackBuffer(h),this.renderingToTexture=!1,e.bindFramebuffer.set(null),e.viewport.set([0,0,c.width,c.height]),k.end+1}postRender(){}renderCacheEfficiency(a){const e=a.order.length;if(0===e)return{efficiency:100};let f,g=0,b=0,c=!1;for(let d=0;d<e;++d){const h=a._layers[a.order[d]];this._style.isLayerDraped(h)?(c&& ++g,++b):c||(c=!0,f=h.id)}return 0===b?{efficiency:100}:{efficiency:100*(1-g/b),firstUndrapedLayer:f}}getMinElevationBelowMSL(){let a=0;return this._visibleDemTiles.filter(a=>a.dem).forEach(b=>{a=Math.min(a,b.dem.tree.minimums[0])}),0===a?a:(a-30)*this._exaggeration}raycast(d,e,f){if(!this._visibleDemTiles)return null;const b=this._visibleDemTiles.filter(a=>a.dem).map(b=>{const c=b.tileID,a=Math.pow(2,c.overscaledZ),{x:g,y:h}=c.canonical,i=g/a,j=(g+1)/a,k=h/a,l=(h+1)/a;return{minx:i,miny:k,maxx:j,maxy:l,t:b.dem.tree.raycastRoot(i,k,j,l,d,e,f),tile:b}});for(const a of(b.sort((a,b)=>(null!==a.t?a.t:Number.MAX_VALUE)-(null!==b.t?b.t:Number.MAX_VALUE)),b)){if(null==a.t)break;const c=a.tile.dem.tree.raycast(a.minx,a.miny,a.maxx,a.maxy,d,e,f);if(null!=c)return c}return null}_createFBO(){const b=this.painter.context,c=b.gl,d=this.drapeBufferSize;b.activeTexture.set(c.TEXTURE0);const f=new a.Texture(b,{width:d[0],height:d[1],data:null},c.RGBA);f.bind(c.LINEAR,c.CLAMP_TO_EDGE);const e=b.createFramebuffer(d[0],d[1],!1);return e.colorAttachment.set(f.texture),e.depthAttachment=new Z(b,e.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=b.createRenderbuffer(b.gl.DEPTH_STENCIL,d[0],d[1]),this._stencilRef=0,e.depthAttachment.set(this._sharedDepthStencil),b.clear({stencil:0})):e.depthAttachment.set(this._sharedDepthStencil),b.extTextureFilterAnisotropic&&!b.extTextureFilterAnisotropicForceOff&&c.texParameterf(c.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax),{fb:e,tex:f,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const a in this._style._sourceCaches)if(this._style._sourceCaches[a].hasTransition())return!0;return this._style.order.some(c=>{const a=this._style._layers[c],d=a.isHidden(this.painter.transform.zoom),b=a.getCrossfadeParameters(),e=!!b&&1!==b.t,f=a.hasTransition();return"custom"!==a.type&&!d&&(e||f)})}_clearRasterFadeFromRenderCache(){let e=!1;for(const h in this._style._sourceCaches)if(this._style._sourceCaches[h]._source instanceof r){e=!0;break}if(e)for(let c=0;c<this._style.order.length;++c){const b=this._style._layers[this._style.order[c]],i=b.isHidden(this.painter.transform.zoom),a=this._style._getLayerSourceCache(b);if("raster"!==b.type||i||!a)continue;const j=b.paint.get("raster-fade-duration");for(const k of this.proxyCoords){const f=this.proxyToSource[k.key][a.id];if(f)for(const d of f){const g=bn(a.getTile(d),a.findLoadedParent(d,0),a,this.painter.transform,j);(1!==g.opacity||0!==g.mix)&&this._clearRenderCacheForTile(a.id,d)}}}}_setupDrapedRenderBatches(){const c=this._style.order,d=c.length;if(0===d)return;const e=[];let b,a=0,f=this._style._layers[c[a]];for(;!this._style.isLayerDraped(f)&&f.isHidden(this.painter.transform.zoom)&& ++a<d;)f=this._style._layers[c[a]];for(;a<d;++a){const g=this._style._layers[c[a]];g.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(g)?void 0===b&&(b=a):void 0!==b&&(e.push({start:b,end:a-1}),b=void 0))}void 0!==b&&e.push({start:b,end:a-1}),this._drapedRenderBatches=e}_setupRenderCache(p){const a=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,a.renderCache.length>a.renderCachePool.length){const i=Object.values(a.proxyCachedFBO);a.proxyCachedFBO={};for(let e=0;e<i.length;++e){const q=Object.values(i[e]);a.renderCachePool.push(...q)}}return}this._clearRasterFadeFromRenderCache();const f=this.proxyCoords,t=this._tilesDirty;for(let g=f.length-1;g>=0;g--){const b=f[g];if(a.getTileByID(b.key),void 0!==a.proxyCachedFBO[b.key]){const j=p[b.key],k=this.proxyToSource[b.key];let d=0;for(const l in k){const m=k[l],n=j[l];if(!n||n.length!==m.length||m.some((a,b)=>a!==n[b]||t[l]&&t[l].hasOwnProperty(a.key))){d=-1;break}++d}for(const r in a.proxyCachedFBO[b.key])a.renderCache[a.proxyCachedFBO[b.key][r]].dirty=d<0||d!==Object.values(j).length}}const o=[...this._drapedRenderBatches];for(const s of(o.sort((a,b)=>b.end-b.start-(a.end-a.start)),o))for(const h of f){if(a.proxyCachedFBO[h.key])continue;let c=a.renderCachePool.pop();void 0===c&&a.renderCache.length<50&&(c=a.renderCache.length,a.renderCache.push(this._createFBO())),void 0!==c&&(a.proxyCachedFBO[h.key]={},a.proxyCachedFBO[h.key][s.start]=c,a.renderCache[c].dirty=!0)}this._tilesDirty={}}_setupStencil(g,a,c,d){if(!d||!this._sourceTilesOverlap[d.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const e=this.painter.context,f=e.gl;if(a.length<=1)return void(this._overlapStencilType=!1);let b;if(c.isTileClipped())b=a.length,this._overlapStencilMode.test={func:f.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(a[0].overscaledZ>a[a.length-1].overscaledZ))return void(this._overlapStencilType=!1);b=1,this._overlapStencilMode.test={func:f.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+b>255&&(e.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=b,this._overlapStencilMode.ref=this._stencilRef,c.isTileClipped()&&this._renderTileClippingMasks(a,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(b){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[b.key]),this._overlapStencilMode):a.StencilMode.disabled}_renderTileClippingMasks(f,g){const b=this.painter,d=this.painter.context,c=d.gl;b._tileClippingMaskIDs={},d.setColorMode(a.ColorMode.disabled),d.setDepthMode(a.DepthMode.disabled);const h=b.useProgram("clippingMask");for(const e of f){const i=b._tileClippingMaskIDs[e.key]=--g;h.draw(d,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},i,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bm(e.projMatrix),"$clipping",b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}}pointCoordinate(e){const d=this.painter.transform;if(e.x<0||e.x>d.width||e.y<0||e.y>d.height)return null;const b=[e.x,e.y,1,1];a.transformMat4$1(b,b,d.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),b[0]/=d.worldSize,b[1]/=d.worldSize;const g=d._camera.position,i=a.mercatorZfromAltitude(1,d.center.lat),c=[g[0],g[1],g[2]/i,0],f=a.subtract([],b.slice(0,3),c);a.normalize(f,f);const h=this.raycast(c,f,this._exaggeration);return null!==h&&h?(a.scaleAndAdd(c,c,f,h),c[3]=c[2],c[2]*=i,c):null}drawDepth(){const e=this.painter,b=e.context,i=this.proxySourceCache,c=Math.ceil(e.width),d=Math.ceil(e.height);if(this._depthFBO&&(this._depthFBO.width!==c||this._depthFBO.height!==d)&&(this._depthFBO.destroy(),delete this._depthFBO,delete this._depthTexture),!this._depthFBO){const f=b.gl,g=b.createFramebuffer(c,d,!0);b.activeTexture.set(f.TEXTURE0);const h=new a.Texture(b,{width:c,height:d,data:null},f.RGBA);h.bind(f.NEAREST,f.CLAMP_TO_EDGE),g.colorAttachment.set(h.texture);const j=b.createRenderbuffer(b.gl.DEPTH_COMPONENT16,c,d);g.depthAttachment.set(j),this._depthFBO=g,this._depthTexture=h}b.bindFramebuffer.set(this._depthFBO.framebuffer),b.viewport.set([0,0,c,d]),function(b,c,h,i){if("globe"===b.transform.projection.name)return;const d=b.context,e=d.gl;d.clear({depth:1});const f=b.useProgram("terrainDepth"),j=new a.DepthMode(e.LESS,a.DepthMode.ReadWrite,b.depthRangeFor3D);for(const g of i){const k=h.getTile(g),l=bg(g.projMatrix,0);c.setupElevationDraw(k,f),f.draw(d,e.TRIANGLES,j,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.backCCW,l,"terrain_depth",c.gridBuffer,c.gridIndexBuffer,c.gridNoSkirtSegments)}}(e,this,i,this.proxyCoords)}_setupProxiedCoordsForOrtho(a,f,c){if(a.getSource() instanceof s)return this._setupProxiedCoordsForImageSource(a,f,c);this._findCoveringTileCache[a.id]=this._findCoveringTileCache[a.id]||{};const k=this.proxiedCoords[a.id]=[],l=this.proxyCoords;for(let g=0;g<l.length;g++){const d=l[g],m=this._findTileCoveringTileID(d,a);if(m){const n=this._createProxiedId(d,m,c[d.key]&&c[d.key][a.id]);k.push(n),this.proxyToSource[d.key][a.id]=[n,]}}let o=!1;for(let h=0;h<f.length;h++){const e=a.getTile(f[h]);if(!e||!e.hasData())continue;const b=this._findTileCoveringTileID(e.tileID,this.proxySourceCache);if(b&&b.tileID.canonical.z!==e.tileID.canonical.z){const i=this.proxyToSource[b.tileID.key][a.id],j=this._createProxiedId(b.tileID,e,c[b.tileID.key]&&c[b.tileID.key][a.id]);i?i.splice(i.length-1,0,j):this.proxyToSource[b.tileID.key][a.id]=[j],k.push(j),o=!0}}this._sourceTilesOverlap[a.id]=o}_setupProxiedCoordsForImageSource(b,i,j){if(!b.getSource().loaded())return;const m=this.proxiedCoords[b.id]=[],k=this.proxyCoords,d=b.getSource(),o=new a.pointGeometry(d.tileID.x,d.tileID.y)._div(1<<d.tileID.z),p=d.coordinates.map(a.MercatorCoordinate.fromLngLat).reduce((a,b)=>(a.min.x=Math.min(a.min.x,b.x-o.x),a.min.y=Math.min(a.min.y,b.y-o.y),a.max.x=Math.max(a.max.x,b.x-o.x),a.max.y=Math.max(a.max.y,b.y-o.y),a),{min:new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new a.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),n=(b,c)=>{const d=b.wrap+b.canonical.x/(1<<b.canonical.z),e=b.canonical.y/(1<<b.canonical.z),f=a.EXTENT/(1<<b.canonical.z),g=c.wrap+c.canonical.x/(1<<c.canonical.z),h=c.canonical.y/(1<<c.canonical.z);return d+f<g+p.min.x||d>g+p.max.x||e+f<h+p.min.y||e>h+p.max.y};for(let f=0;f<k.length;f++){const c=k[f];for(let g=0;g<i.length;g++){const e=b.getTile(i[g]);if(!e||!e.hasData()||n(c,e.tileID))continue;const h=this._createProxiedId(c,e,j[c.key]&&j[c.key][b.id]),l=this.proxyToSource[c.key][b.id];l?l.push(h):this.proxyToSource[c.key][b.id]=[h],m.push(h)}}}_createProxiedId(b,c,i){let e=this.orthoMatrix;if(i){const j=i.find(a=>a.key===c.tileID.key);if(j)return j}if(c.tileID.key!==b.key){const d=b.canonical.z-c.tileID.canonical.z;let f,g,h;e=a.create();const k=c.tileID.wrap-b.wrap<<b.overscaledZ;d>0?(g=(f=a.EXTENT>>d)*((c.tileID.canonical.x<<d)-b.canonical.x+k),h=f*((c.tileID.canonical.y<<d)-b.canonical.y)):(f=a.EXTENT<< -d,g=a.EXTENT*(c.tileID.canonical.x-(b.canonical.x+k<< -d)),h=a.EXTENT*(c.tileID.canonical.y-(b.canonical.y<< -d))),a.ortho(e,0,f,0,f,0,1),a.translate(e,e,[g,h,0])}return new bq(c.tileID,b.key,e)}_findTileCoveringTileID(c,d){let b=d.getTile(c);if(b&&b.hasData())return b;const l=this._findCoveringTileCache[d.id],i=l[c.key];if((b=i?d.getTileByID(i):null)&&b.hasData()||null===i)return b;let f=b?b.tileID:c,e=f.overscaledZ;const o=d.getSource().minzoom,m=[];if(!i){const g=d.getSource().maxzoom;if(c.canonical.z>=g){const h=c.canonical.z-g;d.getSource().reparseOverscaled?(e=Math.max(c.canonical.z+2,d.transform.tileZoom),f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h)):0!==h&&(e=g,f=new a.OverscaledTileID(e,c.wrap,g,c.canonical.x>>h,c.canonical.y>>h))}f.key!==c.key&&(m.push(f.key),b=d.getTile(f))}const n=a=>{m.forEach(b=>{l[b]=a}),m.length=0};for(e-=1;e>=o&&(!b||!b.hasData());e--){b&&n(b.tileID.key);const j=f.calculateScaledKey(e);if((b=d.getTileByID(j))&&b.hasData())break;const k=l[j];if(null===k)break;void 0===k?m.push(j):b=d.getTileByID(k)}return n(b?b.tileID.key:null),b&&b.hasData()?b:null}findDEMTileFor(a){return this.enabled?this._findTileCoveringTileID(a,this.sourceCache):null}prepareDrawTile(a){this.renderedToTile=!0}_clearRenderCacheForTile(b,c){let a=this._tilesDirty[b];a||(a=this._tilesDirty[b]={}),a[c.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const b=function(g){let f,e,b;const c=new a.StructArrayLayout2ui4,d=131;for(e=1;e<129;e++){for(f=1;f<129;f++)b=e*d+f,c.emplaceBack(b,b+1),c.emplaceBack(b,b+d),c.emplaceBack(b+1,b+d),128===e&&c.emplaceBack(b+d,b+d+1);c.emplaceBack(b+1,b+1+d)}return c}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(b),this.wireframeSegments=a.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,b.length)}return[this.wireframeIndexBuffer,this.wireframeSegments,]}}function bs(b){const c=[];for(let a=0;a<b.length;a++){if(null===b[a])continue;const d=b[a].split(" ");c.push(d.pop())}return c}class bt{static cacheKey(c,d,a){let b=`${c}${a?a.cacheKey:""}`;for(const e of d)b+=`/${e}`;return b}constructor(j,F,k,e,x,r){var b,c,g,h;const d=j.gl;this.program=d.createProgram();const y=bs(k.staticAttributes),z=e?e.getBinderAttributes():[],l=y.concat(z),A=k.staticUniforms?bs(k.staticUniforms):[],B=e?e.getBinderUniforms():[],C=A.concat(B),m=[];for(const t of C)0>m.indexOf(t)&&m.push(t);let n=e?e.defines():[];n=n.concat(r.map(a=>`#define ${a}`));const D=n.concat("\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",a9,a8.fragmentSource,v.fragmentSource,k.fragmentSource).join("\n"),E=n.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",a9,a8.vertexSource,v.vertexSource,u.vertexSource,k.vertexSource).join("\n"),o=d.createShader(d.FRAGMENT_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(o,D),d.compileShader(o),d.attachShader(this.program,o);const p=d.createShader(d.VERTEX_SHADER);if(d.isContextLost())return void(this.failedToCreate=!0);d.shaderSource(p,E),d.compileShader(p),d.attachShader(this.program,p),this.attributes={};const i={};this.numAttributes=l.length;for(let f=0;f<this.numAttributes;f++)l[f]&&(d.bindAttribLocation(this.program,f,l[f]),this.attributes[l[f]]=f);d.linkProgram(this.program),d.deleteShader(p),d.deleteShader(o);for(let s=0;s<m.length;s++){const q=m[s];if(q&&!i[q]){const w=d.getUniformLocation(this.program,q);w&&(i[q]=w)}}this.fixedUniforms=x(j,i),this.binderUniforms=e?e.getUniforms(j,i):[],-1!==r.indexOf("TERRAIN")&&(this.terrainUniforms=(b=j,c=i,{u_dem:new a.Uniform1i(b,c.u_dem),u_dem_prev:new a.Uniform1i(b,c.u_dem_prev),u_dem_unpack:new a.Uniform4f(b,c.u_dem_unpack),u_dem_tl:new a.Uniform2f(b,c.u_dem_tl),u_dem_scale:new a.Uniform1f(b,c.u_dem_scale),u_dem_tl_prev:new a.Uniform2f(b,c.u_dem_tl_prev),u_dem_scale_prev:new a.Uniform1f(b,c.u_dem_scale_prev),u_dem_size:new a.Uniform1f(b,c.u_dem_size),u_dem_lerp:new a.Uniform1f(b,c.u_dem_lerp),u_exaggeration:new a.Uniform1f(b,c.u_exaggeration),u_depth:new a.Uniform1i(b,c.u_depth),u_depth_size_inv:new a.Uniform2f(b,c.u_depth_size_inv),u_meter_to_dem:new a.Uniform1f(b,c.u_meter_to_dem),u_label_plane_matrix_inv:new a.UniformMatrix4f(b,c.u_label_plane_matrix_inv),u_tile_tl_up:new a.Uniform3f(b,c.u_tile_tl_up),u_tile_tr_up:new a.Uniform3f(b,c.u_tile_tr_up),u_tile_br_up:new a.Uniform3f(b,c.u_tile_br_up),u_tile_bl_up:new a.Uniform3f(b,c.u_tile_bl_up),u_tile_up_scale:new a.Uniform1f(b,c.u_tile_up_scale)})),-1!==r.indexOf("FOG")&&(this.fogUniforms=(g=j,h=i,{u_fog_matrix:new a.UniformMatrix4f(g,h.u_fog_matrix),u_fog_range:new a.Uniform2f(g,h.u_fog_range),u_fog_color:new a.Uniform4f(g,h.u_fog_color),u_fog_horizon_blend:new a.Uniform1f(g,h.u_fog_horizon_blend),u_fog_temporal_offset:new a.Uniform1f(g,h.u_fog_temporal_offset)}))}setTerrainUniformValues(c,a){if(!this.terrainUniforms)return;const d=this.terrainUniforms;if(!this.failedToCreate)for(const b in c.program.set(this.program),a)d[b].set(a[b])}setFogUniformValues(d,b){if(!this.fogUniforms)return;const c=this.fogUniforms;if(!this.failedToCreate)for(const a in d.program.set(this.program),b)c[a].location&&c[a].set(b[a])}draw(a,e,j,k,l,m,n,f,o,p,q,r,s,d,t,u){const b=a.gl;if(this.failedToCreate)return;for(const g of(a.program.set(this.program),a.setDepthMode(j),a.setStencilMode(k),a.setColorMode(l),a.setCullFace(m),Object.keys(this.fixedUniforms)))this.fixedUniforms[g].set(n[g]);d&&d.setUniforms(a,this.binderUniforms,r,{zoom:s});const h={[b.LINES]:2,[b.TRIANGLES]:3,[b.LINE_STRIP]:1}[e];for(const c of q.get()){const i=c.vaos||(c.vaos={});(i[f]||(i[f]=new bc)).bind(a,this,o,d?d.getPaintVertexBuffers():[],p,c.vertexOffset,t,u),b.drawElements(e,c.primitiveLength*h,b.UNSIGNED_SHORT,c.primitiveOffset*h*2)}}}function bu(b,c,a){const h=1/V(a,1,c.transform.tileZoom),d=Math.pow(2,a.tileID.overscaledZ),e=a.tileSize*Math.pow(2,c.transform.tileZoom)/d,f=e*(a.tileID.canonical.x+a.tileID.wrap*d),g=e*a.tileID.canonical.y;return{u_image:0,u_texsize:a.imageAtlasTexture.size,u_scale:[h,b.fromScale,b.toScale],u_fade:b.t,u_pixel_coord_upper:[f>>16,g>>16],u_pixel_coord_lower:[65535&f,65535&g]}}const bv=(h,f,i,j)=>{const b=f.style.light,c=b.properties.get("position"),d=[c.x,c.y,c.z],g=a.create$1();"viewport"===b.properties.get("anchor")&&(a.fromRotation(g,-f.transform.angle),a.transformMat3(d,d,g));const e=b.properties.get("color");return{u_matrix:h,u_lightpos:d,u_lightintensity:b.properties.get("intensity"),u_lightcolor:[e.r,e.g,e.b],u_vertical_gradient:+i,u_opacity:j}},bw=(d,b,e,f,g,h,c)=>a.extend(bv(d,b,e,f),bu(h,b,c),{u_height_factor:-Math.pow(2,g.overscaledZ)/c.tileSize/8}),bx=a=>({u_matrix:a}),by=(b,c,d,e)=>a.extend(bx(b),bu(d,c,e)),bz=(a,b)=>({u_matrix:a,u_world:b}),bA=(b,c,d,e,f)=>a.extend(by(b,c,d,e),{u_world:f}),bB=(d,g,e,c)=>{const b=d.transform;let f;return f="map"===c.paint.get("circle-pitch-alignment")?b.calculatePixelsToTileUnitsMatrix(e):new Float32Array([b.pixelsToGLUnits[0],0,0,b.pixelsToGLUnits[1],]),{u_camera_to_center_distance:b.cameraToCenterDistance,u_matrix:d.translatePosMatrix(g.projMatrix,e,c.paint.get("circle-translate"),c.paint.get("circle-translate-anchor")),u_device_pixel_ratio:a.exported.devicePixelRatio,u_extrude_scale:f}},bC=b=>{const a=[];return"map"===b.paint.get("circle-pitch-alignment")&&a.push("PITCH_WITH_MAP"),"map"===b.paint.get("circle-pitch-scale")&&a.push("SCALE_WITH_MAP"),a},bD=(d,b,e)=>{const c=a.EXTENT/e.tileSize;return{u_matrix:d,u_camera_to_center_distance:b.cameraToCenterDistance,u_extrude_scale:[b.pixelsToGLUnits[0]/c,b.pixelsToGLUnits[1]/c,]}},bE=(a,b,c=1)=>({u_matrix:a,u_color:b,u_overlay:0,u_overlay_scale:c}),bF=(a,b,c,d)=>({u_matrix:a,u_extrude_scale:V(b,1,c),u_intensity:d}),bG=(d,b,g,e,h,i)=>{const f=d.transform,j=f.calculatePixelsToTileUnitsMatrix(b),c={u_matrix:bJ(d,b,g,h),u_pixels_to_tile_units:j,u_device_pixel_ratio:a.exported.devicePixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1],],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0};if(bK(g)){const k=bI(b,d.transform);c.u_texsize=b.lineAtlasTexture.size,c.u_scale=[k,e.fromScale,e.toScale,],c.u_mix=e.t}return c},bH=(e,b,f,d,g)=>{const c=e.transform,h=bI(b,c);return{u_matrix:bJ(e,b,f,g),u_texsize:b.imageAtlasTexture.size,u_pixels_to_tile_units:c.calculatePixelsToTileUnitsMatrix(b),u_device_pixel_ratio:a.exported.devicePixelRatio,u_image:0,u_scale:[h,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1],],u_alpha_discard_threshold:0}};function bI(a,b){return 1/V(a,1,b.tileZoom)}function bJ(c,a,b,d){return c.translatePosMatrix(d||a.tileID.projMatrix,a,b.paint.get("line-translate"),b.paint.get("line-translate-anchor"))}function bK(b){const a=b.paint.get("line-dasharray").value;return a.value||"constant"!==a.kind}const bL=(e,f,g,d,a,h)=>{var b,c;return{u_matrix:e,u_tl_parent:f,u_scale_parent:g,u_fade_t:d.mix,u_opacity:d.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(c=a.paint.get("raster-saturation"))>0?1-1/(1.001-c):-c,u_contrast_factor:(b=a.paint.get("raster-contrast"))>0?1/(1-b):1+b,u_spin_weights:bM(a.paint.get("raster-hue-rotate")),u_perspective_transform:h}};function bM(a){a*=Math.PI/180;const c=Math.sin(a),b=Math.cos(a);return[(2*b+1)/3,(-Math.sqrt(3)*c-b+1)/3,(Math.sqrt(3)*c-b+1)/3,]}const bN=(a,b,e,f,d,g,h,i,j,k,l,m,n,o)=>{const c=d.transform;return{u_is_size_zoom_constant:+("constant"===a||"source"===a),u_is_size_feature_constant:+("constant"===a||"camera"===a),u_size_t:b?b.uSizeT:0,u_size:b?b.uSize:0,u_camera_to_center_distance:c.cameraToCenterDistance,u_pitch:c.pitch/360*2*Math.PI,u_rotate_symbol:+e,u_aspect_ratio:c.width/c.height,u_fade_change:d.options.fadeDuration?d.symbolFadeChange:1,u_matrix:g,u_label_plane_matrix:h,u_coord_matrix:i,u_is_text:+j,u_pitch_with_map:+f,u_texsize:k,u_tile_id:l,u_zoom_transition:m,u_inv_rot_matrix:n,u_merc_center:o,u_texture:0}},bO=(d,e,f,c,b,g,h,i,j,k,l,m,n,o,p)=>{const{cameraToCenterDistance:q,_pitch:r}=b.transform;return a.extend(bN(d,e,f,c,b,g,h,i,j,k,m,n,o,p),{u_gamma_scale:c?q*Math.cos(b.terrain?0:r):1,u_device_pixel_ratio:a.exported.devicePixelRatio,u_is_halo:+l})},bP=(b,c,d,e,f,g,h,i,j,k,l,m,n,o)=>a.extend(bO(b,c,d,e,f,g,h,i,!0,j,!0,l,m,n,o),{u_texsize_icon:k,u_texture_icon:1}),bQ=(a,b,c)=>({u_matrix:a,u_opacity:b,u_color:c}),bR=(b,c,d,e,f,g)=>a.extend(function(f,c,b,a){const d=b.imageManager.getPattern(f.from.toString()),e=b.imageManager.getPattern(f.to.toString()),{width:k,height:l}=b.imageManager.getPixelSize(),g=Math.pow(2,a.tileID.overscaledZ),h=a.tileSize*Math.pow(2,b.transform.tileZoom)/g,i=h*(a.tileID.canonical.x+a.tileID.wrap*g),j=h*a.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:d.tl,u_pattern_br_a:d.br,u_pattern_tl_b:e.tl,u_pattern_br_b:e.br,u_texsize:[k,l],u_mix:c.t,u_pattern_size_a:d.displaySize,u_pattern_size_b:e.displaySize,u_scale_a:c.fromScale,u_scale_b:c.toScale,u_tile_units_to_pixels:1/V(a,1,b.transform.tileZoom),u_pixel_coord_upper:[i>>16,j>>16,],u_pixel_coord_lower:[65535&i,65535&j,]}}(e,g,d,f),{u_matrix:b,u_opacity:c}),bS={fillExtrusion:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fillExtrusionPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_lightpos:new a.Uniform3f(b,c.u_lightpos),u_lightintensity:new a.Uniform1f(b,c.u_lightintensity),u_lightcolor:new a.Uniform3f(b,c.u_lightcolor),u_vertical_gradient:new a.Uniform1f(b,c.u_vertical_gradient),u_height_factor:new a.Uniform1f(b,c.u_height_factor),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_opacity:new a.Uniform1f(b,c.u_opacity)}),fill:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),fillPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),fillOutline:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world)}),fillOutlinePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_world:new a.Uniform2f(b,c.u_world),u_image:new a.Uniform1i(b,c.u_image),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade)}),circle:(b,c)=>({u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.UniformMatrix2f(b,c.u_extrude_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),collisionBox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_extrude_scale:new a.Uniform2f(b,c.u_extrude_scale)}),collisionCircle:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_inv_matrix:new a.UniformMatrix4f(b,c.u_inv_matrix),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_viewport_size:new a.Uniform2f(b,c.u_viewport_size)}),debug:(b,c)=>({u_color:new a.UniformColor(b,c.u_color),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_overlay:new a.Uniform1i(b,c.u_overlay),u_overlay_scale:new a.Uniform1f(b,c.u_overlay_scale)}),clippingMask:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmap:(b,c)=>({u_extrude_scale:new a.Uniform1f(b,c.u_extrude_scale),u_intensity:new a.Uniform1f(b,c.u_intensity),u_matrix:new a.UniformMatrix4f(b,c.u_matrix)}),heatmapTexture:(b,c)=>({u_image:new a.Uniform1i(b,c.u_image),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_opacity:new a.Uniform1f(b,c.u_opacity)}),hillshade:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_latrange:new a.Uniform2f(b,c.u_latrange),u_light:new a.Uniform2f(b,c.u_light),u_shadow:new a.UniformColor(b,c.u_shadow),u_highlight:new a.UniformColor(b,c.u_highlight),u_accent:new a.UniformColor(b,c.u_accent)}),hillshadePrepare:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_image:new a.Uniform1i(b,c.u_image),u_dimension:new a.Uniform2f(b,c.u_dimension),u_zoom:new a.Uniform1f(b,c.u_zoom),u_unpack:new a.Uniform4f(b,c.u_unpack)}),line:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_dash_image:new a.Uniform1i(b,c.u_dash_image),u_gradient_image:new a.Uniform1i(b,c.u_gradient_image),u_image_height:new a.Uniform1f(b,c.u_image_height),u_texsize:new a.Uniform2f(b,c.u_texsize),u_scale:new a.Uniform3f(b,c.u_scale),u_mix:new a.Uniform1f(b,c.u_mix),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),linePattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_texsize:new a.Uniform2f(b,c.u_texsize),u_pixels_to_tile_units:new a.UniformMatrix2f(b,c.u_pixels_to_tile_units),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_image:new a.Uniform1i(b,c.u_image),u_units_to_pixels:new a.Uniform2f(b,c.u_units_to_pixels),u_scale:new a.Uniform3f(b,c.u_scale),u_fade:new a.Uniform1f(b,c.u_fade),u_alpha_discard_threshold:new a.Uniform1f(b,c.u_alpha_discard_threshold)}),raster:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_tl_parent:new a.Uniform2f(b,c.u_tl_parent),u_scale_parent:new a.Uniform1f(b,c.u_scale_parent),u_fade_t:new a.Uniform1f(b,c.u_fade_t),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image0:new a.Uniform1i(b,c.u_image0),u_image1:new a.Uniform1i(b,c.u_image1),u_brightness_low:new a.Uniform1f(b,c.u_brightness_low),u_brightness_high:new a.Uniform1f(b,c.u_brightness_high),u_saturation_factor:new a.Uniform1f(b,c.u_saturation_factor),u_contrast_factor:new a.Uniform1f(b,c.u_contrast_factor),u_spin_weights:new a.Uniform3f(b,c.u_spin_weights),u_perspective_transform:new a.Uniform2f(b,c.u_perspective_transform)}),symbolIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_texture:new a.Uniform1i(b,c.u_texture)}),symbolSDF:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texture:new a.Uniform1i(b,c.u_texture),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_tile_id:new a.Uniform3f(b,c.u_tile_id),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_inv_rot_matrix:new a.UniformMatrix4f(b,c.u_inv_rot_matrix),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),symbolTextAndIcon:(b,c)=>({u_is_size_zoom_constant:new a.Uniform1i(b,c.u_is_size_zoom_constant),u_is_size_feature_constant:new a.Uniform1i(b,c.u_is_size_feature_constant),u_size_t:new a.Uniform1f(b,c.u_size_t),u_size:new a.Uniform1f(b,c.u_size),u_camera_to_center_distance:new a.Uniform1f(b,c.u_camera_to_center_distance),u_pitch:new a.Uniform1f(b,c.u_pitch),u_rotate_symbol:new a.Uniform1i(b,c.u_rotate_symbol),u_aspect_ratio:new a.Uniform1f(b,c.u_aspect_ratio),u_fade_change:new a.Uniform1f(b,c.u_fade_change),u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_label_plane_matrix:new a.UniformMatrix4f(b,c.u_label_plane_matrix),u_coord_matrix:new a.UniformMatrix4f(b,c.u_coord_matrix),u_is_text:new a.Uniform1i(b,c.u_is_text),u_pitch_with_map:new a.Uniform1i(b,c.u_pitch_with_map),u_texsize:new a.Uniform2f(b,c.u_texsize),u_texsize_icon:new a.Uniform2f(b,c.u_texsize_icon),u_texture:new a.Uniform1i(b,c.u_texture),u_texture_icon:new a.Uniform1i(b,c.u_texture_icon),u_gamma_scale:new a.Uniform1f(b,c.u_gamma_scale),u_device_pixel_ratio:new a.Uniform1f(b,c.u_device_pixel_ratio),u_is_halo:new a.Uniform1i(b,c.u_is_halo)}),background:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_color:new a.UniformColor(b,c.u_color)}),backgroundPattern:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_opacity:new a.Uniform1f(b,c.u_opacity),u_image:new a.Uniform1i(b,c.u_image),u_pattern_tl_a:new a.Uniform2f(b,c.u_pattern_tl_a),u_pattern_br_a:new a.Uniform2f(b,c.u_pattern_br_a),u_pattern_tl_b:new a.Uniform2f(b,c.u_pattern_tl_b),u_pattern_br_b:new a.Uniform2f(b,c.u_pattern_br_b),u_texsize:new a.Uniform2f(b,c.u_texsize),u_mix:new a.Uniform1f(b,c.u_mix),u_pattern_size_a:new a.Uniform2f(b,c.u_pattern_size_a),u_pattern_size_b:new a.Uniform2f(b,c.u_pattern_size_b),u_scale_a:new a.Uniform1f(b,c.u_scale_a),u_scale_b:new a.Uniform1f(b,c.u_scale_b),u_pixel_coord_upper:new a.Uniform2f(b,c.u_pixel_coord_upper),u_pixel_coord_lower:new a.Uniform2f(b,c.u_pixel_coord_lower),u_tile_units_to_pixels:new a.Uniform1f(b,c.u_tile_units_to_pixels)}),terrainRaster:k,terrainDepth:k,skybox:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_cubemap:new a.Uniform1i(b,c.u_cubemap),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxGradient:(b,c)=>({u_matrix:new a.UniformMatrix4f(b,c.u_matrix),u_color_ramp:new a.Uniform1i(b,c.u_color_ramp),u_center_direction:new a.Uniform3f(b,c.u_center_direction),u_radius:new a.Uniform1f(b,c.u_radius),u_opacity:new a.Uniform1f(b,c.u_opacity),u_temporal_offset:new a.Uniform1f(b,c.u_temporal_offset)}),skyboxCapture:(b,c)=>({u_matrix_3f:new a.UniformMatrix3f(b,c.u_matrix_3f),u_sun_direction:new a.Uniform3f(b,c.u_sun_direction),u_sun_intensity:new a.Uniform1f(b,c.u_sun_intensity),u_color_tint_r:new a.Uniform4f(b,c.u_color_tint_r),u_color_tint_m:new a.Uniform4f(b,c.u_color_tint_m),u_luminance:new a.Uniform1f(b,c.u_luminance)}),globeRaster:(b,c)=>({u_proj_matrix:new a.UniformMatrix4f(b,c.u_proj_matrix),u_globe_matrix:new a.UniformMatrix4f(b,c.u_globe_matrix),u_merc_matrix:new a.UniformMatrix4f(b,c.u_merc_matrix),u_zoom_transition:new a.Uniform1f(b,c.u_zoom_transition),u_merc_center:new a.Uniform2f(b,c.u_merc_center),u_image0:new a.Uniform1i(b,c.u_image0)}),globeAtmosphere:(b,c)=>({u_center:new a.Uniform2f(b,c.u_center),u_radius:new a.Uniform1f(b,c.u_radius),u_screen_size:new a.Uniform2f(b,c.u_screen_size),u_pixel_ratio:new a.Uniform1f(b,c.u_pixel_ratio),u_opacity:new a.Uniform1f(b,c.u_opacity),u_fadeout_range:new a.Uniform1f(b,c.u_fadeout_range),u_start_color:new a.Uniform3f(b,c.u_start_color),u_end_color:new a.Uniform3f(b,c.u_end_color)})};let bT;function bU(b,H,s,A,t,I,B){var u;const f=b.context,C=f.gl,D=b.useProgram("collisionBox"),j=[];let g=0,E=0;for(let v=0;v<A.length;v++){const w=A[v],k=H.getTile(w),d=k.getBucket(s);if(!d)continue;let x=w.projMatrix;0===t[0]&&0===t[1]||(x=b.translatePosMatrix(w.projMatrix,k,t,I));const e=B?d.textCollisionBox:d.iconCollisionBox,y=d.collisionCircleArray;if(y.length>0){const l=a.create(),J=x;a.mul(l,d.placementInvProjMatrix,b.transform.glCoordMatrix),a.mul(l,l,d.placementViewportMatrix),j.push({circleArray:y,circleOffset:E,transform:J,invTransform:l}),g+=y.length/4,E=g}e&&(b.terrain&&b.terrain.setupElevationDraw(k,D),D.draw(f,C.LINES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,bD(x,b.transform,k),s.id,e.layoutVertexBuffer,e.indexBuffer,e.segments,null,b.transform.zoom,null,e.collisionVertexBuffer,e.collisionVertexBufferExt))}if(!B||!j.length)return;const K=b.useProgram("collisionCircle"),c=new a.StructArrayLayout2f1f2i16;c.resize(4*g),c._trim();let m=0;for(const h of j)for(let z=0;z<h.circleArray.length/4;z++){const n=4*z,o=h.circleArray[n+0],p=h.circleArray[n+1],q=h.circleArray[n+2],r=h.circleArray[n+3];c.emplace(m++,o,p,q,r,0),c.emplace(m++,o,p,q,r,1),c.emplace(m++,o,p,q,r,2),c.emplace(m++,o,p,q,r,3)}(!bT||bT.length<2*g)&&(bT=function(f){const e=2*f,b=new a.StructArrayLayout3ui6;b.resize(e),b._trim();for(let c=0;c<e;c++){const d=6*c;b.uint16[d+0]=4*c+0,b.uint16[d+1]=4*c+1,b.uint16[d+2]=4*c+2,b.uint16[d+3]=4*c+2,b.uint16[d+4]=4*c+3,b.uint16[d+5]=4*c+0}return b}(g));const F=f.createIndexBuffer(bT,!0),G=f.createVertexBuffer(c,a.collisionCircleLayout.members,!0);for(const i of j){const L={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(u=b.transform).cameraToCenterDistance,u_viewport_size:[u.width,u.height]};K.draw(f,C.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.disabled,L,s.id,G,F,a.SegmentVector.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,b.transform.zoom,null,null,null)}G.destroy(),F.destroy()}const bV=a.identity(new Float32Array(16));function bW(b,f,g,h,c,d){const{horizontalAlign:i,verticalAlign:j}=a.getAnchorAlignment(b),e=a.evaluateVariableOffset(b,h);return new a.pointGeometry((-(i-.5)*f/c+e[0])*d,(-(j-.5)*g/c+e[1])*d)}function bX(c,C,h,D,E,i,n,o,F,G,p,H){const q=c.text.placedSymbolArray,e=c.text.dynamicLayoutVertexArray,d=c.icon.dynamicLayoutVertexArray,r={},I=o.projMatrix,s=i.elevation,J=s?s.getAtTileOffsetFunc(o,H):a=>[0,0,0];e.clear();for(let j=0;j<q.length;j++){const b=q.get(j),K=c.allowVerticalPlacement&&!b.placedOrientation,t=b.hidden||!b.crossTileID||K?null:D[b.crossTileID];if(t){const k=new a.pointGeometry(b.tileAnchorX,b.tileAnchorY),u=J(k),v=aD(k,h?I:n,u[2]),L=aE(i.cameraToCenterDistance,v.signedDistanceFromCamera);let w=E.evaluateSizeForFeature(c.textSizeData,G,b)*L/a.ONE_EM;h&&(w*=c.tilePixelRatio/F);const{width:M,height:N,anchor:O,textOffset:P,textScale:Q}=t,l=bW(O,M,N,P,Q,w),x=h?aD(k.add(l),n,u[2]).point:v.point.add(C?l.rotate(-i.angle):l),y=c.allowVerticalPlacement&&b.placedOrientation===a.WritingMode.vertical?Math.PI/2:0;for(let z=0;z<b.numGlyphs;z++)a.addDynamicAttributes(e,x,y);p&&b.associatedIconIndex>=0&&(r[b.associatedIconIndex]={shiftedAnchor:x,angle:y})}else aO(b.numGlyphs,e)}if(p){d.clear();const A=c.icon.placedSymbolArray;for(let f=0;f<A.length;f++){const g=A.get(f);if(g.hidden)aO(g.numGlyphs,d);else{const m=r[f];if(m)for(let B=0;B<g.numGlyphs;B++)a.addDynamicAttributes(d,m.shiftedAnchor,m.angle);else aO(g.numGlyphs,d)}}c.icon.dynamicLayoutVertexBuffer.updateData(d)}c.text.dynamicLayoutVertexBuffer.updateData(e)}function bY(a,b,c){return c.iconsInText&&b?"symbolTextAndIcon":a?"symbolSDF":"symbolIcon"}function bZ(b,_,h,aa,i,J,K,ab,ac,ad,L,M){const t=b.context,k=t.gl,f=b.transform,N=f.projection.createTileTransform(f,f.worldSize),q="map"===ab,j="map"===ac,n=q&&"point"!==h.layout.get("symbol-placement"),u=q&&!j&&!n,ae=void 0!==h.layout.get("symbol-sort-key").constantOr(1);let O=!1;const P=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),v=[a.mercatorXfromLng(f.center.lng),a.mercatorYfromLat(f.center.lat),],Q=h.layout.get("text-variable-anchor"),w="globe"===f.projection.name,x=w?a.globeToMercatorTransition(f.zoom):0,r=[],s=[];for(const g of(b.terrain&&j&&s.push("PITCH_WITH_MAP_TERRAIN"),w&&s.push("PROJECTION_GLOBE_VIEW"),n&&s.push("PROJECTED_POS_ON_VIEWPORT"),aa)){const e=_.getTile(g),d=e.getBucket(h);if(!d||d.projection!==f.projection.name)continue;const l=i?d.text:d.icon;if(!l||d.fullyClipped||!l.segments.get().length)continue;const af=l.programConfigurations.get(h.id),o=i||d.sdfIcons,m=i?d.textSizeData:d.iconSizeData,R=j||0!==f.pitch,ag=b.useProgram(bY(o,i,d),af,s),y=a.evaluateSizeForZoom(m,f.zoom),z=[g.canonical.x,g.canonical.y,1<<g.canonical.z,];let p,A,B,S,T=[0,0],U=null;if(i){if(A=e.glyphAtlasTexture,B=k.LINEAR,p=e.glyphAtlasTexture.size,d.iconsInText){T=e.imageAtlasTexture.size,U=e.imageAtlasTexture;const ah="composite"===m.kind||"camera"===m.kind;S=R||b.options.rotating||b.options.zooming||ah?k.LINEAR:k.NEAREST}}else{const ai=1!==h.layout.get("icon-size").constantOr(0)||d.iconsNeedLinear;A=e.imageAtlasTexture,B=o||b.options.rotating||b.options.zooming||ai||R?k.LINEAR:k.NEAREST,p=e.imageAtlasTexture.size}const V=b.transform.calculatePixelsToTileUnitsMatrix(e),C=aB(g.projMatrix,e.tileID.canonical,j,q,b.transform,V),aj=b.terrain&&j&&n?a.invert(new Float32Array(16),C):bV,W=aC(g.projMatrix,e.tileID.canonical,j,q,b.transform,V),ak=Q&&d.hasTextData(),al="none"!==h.layout.get("icon-text-fit")&&ak&&d.hasIconData();if(n){const X=f.elevation,am=X?X.getAtTileOffsetFunc(g,N):a=>[0,0,0];aG(d,g.projMatrix,b,i,C,W,j,ad,am,g)}const D=b.translatePosMatrix(g.projMatrix,e,J,K),E=n||i&&Q||al?bV:C,F=b.translatePosMatrix(W,e,J,K,!0),an=o&&0!==h.paint.get(i?"text-halo-width":"icon-halo-width").constantOr(1);let Y;const G=N.createInversionMatrix(g.toUnwrapped());Y=o?d.iconsInText?bP(m.kind,y,u,j,b,D,E,F,p,T,z,x,G,v):bO(m.kind,y,u,j,b,D,E,F,i,p,!0,z,x,G,v):bN(m.kind,y,u,j,b,D,E,F,i,p,z,x,G,v);const Z={program:ag,buffers:l,uniformValues:Y,atlasTexture:A,atlasTextureIcon:U,atlasInterpolation:B,atlasInterpolationIcon:S,isSDF:o,hasHalo:an,tile:e,labelPlaneMatrixInv:aj};if(ae&&d.canOverlap){O=!0;const ao=l.segments.get();for(const $ of ao)r.push({segments:new a.SegmentVector([$]),sortKey:$.sortKey,state:Z})}else r.push({segments:l.segments,sortKey:0,state:Z})}for(const H of(O&&r.sort((a,b)=>a.sortKey-b.sortKey),r)){const c=H.state;if(b.terrain&&b.terrain.setupElevationDraw(c.tile,c.program,{useDepthForOcclusion:!w,labelPlaneMatrixInv:c.labelPlaneMatrixInv}),t.activeTexture.set(k.TEXTURE0),c.atlasTexture.bind(c.atlasInterpolation,k.CLAMP_TO_EDGE),c.atlasTextureIcon&&(t.activeTexture.set(k.TEXTURE1),c.atlasTextureIcon&&c.atlasTextureIcon.bind(c.atlasInterpolationIcon,k.CLAMP_TO_EDGE)),c.isSDF){const I=c.uniformValues;c.hasHalo&&(I.u_is_halo=1,b$(c.buffers,H.segments,h,b,c.program,P,L,M,I)),I.u_is_halo=0}b$(c.buffers,H.segments,h,b,c.program,P,L,M,c.uniformValues)}}function b$(b,f,c,d,g,h,i,j,k){const e=d.context;g.draw(e,e.gl.TRIANGLES,h,i,j,a.CullFaceMode.disabled,k,c.id,b.layoutVertexBuffer,b.indexBuffer,f,c.paint,d.transform.zoom,b.programConfigurations.get(c.id),b.dynamicLayoutVertexBuffer,b.opacityVertexBuffer)}function b_(b,y,c,z,A,B,s){const e=b.context.gl,l=c.paint.get("fill-pattern"),g=l&&l.constantOr(1),m=c.getCrossfadeParameters();let n,i,o,p,q;for(const h of(s?(i=g&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",n=e.LINES):(i=g?"fillPattern":"fill",n=e.TRIANGLES),z)){const d=y.getTile(h);if(g&&!d.patternsLoaded())continue;const f=d.getBucket(c);if(!f)continue;b.prepareDrawTile(h);const j=f.programConfigurations.get(c.id),t=b.useProgram(i,j);g&&(b.context.activeTexture.set(e.TEXTURE0),d.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),j.updatePaintBuffers(m));const r=l.constantOr(null);if(r&&d.imageAtlas){const u=d.imageAtlas,v=u.patternPositions[r.to.toString()],w=u.patternPositions[r.from.toString()];v&&w&&j.setConstantPatternPositions(v,w)}const k=b.translatePosMatrix(h.projMatrix,d,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(s){p=f.indexBuffer2,q=f.segments2;const x=b.terrain&&b.terrain.renderingToTexture?b.terrain.drapeBufferSize:[e.drawingBufferWidth,e.drawingBufferHeight,];o="fillOutlinePattern"===i&&g?bA(k,b,m,d,x):bz(k,x)}else p=f.indexBuffer,q=f.segments,o=g?by(k,b,m,d):bx(k);b.prepareDrawProgram(b.context,t,h.toUnwrapped()),t.draw(b.context,n,A,b.stencilModeForClipping(h),B,a.CullFaceMode.disabled,o,c.id,f.layoutVertexBuffer,p,q,c.paint,b.transform.zoom,j)}}function b0(b,m,c,x,y,z,A){const f=b.context,h=f.gl,n=c.paint.get("fill-extrusion-pattern"),k=n.constantOr(1),o=c.getCrossfadeParameters(),p=c.paint.get("fill-extrusion-opacity");for(const g of x){const e=m.getTile(g),d=e.getBucket(c);if(!d)continue;const i=d.programConfigurations.get(c.id),j=b.useProgram(k?"fillExtrusionPattern":"fillExtrusion",i);if(b.terrain){const q=b.terrain;if(!d.enableTerrain)continue;if(q.setupElevationDraw(e,j,{useMeterToDem:!0}),b1(f,m,g,d,c,q),!d.centroidVertexBuffer){const r=j.attributes.a_centroid_pos;void 0!==r&&h.vertexAttrib2f(r,0,0)}}k&&(b.context.activeTexture.set(h.TEXTURE0),e.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),i.updatePaintBuffers(o));const l=n.constantOr(null);if(l&&e.imageAtlas){const s=e.imageAtlas,t=s.patternPositions[l.to.toString()],u=s.patternPositions[l.from.toString()];t&&u&&i.setConstantPatternPositions(t,u)}const v=b.translatePosMatrix(g.projMatrix,e,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),w=c.paint.get("fill-extrusion-vertical-gradient"),B=k?bw(v,b,w,p,g,o,e):bv(v,b,w,p);b.prepareDrawProgram(f,j,g.toUnwrapped()),j.draw(f,f.gl.TRIANGLES,y,z,A,a.CullFaceMode.backCCW,B,c.id,d.layoutVertexBuffer,d.indexBuffer,d.segments,c.paint,b.transform.zoom,i,b.terrain?d.centroidVertexBuffer:null)}}function b1(w,D,p,c,E,q){const x=[b=>{let c=b.canonical.x-1,d=b.wrap;return c<0&&(c=(1<<b.canonical.z)-1,d--),new a.OverscaledTileID(b.overscaledZ,d,b.canonical.z,c,b.canonical.y)},b=>{let c=b.canonical.x+1,d=b.wrap;return c===1<<b.canonical.z&&(c=0,d++),new a.OverscaledTileID(b.overscaledZ,d,b.canonical.z,c,b.canonical.y)},b=>new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,(0===b.canonical.y?1<<b.canonical.z:b.canonical.y)-1),b=>new a.OverscaledTileID(b.overscaledZ,b.wrap,b.canonical.z,b.canonical.x,b.canonical.y===(1<<b.canonical.z)-1?0:b.canonical.y+1),],y=a=>{const b=D.getSource().maxzoom,c=b=>{const a=D.getTileByID(b);if(a&&a.hasData())return a.getBucket(E)};let d,e,f;return(a.overscaledZ===a.canonical.z||a.overscaledZ>=b)&&(d=c(a.key)),a.overscaledZ>=b&&(e=c(a.calculateScaledKey(a.overscaledZ+1))),a.overscaledZ>b&&(f=c(a.calculateScaledKey(a.overscaledZ-1))),d||e||f},F=[0,0,0],G=(b,c)=>(F[0]=Math.min(b.min.y,c.min.y),F[1]=Math.max(b.max.y,c.max.y),F[2]=a.EXTENT-c.min.x>b.max.x?c.min.x-a.EXTENT:b.max.x,F),H=(b,c)=>(F[0]=Math.min(b.min.x,c.min.x),F[1]=Math.max(b.max.x,c.max.x),F[2]=a.EXTENT-c.min.y>b.max.y?c.min.y-a.EXTENT:b.max.y,F),z=[(a,b)=>G(a,b),(a,b)=>G(b,a),(a,b)=>H(a,b),(a,b)=>H(b,a),],j=new a.pointGeometry(0,0);let r,s,A;const B=(e,f,b,c,d)=>{const g=[[c?b:e,c?e:b,0],[c?b:f,c?f:b,0],],i=d<0?a.EXTENT+d:d,h=[c?i:(e+f)/2,c?(e+f)/2:i,0,];return 0===b&&d<0||0!==b&&d>0?q.getForTilePoints(A,[h],!0,s):g.push(h),q.getForTilePoints(p,g,!0,r),Math.max(g[0][2],g[1][2],h[2])/q.exaggeration()};for(let d=0;d<4;d++){const k=c.borders[d];if(0===k.length&&(c.borderDone[d]=!0),c.borderDone[d])continue;const t=A=x[d](p),b=y(t);if(!b||!b.enableTerrain||!(s=q.findDEMTileFor(t))||!s.dem)continue;if(!r){const l=q.findDEMTileFor(p);if(!l||!l.dem)return;r=l}const f=(d<2?1:5)-d,h=b.borders[f];let g=0;for(let m=0;m<k.length;m++){const i=c.featuresOnBorder[k[m]],u=i.borders[d];let e;for(;g<h.length&&!((e=b.featuresOnBorder[h[g]]).borders[f][1]>u[0]+3);)b.borderDone[f]||b.encodeCentroid(void 0,e,!1),g++;if(e&&g<h.length){const v=g;let n=0;for(;!(e.borders[f][0]>u[1]-3)&&(n++,++g!==h.length);)e=b.featuresOnBorder[h[g]];if(e=b.featuresOnBorder[h[v]],i.intersectsCount()>1||e.intersectsCount()>1||1!==n){1!==n&&(g=v),c.encodeCentroid(void 0,i,!1),b.borderDone[f]||b.encodeCentroid(void 0,e,!1);continue}const o=z[d](i,e),C=d%2?a.EXTENT-1:0;j.x=B(o[0],Math.min(a.EXTENT-1,o[1]),C,d<2,o[2]),j.y=0,c.encodeCentroid(j,i,!1),b.borderDone[f]||b.encodeCentroid(j,e,!1)}else c.encodeCentroid(void 0,i,!1)}c.borderDone[d]=c.needsCentroidUpdate=!0,b.borderDone[f]||(b.borderDone[f]=b.needsCentroidUpdate=!0)}(c.needsCentroidUpdate|| !c.centroidVertexBuffer&&0!==c.centroidVertexArray.length)&&c.uploadCentroid(w)}const b2=new a.Color(1,0,0,1),b3=new a.Color(0,1,0,1),b4=new a.Color(0,0,1,1),b5=new a.Color(1,0,1,1),b6=new a.Color(0,1,1,1);function b7(a,c,b,d){b9(a,0,c+b/2,a.transform.width,b,d)}function b8(a,c,b,d){b9(a,c-b/2,0,b,a.transform.height,d)}function b9(d,e,f,g,h,i){const c=d.context,b=c.gl;b.enable(b.SCISSOR_TEST),b.scissor(e*a.exported.devicePixelRatio,f*a.exported.devicePixelRatio,g*a.exported.devicePixelRatio,h*a.exported.devicePixelRatio),c.clear({color:i}),b.disable(b.SCISSOR_TEST)}function ca(b,h,c){const f=b.context,e=f.gl,i=c.projMatrix,g=b.useProgram("debug"),d=h.getTileByID(c.key);b.terrain&&b.terrain.setupElevationDraw(d,g);const j=a.DepthMode.disabled,k=a.StencilMode.disabled,o=b.colorModeForRenderPass(),l="$debug";f.activeTexture.set(e.TEXTURE0),b.emptyTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),d._makeDebugTileBoundsBuffers(b.context,b.transform.projection);const p=d._tileDebugBuffer||b.debugBuffer,q=d._tileDebugIndexBuffer||b.debugIndexBuffer,r=d._tileDebugSegments||b.debugSegments;g.draw(f,e.LINE_STRIP,j,k,o,a.CullFaceMode.disabled,bE(i,a.Color.red),l,p,q,r);const m=d.latestRawTileData,s=Math.floor((m&&m.byteLength||0)/1024),t=h.getTile(c).tileSize,u=512/Math.min(t,512)*(c.overscaledZ/b.transform.zoom)*.5;let n=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(n+=` => ${c.overscaledZ}`),function(b,d){b.initDebugOverlayCanvas();const c=b.debugOverlayCanvas,e=b.context.gl,a=b.debugOverlayCanvas.getContext("2d");a.clearRect(0,0,c.width,c.height),a.shadowColor="white",a.shadowBlur=2,a.lineWidth=1.5,a.strokeStyle="white",a.textBaseline="top",a.font="bold 36px Open Sans, sans-serif",a.fillText(d,5,5),a.strokeText(d,5,5),b.debugOverlayTexture.update(c),b.debugOverlayTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}(b,`${n} ${s}kb`),g.draw(f,e.TRIANGLES,j,k,a.ColorMode.alphaBlended,a.CullFaceMode.disabled,bE(i,a.Color.transparent,u),l,b.debugBuffer,b.quadTriangleIndexBuffer,b.debugSegments)}const w=a.createLayout([{name:"a_pos_3f",components:3,type:"Float32"},]),{members:cb}=w;function cc(a,b,c,d){a.emplaceBack(b,c,d)}class cd{constructor(b){this.vertexArray=new a.StructArrayLayout3f12,this.indices=new a.StructArrayLayout3ui6,cc(this.vertexArray,-1,-1,1),cc(this.vertexArray,1,-1,1),cc(this.vertexArray,-1,1,1),cc(this.vertexArray,1,1,1),cc(this.vertexArray,-1,-1,-1),cc(this.vertexArray,1,-1,-1),cc(this.vertexArray,-1,1,-1),cc(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=b.createVertexBuffer(this.vertexArray,cb),this.indexBuffer=b.createIndexBuffer(this.indices),this.segment=a.SegmentVector.simpleSegment(0,0,36,12)}}function ce(f,b,j,k,l,m){var g,h,i,c,d;const e=f.gl,n=b.paint.get("sky-atmosphere-color"),o=b.paint.get("sky-atmosphere-halo-color"),p=b.paint.get("sky-atmosphere-sun-intensity"),q=(g=a.fromMat4([],k),h=l,i=p,c=n,d=o,{u_matrix_3f:g,u_sun_direction:h,u_sun_intensity:i,u_color_tint_r:[c.r,c.g,c.b,c.a],u_color_tint_m:[d.r,d.g,d.b,d.a],u_luminance:5e-5});e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+m,b.skyboxTexture,0),j.draw(f,e.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,a.ColorMode.unblended,a.CullFaceMode.frontCW,q,"skyboxCapture",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}const cf={symbol:function(c,d,b,e,h){if("translucent"!==c.renderPass)return;const f=a.StencilMode.disabled,g=c.colorModeForRenderPass();b.layout.get("text-variable-anchor")&&function(k,e,g,l,m,n,o){const b=e.transform,h="map"===m,i="map"===n,p=b.projection.createTileTransform(b,b.worldSize);for(const f of k){const d=l.getTile(f),c=d.getBucket(g);if(!c||c.projection!==b.projection.name||!c.text||!c.text.segments.get().length)continue;const j=a.evaluateSizeForZoom(c.textSizeData,b.zoom),q=e.transform.calculatePixelsToTileUnitsMatrix(d),r=aB(f.projMatrix,d.tileID.canonical,i,h,e.transform,q),s="none"!==g.layout.get("icon-text-fit")&&c.hasIconData();if(j){const t=Math.pow(2,b.zoom-d.tileID.overscaledZ);bX(c,h,i,o,a.symbolSize,b,r,f,t,j,s,p)}}}(e,c,b,d,b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),h),0!==b.paint.get("icon-opacity").constantOr(1)&&bZ(c,d,b,e,!1,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),b.layout.get("icon-rotation-alignment"),b.layout.get("icon-pitch-alignment"),b.layout.get("icon-keep-upright"),f,g),0!==b.paint.get("text-opacity").constantOr(1)&&bZ(c,d,b,e,!0,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),b.layout.get("text-rotation-alignment"),b.layout.get("text-pitch-alignment"),b.layout.get("text-keep-upright"),f,g),d.map.showCollisionBoxes&&(bU(c,d,b,e,b.paint.get("text-translate"),b.paint.get("text-translate-anchor"),!0),bU(c,d,b,e,b.paint.get("icon-translate"),b.paint.get("icon-translate-anchor"),!1))},circle:function(b,r,c,j){if("translucent"!==b.renderPass)return;const s=c.paint.get("circle-opacity"),t=c.paint.get("circle-stroke-width"),u=c.paint.get("circle-stroke-opacity"),k=void 0!==c.layout.get("circle-sort-key").constantOr(1);if(0===s.constantOr(1)&&(0===t.constantOr(1)||0===u.constantOr(1)))return;const f=b.context,v=f.gl,w=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),x=a.StencilMode.disabled,y=b.colorModeForRenderPass(),e=[];for(let g=0;g<j.length;g++){const l=j[g],h=r.getTile(l),d=h.getBucket(c);if(!d)continue;const m=d.programConfigurations.get(c.id),z=bC(c),n={programConfiguration:m,program:b.useProgram("circle",m,z),layoutVertexBuffer:d.layoutVertexBuffer,indexBuffer:d.indexBuffer,uniformValues:bB(b,l,h,c),tile:h};if(k){const A=d.segments.get();for(const o of A)e.push({segments:new a.SegmentVector([o,]),sortKey:o.sortKey,state:n})}else e.push({segments:d.segments,sortKey:0,state:n})}k&&e.sort((a,b)=>a.sortKey-b.sortKey);const B={useDepthForOcclusion:"globe"!==b.transform.projection.name};for(const p of e){const{programConfiguration:C,program:i,layoutVertexBuffer:D,indexBuffer:E,uniformValues:F,tile:q}=p.state,G=p.segments;b.terrain&&b.terrain.setupElevationDraw(q,i,B),b.prepareDrawProgram(f,i,q.tileID.toUnwrapped()),i.draw(f,v.TRIANGLES,w,x,y,a.CullFaceMode.disabled,F,c.id,D,E,G,c.paint,b.transform.zoom,C)}},heatmap:function(b,k,c,l){if(0!==c.paint.get("heatmap-opacity")){if("offscreen"===b.renderPass){const d=b.context,g=d.gl,n=a.StencilMode.disabled,o=new a.ColorMode([g.ONE,g.ONE],a.Color.transparent,[!0,!0,!0,!0]);(function(b,c,e){const a=b.gl;b.activeTexture.set(a.TEXTURE1),b.viewport.set([0,0,c.width/4,c.height/4,]);let d=e.heatmapFbo;if(d)a.bindTexture(a.TEXTURE_2D,d.colorAttachment.get()),b.bindFramebuffer.set(d.framebuffer);else{const f=a.createTexture();a.bindTexture(a.TEXTURE_2D,f),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),d=e.heatmapFbo=b.createFramebuffer(c.width/4,c.height/4,!1),function(b,c,d,e){const a=b.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,c.width/4,c.height/4,0,a.RGBA,b.extRenderToTextureHalfFloat?b.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),e.colorAttachment.set(d)}(b,c,f,d)}})(d,b,c),d.clear({color:a.Color.transparent});for(let h=0;h<l.length;h++){const f=l[h];if(k.hasRenderableParent(f))continue;const i=k.getTile(f),e=i.getBucket(c);if(!e)continue;const m=e.programConfigurations.get(c.id),j=b.useProgram("heatmap",m),{zoom:p}=b.transform;b.terrain&&b.terrain.setupElevationDraw(i,j),b.prepareDrawProgram(d,j,f.toUnwrapped()),j.draw(d,g.TRIANGLES,a.DepthMode.disabled,n,o,a.CullFaceMode.disabled,bF(f.projMatrix,i,p,c.paint.get("heatmap-intensity")),c.id,e.layoutVertexBuffer,e.indexBuffer,e.segments,c.paint,b.transform.zoom,m)}d.viewport.set([0,0,b.width,b.height,])}else"translucent"===b.renderPass&&(b.context.setColorMode(b.colorModeForRenderPass()),function(c,d){const e=c.context,b=e.gl,g=d.heatmapFbo;if(!g)return;e.activeTexture.set(b.TEXTURE0),b.bindTexture(b.TEXTURE_2D,g.colorAttachment.get()),e.activeTexture.set(b.TEXTURE1);let f=d.colorRampTexture;f||(f=d.colorRampTexture=new a.Texture(e,d.colorRamp,b.RGBA)),f.bind(b.LINEAR,b.CLAMP_TO_EDGE),c.useProgram("heatmapTexture").draw(e,b.TRIANGLES,a.DepthMode.disabled,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.disabled,{u_image:0,u_color_ramp:1,u_opacity:d.paint.get("heatmap-opacity")},d.id,c.viewportBuffer,c.quadTriangleIndexBuffer,c.viewportSegments,d.paint,c.transform.zoom)}(b,c))}},line:function(b,s,c,H){if("translucent"!==b.renderPass)return;const I=c.paint.get("line-opacity"),J=c.paint.get("line-width");if(0===I.constantOr(1)||0===J.constantOr(1))return;const R=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),S=b.colorModeForRenderPass(),t=c.paint.get("line-dasharray"),K=t.constantOr(1),L=c.layout.get("line-cap"),u=c.paint.get("line-pattern"),j=u.constantOr(1),M=c.paint.get("line-gradient"),l=c.getCrossfadeParameters(),N=j?"linePattern":"line",g=b.context,d=g.gl,v=(a=>{const b=[];bK(a)&&b.push("RENDER_LINE_DASH"),a.paint.get("line-gradient")&&b.push("RENDER_LINE_GRADIENT");const c=a.paint.get("line-pattern").constantOr(1),d=1!==a.paint.get("line-opacity").constantOr(1);return!c&&d&&b.push("RENDER_LINE_ALPHA_DISCARD"),b})(c);let m=v.includes("RENDER_LINE_ALPHA_DISCARD");for(const h of(b.terrain&&b.terrain.clipOrMaskOverlapStencilType()&&(m=!1),H)){const f=s.getTile(h);if(j&&!f.patternsLoaded())continue;const i=f.getBucket(c);if(!i)continue;b.prepareDrawTile(h);const k=i.programConfigurations.get(c.id),O=b.useProgram(N,k,v),n=u.constantOr(null);if(n&&f.imageAtlas){const w=f.imageAtlas,x=w.patternPositions[n.to.toString()],y=w.patternPositions[n.from.toString()];x&&y&&k.setConstantPatternPositions(x,y)}const o=t.constantOr(null),p=L.constantOr(null);if(!j&&o&&p&&f.lineAtlas){const z=f.lineAtlas,A=z.getDash(o.to,p),B=z.getDash(o.from,p);A&&B&&k.setConstantPatternPositions(A,B)}const C=b.terrain?h.projMatrix:null,D=j?bH(b,f,c,l,C):bG(b,f,c,l,C,i.lineClipsArray.length);if(M){const e=i.gradients[c.id];let E=e.texture;if(c.gradientVersion!==e.version){let F=256;if(c.stepInterpolant){const P=s.getSource().maxzoom,Q=h.canonical.z===P?Math.ceil(1<<b.transform.maxZoom-h.canonical.z):1;F=a.clamp(a.nextPowerOfTwo(i.maxLineLength/a.EXTENT*1024*Q),256,g.maxTextureSize)}e.gradient=a.renderColorRamp({expression:c.gradientExpression(),evaluationKey:"lineProgress",resolution:F,image:e.gradient||void 0,clips:i.lineClipsArray}),e.texture?e.texture.update(e.gradient):e.texture=new a.Texture(g,e.gradient,d.RGBA),e.version=c.gradientVersion,E=e.texture}g.activeTexture.set(d.TEXTURE1),E.bind(c.stepInterpolant?d.NEAREST:d.LINEAR,d.CLAMP_TO_EDGE)}K&&(g.activeTexture.set(d.TEXTURE0),f.lineAtlasTexture.bind(d.LINEAR,d.REPEAT),k.updatePaintBuffers(l)),j&&(g.activeTexture.set(d.TEXTURE0),f.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),k.updatePaintBuffers(l)),b.prepareDrawProgram(g,O,h.toUnwrapped());const q=e=>{O.draw(g,d.TRIANGLES,R,e,S,a.CullFaceMode.disabled,D,c.id,i.layoutVertexBuffer,i.indexBuffer,i.segments,c.paint,b.transform.zoom,k,i.layoutVertexBuffer2)};if(m){const r=b.stencilModeForClipping(h).ref;0===r&&b.terrain&&g.clear({stencil:0});const G={func:d.EQUAL,mask:255};D.u_alpha_discard_threshold=.8,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.INVERT)),D.u_alpha_discard_threshold=0,q(new a.StencilMode(G,r,255,d.KEEP,d.KEEP,d.KEEP))}else q(b.stencilModeForClipping(h))}m&&(b.resetStencilClippingMasks(),b.terrain&&g.clear({stencil:0}))},fill:function(b,d,c,e){const h=c.paint.get("fill-color"),f=c.paint.get("fill-opacity");if(0===f.constantOr(1))return;const g=b.colorModeForRenderPass(),i=c.paint.get("fill-pattern"),j=b.opaquePassEnabledForLayer()&&!i.constantOr(1)&&1===h.constantOr(a.Color.transparent).a&&1===f.constantOr(0)?"opaque":"translucent";if(b.renderPass===j){const k=b.depthModeForSublayer(1,"opaque"===b.renderPass?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly);b_(b,d,c,e,k,g,!1)}if("translucent"===b.renderPass&&c.paint.get("fill-antialias")){const l=b.depthModeForSublayer(c.getPaintProperty("fill-outline-color")?2:0,a.DepthMode.ReadOnly);b_(b,d,c,e,l,g,!0)}},"fill-extrusion":function(b,d,c,e){const g=c.paint.get("fill-extrusion-opacity");if(0!==g&&"translucent"===b.renderPass){const f=new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D);if(1!==g||c.paint.get("fill-extrusion-pattern").constantOr(1))b0(b,d,c,e,f,a.StencilMode.disabled,a.ColorMode.disabled),b0(b,d,c,e,f,b.stencilModeFor3D(),b.colorModeForRenderPass()),b.resetStencilClippingMasks();else{const h=b.colorModeForRenderPass();b0(b,d,c,e,f,a.StencilMode.disabled,h)}}},hillshade:function(b,j,e,f){if("offscreen"!==b.renderPass&&"translucent"!==b.renderPass)return;const k=b.context,g=b.depthModeForSublayer(0,a.DepthMode.ReadOnly),h=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[l,m]="translucent"!==b.renderPass||i?[{},f]:b.stencilConfigForOverlap(f);for(const c of m){const d=j.getTile(c);if(d.needsHillshadePrepare&&"offscreen"===b.renderPass)bf(b,d,e,g,a.StencilMode.disabled,h);else if("translucent"===b.renderPass){const n=i&&b.terrain?b.terrain.stencilModeForRTTOverlap(c):l[c.overscaledZ];bd(b,c,d,e,g,n,h)}}k.viewport.set([0,0,b.width,b.height]),b.resetStencilClippingMasks()},raster:function(b,j,f,m,H,x){if("translucent"!==b.renderPass||0===f.paint.get("raster-opacity")||!m.length)return;const g=b.context,c=g.gl,h=j.getSource(),n=b.useProgram("raster"),q=b.colorModeForRenderPass(),i=b.terrain&&b.terrain.renderingToTexture,[y,o]=h instanceof s||i?[{},m]:b.stencilConfigForOverlap(m),z=o[o.length-1].overscaledZ,A=!b.options.moving;for(const e of o){const r=i?a.DepthMode.disabled:b.depthModeForSublayer(e.overscaledZ-z,1===f.paint.get("raster-opacity")?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly,c.LESS),t=e.toUnwrapped(),d=j.getTile(e);if(i&&(!d||!d.hasData()))continue;const B=i?e.projMatrix:b.transform.calculateProjMatrix(t,A),C=b.terrain&&i?b.terrain.stencilModeForRTTOverlap(e):y[e.overscaledZ],u=x?0:f.paint.get("raster-fade-duration");d.registerFadeDuration(u);const k=j.findLoadedParent(e,0),D=bn(d,k,j,b.transform,u);let l,v;b.terrain&&b.terrain.prepareDrawTile(e);const p="nearest"===f.paint.get("raster-resampling")?c.NEAREST:c.LINEAR;g.activeTexture.set(c.TEXTURE0),d.texture.bind(p,c.CLAMP_TO_EDGE),g.activeTexture.set(c.TEXTURE1),k?(k.texture.bind(p,c.CLAMP_TO_EDGE),l=Math.pow(2,k.tileID.overscaledZ-d.tileID.overscaledZ),v=[d.tileID.canonical.x*l%1,d.tileID.canonical.y*l%1,]):d.texture.bind(p,c.CLAMP_TO_EDGE);const w=bL(B,v||[0,0],l||1,D,f,h instanceof s?h.perspectiveTransform:[0,0]);if(b.prepareDrawProgram(g,n,t),h instanceof s)n.draw(g,c.TRIANGLES,r,a.StencilMode.disabled,q,a.CullFaceMode.disabled,w,f.id,h.boundsBuffer,b.quadTriangleIndexBuffer,h.boundsSegments);else{const{tileBoundsBuffer:E,tileBoundsIndexBuffer:F,tileBoundsSegments:G}=b.getTileBoundsBuffers(d);n.draw(g,c.TRIANGLES,r,C,q,a.CullFaceMode.disabled,w,f.id,E,F,G)}}b.resetStencilClippingMasks()},background:function(b,j,e,k){const l=e.paint.get("background-color"),f=e.paint.get("background-opacity");if(0===f)return;const g=b.context,m=g.gl,n=b.transform,o=n.tileSize,d=e.paint.get("background-pattern");if(b.isPatternMissing(d))return;const p=!d&&1===l.a&&1===f&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==p)return;const t=a.StencilMode.disabled,u=b.depthModeForSublayer(0,"opaque"===p?a.DepthMode.ReadWrite:a.DepthMode.ReadOnly),v=b.colorModeForRenderPass(),q=b.useProgram(d?"backgroundPattern":"background");let h,i=k;i||(i=Object.values(h=b.getBackgroundTiles()).map(a=>a.tileID)),d&&(g.activeTexture.set(m.TEXTURE0),b.imageManager.bind(b.context));const w=e.getCrossfadeParameters();for(const c of i){const r=c.toUnwrapped(),s=k?c.projMatrix:b.transform.calculateProjMatrix(r);b.prepareDrawTile(c);const x=j?j.getTile(c):h?h[c.key]:new a.Tile(c,o,n.zoom,b),y=d?bR(s,f,b,d,{tileID:c,tileSize:o},w):bQ(s,f,l);b.prepareDrawProgram(g,q,r);const{tileBoundsBuffer:z,tileBoundsIndexBuffer:A,tileBoundsSegments:B}=b.getTileBoundsBuffers(x);q.draw(g,m.TRIANGLES,u,t,v,a.CullFaceMode.disabled,y,e.id,z,A,B)}},sky:function(b,k,c){const d=b.transform,i="mercator"===d.projection.name||"globe"===d.projection.name?1:a.smoothstep(7,8,d.zoom),e=c.paint.get("sky-opacity")*i;if(0===e)return;const j=b.context,f=c.paint.get("sky-type"),g=new a.DepthMode(j.gl.LEQUAL,a.DepthMode.ReadOnly,[0,1]),h=b.frameCounter/1e3%1;"atmosphere"===f?"offscreen"===b.renderPass?c.needsSkyboxCapture(b)&&(function(h,e,k,l){const d=h.context,b=d.gl;let i=e.skyboxFbo;if(!i){i=e.skyboxFbo=d.createFramebuffer(32,32,!1),e.skyboxGeometry=new cd(d),e.skyboxTexture=d.gl.createTexture(),b.bindTexture(b.TEXTURE_CUBE_MAP,e.skyboxTexture),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);for(let j=0;j<6;++j)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,b.RGBA,32,32,0,b.RGBA,b.UNSIGNED_BYTE,null)}d.bindFramebuffer.set(i.framebuffer),d.viewport.set([0,0,32,32,]);const f=e.getCenter(h,!0),g=h.useProgram("skyboxCapture"),c=new Float64Array(16);a.identity(c),a.rotateY(c,c,-(.5*Math.PI)),ce(d,e,g,c,f,0),a.identity(c),a.rotateY(c,c,.5*Math.PI),ce(d,e,g,c,f,1),a.identity(c),a.rotateX(c,c,-(.5*Math.PI)),ce(d,e,g,c,f,2),a.identity(c),a.rotateX(c,c,.5*Math.PI),ce(d,e,g,c,f,3),a.identity(c),ce(d,e,g,c,f,4),a.identity(c),a.rotateY(c,c,Math.PI),ce(d,e,g,c,f,5),d.viewport.set([0,0,h.width,h.height,])}(b,c),c.markSkyboxValid(b)):"sky"===b.renderPass&&function(b,c,i,j,k){var f,g;const d=b.context,e=d.gl,l=b.transform,h=b.useProgram("skybox");d.activeTexture.set(e.TEXTURE0),e.bindTexture(e.TEXTURE_CUBE_MAP,c.skyboxTexture);const m=(f=l.skyboxMatrix,g=c.getCenter(b,!1),{u_matrix:f,u_sun_direction:g,u_cubemap:0,u_opacity:j,u_temporal_offset:k});b.prepareDrawProgram(d,h),h.draw(d,e.TRIANGLES,i,a.StencilMode.disabled,b.colorModeForRenderPass(),a.CullFaceMode.backCW,m,"skybox",c.skyboxGeometry.vertexBuffer,c.skyboxGeometry.indexBuffer,c.skyboxGeometry.segment)}(b,c,g,e,h):"gradient"===f&&"sky"===b.renderPass&&function(c,b,m,n,o){var g,h,i,j,k;const d=c.context,e=d.gl,p=c.transform,l=c.useProgram("skyboxGradient");b.skyboxGeometry||(b.skyboxGeometry=new cd(d)),d.activeTexture.set(e.TEXTURE0);let f=b.colorRampTexture;f||(f=b.colorRampTexture=new a.Texture(d,b.colorRamp,e.RGBA)),f.bind(e.LINEAR,e.CLAMP_TO_EDGE);const q=(g=p.skyboxMatrix,h=b.getCenter(c,!1),i=b.paint.get("sky-gradient-radius"),j=n,k=o,{u_matrix:g,u_color_ramp:0,u_center_direction:h,u_radius:a.degToRad(i),u_opacity:j,u_temporal_offset:k});c.prepareDrawProgram(d,l),l.draw(d,e.TRIANGLES,m,a.StencilMode.disabled,c.colorModeForRenderPass(),a.CullFaceMode.backCW,q,"skyboxGradient",b.skyboxGeometry.vertexBuffer,b.skyboxGeometry.indexBuffer,b.skyboxGeometry.segment)}(b,c,g,e,h)},debug:function(c,d,b){for(let a=0;a<b.length;a++)ca(c,d,b[a])},custom:function(b,h,f){const c=b.context,d=f.implementation;if(b.transform.projection.unsupportedLayers&&b.transform.projection.unsupportedLayers.includes("custom"))a.warnOnce("Custom layers are not yet supported with non-mercator projections. Use mercator to enable custom layers.");else if("offscreen"===b.renderPass){const e=d.prerender;e&&(b.setCustomLayerDefaults(),c.setColorMode(b.colorModeForRenderPass()),e.call(d,c.gl,b.transform.customLayerMatrix()),c.setDirty(),b.setBaseState())}else if("translucent"===b.renderPass){b.setCustomLayerDefaults(),c.setColorMode(b.colorModeForRenderPass()),c.setStencilMode(a.StencilMode.disabled);const g="3d"===d.renderingMode?new a.DepthMode(b.context.gl.LEQUAL,a.DepthMode.ReadWrite,b.depthRangeFor3D):b.depthModeForSublayer(0,a.DepthMode.ReadOnly);c.setDepthMode(g),d.render(c.gl,b.transform.customLayerMatrix()),c.setDirty(),b.setBaseState(),c.bindFramebuffer.set(null)}}};class cg{constructor(b,c){this.context=new class{constructor(b){this.gl=b,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),this.clearColor=new class extends o{getDefault(){return a.Color.transparent}set(a){const b=this.current;(a.r!==b.r||a.g!==b.g||a.b!==b.b||a.a!==b.a||this.dirty)&&(this.gl.clearColor(a.r,a.g,a.b,a.a),this.current=a,this.dirty=!1)}}(this),this.clearDepth=new class extends o{getDefault(){return 1}set(a){(a!==this.current||this.dirty)&&(this.gl.clearDepth(a),this.current=a,this.dirty=!1)}}(this),this.clearStencil=new class extends o{getDefault(){return 0}set(a){(a!==this.current||this.dirty)&&(this.gl.clearStencil(a),this.current=a,this.dirty=!1)}}(this),this.colorMask=new class extends o{getDefault(){return[!0,!0,!0,!0]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||a[2]!==b[2]||a[3]!==b[3]||this.dirty)&&(this.gl.colorMask(a[0],a[1],a[2],a[3]),this.current=a,this.dirty=!1)}}(this),this.depthMask=new class extends o{getDefault(){return!0}set(a){(a!==this.current||this.dirty)&&(this.gl.depthMask(a),this.current=a,this.dirty=!1)}}(this),this.stencilMask=new class extends o{getDefault(){return 255}set(a){(a!==this.current||this.dirty)&&(this.gl.stencilMask(a),this.current=a,this.dirty=!1)}}(this),this.stencilFunc=new class extends o{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(a){const b=this.current;(a.func!==b.func||a.ref!==b.ref||a.mask!==b.mask||this.dirty)&&(this.gl.stencilFunc(a.func,a.ref,a.mask),this.current=a,this.dirty=!1)}}(this),this.stencilOp=new class extends o{getDefault(){const a=this.gl;return[a.KEEP,a.KEEP,a.KEEP]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||a[2]!==b[2]||this.dirty)&&(this.gl.stencilOp(a[0],a[1],a[2]),this.current=a,this.dirty=!1)}}(this),this.stencilTest=new class extends o{getDefault(){return!1}set(b){if(b===this.current&&!this.dirty)return;const a=this.gl;b?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),this.current=b,this.dirty=!1}}(this),this.depthRange=new class extends o{getDefault(){return[0,1]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||this.dirty)&&(this.gl.depthRange(a[0],a[1]),this.current=a,this.dirty=!1)}}(this),this.depthTest=new class extends o{getDefault(){return!1}set(b){if(b===this.current&&!this.dirty)return;const a=this.gl;b?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),this.current=b,this.dirty=!1}}(this),this.depthFunc=new class extends o{getDefault(){return this.gl.LESS}set(a){(a!==this.current||this.dirty)&&(this.gl.depthFunc(a),this.current=a,this.dirty=!1)}}(this),this.blend=new class extends o{getDefault(){return!1}set(b){if(b===this.current&&!this.dirty)return;const a=this.gl;b?a.enable(a.BLEND):a.disable(a.BLEND),this.current=b,this.dirty=!1}}(this),this.blendFunc=new class extends o{getDefault(){const a=this.gl;return[a.ONE,a.ZERO]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||this.dirty)&&(this.gl.blendFunc(a[0],a[1]),this.current=a,this.dirty=!1)}}(this),this.blendColor=new class extends o{getDefault(){return a.Color.transparent}set(a){const b=this.current;(a.r!==b.r||a.g!==b.g||a.b!==b.b||a.a!==b.a||this.dirty)&&(this.gl.blendColor(a.r,a.g,a.b,a.a),this.current=a,this.dirty=!1)}}(this),this.blendEquation=new class extends o{getDefault(){return this.gl.FUNC_ADD}set(a){(a!==this.current||this.dirty)&&(this.gl.blendEquation(a),this.current=a,this.dirty=!1)}}(this),this.cullFace=new class extends o{getDefault(){return!1}set(b){if(b===this.current&&!this.dirty)return;const a=this.gl;b?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),this.current=b,this.dirty=!1}}(this),this.cullFaceSide=new class extends o{getDefault(){return this.gl.BACK}set(a){(a!==this.current||this.dirty)&&(this.gl.cullFace(a),this.current=a,this.dirty=!1)}}(this),this.frontFace=new class extends o{getDefault(){return this.gl.CCW}set(a){(a!==this.current||this.dirty)&&(this.gl.frontFace(a),this.current=a,this.dirty=!1)}}(this),this.program=new class extends o{getDefault(){return null}set(a){(a!==this.current||this.dirty)&&(this.gl.useProgram(a),this.current=a,this.dirty=!1)}}(this),this.activeTexture=new class extends o{getDefault(){return this.gl.TEXTURE0}set(a){(a!==this.current||this.dirty)&&(this.gl.activeTexture(a),this.current=a,this.dirty=!1)}}(this),this.viewport=new class extends o{getDefault(){const a=this.gl;return[0,0,a.drawingBufferWidth,a.drawingBufferHeight,]}set(a){const b=this.current;(a[0]!==b[0]||a[1]!==b[1]||a[2]!==b[2]||a[3]!==b[3]||this.dirty)&&(this.gl.viewport(a[0],a[1],a[2],a[3]),this.current=a,this.dirty=!1)}}(this),this.bindFramebuffer=new class extends o{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindFramebuffer(b.FRAMEBUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindRenderbuffer=new class extends o{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindRenderbuffer(b.RENDERBUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindTexture=new class extends o{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindTexture(b.TEXTURE_2D,a),this.current=a,this.dirty=!1}}(this),this.bindVertexBuffer=new class extends o{getDefault(){return null}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindElementBuffer=new class extends o{getDefault(){return null}set(a){const b=this.gl;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,a),this.current=a,this.dirty=!1}}(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new class extends o{constructor(a){super(a),this.vao=a.extVertexArrayObject}getDefault(){return null}set(a){this.vao&&(a!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(a),this.current=a,this.dirty=!1)}}(this),this.pixelStoreUnpack=new class extends o{getDefault(){return 4}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.pixelStorei(b.UNPACK_ALIGNMENT,a),this.current=a,this.dirty=!1}}(this),this.pixelStoreUnpackPremultiplyAlpha=new class extends o{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a),this.current=a,this.dirty=!1}}(this),this.pixelStoreUnpackFlipY=new class extends o{getDefault(){return!1}set(a){if(a===this.current&&!this.dirty)return;const b=this.gl;b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,a),this.current=a,this.dirty=!1}}(this),this.extTextureFilterAnisotropic=b.getExtension("EXT_texture_filter_anisotropic")||b.getExtension("MOZ_EXT_texture_filter_anisotropic")||b.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=b.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extTextureHalfFloat=b.getExtension("OES_texture_half_float"),this.extTextureHalfFloat&&(b.getExtension("OES_texture_half_float_linear"),this.extRenderToTextureHalfFloat=b.getExtension("EXT_color_buffer_half_float")),this.extTimerQuery=b.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=b.getParameter(b.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(a,b){return new W(this,a,b)}createVertexBuffer(a,b,c){return new Y(this,a,b,c)}createRenderbuffer(c,d,e){const a=this.gl,b=a.createRenderbuffer();return this.bindRenderbuffer.set(b),a.renderbufferStorage(a.RENDERBUFFER,c,d,e),this.bindRenderbuffer.set(null),b}createFramebuffer(a,b,c){return new $(this,a,b,c)}clear({color:c,depth:d,stencil:e}){const a=this.gl;let b=0;c&&(b|=a.COLOR_BUFFER_BIT,this.clearColor.set(c),this.colorMask.set([!0,!0,!0,!0])),void 0!==d&&(b|=a.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),void 0!==e&&(b|=a.STENCIL_BUFFER_BIT,this.clearStencil.set(e),this.stencilMask.set(255)),a.clear(b)}setCullFace(a){!1===a.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(a.mode),this.frontFace.set(a.frontFace))}setDepthMode(a){a.func!==this.gl.ALWAYS||a.mask?(this.depthTest.set(!0),this.depthFunc.set(a.func),this.depthMask.set(a.mask),this.depthRange.set(a.range)):this.depthTest.set(!1)}setStencilMode(a){a.test.func!==this.gl.ALWAYS||a.mask?(this.stencilTest.set(!0),this.stencilMask.set(a.mask),this.stencilOp.set([a.fail,a.depthFail,a.pass,]),this.stencilFunc.set({func:a.test.func,ref:a.ref,mask:a.test.mask})):this.stencilTest.set(!1)}setColorMode(b){D(b.blendFunction,a.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(b.blendFunction),this.blendColor.set(b.blendColor)),this.colorMask.set(b.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}(b),this.transform=c,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=a.SourceCache.maxUnderzooming+a.SourceCache.maxOverzooming+1,this.depthEpsilon=152587890625e-16,this.crossTileSymbolIndex=new a2,this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(a,d){const b=!!a&&!!a.terrain&&this.transform.projection.supportsTerrain;if(!(b||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new br(this,a));const c=this._terrain;this.transform.elevation=b?c:null,c.update(a,this.transform,d)}_updateFog(e){const a=e.fog;if(!a||1>a.getOpacity(this.transform.pitch)||.03>a.properties.get("horizon-blend"))return void(this.transform.fogCullDistSq=null);const[b,c]=a.getFovAdjustedRange(this.transform._fov);if(b>c)return void(this.transform.fogCullDistSq=null);const d=b+.78*(c-b);this.transform.fogCullDistSq=d*d}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(b,c){if(this.width=b*a.exported.devicePixelRatio,this.height=c*a.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height,]),this.style)for(const d of this.style.order)this.style._layers[d].resize()}setup(){const b=this.context,c=new a.StructArrayLayout2i4;c.emplaceBack(0,0),c.emplaceBack(a.EXTENT,0),c.emplaceBack(0,a.EXTENT),c.emplaceBack(a.EXTENT,a.EXTENT),this.tileExtentBuffer=b.createVertexBuffer(c,a.posAttributes.members),this.tileExtentSegments=a.SegmentVector.simpleSegment(0,0,4,2);const d=new a.StructArrayLayout2i4;d.emplaceBack(0,0),d.emplaceBack(a.EXTENT,0),d.emplaceBack(0,a.EXTENT),d.emplaceBack(a.EXTENT,a.EXTENT),this.debugBuffer=b.createVertexBuffer(d,a.posAttributes.members),this.debugSegments=a.SegmentVector.simpleSegment(0,0,4,5);const e=new a.StructArrayLayout2i4;e.emplaceBack(-1,-1),e.emplaceBack(1,-1),e.emplaceBack(-1,1),e.emplaceBack(1,1),this.viewportBuffer=b.createVertexBuffer(e,a.posAttributes.members),this.viewportSegments=a.SegmentVector.simpleSegment(0,0,4,2);const f=new a.StructArrayLayout4i8;f.emplaceBack(0,0,0,0),f.emplaceBack(a.EXTENT,0,a.EXTENT,0),f.emplaceBack(0,a.EXTENT,0,a.EXTENT),f.emplaceBack(a.EXTENT,a.EXTENT,a.EXTENT,a.EXTENT),this.mercatorBoundsBuffer=b.createVertexBuffer(f,a.boundsAttributes.members),this.mercatorBoundsSegments=a.SegmentVector.simpleSegment(0,0,4,2);const h=new a.StructArrayLayout3ui6;h.emplaceBack(0,1,2),h.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=b.createIndexBuffer(h);const i=new a.StructArrayLayout1ui2;for(const j of[0,1,3,2,0])i.emplaceBack(j);this.debugIndexBuffer=b.createIndexBuffer(i),this.emptyTexture=new a.Texture(b,{width:1,height:1,data:new Uint8Array([0,0,0,0])},b.gl.RGBA),this.identityMat=a.create();const g=this.context.gl;this.stencilClearMode=new a.StencilMode({func:g.ALWAYS,mask:0},0,255,g.ZERO,g.ZERO,g.ZERO),this.loadTimeStamps.push(a.window.performance.now())}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(a){return a._makeTileBoundsBuffers(this.context,this.transform.projection),a._tileBoundsBuffer?{tileBoundsBuffer:a._tileBoundsBuffer,tileBoundsIndexBuffer:a._tileBoundsIndexBuffer,tileBoundsSegments:a._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const b=this.context,c=b.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(b,c.TRIANGLES,a.DepthMode.disabled,this.stencilClearMode,a.ColorMode.disabled,a.CullFaceMode.disabled,bm(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(h,d,b){if(!d||this.currentStencilSource===d.id||!h.isTileClipped()||!b||0===b.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let g=!1;for(const i of b)if(void 0===this._tileClippingMaskIDs[i.key]){g=!0;break}if(!g)return}this.currentStencilSource=d.id;const e=this.context,c=e.gl;this.nextStencilID+b.length>256&&this.clearStencil(),e.setColorMode(a.ColorMode.disabled),e.setDepthMode(a.DepthMode.disabled);const j=this.useProgram("clippingMask");for(const f of(this._tileClippingMaskIDs={},b)){const k=d.getTile(f),l=this._tileClippingMaskIDs[f.key]=this.nextStencilID++,{tileBoundsBuffer:m,tileBoundsIndexBuffer:n,tileBoundsSegments:o}=this.getTileBoundsBuffers(k);j.draw(e,c.TRIANGLES,a.DepthMode.disabled,new a.StencilMode({func:c.ALWAYS,mask:0},l,255,c.KEEP,c.KEEP,c.REPLACE),a.ColorMode.disabled,a.CullFaceMode.disabled,bm(f.projMatrix),"$clipping",m,n,o)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const c=this.nextStencilID++,b=this.context.gl;return new a.StencilMode({func:b.NOTEQUAL,mask:255},c,255,b.KEEP,b.KEEP,b.REPLACE)}stencilModeForClipping(c){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(c);const b=this.context.gl;return new a.StencilMode({func:b.EQUAL,mask:255},this._tileClippingMaskIDs[c.key],0,b.KEEP,b.KEEP,b.REPLACE)}stencilConfigForOverlap(h){const c=this.context.gl,b=h.sort((a,b)=>b.overscaledZ-a.overscaledZ),f=b[b.length-1].overscaledZ,d=b[0].overscaledZ-f+1;if(d>1){this.currentStencilSource=void 0,this.nextStencilID+d>256&&this.clearStencil();const g={};for(let e=0;e<d;e++)g[e+f]=new a.StencilMode({func:c.GEQUAL,mask:255},e+this.nextStencilID,255,c.KEEP,c.KEEP,c.REPLACE);return this.nextStencilID+=d,[g,b]}return[{[f]:a.StencilMode.disabled},b,]}colorModeForRenderPass(){const c=this.context.gl;if(this._showOverdrawInspector){const b=.125;return new a.ColorMode([c.CONSTANT_COLOR,c.ONE],new a.Color(b,b,b,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?a.ColorMode.unblended:a.ColorMode.alphaBlended}depthModeForSublayer(c,d,e){if(!this.opaquePassEnabledForLayer())return a.DepthMode.disabled;const b=1-((1+this.currentLayer)*this.numSublayers+c)*this.depthEpsilon;return new a.DepthMode(e||this.context.gl.LEQUAL,d,[b,b])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(b,m){this.style=b,this.options=m,this.lineAtlas=b.lineAtlas,this.imageManager=b.imageManager,this.glyphManager=b.glyphManager,this.symbolFadeChange=b.placement.symbolFadeChange(a.exported.now()),this.imageManager.beginFrame();const c=this.style.order,i=this.style._sourceCaches;for(const y in i){const u=i[y];u.used&&u.prepare(this.context)}const n={},g={},o={};for(const h in i){const v=i[h];n[h]=v.getVisibleCoordinates(),g[h]=n[h].slice().reverse(),o[h]=v.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let j=0;j<c.length;j++)if(this.style._layers[c[j]].is3D()){this.opaquePassCutoff=j;break}if(this.terrain&&(this.terrain.updateTileBinding(o),this.opaquePassCutoff=0),"globe"!==this.transform.projection.name||this.globeSharedBuffers||(this.globeSharedBuffers=new a.GlobeSharedBuffers(this.context)),!a.isMapAuthenticated(this.context.gl))return;for(const z of(this.renderPass="offscreen",c)){const e=this.style._layers[z],p=b._getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const q=p?g[p.id]:void 0;("custom"===e.type||e.isSky()||q&&q.length)&&this.renderLayer(this,p,e,q)}this.depthRangeFor3D=[0,1-(b.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 w=a.Color.transparent;if(this.style.fog&&this.style.fog.getOpacity(this.transform.pitch)&&(w=this.style.fog.properties.get("color")),this.context.clear({color:m.showOverdrawInspector?a.Color.black:w,depth:1}),this.clearStencil(),this._showOverdrawInspector=m.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=c.length-1;this.currentLayer>=0;this.currentLayer--){const k=this.style._layers[c[this.currentLayer]],l=b._getLayerSourceCache(k);if(k.isSky())continue;const x=l?g[l.id]:void 0;this._renderTileClippingMasks(k,l,x),this.renderLayer(this,l,k,x)}if(this.renderPass="sky",(a.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<c.length;this.currentLayer++){const r=this.style._layers[c[this.currentLayer]],s=b._getLayerSourceCache(r);r.isSky()&&this.renderLayer(this,s,r,s?g[s.id]:void 0)}for("globe"===this.transform.projection.name&&function(c){const e=c.context,f=e.gl,b=c.transform,k=new a.DepthMode(f.LEQUAL,a.DepthMode.ReadOnly,[0,1]),g=c.useProgram("globeAtmosphere"),l=b._camera.getWorldToCamera(b.worldSize,1),m=b._camera.getCameraToClipPerspective(b._fov,b.width/b.height,b._nearZ,b._farZ),n=a.mul([],l,a.calculateGlobeMatrix(b,b.worldSize)),h=a.mul([],b.labelPlaneMatrix,m),i=a.transformMat4([],[0,0,0],n),o=a.add([],i,[b.worldSize/Math.PI/2,0,0,]),j=a.transformMat4([],i,h),p=a.transformMat4([],o,h),q=a.length(a.sub([],p,j)),r=1-a.globeToMercatorTransition(b.zoom),s={u_center:j,u_radius:q,u_screen_size:[b.width,b.height,],u_pixel_ratio:a.exported.devicePixelRatio,u_opacity:r,u_fadeout_range:2,u_start_color:[1,1,1],u_end_color:[.0118,.7451,.9882,]};c.prepareDrawProgram(e,g);const d=c.globeSharedBuffers;d&&g.draw(e,f.TRIANGLES,k,a.StencilMode.disabled,a.ColorMode.alphaBlended,a.CullFaceMode.backCW,s,"skybox",d.atmosphereVertexBuffer,d.atmosphereIndexBuffer,d.atmosphereSegments)}(this),this.renderPass="translucent",this.currentLayer=0;this.currentLayer<c.length;){const d=this.style._layers[c[this.currentLayer]],f=b._getLayerSourceCache(d);if(d.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(d)){if(d.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const A=f?("symbol"===d.type?o:g)[f.id]:void 0;this._renderTileClippingMasks(d,f,f?n[f.id]:void 0),this.renderLayer(this,f,d,A),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry){let t=null;a.values(this.style._layers).forEach(c=>{const a=b._getLayerSourceCache(c);a&&!c.isHidden(this.transform.zoom)&&(!t||t.getSource().maxzoom<a.getSource().maxzoom)&&(t=a)}),t&&this.options.showTileBoundaries&&cf.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(a){var c,d,e,f;const b=a.transform.padding;b7(a,a.transform.height-(b.top||0),3,b2),b7(a,b.bottom||0,3,b3),b8(a,b.left||0,3,b4),b8(a,a.transform.width-(b.right||0),3,b5);const g=a.transform.centerPoint;b9(c=a,(d=g.x)-1,(e=a.transform.height-g.y)-10,2,20,f=b6),b9(c,d-10,e-1,20,2,f)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(a.window.performance.now()),this.saveCanvasCopy())}renderLayer(b,d,a,c){a.isHidden(this.transform.zoom)||("background"===a.type||"sky"===a.type||"custom"===a.type||c&&c.length)&&(this.id=a.id,this.gpuTimingStart(a),b.transform.projection.unsupportedLayers&&b.transform.projection.unsupportedLayers.includes(a.type)||cf[a.type](b,d,a,c,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(c){if(!this.options.gpuTiming)return;const b=this.context.extTimerQuery;let a=this.gpuTimers[c.id];a||(a=this.gpuTimers[c.id]={calls:0,cpuTime:0,query:b.createQueryEXT()}),a.calls++,b.beginQueryEXT(b.TIME_ELAPSED_EXT,a.query)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const a=this.context.extTimerQuery;a.endQueryEXT(a.TIME_ELAPSED_EXT)}collectGpuTimers(){const a=this.gpuTimers;return this.gpuTimers={},a}queryGpuTimers(b){const c={};for(const d in b){const e=b[d],a=this.context.extTimerQuery,f=a.getQueryObjectEXT(e.query,a.QUERY_RESULT_EXT)/1e6;a.deleteQueryEXT(e.query),c[d]=f}return c}translatePosMatrix(e,f,b,g,c){if(!b[0]&&!b[1])return e;const d=c?"map"===g?this.transform.angle:0:"viewport"===g?-this.transform.angle:0;if(d){const h=Math.sin(d),i=Math.cos(d);b=[b[0]*i-b[1]*h,b[0]*h+b[1]*i,]}const k=[c?b[0]:V(f,b[0],this.transform.zoom),c?b[1]:V(f,b[1],this.transform.zoom),0,],j=new Float32Array(16);return a.translate(j,e,k),j}saveTileTexture(a){const b=this._tileTextures[a.size[0]];b?b.push(a):this._tileTextures[a.size[0]]=[a]}getTileTexture(b){const a=this._tileTextures[b];return a&&a.length>0?a.pop():null}isPatternMissing(a){if(!a)return!1;if(!a.from||!a.to)return!0;const b=this.imageManager.getPattern(a.from.toString()),c=this.imageManager.getPattern(a.to.toString());return!b||!c}currentGlobalDefines(){const b=this.terrain&&this.terrain.renderingToTexture,c=this.style&&this.style.fog,a=[];return this.terrain&&!this.terrain.renderingToTexture&&a.push("TERRAIN"),c&&!b&&0!==c.getOpacity(this.transform.pitch)&&a.push("FOG"),b&&a.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&a.push("OVERDRAW_INSPECTOR"),a}useProgram(a,c,e){this.cache=this.cache||{};const d=this.currentGlobalDefines().concat(e||[]),b=bt.cacheKey(a,d,c);return this.cache[b]||(this.cache[b]=new bt(this.context,a,ba[a],c,bS[a],d)),this.cache[b]}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 a=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height,]),this.context.blendEquation.set(a.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=a.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new a.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}prepareDrawTile(a){this.terrain&&this.terrain.prepareDrawTile(a)}prepareDrawProgram(c,d,e){if(this.terrain&&this.terrain.renderingToTexture)return;const a=this.style.fog;if(a){const b=a.getOpacity(this.transform.pitch);0!==b&&d.setFogUniformValues(c,((b,c,d,e)=>{const a=c.properties.get("color"),f=b.frameCounter/1e3%1,g=[a.r/a.a,a.g/a.a,a.b/a.a,e,];return{u_fog_matrix:d?b.transform.calculateFogTileMatrix(d):b.identityMat,u_fog_range:c.getFovAdjustedRange(b.transform._fov),u_fog_color:g,u_fog_horizon_blend:c.properties.get("horizon-blend"),u_fog_temporal_offset:f}})(this,a,e,b))}}setTileLoadedFlag(a){this.tileLoaded=a}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const a=this.context.gl,b=a.createTexture();return a.bindTexture(a.TEXTURE_2D,b),a.copyTexImage2D(a.TEXTURE_2D,0,a.RGBA,0,0,a.drawingBufferWidth,a.drawingBufferHeight,0),b}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const a=this.style&&this.style.fog;return!!a&&0!==a.getOpacity(this.transform.pitch)}getBackgroundTiles(){const d=this._backgroundTiles,c=this._backgroundTiles={},e=this.transform.coveringTiles({tileSize:512});for(const b of e)c[b.key]=d[b.key]||new a.Tile(b,512,this.transform.tileZoom,this);return c}clearBackgroundTiles(){this._backgroundTiles={}}}class ch{constructor(a=0,b=0,c=0,d=0){if(isNaN(a)||a<0||isNaN(b)||b<0||isNaN(c)||c<0||isNaN(d)||d<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=a,this.bottom=b,this.left=c,this.right=d}interpolate(b,c,d){return null!=c.top&&null!=b.top&&(this.top=a.number(b.top,c.top,d)),null!=c.bottom&&null!=b.bottom&&(this.bottom=a.number(b.bottom,c.bottom,d)),null!=c.left&&null!=b.left&&(this.left=a.number(b.left,c.left,d)),null!=c.right&&null!=b.right&&(this.right=a.number(b.right,c.right,d)),this}getCenter(b,c){const d=a.clamp((this.left+b-this.right)/2,0,b),e=a.clamp((this.top+c-this.bottom)/2,0,c);return new a.pointGeometry(d,e)}equals(a){return this.top===a.top&&this.bottom===a.bottom&&this.left===a.left&&this.right===a.right}clone(){return new ch(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ci(b,c){const d=a.getColumn(b,3);a.fromQuat(b,c),a.setColumn(b,3,d)}function cj(c,b){a.setColumn(c,3,[b[0],b[1],b[2],1])}function ck(c,d){const b=a.identity$1([]);return a.rotateZ$1(b,b,-d),a.rotateX$1(b,b,-c),b}function cl(b,c){const f=[b[0],b[1],0],d=[c[0],c[1],0];if(a.length(f)>=1e-15){const g=a.normalize([],f);a.scale$2(d,g,a.dot(d,g)),c[0]=d[0],c[1]=d[1]}const e=a.cross([],c,b);if(1e-15>a.len(e))return null;const h=Math.atan2(-e[1],e[0]);return ck(Math.atan2(Math.sqrt(b[0]*b[0]+b[1]*b[1]),-b[2]),h)}class x{constructor(a,b){this.position=a,this.orientation=b}get position(){return this._position}set position(b){this._position=this._renderWorldCopies?function(b){if(!b)return;const c=Array.isArray(b)?new a.MercatorCoordinate(b[0],b[1],b[2]):b;return c.x=a.wrap(c.x,0,1),c}(b):b}lookAtPoint(e,b){if(this.orientation=null,!this.position)return;const f=this._elevation?this._elevation.getAtPointOrZero(a.MercatorCoordinate.fromLngLat(e)):0,c=this.position,d=a.MercatorCoordinate.fromLngLat(e,f),g=[d.x-c.x,d.y-c.y,d.z-c.z];b||(b=[0,0,1]),b[2]=Math.abs(b[2]),this.orientation=cl(g,b)}setPitchBearing(b,c){this.orientation=ck(a.degToRad(b),a.degToRad(-c))}}class cm{constructor(b,c){this._transform=a.identity([]),this._orientation=a.identity$1([]),c&&(this._orientation=c,ci(this._transform,this._orientation)),b&&cj(this._transform,b)}get mercatorPosition(){const b=this.position;return new a.MercatorCoordinate(b[0],b[1],b[2])}get position(){const b=a.getColumn(this._transform,3);return[b[0],b[1],b[2]]}set position(a){cj(this._transform,a)}get orientation(){return this._orientation}set orientation(a){this._orientation=a,ci(this._transform,this._orientation)}getPitchBearing(){const a=this.forward(),b=this.right();return{bearing:Math.atan2(-b[1],b[0]),pitch:Math.atan2(Math.sqrt(a[0]*a[0]+a[1]*a[1]),-a[2])}}setPitchBearing(a,b){this._orientation=ck(a,b),ci(this._transform,this._orientation)}forward(){const b=a.getColumn(this._transform,2);return[-b[0],-b[1],-b[2]]}up(){const b=a.getColumn(this._transform,1);return[-b[0],-b[1],-b[2]]}right(){const b=a.getColumn(this._transform,0);return[b[0],b[1],b[2]]}getCameraToWorld(c,d){const b=new Float64Array(16);return a.invert(b,this.getWorldToCamera(c,d)),b}getWorldToCameraPosition(e,f,c){const d=this.position;a.scale$2(d,d,-e);const b=new Float64Array(16);return a.fromScaling(b,[c,c,c]),a.translate(b,b,d),b[10]*=f,b}getWorldToCamera(f,c){const b=new Float64Array(16),e=new Float64Array(4),d=this.position;return a.conjugate(e,this._orientation),a.scale$2(d,d,-f),a.fromQuat(b,e),a.translate(b,b,d),b[1]*=-1,b[5]*=-1,b[9]*=-1,b[13]*=-1,b[8]*=c,b[9]*=c,b[10]*=c,b[11]*=c,b}getCameraToClipPerspective(c,d,e,f){const b=new Float64Array(16);return a.perspective(b,c,d,e,f),b}getDistanceToElevation(b){const c=0===b?0:a.mercatorZfromAltitude(b,this.position[1]),d=this.forward();return(c-this.position[2])/d[2]}clone(){return new cm([...this.position],[...this.orientation])}}function cn(b,e){const f=cp(b),c=function(c,y,d,h,v){const l=new a.LngLat(d.lng-180*cq,d.lat),m=new a.LngLat(d.lng+180*cq,d.lat),n=c.project(l.lng,l.lat),o=c.project(m.lng,m.lat),e=-Math.atan2(o.y-n.y,o.x-n.x),i=a.MercatorCoordinate.fromLngLat(d);i.y=a.clamp(i.y,-0.999975,.999975);const f=i.toLngLat(),g=c.project(f.lng,f.lat),p=a.MercatorCoordinate.fromLngLat(f);p.x+=cq;const q=p.toLngLat(),r=c.project(q.lng,q.lat),w=cs(r.x-g.x,r.y-g.y,e),s=a.MercatorCoordinate.fromLngLat(f);s.y+=cq;const t=s.toLngLat(),u=c.project(t.lng,t.lat),j=cs(u.x-g.x,u.y-g.y,e),x=Math.abs(w.x)/Math.abs(j.y),k=a.identity([]);a.rotateZ(k,k,-e*(1-(v?0:h)));const b=a.identity([]);return a.scale(b,b,[1,1-(1-x)*h,1]),b[4]=-j.x/j.y*h,a.rotateZ(b,b,e),a.multiply$1(b,k,b),b}(b.projection,0,b.center,f,e),d=co(b);return a.scale(c,c,[d,d,1]),c}function co(b){const c=b.projection,d=cp(b),e=cr(c,b.center),f=cr(c,a.LngLat.convert(c.center));return Math.pow(2,e*d+(1-d)*f)}function cp(b){const c=b.projection.range;if(!c)return 0;const e=Math.max(b.width,b.height),d=Math.log(e/1024)/Math.LN2;return a.smoothstep(c[0]+d,c[1]+d,b.zoom)}const cq=1/4e4;function cr(d,c){const b=a.clamp(c.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),e=new a.LngLat(c.lng-180*cq,b),f=new a.LngLat(c.lng+180*cq,b),g=d.project(e.lng,b),h=d.project(f.lng,b),i=a.MercatorCoordinate.fromLngLat(e),j=a.MercatorCoordinate.fromLngLat(f),k=h.x-g.x,l=h.y-g.y,m=j.x-i.x,n=j.y-i.y;return Math.log(Math.sqrt((m*m+n*n)/(k*k+l*l)))/Math.LN2}function cs(a,b,c){const d=Math.cos(c),e=Math.sin(c);return{x:a*d-b*e,y:a*e+b*d}}class ct{constructor(e,f,b,c,d){this.tileSize=512,this._renderWorldCopies=void 0===d||d,this._minZoom=e||0,this._maxZoom=f||22,this._minPitch=null==b?0:b,this._maxPitch=null==c?60:c,this.setProjection(),this.setMaxBounds(),this.width=0,this.height=0,this._center=new a.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 ch,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new cm,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._projectionScaler=1,this._horizonShift=.1}clone(){const a=new ct(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return a.setProjection(this.getProjection()),a._elevation=this._elevation,a._centerAltitude=this._centerAltitude,a.tileSize=this.tileSize,a.setMaxBounds(this.getMaxBounds()),a.width=this.width,a.height=this.height,a.cameraElevationReference=this.cameraElevationReference,a._center=this._center,a._setZoom(this.zoom),a._cameraZoom=this._cameraZoom,a.angle=this.angle,a._fov=this._fov,a._pitch=this._pitch,a._nearZ=this._nearZ,a._farZ=this._farZ,a._averageElevation=this._averageElevation,a._unmodified=this._unmodified,a._edgeInsets=this._edgeInsets.clone(),a._camera=this._camera.clone(),a._calcMatrices(),a.freezeTileCoverage=this.freezeTileCoverage,a}get elevation(){return this._elevation}set elevation(a){this._elevation!==a&&(this._elevation=a,a?this._updateCenterElevation()&&this._updateCameraOnTerrain():(this._cameraZoom=null,this._centerAltitude=0),this._calcMatrices())}updateElevation(a){this._terrainEnabled()&&null==this._cameraZoom&&this._updateCenterElevation()&&this._updateCameraOnTerrain(),a&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return a.pick(this.projection,["name","center","parallels",])}setProjection(b){null==b&&(b={name:"mercator"}),this.projectionOptions=b;const c=this.projection?this.getProjection():void 0;return this.projection=a.getProjection(b),!D(c,this.getProjection())&&(this._calcMatrices(),!0)}get minZoom(){return this._minZoom}set minZoom(a){this._minZoom!==a&&(this._minZoom=a,this.zoom=Math.max(this.zoom,a))}get maxZoom(){return this._maxZoom}set maxZoom(a){this._maxZoom!==a&&(this._maxZoom=a,this.zoom=Math.min(this.zoom,a))}get minPitch(){return this._minPitch}set minPitch(a){this._minPitch!==a&&(this._minPitch=a,this.pitch=Math.max(this.pitch,a))}get maxPitch(){return this._maxPitch}set maxPitch(a){this._maxPitch!==a&&(this._maxPitch=a,this.pitch=Math.min(this.pitch,a))}get renderWorldCopies(){return this._renderWorldCopies&& !0===this.projection.supportsWorldCopies}set renderWorldCopies(a){void 0===a?a=!0:null===a&&(a=!1),this._renderWorldCopies=a}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const a=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(a))}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 a.pointGeometry(this.width,this.height)}get bearing(){return a.wrap(this.rotation,-180,180)}set bearing(a){this.rotation=a}get rotation(){return-this.angle/Math.PI*180}set rotation(m){var b,c,d,g,h,i,j,k,e,f;const l=-m*Math.PI/180;this.angle!==l&&(this._unmodified=!1,this.angle=l,this._calcMatrices(),this.rotationMatrix=(b=new a.ARRAY_TYPE(4),a.ARRAY_TYPE!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b),c=this.rotationMatrix,d=this.rotationMatrix,g=this.angle,h=d[0],i=d[1],j=d[2],k=d[3],e=Math.sin(g),f=Math.cos(g),c[0]=h*f+j*e,c[1]=i*f+k*e,c[2]=-(h*e)+j*f,c[3]=-(i*e)+k*f)}get pitch(){return this._pitch/Math.PI*180}set pitch(c){const b=a.clamp(c,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==b&&(this._unmodified=!1,this._pitch=b,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(a){a=Math.max(.01,Math.min(60,a)),this._fov!==a&&(this._unmodified=!1,this._fov=a/180*Math.PI,this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(a){this._averageElevation=a,this._calcFogMatrices()}get zoom(){return this._zoom}set zoom(b){const a=Math.min(Math.max(b,this.minZoom),this.maxZoom);this._zoom!==a&&(this._unmodified=!1,this._setZoom(a),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._constrain(),this._calcMatrices())}_setZoom(a){this._zoom=a,this.scale=this.zoomScale(a),this.tileZoom=Math.floor(a),this.zoomFraction=a-this.tileZoom}_updateCenterElevation(){if(!this._elevation)return!1;const a=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center),-1);return -1===a?(this._cameraZoom=null,!1):(this._centerAltitude=a,!0)}_updateCameraOnTerrain(){this._cameraZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize)}sampleAverageElevation(){if(!this._elevation)return 0;const i=this._elevation,d=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8],],f=this.horizonLineFromTop();let g=0,e=0;for(let b=0;b<d.length;b++){const j=new a.pointGeometry(d[b][0]*this.width,f+d[b][1]*(this.height-f)),c=i.pointCoordinate(j);if(!c)continue;const h=1/Math.hypot(c[0]-this._camera.position[0],c[1]-this._camera.position[1]);g+=c[3]*h,e+=h}return 0===e?NaN:g/e}get center(){return this._center}set center(a){a.lat===this._center.lat&&a.lng===this._center.lng||(this._unmodified=!1,this._center=a,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 a=this._cameraZoom,b=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),c=this.pixelsPerMeter/this.worldSize*b,d=this._mercatorZfromZoom(a),e=this._mercatorZfromZoom(this._maxZoom),f=Math.max(d-c,e);this._setZoom(this._zoomFromMercatorZ(f))}get padding(){return this._edgeInsets.toJSON()}set padding(a){this._edgeInsets.equals(a)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,a,1),this._calcMatrices())}computeZoomRelativeTo(b){const c=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,b.toAltitude()));let d;d=b.z<this._camera.position[2]?[c.x,c.y,c.z]:[b.x,b.y,b.z];const e=a.length(a.sub([],this._camera.position,d));return a.clamp(this._zoomFromMercatorZ(e),this._minZoom,this._maxZoom)}setFreeCameraOptions(b){if(!this.height|| !b.position&&!b.orientation)return;this._updateCameraState();let c=!1;if(b.orientation&&!a.exactEquals(b.orientation,this._camera.orientation)&&(c=this._setCameraOrientation(b.orientation)),b.position){const d=[b.position.x,b.position.y,b.position.z,];a.exactEquals$1(d,this._camera.position)||(this._setCameraPosition(d),c=!0)}c&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const c=this._camera.position,b=new x;return b.position=new a.MercatorCoordinate(c[0],c[1],c[2]),b.orientation=this._camera.orientation,b._elevation=this.elevation,b._renderWorldCopies=this.renderWorldCopies,b}_setCameraOrientation(b){if(!a.length$1(b))return!1;a.normalize$1(b,b);const e=a.transformQuat([],[0,0,-1],b),c=a.transformQuat([],[0,-1,0],b);if(c[2]<0)return!1;const d=cl(e,c);return!!d&&(this._camera.orientation=d,!0)}_setCameraPosition(b){const d=this.zoomScale(this.minZoom)*this.tileSize,e=this.zoomScale(this.maxZoom)*this.tileSize,c=this.cameraToCenterDistance;b[2]=a.clamp(b[2],c/e,c/d),this._camera.position=b}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(a){return this._edgeInsets.equals(a)}interpolatePadding(a,b,c){this._unmodified=!1,this._edgeInsets.interpolate(a,b,c),this._constrain(),this._calcMatrices()}coveringZoomLevel(a){const b=(a.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/a.tileSize));return Math.max(0,b)}getVisibleUnwrappedCoordinates(c){const d=[new a.UnwrappedTileID(0,c)];if(this.renderWorldCopies){const e=this.pointCoordinate(new a.pointGeometry(0,0)),f=this.pointCoordinate(new a.pointGeometry(this.width,0)),g=this.pointCoordinate(new a.pointGeometry(this.width,this.height)),h=this.pointCoordinate(new a.pointGeometry(0,this.height)),j=Math.floor(Math.min(e.x,f.x,g.x,h.x)),k=Math.floor(Math.max(e.x,f.x,g.x,h.x)),i=1;for(let b=j-i;b<=k+i;b++)0!==b&&d.push(new a.UnwrappedTileID(b,c))}return d}coveringTiles(c){let d=this.coveringZoomLevel(c);const A=d,B=this.elevation&&!c.isTerrainDEM,C="mercator"===this.projection.name;if(void 0!==c.minzoom&&d<c.minzoom)return[];void 0!==c.maxzoom&&d>c.maxzoom&&(d=c.maxzoom);const r=this.locationCoordinate(this.center),e=1<<d,s=[e*r.x,e*r.y,0],D=a.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,d,"globe"!==this.projection.name),t=this.pointCoordinate(this.getCameraPoint()),E=e*a.mercatorZfromAltitude(1,this.center.lat),u=this._camera.position[2]/a.mercatorZfromAltitude(1,this.center.lat),K=[e*t.x,e*t.y,u],L=this.cameraToCenterDistance/c.tileSize*(c.roundZoom?1:.502),M=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?d:0,F=c.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,N=c.isTerrainDEM?-F:this._elevation?this._elevation.getMinElevationBelowMSL():0,O=this.projection.isReprojectedInTileSpace?co(this):1,P=b=>{const d=1/4e4,g=new a.MercatorCoordinate(b.x+d,b.y,b.z),h=new a.MercatorCoordinate(b.x,b.y+d,b.z),i=b.toLngLat(),j=g.toLngLat(),k=h.toLngLat(),c=this.locationCoordinate(i),e=this.locationCoordinate(j),f=this.locationCoordinate(k),l=Math.hypot(e.x-c.x,e.y-c.y),m=Math.hypot(f.x-c.x,f.y-c.y);return Math.sqrt(l*m)*O/d},j=b=>{const c=F,d=N;return{aabb:a.tileAABB(this,e,0,0,0,b,d,c,this.projection),zoom:0,x:0,y:0,minZ:d,maxZ:c,wrap:b,fullyVisible:!1}},f=[];let h=[];const k=d,v=c.reparseOverscaled?A:d,G=a=>a*a,Q=G((u-this._centerAltitude)*E),H=b=>{if(!this._elevation||!b.tileID||!C)return;const c=this._elevation.getMinMaxForTile(b.tileID),a=b.aabb;c?(a.min[2]=c.min,a.max[2]=c.max,a.center[2]=(a.min[2]+a.max[2])/2):(b.shouldSplit=I(b),b.shouldSplit||(a.min[2]=a.max[2]=a.center[2]=this._centerAltitude))},I=b=>{if(b.zoom<M)return!0;if(b.zoom===k)return!1;if(null!=b.shouldSplit)return b.shouldSplit;const d=b.aabb.distanceX(K),e=b.aabb.distanceY(K);let c=Q;B&&(c=G(b.aabb.distanceZ(K)*E));let f=1;if(this.projection.isReprojectedInTileSpace&&A<=5){const g=Math.pow(2,b.zoom),h=P(new a.MercatorCoordinate((b.x+.5)/g,(b.y+.5)/g));f=h>.85?1:h}const i=d*d+e*e+c;return i<G((1<<k-b.zoom)*L*f*((a,b)=>{if(b*G(.707)<a)return 1;const c=Math.sqrt(b/a);return c/(1.4144271570014144+(Math.pow(1.1,c-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(c,Q),i))};if(this.renderWorldCopies)for(let i=1;i<=3;i++)f.push(j(-i)),f.push(j(i));for(f.push(j(0));f.length>0;){const b=f.pop(),l=b.x,m=b.y;let n=b.fullyVisible;if(!n){const w=b.aabb.intersects(D);if(0===w)continue;n=2===w}if(b.zoom!==k&&I(b))for(let g=0;g<4;g++){const o=(l<<1)+g%2,p=(m<<1)+(g>>1),q={aabb:C?b.aabb.quadrant(g):a.tileAABB(this,e,b.zoom+1,o,p,b.wrap,b.minZ,b.maxZ,this.projection),zoom:b.zoom+1,x:o,y:p,wrap:b.wrap,fullyVisible:n,tileID:void 0,shouldSplit:void 0,minZ:b.minZ,maxZ:b.maxZ};B&&(q.tileID=new a.OverscaledTileID(b.zoom+1===k?v:b.zoom+1,b.wrap,b.zoom+1,o,p),H(q)),f.push(q)}else{const x=b.zoom===k?v:b.zoom;if(c.minzoom&&c.minzoom>x)continue;const y=s[0]-(.5+l+(b.wrap<<b.zoom))*(1<<d-b.zoom),z=s[1]-.5-m,J=b.tileID?b.tileID:new a.OverscaledTileID(x,b.wrap,b.zoom,l,m);h.push({tileID:J,distanceSq:y*y+z*z})}}if(this.fogCullDistSq){const R=this.fogCullDistSq,S=this.horizonLineFromTop();h=h.filter(d=>{const e=[0,0,0,1],f=[a.EXTENT,a.EXTENT,0,1],i=this.calculateFogTileMatrix(d.tileID.toUnwrapped());a.transformMat4$1(e,e,i),a.transformMat4$1(f,f,i);const g=a.getAABBPointSquareDist(e,f);if(0===g)return!0;let j=!1;const k=this._elevation;if(k&&g>R&&0!==S){const m=this.calculateProjMatrix(d.tileID.toUnwrapped());let b;c.isTerrainDEM||(b=k.getMinMaxForTile(d.tileID)),b||(b={min:N,max:F});const l=a.furthestTileCorner(this.rotation),h=[l[0]*a.EXTENT,l[1]*a.EXTENT,b.max,];a.transformMat4(h,h,m),j=(1-h[1])*this.height*.5<S}return g<R||j})}return h.sort((a,b)=>a.distanceSq-b.distanceSq).map(a=>a.tileID)}resize(a,b){this.width=a,this.height=b,this.pixelsToGLUnits=[2/a,-2/b],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(a){return Math.pow(2,a)}scaleZoom(a){return Math.log(a)/Math.LN2}project(b){const d=a.clamp(b.lat,-a.MAX_MERCATOR_LATITUDE,a.MAX_MERCATOR_LATITUDE),c=this.projection.project(b.lng,d);return new a.pointGeometry(c.x*this.worldSize,c.y*this.worldSize)}unproject(a){return this.projection.unproject(a.x/this.worldSize,a.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(e,f){const b=this.pointCoordinate(f),c=this.pointCoordinate(this.centerPoint),d=this.locationCoordinate(e);this.setLocation(new a.MercatorCoordinate(d.x-(b.x-c.x),d.y-(b.y-c.y)))}setLocation(a){this.center=this.coordinateLocation(a),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(a){return this.projection.locationPoint(this,a)}locationPoint3D(a){return this._coordinatePoint(this.locationCoordinate(a),!0)}pointLocation(a){return this.coordinateLocation(this.pointCoordinate(a))}pointLocation3D(a){return this.coordinateLocation(this.pointCoordinate3D(a))}locationCoordinate(b,c){const e=c?a.mercatorZfromAltitude(c,b.lat):void 0,d=this.projection.project(b.lng,b.lat);return new a.MercatorCoordinate(d.x,d.y,e)}coordinateLocation(a){return this.projection.unproject(a.x,a.y)}pointRayIntersection(d,f){const h=null!=f?f:this._centerAltitude,b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse);const i=c[3];a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/i);const e=b[2],g=c[2];return{p0:b,p1:c,t:e===g?0:(h-e)/(g-e)}}screenPointToMercatorRay(d){const b=[d.x,d.y,0,1],c=[d.x,d.y,1,1];return a.transformMat4$1(b,b,this.pixelMatrixInverse),a.transformMat4$1(c,c,this.pixelMatrixInverse),a.scale$1(b,b,1/b[3]),a.scale$1(c,c,1/c[3]),b[2]=a.mercatorZfromAltitude(b[2],this._center.lat)*this.worldSize,c[2]=a.mercatorZfromAltitude(c[2],this._center.lat)*this.worldSize,a.scale$1(b,b,1/this.worldSize),a.scale$1(c,c,1/this.worldSize),new a.Ray([b[0],b[1],b[2]],a.normalize([],a.sub([],c,b)))}rayIntersectionCoordinate(e){const{p0:b,p1:c,t:d}=e,f=a.mercatorZfromAltitude(b[2],this._center.lat),g=a.mercatorZfromAltitude(c[2],this._center.lat);return new a.MercatorCoordinate(a.number(b[0],c[0],d)/this.worldSize,a.number(b[1],c[1],d)/this.worldSize,a.number(f,g,d))}pointCoordinate(a,b=this._centerAltitude){return this.projection.createTileTransform(this,this.worldSize).pointCoordinate(a.x,a.y,b)}pointCoordinate3D(c){if(!this.elevation)return this.pointCoordinate(c);const i=this.elevation;let b=this.elevation.pointCoordinate(c);if(b)return new a.MercatorCoordinate(b[0],b[1],b[2]);let f=0,d=this.horizonLineFromTop();if(c.y>d)return this.pointCoordinate(c);const j=.02*d,e=c.clone();for(let g=0;g<10&&d-f>j;g++){e.y=a.number(f,d,.66);const h=i.pointCoordinate(e);h?(d=e.y,b=h):f=e.y}return b?new a.MercatorCoordinate(b[0],b[1],b[2]):this.pointCoordinate(c)}isPointAboveHorizon(a){if(this.elevation)return!this.elevation.pointCoordinate(a);{const b=this.horizonLineFromTop();return a.y<b}}_coordinatePoint(c,d){const e=d&&this.elevation?this.elevation.getAtPointOrZero(c,this._centerAltitude):this._centerAltitude,b=[c.x*this.worldSize,c.y*this.worldSize,e+c.toAltitude(),1,];return a.transformMat4$1(b,b,this.pixelMatrix),b[3]>0?new a.pointGeometry(b[0]/b[3],b[1]/b[3]):new a.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getBounds(j,k){var f,l,g,m,h,n,i,o;const p=new a.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),q=new a.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),r=new a.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),s=new a.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let b=this.pointCoordinate(p,j),c=this.pointCoordinate(q,j);const d=this.pointCoordinate(r,k),e=this.pointCoordinate(s,k);return b.y>1&&c.y>=0?b=new a.MercatorCoordinate((1-e.y)/(f=e,((l=b).y-f.y)/(l.x-f.x))+e.x,1):b.y<0&&c.y<=1&&(b=new a.MercatorCoordinate(-e.y/(g=e,((m=b).y-g.y)/(m.x-g.x))+e.x,0)),c.y>1&&b.y>=0?c=new a.MercatorCoordinate((1-d.y)/(h=d,((n=c).y-h.y)/(n.x-h.x))+d.x,1):c.y<0&&b.y<=1&&(c=new a.MercatorCoordinate(-d.y/(i=d,((o=c).y-i.y)/(o.x-i.x))+d.x,0)),new a.LngLatBounds().extend(this.coordinateLocation(b)).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(e)).extend(this.coordinateLocation(d))}_getBounds3D(){const a=this.elevation;if(!a.visibleDemTiles.length)return this._getBounds(0,0);const b=a.visibleDemTiles.reduce((a,b)=>{if(b.dem){const c=b.dem.tree;a.min=Math.min(a.min,c.minimums[0]),a.max=Math.max(a.max,c.maximums[0])}return a},{min:Number.MAX_VALUE,max:0});return this._getBounds(b.min*a.exaggeration(),b.max*a.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(b=!0){const c=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,a=this.height/2-c*(1-this._horizonShift);return b?Math.max(0,a):a}getMaxBounds(){return this.maxBounds}setMaxBounds(b){this.maxBounds=b,this.minLat=-a.MAX_MERCATOR_LATITUDE,this.maxLat=a.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,b&&(this.minLat=b.getSouth(),this.maxLat=b.getNorth(),this.minLng=b.getWest(),this.maxLng=b.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=a.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=a.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=a.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=a.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(a,b){return this.projection.createTileTransform(this,b).createTileMatrix(a)}calculateDistanceTileData(e){const b=e.key,c=this._distanceTileDataCache;if(c[b])return c[b];const d=e.canonical,f=1/this.height,g=this.cameraWorldSize/this.zoomScale(d.z),j=(d.x+Math.pow(2,d.z)*e.wrap)*g,k=d.y*g,h=this.point,i=this.angle,l=Math.sin(-i),m=-Math.cos(-i);return c[b]={bearing:[l,m],center:[(h.x-j)*f,(h.y-k)*f],scale:g/a.EXTENT*f},c[b]}calculateFogTileMatrix(e){const b=e.key,c=this._fogTileMatrixCache;if(c[b])return c[b];const d=this.calculatePosMatrix(e,this.cameraWorldSize);return a.multiply$1(d,this.worldToFogMatrix,d),c[b]=new Float32Array(d),c[b]}calculateProjMatrix(e,f=!1){const b=e.key,c=f?this._alignedProjMatrixCache:this._projMatrixCache;if(c[b])return c[b];const d=this.calculatePosMatrix(e,this.worldSize);return a.multiply$1(d,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:f?this.alignedProjMatrix:this.projMatrix,d),c[b]=new Float32Array(d),c[b]}calculatePixelsToTileUnitsMatrix(d){const b=d.tileID.key,c=this._pixelsToTileUnitsCache;if(c[b])return c[b];const e=function(c,f){var b,d,g,h,i,j,k,e;const{scale:m}=c.tileTransform,l=m*a.EXTENT/(c.tileSize*Math.pow(2,f.zoom-c.tileID.overscaledZ+c.tileID.canonical.z));return b=new Float32Array(4),h=(d=f.inverseAdjustmentMatrix)[1],i=d[2],j=d[3],e=(g=[l,l])[1],b[0]=d[0]*(k=g[0]),b[1]=h*k,b[2]=i*e,b[3]=j*e,b}(d,this);return c[b]=e,c[b]}customLayerMatrix(){return this.mercatorMatrix.slice()}recenterOnTerrain(){if(!this._elevation)return;const g=this._elevation;this._updateCameraState();const i=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,b=this._computeCameraPosition(i),d=this._camera.forward(),f=a.mercatorZfromAltitude(1,this._center.lat);b[2]/=f,d[2]/=f,a.normalize(d,d);const h=g.raycast(b,d,g.exaggeration());if(h){const e=a.scaleAndAdd([],b,d,h),c=new a.MercatorCoordinate(e[0],e[1],a.mercatorZfromAltitude(e[2],a.latFromMercatorY(e[1]))),j=(c.z+a.length([c.x-b[0],c.y-b[1],c.z-b[2]*f,]))*this._projectionScaler;this._cameraZoom=this._zoomFromMercatorZ(j),this._centerAltitude=c.toAltitude(),this._center=this.coordinateLocation(c),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCameraAltitude(){if(!this._elevation)return;const h=this._elevation;this._updateCameraState();const i=a.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,d=this._computeCameraPosition(i),j=h.getAtPointOrZero(new a.MercatorCoordinate(...d)),e=this._minimumHeightOverTerrain()*Math.cos(a.degToRad(this._maxPitch)),f=this._camera.position[2]-this.pixelsPerMeter/this.worldSize*j;if(f<e){const c=this.locationCoordinate(this._center,this._centerAltitude),b=[c.x-d[0],c.y-d[1],c.z-d[2],],k=a.length(b);b[2]-=(e-f)/this._projectionScaler;const g=a.length(b);if(0===g)return;a.scale$2(b,b,k/g*this._projectionScaler),this._camera.position=[c.x-b[0],c.y-b[1],c.z*this._projectionScaler-b[2],],this._camera.orientation=cl(b,this._camera.up()),this._updateStateFromCamera()}}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;if(this._constraining=!0,this.projection.isReprojectedInTileSpace){const f=this.center;return f.lat=a.clamp(f.lat,this.minLat,this.maxLat),!this.maxBounds&&this.renderWorldCopies||(f.lng=a.clamp(f.lng,this.minLng,this.maxLng)),this.center=f,void(this._constraining=!1)}const o=this._unmodified,{x:m,y:j}=this.point;let c=0,b=m,g=j;const k=this.width/2,l=this.height/2,h=this.worldMinY*this.scale,i=this.worldMaxY*this.scale;if(j-l<h&&(g=h+l),j+l>i&&(g=i-l),i-h<this.height&&(c=Math.max(c,this.height/(i-h)),g=(i+h)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const d=this.worldMinX*this.scale,e=this.worldMaxX*this.scale,n=this.worldSize/2-(d+e)/2;(b=(m+n+this.worldSize)%this.worldSize-n)-k<d&&(b=d+k),b+k>e&&(b=e-k),e-d<this.width&&(c=Math.max(c,this.width/(e-d)),b=(e+d)/2)}b===m&&g===j||(this.center=this.unproject(new a.pointGeometry(b,g))),c&&(this.zoom+=this.scaleZoom(c)),this._constrainCameraAltitude(),this._unmodified=o,this._constraining=!1}_minZoomForBounds(){let a=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(a=Math.max(a,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),a}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const t=this._fov/2,e=this.centerOffset,g=this.pixelsPerMeter;this._projectionScaler=g/(a.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 u=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?g:1),h=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);h[8]=-(2*e.x)/this.width,h[9]=2*e.y/this.height;let b=a.mul([],h,u);if(this.projection.isReprojectedInTileSpace){const f=this.locationCoordinate(this.center),d=a.identity([]);a.translate(d,d,[f.x*this.worldSize,f.y*this.worldSize,0,]),a.multiply$1(d,d,cn(this)),a.translate(d,d,[-f.x*this.worldSize,-f.y*this.worldSize,0,]),a.multiply$1(b,b,d),this.inverseAdjustmentMatrix=function(b){const a=cn(b,!0);return C([],[a[0],a[1],a[4],a[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=a.scale([],b,[this.worldSize,this.worldSize,this.worldSize/g,1,]),this.projMatrix=b,this.invProjMatrix=a.invert(new Float64Array(16),this.projMatrix);const c=new Float32Array(16);a.identity(c),a.scale(c,c,[1,-1,1]),a.rotateX(c,c,this._pitch),a.rotateZ(c,c,this.angle);const i=a.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),v=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;i[8]=-(2*e.x)/this.width,i[9]=2*(e.y+v)/this.height,this.skyboxMatrix=a.multiply$1(c,i,c);const m=this.point,n=m.x,o=m.y,p=this.width%2/2,q=this.height%2/2,r=Math.cos(this.angle),s=Math.sin(this.angle),j=n-Math.round(n)+r*p+s*q,k=o-Math.round(o)+r*q+s*p,l=new Float64Array(b);if(a.translate(l,l,[j>.5?j-1:j,k>.5?k-1:k,0,]),this.alignedProjMatrix=l,b=a.create(),a.scale(b,b,[this.width/2,-this.height/2,1,]),a.translate(b,b,[1,-1,0]),this.labelPlaneMatrix=b,b=a.create(),a.scale(b,b,[1,-1,1]),a.translate(b,b,[-1,-1,0]),a.scale(b,b,[2/this.width,2/this.height,1,]),this.glCoordMatrix=b,this.pixelMatrix=a.multiply$1(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},b=a.invert(new Float64Array(16),this.pixelMatrix),!b)throw Error("failed to invert matrix");this.pixelMatrixInverse=b,this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSize,f=this.cameraPixelsPerMeter,b=this._camera.position,g=1/this.height,d=[e,e,f];a.scale$2(d,d,g),a.scale$2(b,b,-1),a.multiply$2(b,b,d);const c=a.create();a.translate(c,c,b),a.scale(c,c,d),this.mercatorFogMatrix=c,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,f,g)}_computeCameraPosition(a){const e=(a=a||this.pixelsPerMeter)/this.pixelsPerMeter,b=this._camera.forward(),d=this.point,c=this._mercatorZfromZoom(this._cameraZoom?this._cameraZoom:this._zoom)*e-a/this.worldSize*this._centerAltitude;return[d.x/this.worldSize-b[0]*c,d.y/this.worldSize-b[1]*c,a/this.worldSize*this._centerAltitude-b[2]*c,]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(b){const e=this._maxCameraBoundsDistance()*Math.cos(this._pitch),c=b[2];let d=1;c>0&&(d=Math.min((e-this._camera.position[2])/c,1)),this._camera.position=a.scaleAndAdd([],this._camera.position,b,d),this._updateStateFromCamera()}_updateStateFromCamera(){const b=this._camera.position,e=this._camera.forward(),{pitch:c,bearing:f}=this._camera.getPitchBearing(),g=a.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._projectionScaler,h=this._mercatorZfromZoom(this._maxZoom)*Math.cos(a.degToRad(this._maxPitch)),d=Math.max((b[2]-g)/Math.cos(c),h),i=this._zoomFromMercatorZ(d);a.scaleAndAdd(b,b,e,d),this._pitch=a.clamp(c,a.degToRad(this.minPitch),a.degToRad(this.maxPitch)),this.angle=a.wrap(f,-Math.PI,Math.PI),this._setZoom(a.clamp(i,this._minZoom,this._maxZoom)),this._terrainEnabled()&&this._updateCameraOnTerrain(),this._center=this.coordinateLocation(new a.MercatorCoordinate(b[0],b[1],b[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(a){return Math.pow(2,a)*this.tileSize}_mercatorZfromZoom(a){return this.cameraToCenterDistance/this._worldSizeFromZoom(a)}_minimumHeightOverTerrain(){const a=Math.min((null!=this._cameraZoom?this._cameraZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(a)}_zoomFromMercatorZ(a){return this.scaleZoom(this.cameraToCenterDistance/(a*this.tileSize))}_terrainEnabled(){return!(!this._elevation|| !this.projection.supportsTerrain&&(a.warnOnce("Terrain is not yet supported with alternate projections. Use mercator to enable terrain."),1))}anyCornerOffEdge(b,c){const f=Math.min(b.x,c.x),g=Math.max(b.x,c.x),e=Math.min(b.y,c.y),h=Math.max(b.y,c.y);if(e<this.horizonLineFromTop(!1))return!0;if("mercator"!==this.projection.name)return!1;const j=[new a.pointGeometry(f,e),new a.pointGeometry(g,h),new a.pointGeometry(f,h),new a.pointGeometry(g,e),],k=this.renderWorldCopies?-3:0,l=this.renderWorldCopies?4:1;for(const m of j){const i=this.pointRayIntersection(m);if(i.t<0)return!0;const d=this.rayIntersectionCoordinate(i);if(d.x<k||d.y<0||d.x>l||d.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+a.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new a.pointGeometry(0,0),new a.pointGeometry(this.width,this.height))}zoomDeltaToMovement(c,d){const b=a.length(a.sub([],this._camera.position,c)),e=this._zoomFromMercatorZ(b)+d;return b-this._mercatorZfromZoom(e)}getCameraPoint(){const b=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new a.pointGeometry(0,b))}}function cu(a,b){let c=!1,d=null;const e=()=>{d=null,c&&(a(),d=setTimeout(e,b),c=!1)};return()=>(c=!0,d||e(),d)}const d={linearity:.3,easing:a.bezier(0,0,.3,1)},cv=a.extend({deceleration:2500,maxSpeed:1400},d),cw=a.extend({deceleration:20,maxSpeed:1400},d),cx=a.extend({deceleration:1e3,maxSpeed:360},d),cy=a.extend({deceleration:1e3,maxSpeed:90},d);function cz(a,b){(!a.duration||a.duration<b.duration)&&(a.duration=b.duration,a.easing=b.easing)}function cA(g,h,b){const{maxSpeed:c,linearity:d,deceleration:i}=b,e=a.clamp(g*d/(h/1e3),-c,c),f=Math.abs(e)/(i*d);return{easing:b.easing,duration:1e3*f,amount:e*(f/2)}}class cB extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(f,c,d,g={}){const e=b.mousePos(c.getCanvasContainer(),d),h=c.unproject(e);super(f,a.extend({point:e,lngLat:h,originalEvent:d},g)),this._defaultPrevented=!1,this.target=c}}class cC extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,f,c){const h="touchend"===e?c.changedTouches:c.touches,d=b.touchPos(f.getCanvasContainer(),h),i=d.map(a=>f.unproject(a)),g=d.reduce((a,b,d,c)=>a.add(b.div(c.length)),new a.pointGeometry(0,0));super(e,{points:d,point:g,lngLats:i,lngLat:f.unproject(g),originalEvent:c}),this._defaultPrevented=!1}}class cD extends a.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(a,c,b){super(a,{originalEvent:b}),this._defaultPrevented=!1}}class cE{constructor(a,b){this._map=a,this._clickTolerance=b.clickTolerance}reset(){delete this._mousedownPos}wheel(a){return this._firePreventable(new cD(a.type,this._map,a))}mousedown(a,b){return this._mousedownPos=b,this._firePreventable(new cB(a.type,this._map,a))}mouseup(a){this._map.fire(new cB(a.type,this._map,a))}preclick(c){const b=a.extend({},c);b.type="preclick",this._map.fire(new cB(b.type,this._map,b))}click(a,b){this._mousedownPos&&this._mousedownPos.dist(b)>=this._clickTolerance||(this.preclick(a),this._map.fire(new cB(a.type,this._map,a)))}dblclick(a){return this._firePreventable(new cB(a.type,this._map,a))}mouseover(a){this._map.fire(new cB(a.type,this._map,a))}mouseout(a){this._map.fire(new cB(a.type,this._map,a))}touchstart(a){return this._firePreventable(new cC(a.type,this._map,a))}touchmove(a){this._map.fire(new cC(a.type,this._map,a))}touchend(a){this._map.fire(new cC(a.type,this._map,a))}touchcancel(a){this._map.fire(new cC(a.type,this._map,a))}_firePreventable(a){if(this._map.fire(a),a.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cF{constructor(a){this._map=a}reset(){this._delayContextMenu=!1,delete this._contextMenuEvent}mousemove(a){this._map.fire(new cB(a.type,this._map,a))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new cB("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(a){this._delayContextMenu?this._contextMenuEvent=a:this._map.fire(new cB(a.type,this._map,a)),this._map.listens("contextmenu")&&a.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class cG{constructor(a,b){this._map=a,this._el=a.getCanvasContainer(),this._container=a.getContainer(),this._clickTolerance=b.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(a,c){this.isEnabled()&&a.shiftKey&&0===a.button&&(b.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(d,e){if(!this._active)return;const a=e;if(this._lastPos.equals(a)|| !this._box&&a.dist(this._startPos)<this._clickTolerance)return;const c=this._startPos;this._lastPos=a,this._box||(this._box=b.create("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",d));const f=Math.min(c.x,a.x),g=Math.max(c.x,a.x),h=Math.min(c.y,a.y),i=Math.max(c.y,a.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${f}px,${h}px)`,this._box.style.width=g-f+"px",this._box.style.height=i-h+"px")})}mouseupWindow(c,f){if(!this._active||0!==c.button)return;const d=this._startPos,e=f;if(this.reset(),b.suppressClick(),d.x!==e.x||d.y!==e.y)return this._map.fire(new a.Event("boxzoomend",{originalEvent:c})),{cameraAnimation:a=>a.fitScreenCoordinates(d,e,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",c)}keydown(a){this._active&&27===a.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",a))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),b.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(b,c){return this._map.fire(new a.Event(b,{originalEvent:c}))}}function cH(b,d){const c={};for(let a=0;a<b.length;a++)c[b[a].identifier]=d[a];return c}class cI{constructor(b){this.singleTap=new class{constructor(a){this.reset(),this.numTouches=a.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(d,c,b){(this.centroid||b.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=d.timeStamp),b.length===this.numTouches&&(this.centroid=function(b){const c=new a.pointGeometry(0,0);for(const d of b)c._add(d);return c.div(b.length)}(c),this.touches=cH(b,c)))}touchmove(g,c,d){if(this.aborted||!this.centroid)return;const e=cH(d,c);for(const a in this.touches){const f=this.touches[a],b=e[a];(!b||b.dist(f)>30)&&(this.aborted=!0)}}touchend(b,d,c){if((!this.centroid||b.timeStamp-this.startTime>500)&&(this.aborted=!0),0===c.length){const a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}(b),this.numTaps=b.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(a,b,c){this.singleTap.touchstart(a,b,c)}touchmove(a,b,c){this.singleTap.touchmove(a,b,c)}touchend(b,c,d){const a=this.singleTap.touchend(b,c,d);if(a){const e=b.timeStamp-this.lastTime<500,f=!this.lastTap||30>this.lastTap.dist(a);if(e&&f||this.reset(),this.count++,this.lastTime=b.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class cJ{constructor(){this._zoomIn=new cI({numTouches:1,numTaps:2}),this._zoomOut=new cI({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(a,b,c){this._zoomIn.touchstart(a,b,c),this._zoomOut.touchstart(a,b,c)}touchmove(a,b,c){this._zoomIn.touchmove(a,b,c),this._zoomOut.touchmove(a,b,c)}touchend(a,b,c){const d=this._zoomIn.touchend(a,b,c),e=this._zoomOut.touchend(a,b,c);return d?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()+1,around:b.unproject(d)},{originalEvent:a})}):e?(this._active=!0,a.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:b=>b.easeTo({duration:300,zoom:b.getZoom()-1,around:b.unproject(e)},{originalEvent:a})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const cK={0:1,2:2};class f{constructor(a){this.reset(),this._clickTolerance=a.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(a,b){return!1}_move(a,b){return{}}mousedown(a,d){if(this._lastPoint)return;const c=b.mouseButton(a);this._correctButton(a,c)&&(this._lastPoint=d,this._eventButton=c)}mousemoveWindow(c,a){const b=this._lastPoint;if(b){if(c.preventDefault(),function(a,c){const b=cK[c];return void 0===a.buttons||(a.buttons&b)!==b}(c,this._eventButton))this.reset();else if(this._moved||!(a.dist(b)<this._clickTolerance))return this._moved=!0,this._lastPoint=a,this._move(b,a)}}mouseupWindow(a){this._lastPoint&&b.mouseButton(a)===this._eventButton&&(this._moved&&b.suppressClick(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class cL extends f{mousedown(a,b){super.mousedown(a,b),this._lastPoint&&(this._active=!0)}_correctButton(a,b){return 0===b&&!a.ctrlKey}_move(b,a){return{around:a,panDelta:a.sub(b)}}}class cM extends f{_correctButton(b,a){return 0===a&&b.ctrlKey||2===a}_move(b,c){const a=.8*(c.x-b.x);if(a)return this._active=!0,{bearingDelta:a}}contextmenu(a){a.preventDefault()}}class cN extends f{_correctButton(b,a){return 0===a&&b.ctrlKey||2===a}_move(b,c){const a=-0.5*(c.y-b.y);if(a)return this._active=!0,{pitchDelta:a}}contextmenu(a){a.preventDefault()}}class cO{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._minTouches=1,this._clickTolerance=c.clickTolerance||1,this.reset(),a.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert",],this)}reset(){this._active=!1,this._touches={},this._sum=new a.pointGeometry(0,0)}touchstart(a,b,c){return this._calculateTransform(a,b,c)}touchmove(b,c,a){if(this._active&&!(a.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(1===a.length)return void this._showTouchPanBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return b.preventDefault(),this._calculateTransform(b,c,a)}}touchend(b,c,a){this._calculateTransform(b,c,a),this._active&&a.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(l,k,g){g.length>0&&(this._active=!0);const b=cH(g,k),h=new a.pointGeometry(0,0),d=new a.pointGeometry(0,0);let c=0;for(const e in b){const f=b[e],i=this._touches[e];i&&(h._add(f),d._add(f.sub(i)),c++,b[e]=f)}if(this._touches=b,c<this._minTouches||!d.mag())return;const j=d.div(c);return this._sum._add(j),this._sum.mag()<this._clickTolerance?void 0:{around:h.div(c),panDelta:j}}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=b.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 g{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}_start(a){}_move(a,b,c){return{}}touchstart(c,b,a){this._firstTwoTouches||a.length<2||(this._firstTwoTouches=[a[0].identifier,a[1].identifier,],this._start([b[0],b[1]]))}touchmove(c,d,e){if(!this._firstTwoTouches)return;c.preventDefault();const[f,g]=this._firstTwoTouches,a=cP(e,d,f),b=cP(e,d,g);if(!a||!b)return;const h=this._aroundCenter?null:a.add(b).div(2);return this._move([a,b],h,c)}touchend(h,a,c){if(!this._firstTwoTouches)return;const[d,e]=this._firstTwoTouches,f=cP(c,a,d),g=cP(c,a,e);f&&g||(this._active&&b.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(a){this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function cP(b,c,d){for(let a=0;a<b.length;a++)if(b[a].identifier===d)return c[a]}function cQ(a,b){return Math.log(a/b)/Math.LN2}class cR extends g{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(a){this._startDistance=this._distance=a[0].dist(a[1])}_move(a,b){const c=this._distance;if(this._distance=a[0].dist(a[1]),this._active||!(.1>Math.abs(cQ(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:cQ(this._distance,c),pinchAround:b}}}function cS(a,b){return 180*a.angleWith(b)/Math.PI}class cT extends g{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(a){this._startVector=this._vector=a[0].sub(a[1]),this._minDiameter=a[0].dist(a[1])}_move(a,b){const c=this._vector;if(this._vector=a[0].sub(a[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:cS(this._vector,c),pinchAround:b}}_isBelowThreshold(a){this._minDiameter=Math.min(this._minDiameter,a.mag());const b=25/(Math.PI*this._minDiameter)*360,c=cS(a,this._startVector);return Math.abs(c)<b}}function cU(a){return Math.abs(a.y)>Math.abs(a.x)}class cV extends g{constructor(a){super(),this._map=a}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}_start(a){this._lastPoints=a,cU(a[0].sub(a[1]))&&(this._valid=!1)}_move(a,e,b){const c=a[0].sub(this._lastPoints[0]),d=a[1].sub(this._lastPoints[1]);if(!(this._map._cooperativeGestures&&b.touches.length<3)&&(this._valid=this.gestureBeginsVertically(c,d,b.timeStamp),this._valid))return this._lastPoints=a,this._active=!0,{pitchDelta:-((c.y+d.y)/2*.5)}}gestureBeginsVertically(a,b,c){if(void 0!==this._valid)return this._valid;const d=a.mag()>=2,e=b.mag()>=2;if(!d&&!e)return;if(!d||!e)return void 0===this._firstMove&&(this._firstMove=c),c-this._firstMove<100&&void 0;const f=a.y>0==b.y>0;return cU(a)&&cU(b)&&f}}class cW{constructor(){const a={panStep:100,bearingStep:15,pitchStep:10};this._panStep=a.panStep,this._bearingStep=a.bearingStep,this._pitchStep=a.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(a){if(a.altKey||a.ctrlKey||a.metaKey)return;let d=0,b=0,c=0,e=0,f=0;switch(a.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:a.shiftKey?b=-1:(a.preventDefault(),e=-1);break;case 39:a.shiftKey?b=1:(a.preventDefault(),e=1);break;case 38:a.shiftKey?c=1:(a.preventDefault(),f=-1);break;case 40:a.shiftKey?c=-1:(a.preventDefault(),f=1);break;default:return}return this._rotationDisabled&&(b=0,c=0),{cameraAnimation:g=>{const h=g.getZoom();g.easeTo({duration:300,easeId:"keyboardHandler",easing:cX,zoom:d?Math.round(h)+d*(a.shiftKey?2:1):h,bearing:g.getBearing()+b*this._bearingStep,pitch:g.getPitch()+c*this._pitchStep,offset:[-e*this._panStep,-f*this._panStep,],center:g.getCenter()},{originalEvent:a})}}}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 cX(a){return a*(2-a)}const cY=4.000244140625;class cZ{constructor(b,c){this._map=b,this._el=b.getCanvasContainer(),this._handler=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,a.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert","_isFullscreen",],this)}setZoomRate(a){this._defaultZoomRate=a}setWheelZoomRate(a){this._wheelZoomRate=a}isEnabled(){return!!this._enabled}isActive(){return!!this._active|| void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(a){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!a&&"center"===a.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(b){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(b.ctrlKey||b.metaKey||this.isZooming()||this._isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let c=b.deltaMode===a.window.WheelEvent.DOM_DELTA_LINE?40*b.deltaY:b.deltaY;const d=a.exported.now(),e=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,0!==c&&c%cY==0?this._type="wheel":0!==c&&4>Math.abs(c)?this._type="trackpad":e>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,b)):this._type||(this._type=200>Math.abs(e*c)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),b.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=b,this._delta-=c,this._active||this._start(b)),b.preventDefault()}_onTimeout(a){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)}_start(a){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 c=b.mousePos(this._el,a);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:c,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const b=this._map.transform,c=()=>b._terrainEnabled()&&this._aroundCoord?b.computeZoomRelativeTo(this._aroundCoord):b.zoom;if(0!==this._delta){const k="wheel"===this._type&&Math.abs(this._delta)>cY?this._wheelZoomRate:this._defaultZoomRate;let d=2/(1+Math.exp(-Math.abs(this._delta*k)));this._delta<0&&0!==d&&(d=1/d);const l=c(),m=Math.pow(2,l),n="number"==typeof this._targetZoom?b.zoomScale(this._targetZoom):m;this._targetZoom=Math.min(b.maxZoom,Math.max(b.minZoom,b.scaleZoom(n*d))),"wheel"===this._type&&(this._startZoom=c(),this._easing=this._smoothOutEasing(200)),this._delta=0}const g="number"==typeof this._targetZoom?this._targetZoom:c(),h=this._startZoom,i=this._easing;let f,e=!1;if("wheel"===this._type&&h&&i){const j=Math.min((a.exported.now()-this._lastWheelEventTime)/200,1),o=i(j);f=a.number(h,g,o),j<1?this._frameId||(this._frameId=!0):e=!0}else f=g,e=!0;return this._active=!0,e&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!e,zoomDelta:f-c(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(g){let c=a.ease;if(this._prevEase){const b=this._prevEase,e=(a.exported.now()-b.start)/b.duration,f=b.easing(e+.01)-b.easing(e),d=.27/Math.sqrt(f*f+1e-4)*.01,h=Math.sqrt(.0729-d*d);c=a.bezier(d,h,.25,1)}return this._prevEase={start:a.exported.now(),duration:g,easing:c},c}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=b.create("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(a.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_isFullscreen(){return!!a.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 c${constructor(a,b){this._clickZoom=a,this._tapZoom=b}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 c_{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(a,b){return a.preventDefault(),{cameraAnimation(c){c.easeTo({duration:300,zoom:c.getZoom()+(a.shiftKey?-1:1),around:c.unproject(b)},{originalEvent:a})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c0{constructor(){this._tap=new cI({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(b,c,a){this._swipePoint||(this._tapTime&&b.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?a.length>0&&(this._swipePoint=c[0],this._swipeTouch=a[0].identifier):this._tap.touchstart(b,c,a))}touchmove(a,b,c){if(this._tapTime){if(this._swipePoint){if(c[0].identifier!==this._swipeTouch)return;const d=b[0],e=d.y-this._swipePoint.y;return this._swipePoint=d,a.preventDefault(),this._active=!0,{zoomDelta:e/128}}}else this._tap.touchmove(a,b,c)}touchend(a,c,b){this._tapTime?this._swipePoint&&0===b.length&&this.reset():this._tap.touchend(a,c,b)&&(this._tapTime=a.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class c1{constructor(a,b,c){this._el=a,this._mousePan=b,this._touchPan=c}enable(a){this._inertiaOptions=a||{},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 c2{constructor(a,b,c){this._pitchWithRotate=a.pitchWithRotate,this._mouseRotate=b,this._mousePitch=c}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 c3{constructor(a,b,c,d){this._el=a,this._touchZoom=b,this._touchRotate=c,this._tapDragZoom=d,this._rotationDisabled=!1,this._enabled=!0}enable(a){this._touchZoom.enable(a),this._rotationDisabled||this._touchRotate.enable(a),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 c4=a=>a.zoom||a.drag||a.pitch||a.rotate;class c5 extends a.Event{}function c6(a){return a.panDelta&&a.panDelta.mag()||a.zoomDelta||a.bearingDelta||a.pitchDelta}const c7="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class c8 extends a.Evented{constructor(b,c){super(),this._moving=!1,this._zooming=!1,this.transform=b,this._bearingSnap=c.bearingSnap,a.bindAll(["_renderFrameCallback"],this)}getCenter(){return new a.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(a,b){return this.jumpTo({center:a},b)}panBy(b,c,d){return b=a.pointGeometry.convert(b).mult(-1),this.panTo(this.transform.center,a.extend({offset:b},c),d)}panTo(b,c,d){return this.easeTo(a.extend({center:b},c),d)}getZoom(){return this.transform.zoom}setZoom(a,b){return this.jumpTo({zoom:a},b),this}zoomTo(b,c,d){return this.easeTo(a.extend({zoom:b},c),d)}zoomIn(a,b){return this.zoomTo(this.getZoom()+1,a,b),this}zoomOut(a,b){return this.zoomTo(this.getZoom()-1,a,b),this}getBearing(){return this.transform.bearing}setBearing(a,b){return this.jumpTo({bearing:a},b),this}getPadding(){return this.transform.padding}setPadding(a,b){return this.jumpTo({padding:a},b),this}rotateTo(b,c,d){return this.easeTo(a.extend({bearing:b},c),d)}resetNorth(b,c){return this.rotateTo(0,a.extend({duration:1e3},b),c),this}resetNorthPitch(b,c){return this.easeTo(a.extend({bearing:0,pitch:0,duration:1e3},b),c),this}snapToNorth(a,b){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(a,b):this}getPitch(){return this.transform.pitch}setPitch(a,b){return this.jumpTo({pitch:a},b),this}cameraForBounds(b,c){b=a.LngLatBounds.convert(b);const d=c&&c.bearing||0;return this._cameraForBoxAndBearing(b.getNorthWest(),b.getSouthEast(),d,c)}_extendCameraOptions(b){const d={top:0,bottom:0,right:0,left:0};if("number"==typeof(b=a.extend({padding:d,offset:[0,0],maxZoom:this.transform.maxZoom},b)).padding){const c=b.padding;b.padding={top:c,bottom:c,right:c,left:c}}return b.padding=a.extend(d,b.padding),b}_cameraForBoxAndBearing(n,o,d,p){const b=this._extendCameraOptions(p),c=this.transform,e=c.padding,h=c.project(a.LngLat.convert(n)),i=c.project(a.LngLat.convert(o)),f=h.rotate(-a.degToRad(d)),g=i.rotate(-a.degToRad(d)),q=new a.pointGeometry(Math.max(f.x,g.x),Math.max(f.y,g.y)),r=new a.pointGeometry(Math.min(f.x,g.x),Math.min(f.y,g.y)),j=q.sub(r),k=(c.width-(e.left+e.right+b.padding.left+b.padding.right))/j.x,l=(c.height-(e.top+e.bottom+b.padding.top+b.padding.bottom))/j.y;if(l<0||k<0)return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const m=Math.min(c.scaleZoom(c.scale*Math.min(k,l)),b.maxZoom),s="number"==typeof b.offset.x?new a.pointGeometry(b.offset.x,b.offset.y):a.pointGeometry.convert(b.offset),t=new a.pointGeometry((b.padding.left-b.padding.right)/2,(b.padding.top-b.padding.bottom)/2).rotate(d*Math.PI/180),u=s.add(t).mult(c.scale/c.zoomScale(m));return{center:c.unproject(h.add(i).div(2).sub(u)),zoom:m,bearing:d}}_cameraForBox(d,e,f,g,q){var k;const r=this._extendCameraOptions(q);f=f||0,g=g||0,d=a.LngLat.convert(d),e=a.LngLat.convert(e);const b=this.transform.clone();b.padding=r.padding;const l=this.getFreeCameraOptions(),m=new a.LngLat(.5*(d.lng+e.lng),.5*(d.lat+e.lat)),n=.5*(f+g);if(b._camera.position[2]<a.mercatorZfromAltitude(n,m.lat))return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.");l.lookAtPoint(m),b.setFreeCameraOptions(l);const h=a.MercatorCoordinate.fromLngLat(d),i=a.MercatorCoordinate.fromLngLat(e),s=b.pointRayIntersection(b.centerPoint,n),t=[(k=b.rayIntersectionCoordinate(s)).x,k.y,k.z,],o=b.screenPointToMercatorRay(b.centerPoint),u="globe"!==b.projection.name;let j,v=0;do{const p=Math.floor(b.zoom),c=1<<p,w=Math.min(c*h.x,c*i.x),x=Math.min(c*h.y,c*i.y),y=Math.max(c*h.x,c*i.x),z=Math.max(c*h.y,c*i.y),A=new a.Aabb([w,x,f],[y,z,g]),B=a.Frustum.fromInvProjectionMatrix(b.invProjMatrix,b.worldSize,p,u);if(2!==A.intersects(B)){j&&(b._camera.position=a.scaleAndAdd([],b._camera.position,o.dir,-j),b._updateStateFromCamera());break}const C=a.sub([],b._camera.position,t);j=.5*a.length(C),b._camera.position=a.scaleAndAdd([],b._camera.position,o.dir,j);try{b._updateStateFromCamera()}catch(D){return void a.warnOnce("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}}while(++v<10)return{center:b.center,zoom:b.zoom,bearing:b.bearing,pitch:b.pitch}}fitBounds(b,a,c){return this._fitInternal(this.cameraForBounds(b,a),a,c)}_raycastElevationBox(k,l){const b=this.transform.elevation;if(!b)return;const m=new a.pointGeometry(k.x,l.y),n=new a.pointGeometry(l.x,k.y),c=b.pointCoordinate(k);if(!c)return;const d=b.pointCoordinate(l);if(!d)return;const e=b.pointCoordinate(m);if(!e)return;const f=b.pointCoordinate(n);if(!f)return;const g=new a.MercatorCoordinate(c[0],c[1]).toLngLat(),h=new a.MercatorCoordinate(d[0],d[1]).toLngLat(),i=new a.MercatorCoordinate(e[0],e[1]).toLngLat(),j=new a.MercatorCoordinate(f[0],f[1]).toLngLat(),o=Math.min(g.lng,Math.min(h.lng,Math.min(i.lng,j.lng))),p=Math.min(g.lat,Math.min(h.lat,Math.min(i.lat,j.lat))),q=Math.max(g.lng,Math.max(h.lng,Math.max(i.lng,j.lng))),r=Math.max(g.lat,Math.max(h.lat,Math.max(i.lat,j.lat))),s=Math.min(c[3],Math.min(d[3],Math.min(e[3],f[3]))),t=Math.max(c[3],Math.max(d[3],Math.max(e[3],f[3])));return{minLngLat:new a.LngLat(o,p),maxLngLat:new a.LngLat(q,r),minAltitude:s,maxAltitude:t}}fitScreenCoordinates(h,i,l,c,m){let d,e,j,k;const f=a.pointGeometry.convert(h),g=a.pointGeometry.convert(i),b=this._raycastElevationBox(f,g);if(b)d=b.minLngLat,e=b.maxLngLat,j=b.minAltitude,k=b.maxAltitude;else{if(this.transform.anyCornerOffEdge(f,g))return this;d=this.transform.pointLocation(f),e=this.transform.pointLocation(g)}return this._fitInternal(0===this.transform.pitch?this._cameraForBoxAndBearing(this.transform.pointLocation(a.pointGeometry.convert(h)),this.transform.pointLocation(a.pointGeometry.convert(i)),l,c):this._cameraForBox(d,e,j,k,c),c,m)}_fitInternal(c,b,d){return c?(delete(b=a.extend(c,b)).padding,b.linear?this.easeTo(b,d):this.flyTo(b,d)):this}jumpTo(b,c){this.stop();const d=b.preloadOnly?this.transform.clone():this.transform;let e=!1,f=!1,g=!1;return"zoom"in b&&d.zoom!== +b.zoom&&(e=!0,d.zoom=+b.zoom),void 0!==b.center&&(d.center=a.LngLat.convert(b.center)),"bearing"in b&&d.bearing!== +b.bearing&&(f=!0,d.bearing=+b.bearing),"pitch"in b&&d.pitch!== +b.pitch&&(g=!0,d.pitch=+b.pitch),null==b.padding||d.isPaddingEqual(b.padding)||(d.padding=b.padding),b.preloadOnly?(this._preloadTiles(d),this):(this.fire(new a.Event("movestart",c)).fire(new a.Event("move",c)),e&&this.fire(new a.Event("zoomstart",c)).fire(new a.Event("zoom",c)).fire(new a.Event("zoomend",c)),f&&this.fire(new a.Event("rotatestart",c)).fire(new a.Event("rotate",c)).fire(new a.Event("rotateend",c)),g&&this.fire(new a.Event("pitchstart",c)).fire(new a.Event("pitch",c)).fire(new a.Event("pitchend",c)),this.fire(new a.Event("moveend",c)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||a.warnOnce(c7),this.transform.getFreeCameraOptions()}setFreeCameraOptions(d,b){const c=this.transform;if(!c.projection.supportsFreeCamera)return void a.warnOnce(c7);this.stop();const e=c.zoom,f=c.pitch,g=c.bearing;c.setFreeCameraOptions(d);const h=e!==c.zoom,i=f!==c.pitch,j=g!==c.bearing;return this.fire(new a.Event("movestart",b)).fire(new a.Event("move",b)),h&&this.fire(new a.Event("zoomstart",b)).fire(new a.Event("zoom",b)).fire(new a.Event("zoomend",b)),j&&this.fire(new a.Event("rotatestart",b)).fire(new a.Event("rotate",b)).fire(new a.Event("rotateend",b)),i&&this.fire(new a.Event("pitchstart",b)).fire(new a.Event("pitch",b)).fire(new a.Event("pitchend",b)),this.fire(new a.Event("moveend",b)),this}easeTo(b,m){this._stop(!1,b.easeId),(!1===(b=a.extend({offset:[0,0],duration:500,easing:a.ease},b)).animate|| !b.essential&&a.exported.prefersReducedMotion)&&(b.duration=0);const c=this.transform,d=this.getZoom(),e=this.getBearing(),f=this.getPitch(),z=this.getPadding(),g="zoom"in b?+b.zoom:d,n="bearing"in b?this._normalizeBearing(b.bearing,e):e,o="pitch"in b?+b.pitch:f,p="padding"in b?b.padding:c.padding,q=a.pointGeometry.convert(b.offset);let h=c.centerPoint.add(q);const i="globe"===c.projection.name?c.pointCoordinate(h).toLngLat():c.pointLocation(h),j=a.LngLat.convert(b.center||i);this._normalizeCenter(j);const r=c.project(i),A=c.project(j).sub(r),B=c.zoomScale(g-d);let k,s;b.around&&(k=a.LngLat.convert(b.around),s=c.locationPoint(k));const t=this._zooming||g!==d,u=this._rotating||e!==n,v=this._pitching||o!==f,w=!c.isPaddingEqual(p),l=c=>i=>{if(t&&(c.zoom=a.number(d,g,i)),u&&(c.bearing=a.number(e,n,i)),v&&(c.pitch=a.number(f,o,i)),w&&(c.interpolatePadding(z,p,i),h=c.centerPoint.add(q)),k)c.setLocationAtPoint(k,s);else{const l=c.zoomScale(c.zoom-d),x=g>d?Math.min(2,B):Math.max(.5,B),y=Math.pow(x,1-i),j=c.unproject(r.add(A.mult(i*y)).mult(l));c.setLocationAtPoint(c.renderWorldCopies?j.wrap():j,h)}return b.preloadOnly||this._fireMoveEvents(m),c};if(b.preloadOnly){const x=this._emulate(l,b.duration,c);return this._preloadTiles(x),this}const y={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=t,this._rotating=u,this._pitching=v,this._padding=w,this._easeId=b.easeId,this._prepareEase(m,b.noMoveStart,y),this._ease(l(c),a=>{c.recenterOnTerrain(),this._afterEase(m,a)},b),this}_prepareEase(b,d,c={}){this._moving=!0,this.transform.cameraElevationReference="sea",d||c.moving||this.fire(new a.Event("movestart",b)),this._zooming&&!c.zooming&&this.fire(new a.Event("zoomstart",b)),this._rotating&&!c.rotating&&this.fire(new a.Event("rotatestart",b)),this._pitching&&!c.pitching&&this.fire(new a.Event("pitchstart",b))}_fireMoveEvents(b){this.fire(new a.Event("move",b)),this._zooming&&this.fire(new a.Event("zoom",b)),this._rotating&&this.fire(new a.Event("rotate",b)),this._pitching&&this.fire(new a.Event("pitch",b))}_afterEase(b,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId,this.transform.cameraElevationReference="ground";const d=this._zooming,e=this._rotating,f=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new a.Event("zoomend",b)),e&&this.fire(new a.Event("rotateend",b)),f&&this.fire(new a.Event("pitchend",b)),this.fire(new a.Event("moveend",b))}flyTo(b,g){if(!b.essential&&a.exported.prefersReducedMotion){const r=a.pick(b,["center","zoom","bearing","pitch","around",]);return this.jumpTo(r,g)}this.stop(),b=a.extend({offset:[0,0],speed:1.2,curve:1.42,easing:a.ease},b);const c=this.transform,f=this.getZoom(),h=this.getBearing(),k=this.getPitch(),J=this.getPadding(),l="zoom"in b?a.clamp(+b.zoom,c.minZoom,c.maxZoom):f,s="bearing"in b?this._normalizeBearing(b.bearing,h):h,t="pitch"in b?+b.pitch:k,u="padding"in b?b.padding:c.padding,v=c.zoomScale(l-f),w=a.pointGeometry.convert(b.offset);let x=c.centerPoint.add(w);const m=c.pointLocation(x),n=a.LngLat.convert(b.center||m);this._normalizeCenter(n);const y=c.project(m),z=c.project(n).sub(y);let d=b.curve;const e=Math.max(c.width,c.height),i=e/v,o=z.mag();if("minZoom"in b){const A=a.clamp(Math.min(b.minZoom,f,l),c.minZoom,c.maxZoom),B=e/c.zoomScale(A-f);d=Math.sqrt(B/o*2)}const K=d*d;function p(b){const a=(i*i-e*e+(b?-1:1)*K*K*o*o)/(2*(b?i:e)*K*o);return Math.log(Math.sqrt(a*a+1)-a)}function L(a){return(Math.exp(a)-Math.exp(-a))/2}function M(a){return(Math.exp(a)+Math.exp(-a))/2}const C=p(0);let D=function(a){return M(C)/M(C+d*a)},E=function(b){var a;return e*((M(C)*(L(a=C+d*b)/M(a))-L(C))/K)/o},j=(p(1)-C)/d;if(1e-6>Math.abs(o)||!isFinite(j)){if(1e-6>Math.abs(e-i))return this.easeTo(b,g);const N=i<e?-1:1;j=Math.abs(Math.log(i/e))/d,E=function(){return 0},D=function(a){return Math.exp(N*d*a)}}b.duration="duration"in b?+b.duration:1e3*j/("screenSpeed"in b?+b.screenSpeed/d:+b.speed),b.maxDuration&&b.duration>b.maxDuration&&(b.duration=0);const F=h!==s,G=t!==k,H=!c.isPaddingEqual(u),q=c=>d=>{const e=d*j,i=1/D(e);c.zoom=1===d?l:f+c.scaleZoom(i),F&&(c.bearing=a.number(h,s,d)),G&&(c.pitch=a.number(k,t,d)),H&&(c.interpolatePadding(J,u,d),x=c.centerPoint.add(w));const m=1===d?n:c.unproject(y.add(z.mult(E(e))).mult(i));return c.setLocationAtPoint(c.renderWorldCopies?m.wrap():m,x),c._updateCenterElevation(),b.preloadOnly||this._fireMoveEvents(g),c};if(b.preloadOnly){const I=this._emulate(q,b.duration,c);return this._preloadTiles(I),this}return this._zooming=!0,this._rotating=F,this._pitching=G,this._padding=H,this._prepareEase(g,!1),this._ease(q(c),()=>this._afterEase(g),b),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(b,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const d=this._onEaseEnd;delete this._onEaseEnd,d.call(this,c)}if(!b){const a=this.handlers;a&&a.stop(!1)}return this}_ease(c,d,b){!1===b.animate||0===b.duration?(c(1),d()):(this._easeStart=a.exported.now(),this._easeOptions=b,this._onEaseFrame=c,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const b=Math.min((a.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(b,c){b=a.wrap(b,-180,180);const d=Math.abs(b-c);return Math.abs(b-360-c)<d&&(b-=360),Math.abs(b+360-c)<d&&(b+=360),b}_normalizeCenter(b){const a=this.transform;if(!a.renderWorldCopies||a.maxBounds)return;const c=b.lng-a.center.lng;b.lng+=c>180?-360:c< -180?360:0}_emulate(d,e,f){const b=Math.ceil(15*e/1e3),c=[],g=d(f.clone());for(let a=0;a<=b;a++){const h=g(a/b);c.push(h.clone())}return c}}class y{constructor(b={}){this.options=b,a.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact",],this)}getDefaultPosition(){return"bottom-right"}onAdd(c){const a=this.options&&this.options.compact;return this._map=c,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=b.create("button","mapboxgl-ctrl-attrib-button",this._container),b.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=b.create("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),a&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===a&&(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(a,c){const b=this._map._getUIString(`AttributionControl.${c}`);a.setAttribute("aria-label",b),a.removeAttribute("title"),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}_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 b=this._editLink;b||(b=this._editLink=this._container.querySelector(".mapbox-improve-map"));const c=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||a.config.ACCESS_TOKEN},];if(b){const d=c.reduce((b,a,d)=>(a.value&&(b+=`${a.key}=${a.value}${d<c.length-1?"&":""}`),b),"?");b.href=`${a.config.FEEDBACK_URL}/${d}${this._map._hash?this._map._hash.getHashString(!0):""}`,b.rel="noopener nofollow",this._setElementTitle(b,"MapFeedback")}}_updateData(a){a&&("metadata"===a.sourceDataType||"visibility"===a.sourceDataType||"style"===a.dataType)&&(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let a=[];if(this._map.style.stylesheet){const d=this._map.style.stylesheet;this.styleOwner=d.owner,this.styleId=d.id}const e=this._map.style._sourceCaches;for(const g in e){const f=e[g];if(f.used){const b=f.getSource();b.attribution&&0>a.indexOf(b.attribution)&&a.push(b.attribution)}}a.sort((a,b)=>a.length-b.length),a=a.filter((c,d)=>{for(let b=d+1;b<a.length;b++)if(a[b].indexOf(c)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?a=[...this.options.customAttribution,...a,]:a.unshift(this.options.customAttribution));const c=a.join(" | ");c!==this._attribHTML&&(this._attribHTML=c,a.length?(this._innerContainer.innerHTML=c,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 c9{constructor(){a.bindAll(["_updateLogo"],this),a.bindAll(["_updateCompact"],this)}onAdd(c){this._map=c,this._container=b.create("div","mapboxgl-ctrl");const a=b.create("a","mapboxgl-ctrl-logo");return a.target="_blank",a.rel="noopener nofollow",a.href="https://www.mapbox.com/",a.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),a.setAttribute("rel","noopener nofollow"),this._container.appendChild(a),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(a){a&&"metadata"!==a.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const a=this._map.style._sourceCaches;if(0===Object.entries(a).length)return!0;for(const c in a){const b=a[c].getSource();if(b.hasOwnProperty("mapbox_logo")&&!b.mapbox_logo)return!1}return!0}_updateCompact(){const a=this._container.children;if(a.length){const b=a[0];this._map.getCanvasContainer().offsetWidth<250?b.classList.add("mapboxgl-compact"):b.classList.remove("mapboxgl-compact")}}}class da{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(b){const a=++this._id;return this._queue.push({callback:b,id:a,cancelled:!1}),a}remove(c){const a=this._currentlyRunning,d=a?this._queue.concat(a):this._queue;for(const b of d)if(b.id===c)return void(b.cancelled=!0)}run(b=0){const c=this._currentlyRunning=this._queue;for(const a of(this._queue=[],c))if(!a.cancelled&&(a.callback(b),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function db(b,d,c){if(b=new a.LngLat(b.lng,b.lat),d){const f=new a.LngLat(b.lng-360,b.lat),g=new a.LngLat(b.lng+360,b.lat),h=360*Math.ceil(Math.abs(b.lng-c.center.lng)/360),i=c.locationPoint(b).distSqr(d),j=d.x<0||d.y<0||d.x>c.width||d.y>c.height;c.locationPoint(f).distSqr(d)<i&&(j||Math.abs(f.lng-c.center.lng)<h)?b=f:c.locationPoint(g).distSqr(d)<i&&(j||Math.abs(g.lng-c.center.lng)<h)&&(b=g)}for(;Math.abs(b.lng-c.center.lng)>180;){const e=c.locationPoint(b);if(e.x>=0&&e.y>=0&&e.x<=c.width&&e.y<=c.height)break;b.lng>c.center.lng?b.lng-=360:b.lng+=360}return b}const dc={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class z extends a.Evented{constructor(c,e){if(super(),(c instanceof a.window.HTMLElement||e)&&(c=a.extend({element:c},e)),a.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer",],this),this._anchor=c&&c.anchor||"center",this._color=c&&c.color||"#3FB1CE",this._scale=c&&c.scale||1,this._draggable=c&&c.draggable||!1,this._clickTolerance=c&&c.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=c&&c.rotation||0,this._rotationAlignment=c&&c.rotationAlignment||"auto",this._pitchAlignment=c&&c.pitchAlignment&&"auto"!==c.pitchAlignment?c.pitchAlignment:this._rotationAlignment,this._updateMoving=()=>this._update(!0),c&&c.element)this._element=c.element,this._offset=a.pointGeometry.convert(c&&c.offset||[0,0]);else{this._defaultMarker=!0,this._element=b.create("div");const f=41,g=27,d=b.createSVG("svg",{display:"block",height:f*this._scale+"px",width:g*this._scale+"px",viewBox:`0 0 ${g} ${f}`},this._element),h=b.createSVG("radialGradient",{id:"shadowGradient"},b.createSVG("defs",{},d));b.createSVG("stop",{offset:"10%","stop-opacity":.4},h),b.createSVG("stop",{offset:"100%","stop-opacity":.05},h),b.createSVG("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},d),b.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"},d),b.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"},d),b.createSVG("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},d),this._offset=a.pointGeometry.convert(c&&c.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",a=>{a.preventDefault()}),this._element.addEventListener("mousedown",a=>{a.preventDefault()});const i=this._element.classList;for(const j in dc)i.remove(`mapboxgl-marker-anchor-${j}`);i.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(a){return a===this._map||(this.remove(),this._map=a,a.getCanvasContainer().appendChild(this._element),a.on("move",this._updateMoving),a.on("moveend",this._update),a.on("remove",this._clearFadeTimer),a._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(b){return this._lngLat=a.LngLat.convert(b),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(c){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")),c){if(!("offset"in c.options)){const b=38.1,a=13.5,d=Math.sqrt(Math.pow(a,2)/2);c.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-b],"bottom-left":[d,-1*(b-a+d),],"bottom-right":[-d,-1*(b-a+d),],left:[a,-1*(b-a)],right:[-a,-1*(b-a)]}:this._offset}this._popup=c,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(a){const b=a.code,c=a.charCode||a.keyCode;"Space"!==b&&"Enter"!==b&&32!==c&&13!==c||this.togglePopup()}_onMapClick(c){const a=c.originalEvent.target,b=this._element;this._popup&&(a===b||b.contains(a))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const a=this._popup;return a&&(a.isOpen()?(a.remove(),this._element.setAttribute("aria-expanded","false")):(a.addTo(this._map),this._element.setAttribute("aria-expanded","true"))),this}_evaluateOpacity(){const a=this._pos?this._pos.sub(this._transformedOffset()):null;if(!this._withinScreenBounds(a))return void this._clearFadeTimer();const b=this._map.unproject(a);let c=!1;if(this._map.transform._terrainEnabled()&&this._map.getTerrain()){const d=this._map.getFreeCameraOptions();if(d.position){const e=d.position.toLngLat();c=e.distanceTo(b)<.9*e.distanceTo(this._lngLat)}}const f=(1-this._map._queryFogOpacity(b))*(c?.2:1);this._element.style.opacity=`${f}`,this._popup&&this._popup._setOpacity(`${f}`),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_withinScreenBounds(a){const b=this._map.transform;return!!a&&a.x>=0&&a.x<b.width&&a.y>=0&&a.y<b.height}_updateDOM(){const b=this._pos||new a.pointGeometry(0,0),c=this._calculatePitch(),d=this._calculateRotation();this._element.style.transform=`${dc[this._anchor]} translate(${b.x}px, ${b.y}px) rotateX(${c}deg) rotateZ(${d}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(b){a.window.cancelAnimationFrame(this._updateFrameId),this._map&&(this._map.transform.renderWorldCopies&&(this._lngLat=db(this._lngLat,this._pos,this._map.transform)),this._pos=this._map.project(this._lngLat)._add(this._transformedOffset()),!0===b?this._updateFrameId=a.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 b=this._map.transform,a=this._offset.mult(this._scale);return"map"===this._rotationAlignment&&a._rotate(b.angle),"map"===this._pitchAlignment&&(a.y*=Math.cos(b._pitch)),a}getOffset(){return this._offset}setOffset(b){return this._offset=a.pointGeometry.convert(b),this._update(),this}_onMove(b){if(!this._isDragging){const c=this._clickTolerance||this._map._clickTolerance;this._isDragging=b.point.dist(this._pointerdownPos)>=c}this._isDragging&&(this._pos=b.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 a.Event("dragstart"))),this.fire(new a.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 a.Event("dragend")),this._state="inactive"}_addDragHandler(a){this._element.contains(a.originalEvent.target)&&(a.preventDefault(),this._positionDelta=a.point.sub(this._pos).add(this._transformedOffset()),this._pointerdownPos=a.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(a){return this._draggable=!!a,this._map&&(a?(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(a){return this._rotation=a||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(a){return this._rotationAlignment=a||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(a){return this._pitchAlignment=a&&"auto"!==a?a:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}}const{HTMLImageElement:dd,HTMLElement:de,ImageBitmap:df}=a.window;function dg(a){a.parentNode&&a.parentNode.removeChild(a)}class dh{constructor(c,b,d=!1){this._clickTolerance=10,this.element=b,this.mouseRotate=new cM({clickTolerance:c.dragRotate._mouseRotate._clickTolerance}),this.map=c,d&&(this.mousePitch=new cN({clickTolerance:c.dragRotate._mousePitch._clickTolerance})),a.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset",],this),b.addEventListener("mousedown",this.mousedown),b.addEventListener("touchstart",this.touchstart,{passive:!1}),b.addEventListener("touchmove",this.touchmove),b.addEventListener("touchend",this.touchend),b.addEventListener("touchcancel",this.reset)}down(a,c){this.mouseRotate.mousedown(a,c),this.mousePitch&&this.mousePitch.mousedown(a,c),b.disableDrag()}move(d,e){const a=this.map,b=this.mouseRotate.mousemoveWindow(d,e);if(b&&b.bearingDelta&&a.setBearing(a.getBearing()+b.bearingDelta),this.mousePitch){const c=this.mousePitch.mousemoveWindow(d,e);c&&c.pitchDelta&&a.setPitch(a.getPitch()+c.pitchDelta)}}off(){const a=this.element;a.removeEventListener("mousedown",this.mousedown),a.removeEventListener("touchstart",this.touchstart,{passive:!1}),a.removeEventListener("touchmove",this.touchmove),a.removeEventListener("touchend",this.touchend),a.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){b.enableDrag(),a.window.removeEventListener("mousemove",this.mousemove),a.window.removeEventListener("mouseup",this.mouseup)}mousedown(c){this.down(a.extend({},c,{ctrlKey:!0,preventDefault:()=>c.preventDefault()}),b.mousePos(this.element,c)),a.window.addEventListener("mousemove",this.mousemove),a.window.addEventListener("mouseup",this.mouseup)}mousemove(a){this.move(a,b.mousePos(this.element,a))}mouseup(a){this.mouseRotate.mouseupWindow(a),this.mousePitch&&this.mousePitch.mouseupWindow(a),this.offTemp()}touchstart(a){1!==a.targetTouches.length?this.reset():(this._startPos=this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>a.preventDefault()},this._startPos))}touchmove(a){1!==a.targetTouches.length?this.reset():(this._lastPos=b.touchPos(this.element,a.targetTouches)[0],this.move({preventDefault:()=>a.preventDefault()},this._lastPos))}touchend(a){0===a.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()}}let di,dj=0,dk=!1;function dl(a,d,b){const c=b&&b.maxWidth||100,g=a._containerHeight/2,h=a.unproject([0,g]),i=a.unproject([c,g]),e=h.distanceTo(i);if(b&&"imperial"===b.unit){const f=3.2808*e;f>5280?dm(d,c,f/5280,a._getUIString("ScaleControl.Miles"),a):dm(d,c,f,a._getUIString("ScaleControl.Feet"),a)}else b&&"nautical"===b.unit?dm(d,c,e/1852,a._getUIString("ScaleControl.NauticalMiles"),a):e>=1e3?dm(d,c,e/1e3,a._getUIString("ScaleControl.Kilometers"),a):dm(d,c,e,a._getUIString("ScaleControl.Meters"),a)}function dm(d,e,a,f,b){const c=function(b){const c=Math.pow(10,`${Math.floor(b)}`.length-1);let a=b/c;return a=a>=10?10:a>=5?5:a>=3?3:a>=2?2:a>=1?1:function(a){const b=Math.pow(10,Math.ceil(-Math.log(a)/Math.LN10));return Math.round(a*b)/b}(a),c*a}(a),g=c/a;b._requestDomTask(()=>{d.style.width=e*g+"px",d.innerHTML=`${c} ${f}`})}const A={version:a.version,supported:l,setRTLTextPlugin:a.setRTLTextPlugin,getRTLTextPluginStatus:a.getRTLTextPluginStatus,Map:class extends c8{constructor(c){if(null!=(c=a.extend({},{center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,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},c)).minZoom&&null!=c.maxZoom&&c.minZoom>c.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=c.minPitch&&null!=c.maxPitch&&c.minPitch>c.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=c.minPitch&&c.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=c.maxPitch&&c.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(super(new ct(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),c),this._interactive=c.interactive,this._minTileCacheSize=c.minTileCacheSize,this._maxTileCacheSize=c.maxTileCacheSize,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._optimizeForTerrain=c.optimizeForTerrain,this._renderTaskQueue=new da,this._domRenderTaskQueue=new da,this._controls=[],this._markers=[],this._mapId=a.uniqueId(),this._locale=a.extend({},{"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 \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},c.locale),this._clickTolerance=c.clickTolerance,this._cooperativeGestures=c.cooperativeGestures,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevation=new class{constructor(a){this.jumpTo(a)}getValue(b){if(b<=this._startTime)return this._start;if(b>=this._endTime)return this._end;const c=a.easeCubicInOut((b-this._startTime)/(this._endTime-this._startTime));return this._start*(1-c)+this._end*c}isEasing(a){return a>=this._startTime&&a<=this._endTime}jumpTo(a){this._startTime=-1/0,this._endTime=-1/0,this._start=a,this._end=a}easeTo(b,a,c){this._start=this.getValue(a),this._end=b,this._startTime=a,this._endTime=a+c}}(0),this._requestManager=new a.RequestManager(c.transformRequest,c.accessToken,c.testMode),this._silenceAuthErrors=!!c.testMode,"string"==typeof c.container){if(this._container=a.window.document.getElementById(c.container),!this._container)throw Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof de))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(this._container.childNodes.length>0&&a.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."),c.maxBounds&&this.setMaxBounds(c.maxBounds),a.bindAll(["_onWindowOnline","_onWindowResize","_onMapScroll","_contextLost","_contextRestored",],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw 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!==a.window&&(a.window.addEventListener("online",this._onWindowOnline,!1),a.window.addEventListener("resize",this._onWindowResize,!1),a.window.addEventListener("orientationchange",this._onWindowResize,!1),a.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1)),this.handlers=new class{constructor(c,d){this._map=c,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new class{constructor(a){this._map=a,this.clear()}clear(){this._inertiaBuffer=[]}record(b){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:a.exported.now(),settings:b})}_drainInertiaBuffer(){const b=this._inertiaBuffer,c=a.exported.now();for(;b.length>0&&c-b[0].time>160;)b.shift()}_onMoveEnd(k){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const b={zoom:0,bearing:0,pitch:0,pan:new a.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:d}of this._inertiaBuffer)b.zoom+=d.zoomDelta||0,b.bearing+=d.bearingDelta||0,b.pitch+=d.pitchDelta||0,d.panDelta&&b.pan._add(d.panDelta),d.around&&(b.around=d.around),d.pinchAround&&(b.pinchAround=d.pinchAround);const e=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,c={};if(b.pan.mag()){const f=cA(b.pan.mag(),e,a.extend({},cv,k||{}));c.offset=b.pan.mult(f.amount/b.pan.mag()),c.center=this._map.transform.center,cz(c,f)}if(b.zoom){const g=cA(b.zoom,e,cw);c.zoom=this._map.transform.zoom+g.amount,cz(c,g)}if(b.bearing){const h=cA(b.bearing,e,cx);c.bearing=this._map.transform.bearing+a.clamp(h.amount,-179,179),cz(c,h)}if(b.pitch){const i=cA(b.pitch,e,cy);c.pitch=this._map.transform.pitch+i.amount,cz(c,i)}if(c.zoom||c.bearing){const j=void 0===b.pinchAround?b.around:b.pinchAround;c.around=j?this._map.unproject(j):this._map.getCenter()}return this.clear(),a.extend(c,{noMoveStart:!0})}}(c),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new class{constructor(){this.constants=[1,1,.01],this.radius=0}setup(c,d){const b=a.sub([],d,c);this.radius=a.length(b[2]<0?a.div([],b,this.constants):[b[0],b[1],0])}projectRay(c){a.div(c,c,this.constants),a.normalize(c,c),a.mul$1(c,c,this.constants);const b=a.scale$2([],c,this.radius);if(b[2]>0){const e=a.scale$2([],[0,0,1],a.dot(b,[0,0,1])),f=a.scale$2([],a.normalize([],[b[0],b[1],0]),this.radius),d=a.add([],b,a.scale$2([],a.sub([],a.add([],f,e),b),2));b[0]=d[0],b[1]=d[1]}return b}},this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(d),a.bindAll(["handleEvent","handleWindowEvent"],this);const b=this._el;for(const[e,f,g]of(this._listeners=[[b,"touchstart",{passive:!0},],[b,"touchmove",{passive:!1},],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[a.window.document,"mousemove",{capture:!0},],[a.window.document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1},],[b,"keyup",void 0],[b,"wheel",{passive:!1},],[b,"contextmenu",void 0],[a.window,"blur",void 0],],this._listeners))e.addEventListener(f,e===a.window.document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[b,c,d]of this._listeners)b.removeEventListener(c,b===a.window.document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(b){const a=this._map,d=a.getCanvasContainer();this._add("mapEvent",new cE(a,b));const n=a.boxZoom=new cG(a,b);this._add("boxZoom",n);const e=new cJ,f=new c_;a.doubleClickZoom=new c$(f,e),this._add("tapZoom",e),this._add("clickZoom",f);const g=new c0;this._add("tapDragZoom",g);const o=a.touchPitch=new cV(a);this._add("touchPitch",o);const h=new cM(b),i=new cN(b);a.dragRotate=new c2(b,h,i),this._add("mouseRotate",h,["mousePitch"]),this._add("mousePitch",i,["mouseRotate"]);const j=new cL(b),k=new cO(a,b);a.dragPan=new c1(d,j,k),this._add("mousePan",j),this._add("touchPan",k,["touchZoom","touchRotate",]);const l=new cT,m=new cR;a.touchZoomRotate=new c3(d,m,l,g),this._add("touchRotate",l,["touchPan","touchZoom",]),this._add("touchZoom",m,["touchPan","touchRotate",]),this._add("blockableMapEvent",new cF(a));const p=a.scrollZoom=new cZ(a,this);this._add("scrollZoom",p,["mousePan"]);const q=a.keyboard=new cW;for(const c of(this._add("keyboard",q),["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard",]))b.interactive&&b[c]&&a[c].enable(b[c])}_add(a,b,c){this._handlers.push({handlerName:a,handler:b,allowed:c}),this._handlersById[a]=b}stop(a){if(!this._updatingCamera){for(const{handler:b}of this._handlers)b.reset();this._inertia.clear(),this._fireEvents({},{},a),this._changes=[]}}isActive(){for(const{handler:a}of this._handlers)if(a.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(c4(this._eventsInProgress))||this.isZooming()}_blockedByActive(c,a,d){for(const b in c)if(b!==d&&(!a||0>a.indexOf(b)))return!0;return!1}handleWindowEvent(a){this.handleEvent(a,`${a.type}Window`)}_getMapTouches(c){const a=[];for(const b of c)this._el.contains(b.target)&&a.push(b);return a}handleEvent(a,j){this._updatingCamera=!0;const k="renderFrame"===a.type,l=k?void 0:a,d={needsRenderFrame:!1},m={},e={},g=a.touches?this._getMapTouches(a.touches):void 0,p=g?b.touchPos(this._el,g):k?void 0:b.mousePos(this._el,a);for(const{handlerName:h,handler:c,allowed:q}of this._handlers){if(!c.isEnabled())continue;let f;this._blockedByActive(e,q,h)?c.reset():c[j||a.type]&&(f=c[j||a.type](a,p,g),this.mergeHandlerResult(d,m,f,h,l),f&&f.needsRenderFrame&&this._triggerRenderFrame()),(f||c.isActive())&&(e[h]=c)}const i={};for(const n in this._previousActiveHandlers)e[n]||(i[n]=l);this._previousActiveHandlers=e,(Object.keys(i).length||c6(d))&&(this._changes.push([d,m,i]),this._triggerRenderFrame()),(Object.keys(e).length||c6(d))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:o}=d;o&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],o(this._map))}mergeHandlerResult(e,c,b,f,g){if(!b)return;a.extend(e,b);const d={handlerName:f,originalEvent:b.originalEvent||g};void 0!==b.zoomDelta&&(c.zoom=d),void 0!==b.panDelta&&(c.drag=d),void 0!==b.pitchDelta&&(c.pitch=d),void 0!==b.bearingDelta&&(c.rotate=d)}_applyChanges(){const c={},d={},e={};for(const[b,f,g]of this._changes)b.panDelta&&(c.panDelta=(c.panDelta||new a.pointGeometry(0,0))._add(b.panDelta)),b.zoomDelta&&(c.zoomDelta=(c.zoomDelta||0)+b.zoomDelta),b.bearingDelta&&(c.bearingDelta=(c.bearingDelta||0)+b.bearingDelta),b.pitchDelta&&(c.pitchDelta=(c.pitchDelta||0)+b.pitchDelta),void 0!==b.around&&(c.around=b.around),void 0!==b.aroundCoord&&(c.aroundCoord=b.aroundCoord),void 0!==b.pinchAround&&(c.pinchAround=b.pinchAround),b.noInertia&&(c.noInertia=b.noInertia),a.extend(d,f),a.extend(e,g);this._updateMapTransform(c,d,e),this._changes=[]}_updateMapTransform(d,f,k){const g=this._map,b=g.transform,l=a=>[a.x,a.y,a.z];if((b=>{const a=this._eventsInProgress.drag;return a&&!this._handlersById[a.handlerName].isActive()})()&&!c6(d)){const t=b.zoom;b.cameraElevationReference="sea",b.recenterOnTerrain(),b.cameraElevationReference="ground",t!==b.zoom&&this._map._update(!0)}if(!c6(d))return this._fireEvents(f,k,!0);let{panDelta:m,zoomDelta:h,bearingDelta:n,pitchDelta:o,around:c,aroundCoord:u,pinchAround:p}=d;void 0!==p&&(c=p),f.drag&&!this._eventsInProgress.drag&&c&&(this._dragOrigin=l(b.pointCoordinate3D(c)),this._trackingEllipsoid.setup(b._camera.position,this._dragOrigin)),b.cameraElevationReference="sea",g._stop(!0),c=c||g.transform.centerPoint,n&&(b.bearing+=n),o&&(b.pitch+=o),b._updateCameraState();const e=[0,0,0];if(m){const i=b.pointCoordinate(c),j=b.pointCoordinate(c.sub(m));i&&j&&(e[0]=j.x-i.x,e[1]=j.y-i.y)}const v=b.zoom,q=[0,0,0];if(h){const r=l(u||b.pointCoordinate3D(c)),s={dir:a.normalize([],a.sub([],r,b._camera.position))};if(s.dir[2]<0){const w=b.zoomDeltaToMovement(r,h);a.scale$2(q,s.dir,w)}}const x=a.add(e,e,q);b._translateCameraConstrained(x),h&&Math.abs(b.zoom-v)>1e-4&&b.recenterOnTerrain(),b.cameraElevationReference="ground",this._map._update(),d.noInertia||this._inertia.record(d),this._fireEvents(f,k,!0)}_fireEvents(b,p,q){const j=c4(this._eventsInProgress),c=c4(b),g={};for(const d in b){const{originalEvent:r}=b[d];this._eventsInProgress[d]||(g[`${d}start`]=r),this._eventsInProgress[d]=b[d]}for(const k in!j&&c&&this._fireEvent("movestart",c.originalEvent),g)this._fireEvent(k,g[k]);for(const l in c&&this._fireEvent("move",c.originalEvent),b){const{originalEvent:s}=b[l];this._fireEvent(l,s)}const h={};let e;for(const i in this._eventsInProgress){const{handlerName:m,originalEvent:t}=this._eventsInProgress[i];this._handlersById[m].isActive()||(delete this._eventsInProgress[i],e=p[m]||t,h[`${i}end`]=e)}for(const n in h)this._fireEvent(n,h[n]);const u=c4(this._eventsInProgress);if(q&&(j||c)&&!u){this._updatingCamera=!0;const f=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),o=a=>0!==a&& -this._bearingSnap<a&&a<this._bearingSnap;f?(o(f.bearing||this._map.getBearing())&&(f.bearing=0),this._map.easeTo(f,{originalEvent:e})):(this._map.fire(new a.Event("moveend",{originalEvent:e})),o(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(c,b){this._map.fire(new a.Event(c,b?{originalEvent:b}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(a=>{delete this._frameId,this.handleEvent(new c5("renderFrame",{timeStamp:a})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}(this,c),this._localFontFamily=c.localFontFamily,this._localIdeographFontFamily=c.localIdeographFontFamily,c.style&&this.setStyle(c.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),c.projection&&this.setProjection(c.projection),this._hash=c.hash&&new class{constructor(b){this._hashName=b&&encodeURIComponent(b),a.bindAll(["_getCurrentHash","_onHashChange","_updateHash",],this),this._updateHash=cu(this._updateHashUnthrottled.bind(this),300)}addTo(b){return this._map=b,a.window.addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return a.window.removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(k){const f=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,c=Math.pow(10,Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10)),g=Math.round(f.lng*c)/c,h=Math.round(f.lat*c)/c,i=this._map.getBearing(),e=this._map.getPitch();let b="";if(b+=k?`/${g}/${h}/${d}`:`${d}/${h}/${g}`,(i||e)&&(b+="/"+Math.round(10*i)/10),e&&(b+=`/${Math.round(e)}`),this._hashName){const l=this._hashName;let m=!1;const j=a.window.location.hash.slice(1).split("&").map(a=>{const c=a.split("=")[0];return c===l?(m=!0,`${c}=${b}`):a}).filter(a=>a);return m||j.push(`${l}=${b}`),`#${j.join("&")}`}return`#${b}`}_getCurrentHash(){const b=a.window.location.hash.replace("#","");if(this._hashName){let c;return b.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(c=a)}),(c&&c[1]||"").split("/")}return b.split("/")}_onHashChange(){const a=this._getCurrentHash();if(a.length>=3&&!a.some(a=>isNaN(a))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(a[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+a[2],+a[1]],zoom:+a[0],bearing:b,pitch:+(a[4]||0)}),!0}return!1}_updateHashUnthrottled(){const b=a.window.location.href.replace(/(#.+)?$/,this.getHashString());a.window.history.replaceState(a.window.history.state,null,b)}}("string"==typeof c.hash&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,a.extend({},c.fitBoundsOptions,{duration:0})))),this.resize(),c.attributionControl&&this.addControl(new y({customAttribution:c.customAttribution})),this._logoControl=new c9,this.addControl(this._logoControl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",b=>{this._update("style"===b.dataType),this.fire(new a.Event(`${b.dataType}data`,b))}),this.on("dataloading",b=>{this.fire(new a.Event(`${b.dataType}dataloading`,b))})}_getMapId(){return this._mapId}addControl(b,c){if(void 0===c&&(c=b.getDefaultPosition?b.getDefaultPosition():"top-right"),!b||!b.onAdd)return this.fire(new a.ErrorEvent(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const e=b.onAdd(this);this._controls.push(b);const d=this._controlPositions[c];return -1!==c.indexOf("bottom")?d.insertBefore(e,d.firstChild):d.appendChild(e),this}removeControl(b){if(!b||!b.onRemove)return this.fire(new a.ErrorEvent(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const c=this._controls.indexOf(b);return c> -1&&this._controls.splice(c,1),b.onRemove(this),this}hasControl(a){return this._controls.indexOf(a)> -1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(b){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 c=!this._moving;return c&&this.fire(new a.Event("movestart",b)).fire(new a.Event("move",b)),this.fire(new a.Event("resize",b)),c&&this.fire(new a.Event("moveend",b)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(b){return this.transform.setMaxBounds(a.LngLatBounds.convert(b)),this._update()}setMinZoom(b){if((b=null==b?-2:b)>= -2&&b<=this.transform.maxZoom)return this.transform.minZoom=b,this._update(),this.getZoom()<b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(b){if((b=null==b?22:b)>=this.transform.minZoom)return this.transform.maxZoom=b,this._update(),this.getZoom()>b?this.setZoom(b):this.fire(new a.Event("zoomstart")).fire(new a.Event("zoom")).fire(new a.Event("zoomend")),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(b){if((b=null==b?0:b)<0)throw Error("minPitch must be greater than or equal to 0");if(b>=0&&b<=this.transform.maxPitch)return this.transform.minPitch=b,this._update(),this.getPitch()<b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(b){if((b=null==b?85:b)>85)throw Error("maxPitch must be less than or equal to 85");if(b>=this.transform.minPitch)return this.transform.maxPitch=b,this._update(),this.getPitch()>b?this.setPitch(b):this.fire(new a.Event("pitchstart")).fire(new a.Event("pitch")).fire(new a.Event("pitchend")),this;throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(a){return this.transform.renderWorldCopies=a,this._update()}getProjection(){return this.transform.getProjection()}setProjection(a){return this._lazyInitEmptyStyle(),"string"==typeof a&&(a={name:a}),this._runtimeProjection=a,this.style.updateProjection(),this._transitionFromGlobe=!1,this}project(b){return this.transform.locationPoint3D(a.LngLat.convert(b))}unproject(b){return this.transform.pointLocation3D(a.pointGeometry.convert(b))}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(a,b,c){if("mouseenter"===a||"mouseover"===a){let h=!1;const d=d=>{const e=b.filter(a=>this.getLayer(a)),f=e.length?this.queryRenderedFeatures(d.point,{layers:e}):[];f.length?h||(h=!0,c.call(this,new cB(a,this,d.originalEvent,{features:f}))):h=!1},e=()=>{h=!1};return{layers:new Set(b),listener:c,delegates:{mousemove:d,mouseout:e}}}if("mouseleave"===a||"mouseout"===a){let i=!1;const f=d=>{const e=b.filter(a=>this.getLayer(a));(e.length?this.queryRenderedFeatures(d.point,{layers:e}):[]).length?i=!0:i&&(i=!1,c.call(this,new cB(a,this,d.originalEvent)))},g=b=>{i&&(i=!1,c.call(this,new cB(a,this,b.originalEvent)))};return{layers:new Set(b),listener:c,delegates:{mousemove:f,mouseout:g}}}return{layers:new Set(b),listener:c,delegates:{[a]:a=>{const d=b.filter(a=>this.getLayer(a)),e=d.length?this.queryRenderedFeatures(a.point,{layers:d}):[];e.length&&(a.features=e,c.call(this,a),delete a.features)}}}}on(a,b,d){if(void 0===d)return super.on(a,b);Array.isArray(b)||(b=[b]);const c=this._createDelegatedListener(a,b,d);for(const e in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[a]=this._delegatedListeners[a]||[],this._delegatedListeners[a].push(c),c.delegates)this.on(e,c.delegates[e]);return this}once(b,a,c){if(void 0===c)return super.once(b,a);Array.isArray(a)||(a=[a]);const d=this._createDelegatedListener(b,a,c);for(const e in d.delegates)this.once(e,d.delegates[e]);return this}off(b,a,d){if(void 0===d)return super.off(b,a);a=new Set(Array.isArray(a)?a:[a]);const e=(a,b)=>{if(a.size!==b.size)return!1;for(const c of a)if(!b.has(c))return!1;return!0},c=this._delegatedListeners?this._delegatedListeners[b]:void 0;return c&&(f=>{for(let b=0;b<f.length;b++){const c=f[b];if(c.listener===d&&e(c.layers,a)){for(const g in c.delegates)this.off(g,c.delegates[g]);return f.splice(b,1),this}}})(c),this}queryRenderedFeatures(b,c){return this.style?(void 0!==c|| void 0===b||b instanceof a.pointGeometry||Array.isArray(b)||(c=b,b=void 0),this.style.queryRenderedFeatures(b=b||[[0,0],[this.transform.width,this.transform.height,],],c=c||{},this.transform)):[]}querySourceFeatures(a,b){return this.style.querySourceFeatures(a,b)}queryTerrainElevation(d,b){const c=this.transform.elevation;return c?(b=a.extend({},{exaggerated:!0},b),c.getAtPoint(a.MercatorCoordinate.fromLngLat(d),null,b.exaggerated)):null}setStyle(c,b){return!1!==(b=a.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},b)).diff&&b.localIdeographFontFamily===this._localIdeographFontFamily&&b.localFontFamily===this._localFontFamily&&this.style&&c?(this._diffStyle(c,b),this):(this._localIdeographFontFamily=b.localIdeographFontFamily,this._localFontFamily=b.localFontFamily,this._updateStyle(c,b))}_getUIString(a){const b=this._locale[a];if(null==b)throw Error(`Missing UI string '${a}'`);return b}_updateStyle(a,b){return this.style&&(this.style.setEventedParent(null),this.style._remove(),delete this.style),a&&(this.style=new c(this,b||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof a?this.style.loadURL(a):this.style.loadJSON(a)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new c(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(b,c){if("string"==typeof b){const d=this._requestManager.normalizeStyleURL(b),e=this._requestManager.transformRequest(d,a.ResourceType.Style);a.getJSON(e,(b,d)=>{b?this.fire(new a.ErrorEvent(b)):d&&this._updateDiff(d,c)})}else"object"==typeof b&&this._updateDiff(b,c)}_updateDiff(c,d){try{this.style.setState(c)&&this._update(!0)}catch(b){a.warnOnce(`Unable to perform style diff: ${b.message||b.error||b}. Rebuilding the style from scratch.`),this._updateStyle(c,d)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():a.warnOnce("There is no style added to the map.")}addSource(a,b){return this._lazyInitEmptyStyle(),this.style.addSource(a,b),this._update(!0)}isSourceLoaded(b){const c=this.style&&this.style._getSourceCaches(b);if(0!==c.length)return c.every(a=>a.loaded());this.fire(new a.ErrorEvent(Error(`There is no source with ID '${b}'`)))}areTilesLoaded(){const a=this.style&&this.style._sourceCaches;for(const d in a){const b=a[d]._tiles;for(const e in b){const c=b[e];if("loaded"!==c.state&&"errored"!==c.state)return!1}}return!0}addSourceType(a,b,c){return this._lazyInitEmptyStyle(),this.style.addSourceType(a,b,c)}removeSource(a){return this.style.removeSource(a),this._updateTerrain(),this._update(!0)}getSource(a){return this.style.getSource(a)}addImage(c,b,{pixelRatio:e=1,sdf:f=!1,stretchX:g,stretchY:h,content:i}={}){if(this._lazyInitEmptyStyle(),b instanceof dd||df&&b instanceof df){const{width:j,height:k,data:l}=a.exported.getImageData(b);this.style.addImage(c,{data:new a.RGBAImage({width:j,height:k},l),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0})}else{if(void 0===b.width|| void 0===b.height)return this.fire(new a.ErrorEvent(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:m,height:n,data:o}=b,d=b;this.style.addImage(c,{data:new a.RGBAImage({width:m,height:n},new Uint8Array(o)),pixelRatio:e,stretchX:g,stretchY:h,content:i,sdf:f,version:0,userImage:d}),d.onAdd&&d.onAdd(this,c)}}}updateImage(d,b){const c=this.style.getImage(d);if(!c)return this.fire(new a.ErrorEvent(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const g=b instanceof dd||df&&b instanceof df?a.exported.getImageData(b):b,{width:e,height:f,data:h}=g;return void 0===e|| void 0===f?this.fire(new a.ErrorEvent(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`"))):e!==c.data.width||f!==c.data.height?this.fire(new a.ErrorEvent(Error("The width and height of the updated image must be that same as the previous version of the image"))):(c.data.replace(h,!(b instanceof dd||df&&b instanceof df)),void this.style.updateImage(d,c))}hasImage(b){return b?!!this.style.getImage(b):(this.fire(new a.ErrorEvent(Error("Missing required image id"))),!1)}removeImage(a){this.style.removeImage(a)}loadImage(b,c){a.getImage(this._requestManager.transformRequest(b,a.ResourceType.Image),(d,b)=>{c(d,b instanceof dd?a.exported.getImageData(b):b)})}listImages(){return this.style.listImages()}addLayer(a,b){return this._lazyInitEmptyStyle(),this.style.addLayer(a,b),this._update(!0)}moveLayer(a,b){return this.style.moveLayer(a,b),this._update(!0)}removeLayer(a){return this.style.removeLayer(a),this._update(!0)}getLayer(a){return this.style.getLayer(a)}setLayerZoomRange(a,b,c){return this.style.setLayerZoomRange(a,b,c),this._update(!0)}setFilter(a,b,c={}){return this.style.setFilter(a,b,c),this._update(!0)}getFilter(a){return this.style.getFilter(a)}setPaintProperty(a,b,c,d={}){return this.style.setPaintProperty(a,b,c,d),this._update(!0)}getPaintProperty(a,b){return this.style.getPaintProperty(a,b)}setLayoutProperty(a,b,c,d={}){return this.style.setLayoutProperty(a,b,c,d),this._update(!0)}getLayoutProperty(a,b){return this.style.getLayoutProperty(a,b)}setLight(a,b={}){return this._lazyInitEmptyStyle(),this.style.setLight(a,b),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(a){return this._lazyInitEmptyStyle(),!a&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(a),this._averageElevationLastSampledAt=-1/0,this._update(!0)}_updateProjection(){"globe"===this.transform.projection.name&&this.transform.zoom>=a.GLOBE_ZOOM_THRESHOLD_MAX&&!this._transitionFromGlobe&&(this.setProjection({name:"mercator"}),this._transitionFromGlobe=!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(a){return this._lazyInitEmptyStyle(),this.style.setFog(a),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(b){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(a.LngLat.convert(b),this.transform):0}setFeatureState(a,b){return this.style.setFeatureState(a,b),this._update()}removeFeatureState(a,b){return this.style.removeFeatureState(a,b),this._update()}getFeatureState(a){return this.style.getFeatureState(a)}_updateContainerDimensions(){if(!this._container)return;const d=this._container.getBoundingClientRect().width||400,e=this._container.getBoundingClientRect().height||300;let b,c=this._container;for(;c&&!b;){const f=a.window.getComputedStyle(c).transform;f&&"none"!==f&&(b=f.match(/matrix.*\((.+)\)/)[1].split(", ")),c=c.parentElement}b?(this._containerWidth=b[0]&&"0"!==b[0]?Math.abs(d/b[0]):d,this._containerHeight=b[3]&&"0"!==b[3]?Math.abs(e/b[3]):e):(this._containerWidth=d,this._containerHeight=e)}_detectMissingCSS(){"rgb(250, 128, 114)"!==a.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&a.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 a=this._container;a.classList.add("mapboxgl-map"),(this._missingCSSCanary=b.create("div","mapboxgl-canary",a)).style.visibility="hidden",this._detectMissingCSS();const c=this._canvasContainer=b.create("div","mapboxgl-canvas-container",a);this._interactive&&c.classList.add("mapboxgl-interactive"),this._canvas=b.create("canvas","mapboxgl-canvas",c),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 d=this._controlContainer=b.create("div","mapboxgl-control-container",a),e=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right",].forEach(a=>{e[a]=b.create("div",`mapboxgl-ctrl-${a}`,d)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(b,c){const d=a.exported.devicePixelRatio||1;this._canvas.width=d*Math.ceil(b),this._canvas.height=d*Math.ceil(c),this._canvas.style.width=`${b}px`,this._canvas.style.height=`${c}px`}_addMarker(a){this._markers.push(a)}_removeMarker(b){const a=this._markers.indexOf(b);-1!==a&&this._markers.splice(a,1)}_setupPainter(){const c=a.extend({},l.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),b=this._canvas.getContext("webgl",c)||this._canvas.getContext("experimental-webgl",c);b?(a.storeAuthState(b,!0),this.painter=new cg(b,this.transform),this.on("data",a=>{"source"===a.dataType&&this.painter.setTileLoadedFlag(!0)}),a.exported$1.testSupport(b)):this.fire(new a.ErrorEvent(Error("Failed to initialize WebGL")))}_contextLost(b){b.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new a.Event("webglcontextlost",{originalEvent:b}))}_contextRestored(b){this._setupPainter(),this.resize(),this._update(),this.fire(new a.Event("webglcontextrestored",{originalEvent:b}))}_onMapScroll(a){if(a.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(a){return this.style&&(this._styleDirty=this._styleDirty||a,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(a){return this._update(),this._renderTaskQueue.add(a)}_cancelRenderFrame(a){this._renderTaskQueue.remove(a)}_requestDomTask(a){!this.loaded()||this.loaded()&&!this.isMoving()?a():this._domRenderTaskQueue.add(a)}_render(h){let c;const b=this.painter.context.extTimerQuery,d=a.exported.now();this.listens("gpu-timing-frame")&&(c=b.createQueryEXT(),b.beginQueryEXT(b.TIME_ELAPSED_EXT,c));let e=this._updateAverageElevation(d);if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._domRenderTaskQueue.run(h),this._removed)return;this._updateProjection();let i=!1;const f=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const j=this.transform.zoom,o=this.transform.pitch,k=a.exported.now();this.style.zoomHistory.update(j,k);const l=new a.EvaluationParameters(j,{now:k,fadeDuration:f,pitch:o,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),g=l.crossFadingFactor();1===g&&g===this._crossFadingFactor||(i=!0,this._crossFadingFactor=g),this.style.update(l)}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,f,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:f,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),speedIndexTiming:this.speedIndexTiming}),this.fire(new a.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new a.Event("load"))),this.style&&(this.style.hasTransitions()||i)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),this.listens("gpu-timing-frame")){const q=a.exported.now()-d;b.endQueryEXT(b.TIME_ELAPSED_EXT,c),setTimeout(()=>{const d=b.getQueryObjectEXT(c,b.QUERY_RESULT_EXT)/1e6;b.deleteQueryEXT(c),this.fire(new a.Event("gpu-timing-frame",{cpuTime:q,gpuTime:d}))},50)}if(this.listens("gpu-timing-layer")){const r=this.painter.collectGpuTimers();setTimeout(()=>{const b=this.painter.queryGpuTimers(r);this.fire(new a.Event("gpu-timing-layer",{layerTimes:b}))},50)}const m=this._sourcesDirty||this._styleDirty||this._placementDirty||e;if(m||this._repaint)this.triggerRepaint();else{const n=!this.isMoving()&&this.loaded();if(n&&(e=this._updateAverageElevation(d,!0)),e)this.triggerRepaint();else if(this._triggerFrame(!1),n&&(this.fire(new a.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const p=this._calculateSpeedIndex();this.fire(new a.Event("speedindexcompleted",{speedIndex:p})),this.speedIndexTiming=!1}}return!this._loaded||this._fullyLoaded||m||(this._fullyLoaded=!0,this._authenticate()),this}_forceMarkerUpdate(){for(const a of this._markers)a._update()}_updateAverageElevation(b,e=!1){const c=a=>(this.transform.averageElevation=a,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&c(0);if((e||b-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(b)){const f=this.transform.averageElevation;let a=this.transform.sampleAverageElevation();isNaN(a)?a=0:this._averageElevationLastSampledAt=b;const d=Math.abs(f-a);if(d>1){if(this._isInitialLoad)return this._averageElevation.jumpTo(a),c(a);this._averageElevation.easeTo(a,b,300)}else if(d>1e-4)return this._averageElevation.jumpTo(a),c(a)}return!!this._averageElevation.isEasing(b)&&c(this._averageElevation.getValue(b))}_authenticate(){a.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,c=>{if(c&&(c.message===a.AUTH_ERR_MSG||401===c.status)){const b=this.painter.context.gl;a.storeAuthState(b,!1),this._logoControl instanceof c9&&this._logoControl._updateLogo(),b&&b.clear(b.DEPTH_BUFFER_BIT|b.COLOR_BUFFER_BIT|b.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new a.ErrorEvent(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/")))}}),a.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const d=this.painter.canvasCopy(),a=this.painter.getCanvasCopiesAndTimestamps();a.timeStamps.push(performance.now());const b=this.painter.context.gl,e=b.createFramebuffer();function c(c){b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,c,0);const a=new Uint8Array(b.drawingBufferWidth*b.drawingBufferHeight*4);return b.readPixels(0,0,b.drawingBufferWidth,b.drawingBufferHeight,b.RGBA,b.UNSIGNED_BYTE,a),a}return b.bindFramebuffer(b.FRAMEBUFFER,e),this._canvasPixelComparison(c(d),a.canvasCopies.map(c),a.timeStamps)}_canvasPixelComparison(b,f,e){let g=e[1]-e[0];const i=b.length/4;for(let c=0;c<f.length;c++){const d=f[c];let h=0;for(let a=0;a<d.length;a+=4)d[a]===b[a]&&d[a+1]===b[a+1]&&d[a+2]===b[a+2]&&d[a+3]===b[a+3]&&(h+=1);g+=(e[c+2]-e[c+1])*(1-h/i)}return g}remove(){for(const c of(this._hash&&this._hash.remove(),this._controls))c.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!==a.window&&(a.window.removeEventListener("resize",this._onWindowResize,!1),a.window.removeEventListener("orientationchange",this._onWindowResize,!1),a.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),a.window.removeEventListener("online",this._onWindowOnline,!1));const b=this.painter.context.gl.getExtension("WEBGL_lose_context");b&&b.loseContext(),dg(this._canvasContainer),dg(this._controlContainer),dg(this._missingCSSCanary),this._container.classList.remove("mapboxgl-map"),a.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new a.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(b){this._renderNextFrame=this._renderNextFrame||b,this.style&&!this._frame&&(this._frame=a.exported.frame(a=>{const b=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,b&&this._render(a)}))}_preloadTiles(c){const b=this.style&&Object.values(this.style._sourceCaches)||[];return a.asyncAll(b,(a,b)=>a._preloadTiles(c,b),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(a){this._trackResize&&this.resize({originalEvent:a})._update()}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(a){this._showTileBoundaries!==a&&(this._showTileBoundaries=a,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(a){this._showTerrainWireframe!==a&&(this._showTerrainWireframe=a,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(a){this._speedIndexTiming!==a&&(this._speedIndexTiming=a,this._update())}get showPadding(){return!!this._showPadding}set showPadding(a){this._showPadding!==a&&(this._showPadding=a,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(a){this._showCollisionBoxes!==a&&(this._showCollisionBoxes=a,a?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(a){this._showOverdrawInspector!==a&&(this._showOverdrawInspector=a,this._update())}get repaint(){return!!this._repaint}set repaint(a){this._repaint!==a&&(this._repaint=a,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(a){this._vertices=a,this._update()}_setCacheLimits(b,c){a.setCacheLimits(b,c)}get version(){return a.version}},NavigationControl:class{constructor(c){this.options=a.extend({},{showCompass:!0,showZoom:!0,visualizePitch:!1},c),this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",a=>a.preventDefault()),this.options.showZoom&&(a.bindAll(["_setButtonTitle","_updateZoomButtons",],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",a=>this._map.zoomIn({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden",!0),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",a=>this._map.zoomOut({},{originalEvent:a})),b.create("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden",!0)),this.options.showCompass&&(a.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",a=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:a}):this._map.resetNorth({},{originalEvent:a})}),this._compassIcon=b.create("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden",!0))}_updateZoomButtons(){const a=this._map.getZoom(),b=a===this._map.getMaxZoom(),c=a===this._map.getMinZoom();this._zoomInButton.disabled=b,this._zoomOutButton.disabled=c,this._zoomInButton.setAttribute("aria-disabled",b.toString()),this._zoomOutButton.setAttribute("aria-disabled",c.toString())}_rotateCompassArrow(){const a=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=a)})}onAdd(a){return this._map=a,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 dh(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(c,d){const a=b.create("button",c,this._container);return a.type="button",a.addEventListener("click",d),a}_setButtonTitle(a,c){const b=this._map._getUIString(`NavigationControl.${c}`);a.setAttribute("aria-label",b),a.firstElementChild&&a.firstElementChild.setAttribute("title",b)}},GeolocateControl:class extends a.Evented{constructor(b){super(),this.options=a.extend({},{positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},b),a.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation",],this),this._onDeviceOrientationListener=this._onDeviceOrientation.bind(this),this._updateMarkerRotationThrottled=cu(this._updateMarkerRotation,20)}onAdd(d){var c;return this._map=d,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),c=this._setupUI,void 0!==di?c(di):void 0!==a.window.navigator.permissions?a.window.navigator.permissions.query({name:"geolocation"}).then(a=>{c(di="denied"!==a.state)}):c(di=!!a.window.navigator.geolocation),this._container}onRemove(){void 0!==this._geolocationWatchID&&(a.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,dj=0,dk=!1}_isOutOfMapMaxBounds(c){const a=this._map.getMaxBounds(),b=c.coords;return a&&(b.longitude<a.getWest()||b.longitude>a.getEast()||b.latitude<a.getSouth()||b.latitude>a.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(b){if(this._map){if(this._isOutOfMapMaxBounds(b))return this._setErrorState(),this.fire(new a.Event("outofmaxbounds",b)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=b,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(b),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(b),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("geolocate",b)),this._finish()}}_updateCamera(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude),d=b.coords.accuracy,e=this._map.getBearing(),f=a.extend({bearing:e},this.options.fitBoundsOptions);this._map.fitBounds(c.toBounds(d),f,{geolocateSource:!0})}_updateMarker(b){if(b){const c=new a.LngLat(b.coords.longitude,b.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=b.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const a=this._map._containerHeight/2,c=this._map.unproject([0,a]),d=this._map.unproject([100,a]),e=c.distanceTo(d)/100,b=Math.ceil(2*this._accuracy/e);this._circleElement.style.width=`${b}px`,this._circleElement.style.height=`${b}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(b){if(this._map){if(this.options.trackUserLocation){if(1===b.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 c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===b.code&&dk)return;this._setErrorState()}}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new a.Event("error",b)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(this._container.addEventListener("contextmenu",a=>a.preventDefault()),this._geolocateButton=b.create("button","mapboxgl-ctrl-geolocate",this._container),b.create("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden",!0),this._geolocateButton.type="button",!1===e){a.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",c),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",c)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",d),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",d)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=b.create("div","mapboxgl-user-location"),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(b.create("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new z({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=b.create("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new z({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",b=>{b.geolocateSource||"ACTIVE_LOCK"!==this._watchState||b.originalEvent&&"resize"===b.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new a.Event("trackuserlocationend")))})}_onDeviceOrientation(a){this._userLocationDotMarker&&(a.webkitCompassHeading?this._heading=a.webkitCompassHeading:!0===a.absolute&&(this._heading=-1*a.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return a.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 a.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":dj--,dk=!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 a.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 a.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 b;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++dj>1?(b={maximumAge:6e5,timeout:0},dk=!0):(b=this.options.positionOptions,dk=!1),this._geolocationWatchID=a.window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,b),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else a.window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const b=()=>{a.window.addEventListener("ondeviceorientationabsolute"in a.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientationListener)};void 0!==a.window.DeviceMotionEvent&&"function"==typeof a.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(a=>{"granted"===a&&b()}).catch(console.error):b()}_clearWatch(){a.window.navigator.geolocation.clearWatch(this._geolocationWatchID),a.window.removeEventListener("deviceorientation",this._onDeviceOrientationListener),a.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:y,ScaleControl:class{constructor(b){this.options=a.extend({},{maxWidth:100,unit:"metric"},b),a.bindAll(["_onMove","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_onMove(){dl(this._map,this._container,this.options)}onAdd(a){return this._map=a,this._container=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-scale",a.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(a){this.options.unit=a,dl(this._map,this._container,this.options)}},FullscreenControl:class{constructor(b){this._fullscreen=!1,b&&b.container&&(b.container instanceof a.window.HTMLElement?this._container=b.container:a.warnOnce("Full screen control 'container' must be a DOM element.")),a.bindAll(["_onClickFullscreen","_changeIcon",],this),"onfullscreenchange"in a.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in a.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=b.create("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",a.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,a.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!a.window.document.fullscreenEnabled&&!a.window.document.webkitFullscreenEnabled)}_setupUI(){const c=this._fullscreenButton=b.create("button","mapboxgl-ctrl-fullscreen",this._controlContainer);b.create("span","mapboxgl-ctrl-icon",c).setAttribute("aria-hidden",!0),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),a.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const a=this._getTitle();this._fullscreenButton.setAttribute("aria-label",a),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",a)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(a.window.document.fullscreenElement||a.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()?a.window.document.exitFullscreen?a.window.document.exitFullscreen():a.window.document.webkitCancelFullScreen&&a.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends a.Evented{constructor(b){super(),this.options=a.extend(Object.create({closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"}),b),a.bindAll(["_update","_onClose","remove","_onMouseMove","_onMouseUp","_onDrag",],this),this._classList=new Set(b&&b.className?b.className.trim().split(/\s+/):[])}addTo(b){return this._map&&this.remove(),this._map=b,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 a.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 a.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(b){return this._lngLat=a.LngLat.convert(b),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(b){return this.setDOMContent(a.window.document.createTextNode(b))}setHTML(e){const b=a.window.document.createDocumentFragment(),c=a.window.document.createElement("body");let d;for(c.innerHTML=e;d=c.firstChild;)b.appendChild(d);return this.setDOMContent(b)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(a){return this.options.maxWidth=a,this._update(),this}setDOMContent(a){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=b.create("div","mapboxgl-popup-content",this._container);return this._content.appendChild(a),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(a){return this._classList.add(a),this._container&&this._updateClassList(),this}removeClassName(a){return this._classList.delete(a),this._container&&this._updateClassList(),this}setOffset(a){return this.options.offset=a,this._update(),this}toggleClassName(b){let a;return this._classList.delete(b)?a=!1:(this._classList.add(b),a=!0),this._container&&this._updateClassList(),a}_createCloseButton(){this.options.closeButton&&(this._closeButton=b.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="×",this._closeButton.addEventListener("click",this._onClose))}_onMouseUp(a){this._update(a.point)}_onMouseMove(a){this._update(a.point)}_onDrag(a){this._update(a.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const b=this._pos,c=this._container.offsetWidth,d=this._container.offsetHeight;let a;return a=b.y+e.bottom.y<d?["top"]:b.y>this._map.transform.height-d?["bottom"]:[],b.x<c/2?a.push("left"):b.x>this._map.transform.width-c/2&&a.push("right"),0===a.length?"bottom":a.join("-")}_updateClassList(){const a=[...this._classList];a.push("mapboxgl-popup"),this._anchor&&a.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&a.push("mapboxgl-popup-track-pointer"),this._container.className=a.join(" ")}_update(c){if(this._map&&(this._lngLat||this._trackPointer)&&this._content){if(this._container||(this._container=b.create("div","mapboxgl-popup",this._map.getContainer()),this._tip=b.create("div","mapboxgl-popup-tip",this._container),this._container.appendChild(this._content)),this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=db(this._lngLat,this._pos,this._map.transform)),!this._trackPointer||c){const e=this._pos=this._trackPointer&&c?c:this._map.project(this._lngLat),d=function(b){if(b||(b=new a.pointGeometry(0,0)),"number"==typeof b){const d=Math.round(Math.sqrt(.5*Math.pow(b,2)));return{center:new a.pointGeometry(0,0),top:new a.pointGeometry(0,b),"top-left":new a.pointGeometry(d,d),"top-right":new a.pointGeometry(-d,d),bottom:new a.pointGeometry(0,-b),"bottom-left":new a.pointGeometry(d,-d),"bottom-right":new a.pointGeometry(-d,-d),left:new a.pointGeometry(b,0),right:new a.pointGeometry(-b,0)}}if(b instanceof a.pointGeometry||Array.isArray(b)){const c=a.pointGeometry.convert(b);return{center:c,top:c,"top-left":c,"top-right":c,bottom:c,"bottom-left":c,"bottom-right":c,left:c,right:c}}return{center:a.pointGeometry.convert(b.center||[0,0,]),top:a.pointGeometry.convert(b.top||[0,0]),"top-left":a.pointGeometry.convert(b["top-left"]||[0,0]),"top-right":a.pointGeometry.convert(b["top-right"]||[0,0]),bottom:a.pointGeometry.convert(b.bottom||[0,0,]),"bottom-left":a.pointGeometry.convert(b["bottom-left"]||[0,0]),"bottom-right":a.pointGeometry.convert(b["bottom-right"]||[0,0]),left:a.pointGeometry.convert(b.left||[0,0]),right:a.pointGeometry.convert(b.right||[0,0,])}}(this.options.offset),f=this._anchor=this._getAnchor(d),g=e.add(d[f]).round();this._map._requestDomTask(()=>{this._container&&f&&(this._container.style.transform=`${dc[f]} translate(${g.x}px,${g.y}px)`)})}this._updateClassList()}}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const a=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");a&&a.focus()}_onClose(){this.remove()}_setOpacity(a){this._content&&(this._content.style.opacity=a),this._tip&&(this._tip.style.opacity=a)}},Marker:z,Style:c,LngLat:a.LngLat,LngLatBounds:a.LngLatBounds,Point:a.pointGeometry,MercatorCoordinate:a.MercatorCoordinate,FreeCameraOptions:x,Evented:a.Evented,config:a.config,prewarm:function(){ao().acquire(am)},clearPrewarmedResources:function(){const a=an;a&&(a.isPreloaded()&&1===a.numActive()?(a.release(am),an=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return a.config.ACCESS_TOKEN},set accessToken(t){a.config.ACCESS_TOKEN=t},get baseApiUrl(){return a.config.API_URL},set baseApiUrl(t){a.config.API_URL=t},get workerCount(){return e.workerCount},set workerCount(e){e.workerCount=e},get maxParallelImageRequests(){return a.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){a.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(b){a.clearTileCache(b)},workerUrl:"",workerClass:null,setNow:a.exported.setNow,restoreNow:a.exported.restoreNow};return A}),b})}},])
|