=(t-a)*(s-o)&&(t-a)*(n-o)>=(r-a)*(e-o)&&(r-a)*(s-o)>=(i-a)*(n-o)}function Du(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&Lu(r,r.next,t,e))return !0;r=r.next;}while(r!==t);return !1}(t,e)&&(ju(t,e)&&ju(e,t)&&function(t,e){var r=t,n=!1,i=(t.x+e.x)/2,s=(t.y+e.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&i<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;}while(r!==t);return n}(t,e)&&(Vu(t.prev,t,e.prev)||Vu(t,e.prev,e))||Fu(t,e)&&Vu(t.prev,t,t.next)>0&&Vu(e.prev,e,e.next)>0)}function Vu(t,e,r){return (e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Fu(t,e){return t.x===e.x&&t.y===e.y}function Lu(t,e,r,n){var i=Uu(Vu(t,e,r)),s=Uu(Vu(t,e,n)),a=Uu(Vu(r,n,t)),o=Uu(Vu(r,n,e));return i!==s&&a!==o||!(0!==i||!Ru(t,r,e))||!(0!==s||!Ru(t,n,e))||!(0!==a||!Ru(r,t,n))||!(0!==o||!Ru(r,e,n))}function Ru(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Uu(t){return t>0?1:t<0?-1:0}function ju(t,e){return Vu(t.prev,t,t.next)<0?Vu(t,e,t.next)>=0&&Vu(t,t.prev,e)>=0:Vu(t,e,t.prev)<0||Vu(t,t.next,e)<0}function $u(t,e){var r=new Nu(t.i,t.x,t.y),n=new Nu(e.i,e.x,e.y),i=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=i,i.prev=r,n.next=r,r.prev=n,s.next=n,n.prev=s,n}function Ou(t,e,r,n){var i=new Nu(t,e,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function qu(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ);}function Nu(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1;}function Gu(t,e,r,n){for(var i=0,s=e,a=r-n;sr;){if(n-r>600){var s=n-r+1,a=e-r+1,o=Math.log(s),l=.5*Math.exp(2*o/3),u=.5*Math.sqrt(o*l*(s-l)/s)*(a-s/2<0?-1:1);Xu(t,e,Math.max(r,Math.floor(e-a*l/s+u)),Math.min(n,Math.floor(e+(s-a)*l/s+u)),i);}var c=t[e],h=r,p=n;for(Ku(t,r,e),i(t[n],c)>0&&Ku(t,r,n);h0;)p--;}0===i(t[r],c)?Ku(t,r,p):Ku(t,++p,n),p<=e&&(r=p+1),e<=p&&(n=p-1);}}function Ku(t,e,r){var n=t[e];t[e]=t[r],t[r]=n;}function Hu(t,e){return te?1:0}function Yu(t,e){const r=t.length;if(r<=1)return [t];const n=[];let i,s;for(let e=0;e1)for(let t=0;t0&&r.holes.push(n+=t[i-1].length);}return r},xu.default=vu;class tc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Qs,this.indexArray=new ya,this.indexArray2=new _a,this.programConfigurations=new co(t.layers,t.zoom),this.segments=new _o,this.segments2=new _o,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection;}populate(t,e,r,n){this.hasPattern=Ju(\"fill\",this.layers,e);const i=this.layers[0].layout.get(\"fill-sort-key\"),s=[];for(const{feature:a,id:o,index:l,sourceLayerIndex:u}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Go(a,t);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom),c,r))continue;const h=i?i.evaluate(c,{},r,e.availableImages):void 0,p={id:o,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:t?c.geometry:No(a,r,n),patterns:{},sortKey:h};s.push(p);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:i,index:s,sourceLayerIndex:a}=n;if(this.hasPattern){const t=Qu(\"fill\",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,{},e.availableImages);e.featureIndex.insert(t[s].feature,i,s,a,this.index);}}update(t,e,r,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r,n);}addFeatures(t,e,r,n,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,gu),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy());}addFeature(t,e,r,n,i,s=[]){for(const t of Yu(e,500)){let e=0;for(const r of t)e+=r.length;const r=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=r.vertexLength,i=[],s=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&s.push(i.length/2);const r=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=r.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),i.push(e[0].x),i.push(e[0].y);for(let t=1;t>3;}if(s--,1===n||2===n)a+=t.readSVarint(),o+=t.readSVarint(),1===n&&(e&&l.push(e),e=[]),e.push(new i(a,o));else {if(7!==n)throw new Error(\"unknown command \"+n);e&&e.push(e[0].clone());}}return e&&l.push(e),l},lc.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,r=1,n=0,i=0,s=0,a=1/0,o=-1/0,l=1/0,u=-1/0;t.pos>3;}if(n--,1===r||2===r)(i+=t.readSVarint())o&&(o=i),(s+=t.readSVarint())u&&(u=s);else if(7!==r)throw new Error(\"unknown command \"+r)}return [a,l,o,u]},lc.prototype.toGeoJSON=function(t,e,r){var n,i,s=this.extent*Math.pow(2,r),a=this.extent*t,o=this.extent*e,l=this.loadGeometry(),u=lc.types[this.type];function c(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null;}return e}(r));}function dc(t,e,r){if(3===t){var n=new hc(r,r.readVarint()+r.pos);n.length&&(e[n.name]=n);}}pc.prototype.feature=function(t){if(t<0||t>=this._features.length)throw new Error(\"feature index out of bounds\");this._pbf.pos=this._features[t];var e=this._pbf.readVarint()+this._pbf.pos;return new oc(this._pbf,e,this.extent,this._keys,this._values)};var yc={VectorTile:function(t,e){this.layers=t.readFields(dc,{},e);},VectorTileFeature:oc,VectorTileLayer:hc};function mc(t,e,r,n){const s=[],a=0===n?(t,e,r,n,s,a)=>{t.push(new i(a,r+(a-e)/(n-e)*(s-r)));}:(t,e,r,n,s,a)=>{t.push(new i(e+(a-r)/(s-r)*(n-e),a));};for(const i of t){const t=[];for(const s of i){if(s.length<=2)continue;const i=[];for(let t=0;te&&a(i,o,l,u,c,e):h>r?p=e&&a(i,o,l,u,c,e),p>r&&h<=r&&a(i,o,l,u,c,r);}let o=s[s.length-1];const l=0===n?o.x:o.y;l>=e&&l<=r&&i.push(o),i.length&&(o=i[i.length-1],i[0].x===o.x&&i[0].y===o.y||i.push(i[0]),t.push(i));}t.length&&s.push(t);}return s}const gc=yc.VectorTileFeature.types,xc=Math.pow(2,13);function vc(t,e,r,n,i,s,a,o){t.emplaceBack((e<<1)+a,(r<<1)+s,(Math.floor(n*xc)<<1)+i,Math.round(o));}function bc(t,e,r){const n=16384;t.emplaceBack(e.x,e.y,e.z,r[0]*n,r[1]*n,r[2]*n);}class _c{constructor(){this.acc=new i(0,0),this.polyCount=[];}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new i(t.x,t.y),this.max=new i(t.x,t.y));}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const r=this.min,n=this.max;t.xn.x&&(n.x=t.x),t.yn.y&&(n.y=t.y),((0===t.x||t.x===wo)&&t.x===e.x)!=((0===t.y||t.y===wo)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,xr(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>wo!=t.x>wo&&this.addBorderIntersection(1,xr(e.y,t.y,(wo-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,xr(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>wo!=t.y>wo&&this.addBorderIntersection(3,xr(e.x,t.x,(wo-e.y)/(t.y-e.y)));}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const r=this.borders[t];er[1]&&(r[1]=e);}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const r=0===t.x?0:1;this.addBorderIntersection(r,e.y),this.addBorderIntersection(r,t.y);}else {const r=0===t.y?2:3;this.addBorderIntersection(r,e.x),this.addBorderIntersection(r,t.x);}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new i(0,0)}span(){return new i(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class wc{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.layoutVertexArray=new ea,this.centroidVertexArray=new La,this.indexArray=new ya,this.programConfigurations=new co(t.layers,t.zoom),this.segments=new _o,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain;}populate(t,e,r,n){this.features=[],this.hasPattern=Ju(\"fill-extrusion\",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<=0;t--){const e=f[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=wo))||d.every((t=>t.y<=0))||d.every((t=>t.y>=wo)))&&f.splice(t,1);}var d;let y;if(c)y=Bc(f,l,n);else {y=[];for(const t of f)y.push({polygon:t,bounds:l});}const m=p?this.edgeRadius:0;for(const{polygon:t,bounds:e}of y){let r=0,i=0;for(const e of t)p&&!e[0].equals(e[e.length-1])&&e.push(e[0]),i+=p?e.length-1:e.length;const s=this.segments.prepareSegment((p?5:4)*i,this.layoutVertexArray,this.indexArray);if(p){const e=[],i=[];r=s.vertexLength;for(const r of t){let a,o;r.length&&r!==t[0]&&i.push(e.length/2),a=r[1].sub(r[0])._perp()._unit();for(let t=1;t4&&Mc(i[i.length-2],i[0],i[1]),f=m?Sc(i[i.length-2],i[0],i[1],m):0;a=i[1].sub(i[0])._perp()._unit();for(let d=1,y=0;d0?1:0,A=g.dist(x);if(y+A>32768&&(y=0),m){o=v.sub(x)._perp()._unit();let t=kc(g,x,v,Ac(a,o),m);isNaN(t)&&(t=0);const e=x.sub(g)._unit();g=g.add(e.mult(f))._round(),x=x.add(e.mult(-t))._round(),f=t,a=o;}const S=s.vertexLength,k=i.length>4&&Mc(g,x,v);let I=zc(y,l,!0);if(vc(this.layoutVertexArray,g.x,g.y,_,w,0,0,I),vc(this.layoutVertexArray,g.x,g.y,_,w,0,1,I),y+=A,I=zc(y,k,!1),l=k,vc(this.layoutVertexArray,x.x,x.y,_,w,0,0,I),vc(this.layoutVertexArray,x.x,x.y,_,w,0,1,I),s.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),s.primitiveLength+=2,m){const n=r+(1===d?i.length-2:d-2),a=1===d?r:n+1;if(this.indexArray.emplaceBack(S+1,n,S+3),this.indexArray.emplaceBack(n,a,S+3),s.primitiveLength+=2,void 0===t&&(t=S),!Ic(v,i[d],e)){const e=d===i.length-1?t:s.vertexLength;this.indexArray.emplaceBack(S+2,S+3,e),this.indexArray.emplaceBack(S+3,e+1,e),this.indexArray.emplaceBack(S+3,a,e+1),s.primitiveLength+=3;}}if(c){const t=this.layoutVertexExtArray,e=u.projectTilePoint(g.x,g.y,n),r=u.projectTilePoint(x.x,x.y,n),i=u.upVector(n,g.x,g.y),s=u.upVector(n,x.x,x.y);bc(t,e,i),bc(t,e,i),bc(t,r,s),bc(t,r,s);}}p&&(r+=i.length-1);}}if(h&&h.polyCount.length>0){if(h.borders){h.vertexArrayOffset=this.centroidVertexArray.length;const t=h.borders,e=this.featuresOnBorder.push(h)-1;for(let r=0;r<4;r++)t[r][0]!==Number.MAX_VALUE&&this.borders[r].push(e);}this.encodeCentroid(h.borders?void 0:h.centroid(),h);}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,s,a,n);}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,r)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[r].borders[t][0]));}encodeCentroid(t,e,r=!0){let n,i;if(t)if(0!==t.y){const r=e.span()._mult(this.tileToMeter);n=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(r.x/10)),i=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(r.y/10));}else n=Math.ceil(7*(t.x+450)),i=0;else n=0,i=+r;let s=r?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){r&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;er[1].x&&e.x>r[1].x||t.yr[1].y&&e.y>r[1].y}function Mc(t,e,r){if(t.x<0||t.x>=wo||e.x<0||e.x>=wo||r.x<0||r.x>=wo)return !1;const n=r.sub(e),i=n.perp(),s=t.sub(e);return (n.x*s.x+n.y*s.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(s.x*s.x+s.y*s.y))>-.866&&i.x*s.x+i.y*s.y<0}function zc(t,e,r){const n=e?2|t:-3&t;return r?1|n:-2&n}function Tc(){const t=Math.PI/32,e=Math.tan(t),r=So;return r*Math.sqrt(1+2*e*e)-r}function Bc(t,e,r){const n=1<{for(const r of t)o.push({polygon:r,bounds:e});},u=Math.ceil(Math.log2(r)),c=Math.ceil(Math.log2(n)),h=u-c,p=[];for(let t=0;t0?0:1);for(let t=0;te+1?d.push({polygons:f,bounds:t,depth:e+1}):l(f,t);}if(y.length){const t=[new i(0===r?h:n.x,1===r?h:n.y),o];p.length>e+1?d.push({polygons:y,bounds:t,depth:e+1}):l(y,t);}}return o}(t,e,Math.ceil((a-s)/11.25),Math.ceil((o-l)/11.25),1,((t,e,i)=>{if(0===t)return .5*(e+i);{const t=Co((r.y+e/wo)/n);return (To(.5*(Co((r.y+i/wo)/n)+t))*n-r.y)*wo}}))}Pi(wc,\"FillExtrusionBucket\",{omit:[\"layers\",\"features\"]}),Pi(_c,\"PartMetadata\");const Ec=new Zs({\"fill-extrusion-edge-radius\":new $s(Gt[\"layout_fill-extrusion\"][\"fill-extrusion-edge-radius\"])});var Cc={paint:new Zs({\"fill-extrusion-opacity\":new $s(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-opacity\"]),\"fill-extrusion-color\":new Os(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-color\"]),\"fill-extrusion-translate\":new $s(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-translate\"]),\"fill-extrusion-translate-anchor\":new $s(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-translate-anchor\"]),\"fill-extrusion-pattern\":new qs(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-pattern\"]),\"fill-extrusion-height\":new Os(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-height\"]),\"fill-extrusion-base\":new Os(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-base\"]),\"fill-extrusion-vertical-gradient\":new $s(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-vertical-gradient\"]),\"fill-extrusion-ambient-occlusion-intensity\":new $s(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-ambient-occlusion-intensity\"]),\"fill-extrusion-ambient-occlusion-radius\":new $s(Gt[\"paint_fill-extrusion\"][\"fill-extrusion-ambient-occlusion-radius\"])}),layout:Ec};function Pc(t,e,r){var n=2*Math.PI*6378137/256/Math.pow(2,r);return [t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Dc{constructor(t,e,r){this.z=t,this.x=e,this.y=r,this.key=Lc(0,t,t,e,r);}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const r=function(t,e,r){var n=Pc(256*t,256*(e=Math.pow(2,r)-e-1),r),i=Pc(256*(t+1),256*(e+1),r);return n[0]+\",\"+n[1]+\",\"+i[0]+\",\"+i[1]}(this.x,this.y,this.z),n=function(t,e,r){let n,i=\"\";for(let s=t;s>0;s--)n=1<this.canonical.z?new Fc(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Fc(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return Lc(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const r=this.canonical.z-t;return Lc(this.wrap*+e,t,t,this.canonical.x>>r,this.canonical.y>>r)}}isChildOf(t){if(t.wrap!==this.wrap)return !1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return [new Fc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return [new Fc(e,this.wrap,e,r,n),new Fc(e,this.wrap,e,r+1,n),new Fc(e,this.wrap,e,r,n+1),new Fc(e,this.wrap,e,r+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.yt.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={};})),this.layoutVertexArray=new ra,this.layoutVertexArray2=new na,this.indexArray=new ya,this.programConfigurations=new co(t.layers,t.zoom),this.segments=new _o,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id));}populate(t,e,r,n){this.hasPattern=Ju(\"line\",this.layers,e);const i=this.layers[0].layout.get(\"line-sort-key\"),s=[];for(const{feature:e,id:a,index:o,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,u=Go(e,t);if(!this.layers[0]._featureFilter.filter(new Cs(this.zoom),u,r))continue;const c=i?i.evaluate(u,{},r):void 0,h={id:a,properties:e.properties,type:e.type,sourceLayerIndex:l,index:o,geometry:t?u.geometry:No(e,r,n),patterns:{},sortKey:c};s.push(h);}i&&s.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:a,featureIndex:o}=e,l=this.addConstantDashes(a);for(const n of s){const{geometry:i,index:s,sourceLayerIndex:u}=n;if(l&&this.addFeatureDashes(n,a),this.hasPattern){const t=Qu(\"line\",this.layers,n,this.zoom,e);this.patternFeatures.push(t);}else this.addFeature(n,i,s,r,a.positions,e.availableImages);o.insert(t[s].feature,i,s,u,this.index);}}addConstantDashes(t){let e=!1;for(const r of this.layers){const n=r.paint.get(\"line-dasharray\").value,i=r.layout.get(\"line-cap\").value;if(\"constant\"!==n.kind||\"constant\"!==i.kind)e=!0;else {const e=i.value,r=n.value;if(!r)continue;t.addDash(r.from,e),t.addDash(r.to,e),r.other&&t.addDash(r.other,e);}}return e}addFeatureDashes(t,e){const r=this.zoom;for(const n of this.layers){const i=n.paint.get(\"line-dasharray\").value,s=n.layout.get(\"line-cap\").value;if(\"constant\"===i.kind&&\"constant\"===s.kind)continue;let a,o,l,u,c,h;if(\"constant\"===i.kind){const t=i.value;if(!t)continue;a=t.other||t.to,o=t.to,l=t.from;}else a=i.evaluate({zoom:r-1},t),o=i.evaluate({zoom:r},t),l=i.evaluate({zoom:r+1},t);\"constant\"===s.kind?u=c=h=s.value:(u=s.evaluate({zoom:r-1},t),c=s.evaluate({zoom:r},t),h=s.evaluate({zoom:r+1},t)),e.addDash(a,u),e.addDash(o,c),e.addDash(l,h);const p=e.getKey(a,u),f=e.getKey(o,c),d=e.getKey(l,h);t.patterns[n.id]={min:p,mid:f,max:d};}}update(t,e,r,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,r,n);}addFeatures(t,e,r,n,i){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,r,n);}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return !this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Gc)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,qc),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0;}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy());}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty(\"mapbox_clip_start\")&&t.properties.hasOwnProperty(\"mapbox_clip_end\"))return {start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,r,n,i,s){const a=this.layers[0].layout,o=a.get(\"line-join\").evaluate(t,{}),l=a.get(\"line-cap\").evaluate(t,{}),u=a.get(\"line-miter-limit\"),c=a.get(\"line-round-limit\");this.lineClips=this.lineFeatureClips(t);for(const r of e)this.addLine(r,t,o,l,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,r,i,s,n);}addLine(t,e,r,n,i,s){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[o-1].equals(t[o-2]);)o--;let l=0;for(;l0;if(_&&e>l){const t=h.dist(p);if(t>2*u){const e=h.sub(h.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,d,0,0,c),p=e;}}const A=p&&f;let S=A?r:a?\"butt\":n;if(A&&\"round\"===S&&(vi&&(S=\"bevel\"),\"bevel\"===S&&(v>2&&(S=\"flipbevel\"),v100)m=y.mult(-1);else {const t=v*d.add(y).mag()/d.sub(y).mag();m._perp()._mult(t*(w?-1:1));}this.addCurrentVertex(h,m,0,0,c),this.addCurrentVertex(h,m.mult(-1),0,0,c);}else if(\"bevel\"===S||\"fakeround\"===S){const t=-Math.sqrt(v*v-1),e=w?t:0,r=w?0:t;if(p&&this.addCurrentVertex(h,d,e,r,c),\"fakeround\"===S){const t=Math.round(180*b/Math.PI/20);for(let e=1;e2*u){const e=h.add(f.sub(h)._mult(u/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,y,0,0,c),h=e;}}}}addCurrentVertex(t,e,r,n,i,s=!1){const a=e.y*n-e.x,o=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*r,e.y-e.x*r,s,!1,r,i),this.addHalfVertex(t,a,o,s,!0,-n,i);}addHalfVertex({x:t,y:e},r,n,i,s,a,o){this.layoutVertexArray.emplaceBack((t<<1)+(i?1:0),(e<<1)+(s?1:0),Math.round(63*r)+128,Math.round(63*n)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=o.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),o.primitiveLength++),s?this.e2=l:this.e1=l;}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance;}else this.lineSoFar=this.distance;}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance();}}Pi(Kc,\"LineBucket\",{omit:[\"layers\",\"patternFeatures\"]});const Hc=new Zs({\"line-cap\":new Os(Gt.layout_line[\"line-cap\"]),\"line-join\":new Os(Gt.layout_line[\"line-join\"]),\"line-miter-limit\":new $s(Gt.layout_line[\"line-miter-limit\"]),\"line-round-limit\":new $s(Gt.layout_line[\"line-round-limit\"]),\"line-sort-key\":new Os(Gt.layout_line[\"line-sort-key\"])});var Yc={paint:new Zs({\"line-opacity\":new Os(Gt.paint_line[\"line-opacity\"]),\"line-color\":new Os(Gt.paint_line[\"line-color\"]),\"line-translate\":new $s(Gt.paint_line[\"line-translate\"]),\"line-translate-anchor\":new $s(Gt.paint_line[\"line-translate-anchor\"]),\"line-width\":new Os(Gt.paint_line[\"line-width\"]),\"line-gap-width\":new Os(Gt.paint_line[\"line-gap-width\"]),\"line-offset\":new Os(Gt.paint_line[\"line-offset\"]),\"line-blur\":new Os(Gt.paint_line[\"line-blur\"]),\"line-dasharray\":new qs(Gt.paint_line[\"line-dasharray\"]),\"line-pattern\":new qs(Gt.paint_line[\"line-pattern\"]),\"line-gradient\":new Gs(Gt.paint_line[\"line-gradient\"]),\"line-trim-offset\":new $s(Gt.paint_line[\"line-trim-offset\"])}),layout:Hc};const Wc=new class extends Os{possiblyEvaluate(t,e){return e=new Cs(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,r,n){return e=v({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,r,n)}}(Yc.paint.properties[\"line-width\"].specification);function Jc(t,e){return e>0?e+2*t:t}Wc.useIntegerZoom=!0;const Qc=Ws([{name:\"a_pos_offset\",components:4,type:\"Int16\"},{name:\"a_tex_size\",components:4,type:\"Uint16\"},{name:\"a_pixeloffset\",components:4,type:\"Int16\"}],4),th=Ws([{name:\"a_globe_anchor\",components:3,type:\"Int16\"},{name:\"a_globe_normal\",components:3,type:\"Float32\"}],4),eh=Ws([{name:\"a_projected_pos\",components:4,type:\"Float32\"}],4);Ws([{name:\"a_fade_opacity\",components:1,type:\"Uint32\"}],4);const rh=Ws([{name:\"a_placed\",components:2,type:\"Uint8\"},{name:\"a_shift\",components:2,type:\"Float32\"}]),nh=Ws([{name:\"a_size_scale\",components:1,type:\"Float32\"},{name:\"a_padding\",components:2,type:\"Float32\"}]);Ws([{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 ih=Ws([{name:\"a_pos\",components:3,type:\"Int16\"},{name:\"a_anchor_pos\",components:2,type:\"Int16\"},{name:\"a_extrude\",components:2,type:\"Int16\"}],4),sh=Ws([{name:\"a_pos_2f\",components:2,type:\"Float32\"},{name:\"a_radius\",components:1,type:\"Float32\"},{name:\"a_flags\",components:2,type:\"Int16\"}],4);Ws([{name:\"triangle\",components:3,type:\"Uint16\"}]),Ws([{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\"}]),Ws([{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\"}]),Ws([{type:\"Float32\",name:\"offsetX\"}]),Ws([{type:\"Int16\",name:\"x\"},{type:\"Int16\",name:\"y\"},{type:\"Int16\",name:\"tileUnitDistanceFromAnchor\"}]);var ah=24;const oh=128;function lh(t,e){const{expression:r}=e;if(\"constant\"===r.kind)return {kind:\"constant\",layoutSize:r.evaluate(new Cs(t+1))};if(\"source\"===r.kind)return {kind:\"source\"};{const{zoomStops:e,interpolationType:n}=r;let i=0;for(;i{t.text=function(t,e,r){const n=e.layout.get(\"text-transform\").evaluate(r,{});return \"uppercase\"===n?t=t.toLocaleUpperCase():\"lowercase\"===n&&(t=t.toLocaleLowerCase()),Es.applyArabicShaping&&(t=Es.applyArabicShaping(t)),t}(t.text,e,r);})),t}const fh={\"!\":\"︕\",\"#\":\"#\",$:\"$\",\"%\":\"%\",\"&\":\"&\",\"(\":\"︵\",\")\":\"︶\",\"*\":\"*\",\"+\":\"+\",\",\":\"︐\",\"-\":\"︲\",\".\":\"・\",\"/\":\"/\",\":\":\"︓\",\";\":\"︔\",\"<\":\"︿\",\"=\":\"=\",\">\":\"﹀\",\"?\":\"︖\",\"@\":\"@\",\"[\":\"﹇\",\"\\\\\":\"\\",\"]\":\"﹈\",\"^\":\"^\",_:\"︳\",\"`\":\"`\",\"{\":\"︷\",\"|\":\"―\",\"}\":\"︸\",\"~\":\"~\",\"¢\":\"¢\",\"£\":\"£\",\"¥\":\"¥\",\"¦\":\"¦\",\"¬\":\"¬\",\"¯\":\" ̄\",\"–\":\"︲\",\"—\":\"︱\",\"‘\":\"﹃\",\"’\":\"﹄\",\"“\":\"﹁\",\"”\":\"﹂\",\"…\":\"︙\",\"‧\":\"・\",\"₩\":\"₩\",\"、\":\"︑\",\"。\":\"︒\",\"〈\":\"︿\",\"〉\":\"﹀\",\"《\":\"︽\",\"》\":\"︾\",\"「\":\"﹁\",\"」\":\"﹂\",\"『\":\"﹃\",\"』\":\"﹄\",\"【\":\"︻\",\"】\":\"︼\",\"〔\":\"︹\",\"〕\":\"︺\",\"〖\":\"︗\",\"〗\":\"︘\",\"!\":\"︕\",\"(\":\"︵\",\")\":\"︶\",\",\":\"︐\",\"-\":\"︲\",\".\":\"・\",\":\":\"︓\",\";\":\"︔\",\"<\":\"︿\",\">\":\"﹀\",\"?\":\"︖\",\"[\":\"﹇\",\"]\":\"﹈\",\"_\":\"︳\",\"{\":\"︷\",\"|\":\"―\",\"}\":\"︸\",\"⦅\":\"︵\",\"⦆\":\"︶\",\"。\":\"︒\",\"「\":\"﹁\",\"」\":\"﹂\"};function dh(t){return \"︶\"===t||\"﹈\"===t||\"︸\"===t||\"﹄\"===t||\"﹂\"===t||\"︾\"===t||\"︼\"===t||\"︺\"===t||\"︘\"===t||\"﹀\"===t||\"︐\"===t||\"︓\"===t||\"︔\"===t||\"`\"===t||\" ̄\"===t||\"︑\"===t||\"︒\"===t}function yh(t){return \"︵\"===t||\"﹇\"===t||\"︷\"===t||\"﹃\"===t||\"﹁\"===t||\"︽\"===t||\"︻\"===t||\"︹\"===t||\"︗\"===t||\"︿\"===t}var mh=function(t,e,r,n,i){var s,a,o=8*i-n-1,l=(1<>1,c=-7,h=r?i-1:0,p=r?-1:1,f=t[e+h];for(h+=p,s=f&(1<<-c)-1,f>>=-c,c+=o;c>0;s=256*s+t[e+h],h+=p,c-=8);for(a=s&(1<<-c)-1,s>>=-c,c+=n;c>0;a=256*a+t[e+h],h+=p,c-=8);if(0===s)s=1-u;else {if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u;}return (f?-1:1)*a*Math.pow(2,s-n)},gh=function(t,e,r,n,i,s){var a,o,l,u=8*s-i-1,c=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),(e+=a+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(o=0,a=c):a+h>=1?(o=(e*l-1)*Math.pow(2,i),a+=h):(o=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+f]=255&o,f+=d,o/=256,i-=8);for(a=a<0;t[r+f]=255&a,f+=d,a/=256,u-=8);t[r+f-d]|=128*y;},xh=vh;function vh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length;}vh.Varint=0,vh.Fixed64=1,vh.Bytes=2,vh.Fixed32=5;var bh=4294967296,_h=1/bh,wh=\"undefined\"==typeof TextDecoder?null:new TextDecoder(\"utf8\");function Ah(t){return t.type===vh.Bytes?t.readVarint()+t.pos:t.pos+1}function Sh(t,e,r){return r?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function kh(t,e,r){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(n);for(var i=r.pos-1;i>=t;i--)r.buf[i+n]=r.buf[i];}function Ih(t,e){for(var r=0;r>>8,t[r+2]=e>>>16,t[r+3]=e>>>24;}function Lh(t,e){return (t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Rh(t,e,r){e.glyphs=[],1===t&&r.readMessage(Uh,e);}function Uh(t,e,r){if(3===t){const{id:t,bitmap:n,width:i,height:s,left:a,top:o,advance:l}=r.readMessage(jh,{});e.glyphs.push({id:t,bitmap:new hu({width:i+6,height:s+6},n),metrics:{width:i,height:s,left:a,top:o,advance:l}});}else 4===t?e.ascender=r.readSVarint():5===t&&(e.descender=r.readSVarint());}function jh(t,e,r){1===t?e.id=r.readVarint():2===t?e.bitmap=r.readBytes():3===t?e.width=r.readVarint():4===t?e.height=r.readVarint():5===t?e.left=r.readSVarint():6===t?e.top=r.readSVarint():7===t&&(e.advance=r.readVarint());}function $h(t){let e=0,r=0;for(const n of t)e+=n.w*n.h,r=Math.max(r,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let i=0,s=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const r=n[t];if(!(e.w>r.w||e.h>r.h)){if(e.x=r.x,e.y=r.y,s=Math.max(s,e.y+e.h),i=Math.max(i,e.x+e.w),e.w===r.w&&e.h===r.h){const e=n.pop();t>3,s=this.pos;this.type=7&n,t(i,e,this),this.pos===s&&this.skip(n);}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Vh(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Lh(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Vh(this.buf,this.pos)+Vh(this.buf,this.pos+4)*bh;return this.pos+=8,t},readSFixed64:function(){var t=Vh(this.buf,this.pos)+Lh(this.buf,this.pos+4)*bh;return this.pos+=8,t},readFloat:function(){var t=mh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=mh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,r,n=this.buf;return e=127&(r=n[this.pos++]),r<128?e:(e|=(127&(r=n[this.pos++]))<<7,r<128?e:(e|=(127&(r=n[this.pos++]))<<14,r<128?e:(e|=(127&(r=n[this.pos++]))<<21,r<128?e:function(t,e,r){var n,i,s=r.buf;if(n=(112&(i=s[r.pos++]))>>4,i<128)return Sh(t,n,e);if(n|=(127&(i=s[r.pos++]))<<3,i<128)return Sh(t,n,e);if(n|=(127&(i=s[r.pos++]))<<10,i<128)return Sh(t,n,e);if(n|=(127&(i=s[r.pos++]))<<17,i<128)return Sh(t,n,e);if(n|=(127&(i=s[r.pos++]))<<24,i<128)return Sh(t,n,e);if(n|=(1&(i=s[r.pos++]))<<31,i<128)return Sh(t,n,e);throw new Error(\"Expected varint not more than 10 bytes\")}(e|=(15&(r=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&wh?function(t,e,r){return wh.decode(t.subarray(e,r))}(this.buf,e,t):function(t,e,r){for(var n=\"\",i=e;i239?4:l>223?3:l>191?2:1;if(i+c>r)break;1===c?l<128&&(u=l):2===c?128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)<=127&&(u=null):3===c?(a=t[i+2],128==(192&(s=t[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&s)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=t[i+2],o=t[i+3],128==(192&(s=t[i+1]))&&128==(192&a)&&128==(192&o)&&((u=(15&l)<<18|(63&s)<<12|(63&a)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,n+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),n+=String.fromCharCode(u),i+=c;}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==vh.Bytes)return t.push(this.readVarint(e));var r=Ah(this);for(t=t||[];this.pos127;);else if(e===vh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===vh.Fixed32)this.pos+=4;else {if(e!==vh.Fixed64)throw new Error(\"Unimplemented type: \"+e);this.pos+=8;}},writeTag:function(t,e){this.writeVarint(t<<3|e);},realloc:function(t){for(var e=this.length||16;e268435455||t<0?function(t,e){var r,n;if(t>=0?(r=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(r=~(-t%4294967296))?r=r+1|0:(r=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error(\"Given varint doesn't fit into 10 bytes\");e.realloc(10),function(t,e,r){r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,t>>>=7,r.buf[r.pos++]=127&t|128,r.buf[r.pos]=127&(t>>>=7);}(r,0,e),function(t,e){var r=(7&t)<<4;e.buf[e.pos++]|=r|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))));}(n,e);}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))));},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t);},writeBoolean:function(t){this.writeVarint(Boolean(t));},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,r){for(var n,i,s=0;s55295&&n<57344){if(!i){n>56319||s+1===e.length?(t[r++]=239,t[r++]=191,t[r++]=189):i=n;continue}if(n<56320){t[r++]=239,t[r++]=191,t[r++]=189,i=n;continue}n=i-55296<<10|n-56320|65536,i=null;}else i&&(t[r++]=239,t[r++]=191,t[r++]=189,i=null);n<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:(n<65536?t[r++]=n>>12|224:(t[r++]=n>>18|240,t[r++]=n>>12&63|128),t[r++]=n>>6&63|128),t[r++]=63&n|128);}return r}(this.buf,t,this.pos);var r=this.pos-e;r>=128&&kh(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r;},writeFloat:function(t){this.realloc(4),gh(this.buf,t,this.pos,!0,23,4),this.pos+=4;},writeDouble:function(t){this.realloc(8),gh(this.buf,t,this.pos,!0,52,8),this.pos+=8;},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&kh(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n;},writeMessage:function(t,e,r){this.writeTag(t,vh.Bytes),this.writeRawMessage(e,r);},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,Ih,e);},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,Mh,e);},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,Bh,e);},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,zh,e);},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Th,e);},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Eh,e);},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Ch,e);},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Ph,e);},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Dh,e);},writeBytesField:function(t,e){this.writeTag(t,vh.Bytes),this.writeBytes(e);},writeFixed32Field:function(t,e){this.writeTag(t,vh.Fixed32),this.writeFixed32(e);},writeSFixed32Field:function(t,e){this.writeTag(t,vh.Fixed32),this.writeSFixed32(e);},writeFixed64Field:function(t,e){this.writeTag(t,vh.Fixed64),this.writeFixed64(e);},writeSFixed64Field:function(t,e){this.writeTag(t,vh.Fixed64),this.writeSFixed64(e);},writeVarintField:function(t,e){this.writeTag(t,vh.Varint),this.writeVarint(e);},writeSVarintField:function(t,e){this.writeTag(t,vh.Varint),this.writeSVarint(e);},writeStringField:function(t,e){this.writeTag(t,vh.Bytes),this.writeString(e);},writeFloatField:function(t,e){this.writeTag(t,vh.Fixed32),this.writeFloat(e);},writeDoubleField:function(t,e){this.writeTag(t,vh.Fixed64),this.writeDouble(e);},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e));}};class Oh{constructor(t,{pixelRatio:e,version:r,stretchX:n,stretchY:i,content:s}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=n,this.stretchY=i,this.content=s,this.version=r;}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 qh{constructor(t,e){const r={},n={};this.haveRenderCallbacks=[];const i=[];this.addImages(t,r,i),this.addImages(e,n,i);const{w:s,h:a}=$h(i),o=new pu({width:s||1,height:a||1});for(const e in t){const n=t[e],i=r[e].paddedRect;pu.copy(n.data,o,{x:0,y:0},{x:i.x+1,y:i.y+1},n.data);}for(const t in e){const r=e[t],i=n[t].paddedRect,s=i.x+1,a=i.y+1,l=r.data.width,u=r.data.height;pu.copy(r.data,o,{x:0,y:0},{x:s,y:a},r.data),pu.copy(r.data,o,{x:0,y:u-1},{x:s,y:a-1},{width:l,height:1}),pu.copy(r.data,o,{x:0,y:0},{x:s,y:a+u},{width:l,height:1}),pu.copy(r.data,o,{x:l-1,y:0},{x:s-1,y:a},{width:1,height:u}),pu.copy(r.data,o,{x:0,y:0},{x:s+l,y:a},{width:1,height:u});}this.image=o,this.iconPositions=r,this.patternPositions=n;}addImages(t,e,r){for(const n in t){const i=t[n],s={x:0,y:0,w:i.data.width+2,h:i.data.height+2};r.push(s),e[n]=new Oh(s,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(n);}}patchUpdatedImages(t,e){this.haveRenderCallbacks=this.haveRenderCallbacks.filter((e=>t.hasImage(e))),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const r in t.updatedImages)this.patchUpdatedImage(this.iconPositions[r],t.getImage(r),e),this.patchUpdatedImage(this.patternPositions[r],t.getImage(r),e);}patchUpdatedImage(t,e,r){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,i]=t.tl;r.update(e.data,void 0,{x:n,y:i});}}Pi(Oh,\"ImagePosition\"),Pi(qh,\"ImageAtlas\");const Nh={horizontal:1,vertical:2,horizontalOnly:3};class Gh{constructor(){this.scale=1,this.fontStack=\"\",this.imageName=null;}static forText(t,e){const r=new Gh;return r.scale=t||1,r.fontStack=e,r}static forImage(t){const e=new Gh;return e.imageName=t,e}}class Zh{constructor(){this.text=\"\",this.sectionIndex=[],this.sections=[],this.imageSectionID=null;}static fromFeature(t,e){const r=new Zh;for(let n=0;n=0&&r>=t&&Kh[this.text.charCodeAt(r)];r--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e);}substring(t,e){const r=new Zh;return r.text=this.text.substring(t,e),r.sectionIndex=this.sectionIndex.slice(t,e),r.sections=this.sections,r}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Gh.forText(t.scale,t.fontStack||e));const r=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Xh(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y){const m=Zh.fromFeature(t,i);let g;h===Nh.vertical&&m.verticalizePunctuation(p);const{processBidirectionalText:x,processStyledBidirectionalText:v}=Es;if(x&&1===m.sections.length){g=[];const t=x(m.toString(),ep(m,u,s,e,n,f,d));for(const e of t){const t=new Zh;t.text=e,t.sections=m.sections;for(let r=0;r0&&s>_&&(_=s);}else {const t=r[o.fontStack];if(!t)continue;t[y]&&(S=t[y]);const n=e[o.fontStack];if(!n)continue;const s=n.glyphs[y];if(!s)continue;if(v=s.metrics,I=8203!==y?ah:0,m){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,r=(t+e)*g;w=0;let c=0;for(let r=0;r-r/2;){if(a--,a<0)return !1;o-=t[a].dist(s),s=t[a];}o+=t[a].dist(t[a+1]),a++;const l=[];let u=0;for(;on;)u-=l.shift().angleDelta;if(u>i)return !1;a++,o+=e.dist(r);}return !0}function lp(t){let e=0;for(let r=0;ru){const c=(u-l)/s,h=xr(n.x,i.x,c),p=xr(n.y,i.y,c),f=new ap(h,p,0,i.angleTo(n),r);return !a||op(t,f,o,a,e)?f:void 0}l+=s;}}function pp(t,e,r,n,i,s,a,o,l){const u=up(n,s,a),c=cp(n,i),h=c*a,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&g=0&&x=0&&p+u<=c){const r=new ap(g,x,0,y,e);r._round(),n&&!op(t,r,s,n,i)||f.push(r);}}h+=d;}return o||f.length||a||(f=fp(t,h/2,r,n,i,s,a,!0,l)),f}function dp(t,e,r,n,s){const a=[];for(let o=0;o=n&&c.x>=n||(o.x>=n?o=new i(n,o.y+(n-o.x)/(c.x-o.x)*(c.y-o.y))._round():c.x>=n&&(c=new i(n,o.y+(n-o.x)/(c.x-o.x)*(c.y-o.y))._round()),o.y>=s&&c.y>=s||(o.y>=s?o=new i(o.x+(s-o.y)/(c.y-o.y)*(c.x-o.x),s)._round():c.y>=s&&(c=new i(o.x+(s-o.y)/(c.y-o.y)*(c.x-o.x),s)._round()),u&&o.equals(u[u.length-1])||(u=[o],a.push(u)),u.push(c)))));}}return a}Pi(ap,\"Anchor\");const yp=1e20;function mp(t,e,r,n,i,s,a,o,l){for(let u=e;u-1);l++,s[l]=o,a[l]=u,a[l+1]=yp;}for(let o=0,l=0;o{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=n.glyphs[e];if(void 0!==i)return void r(null,{stack:t,id:e,glyph:i});if(i=this._tinySDF(n,t,e),i)return n.glyphs[e]=i,void r(null,{stack:t,id:e,glyph:i});const s=Math.floor(e/256);if(256*s>65535)return void r(new Error(\"glyphs > 65535 not supported\"));if(n.ranges[s])return void r(null,{stack:t,id:e,glyph:i});let a=n.requests[s];a||(a=n.requests[s]=[],vp.loadGlyphRange(t,s,this.url,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[s]=!0;}for(const r of a)r(t,e);delete n.requests[s];}))),a.push(((n,i)=>{n?r(n):i&&r(null,{stack:t,id:e,glyph:i.glyphs[e]||null});}));}),((t,r)=>{if(t)e(t);else if(r){const t={};for(const{stack:e,id:n,glyph:i}of r)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[n]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t);}}));}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==xp.none&&(this.localGlyphMode===xp.all?!!this.localFontFamily:!!this.localFontFamily&&(es(t)||is(t)||Zi(t)||Xi(t)||Gi(t)))}_tinySDF(t,e,r){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(r))return;let i=t.tinySDF;if(!i){let r=\"400\";/bold/i.test(e)?r=\"900\":/medium/i.test(e)?r=\"500\":/light/i.test(e)&&(r=\"200\"),i=t.tinySDF=new vp.TinySDF({fontFamily:n,fontWeight:r,fontSize:48,buffer:6,radius:16}),i.fontWeight=r;}if(this.localGlyphs[i.fontWeight][r])return this.localGlyphs[i.fontWeight][r];const s=String.fromCharCode(r),{data:a,width:o,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:p,glyphAdvance:f}=i.draw(s);return this.localGlyphs[i.fontWeight][r]={id:r,bitmap:new hu({width:o,height:l},a),metrics:{width:u/2,height:c/2,left:h/2,top:p/2-27,advance:f/2,localGlyph:!0}}}}function bp(t,e,r,n){const s=[],a=t.image,o=a.pixelRatio,l=a.paddedRect.w-2,u=a.paddedRect.h-2,c=t.right-t.left,h=t.bottom-t.top,p=a.stretchX||[[0,l]],f=a.stretchY||[[0,u]],d=(t,e)=>t+e[1]-e[0],y=p.reduce(d,0),m=f.reduce(d,0),g=l-y,x=u-m;let v=0,b=y,_=0,w=m,A=0,S=g,k=0,I=x;if(a.content&&n){const t=a.content;v=_p(p,0,t[0]),_=_p(f,0,t[1]),b=_p(p,t[0],t[2]),w=_p(f,t[1],t[3]),A=t[0]-v,k=t[1]-_,S=t[2]-t[0]-b,I=t[3]-t[1]-w;}const M=(n,s,l,u)=>{const p=Ap(n.stretch-v,b,c,t.left),f=Sp(n.fixed-A,S,n.stretch,y),d=Ap(s.stretch-_,w,h,t.top),g=Sp(s.fixed-k,I,s.stretch,m),x=Ap(l.stretch-v,b,c,t.left),M=Sp(l.fixed-A,S,l.stretch,y),z=Ap(u.stretch-_,w,h,t.top),T=Sp(u.fixed-k,I,u.stretch,m),B=new i(p,d),E=new i(x,d),C=new i(x,z),P=new i(p,z),D=new i(f/o,g/o),V=new i(M/o,T/o),F=e*Math.PI/180;if(F){const t=Math.sin(F),e=Math.cos(F),r=[e,-t,t,e];B._matMult(r),E._matMult(r),P._matMult(r),C._matMult(r);}const L=n.stretch+n.fixed,R=s.stretch+s.fixed;return {tl:B,tr:E,bl:P,br:C,tex:{x:a.paddedRect.x+1+L,y:a.paddedRect.y+1+R,w:l.stretch+l.fixed-L,h:u.stretch+u.fixed-R},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:V,minFontScaleX:S/o/c,minFontScaleY:I/o/h,isSDF:r}};if(n&&(a.stretchX||a.stretchY)){const t=wp(p,g,y),e=wp(f,x,m);for(let r=0;r{if(t)i(t);else if(e){const t={},r=function(t){return new xh(t).readFields(Rh,{})}(e);for(const e of r.glyphs)t[e.id]=e;i(null,{glyphs:t,ascender:r.ascender,descender:r.descender});}}));},vp.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:r=8,cutoff:n=.25,fontFamily:i=\"sans-serif\",fontWeight:s=\"normal\",fontStyle:a=\"normal\"}={}){this.buffer=e,this.cutoff=n,this.radius=r;const o=this.size=t+4*e,l=this._createCanvas(o),u=this.ctx=l.getContext(\"2d\",{willReadFrequently:!0});u.font=`${a} ${s} ${t}px ${i}`,u.textBaseline=\"alphabetic\",u.textAlign=\"left\",u.fillStyle=\"black\",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o);}_createCanvas(t){const e=document.createElement(\"canvas\");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:r,actualBoundingBoxDescent:n,actualBoundingBoxLeft:i,actualBoundingBoxRight:s}=this.ctx.measureText(t),a=Math.ceil(r),o=Math.min(this.size-this.buffer,Math.ceil(s-i)),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=o+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),p=new Uint8ClampedArray(h),f={data:p,width:u,height:c,glyphWidth:o,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:e};if(0===o||0===l)return f;const{ctx:d,buffer:y,gridInner:m,gridOuter:g}=this;d.clearRect(y,y,o,l),d.fillText(t,y,y+a);const x=d.getImageData(y,y,o,l);g.fill(yp,0,h),m.fill(0,0,h);for(let t=0;t0?t*t:0,m[n]=t<0?t*t:0;}}mp(g,0,0,u,c,u,this.f,this.v,this.z),mp(m,y,y,o,l,u,this.f,this.v,this.z);for(let t=0;t0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t);}push(t){this.data.push(t),this.length++,this._up(this.length-1);}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:r}=this,n=e[t];for(;t>0;){const i=t-1>>1,s=e[i];if(r(n,s)>=0)break;e[t]=s,t=i;}e[t]=n;}_down(t){const{data:e,compare:r}=this,n=this.length>>1,i=e[t];for(;t=0)break;e[t]=s,t=n;}e[t]=i;}}function Mp(t,e){return te?1:0}function zp(t,e=1,r=!1){let n=1/0,s=1/0,a=-1/0,o=-1/0;const l=t[0];for(let t=0;ta)&&(a=e.x),(!t||e.y>o)&&(o=e.y);}const u=Math.min(a-n,o-s);let c=u/2;const h=new Ip([],Tp);if(0===u)return new i(n,s);for(let e=n;ep.d||!p.d)&&(p=n,r&&console.log(\"found best %d after %d probes\",Math.round(1e4*n.d)/1e4,f)),n.max-p.d<=e||(c=n.h/2,h.push(new Bp(n.p.x-c,n.p.y-c,c,t)),h.push(new Bp(n.p.x+c,n.p.y-c,c,t)),h.push(new Bp(n.p.x-c,n.p.y+c,c,t)),h.push(new Bp(n.p.x+c,n.p.y+c,c,t)),f+=4);}return r&&(console.log(`num probes: ${f}`),console.log(`best distance: ${p.d}`)),p.p}function Tp(t,e){return e.max-t.max}function Bp(t,e,r,n){this.p=new i(t,e),this.h=r,this.d=function(t,e){let r=!1,n=1/0;for(let i=0;it.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(r=!r),n=Math.min(n,rl(t,i,o));}}return (r?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2;}const Ep=Number.POSITIVE_INFINITY,Cp=Math.sqrt(2);function Pp(t,e){return e[1]!==Ep?function(t,e,r){let n=0,i=0;switch(e=Math.abs(e),r=Math.abs(r),t){case\"top-right\":case\"top-left\":case\"top\":i=r-7;break;case\"bottom-right\":case\"bottom-left\":case\"bottom\":i=7-r;}switch(t){case\"top-right\":case\"bottom-right\":case\"right\":n=-e;break;case\"top-left\":case\"bottom-left\":case\"left\":n=e;}return [n,i]}(t,e[0],e[1]):function(t,e){let r=0,n=0;e<0&&(e=0);const i=e/Cp;switch(t){case\"top-right\":case\"top-left\":n=i-7;break;case\"bottom-right\":case\"bottom-left\":n=7-i;break;case\"bottom\":n=7-e;break;case\"top\":n=e-7;}switch(t){case\"top-right\":case\"bottom-right\":r=-i;break;case\"top-left\":case\"bottom-left\":r=i;break;case\"left\":r=e;break;case\"right\":r=-e;}return [r,n]}(t,e[0])}function Dp(t,e,r,n,i,s,a,o,l,u){t.createArrays(),t.tilePixelRatio=wo/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const c=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if(\"composite\"===t.textSizeData.kind){const{minZoom:e,maxZoom:r}=t.textSizeData;p.compositeTextSizes=[h[\"text-size\"].possiblyEvaluate(new Cs(e),o),h[\"text-size\"].possiblyEvaluate(new Cs(r),o)];}if(\"composite\"===t.iconSizeData.kind){const{minZoom:e,maxZoom:r}=t.iconSizeData;p.compositeIconSizes=[h[\"icon-size\"].possiblyEvaluate(new Cs(e),o),h[\"icon-size\"].possiblyEvaluate(new Cs(r),o)];}p.layoutTextSize=h[\"text-size\"].possiblyEvaluate(new Cs(l+1),o),p.layoutIconSize=h[\"icon-size\"].possiblyEvaluate(new Cs(l+1),o),p.textMaxSize=h[\"text-size\"].possiblyEvaluate(new Cs(18),o);const f=\"map\"===c.get(\"text-rotation-alignment\")&&\"point\"!==c.get(\"symbol-placement\"),d=c.get(\"text-size\");for(const s of t.features){const l=c.get(\"text-font\").evaluate(s,{},o).join(\",\"),h=d.evaluate(s,{},o),y=p.layoutTextSize.evaluate(s,{},o),m=(p.layoutIconSize.evaluate(s,{},o),{horizontal:{},vertical:void 0}),g=s.text;let x,v=[0,0];if(g){const n=g.toString(),a=c.get(\"text-letter-spacing\").evaluate(s,{},o)*ah,u=c.get(\"text-line-height\").evaluate(s,{},o)*ah,p=fs(n)?a:0,d=c.get(\"text-anchor\").evaluate(s,{},o),x=c.get(\"text-variable-anchor\");if(!x){const t=c.get(\"text-radial-offset\").evaluate(s,{},o);v=t?Pp(d,[t*ah,Ep]):c.get(\"text-offset\").evaluate(s,{},o).map((t=>t*ah));}let b=f?\"center\":c.get(\"text-justify\").evaluate(s,{},o);const _=c.get(\"symbol-placement\"),w=\"point\"===_,A=\"point\"===_?c.get(\"text-max-width\").evaluate(s,{},o)*ah:0,S=s=>{t.allowVerticalPlacement&&ps(n)&&(m.vertical=Xh(g,e,r,i,l,A,u,d,s,p,v,Nh.vertical,!0,_,y,h));};if(!f&&x){const t=\"auto\"===b?x.map((t=>Vp(t))):[b];let n=!1;for(let s=0;s=0||!ps(n)){const t=Xh(g,e,r,i,l,A,u,d,b,p,v,Nh.horizontal,!1,_,y,h);t&&(m.horizontal[b]=t);}S(\"point\"===_?\"left\":b);}}let b=!1;if(s.icon&&s.icon.name){const e=n[s.icon.name];e&&(x=ip(i[s.icon.name],c.get(\"icon-offset\").evaluate(s,{},o),c.get(\"icon-anchor\").evaluate(s,{},o)),b=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&E(\"Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer\"),(e.pixelRatio!==t.pixelRatio||0!==c.get(\"icon-rotate\").constantOr(1))&&(t.iconsNeedLinear=!0));}const _=Up(m.horizontal)||m.vertical;t.iconsInText||(t.iconsInText=!!_&&_.iconsInText),(_||x)&&Fp(t,s,m,x,n,p,y,0,v,b,a,o,u);}s&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray);}function Vp(t){switch(t){case\"right\":case\"top-right\":case\"bottom-right\":return \"right\";case\"left\":case\"top-left\":case\"bottom-left\":return \"left\"}return \"center\"}function Fp(t,e,r,n,i,s,a,o,u,c,h,p,f){let d=s.textMaxSize.evaluate(e,{},p);void 0===d&&(d=a);const y=t.layers[0].layout,m=y.get(\"icon-offset\").evaluate(e,{},p),g=Up(r.horizontal)||r.vertical,x=\"globe\"===f.name,v=a/24,b=t.tilePixelRatio*d/24,_=(T=t.overscaling,t.zoom>18&&T>2&&(T>>=1),Math.max(wo/(512*T),1)*y.get(\"symbol-spacing\")),w=y.get(\"text-padding\")*t.tilePixelRatio,A=y.get(\"icon-padding\")*t.tilePixelRatio,S=l(y.get(\"text-max-angle\")),k=\"map\"===y.get(\"text-rotation-alignment\")&&\"point\"!==y.get(\"symbol-placement\"),I=\"map\"===y.get(\"icon-rotation-alignment\")&&\"point\"!==y.get(\"symbol-placement\"),M=y.get(\"symbol-placement\"),z=_/2;var T;const B=y.get(\"icon-text-fit\");let C;n&&\"none\"!==B&&(t.allowVerticalPlacement&&r.vertical&&(C=sp(n,r.vertical,B,y.get(\"icon-text-fit-padding\"),m,v)),g&&(n=sp(n,g,B,y.get(\"icon-text-fit-padding\"),m,v)));const P=(a,o,l)=>{if(o.x<0||o.x>=wo||o.y<0||o.y>=wo)return;let d=null;if(x){const{x:t,y:e,z:r}=f.projectTilePoint(o.x,o.y,l);d={anchor:new ap(t,e,r,0,void 0),up:f.upVector(l,o.x,o.y)};}!function(t,e,r,n,i,s,a,o,l,u,c,h,p,f,d,y,m,g,x,v,b,_,w,A,S){const k=t.addToLineVertexArray(e,n);let I,M,z,T,B,C,P,D=0,V=0,F=0,L=0,R=-1,U=-1;const j={};let $=Na(\"\");const O=r?r.anchor:e;let q=0,N=0;if(void 0===l._unevaluatedLayout.getValue(\"text-radial-offset\")?[q,N]=l.layout.get(\"text-offset\").evaluate(b,{},S).map((t=>t*ah)):(q=l.layout.get(\"text-radial-offset\").evaluate(b,{},S)*ah,N=Ep),t.allowVerticalPlacement&&i.vertical){const t=i.vertical;if(d)C=$p(t),o&&(P=$p(o));else {const r=l.layout.get(\"text-rotate\").evaluate(b,{},S)+90;z=jp(u,O,e,c,h,p,t,f,r,y),o&&(T=jp(u,O,e,c,h,p,o,g,r));}}if(s){const n=l.layout.get(\"icon-rotate\").evaluate(b,{},S),i=\"none\"!==l.layout.get(\"icon-text-fit\"),a=bp(s,n,w,i),f=o?bp(o,n,w,i):void 0;M=jp(u,O,e,c,h,p,s,g,n),D=4*a.length;const d=t.iconSizeData;let y=null;\"source\"===d.kind?(y=[oh*l.layout.get(\"icon-size\").evaluate(b,{},S)],y[0]>Lp&&E(`${t.layerIds[0]}: Value for \"icon-size\" is >= 255. Reduce your \"icon-size\".`)):\"composite\"===d.kind&&(y=[oh*_.compositeIconSizes[0].evaluate(b,{},S),oh*_.compositeIconSizes[1].evaluate(b,{},S)],(y[0]>Lp||y[1]>Lp)&&E(`${t.layerIds[0]}: Value for \"icon-size\" is >= 255. Reduce your \"icon-size\".`)),t.addSymbols(t.icon,a,y,v,x,b,!1,r,e,k.lineStartIndex,k.lineLength,-1,A,S),R=t.icon.placedSymbolArray.length-1,f&&(V=4*f.length,t.addSymbols(t.icon,f,y,v,x,b,Nh.vertical,r,e,k.lineStartIndex,k.lineLength,-1,A,S),U=t.icon.placedSymbolArray.length-1);}for(const n in i.horizontal){const s=i.horizontal[n];I||($=Na(s.text),d?B=$p(s):I=jp(u,O,e,c,h,p,s,f,l.layout.get(\"text-rotate\").evaluate(b,{},S),y));const o=1===s.positionedLines.length;if(F+=Rp(t,r,e,s,a,l,d,b,y,k,i.vertical?Nh.horizontal:Nh.horizontalOnly,o?Object.keys(i.horizontal):[n],j,R,_,A,S),o)break}i.vertical&&(L+=Rp(t,r,e,i.vertical,a,l,d,b,y,k,Nh.vertical,[\"vertical\"],j,U,_,A,S));let G=-1;const Z=(t,e)=>t?Math.max(t,e):e;G=Z(B,G),G=Z(C,G),G=Z(P,G);const X=G>-1?1:0;t.glyphOffsetArray.length>=Qf.MAX_GLYPHS&&E(\"Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907\"),void 0!==b.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,b.sortKey),t.symbolInstances.emplaceBack(O.x,O.y,O.z,e.x,e.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,R,U,$,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==z?z:t.collisionBoxArray.length,void 0!==z?z+1:t.collisionBoxArray.length,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,T||t.collisionBoxArray.length,T?T+1:t.collisionBoxArray.length,c,F,L,D,V,X,0,q,N,G);}(t,o,d,a,r,n,i,C,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,w,k,u,0,A,I,m,e,s,c,h,p);};if(\"line\"===M)for(const i of dp(e.geometry,0,0,wo,wo)){const e=pp(i,_,S,r.vertical||g,n,24,b,t.overscaling,wo);for(const r of e){const e=g;e&&Op(t,e.text,z,r)||P(i,r,p);}}else if(\"line-center\"===M){for(const t of e.geometry)if(t.length>1){const e=hp(t,S,r.vertical||g,n,24,b);e&&P(t,e,p);}}else if(\"Polygon\"===e.type)for(const t of Yu(e.geometry,0)){const e=zp(t,16);P(t[0],new ap(e.x,e.y,0,0,void 0),p);}else if(\"LineString\"===e.type)for(const t of e.geometry)P(t,new ap(t[0].x,t[0].y,0,0,void 0),p);else if(\"Point\"===e.type)for(const t of e.geometry)for(const e of t)P([e],new ap(e.x,e.y,0,0,void 0),p);}const Lp=32640;function Rp(t,e,r,n,s,a,o,l,u,c,h,p,f,d,y,m,g){const x=function(t,e,r,n,s,a,o,l){const u=[];if(0===e.positionedLines.length)return u;const c=n.layout.get(\"text-rotate\").evaluate(a,{})*Math.PI/180,h=function(t){const e=t[0],r=t[1],n=e*r;return n>0?[e,-r]:n<0?[-e,r]:0===e?[r,e]:[r,-e]}(r);let p=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)p-=t.lineOffset;const f=e.positionedLines.length,d=p/f;let y=e.top-r[1];for(let t=0;tLp&&E(`${t.layerIds[0]}: Value for \"text-size\" is >= 255. Reduce your \"text-size\".`)):\"composite\"===v.kind&&(b=[oh*y.compositeTextSizes[0].evaluate(l,{},g),oh*y.compositeTextSizes[1].evaluate(l,{},g)],(b[0]>Lp||b[1]>Lp)&&E(`${t.layerIds[0]}: Value for \"text-size\" is >= 255. Reduce your \"text-size\".`)),t.addSymbols(t.text,x,b,u,o,l,h,e,r,c.lineStartIndex,c.lineLength,d,m,g);for(const e of p)f[e]=t.text.placedSymbolArray.length-1;return 4*x.length}function Up(t){for(const e in t)return t[e];return null}function jp(t,e,r,n,s,a,o,u,c,h){let p=o.top,f=o.bottom,d=o.left,y=o.right;const m=o.collisionPadding;if(m&&(d-=m[0],p-=m[1],y+=m[2],f+=m[3]),c){const t=new i(d,p),e=new i(y,p),r=new i(d,f),n=new i(y,f),s=l(c);let a=new i(0,0);h&&(a=new i(h[0],h[1])),t._rotateAround(s,a),e._rotateAround(s,a),r._rotateAround(s,a),n._rotateAround(s,a),d=Math.min(t.x,e.x,r.x,n.x),y=Math.max(t.x,e.x,r.x,n.x),p=Math.min(t.y,e.y,r.y,n.y),f=Math.max(t.y,e.y,r.y,n.y);}return t.emplaceBack(e.x,e.y,e.z,r.x,r.y,d,p,y,f,u,n,s,a),t.length-1}function $p(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Op(t,e,r,n){const i=t.compareText;if(e in i){const t=i[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])1?null:function(t,e,r,n){const i=Math.sin(r);return t*(Math.sin((1-n)*r)/i)+e*(Math.sin(n*r)/i)}(t.a[e],t.b[e],t.angle,d(r,0,1))+t.center[e]}function rf(t){if(t.z<=1)return Jp[t.z+2*t.y+t.x];const e=lf(of(t));return eu.fromPoints(e)}function nf(t,e){const r=gf(e.zoom);if(0===r)return rf(t);const n=of(t),i=lf(n),s=zo(n.getWest())*e.worldSize,a=zo(n.getEast())*e.worldSize,o=To(n.getNorth())*e.worldSize,l=To(n.getSouth())*e.worldSize,u=[s,o,0],c=[a,o,0],h=[s,l,0],p=[a,l,0],f=gl([],e.globeMatrix);return jl(u,u,f),jl(c,c,f),jl(h,h,f),jl(p,p,f),i[0]=vr(i[0],h,r),i[1]=vr(i[1],p,r),i[2]=vr(i[2],c,r),i[3]=vr(i[3],u,r),eu.fromPoints(i)}function sf(t,e,r,n,i){for(const s of r)jl(s,s,n),Vl(s,s,i),Pl(t,t,s),Dl(e,e,s);}function af(t,e,r){const n=e/t.worldSize,i=Number.MAX_VALUE,s=[-i,-i,-i],a=[i,i,i],o=t.globeMatrix;if(r.z<=1)return sf(a,s,rf(r).getCorners(),o,n),new eu(a,s);const u=of(r),c=lf(u);if(sf(a,s,c,o,n),u.contains(t.center)){s[2]=0;const e=t.point,r=[e.x*n,e.y*n,0];return Pl(a,a,r),Dl(s,s,r),new eu(a,s)}const h=[o[12]*n,o[13]*n,o[14]*n],p=u.getCenter(),f=d(t.center.lat,-85.051129,Do),y=d(p.lat,-85.051129,Do),m=zo(t.center.lng),g=To(f);let x=m-zo(p.lng);const v=g-To(y);x>.5?x-=1:x<-.5&&(x+=1);let b=0;Math.abs(x)>Math.abs(v)?b=x>=0?1:3:(b=v>=0?0:2,Fl(h,h,[o[4]*n,o[5]*n,o[6]*n],-Math.sin(l(v>=0?u.getSouth():u.getNorth()))*Xp));const _=c[b],w=c[(b+1)%4],A=new tf(_,w,h),S=[ef(A,0)||_[0],ef(A,1)||_[1],ef(A,2)||_[2]];return a[2]=Math.min(_[2],w[2]),Pl(a,a,S),Dl(s,s,S),new eu(a,s)}function of({x:t,y:e,z:r}){const n=1/(1<v&&(b(t,u,n,i,o,l),b(u,r,o,l,s,a));}b(h,p,n,s,i,s),b(p,f,i,s,i,a),b(f,d,i,a,n,a),b(d,h,n,a,n,s),y-=v,m-=v,g+=v,x+=v;const _=1/Math.max(g-y,x-m);return {scale:_,x:y*_,y:m*_,x2:g*_,y2:x*_,projection:e}}const Sf=ml(new Float32Array(16));class kf{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit=\"meters\",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=[\"custom\"],this.center=[0,0],this.range=[3.5,7];}project(t,e){return {x:0,y:0,z:0}}unproject(t,e){return new ko(0,0)}projectTilePoint(t,e,r){return {x:t,y:e,z:0}}locationPoint(t,e,r=!0){return t._coordinatePoint(t.locationCoordinate(e),r)}pixelsPerMeter(t,e){return Bo(1,t)*e}pixelSpaceConversion(t,e,r){return 1}farthestPixelDistance(t){return wf(t,t.pixelsPerMeter)}pointCoordinate(t,e,r,n){const s=t.horizonLineFromTop(!1),a=new i(e,Math.max(s,r));return t.rayIntersectionCoordinate(t.pointRayIntersection(a,n))}pointCoordinate3D(t,e,r){const n=new i(e,r);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return [e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return !this.pointCoordinate3D(t,e.x,e.y);const r=t.horizonLineFromTop();return e.y0?e<-Df+r&&(e=-Df+r):e>Df-r&&(e=Df-r);const s=i/Math.pow(Vf(e),n),a=s*Math.sin(n*t),o=i-s*Math.cos(n*t);return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+.5),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,e=(2*(1-e)-.5)*Math.PI;const{n:r,f:n}=this,i=n-e,s=Math.sign(i),a=Math.sign(r)*Math.sqrt(t*t+i*i);let o=Math.atan2(t,Math.abs(i))*s;i*r<0&&(o-=Math.PI*Math.sign(t)*s);const l=d(u(o/r)+this.center[0],-180,180),c=d(u(2*Math.atan(Math.pow(n/a,1/r))-Df),-85.051129,Do);return new ko(l,c)}}class Lf extends kf{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null;}project(t,e){return {x:zo(t),y:To(e),z:0}}unproject(t,e){const r=Eo(t),n=Co(e);return new ko(r,n)}}const Rf=l(Do);class Uf extends kf{project(t,e){const r=(e=l(e))*e,n=r*r;return {x:.5*((t=l(t))*(.8707-.131979*r+n*(n*(.003971*r-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+r*(.015085+n*(.028874*r-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let r=e=(2*(1-e)-1)*Math.PI,n=25,i=0,s=r*r;do{s=r*r;const t=s*s;i=(r*(1.007226+s*(.015085+t*(.028874*s-.044475-.005916*t)))-e)/(1.007226+s*(.045255+t*(.259866*s-.311325-.005916*11*t))),r=d(r-i,-Rf,Rf);}while(Math.abs(i)>1e-6&&--n>0);s=r*r;const a=d(u(t/(.8707+s*(s*(s*s*s*(.003971-.001529*s)-.013791)-.131979))),-180,180),o=u(r);return new ko(a,o)}}const jf=l(Do);class $f extends kf{project(t,e){e=l(e),t=l(t);const r=Math.cos(e),n=2/Math.PI,i=Math.acos(r*Math.cos(t/2)),s=Math.sin(i)/i,a=.5*(t*n+2*r*Math.sin(t/2)/s)||0,o=.5*(e+Math.sin(e)/s)||0;return {x:.5*(a/Math.PI+.5),y:1-.5*(o/Math.PI+1),z:0}}unproject(t,e){let r=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,i=25;const s=1e-6;let a=0,o=0;do{const i=Math.cos(n),s=Math.sin(n),l=2*s*i,u=s*s,c=i*i,h=Math.cos(r/2),p=Math.sin(r/2),f=2*h*p,y=p*p,m=1-c*h*h,g=m?1/m:0,x=m?Math.acos(i*h)*Math.sqrt(1/m):0,v=.5*(2*x*i*p+2*r/Math.PI)-t,b=.5*(x*s+n)-e,_=.5*g*(c*y+x*i*h*u)+1/Math.PI,w=g*(f*l/4-x*s*p),A=.125*g*(l*p-x*s*c*f),S=.5*g*(u*h+x*y*i)+.5,k=w*A-S*_;a=(b*w-v*S)/k,o=(v*A-b*_)/k,r=d(r-a,-Math.PI,Math.PI),n=d(n-o,-jf,jf);}while((Math.abs(a)>s||Math.abs(o)>s)&&--i>0);return new ko(u(r),u(n))}}class Of extends kf{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(l(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0;}project(t,e){const{scale:r,cosPhi:n}=this;return {x:l(t)*n*r+.5,y:-Math.sin(l(e))/n*r+.5,z:0}}unproject(t,e){const{scale:r,cosPhi:n}=this,i=-(e-.5)/r,s=d(u((t-.5)/r)/n,-180,180),a=Math.asin(d(i*n,-1,1)),o=d(u(a),-85.051129,Do);return new ko(s,o)}}class qf extends Lf{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit=\"pixels\",this.unsupportedLayers=[\"debug\",\"custom\"],this.range=[3,5];}projectTilePoint(t,e,r){const n=hf(t,e,r);return jl(n,n,df(rf(r))),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const r=cf(e.lat,e.lng),n=Ll([],r),s=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Fl(r,r,n,Bo(1,0)*wo*s);const a=ml(new Float64Array(16));return xl(a,t.pixelMatrix,t.globeMatrix),jl(r,r,a),new i(r[0],r[1])}pixelsPerMeter(t,e){return Bo(1,0)*e}pixelSpaceConversion(t,e,r){const n=xr(Bo(1,45)*e,Bo(1,t)*e,r);return this.pixelsPerMeter(t,e)/n}createTileMatrix(t,e,r){const n=yf(rf(r.canonical));return xl(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:r}=t,n=df(rf(e));return wl(n,n,l(r.lng)),_l(n,n,l(r.lat)),bl(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,r,n){return Qp(t,e,r,!0)||new Fo(0,0)}pointCoordinate3D(t,e,r){const n=this.pointCoordinate(t,e,r,0);return [n.x,n.y,n.z]}isPointAboveHorizon(t,e){return !Qp(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const r=t.cameraToCenterDistance,n=t._centerAltitude*e,i=t._camera,s=t._camera.forward(),a=Bl([],Vl([],s,-r),[0,0,n]),o=t.worldSize/(2*Math.PI),l=[0,0,-o],u=t.width/t.height,c=Math.tan(t.fovAboveCenter),h=Vl([],i.up(),c),p=Vl([],i.right(),c*u),f=Ll([],Bl([],Bl([],s,h),p)),d=[];let y;if(new Jl(a,f).closestPointOnSphere(l,o,d)){const e=Bl([],d,l),r=ql([],e,a);y=Math.cos(t.fovAboveCenter)*zl(r);}else {const t=ql([],a,l),e=ql([],l,a);Ll(e,e);const r=zl(t)-o;y=Math.sqrt(r*(r+2*o));const n=Math.acos(y/(o+r))-Math.acos(Rl(s,e));y*=Math.cos(n);}return 1.01*y}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),r=gf(t.zoom);if(r>0){const n=wf(t,Bo(1,t.center.lat)*t.worldSize),i=t.worldSize/(2*Math.PI),s=Math.max(t.width,t.height)/t.worldSize*Math.PI;return xr(e,n+i*(1-Math.cos(s)),Math.pow(r,10))}return e}upVector(t,e,r){return hf(e,r,t,1)}upVectorScale(t){return {metersToTile:Kp*pf(rf(t))}}}function Nf(t){const e=t.parallels,r=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case\"mercator\":return new Lf(t);case\"equirectangular\":return new Pf(t);case\"naturalEarth\":return new Uf(t);case\"equalEarth\":return new Cf(t);case\"winkelTripel\":return new $f(t);case\"albers\":return r?new Of(t):new If(t);case\"lambertConformalConic\":return r?new Of(t):new Ff(t);case\"globe\":return new qf(t)}throw new Error(`Invalid projection name: ${t.name}`)}const Gf=yc.VectorTileFeature.types,Zf=[{name:\"a_fade_opacity\",components:1,type:\"Uint8\",offset:0}];function Xf(t,e,r,n,i,s,a,o,l,u,c,h,p){const f=o?Math.min(Lp,Math.round(o[0])):0,d=o?Math.min(Lp,Math.round(o[1])):0;t.emplaceBack(e,r,Math.round(32*n),Math.round(32*i),s,a,(f<<1)+(l?1:0),d,16*u,16*c,256*h,256*p);}function Kf(t,e,r,n,i,s,a){t.emplaceBack(e,r,n,i,s,a);}function Hf(t,e,r,n,i){t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i),t.emplaceBack(e,r,n,i);}function Yf(t){for(const e of t.sections)if(vs(e.text))return !0;return !1}class Wf{constructor(t){this.layoutVertexArray=new oa,this.indexArray=new ya,this.programConfigurations=t,this.segments=new _o,this.dynamicLayoutVertexArray=new na,this.opacityVertexArray=new ua,this.placedSymbolArray=new Ta,this.globeExtVertexArray=new la;}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,r,n){this.isEmpty()||(r&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Qc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,eh.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,Zf,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,th.members,!0)),this.opacityVertexBuffer.itemSize=1),(r||n)&&this.programConfigurations.upload(t));}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy());}}Pi(Wf,\"SymbolBuffers\");class Jf{constructor(t,e,r){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new r,this.segments=new _o,this.collisionVertexArray=new fa,this.collisionVertexArrayExt=new da;}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,rh.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,nh.members,!0);}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy());}}Pi(Jf,\"CollisionBuffers\");class Qf{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ml([]),this.placementViewportMatrix=ml([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=lh(this.zoom,e[\"text-size\"]),this.iconSizeData=lh(this.zoom,e[\"icon-size\"]);const r=this.layers[0].layout,n=r.get(\"symbol-sort-key\"),i=r.get(\"symbol-z-order\");this.canOverlap=r.get(\"text-allow-overlap\")||r.get(\"icon-allow-overlap\")||r.get(\"text-ignore-placement\")||r.get(\"icon-ignore-placement\"),this.sortFeaturesByKey=\"viewport-y\"!==i&&void 0!==n.constantOr(1),this.sortFeaturesByY=(\"viewport-y\"===i||\"auto\"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=r.get(\"text-writing-mode\").map((t=>Nh[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection;}createArrays(){this.text=new Wf(new co(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Wf(new co(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Ca,this.lineVertexArray=new Pa,this.symbolInstances=new Ea;}calculateGlyphDependencies(t,e,r,n,i){for(let r=0;r0)&&(\"constant\"!==o.value.kind||o.value.value.length>0),h=\"constant\"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,p=s.get(\"symbol-sort-key\");if(this.features=[],!c&&!h)return;const f=e.iconDependencies,d=e.glyphDependencies,y=e.availableImages,m=new Cs(this.zoom);for(const{feature:e,id:l,index:u,sourceLayerIndex:g}of t){const t=i._featureFilter.needGeometry,x=Go(e,t);if(!i._featureFilter.filter(m,x,r))continue;if(t||(x.geometry=No(e,r,n)),a&&1!==e.type&&r.z<=5){const t=x.geometry,e=.98078528056;for(let n=0;nt),((t,n)=>Rl(hf(t.x,t.y,r,1),hf(n.x,n.y,r,1))=0;for(const r of v.sections)if(r.image)f[r.image.name]=!0;else {const n=ps(v.toString()),i=r.fontStack||t,s=d[i]=d[i]||{};this.calculateGlyphDependencies(r.text,s,e,this.allowVerticalPlacement,n);}}}\"line\"===s.get(\"symbol-placement\")&&(this.features=function(t){const e={},r={},n=[];let i=0;function s(e){n.push(t[e]),i++;}function a(t,e,i){const s=r[t];return delete r[t],r[e]=s,n[s].geometry[0].pop(),n[s].geometry[0]=n[s].geometry[0].concat(i[0]),s}function o(t,r,i){const s=e[r];return delete e[r],e[t]=s,n[s].geometry[0].shift(),n[s].geometry[0]=i[0].concat(n[s].geometry[0]),s}function l(t,e,r){const n=r?e[0][e[0].length-1]:e[0][0];return `${t}:${n.x}:${n.y}`}for(let u=0;ut.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey));}update(t,e,r,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,r,n),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,r,n));}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return !this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0;}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy();}getProjection(){return this.projectionInstance||(this.projectionInstance=Nf(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData();}addToLineVertexArray(t,e){const r=this.lineVertexArray.length,n=t.segment;if(void 0!==n){let r=t.dist(e[n+1]),i=t.dist(e[n]);const s={};for(let t=n+1;t=0;t--)s[t]={x:e[t].x,y:e[t].y,tileUnitDistanceFromAnchor:i},t>0&&(i+=e[t-1].dist(e[t]));for(let t=0;t=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),s=uh(this.textSizeData,t,i)/ah;return this.tilePixelRatio*s}getSymbolInstanceIconSize(t,e,r){const n=this.icon.placedSymbolArray.get(r),i=uh(this.iconSizeData,t,n);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(t,e,r){t.emplaceBack(e,-r,-r),t.emplaceBack(e,r,-r),t.emplaceBack(e,r,r),t.emplaceBack(e,-r,r);}_updateTextDebugCollisionBoxes(t,e,r,n,i,s){for(let a=n;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const r=t.placedSymbolArray.get(e),n=r.vertexStartIndex+4*r.numGlyphs;for(let e=r.vertexStartIndex;en[t]-n[e]||i[e]-i[t])),s}addToSortKeyRanges(t,e){const r=this.sortKeyRanges[this.sortKeyRanges.length-1];r&&r.sortKey===e?r.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1});}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,r)=>{t>=0&&r.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t);})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex);}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray);}}}Pi(Qf,\"SymbolBucket\",{omit:[\"layers\",\"collisionBoxArray\",\"features\",\"compareText\"]}),Qf.MAX_GLYPHS=65535,Qf.addDynamicAttributes=Hf;const td=new Zs({\"symbol-placement\":new $s(Gt.layout_symbol[\"symbol-placement\"]),\"symbol-spacing\":new $s(Gt.layout_symbol[\"symbol-spacing\"]),\"symbol-avoid-edges\":new $s(Gt.layout_symbol[\"symbol-avoid-edges\"]),\"symbol-sort-key\":new Os(Gt.layout_symbol[\"symbol-sort-key\"]),\"symbol-z-order\":new $s(Gt.layout_symbol[\"symbol-z-order\"]),\"icon-allow-overlap\":new $s(Gt.layout_symbol[\"icon-allow-overlap\"]),\"icon-ignore-placement\":new $s(Gt.layout_symbol[\"icon-ignore-placement\"]),\"icon-optional\":new $s(Gt.layout_symbol[\"icon-optional\"]),\"icon-rotation-alignment\":new $s(Gt.layout_symbol[\"icon-rotation-alignment\"]),\"icon-size\":new Os(Gt.layout_symbol[\"icon-size\"]),\"icon-text-fit\":new $s(Gt.layout_symbol[\"icon-text-fit\"]),\"icon-text-fit-padding\":new $s(Gt.layout_symbol[\"icon-text-fit-padding\"]),\"icon-image\":new Os(Gt.layout_symbol[\"icon-image\"]),\"icon-rotate\":new Os(Gt.layout_symbol[\"icon-rotate\"]),\"icon-padding\":new $s(Gt.layout_symbol[\"icon-padding\"]),\"icon-keep-upright\":new $s(Gt.layout_symbol[\"icon-keep-upright\"]),\"icon-offset\":new Os(Gt.layout_symbol[\"icon-offset\"]),\"icon-anchor\":new Os(Gt.layout_symbol[\"icon-anchor\"]),\"icon-pitch-alignment\":new $s(Gt.layout_symbol[\"icon-pitch-alignment\"]),\"text-pitch-alignment\":new $s(Gt.layout_symbol[\"text-pitch-alignment\"]),\"text-rotation-alignment\":new $s(Gt.layout_symbol[\"text-rotation-alignment\"]),\"text-field\":new Os(Gt.layout_symbol[\"text-field\"]),\"text-font\":new Os(Gt.layout_symbol[\"text-font\"]),\"text-size\":new Os(Gt.layout_symbol[\"text-size\"]),\"text-max-width\":new Os(Gt.layout_symbol[\"text-max-width\"]),\"text-line-height\":new Os(Gt.layout_symbol[\"text-line-height\"]),\"text-letter-spacing\":new Os(Gt.layout_symbol[\"text-letter-spacing\"]),\"text-justify\":new Os(Gt.layout_symbol[\"text-justify\"]),\"text-radial-offset\":new Os(Gt.layout_symbol[\"text-radial-offset\"]),\"text-variable-anchor\":new $s(Gt.layout_symbol[\"text-variable-anchor\"]),\"text-anchor\":new Os(Gt.layout_symbol[\"text-anchor\"]),\"text-max-angle\":new $s(Gt.layout_symbol[\"text-max-angle\"]),\"text-writing-mode\":new $s(Gt.layout_symbol[\"text-writing-mode\"]),\"text-rotate\":new Os(Gt.layout_symbol[\"text-rotate\"]),\"text-padding\":new $s(Gt.layout_symbol[\"text-padding\"]),\"text-keep-upright\":new $s(Gt.layout_symbol[\"text-keep-upright\"]),\"text-transform\":new Os(Gt.layout_symbol[\"text-transform\"]),\"text-offset\":new Os(Gt.layout_symbol[\"text-offset\"]),\"text-allow-overlap\":new $s(Gt.layout_symbol[\"text-allow-overlap\"]),\"text-ignore-placement\":new $s(Gt.layout_symbol[\"text-ignore-placement\"]),\"text-optional\":new $s(Gt.layout_symbol[\"text-optional\"])});var ed={paint:new Zs({\"icon-opacity\":new Os(Gt.paint_symbol[\"icon-opacity\"]),\"icon-color\":new Os(Gt.paint_symbol[\"icon-color\"]),\"icon-halo-color\":new Os(Gt.paint_symbol[\"icon-halo-color\"]),\"icon-halo-width\":new Os(Gt.paint_symbol[\"icon-halo-width\"]),\"icon-halo-blur\":new Os(Gt.paint_symbol[\"icon-halo-blur\"]),\"icon-translate\":new $s(Gt.paint_symbol[\"icon-translate\"]),\"icon-translate-anchor\":new $s(Gt.paint_symbol[\"icon-translate-anchor\"]),\"text-opacity\":new Os(Gt.paint_symbol[\"text-opacity\"]),\"text-color\":new Os(Gt.paint_symbol[\"text-color\"],{runtimeType:ne,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),\"text-halo-color\":new Os(Gt.paint_symbol[\"text-halo-color\"]),\"text-halo-width\":new Os(Gt.paint_symbol[\"text-halo-width\"]),\"text-halo-blur\":new Os(Gt.paint_symbol[\"text-halo-blur\"]),\"text-translate\":new $s(Gt.paint_symbol[\"text-translate\"]),\"text-translate-anchor\":new $s(Gt.paint_symbol[\"text-translate-anchor\"])}),layout:td};class rd{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Qt,this.defaultValue=t;}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(e&&e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression);}outputDefined(){return !1}serialize(){return null}}Pi(rd,\"FormatSectionOverride\",{omit:[\"defaultValue\"]});class nd extends xo{constructor(t){super(t,ed);}recalculate(t,e){super.recalculate(t,e),\"auto\"===this.layout.get(\"icon-rotation-alignment\")&&(this.layout._values[\"icon-rotation-alignment\"]=\"point\"!==this.layout.get(\"symbol-placement\")?\"map\":\"viewport\"),\"auto\"===this.layout.get(\"text-rotation-alignment\")&&(this.layout._values[\"text-rotation-alignment\"]=\"point\"!==this.layout.get(\"symbol-placement\")?\"map\":\"viewport\"),\"auto\"===this.layout.get(\"text-pitch-alignment\")&&(this.layout._values[\"text-pitch-alignment\"]=this.layout.get(\"text-rotation-alignment\")),\"auto\"===this.layout.get(\"icon-pitch-alignment\")&&(this.layout._values[\"icon-pitch-alignment\"]=this.layout.get(\"icon-rotation-alignment\"));const r=this.layout.get(\"text-writing-mode\");if(r){const t=[];for(const e of r)t.indexOf(e)<0&&t.push(e);this.layout._values[\"text-writing-mode\"]=t;}else this.layout._values[\"text-writing-mode\"]=\"point\"===this.layout.get(\"symbol-placement\")?[\"horizontal\"]:[\"horizontal\",\"vertical\"];this._setPaintOverrides();}getValueAndResolveTokens(t,e,r,n){const i=this.layout.get(t).evaluate(e,{},r,n),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||Fn(s.value)||!i?i:function(t,e){return e.replace(/{([^{}]+)}/g,((e,r)=>r in t?String(t[r]):\"\"))}(e.properties,i)}createBucket(t){return new Qf(t)}queryRadius(){return 0}queryIntersectsFeature(){return !1}_setPaintOverrides(){for(const t of ed.paint.overridableProperties){if(!nd.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),r=new rd(e),n=new Vn(r,e.property.specification);let i=null;i=\"constant\"===e.value.kind||\"source\"===e.value.kind?new Rn(\"source\",n):new Un(\"composite\",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Us(e.property,i,e.parameters);}}_handleOverridablePaintPropertyUpdate(t,e,r){return !(!this.layout||e.isDataDriven()||r.isDataDriven())&&nd.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const r=t.get(\"text-field\"),n=ed.paint.properties[e];let i=!1;const s=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(i=!0)};if(\"constant\"===r.value.kind&&r.value.value instanceof _e)s(r.value.value.sections);else if(\"source\"===r.value.kind){const t=e=>{i||(e instanceof ze&&ke(e.value)===oe?s(e.value.sections):e instanceof Pe?s(e.sections):e.eachChild(t));},e=r.value;e._styleExpression&&t(e._styleExpression.expression);}return i}getProgramConfiguration(t){return new uo(this,t)}}var id={paint:new Zs({\"background-color\":new $s(Gt.paint_background[\"background-color\"]),\"background-pattern\":new Ns(Gt.paint_background[\"background-pattern\"]),\"background-opacity\":new $s(Gt.paint_background[\"background-opacity\"])})},sd={paint:new Zs({\"raster-opacity\":new $s(Gt.paint_raster[\"raster-opacity\"]),\"raster-hue-rotate\":new $s(Gt.paint_raster[\"raster-hue-rotate\"]),\"raster-brightness-min\":new $s(Gt.paint_raster[\"raster-brightness-min\"]),\"raster-brightness-max\":new $s(Gt.paint_raster[\"raster-brightness-max\"]),\"raster-saturation\":new $s(Gt.paint_raster[\"raster-saturation\"]),\"raster-contrast\":new $s(Gt.paint_raster[\"raster-contrast\"]),\"raster-resampling\":new $s(Gt.paint_raster[\"raster-resampling\"]),\"raster-fade-duration\":new $s(Gt.paint_raster[\"raster-fade-duration\"])})};class ad extends xo{constructor(t){super(t,{}),this.implementation=t;}is3D(){return \"3d\"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return !1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl);}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl);}}var od={paint:new Zs({\"sky-type\":new $s(Gt.paint_sky[\"sky-type\"]),\"sky-atmosphere-sun\":new $s(Gt.paint_sky[\"sky-atmosphere-sun\"]),\"sky-atmosphere-sun-intensity\":new $s(Gt.paint_sky[\"sky-atmosphere-sun-intensity\"]),\"sky-gradient-center\":new $s(Gt.paint_sky[\"sky-gradient-center\"]),\"sky-gradient-radius\":new $s(Gt.paint_sky[\"sky-gradient-radius\"]),\"sky-gradient\":new Gs(Gt.paint_sky[\"sky-gradient\"]),\"sky-atmosphere-halo-color\":new $s(Gt.paint_sky[\"sky-atmosphere-halo-color\"]),\"sky-atmosphere-color\":new $s(Gt.paint_sky[\"sky-atmosphere-color\"]),\"sky-opacity\":new $s(Gt.paint_sky[\"sky-opacity\"])})};function ld(t,e,r){const n=[0,0,1],i=Hl([]);return Wl(i,i,r?-l(t)+Math.PI:l(t)),Yl(i,i,-l(e)),$l(n,n,i),Ll(n,n)}const ud={circle:class extends xo{constructor(t){super(t,pl);}createBucket(t){return new Ko(t)}queryRadius(t){const e=t;return ol(\"circle-radius\",this,e)+ol(\"circle-stroke-width\",this,e)+ll(this.paint.get(\"circle-translate\"))}queryIntersectsFeature(t,e,r,n,i,s,a,o){const l=cl(this.paint.get(\"circle-translate\"),this.paint.get(\"circle-translate-anchor\"),s.angle,t.pixelToTileUnitsFactor),u=this.paint.get(\"circle-radius\").evaluate(e,r)+this.paint.get(\"circle-stroke-width\").evaluate(e,r);return ru(t,n,s,a,o,\"map\"===this.paint.get(\"circle-pitch-alignment\"),\"map\"===this.paint.get(\"circle-pitch-scale\"),l,u)}getProgramIds(){return [\"circle\"]}getProgramConfiguration(t){return new uo(this,t)}},heatmap:class extends xo{createBucket(t){return new ou(t)}constructor(t){super(t,fu),this._updateColorRamp();}_handleSpecialPaintPropertyUpdate(t){\"heatmap-color\"===t&&this._updateColorRamp();}_updateColorRamp(){this.colorRamp=du({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(t){return ol(\"heatmap-radius\",this,t)}queryIntersectsFeature(t,e,r,n,s,a,o,l){const u=this.paint.get(\"heatmap-radius\").evaluate(e,r);return ru(t,n,a,o,l,!0,!0,new i(0,0),u)}hasOffscreenPass(){return 0!==this.paint.get(\"heatmap-opacity\")&&\"none\"!==this.visibility}getProgramIds(){return [\"heatmap\",\"heatmapTexture\"]}getProgramConfiguration(t){return new uo(this,t)}},hillshade:class extends xo{constructor(t){super(t,yu);}hasOffscreenPass(){return 0!==this.paint.get(\"hillshade-exaggeration\")&&\"none\"!==this.visibility}getProgramIds(){return [\"hillshade\",\"hillshadePrepare\"]}},fill:class extends xo{constructor(t){super(t,rc);}getProgramIds(){const t=this.paint.get(\"fill-pattern\"),e=t&&t.constantOr(1),r=[e?\"fillPattern\":\"fill\"];return this.paint.get(\"fill-antialias\")&&r.push(e&&!this.getPaintProperty(\"fill-outline-color\")?\"fillOutlinePattern\":\"fillOutline\"),r}getProgramConfiguration(t){return new uo(this,t)}recalculate(t,e){super.recalculate(t,e);const r=this.paint._values[\"fill-outline-color\"];\"constant\"===r.value.kind&&void 0===r.value.value&&(this.paint._values[\"fill-outline-color\"]=this.paint._values[\"fill-color\"]);}createBucket(t){return new tc(t)}queryRadius(){return ll(this.paint.get(\"fill-translate\"))}queryIntersectsFeature(t,e,r,n,i,s){return !t.queryGeometry.isAboveHorizon&&Wo(ul(t.tilespaceGeometry,this.paint.get(\"fill-translate\"),this.paint.get(\"fill-translate-anchor\"),s.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return !0}},\"fill-extrusion\":class extends xo{constructor(t){super(t,Cc);}createBucket(t){return new wc(t)}queryRadius(){return ll(this.paint.get(\"fill-extrusion-translate\"))}is3D(){return !0}getProgramIds(){return [this.paint.get(\"fill-extrusion-pattern\").constantOr(1)?\"fillExtrusionPattern\":\"fillExtrusion\"]}getProgramConfiguration(t){return new uo(this,t)}queryIntersectsFeature(t,e,r,n,s,a,o,l,u){const c=cl(this.paint.get(\"fill-extrusion-translate\"),this.paint.get(\"fill-extrusion-translate-anchor\"),a.angle,t.pixelToTileUnitsFactor),h=this.paint.get(\"fill-extrusion-height\").evaluate(e,r),p=this.paint.get(\"fill-extrusion-base\").evaluate(e,r),f=[0,0],d=l&&a.elevation,y=a.elevation?a.elevation.exaggeration():1,m=t.tile.getBucket(this);if(d&&m instanceof wc){const t=m.centroidVertexArray,e=u+1;if(et.polygon)).flat());const g=function(t,e,r,n,s,a,o,l,u,c,h){return \"globe\"===t.projection.name?function(t,e,r,n,i,s,a,o,l,u,c){const h=[],p=[],f=t.projection.upVectorScale(c,t.center.lat,t.worldSize).metersToTile,d=[0,0,0,1],y=[0,0,0,1],m=(t,e,r,n)=>{t[0]=e,t[1]=r,t[2]=n,t[3]=1;},g=Tc();r>0&&(r+=g),n+=g;for(const g of e){const e=[],x=[];for(const h of g){const p=h.x+i.x,g=h.y+i.y,v=t.projection.projectTilePoint(p,g,c),b=t.projection.upVector(c,h.x,h.y);let _=r,w=n;if(a){const t=$c(p,g,r,n,a,o,l,u);_+=t.base,w+=t.top;}0!==r?m(d,v.x+b[0]*f*_,v.y+b[1]*f*_,v.z+b[2]*f*_):m(d,v.x,v.y,v.z),m(y,v.x+b[0]*f*w,v.y+b[1]*f*w,v.z+b[2]*f*w),jl(d,d,s),jl(y,y,s),e.push(jc(d)),x.push(jc(y));}h.push(e),p.push(x);}return [h,p]}(t,e,r,n,s,a,o,l,u,c,h):o?function(t,e,r,n,i,s,a,o,l){const u=[],c=[],h=[0,0,0,1];for(const p of t){const t=[],f=[];for(const u of p){const c=u.x+n.x,p=u.y+n.y,d=$c(c,p,e,r,s,a,o,l);h[0]=c,h[1]=p,h[2]=d.base,h[3]=1,Xl(h,h,i),h[3]=Math.max(h[3],1e-5);const y=jc([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);h[0]=c,h[1]=p,h[2]=d.top,h[3]=1,Xl(h,h,i),h[3]=Math.max(h[3],1e-5);const m=jc([h[0]/h[3],h[1]/h[3],h[2]/h[3]]);t.push(y),f.push(m);}u.push(t),c.push(f);}return [u,c]}(e,r,n,s,a,o,l,u,c):function(t,e,r,n,s){const a=[],o=[],l=s[8]*e,u=s[9]*e,c=s[10]*e,h=s[11]*e,p=s[8]*r,f=s[9]*r,d=s[10]*r,y=s[11]*r;for(const e of t){const t=[],r=[];for(const a of e){const e=a.x+n.x,o=a.y+n.y,m=s[0]*e+s[4]*o+s[12],g=s[1]*e+s[5]*o+s[13],x=s[2]*e+s[6]*o+s[14],v=s[3]*e+s[7]*o+s[15],b=m+l,_=g+u,w=x+c,A=Math.max(v+h,1e-5),S=m+p,k=g+f,I=x+d,M=Math.max(v+y,1e-5),z=new i(b/A,_/A);z.z=w/A,t.push(z);const T=new i(S/M,k/M);T.z=I/M,r.push(T);}a.push(t),o.push(r);}return [a,o]}(e,r,n,s,a)}(a,n,p,h,c,o,d?l:null,f,y,a.center.lat,t.tileID.canonical),x=t.queryGeometry;return function(t,e,r){let n=1/0;Wo(r,e)&&(n=Uc(r,e[0]));for(let i=0;i=3)for(let e=0;e1&&(a=t[++s]);const l=Math.abs(o-a.left),u=Math.abs(o-a.right),c=Math.min(l,u);let h;const p=e/r*(n+1);if(a.isDash){const t=n-Math.abs(p);h=Math.sqrt(c*c+t*t);}else h=n-Math.sqrt(c*c+p*p);this.image.data[i+o]=Math.max(0,Math.min(255,h+128));}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const r=t[e],n=t[e+1];r.zeroLength?t.splice(e,1):n&&n.isDash===r.isDash&&(n.left=r.left,t.splice(e,1));}const r=t[0],n=t[t.length-1];r.isDash===n.isDash&&(r.left=n.left-this.width,n.right=r.right+this.width);const i=this.width*this.nextRow;let s=0,a=t[s];for(let r=0;r1&&(a=t[++s]);const n=Math.abs(r-a.left),o=Math.abs(r-a.right),l=Math.min(n,o);this.image.data[i+r]=Math.max(0,Math.min(255,(a.isDash?l:-l)+e+128));}}addDash(t,e){const r=this.getKey(t,e);if(this.positions[r])return this.positions[r];const n=\"round\"===e,i=n?7:0,s=2*i+1;if(this.nextRow+s>this.height)return E(\"LineAtlas out of space\"),null;0===t.length&&t.push(1);let a=0;for(let e=0;e{this._triggered=!1,this._callback();});}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback();}),0));}remove(){this._channel=void 0,this._callback=()=>{};}}class fd{constructor(){this.tasks={},this.taskQueue=[],k([\"process\"],this),this.invoker=new pd(this.process),this.nextId=0;}add(t,e){const r=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:r}){return r=r||0,\"message\"===t?0:\"maybePrepare\"!==t||e?\"parseTile\"!==t||e?\"parseTile\"===t&&e?300-r:\"maybePrepare\"===t&&e?400-r:500:200-r:100-r}(e);if(0===n){D();try{t();}finally{}return {cancel:()=>{}}}return this.tasks[r]={fn:t,metadata:e,priority:n,id:r},this.taskQueue.push(r),this.invoker.trigger(),{cancel:()=>{delete this.tasks[r];}}}process(){D();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn();}finally{}}pick(){let t=null,e=1/0;for(let r=0;r>=1)>1;){const t=r+i>>1,l=n+s>>1;1&e?(i=r,s=n,r=a,n=o):(r=i,n=s,i=a,s=o),a=t,o=l;}const l=4*t;vd[l+0]=r,vd[l+1]=n,vd[l+2]=i,vd[l+3]=s;}const bd=new Uint16Array(2178),_d=new Uint8Array(1089),wd=new Uint16Array(1089);function Ad(t){return 0===t?-.03125:32===t?.03125:0}var Sd=Ws([{name:\"a_pos\",type:\"Int16\",components:2},{name:\"a_texture_pos\",type:\"Int16\",components:2}]);const kd={type:2,extent:wo,loadGeometry:()=>[[new i(0,0),new i(8193,0),new i(8193,8193),new i(0,8193),new i(0,0)]]};class Id{constructor(t,e,r,n,i){this.tileID=t,this.uid=_(),this.uses=0,this.tileSize=e,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state=\"loading\",n&&n.transform&&(this.projection=n.transform.projection);}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)r[e.id]=n;}}return r}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Qf){if(this.hasSymbolBuckets=!0,!r)break;e.justReloaded=!0;}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof Qf&&e.hasRTLText){this.hasRTLText=!0,Es.isLoading()||Es.isLoaded()||\"deferred\"!==Ts()||Bs();break}}this.queryPadding=0;for(const t in this.buckets){const r=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(r));}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas);}else this.collisionBoxArray=new Ma;}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state=\"unloaded\";}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const r=this.buckets[e];r.uploadPending()&&r.upload(t);}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new cd(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new cd(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new cd(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0);}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture);}queryRenderedFeatures(t,e,r,n,i,s,a,o){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:a,transform:s,params:i,tileTransform:this.tileTransform},t,e,r):{}}querySourceFeatures(t,e){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),i=e?e.sourceLayer:\"\",s=n._geojsonTileLayer||n[i];if(!s)return;const a=Jn(e&&e.filter),{z:o,x:l,y:u}=this.tileID.canonical,c={z:o,x:l,y:u};for(let e=0;et)r=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,r=vd[e+0],n=vd[e+1],i=vd[e+2],s=vd[e+3],a=r+i>>1,o=n+s>>1,l=a+o-n,u=o+r-a,c=n*xd+r,h=s*xd+i,p=o*xd+a,f=Math.hypot((bd[2*c+0]+bd[2*h+0])/2-bd[2*p+0],(bd[2*c+1]+bd[2*h+1])/2-bd[2*p+1])>=16;if(_d[p]=_d[p]||(f?1:0),t<1022){const t=(n+u>>1)*xd+(r+l>>1),e=(s+u>>1)*xd+(i+l>>1);_d[p]=_d[p]||_d[t]||_d[e];}}const i=new ea,s=new ya;let a=0;function o(t,e){const r=e*xd+t;return 0===wd[r]&&(i.emplaceBack(bd[2*r+0],bd[2*r+1],t*wo/gd,e*wo/gd),wd[r]=++a),wd[r]-1}function l(t,e,r,n,i,a){const u=t+r>>1,c=e+n>>1;if(Math.abs(t-i)+Math.abs(e-a)>1&&_d[c*xd+u])l(i,a,t,e,u,c),l(r,n,i,a,u,c);else {const l=o(t,e),u=o(r,n),c=o(i,a);s.emplaceBack(l,u,c);}}return l(0,0,gd,gd,gd,0),l(gd,gd,0,0,0,gd),{vertices:i,indices:s}}(this.tileID.canonical,e);n=t.vertices,i=t.indices;}else {n=new ea,i=new ya;for(const{x:t,y:e}of r)n.emplaceBack(t,e,0,0);const t=xu(n.int16,void 0,4);for(let e=0;e0&&(a=gl(new Float64Array(16),e.globeMatrix));const o=(n.x+.5)/(1<.5?l=-1:o<-.5&&(l=1),this._makeGlobeTileDebugBorderBuffer(t,n,e,i,a,s,l),this._makeGlobeTileDebugTextBuffer(t,n,e,i,a,s,l);}_globePoint(t,e,r,n,i,s,a,o){let l=hf(t,e,r);if(s){const i=1<{const d=(h-t)/(f-1),y=(p-c)/(f-1),m=o.length;for(let h=0;hc*t+e;for(let t=0;te[a])return null}else {const o=1/n[a];let l=(t[a]-r[a])*o,u=(e[a]-r[a])*o;if(l>u){const t=l;l=u,u=t;}if(l>i&&(i=l),us)return null}return i}function Bd(t,e,r,n,i,s,a,o,l,u,c){const h=n-t,p=i-e,f=s-r,d=a-t,y=o-e,m=l-r,g=c[1]*m-c[2]*y,x=c[2]*d-c[0]*m,v=c[0]*y-c[1]*d,b=h*g+p*x+f*v;if(Math.abs(b)<1e-15)return null;const _=1/b,w=u[0]-t,A=u[1]-e,S=u[2]-r,k=(w*g+A*x+S*v)*_;if(k<0||k>1)return null;const I=A*f-S*p,M=S*h-w*f,z=w*p-A*h,T=(c[0]*I+c[1]*M+c[2]*z)*_;return T<0||k+T>1?null:(d*I+y*M+m*z)*_}function Ed(t,e,r){return (t-e)/(r-e)}function Cd(t,e,r,n,i,s,a,o,l){const u=1<{const s=n?1:0,a=(t+1)*r-s,o=e*r,l=(e+1)*r-s;i[0]=t*r,i[1]=o,i[2]=a,i[3]=l;};let a=new zd(n);const o=[];for(let e=0;e=1;n/=2){const t=r[r.length-1];a=new zd(n);for(let e=0;e0;){const{idx:o,t:f,nodex:d,nodey:y,depth:m}=p.pop();if(this.leaves[o]){Cd(d,y,m,t,e,r,n,c,h);const o=1<=t[2])return f}continue}let g=0;for(let p=0;p=l[u[r]]&&(u.splice(r,0,p),e=!0);e||(u[g]=p),g++;}}for(let t=0;t=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError(\"out of range source coordinates for DEM data\");return (e+1)*this.stride+(t+1)}_unpackMapbox(t,e,r){return (256*t*256+256*e+r)/10-1e4}_unpackTerrarium(t,e,r){return 256*t+e+r/256-32768}static pack(t,e){const r=[0,0,0,0],n=Ld.getUnpackVector(e);let i=Math.floor((t+n[3])/n[2]);return r[2]=i%256,i=Math.floor(i/256),r[1]=i%256,i=Math.floor(i/256),r[0]=i,r}getPixels(){return new pu({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,r){if(this.dim!==t.dim)throw new Error(\"dem dimension mismatch\");let n=e*this.dim,i=e*this.dim+this.dim,s=r*this.dim,a=r*this.dim+this.dim;switch(e){case-1:n=i-1;break;case 1:i=n+1;}switch(r){case-1:s=a-1;break;case 1:a=s+1;}const o=-e*this.dim,l=-r*this.dim;for(let e=s;e{this.remove(t,i);}),r)),this.data[n].push(i),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const r=t.wrapped().key,n=void 0===e?0:this.data[r].indexOf(e),i=this.data[r][n];return this.data[r].splice(n,1),i.timeout&&clearTimeout(i.timeout),0===this.data[r].length&&delete this.data[r],this.onRemove(i.value),this.order.splice(this.order.indexOf(r),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t);}return this}filter(t){const e=[];for(const r in this.data)for(const n of this.data[r])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t);}}class Ud{constructor(t,e,r){this.func=t,this.mask=e,this.range=r;}}Ud.ReadOnly=!1,Ud.ReadWrite=!0,Ud.disabled=new Ud(519,Ud.ReadOnly,[0,1]);const jd=7680;class $d{constructor(t,e,r,n,i,s){this.test=t,this.ref=e,this.mask=r,this.fail=n,this.depthFail=i,this.pass=s;}}$d.disabled=new $d({func:519,mask:0},0,0,jd,jd,jd);class Od{constructor(t,e,r){this.blendFunction=t,this.blendColor=e,this.mask=r;}}Od.Replace=[1,0],Od.disabled=new Od(Od.Replace,xe.transparent,[!1,!1,!1,!1]),Od.unblended=new Od(Od.Replace,xe.transparent,[!0,!0,!0,!0]),Od.alphaBlended=new Od([1,771],xe.transparent,[!0,!0,!0,!0]);const qd=1029,Nd=2305;class Gd{constructor(t,e,r){this.enable=t,this.mode=e,this.frontFace=r;}}Gd.disabled=new Gd(!1,qd,Nd),Gd.backCCW=new Gd(!0,qd,Nd),Gd.backCW=new Gd(!0,qd,2304),Gd.frontCW=new Gd(!0,1028,2304),Gd.frontCCW=new Gd(!0,1028,Nd);class Zd extends Nt{constructor(t,e,r){super(),this.id=t,this._onlySymbols=r,e.on(\"data\",(t=>{\"source\"===t.dataType&&\"metadata\"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&\"source\"===t.dataType&&\"content\"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform));})),e.on(\"error\",(()=>{this._sourceErrored=!0;})),this._source=e,this._tiles={},this._cache=new Rd(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Md,this._isRaster=\"raster\"===this._source.type||\"raster-dem\"===this._source.type||\"custom\"===this._source.type&&\"raster\"===this._source._dataType;}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize;}loaded(){if(this._sourceErrored)return !0;if(!this._sourceLoaded)return !1;if(!this._source.loaded())return !1;for(const t in this._tiles){const e=this._tiles[t];if(\"loaded\"!==e.state&&\"errored\"!==e.state)return !1}return !0}getSource(){return this._source}pause(){this._paused=!0;}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform);}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){if(this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null),this._source.prepareTile)for(const e in this._tiles){const r=this._tiles[e];this._source.prepareTile(r)&&this.map.painter.terrain&&this.map.painter.terrain._clearRenderCacheForTile(this.id,r.tileID),r.upload(t),r.prepare(this.map.style.imageManager);}else for(const e in this._tiles){const r=this._tiles[e];r.upload(t),r.prepare(this.map.style.imageManager);}}getIds(){return x(this._tiles).map((t=>t.tileID)).sort(Xd).map((t=>t.key))}getRenderableIds(t){const e=[];for(const r in this._tiles)this._isIdRenderable(+r,t)&&e.push(this._tiles[r]);return t?e.sort(((t,e)=>{const r=t.tileID,n=e.tileID,s=new i(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),a=new i(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||a.y-s.y||a.x-s.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(Xd).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return !!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else {this._cache.reset();for(const t in this._tiles)\"errored\"!==this._tiles[t].state&&this._reloadTile(+t,\"reloading\");}}_reloadTile(t,e){const r=this._tiles[t];r&&(\"loading\"!==r.state&&(r.state=e),this._loadTile(r,this._tileLoaded.bind(this,r,t,e)));}_tileLoaded(t,e,r,n){if(n)if(t.state=\"errored\",404!==n.status)this._source.fire(new qt(n,{tile:t}));else if(\"raster-dem\"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id);}else this.update(this.transform);else t.timeAdded=X.now(),\"expired\"===r&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),\"raster-dem\"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Ot(\"data\",{dataType:\"source\",tile:t,coord:t.tileID,sourceCacheId:this.id}));}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(r)>1&&(1===Math.abs(r+i)?r+=i:1===Math.abs(r-i)&&(r-=i)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,r,n),t.neighboringTiles&&t.neighboringTiles[s]&&(t.neighboringTiles[s].backfilled=!0)));}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,r,n){for(const i in this._tiles){let s=this._tiles[i];if(n[i]||!s.hasData()||s.tileID.overscaledZ<=e||s.tileID.overscaledZ>r)continue;let a=s.tileID;for(;s&&s.tileID.overscaledZ>e+1;){const t=s.tileID.scaledTo(s.tileID.overscaledZ-1);s=this._tiles[t.key],s&&s.hasData()&&(a=t);}let o=a;for(;o.overscaledZ>e;)if(o=o.scaledTo(o.overscaledZ-1),t[o.key]){n[a.key]=a;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const r=this._loadedParentTiles[t.key];return r&&r.tileID.overscaledZ>=e?r:null}for(let r=t.overscaledZ-1;r>=e;r--){const e=t.scaledTo(r),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const r=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,i=Math.floor(r*n*5),s=\"number\"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a=\"number\"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._cache.setMaxSize(a);}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const r in this._tiles){const n=this._tiles[r];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n;}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t]);}}update(t,e,r){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;let n;this.updateCacheSize(t,e),\"globe\"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Fc(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((t=>this._source.hasTile(t))))):n=[];const i=this._updateRetainedTiles(n);if(Kd(this._source.type)&&0!==n.length){const t={},e={},r=Object.keys(i);for(const n of r){const r=i[n],s=this._tiles[n];if(!s||s.fadeEndTime&&s.fadeEndTime<=X.now())continue;const a=this.findLoadedParent(r,Math.max(r.overscaledZ-Zd.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),t[a.tileID.key]=a.tileID),e[n]=r;}const s=n[n.length-1].overscaledZ;for(const t in this._tiles){const r=this._tiles[t];if(i[t]||!r.hasData())continue;let n=r.tileID;for(;n.overscaledZ>s;){n=n.scaledTo(n.overscaledZ-1);const s=this._tiles[n.key];if(s&&s.hasData()&&e[n.key]){i[t]=r.tileID;break}}}for(const e in t)i[e]||(this._coveredTiles[e]=!0,i[e]=t[e]);}for(const t in i)this._tiles[t].clearFadeHold();const s=function(t,e){const r=[];for(const n in t)n in e||r.push(n);return r}(this._tiles,i);for(const t of s){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t);}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate();}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t);}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const r={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),i=t[0].overscaledZ,s=Math.max(i-Zd.maxOverzooming,this._source.minzoom),a=Math.max(i+Zd.maxUnderzooming,this._source.minzoom),o={};for(const r of t){const t=this._addTile(r);e[r.key]=r,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],r=this.getTile(t);if(r&&r.hasData()){e[t.key]=t;continue}}else {const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let i=t.wasRequested();for(let a=n.overscaledZ-1;a>=s;--a){const s=n.scaledTo(a);if(r[s.key])break;if(r[s.key]=!0,t=this.getTile(s),!t&&i&&(t=this._addTile(s)),t&&(e[s.key]=s,i=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let r,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){r=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(r=this._getLoadedTile(t),r)break;n=t;}for(const t of e)this._loadedParentTiles[t]=r;}}_addTile(t){let e=this._tiles[t.key];if(e)return this._source.prepareTile&&this._source.prepareTile(e),e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const r=Boolean(e);if(!r){const r=this.map?this.map.painter:null;e=new Id(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,r,this._isRaster),this._source.prepareTile&&this._source.prepareTile(e)||this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state));}return e?(e.uses++,this._tiles[t.key]=e,r||this._source.fire(new Ot(\"dataloading\",{tile:e,coord:e.tileID,dataType:\"source\"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const r=e.getExpiryTimeout();r&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,\"expired\"),delete this._timers[t];}),r));}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&\"reloading\"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))));}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id);}tilesIn(t,e,r){const n=[],i=this.transform;if(!i)return n;const s=\"globe\"===i.projection.name,a=zo(i.center.lng);for(const o in this._tiles){const l=this._tiles[o];if(r&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(s){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(d(a,...Hd(t,-1))-a),Math.abs(d(a,...Hd(t,1))-a)];u=[0,2*e.indexOf(Math.min(...e))-1];}else {const e=[Math.abs(d(a,...Hd(t,-1))-a),Math.abs(d(a,...Hd(t,0))-a),Math.abs(d(a,...Hd(t,1))-a)];u=[e.indexOf(Math.min(...e))-1];}}else u=[0];for(const r of u){const s=t.containsTile(l,i,e,r);s&&n.push(s);}}return n}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return !0;if(Kd(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=X.now())return !0}return !1}setFeatureState(t,e,r){this._state.updateState(t=t||\"_geojsonTileLayer\",e,r);}removeFeatureState(t,e,r){this._state.removeFeatureState(t=t||\"_geojsonTileLayer\",e,r);}getFeatureState(t,e){return this._state.getState(t=t||\"_geojsonTileLayer\",e)}setDependencies(t,e,r){const n=this._tiles[t];n&&n.setDependencies(e,r);}reloadTilesForDependencies(t,e){for(const r in this._tiles)this._tiles[r].hasDependency(t,e)&&this._reloadTile(+r,\"reloading\");this._cache.filter((r=>!r.hasDependency(t,e)));}_preloadTiles(t,e){const r=new Map,n=Array.isArray(t)?t:[t],i=this.map.painter.terrain,s=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:s,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)r.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1);}g(Array.from(r.values()),((t,e)=>{const r=new Id(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(r,(t=>{\"raster-dem\"===this._source.type&&r.dem&&this._backfillDEM(r),e(t,r);}));}),e);}}function Xd(t,e){const r=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-r||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function Kd(t){return \"raster\"===t||\"image\"===t||\"video\"===t}function Hd(t,e){const r=1<=0&&n[3]>=0&&o.insert(a,n[0],n[1],n[2],n[3]);}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new yc.VectorTile(new xh(this.rawTileData)).layers,this.sourceLayerCoder=new dd(this.vtLayers?Object.keys(this.vtLayers).sort():[\"_geojsonTileLayer\"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[];}return this.vtLayers}query(t,e,r,n){this.loadVTLayers();const i=t.params||{},s=Jn(i.filter),a=t.tileResult,o=t.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,r,n)=>sl(a.bufferedTilespaceGeometry,t,e,r,n)));u.sort(Qd);let c=null;o.elevation&&u.length>0&&(c=Yd.create(o.elevation,this.tileID));const h={};let p;for(let o=0;o(d||(d=No(e,this.tileID.canonical,t.tileTransform)),r.queryIntersectsFeature(a,e,n,d,this.z,t.transform,t.pixelPosMatrix,c,i))));}return h}loadMatchingFeature(t,e,r,n,i,s,a,o,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,f=this.bucketLayerIDs[c];if(n&&!function(t,e){for(let r=0;r=0)return !0;return !1}(n,f))return;const d=this.sourceLayerCoder.decode(h),y=this.vtLayers[d].feature(u);if(r.needGeometry){const t=Go(y,!0);if(!r.filter(new Cs(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!r.filter(new Cs(this.tileID.overscaledZ),y))return;const m=this.getId(y,d);for(let e=0;e{const a=e instanceof js?e.get(s):null;return a&&a.evaluate?a.evaluate(r,n,i):a}))}function Qd(t,e){return e-t}Pi(Wd,\"FeatureIndex\",{omit:[\"rawTileData\",\"sourceLayerCoder\"]});class ty{constructor(t){const e={},r=[];for(const n in t){const i=t[n],s=e[n]={};for(const t in i.glyphs){const e=i.glyphs[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const n=e.metrics.localGlyph?2:1,a={x:0,y:0,w:e.bitmap.width+2*n,h:e.bitmap.height+2*n};r.push(a),s[t]=a;}}const{w:n,h:i}=$h(r),s=new hu({width:n||1,height:i||1});for(const r in t){const n=t[r];for(const t in n.glyphs){const i=n.glyphs[+t];if(!i||0===i.bitmap.width||0===i.bitmap.height)continue;const a=e[r][t],o=i.metrics.localGlyph?2:1;hu.copy(i.bitmap,s,{x:0,y:0},{x:a.x+o,y:a.y+o},i.bitmap);}}this.image=s,this.positions=e;}}Pi(ty,\"GlyphAtlas\");class ey{constructor(t){this.tileID=new Fc(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=Af(t.tileID.canonical,t.projection),this.projection=t.projection;}parse(t,e,r,n,i){this.status=\"parsing\",this.data=t,this.collisionBoxArray=new Ma;const s=new dd(Object.keys(t.layers).sort()),a=new Wd(this.tileID,this.promoteId);a.bucketLayerIDs=[];const o={},l=new hd(256,256),u={featureIndex:a,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:l,availableImages:r},c=e.familiesBySource[this.source];for(const e in c){const n=t.layers[e];if(!n)continue;let i=!1,l=!1;for(const t of c[e])\"symbol\"===t[0].type?i=!0:l=!0;if(!0===this.isSymbolTile&&!i)continue;if(!1===this.isSymbolTile&&!l)continue;1===n.version&&E(`Vector tile source \"${this.source}\" layer \"${e}\" does not use vector tile spec v2 and therefore may have some rendering errors.`);const h=s.encode(e),p=[];for(let t=0;t=e.maxzoom||\"none\"!==e.visibility&&(ry(t,this.zoom,r),(o[e.id]=e.createBucket({index:a.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:r})).populate(p,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(t.map((t=>t.id))));}}let h,p,f,d;l.trim();const y={type:\"maybePrepare\",isSymbolTile:this.isSymbolTile,zoom:this.zoom},m=M(u.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(m).length?n.send(\"getGlyphs\",{uid:this.uid,stacks:m},((t,e)=>{h||(h=t,p=e,b.call(this));}),void 0,!1,y):p={};const g=Object.keys(u.iconDependencies);g.length?n.send(\"getImages\",{icons:g,source:this.source,tileID:this.tileID,type:\"icons\"},((t,e)=>{h||(h=t,f=e,b.call(this));}),void 0,!1,y):f={};const v=Object.keys(u.patternDependencies);function b(){if(h)return i(h);if(p&&f&&d){const t=new ty(p),e=new qh(f,d);for(const n in o){const i=o[n];i instanceof Qf?(ry(i.layers,this.zoom,r),Dp(i,p,t.positions,f,e.iconPositions,this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof Kc||i instanceof tc||i instanceof wc)&&(ry(i.layers,this.zoom,r),i.addFeatures(u,this.tileID.canonical,e.patternPositions,r,this.tileTransform));}this.status=\"done\",i(null,{buckets:x(o).filter((t=>!t.isEmpty())),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?t.positions:null});}}v.length?n.send(\"getImages\",{icons:v,source:this.source,tileID:this.tileID,type:\"patterns\"},((t,e)=>{h||(h=t,d=e,b.call(this));}),void 0,!1,y):d={},b.call(this);}}function ry(t,e,r){const n=new Cs(e);for(const e of t)e.recalculate(n,r);}class ny{constructor(t){this.entries={},this.scheduler=t;}request(t,e,r,n){const i=this.entries[t]=this.entries[t]||{callbacks:[]};if(i.result){const[t,r]=i.result;return this.scheduler?this.scheduler.add((()=>{n(t,r);}),e):n(t,r),()=>{}}return i.callbacks.push(n),i.cancel||(i.cancel=r(((r,n)=>{i.result=[r,n];for(const t of i.callbacks)this.scheduler?this.scheduler.add((()=>{t(r,n);}),e):t(r,n);setTimeout((()=>delete this.entries[t]),3e3);}))),()=>{i.result||(i.callbacks=i.callbacks.filter((t=>t!==n)),i.callbacks.length||(i.cancel(),delete this.entries[t]));}}}function iy(t,e,r){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:\"parseTile\",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=Ct(t.request,((t,n,i,s)=>{t?e(t):n&&e(null,{vectorTile:r?void 0:new yc.VectorTile(new xh(n)),rawData:n,cacheControl:i,expires:s});}));return ()=>{n.cancel(),e();}}),e)}t.ARRAY_TYPE=dl,t.AUTH_ERR_MSG=nt,t.Aabb=eu,t.Actor=class{constructor(t,r,n){this.target=t,this.parent=r,this.mapId=n,this.callbacks={},this.cancelCallbacks={},k([\"receive\"],this),this.target.addEventListener(\"message\",this.receive,!1),this.globalScope=D()?t:e,this.scheduler=new fd;}send(t,e,r,n,i=!1,s){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);r&&(r.metadata=s,this.callbacks[a]=r);const o=L(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!r,targetMapId:n,mustQueue:i,sourceMapId:this.mapId,data:Fi(e,o)},o),{cancel:()=>{r&&delete this.callbacks[a],this.target.postMessage({id:a,type:\"\",targetMapId:n,sourceMapId:this.mapId});}}}receive(t){const e=t.data,r=e.id;if(r&&(!e.targetMapId||this.mapId===e.targetMapId))if(\"\"===e.type){const t=this.cancelCallbacks[r];delete this.cancelCallbacks[r],t&&t.cancel();}else if(e.mustQueue||D()){const t=this.callbacks[r];this.cancelCallbacks[r]=this.scheduler.add((()=>this.processTask(r,e)),t&&t.metadata||{type:\"message\"});}else this.processTask(r,e);}processTask(t,e){if(\"\"===e.type){const r=this.callbacks[t];delete this.callbacks[t],r&&(e.error?r(Li(e.error)):r(null,Li(e.data)));}else {const r=L(this.globalScope)?void 0:[],n=e.hasCallback?(e,n)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:\"\",sourceMapId:this.mapId,error:e?Fi(e):null,data:Fi(n,r)},r);}:t=>{},i=Li(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,i,n);else if(this.parent.getWorkerSource){const t=e.type.split(\".\");this.parent.getWorkerSource(e.sourceMapId,t[0],i.source)[t[1]](i,n);}else n(new Error(`Could not find function ${e.type}`));}}remove(){this.scheduler.remove(),this.target.removeEventListener(\"message\",this.receive,!1);}},t.CanonicalTileID=Dc,t.Color=xe,t.ColorMode=Od,t.CullFaceMode=Gd,t.DEMData=Ld,t.DataConstantProperty=$s,t.DedupedRequest=ny,t.DepthMode=Ud,t.EXTENT=wo,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(!e||t.y<0||t.y>1)return !1;const r=e.getSource().maxzoom,n=1<1)return e;const i=n.getSource().maxzoom,s=1<{const s=this.getAtTileOffset(t,i.x,i.y),a=n.upVector(t.canonical,i.x,i.y);return Vl(a,a,s*n.upVectorScale(t.canonical,e,r).metersToTile),a}}getForTilePoints(t,e,r,n){const i=Yd.create(this,t,n);return !!i&&(e.forEach((t=>{t[2]=this.exaggeration()*i.getElevationAt(t[0],t[1],r);})),!0)}getMinMaxForTile(t){const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const r=e.dem.tree,n=e.tileID,i=1<this._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!it(t))return t;const r=ot(t);return r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!it(t))return t;const r=ot(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||e)}normalizeSourceURL(t,e,r,n){if(!it(t))return t;const i=ot(t);return i.path=`/v4/${i.authority}.json`,i.params.push(\"secure\"),r&&i.params.push(`language=${r}`),n&&i.params.push(`worldview=${n}`),this._makeAPIURL(i,this._customAccessToken||e)}normalizeSpriteURL(t,e,r,n){const i=ot(t);return it(t)?(i.path=`/styles/v1${i.path}/sprite${e}${r}`,this._makeAPIURL(i,this._customAccessToken||n)):(i.path+=`${e}${r}`,lt(i))}normalizeTileURL(t,e,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!it(t))return t;const n=ot(t);n.path=n.path.replace(/(\\.(png|jpg)\\d*)(?=$)/,`${e||r&&\"raster\"!==n.authority&&512===r?\"@2x\":\"\"}${Y.supported?\".webp\":\"$1\"}`),\"raster\"===n.authority?n.path=`/${H.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\\/v4\\//,\"/\"),n.path=`/${H.TILE_URL_VERSION}${n.path}`);const i=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(n.params)||H.ACCESS_TOKEN;return H.REQUIRE_ACCESS_TOKEN&&i&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,i)}canonicalizeTileURL(t,e){const r=ot(t);if(!r.path.match(/^(\\/v4\\/|\\/raster\\/v1\\/)/)||!r.path.match(/\\.[\\w]+$/))return t;let n=\"mapbox://\";r.path.match(/^\\/raster\\/v1\\//)?n+=`raster/${r.path.replace(`/${H.RASTER_URL_PREFIX}/`,\"\")}`:n+=`tiles/${r.path.replace(`/${H.TILE_URL_VERSION}/`,\"\")}`;let i=r.params;return e&&(i=i.filter((t=>!t.match(/^access_token=/)))),i.length&&(n+=`?${i.join(\"&\")}`),n}canonicalizeTileset(t,e){const r=!!e&&it(e),n=[];for(const e of t.tiles||[])st(e)?n.push(this.canonicalizeTileURL(e,r)):n.push(e);return n}_makeAPIURL(t,e){const r=\"See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes\",n=ot(H.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,\"http\"===t.protocol){const e=t.params.indexOf(\"secure\");e>=0&&t.params.splice(e,1);}if(\"/\"!==n.path&&(t.path=`${n.path}${t.path}`),!H.REQUIRE_ACCESS_TOKEN)return lt(t);if(e=e||H.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if(\"s\"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter((t=>-1===t.indexOf(\"access_token\"))),t.params.push(`access_token=${e||\"\"}`),lt(t)}},t.ResourceType=zt,t.SegmentVector=_o,t.SourceCache=Zd,t.StencilMode=$d,t.StructArrayLayout1ui2=wa,t.StructArrayLayout2f1f2i16=pa,t.StructArrayLayout2i4=Qs,t.StructArrayLayout2ui4=_a,t.StructArrayLayout3f12=da,t.StructArrayLayout3ui6=ya,t.StructArrayLayout4i8=ea,t.StructArrayLayout5f20=va,t.Texture=cd,t.Tile=Id,t.Transitionable=Vs,t.Uniform1f=Wa,t.Uniform1i=class extends Ya{constructor(t){super(t),this.current=0;}set(t,e,r){this.fetchUniformLocation(t,e)&&this.current!==r&&(this.current=r,this.gl.uniform1i(this.location,r));}},t.Uniform2f=class extends Ya{constructor(t){super(t),this.current=[0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]||(this.current=r,this.gl.uniform2f(this.location,r[0],r[1])));}},t.Uniform3f=class extends Ya{constructor(t){super(t),this.current=[0,0,0];}set(t,e,r){this.fetchUniformLocation(t,e)&&(r[0]===this.current[0]&&r[1]===this.current[1]&&r[2]===this.current[2]||(this.current=r,this.gl.uniform3f(this.location,r[0],r[1],r[2])));}},t.Uniform4f=Ja,t.UniformColor=Qa,t.UniformMatrix2f=class extends Ya{constructor(t){super(t),this.current=ro;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<4;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix2fv(this.location,!1,r);break}}},t.UniformMatrix3f=class extends Ya{constructor(t){super(t),this.current=eo;}set(t,e,r){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix3fv(this.location,!1,r);break}}},t.UniformMatrix4f=class extends Ya{constructor(t){super(t),this.current=to;}set(t,e,r){if(this.fetchUniformLocation(t,e)){if(r[12]!==this.current[12]||r[0]!==this.current[0])return this.current=r,void this.gl.uniformMatrix4fv(this.location,!1,r);for(let t=1;t<16;t++)if(r[t]!==this.current[t]){this.current=r,this.gl.uniformMatrix4fv(this.location,!1,r);break}}}},t.UnwrappedTileID=Vc,t.ValidationError=qn,t.VectorTileWorkerSource=class extends Nt{constructor(t,e,r,n,i){super(),this.actor=t,this.layerIndex=e,this.availableImages=r,this.loadVectorData=i||iy,this.loading={},this.loaded={},this.deduped=new ny(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler;}loadTile(t,e){const r=t.uid,n=t&&t.request,i=n&&n.collectResourceTiming,s=this.loading[r]=new ey(t);s.abort=this.loadVectorData(t,((a,o)=>{const l=!this.loading[r];if(delete this.loading[r],l||a||!o)return s.status=\"done\",l||(this.loaded[r]=s),e(a);const u=o.rawData,c={};o.expires&&(c.expires=o.expires),o.cacheControl&&(c.cacheControl=o.cacheControl),s.vectorTile=o.vectorTile||new yc.VectorTile(new xh(u));const h=()=>{s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,r)=>{if(t||!r)return e(t);const s={};if(i){const t=$(n);t.length>0&&(s.resourceTiming=JSON.parse(JSON.stringify(t)));}e(null,v({rawTileData:u.slice(0)},r,c,s));}));};this.isSpriteLoaded?h():this.once(\"isSpriteLoaded\",(()=>{this.scheduler?this.scheduler.add(h,{type:\"parseTile\",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h();})),this.loaded=this.loaded||{},this.loaded[r]=s;}));}reloadTile(t,e){const r=this.loaded,n=t.uid,i=this;if(r&&r[n]){const s=r[n];s.showCollisionBoxes=t.showCollisionBoxes,s.enableTerrain=!!t.enableTerrain,s.projection=t.projection,s.tileTransform=Af(t.tileID.canonical,t.projection);const a=(t,r)=>{const n=s.reloadCallback;n&&(delete s.reloadCallback,s.parse(s.vectorTile,i.layerIndex,this.availableImages,i.actor,n)),e(t,r);};\"parsing\"===s.status?s.reloadCallback=a:\"done\"===s.status&&(s.vectorTile?s.parse(s.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a());}}abortTile(t,e){const r=t.uid,n=this.loading[r];n&&(n.abort&&n.abort(),delete this.loading[r]),e();}removeTile(t,e){const r=this.loaded,n=t.uid;r&&r[n]&&delete r[n],e();}},t.WritingMode=Nh,t.ZoomHistory=Ri,t.add=Bl,t.addDynamicAttributes=Hf,t.adjoint=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],u=e[7],c=e[8];return t[0]=a*c-o*u,t[1]=i*u-n*c,t[2]=n*o-i*a,t[3]=o*l-s*c,t[4]=r*c-i*l,t[5]=i*s-r*o,t[6]=s*u-a*l,t[7]=n*l-r*u,t[8]=r*a-n*s,t},t.asyncAll=g,t.bezier=p,t.bindAll=k,t.boundsAttributes=Sd,t.bufferConvexPolygon=function(t,e){const r=[];for(let n=0;nbt&&(t.getActor().send(\"enforceCacheSizeLimit\",vt),Mt=0);},t.calculateGlobeLabelMatrix=function(t,e){const{x:r,y:n}=t.point,i=mf(r,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return xl(i,i,yf(rf(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:r}=t.point,{lng:n,lat:i}=t._center;return mf(e,r,t.worldSize,n,i)},t.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,r=e/Bo(1,t.center.lat),n=ml(new Float64Array(16));return vl(n,n,[t.point.x,t.point.y,0]),bl(n,n,[r,r,e]),Float32Array.from(n)},t.circumferenceAtLatitude=Mo,t.clamp=d,t.clearTileCache=function(t){const e=At(),r=[];for(const t in _t)e&&r.push(e.delete(t)),delete _t[t];t&&Promise.all(r).catch(t).then((()=>t()));},t.clipLine=dp,t.clone=function(t){var e=new dl(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.clone$1=T,t.collisionCircleLayout=sh,t.config=H,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new dl(16);return dl!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.create$1=yl,t.createExpression=Ln,t.createLayout=Ws,t.createStyleLayer=function(t){return \"custom\"===t.type?new ad(t):new ud[t.type](t)},t.cross=Ul,t.degToRad=l,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t},t.dot=Rl,t.ease=f,t.easeCubicInOut=h,t.emitValidationErrors=Ti,t.endsWith=I,t.enforceCacheSizeLimit=function(t){for(const e in _t)St(e),_t[e].then((e=>{e.keys().then((r=>{for(let n=0;ns&&(n+=(t[i]-s)*(t[i]-s)),e[i]{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],r=ml(new Float64Array(16));return xl(r,t.pixelMatrix,t.globeMatrix),jl(e,e,r),new i(e[0],e[1])},t.globeDenormalizeECEF=yf,t.globeECEFOrigin=function(t,e){const r=[0,0,0];return jl(r,r,df(rf(e.canonical))),jl(r,r,t),r},t.globeNormalizeECEF=df,t.globePixelsToTileUnits=function(t,e){return wo/(512*Math.pow(2,t))*pf(rf(e))},t.globePoleMatrixForTile=function(t,e,r){const n=ml(new Float64Array(16)),i=(e/(1<0;return 0===n&&!i&&!a&&s},t.identity=ml,t.identity$1=Hl,t.invert=gl,t.isFullscreen=function(){return !!e.document.fullscreenElement||!!e.document.webkitFullscreenElement},t.isLngLatBehindGlobe=function(t,e){return xf(t,e)>Math.PI/2*1.01},t.isMapAuthenticated=function(t){return gt.has(t)},t.isMapboxURL=it,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return !!L(t)&&e&&(e.match(\"Version/15.4\")||e.match(\"Version/15.5\")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Co,t.len=Gl,t.length=zl,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.loadVectorTile=iy,t.makeRequest=Et,t.mapValue=function(t,e,r,n,i){return d((t-e)/(r-e)*(i-n)+n,n,i)},t.mercatorScale=Vo,t.mercatorXfromLng=zo,t.mercatorYfromLat=To,t.mercatorZfromAltitude=Bo,t.mul=kl,t.mul$1=Nl,t.multiply=xl,t.multiply$1=function(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],u=e[6],c=e[7],h=e[8],p=r[0],f=r[1],d=r[2],y=r[3],m=r[4],g=r[5],x=r[6],v=r[7],b=r[8];return t[0]=p*n+f*a+d*u,t[1]=p*i+f*o+d*c,t[2]=p*s+f*l+d*h,t[3]=y*n+m*a+g*u,t[4]=y*i+m*o+g*c,t[5]=y*s+m*l+g*h,t[6]=x*n+v*a+b*u,t[7]=x*i+v*o+b*c,t[8]=x*s+v*l+b*h,t},t.multiply$2=Cl,t.nextPowerOfTwo=A,t.normalize=Ll,t.normalize$1=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r*r+n*n+i*i+s*s;return a>0&&(a=1/Math.sqrt(a)),t[0]=r*a,t[1]=n*a,t[2]=i*a,t[3]=s*a,t},t.number=xr,t.ortho=function(t,e,r,n,i,s,a){var o=1/(e-r),l=1/(n-i),u=1/(s-a);return t[0]=-2*o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*u,t[11]=0,t[12]=(e+r)*o,t[13]=(i+n)*l,t[14]=(a+s)*u,t[15]=1,t},t.pbf=xh,t.perspective=function(t,e,r,n,i){var s,a=1/Math.tan(e/2);return t[0]=a/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=i&&i!==1/0?(t[10]=(i+n)*(s=1/(n-i)),t[14]=2*i*n*s):(t[10]=-1,t[14]=-2*n),t},t.pick=function(t,e){const r={};for(let n=0;nzi(ci(t)),t.validateFog=t=>zi(_i(t)),t.validateLayer=t=>zi(yi(t)),t.validateLight=t=>zi(vi(t)),t.validateSource=t=>zi(xi(t)),t.validateStyle=ki,t.validateTerrain=t=>zi(bi(t)),t.values=x,t.vectorTile=yc,t.version=O,t.warnOnce=E,t.window=e,t.wrap=m;}));\n\ndefine([\"./shared\"],(function(e){\"use strict\";function t(e){if(\"number\"==typeof e||\"boolean\"==typeof e||\"string\"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let r=\"[\";for(const o of e)r+=`${t(o)},`;return `${r}]`}let r=\"{\";for(const o of Object.keys(e).sort())r+=`${o}:${t(e[o])},`;return `${r}}`}function r(r){let o=\"\";for(const n of e.refProperties)o+=`/${t(r[n])}`;return o}class o{constructor(e){this.keyCache={},e&&this.replace(e);}replace(e){this._layerConfigs={},this._layers={},this.update(e,[]);}update(t,o){for(const r of t)this._layerConfigs[r.id]=r,(this._layers[r.id]=e.createStyleLayer(r)).compileFilter(),this.keyCache[r.id]&&delete this.keyCache[r.id];for(const e of o)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=function(e,t){const o={};for(let n=0;nthis._layers[e.id])),r=t[0];if(\"none\"===r.visibility)continue;const o=r.source||\"\";let n=this.familiesBySource[o];n||(n=this.familiesBySource[o]={});const i=r.sourceLayer||\"_geojsonTileLayer\";let s=n[i];s||(s=n[i]=[]),s.push(t);}}}class n{loadTile(t,r){const{uid:o,encoding:n,rawImageData:i,padding:s,buildQuadTree:a}=t,l=e.window.ImageBitmap&&i instanceof e.window.ImageBitmap?this.getImageData(i,s):i;r(null,new e.DEMData(o,l,n,s<1,a));}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext(\"2d\")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const r=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),r}}var i=function e(t,r){var o,n=t&&t.type;if(\"FeatureCollection\"===n)for(o=0;o=Math.abs(a)?r-l+a:a-l+r,r=l;}r+o>=0!=!!t&&e.reverse();}const l=e.vectorTile.VectorTileFeature.prototype.toGeoJSON;class u{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,\"id\"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10));}loadGeometry(){if(1===this._feature.type){const t=[];for(const r of this._feature.geometry)t.push([new e.pointGeometry(r[0],r[1])]);return t}{const t=[];for(const r of this._feature.geometry){const o=[];for(const t of r)o.push(new e.pointGeometry(t[0],t[1]));t.push(o);}return t}}toGeoJSON(e,t,r){return l.call(this,e,t,r)}}class h{constructor(t){this.layers={_geojsonTileLayer:this},this.name=\"_geojsonTileLayer\",this.extent=e.EXTENT,this.length=t.length,this._features=t;}feature(e){return new u(this._features[e])}}var c=e.vectorTile.VectorTileFeature,f=p;function p(e,t){this.options=t||{},this.features=e,this.length=e.length;}function g(e,t){this.id=\"number\"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096;}p.prototype.feature=function(e){return new g(this.features[e],this.options.extent)},g.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var r=0;r>31}function P(e,t){for(var r=e.loadGeometry(),o=e.type,n=0,i=0,s=r.length,a=0;a>1;k(e,t,s,o,n,i%2),T(e,t,r,o,s-1,i+1),T(e,t,r,s+1,n,i+1);}function k(e,t,r,o,n,i){for(;n>o;){if(n-o>600){const s=n-o+1,a=r-o+1,l=Math.log(s),u=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*u*(s-u)/s)*(a-s/2<0?-1:1);k(e,t,r,Math.max(o,Math.floor(r-a*u/s+h)),Math.min(n,Math.floor(r+(s-a)*u/s+h)),i);}const s=t[2*r+i];let a=o,l=n;for(I(e,t,o,r),t[2*n+i]>s&&I(e,t,o,n);as;)l--;}t[2*o+i]===s?I(e,t,o,l):(l++,I(e,t,l,n)),l<=r&&(o=l+1),r<=l&&(n=l-1);}}function I(e,t,r,o){_(e,r,o),_(t,2*r,2*o),_(t,2*r+1,2*o+1);}function _(e,t,r){const o=e[t];e[t]=e[r],e[r]=o;}function L(e,t,r,o){const n=e-r,i=t-o;return n*n+i*i}d.fromVectorTileJs=y,d.fromGeojsonVt=function(e,t){t=t||{};var r={};for(var o in e)r[o]=new f(e[o].features,t),r[o].name=o,r[o].version=t.version,r[o].extent=t.extent;return y({layers:r})},d.GeoJSONWrapper=m;const C=e=>e[0],O=e=>e[1];class z{constructor(e,t=C,r=O,o=64,n=Float64Array){this.nodeSize=o,this.points=e;const i=e.length<65536?Uint16Array:Uint32Array,s=this.ids=new i(e.length),a=this.coords=new n(2*e.length);for(let o=0;o=r&&u<=n&&h>=o&&h<=i&&l.push(e[s]);continue}const g=Math.floor((p+f)/2);u=t[2*g],h=t[2*g+1],u>=r&&u<=n&&h>=o&&h<=i&&l.push(e[g]);const d=(c+1)%2;(0===c?r<=u:o<=h)&&(a.push(p),a.push(g-1),a.push(d)),(0===c?n>=u:i>=h)&&(a.push(g+1),a.push(f),a.push(d));}return l}(this.ids,this.coords,e,t,r,o,this.nodeSize)}within(e,t,r){return function(e,t,r,o,n,i){const s=[0,e.length-1,0],a=[],l=n*n;for(;s.length;){const u=s.pop(),h=s.pop(),c=s.pop();if(h-c<=i){for(let n=c;n<=h;n++)L(t[2*n],t[2*n+1],r,o)<=l&&a.push(e[n]);continue}const f=Math.floor((c+h)/2),p=t[2*f],g=t[2*f+1];L(p,g,r,o)<=l&&a.push(e[f]);const d=(u+1)%2;(0===u?r-n<=p:o-n<=g)&&(s.push(c),s.push(f-1),s.push(d)),(0===u?r+n>=p:o+n>=g)&&(s.push(f+1),s.push(h),s.push(d));}return a}(this.ids,this.coords,e,t,r,this.nodeSize)}}const E={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},F=Math.fround||(N=new Float32Array(1),e=>(N[0]=+e,N[0]));var N;class j{constructor(e){this.options=A(Object.create(E),e),this.trees=new Array(this.options.maxZoom+1);}load(e){const{log:t,minZoom:r,maxZoom:o,nodeSize:n}=this.options;t&&console.time(\"total time\");const i=`prepare ${e.length} points`;t&&console.time(i),this.points=e;let s=[];for(let t=0;t=r;e--){const r=+Date.now();s=this._cluster(s,e),this.trees[e]=new z(s,D,$,n,Float32Array),t&&console.log(\"z%d: %d clusters in %dms\",e,s.length,+Date.now()-r);}return t&&console.timeEnd(\"total time\"),this}getClusters(e,t){let r=((e[0]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const i=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)r=-180,n=180;else if(r>n){const e=this.getClusters([r,o,180,i],t),s=this.getClusters([-180,o,n,i],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(Y(r),X(i),Y(n),X(o)),l=[];for(const e of a){const t=s.points[e];l.push(t.numPoints?J(t):this.points[t.index]);}return l}getChildren(e){const t=this._getOriginId(e),r=this._getOriginZoom(e),o=\"No cluster with the specified id.\",n=this.trees[r];if(!n)throw new Error(o);const i=n.points[t];if(!i)throw new Error(o);const s=this.options.radius/(this.options.extent*Math.pow(2,r-1)),a=n.within(i.x,i.y,s),l=[];for(const t of a){const r=n.points[t];r.parentId===e&&l.push(r.numPoints?J(r):this.points[r.index]);}if(0===l.length)throw new Error(o);return l}getLeaves(e,t,r){const o=[];return this._appendLeaves(o,e,t=t||10,r=r||0,0),o}getTile(e,t,r){const o=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:i,radius:s}=this.options,a=s/i,l=(r-a)/n,u=(r+1+a)/n,h={features:[]};return this._addTileFeatures(o.range((t-a)/n,l,(t+1+a)/n,u),o.points,t,r,n,h),0===t&&this._addTileFeatures(o.range(1-a/n,l,1,u),o.points,n,r,n,h),t===n-1&&this._addTileFeatures(o.range(0,l,a/n,u),o.points,-1,r,n,h),h.features.length?h:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const r=this.getChildren(e);if(t++,1!==r.length)break;e=r[0].properties.cluster_id;}return t}_appendLeaves(e,t,r,o,n){const i=this.getChildren(t);for(const t of i){const i=t.properties;if(i&&i.cluster?n+i.point_count<=o?n+=i.point_count:n=this._appendLeaves(e,i.cluster_id,r,o,n):nt&&(c+=r.numPoints||1);}if(c>h&&c>=s){let e=n.x*h,s=n.y*h,a=i&&h>1?this._map(n,!0):null;const f=(o<<5)+(t+1)+this.points.length;for(const r of u){const o=l.points[r];if(o.zoom<=t)continue;o.zoom=t;const u=o.numPoints||1;e+=o.x*u,s+=o.y*u,o.parentId=f,i&&(a||(a=this._map(n,!0)),i(a,this._map(o)));}n.parentId=f,r.push(Z(e/c,s/c,f,c,a));}else if(r.push(n),c>1)for(const e of u){const o=l.points[e];o.zoom<=t||(o.zoom=t,r.push(o));}}return r}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return (e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?A({},e.properties):e.properties;const r=this.points[e.index].properties,o=this.options.map(r);return t&&o===r?A({},o):o}}function Z(e,t,r,o,n){return {x:F(e),y:F(t),zoom:1/0,id:r,parentId:-1,numPoints:o,properties:n}}function G(e,t){const[r,o]=e.geometry.coordinates;return {x:F(Y(r)),y:F(X(o)),zoom:1/0,index:t,parentId:-1}}function J(e){return {type:\"Feature\",id:e.id,properties:W(e),geometry:{type:\"Point\",coordinates:[(t=e.x,360*(t-.5)),V(e.y)]}};var t;}function W(e){const t=e.numPoints,r=t>=1e4?`${Math.round(t/1e3)}k`:t>=1e3?Math.round(t/100)/10+\"k\":t;return A(A({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:r})}function Y(e){return e/360+.5}function X(e){const t=Math.sin(e*Math.PI/180),r=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return r<0?0:r>1?1:r}function V(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function A(e,t){for(const r in t)e[r]=t[r];return e}function D(e){return e.x}function $(e){return e.y}function B(e,t,r,o){for(var n,i=o,s=r-t>>1,a=r-t,l=e[t],u=e[t+1],h=e[r],c=e[r+1],f=t+3;fi)n=f,i=p;else if(p===i){var g=Math.abs(f-s);go&&(n-t>3&&B(e,t,n,o),e[n+2]=i,r-n>3&&B(e,n,r,o));}function R(e,t,r,o,n,i){var s=n-r,a=i-o;if(0!==s||0!==a){var l=((e-r)*s+(t-o)*a)/(s*s+a*a);l>1?(r=n,o=i):l>0&&(r+=s*l,o+=a*l);}return (s=e-r)*s+(a=t-o)*a}function q(e,t,r,o){var n={id:void 0===e?null:e,type:t,geometry:r,tags:o,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,r=e.type;if(\"Point\"===r||\"MultiPoint\"===r||\"LineString\"===r)U(e,t);else if(\"Polygon\"===r||\"MultiLineString\"===r)for(var o=0;o0&&(s+=o?(n*u-l*i)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(u-i,2))),n=l,i=u;}var h=t.length-3;t[2]=1,B(t,0,h,r),t[h+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size;}function ee(e,t,r,o){for(var n=0;n1?1:r}function oe(e,t,r,o,n,i,s,a){if(o/=t,i>=(r/=t)&&s=o)return null;for(var l=[],u=0;u=r&&g=o)){var d=[];if(\"Point\"===f||\"MultiPoint\"===f)ne(c,d,r,o,n);else if(\"LineString\"===f)ie(c,d,r,o,n,!1,a.lineMetrics);else if(\"MultiLineString\"===f)ae(c,d,r,o,n,!1);else if(\"Polygon\"===f)ae(c,d,r,o,n,!0);else if(\"MultiPolygon\"===f)for(var m=0;m=r&&s<=o&&(t.push(e[i]),t.push(e[i+1]),t.push(e[i+2]));}}function ie(e,t,r,o,n,i,s){for(var a,l,u=se(e),h=0===n?ue:he,c=e.start,f=0;fr&&(l=h(u,p,g,m,y,r),s&&(u.start=c+a*l)):v>o?x=r&&(l=h(u,p,g,m,y,r),w=!0),x>o&&v<=o&&(l=h(u,p,g,m,y,o),w=!0),!i&&w&&(s&&(u.end=c+a*l),t.push(u),u=se(e)),s&&(c+=a);}var S=e.length-3;p=e[S],g=e[S+1],d=e[S+2],(v=0===n?p:g)>=r&&v<=o&&le(u,p,g,d),S=u.length-3,i&&S>=3&&(u[S]!==u[0]||u[S+1]!==u[1])&&le(u,u[0],u[1],u[2]),u.length&&t.push(u);}function se(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function ae(e,t,r,o,n,i){for(var s=0;ss.maxX&&(s.maxX=h),c>s.maxY&&(s.maxY=c);}return s}function me(e,t,r,o){var n=t.geometry,i=t.type,s=[];if(\"Point\"===i||\"MultiPoint\"===i)for(var a=0;a0&&t.size<(n?s:o))r.numPoints+=t.length/3;else {for(var a=[],l=0;ls)&&(r.numSimplified++,a.push(t[l]),a.push(t[l+1])),r.numPoints++;n&&function(e,t){for(var r=0,o=0,n=e.length,i=n-2;o0===t)for(o=0,n=e.length;o24)throw new Error(\"maxZoom should be in the 0-24 range\");if(t.promoteId&&t.generateId)throw new Error(\"promoteId and generateId cannot be used together.\");var o=function(e,t){var r=[];if(\"FeatureCollection\"===e.type)for(var o=0;o1&&console.time(\"creation\"),f=this.tiles[c]=de(e,t,r,o,l),this.tileCoords.push({z:t,x:r,y:o}),u)){u>1&&(console.log(\"tile z%d-%d-%d (features: %d, points: %d, simplified: %d)\",t,r,o,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd(\"creation\"));var p=\"z\"+t;this.stats[p]=(this.stats[p]||0)+1,this.total++;}if(f.source=e,n){if(t===l.maxZoom||t===n)continue;var g=1<1&&console.time(\"clipping\");var d,m,y,v,x,w,S=.5*l.buffer/l.extent,M=.5-S,P=.5+S,b=1+S;d=m=y=v=null,x=oe(e,h,r-S,r+P,0,f.minX,f.maxX,l),w=oe(e,h,r+M,r+b,0,f.minX,f.maxX,l),e=null,x&&(d=oe(x,h,o-S,o+P,1,f.minY,f.maxY,l),m=oe(x,h,o+M,o+b,1,f.minY,f.maxY,l),x=null),w&&(y=oe(w,h,o-S,o+P,1,f.minY,f.maxY,l),v=oe(w,h,o+M,o+b,1,f.minY,f.maxY,l),w=null),u>1&&console.timeEnd(\"clipping\"),a.push(d||[],t+1,2*r,2*o),a.push(m||[],t+1,2*r,2*o+1),a.push(y||[],t+1,2*r+1,2*o),a.push(v||[],t+1,2*r+1,2*o+1);}}},ve.prototype.getTile=function(e,t,r){var o=this.options,n=o.extent,i=o.debug;if(e<0||e>24)return null;var s=1<1&&console.log(\"drilling down to z%d-%d-%d\",e,t,r);for(var l,u=e,h=t,c=r;!l&&u>0;)u--,h=Math.floor(h/2),c=Math.floor(c/2),l=this.tiles[xe(u,h,c)];return l&&l.source?(i>1&&console.log(\"found parent tile z%d-%d-%d\",u,h,c),i>1&&console.time(\"drilling down\"),this.splitTile(l.source,u,h,c,e,t,r),i>1&&console.timeEnd(\"drilling down\"),this.tiles[a]?pe(this.tiles[a],n):null):null};class Se extends e.VectorTileWorkerSource{constructor(e,t,r,o,n){super(e,t,r,o,we),n&&(this.loadGeoJSON=n);}loadData(t,r){const o=t&&t.request,n=o&&o.collectResourceTiming;this.loadGeoJSON(t,((s,a)=>{if(s||!a)return r(s);if(\"object\"!=typeof a)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{i(a,!0);try{if(t.filter){const r=e.createExpression(t.filter,{type:\"boolean\",\"property-type\":\"data-driven\",overridable:!1,transition:!1});if(\"error\"===r.result)throw new Error(r.value.map((e=>`${e.key}: ${e.message}`)).join(\", \"));const o=a.features.filter((e=>r.value.evaluate({zoom:0},e)));a={type:\"FeatureCollection\",features:o};}this._geoJSONIndex=t.cluster?new j(function({superclusterOptions:t,clusterProperties:r}){if(!r||!t)return t;const o={},n={},i={accumulated:null,zoom:0},s={properties:null},a=Object.keys(r);for(const t of a){const[i,s]=r[t],a=e.createExpression(s),l=e.createExpression(\"string\"==typeof i?[i,[\"accumulated\"],[\"get\",t]]:i);o[t]=a.value,n[t]=l.value;}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=o[e].evaluate(i,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)i.accumulated=e[t],e[t]=n[t].evaluate(i,s);},t}(t)).load(a.features):function(e,t){return new ve(e,t)}(a,t.geojsonVtOptions);}catch(s){return r(s)}this.loaded={};const l={};if(n){const r=e.getPerformanceMeasurement(o);r&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(r)));}r(null,l);}}));}reloadTile(e,t){const r=this.loaded;return r&&r[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,r){if(t.request)e.getJSON(t.request,r);else {if(\"string\"!=typeof t.data)return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return r(null,JSON.parse(t.data))}catch(e){return r(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId));}catch(e){t(e);}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId));}catch(e){t(e);}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset));}catch(e){t(e);}}}class Me{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:\"mercator\"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:Se},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name \"${e}\" already registered.`);this.workerSourceTypes[e]=t;},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error(\"RTL text plugin already registered.\");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText;};}clearCaches(e,t,r){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],r();}checkIfReady(e,t,r){r();}setReferrer(e,t){this.referrer=t;}spriteLoaded(t,r){this.isSpriteLoaded[t]=r;for(const o in this.workerSources[t]){const n=this.workerSources[t][o];for(const t in n)n[t]instanceof e.VectorTileWorkerSource&&(n[t].isSpriteLoaded=r,n[t].fire(new e.Event(\"isSpriteLoaded\")));}}setImages(e,t,r){this.availableImages[e]=t;for(const r in this.workerSources[e]){const o=this.workerSources[e][r];for(const e in o)o[e].availableImages=t;}r();}enableTerrain(e,t,r){this.terrain=t,r();}setProjection(t,r){this.projections[t]=e.getProjection(r);}setLayers(e,t,r){this.getLayerIndex(e).replace(t),r();}updateLayers(e,t,r){this.getLayerIndex(e).update(t.layers,t.removedIds),r();}loadTile(t,r,o){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},r):r;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,r.type,r.source).loadTile(n,o);}loadDEMTile(t,r,o){const n=this.enableTerrain?e.extend({buildQuadTree:this.terrain},r):r;this.getDEMWorkerSource(t,r.source).loadTile(n,o);}reloadTile(t,r,o){const n=this.enableTerrain?e.extend({enableTerrain:this.terrain},r):r;n.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,r.type,r.source).reloadTile(n,o);}abortTile(e,t,r){this.getWorkerSource(e,t.type,t.source).abortTile(t,r);}removeTile(e,t,r){this.getWorkerSource(e,t.type,t.source).removeTile(t,r);}removeSource(e,t,r){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const o=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==o.removeSource?o.removeSource(t,r):r();}loadWorkerSource(e,t,r){try{this.self.importScripts(t.url),r();}catch(e){r(e.toString());}}syncRTLPluginState(t,r,o){try{e.plugin.setState(r);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const r=e.plugin.isParsed();o(r?void 0:new Error(`RTL Text Plugin failed to import scripts from ${t}`),r);}}catch(e){o(e.toString());}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new o),t}getWorkerSource(e,t,r){return this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),this.workerSources[e][t][r]||(this.workerSources[e][t][r]=new this.workerSourceTypes[t]({send:(t,r,o,n,i,s)=>{this.actor.send(t,r,o,e,i,s);},scheduler:this.actor.scheduler},this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])),this.workerSources[e][t][r]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new n),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,r){e.enforceCacheSizeLimit(r);}getWorkerPerformanceMetrics(e,t,r){r(void 0,void 0);}}return \"undefined\"!=typeof WorkerGlobalScope&&\"undefined\"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new Me(self)),Me}));\n\ndefine([\"./shared\"],(function(e){\"use strict\";function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return !1;for(let o=0;o{e.window.removeEventListener(\"click\",_,!0);}),0);}function p(e,t){const i=e.getBoundingClientRect();return g(e,i,t)}function m(e,t){const i=e.getBoundingClientRect(),o=[];for(let r=0;r=0?0:t.button}function g(t,i,o){const r=t.offsetWidth===i.width?1:t.offsetWidth/i.width;return new e.pointGeometry((o.clientX-i.left)*r,(o.clientY-i.top)*r)}function v(e,t){var i=t[0],o=t[1],r=t[2],n=t[3],a=i*n-r*o;return a?(e[0]=n*(a=1/a),e[1]=-o*a,e[2]=-r*a,e[3]=i*a,e):null}function x(e){const{userImage:t}=e;return !!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class y extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0;}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[];}}hasImage(e){return !!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t);}_validate(t,i){let o=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image \"${t}\" has invalid \"stretchX\" value`))),o=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image \"${t}\" has invalid \"stretchY\" value`))),o=!1),this._validateContent(i.content,i)||(this.fire(new e.ErrorEvent(new Error(`Image \"${t}\" has invalid \"content\" value`))),o=!1),o}_validateStretch(e,t){if(!e)return !0;let i=0;for(const o of e){if(o[0]{this.ready=!0;}));}broadcast(t,i,o){e.asyncAll(this.actors,((e,o)=>{e.send(t,i,o);}),o=o||function(){});}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((e=>{e.remove();})),this.actors=[],this.workerPool.release(this.id);}}function L(t,i,o){return i*(e.EXTENT/(t.tileSize*Math.pow(2,o-t.tileID.overscaledZ)))}A.Actor=e.Actor;class R{constructor(e,t,i,o){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,o);}static createFromScreenPoints(t,i){let o,r;if(t instanceof e.pointGeometry||\"number\"==typeof t[0]){const n=e.pointGeometry.convert(t);o=[e.pointGeometry.convert(t)],r=i.isPointAboveHorizon(n);}else {const n=e.pointGeometry.convert(t[0]),a=e.pointGeometry.convert(t[1]);o=[n,a],r=e.polygonizeBounds(n,a).every((e=>i.isPointAboveHorizon(e)));}return new R(o,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,o,0,!1);return this.cameraPoint.y>o.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=o.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.bufferConvexPolygon(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],o=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],r=e.polygonizeBounds(i,o,t),n=this.cameraPoint.clone();switch(3*((n.y>i.y)+(n.y>o.y))+((n.x>i.x)+(n.x>o.x))){case 0:r[0]=n,r[4]=n.clone();break;case 1:r.splice(1,0,n);break;case 2:r[1]=n;break;case 3:r.splice(4,0,n);break;case 5:r.splice(2,0,n);break;case 6:r[3]=n;break;case 7:r.splice(3,0,n);break;case 8:r[2]=n;}return r}containsTile(t,i,o,r=0){const n=t.queryPadding/i._pixelsPerMercatorPixel+1,a=o?this._bufferedCameraMercator(n,i):this._bufferedScreenMercator(n,i);let s=t.tileID.wrap+(a.unwrapped?r:0);const l=a.polygon.map((i=>e.getTilePoint(t.tileTransform,i,s)));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>e.getTileVec3(t.tileTransform,i,s))),h=c.map((t=>new e.pointGeometry(t[0],t[1]))),u=i.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),_=e.getTileVec3(t.tileTransform,u,s),d=c.map((t=>{const i=e.sub(t,t,_);return e.normalize(i,i),new e.Ray(_,i)})),p=L(t,1,i.zoom)*i._pixelsPerMercatorPixel;return {queryGeometry:this,tilespaceGeometry:h,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m;}_bufferedScreenMercator(e,t){const i=k(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let o;return o=\"globe\"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._screenRaycastCache[i]=o,o}}_bufferedCameraMercator(e,t){const i=k(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let o;return o=\"globe\"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map((e=>t.pointCoordinate3D(e))),unwrapped:!0},this._cameraRaycastCache[i]=o,o}}_projectAndResample(t,i){const o=function(t,i){const o=e.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-e.GLOBE_RADIUS,0,1],n=[0,e.GLOBE_RADIUS,0,1],a=[0,0,0,1];e.transformMat4$1(r,r,o),e.transformMat4$1(n,n,o),e.transformMat4$1(a,a,o);const s=new e.pointGeometry(r[0]/r[3],r[1]/r[3]),l=new e.pointGeometry(n[0]/n[3],n[1]/n[3]),c=e.polygonContainsPoint(t,s)&&r[3]1?O(t.slice(0,_),i):[],m=_new e.pointGeometry(B(t.x),t.y))),m=m.map((t=>new e.pointGeometry(B(t.x),t.y)));const f=[...p];0===f.length&&f.push(m[m.length-1]);const g=e.number(f[f.length-1].y,(0===m.length?p[0]:m[0]).y,d);let v;return v=c?[new e.pointGeometry(0,g),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,g)]:[new e.pointGeometry(1,g),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,g)],f.push(...v),0===m.length?f.push(p[0]):f.push(...m),{polygon:f.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:!1}}(t,i);if(o)return o;const r=function(t,i){let o=!1,r=-1/0,n=0;for(let e=0;er&&(r=t[e].x,n=e);for(let e=0;e.5&&(r.x{e.x-=1;})),{polygon:t,unwrapped:o}}(O(t,i).map((t=>new e.pointGeometry(B(t.x),t.y))),i);return {polygon:r.polygon.map((t=>new e.MercatorCoordinate(t.x,t.y))),unwrapped:r.unwrapped}}}function O(t,i){return e.resample(t,(e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y;}),1/256)}function B(e){return e<0?1+e%1:e%1}function k(e){return 100*e|0}function F(t,i,o,r,n){const a=function(o,r){if(o)return n(o);if(r){const o=e.pick(e.extend(r,t),[\"tiles\",\"minzoom\",\"maxzoom\",\"attribution\",\"mapbox_logo\",\"bounds\",\"scheme\",\"tileSize\",\"encoding\"]);r.vector_layers&&(o.vectorLayers=r.vector_layers,o.vectorLayerIds=o.vectorLayers.map((e=>e.id))),r.language_options&&(o.languageOptions=r.language_options),r.language&&r.language[r.id]&&(o.language=r.language[r.id]),r.worldview_options&&(o.worldviewOptions=r.worldview_options),r.worldview?o.worldview=r.worldview[r.id]:r.worldview_default&&(o.worldview=r.worldview_default),o.tiles=i.canonicalizeTileset(o,t.url),n(null,o);}};return t.url?e.getJSON(i.transformRequest(i.normalizeSourceURL(t.url,null,o,r),e.ResourceType.Source),a):e.exported.frame((()=>a(null,t)))}class U{constructor(t,i,o){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=i||0,this.maxzoom=o||24;}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),o=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*i),r=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*i),n=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*i),a=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*i);return t.x>=o&&t.x=r&&t.y{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(e.extend(this,i),i.bounds&&(this.tileBounds=new U(i.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(i.tiles),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"})));}));}loaded(){return this._loaded}onAdd(e){this.map=e,this.load();}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}serialize(){return e.extend({},this._options)}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const o=e.exported.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),o,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),((o,r,n,a)=>(delete t.request,t.aborted?(t.state=\"unloaded\",i(null)):o?(t.state=\"errored\",i(o)):r?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:n,expires:a}),t.setTexture(r,this.map.painter),t.state=\"loaded\",e.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))));}static loadTileData(e,t,i){e.setTexture(t,i);}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture);}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t();}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t();}hasTransition(){return !1}}let Se;function ze(t,i,o,r,n,a,s,l){const c=[t,o,n,i,r,a,1,1,1],h=[s,l,1],u=e.adjoint([],c),[_,d,p]=e.transformMat3(h,h,e.transpose(u,u));return e.multiply$1(c,[_,0,0,0,d,0,0,0,p],c)}class De extends e.Evented{constructor(e,t,i,o){super(),this.id=e,this.dispatcher=i,this.coordinates=t.coordinates,this.type=\"image\",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(o),this.options=t;}load(t,i){this._loaded=i||!1,this.fire(new e.Event(\"dataloading\",{dataType:\"source\"})),this.url=this.options.url,e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),((i,o)=>{if(this._loaded=!0,i)this.fire(new e.ErrorEvent(i));else if(o){const{HTMLImageElement:i}=e.window;this.image=o instanceof i?e.exported.getImageData(o):o,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading();}}));}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})));}onAdd(e){this.map=e,this.load();}onRemove(){this.texture&&this.texture.destroy();}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const i=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let i=1/0,o=1/0,r=-1/0,n=-1/0;for(const e of t)i=Math.min(i,e.x),o=Math.min(o,e.y),r=Math.max(r,e.x),n=Math.max(n,e.y);const a=Math.max(r-i,n-o),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,s);return new e.CanonicalTileID(s,Math.floor((i+r)/2*l),Math.floor((o+n)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"})),this}_clear(){this._boundsArray=void 0;}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];\"loaded\"!==t.state&&(t.state=\"loaded\",t.texture=this.texture);}if(this._boundsArray)return;const i=e.tileTransform(this.tileID,this.map.transform.projection),[o,r,n,a]=this.coordinates.map((t=>{const o=i.projection.project(t[0],t[1]);return e.getTilePoint(i,o)._round()}));this.perspectiveTransform=function(t,i,o,r,n,a,s,l,c,h){const u=ze(0,0,t,0,0,i,t,i),_=ze(o,r,n,a,s,l,c,h);return e.multiply$1(_,e.adjoint(u,u),_),[_[6]/_[8]*t/e.EXTENT,_[7]/_[8]*i/e.EXTENT]}(this.width,this.height,o.x,o.y,r.x,r.y,a.x,a.y,n.x,n.y);const s=this._boundsArray=new e.StructArrayLayout4i8;s.emplaceBack(o.x,o.y,0,0),s.emplaceBack(r.x,r.y,e.EXTENT,0),s.emplaceBack(a.x,a.y,0,e.EXTENT),s.emplaceBack(n.x,n.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(s,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._prepareData(t);}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state=\"errored\",t(null));}serialize(){return {type:\"image\",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return !1}}const Pe={vector:class extends e.Evented{constructor(t,i,o,r){if(super(),this.id=t,this.dispatcher=o,this.type=\"vector\",this.minzoom=0,this.maxzoom=22,this.scheme=\"xyz\",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(i,[\"url\",\"scheme\",\"tileSize\",\"promoteId\"])),this._options=e.extend({type:\"vector\"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error(\"vector tile sources must have a tileSize of 512\");this.setEventedParent(r),this._tileWorkers={},this._deduped=new e.DedupedRequest;}load(t){this._loaded=!1,this.fire(new e.Event(\"dataloading\",{dataType:\"source\"}));const i=this.language||this.map._language,o=this.worldview||this.map._worldview;this._tileJSONRequest=F(this._options,this.map._requestManager,i,o,((r,n)=>{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code. Found: ${i}`),o&&2!==o.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${o}`),this.fire(new e.ErrorEvent(r))):n&&(e.extend(this,n),n.bounds&&(this.tileBounds=new U(n.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(n.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"}))),t&&t(r);}));}loaded(){return this._loaded}hasTile(e){return !this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load();}setSourceProperty(e){this._tileJSONRequest&&this._tileJSONRequest.cancel(),e(),this.load((()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles();}));}setTiles(e){return this.setSourceProperty((()=>{this._options.tiles=e;})),this}setUrl(e){return this.setSourceProperty((()=>{this.url=e,this._options.url=e;})),this}_setLanguage(e){return e===this.language||this.setSourceProperty((()=>{this.language=e;})),this}_setWorldview(e){return e===this.worldview?this:this.worldviewOptions&&e&&!this.worldviewOptions[e]?(console.warn(`Vector tile source \"${this.id}\" does not support worldview \"${e}\".`),this):(this.setSourceProperty((()=>{this.worldview=e;})),this)}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null);}serialize(){return e.extend({},this._options)}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(o,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,t.actor&&\"expired\"!==t.state)\"loading\"===t.state?t.reloadCallback=i:t.request=t.actor.send(\"reloadTile\",r,n.bind(this));else if(t.actor=this._tileWorkers[o]=this._tileWorkers[o]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send(\"loadTile\",r,n.bind(this),void 0,!0);else {const i=e.loadVectorTile.call({deduped:this._deduped},r,((e,i)=>{e||!i?n.call(this,e):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},t.actor&&t.actor.send(\"loadTile\",r,n.bind(this),void 0,!0));}),!0);t.request={cancel:i};}function n(o,r){return delete t.request,t.aborted?i(null):o&&404!==o.status?i(o):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send(\"abortTile\",{uid:e.uid,type:this.type,source:this.id});}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send(\"removeTile\",{uid:e.uid,type:this.type,source:this.id});}hasTransition(){return !1}afterUpdate(){this._tileWorkers={};}},raster:Me,\"raster-dem\":class extends Me{constructor(t,i,o,r){super(t,i,o,r),this.type=\"raster-dem\",this.maxzoom=22,this._options=e.extend({type:\"raster-dem\"},i),this.encoding=i.encoding||\"mapbox\";}loadTile(t,i){const o=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(e,o){e&&(t.state=\"errored\",i(e)),o&&(t.dem=o,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state=\"loaded\",i(null));}t.request=e.getImage(this.map._requestManager.transformRequest(o,e.ResourceType.Tile),function(o,n,a,s){if(delete t.request,t.aborted)t.state=\"unloaded\",i(null);else if(o)t.state=\"errored\",i(o);else if(n){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const i=e.window.ImageBitmap&&n instanceof e.window.ImageBitmap&&(null==Se&&(Se=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext(\"2d\")&&\"function\"==typeof e.window.createImageBitmap),Se),o=1-(n.width-e.prevPowerOfTwo(n.width))/2;o<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=i?n:e.exported.getImageData(n,o),c={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:o};t.actor&&\"expired\"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send(\"loadDEMTile\",c,r.bind(this),void 0,!0));}}.bind(this));}_getNeighboringTiles(t){const i=t.canonical,o=Math.pow(2,i.z),r=(i.x-1+o)%o,n=0===i.x?t.wrap-1:t.wrap,a=(i.x+1+o)%o,s=i.x+1===o?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,n,i.z,r,i.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,i.z,a,i.y).key]={backfilled:!1},i.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,n,i.z,r,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,i.z,a,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else {const t={dataType:\"source\",sourceDataType:this._metadataFired?\"content\":\"metadata\"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(t.resourceTiming=i.resourceTiming[this.id]),this.fire(new e.Event(\"data\",t)),this._metadataFired=!0;}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1);}));}loaded(){return this._loaded}loadTile(t,i){const o=t.actor?\"reloadTile\":\"loadTile\";t.actor=this.actor,t.request=this.actor.send(o,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((e,r)=>(delete t.request,t.unloadVectorData(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,\"reloadTile\"===o),i(null)))),void 0,\"loadTile\"===o);}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0;}unloadTile(e){e.unloadVectorData(),this.actor.send(\"removeTile\",{uid:e.uid,type:this.type,source:this.id});}onRemove(){this._pendingLoad&&this._pendingLoad.cancel();}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return !1}},video:class extends De{constructor(e,t,i,o){super(e,t,i,o),this.roundZoom=!0,this.type=\"video\",this.options=t;}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.ResourceType.Source).url);e.getVideo(this.urls,((t,i)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute(\"playsinline\",\"\"),this.video.addEventListener(\"playing\",(()=>{this.map.triggerRepaint();})),this.map&&this.video.play(),this._finishLoading());}));}pause(){this.video&&this.video.pause();}play(){this.video&&this.video.play();}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t;}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)));}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t);}serialize(){return {type:\"video\",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:De,canvas:class extends De{constructor(t,i,o,r){super(t,i,o,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((e=>!Array.isArray(e)||2!==e.length||e.some((e=>\"number\"!=typeof e))))||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'\"coordinates\" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property \"coordinates\"'))),i.animate&&\"boolean\"!=typeof i.animate&&this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'optional \"animate\" property must be a boolean value'))),i.canvas?\"string\"==typeof i.canvas||i.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'\"canvas\" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError(`sources.${t}`,null,'missing required property \"canvas\"'))),this.options=i,this.animate=void 0===i.animate||i.animate;}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.ErrorEvent(new Error(\"Canvas dimensions cannot be less than or equal to zero.\"))):(this.play=function(){this._playing=!0,this.map.triggerRepaint();},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1);},this._finishLoading());}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play();}onRemove(){this.pause();}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i);}serialize(){return {type:\"canvas\",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of [this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return !0;return !1}},custom:class extends e.Evented{constructor(t,i,o,r){super(),this.id=t,this.type=\"custom\",this._dataType=\"raster\",this._dispatcher=o,this._implementation=i,this.setEventedParent(r),this.scheme=\"xyz\",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new U(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(i,[\"dataType\",\"scheme\",\"minzoom\",\"maxzoom\",\"tileSize\",\"attribution\",\"minTileCacheSize\",\"maxTileCacheSize\"]));}serialize(){return e.pick(this,[\"type\",\"scheme\",\"minzoom\",\"maxzoom\",\"tileSize\",\"attribution\"])}load(){this._loaded=!0,this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"metadata\"})),this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"}));}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event(\"dataloading\",{dataType:\"source\"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load();}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e);}hasTile(e){if(this._implementation.hasTile){const{x:t,y:i,z:o}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:o})}return !this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const{x:o,y:r,z:n}=t.tileID.canonical,a=new e.window.AbortController,s=this._implementation.loadTile({x:o,y:r,z:n},{signal:a.signal});if(!s)return this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state=\"loaded\",i(null);s.cancel=()=>a.abort(),t.request=s.then(function(o){return delete t.request,t.aborted?(t.state=\"unloaded\",i(null)):o?function(t){return t instanceof e.window.ImageData||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLCanvasElement}(o)?(this.loadTileData(t,o),t.state=\"loaded\",void i(null)):(t.state=\"errored\",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`))):(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state=\"loaded\",i(null))}.bind(this)).catch((e=>{20!==e.code&&(t.state=\"errored\",i(e));}));}loadTileData(e,t){Me.loadTileData(e,t,this._map.painter);}unloadTileData(e){Me.unloadTileData(e,this._map.painter);}prepareTile(e){if(!this._implementation.prepareTile)return null;const{x:t,y:i,z:o}=e.tileID.canonical,r=this._implementation.prepareTile({x:t,y:i,z:o});return r?(this.loadTileData(e,r),e.state=\"loaded\",r):null}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:i,z:o}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:i,z:o});}t();}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t();}hasTransition(){return !1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z})))}_update(){this.fire(new e.Event(\"data\",{dataType:\"source\",sourceDataType:\"content\"}));}}},Ae=function(t,i,o,r){const n=new Pe[i.type](t,i,o,r);if(n.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${n.id}`);return e.bindAll([\"load\",\"abort\",\"unload\",\"serialize\",\"prepare\"],n),n};function Le(t,i){const o=e.identity([]);return e.scale(o,o,[.5*t.width,.5*-t.height,1]),e.translate(o,o,[1,-1,0]),e.multiply(o,o,t.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(o)}function Re(e,t,i,o,r,n,a,s=!1){const l=e.tilesIn(o,a,s);l.sort(Be);const c=[];for(const o of l)c.push({wrappedTileID:o.tile.tileID.wrapped().key,queryResults:o.tile.queryRenderedFeatures(t,i,e._state,o,r,n,Le(e.transform,o.tile.tileID),s)});const h=function(e){const t={},i={};for(const o of e){const e=o.queryResults,r=o.wrappedTileID,n=i[r]=i[r]||{};for(const i in e){const o=e[i],r=n[i]=n[i]||{},a=t[i]=t[i]||[];for(const e of o)r[e.featureIndex]||(r[e.featureIndex]=!0,a.push(e));}}return t}(c);for(const t in h)h[t].forEach((t=>{const i=t.feature,o=i.layer;o&&\"background\"!==o.type&&\"sky\"!==o.type&&(i.source=o.source,o[\"source-layer\"]&&(i.sourceLayer=o[\"source-layer\"]),i.state=void 0!==i.id?e.getFeatureState(o[\"source-layer\"],i.id):{});}));return h}function Oe(e,t){const i=e.getRenderableIds().map((t=>e.getTileByID(t))),o=[],r={};for(let e=0;e{e.terminate();})),this.workers=null);}isPreloaded(){return !!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let Ne;function Ge(){return Ne||(Ne=new Ue),Ne}function je(t,i){const o={};for(const e in t)\"ref\"!==e&&(o[e]=t[e]);return e.refProperties.forEach((e=>{e in i&&(o[e]=i[e]);})),o}function Ze(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-a)/s:0;return this.points[n].mult(1-l).add(this.points[i].mult(l))}}class Qe{constructor(e,t,i){const o=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||o<0||t>this.height)return !r&&[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=o){if(r)return !0;for(let e=0;e0:a}_queryCircle(e,t,i,o,r){const n=e-i,a=e+i,s=t-i,l=t+i;if(a<0||n>this.width||l<0||s>this.height)return !o&&[];const c=[];return this._forEachCell(n,s,a,l,this._queryCellCircle,c,{hitTest:o,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),o?c.length>0:c}query(e,t,i,o,r){return this._query(e,t,i,o,!1,r)}hitTest(e,t,i,o,r){return this._query(e,t,i,o,!0,r)}hitTestCircle(e,t,i,o){return this._queryCircle(e,t,i,!0,o)}_queryCell(e,t,i,o,r,n,a,s){const l=a.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const h of c)if(!l.box[h]){l.box[h]=!0;const c=4*h;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&o>=r[c+1]&&(!s||s(this.boxKeys[h]))){if(a.hitTest)return n.push(!0),!0;n.push({key:this.boxKeys[h],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]});}}}const h=this.circleCells[r];if(null!==h){const r=this.circles;for(const c of h)if(!l.circle[c]){l.circle[c]=!0;const h=3*c;if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,o)&&(!s||s(this.circleKeys[c]))){if(a.hitTest)return n.push(!0),!0;{const e=r[h],t=r[h+1],i=r[h+2];n.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i});}}}}}_queryCellCircle(e,t,i,o,r,n,a,s){const l=a.circle,c=a.seenUids,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!s||s(this.boxKeys[t])))return n.push(!0),!0}}const u=this.circleCells[r];if(null!==u){const e=this.circles;for(const t of u)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return n.push(!0),!0}}}_forEachCell(e,t,i,o,r,n,a,s){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(o);for(let _=l;_<=h;_++)for(let l=c;l<=u;l++)if(r.call(this,e,t,i,o,this.xCellCount*l+_,n,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,o,r,n){const a=o-e,s=r-t,l=i+n;return l*l>a*a+s*s}_circleAndRectCollide(e,t,i,o,r,n,a){const s=(n-o)/2,l=Math.abs(e-(o+s));if(l>s+i)return !1;const c=(a-r)/2,h=Math.abs(t-(r+c));if(h>c+i)return !1;if(l<=s||h<=c)return !0;const u=l-s,_=h-c;return u*u+_*_<=i*i}}const et=Math.tan(85*Math.PI/180);function tt(t,i,o,r,n,a,s){const l=e.create();if(o)if(\"globe\"===a.name){const t=e.calculateGlobeLabelMatrix(n,i);e.multiply(l,l,t);}else {const t=v([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.rotateZ(l,l,n.angle);}else e.multiply(l,n.labelPlaneMatrix,t);return l}function it(e,t,i,o,r,n,a){const s=tt(e,t,i,o,r,n,a);return \"globe\"===n.name&&i||(s[2]=s[6]=s[10]=s[14]=0),s}function ot(t,i,o,r,n,a,s){if(o){if(\"globe\"===a.name){const l=tt(t,i,o,r,n,a,s);return e.invert(l,l),e.multiply(l,t,l),l}{const i=e.clone(t),o=e.identity([]);return o[0]=s[0],o[1]=s[1],o[4]=s[2],o[5]=s[3],e.multiply(i,i,o),r||e.rotateZ(i,i,-n.angle),i}}return n.glCoordMatrix}function rt(t,i,o=0){const r=[t.x,t.y,o,1];o?e.transformMat4$1(r,r,i):gt(r,r,i);const n=r[3];return {point:[r[0]/n,r[1]/n,r[2]/n],signedDistanceFromCamera:n}}function nt(t,i){const o=[t[0],t[1],t[2],1];e.transformMat4$1(o,o,i);const r=o[3];return {point:[o[0]/r,o[1]/r,o[2]/r],signedDistanceFromCamera:r}}function at(e,t){return Math.min(.5+e/t*.5,1.5)}function st(e,t){const i=e[0]/e[3],o=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&o>=-t[1]&&o<=t[1]}function lt(t,i,o,r,n,a,s,l,c,h){const u=o.transform,_=r?t.textSizeData:t.iconSizeData,d=e.evaluateSizeForZoom(_,o.transform.zoom),p=\"globe\"===u.projection.name,m=[256/o.width*2+1,256/o.height*2+1],f=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;f.clear();let g=null;p&&(g=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const v=t.lineVertexArray,x=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,y=o.transform.width/o.transform.height;let b=!1;for(let r=0;rMath.abs(o.x-i.x)*r?{useVertical:!0}:t.writingMode===e.WritingMode.vertical?i.yet}(i,o,r)?1===t.flipState?{needsFlipping:!0}:null:i.x>o.x?{needsFlipping:!0}:null}function ut(t,i,o,r,n,a,s,l,c,h,u,_,d,p,m,f,g,v,x){const y=i/24,b=t.lineOffsetX*y,w=t.lineOffsetY*y;let T;if(t.numGlyphs>1){const i=t.glyphStartIndex+t.numGlyphs,n=t.lineStartIndex,h=t.lineStartIndex+t.lineLength,u=ct(y,l,b,w,o,_,d,t,c,a,p,f,!1,g,v,x);if(!u)return {notEnoughRoom:!0};const E=nt(u.first.point,s).point,C=nt(u.last.point,s).point,I=new e.pointGeometry(E[0],E[1]),M=new e.pointGeometry(C[0],C[1]);if(r&&!o){const e=ht(t,I,M,m);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}T=[u.first];for(let e=t.glyphStartIndex+1;e0?a.point:dt(d,r,i,1,n,void 0,g,v.canonical),l=ht(t,new e.pointGeometry(i[0],i[1]),new e.pointGeometry(s[0],s[1]),m);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const i=pt(y*l.getoffsetX(t.glyphStartIndex),b,w,o,_,d,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,c,a,p,f,!1,!1,g,v,x);if(!i)return {notEnoughRoom:!0};T=[i];}if(u)for(const t of T)e.updateGlobeVertexNormal(u,h.length+0,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(u,h.length+1,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(u,h.length+2,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(u,h.length+3,t.up[0],t.up[1],t.up[2]),e.addDynamicAttributes(h,t.point[0],t.point[1],t.point[2],t.angle);else for(const t of T)e.addDynamicAttributes(h,t.point[0],t.point[1],t.point[2],t.angle);return {}}function _t(t,i,o,r,n){const a=r.projectTilePoint(t.x,t.y,i);if(!n)return rt(a,o,a.z);const s=n(t);return rt(new e.pointGeometry(a.x+s[0],a.y+s[1]),o,a.z+s[2])}function dt(t,i,o,r,n,a,s,l){const c=_t(t.add(t.sub(i)._unit()),l,n,s,a).point,h=e.sub([],o,c);return e.scaleAndAdd([],o,h,r/e.length(h))}function pt(t,i,o,r,n,a,s,l,c,h,u,_,d,p,m,f,g,v){const x=r?t-i:t+i;let y=x>0?1:-1,b=0;r&&(y*=-1,b=Math.PI),y<0&&(b+=Math.PI);let w=y>0?l+s:l+s+1,T=n,E=n,C=0,I=0;const M=Math.abs(x),S=[],z=[];let D=a;const P=()=>{const t=w-y;return 0===C?a:new e.pointGeometry(h.getx(t),h.gety(t))},A=()=>dt(P(),D,E,M-C+1,u,d,f,g.canonical);for(;C+I<=M;){if(w+=y,w=c)return null;if(E=T,S.push(T),p&&z.push(D||P()),T=_[w],void 0===T){D=new e.pointGeometry(h.getx(w),h.gety(w));const t=_t(D,g.canonical,u,f,d);T=t.signedDistanceFromCamera>0?_[w]=t.point:A();}else D=null;C+=I,I=e.distance(E,T);}D=D||new e.pointGeometry(h.getx(w),h.gety(w));const L=P();m&&d&&(_[w]=T=void 0===_[w]?T:A(),I=e.distance(E,T));const R=(M-C)/I,O=D.sub(L).mult(R)._add(L),B=e.sub([],T,E),k=e.scaleAndAdd([],E,B,R);let F=[0,0,1],U=B[0],N=B[1];if(v&&(F=f.upVector(g.canonical,O.x,O.y),0!==F[0]||0!==F[1]||1!==F[2])){const t=[1,0,0],i=[0,1,0];t[0]=F[2],t[1]=0,t[2]=-F[0],e.cross(i,F,t),e.normalize(t,t),e.normalize(i,i),U=e.dot(B,t),N=e.dot(B,i);}if(o){const t=e.cross([],F,B);e.normalize(t,t),e.scaleAndAdd(k,k,t,o*y);}const G=b+Math.atan2(N,U);return S.push(k),p&&z.push(O),{point:k,angle:G,path:S,tilePath:z,up:F}}const mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function ft(e,t){for(let i=0;i0,e.getProjection()),p=n*d.perspectiveRatio,m=(i.x1*t+o.x-i.padding)*p+d.point.x,f=(i.y1*t+o.y-i.padding)*p+d.point.y,g=(i.x2*t+o.x+i.padding)*p+d.point.x,v=(i.y2*t+o.y+i.padding)*p+d.point.y,x=d.perspectiveRatio<=.55||d.occluded;return !this.isInsideGrid(m,f,g,v)||!r&&this.grid.hitTest(m,f,g,v,s)||x?{box:[],offscreen:!1,occluded:d.occluded}:{box:[m,f,g,v],offscreen:this.isOffscreen(m,f,g,v),occluded:!1}}placeCollisionCircles(t,i,o,r,n,a,s,l,c,h,u,_,d,p,m){const f=[],g=this.transform.elevation,v=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,t.getProjection()):e=>[0,0,0],x=new e.pointGeometry(o.tileAnchorX,o.tileAnchorY),y=t.getProjection().projectTilePoint(o.tileAnchorX,o.tileAnchorY,m.canonical),b=v(x),w=[y.x+b[0],y.y+b[1],y.z+b[2]],T=\"globe\"===t.projection.name,E=this.projectAndGetPerspectiveRatio(s,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,t.getProjection()),{perspectiveRatio:C}=E,I=(u?a/C:a*C)/e.ONE_EM,M=rt(new e.pointGeometry(w[0],w[1]),l,w[2]).point,S=E.signedDistanceFromCamera>0?ct(I,n,o.lineOffsetX*I,o.lineOffsetY*I,!1,M,x,o,r,l,{},g&&!u?v:null,u&&!!g,t.getProjection(),m,u):null;let z=!1,D=!1,P=!0;if(S&&!E.occluded){const t=.5*d*C+p,o=new e.pointGeometry(-100,-100),r=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),n=new Je,a=S.first,s=S.last;let l=[];for(let e=a.path.length-1;e>=1;e--)l.push(a.path[e]);for(let e=1;e{const i=v(tnt(e,c));l=e.some((e=>e.signedDistanceFromCamera<=0))?[]:e.map((e=>e.point));}let m=[];if(l.length>0){const t=l.map((t=>new e.pointGeometry(t[0],t[1])));let i=1/0,n=-1/0,a=1/0,s=-1/0;for(let e=0;e=o.x&&n<=r.x&&a>=o.y&&s<=r.y?[t]:nr.x||sr.y?[]:e.clipLine([t],o.x,o.y,r.x,r.y);}for(const e of m){n.reset(e,.25*t);let o=0;o=n.length<=.5*t?1:Math.ceil(n.paddedLength/u)+1;for(let e=0;e0){e.transformMat4$1(a,a,t);const r=\"globe\"===n.name;this.fogState&&o&&!r&&(s=function(t,i,o,r,n,a){const s=a.calculateFogTileMatrix(n),l=[i,o,r];return e.transformMat4(l,l,s),M(t,l,a.pitch,a._fov)}(this.fogState,i[0],i[1],i[2],o.toUnwrapped(),this.transform)>.9);}else gt(a,a,t);return {point:new e.pointGeometry((a[0]/a[3]+1)/2*this.transform.width+vt,(-a[1]/a[3]+1)/2*this.transform.height+vt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(n)/a[3]*.5,1.5),signedDistanceFromCamera:a[3],occluded:r&&a[2]>a[3]||s}}isOffscreen(e,t,i,o){return i=this.screenRightBoundary||othis.screenBottomBoundary}isInsideGrid(e,t,i,o){return i>=0&&e=0&&te.collisionGroupID===t};}return this.collisionGroups[e]}}function zt(t,i,o,r,n){const{horizontalAlign:a,verticalAlign:s}=e.getAnchorAlignment(t),l=-(a-.5)*i,c=-(s-.5)*o,h=e.evaluateVariableOffset(t,r);return new e.pointGeometry(l+h[0]*n,c+h[1]*n)}function Dt(t,i,o,r,n){const a=new e.pointGeometry(t,i);return o&&a._rotate(r?n:-n),a}class Pt{constructor(e,t,i,o,r){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new xt(this.transform,r),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new St(i),this.collisionCircleArrays={},this.prevPlacement=o,o&&(o.prevPlacement=void 0),this.placedOrientations={};}getBucketParts(t,i,o,r){const n=o.getBucket(i),a=o.latestFeatureIndex;if(!n||!a||i.id!==n.layerIds[0])return;const s=n.layers[0].layout,l=o.collisionBoxArray,c=Math.pow(2,this.transform.zoom-o.tileID.overscaledZ),h=o.tileSize/e.EXTENT,u=o.tileID.toUnwrapped();this.transform.setProjection(n.projection);const _=(d=o.tileID,p=n.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):yt(m,p,d));var d,p,m;const f=\"map\"===s.get(\"text-pitch-alignment\"),g=\"map\"===s.get(\"text-rotation-alignment\");i.compileFilter();const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),y=this.transform.calculatePixelsToTileUnitsMatrix(o),b=it(_,o.tileID.canonical,f,g,this.transform,n.getProjection(),y);let w=null;if(f){const t=ot(_,o.tileID.canonical,f,g,this.transform,n.getProjection(),y);w=e.multiply([],this.transform.labelPlaneMatrix,t);}let T=null;v&&o.latestFeatureIndex&&(T={unwrappedTileID:u,dynamicFilter:v,dynamicFilterNeedsFeature:x,featureIndex:o.latestFeatureIndex}),this.retainedQueryData[n.bucketInstanceId]=new Mt(n.bucketInstanceId,a,n.sourceLayerIndex,n.index,o.tileID);const E={bucket:n,layout:s,posMatrix:_,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:c,textPixelRatio:h,holdingForFade:o.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(n.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(n.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(const e of n.sortKeyRanges){const{sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:o,symbolInstanceEnd:r,parameters:E});}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:E});}attemptAnchorPlacement(e,t,i,o,r,n,a,s,l,c,h,u,_,d,p,m,f,g){const v=[u.textOffset0,u.textOffset1],x=zt(e,i,o,v,r),y=this.collisionIndex.placeCollisionBox(d,r,t,Dt(x.x,x.y,n,a,this.transform.angle),h,s,l,c.predicate);if((!m||0!==this.collisionIndex.placeCollisionBox(d,d.getSymbolInstanceIconSize(g,this.transform.zoom,_),m,Dt(x.x,x.y,n,a,this.transform.angle),h,s,l,c.predicate).box.length)&&y.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(t=this.prevPlacement.variableOffsets[u.crossTileID].anchor),this.variableOffsets[u.crossTileID]={textOffset:v,width:i,height:o,anchor:e,textScale:r,prevAnchor:t},this.markUsedJustification(d,e,u,p),d.allowVerticalPlacement&&(this.markUsedOrientation(d,p,u),this.placedOrientations[u.crossTileID]=p),{shift:x,placedGlyphBoxes:y}}}placeLayerBucketPart(t,i,o,r){const{bucket:n,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:h,textPixelRatio:u,holdingForFade:_,collisionBoxArray:d,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:f}=t.parameters,g=a.get(\"text-optional\"),v=a.get(\"icon-optional\"),x=a.get(\"text-allow-overlap\"),y=a.get(\"icon-allow-overlap\"),b=\"map\"===a.get(\"text-rotation-alignment\"),w=\"map\"===a.get(\"text-pitch-alignment\"),T=\"none\"!==a.get(\"icon-text-fit\"),E=\"viewport-y\"===a.get(\"symbol-z-order\");this.transform.setProjection(n.projection);let C=x&&(y||!n.hasIconData()||v),I=y&&(x||!n.hasTextData()||g);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d),o&&r&&n.updateCollisionDebugBuffers(this.transform.zoom,d);const M=(t,r,d)=>{if(h){const o={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(h.dynamicFilterNeedsFeature){const e=this.retainedQueryData[n.bucketInstanceId];r=h.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0});}if(!(0,h.dynamicFilter)(o,r,this.retainedQueryData[n.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(h.unwrappedTileID)))return this.placements[t.crossTileID]=new Ct(!1,!1,!1,!0),void(i[t.crossTileID]=!0)}if(i[t.crossTileID])return;if(_)return void(this.placements[t.crossTileID]=new Ct(!1,!1,!1));let E=!1,M=!1,S=!0,z=!1,D=!1,P=null,A={box:null,offscreen:null,occluded:null},L={box:null,offscreen:null,occluded:null},R=null,O=null,B=null,k=0,F=0,U=0;d.textFeatureIndex?k=d.textFeatureIndex:t.useRuntimeCollisionCircles&&(k=t.featureIndex),d.verticalTextFeatureIndex&&(F=d.verticalTextFeatureIndex);const N=e=>{e.tileID=this.retainedQueryData[n.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[n.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0);},G=d.textBox;if(G){N(G);const i=i=>{let o=e.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,o=e,this.markUsedOrientation(n,o,t));}return o},o=(i,o)=>{if(n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const t of n.writingModes)if(t===e.WritingMode.vertical?(A=o(),L=A):A=i(),A&&A.box&&A.box.length)break}else A=i();};if(a.get(\"text-variable-anchor\")){let l=a.get(\"text-variable-anchor\");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];l.indexOf(e.anchor)>0&&(l=l.filter((t=>t!==e.anchor)),l.unshift(e.anchor));}const c=(e,i,o)=>{const a=n.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),c=(e.x2-e.x1)*a+2*e.padding,h=(e.y2-e.y1)*a+2*e.padding,_=T&&!y?i:null;_&&N(_);let d={box:[],offscreen:!1,occluded:!1};const g=x?2*l.length:l.length;for(let i=0;i=l.length,t,r,n,o,_,p,m);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){E=!0,P=g.shift;break}}return d};o((()=>c(G,d.iconBox,e.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return i&&N(i),n.allowVerticalPlacement&&!(A&&A.box&&A.box.length)&&t.numVerticalGlyphVertices>0&&i?c(i,d.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),A&&(E=A.box,S=A.offscreen,z=A.occluded);const h=i(A&&A.box);if(!E&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(n,e.anchor,t,h));}}else {const a=(i,o)=>{const a=n.getSymbolInstanceTextSize(p,t,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(n,a,i,new e.pointGeometry(0,0),x,u,s,f.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(n,o,t),this.placedOrientations[t.crossTileID]=o),l};o((()=>a(G,e.WritingMode.horizontal)),(()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?(N(i),a(i,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(A&&A.box&&A.box.length);}}if(R=A,E=R&&R.box&&R.box.length>0,S=R&&R.offscreen,z=R&&R.occluded,t.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),r=e.evaluateSizeForFeature(n.textSizeData,p,i),h=a.get(\"text-padding\");O=this.collisionIndex.placeCollisionCircles(n,x,i,n.lineVertexArray,n.glyphOffsetArray,r,s,l,c,o,w,f.predicate,t.collisionCircleDiameter*r/e.ONE_EM,h,this.retainedQueryData[n.bucketInstanceId].tileID),E=x||O.circles.length>0&&!O.collisionDetected,S=S&&O.offscreen,z=O.occluded;}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const t=t=>{N(t);const i=T&&P?Dt(P.x,P.y,b,w,this.transform.angle):new e.pointGeometry(0,0),o=n.getSymbolInstanceIconSize(m,this.transform.zoom,r);return this.collisionIndex.placeCollisionBox(n,o,t,i,y,u,s,f.predicate)};L&&L.box&&L.box.length&&d.verticalIconBox?(B=t(d.verticalIconBox),M=B.box.length>0):(B=t(d.iconBox),M=B.box.length>0),S=S&&B.offscreen,D=B.occluded;}const j=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,Z=v||0===t.numIconVertices;if(j||Z?Z?j||(M=M&&E):E=M&&E:M=E=M&&E,E&&R&&R.box&&this.collisionIndex.insertCollisionBox(R.box,a.get(\"text-ignore-placement\"),n.bucketInstanceId,L&&L.box&&F?F:k,f.ID),M&&B&&this.collisionIndex.insertCollisionBox(B.box,a.get(\"icon-ignore-placement\"),n.bucketInstanceId,U,f.ID),O&&(E&&this.collisionIndex.insertCollisionCircles(O.circles,a.get(\"text-ignore-placement\"),n.bucketInstanceId,k,f.ID),o)){const e=n.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new It);for(let e=0;e=0;--t){const i=e[t];M(n.symbolInstances.get(i),i,n.collisionArrays[i]);}}else for(let e=t.symbolInstanceStart;e