i.x||r.x===i.x&&jo(i,r)))&&(i=r,p=l)),r=r.next}while(r!==c);return i}(t,e);if(!i)return e;var r=rs(i,t);return Oo(r,r.next),Oo(i,i.next)}function jo(t,e){return Jo(t.prev,t,e.prev)<0&&Jo(e.next,t,t.next)<0}function Xo(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Ho(t){var e=t,i=t;do{(e.x=(t-o)*(a-s)&&(t-o)*(r-s)>=(i-o)*(e-s)&&(i-o)*(a-s)>=(n-o)*(r-s)}function Ko(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&Qo(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(is(t,e)&&is(e,t)&&function(t,e){var i=t,r=!1,n=(t.x+e.x)/2,a=(t.y+e.y)/2;do{i.y>a!=i.next.y>a&&i.next.y!==i.y&&n<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,e)&&(Jo(t.prev,t,e.prev)||Jo(t,e.prev,e))||Yo(t,e)&&Jo(t.prev,t,t.next)>0&&Jo(e.prev,e,e.next)>0)}function Jo(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Yo(t,e){return t.x===e.x&&t.y===e.y}function Qo(t,e,i,r){var n=es(Jo(t,e,i)),a=es(Jo(t,e,r)),o=es(Jo(i,r,t)),s=es(Jo(i,r,e));return n!==a&&o!==s||!(0!==n||!ts(t,i,e))||!(0!==a||!ts(t,r,e))||!(0!==o||!ts(i,t,r))||!(0!==s||!ts(i,e,r))}function ts(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function es(t){return t>0?1:t<0?-1:0}function is(t,e){return Jo(t.prev,t,t.next)<0?Jo(t,e,t.next)>=0&&Jo(t,t.prev,e)>=0:Jo(t,e,t.prev)<0||Jo(t,t.next,e)<0}function rs(t,e){var i=new os(t.i,t.x,t.y),r=new os(e.i,e.x,e.y),n=t.next,a=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,a.next=r,r.prev=a,r}function ns(t,e,i,r){var n=new os(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function as(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 os(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function ss(t,e,i,r){for(var n=0,a=e,o=i-r;ai;){if(r-i>600){var a=r-i+1,o=e-i+1,s=Math.log(a),l=.5*Math.exp(2*s/3),c=.5*Math.sqrt(s*l*(a-l)/a)*(o-a/2<0?-1:1);cs(t,e,Math.max(i,Math.floor(e-o*l/a+c)),Math.min(r,Math.floor(e+(a-o)*l/a+c)),n)}var h=t[e],u=i,p=r;for(hs(t,i,e),n(t[r],h)>0&&hs(t,i,r);u0;)p--}0===n(t[i],h)?hs(t,i,p):hs(t,++p,r),p<=e&&(i=p+1),e<=p&&(r=p-1)}}function hs(t,e,i){var r=t[e];t[e]=t[i],t[i]=r}function us(t,e){return te?1:0}function ps(t,e){const i=t.length;if(i<=1)return[t];const r=[];let n,a;for(let o=0;o1)for(let o=0;o0&&i.holes.push(r+=t[n-1].length)}return i};class gs{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 ea,this.indexArray=new ua,this.indexArray2=new pa,this.programConfigurations=new Va(t.layers,t.zoom),this.segments=new fa,this.segments2=new fa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=ms("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,h=ja(o,t);if(!this.layers[0]._featureFilter.filter(new Yr(this.zoom),h,i))continue;const u=n?r.evaluate(h,{},i,e.availableImages):void 0,p={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:t?h.geometry:Za(o),patterns:{},sortKey:u};a.push(p)}n&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const o of a){const{geometry:r,index:n,sourceLayerIndex:a}=o;if(this.hasPattern){const t=fs("fill",this.layers,o,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(o,r,n,i,{});e.featureIndex.insert(t[n].feature,r,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Lo),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,r,n){for(const a of ps(e,500)){let t=0;for(const s of a)t+=s.length;const e=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),i=e.vertexLength,r=[],n=[];for(const s of a){if(0===s.length)continue;s!==a[0]&&n.push(r.length/2);const t=this.segments2.prepareSegment(s.length,this.layoutVertexArray,this.indexArray2),e=t.vertexLength;this.layoutVertexArray.emplaceBack(s[0].x,s[0].y),this.indexArray2.emplaceBack(e+s.length-1,e),r.push(s[0].x),r.push(s[0].y);for(let i=1;i>3}if(n--,1===r||2===r)a+=t.readSVarint(),o+=t.readSVarint(),1===r&&(e&&s.push(e),e=[]),e.push(new Ts(a,o));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&s.push(e),s},Ss.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,r=0,n=0,a=0,o=1/0,s=-1/0,l=1/0,c=-1/0;t.pos>3}if(r--,1===i||2===i)(n+=t.readSVarint())s&&(s=n),(a+=t.readSVarint())c&&(c=a);else if(7!==i)throw new Error("unknown command "+i)}return[o,l,s,c]},Ss.prototype.toGeoJSON=function(t,e,i){var r,n,a=this.extent*Math.pow(2,i),o=this.extent*t,s=this.extent*e,l=this.loadGeometry(),c=Ss.types[this.type];function h(t){for(var e=0;e>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(i))}ks.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 Cs(this._pbf,e,this.extent,this._keys,this._values)};var Ps=As;function Ds(t,e,i){if(3===t){var r=new Ps(i,i.readVarint()+i.pos);r.length&&(e[r.name]=r)}}ws.VectorTile=function(t,e){this.layers=t.readFields(Ds,{},e)},ws.VectorTileFeature=Es,ws.VectorTileLayer=As;const Ls=ws.VectorTileFeature.types,Bs=Math.pow(2,13);function Rs(t,e,i,r,n,a,o,s){t.emplaceBack(e,i,2*Math.floor(r*Bs)+o,n*Bs*2,a*Bs*2,Math.round(s))}class Fs{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.layoutVertexArray=new ia,this.centroidVertexArray=new Qn,this.indexArray=new ua,this.programConfigurations=new Va(t.layers,t.zoom),this.segments=new fa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasPattern=ms("fill-extrusion",this.layers,e);for(const{feature:r,id:n,index:a,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,s=ja(r,t);if(!this.layers[0]._featureFilter.filter(new Yr(this.zoom),s,i))continue;const l={id:n,sourceLayerIndex:o,index:a,geometry:t?s.geometry:Za(r),properties:r.properties,type:r.type,patterns:{}};this.hasPattern?this.features.push(fs("fill-extrusion",this.layers,l,this.zoom,e)):this.addFeature(l,l.geometry,a,i,{}),e.featureIndex.insert(r,l.geometry,a,o,this.index,!0)}}addFeatures(t,e,i){for(const r of this.features){const{geometry:t}=r;this.addFeature(r,t,r.index,e,i)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,bs),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,vs.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,r,n){const a={x:0,y:0,vertexCount:0};for(const o of ps(e,500)){let e=0;for(const t of o)e+=t.length;let i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const t of o){if(0===t.length)continue;if(Vs(t))continue;let e=0;for(let r=0;r=1){const o=t[r-1];if(!Os(n,o)){i.vertexLength+4>fa.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const t=n.sub(o)._perp()._unit(),r=o.dist(n);e+r>32768&&(e=0),Rs(this.layoutVertexArray,n.x,n.y,t.x,t.y,0,0,e),Rs(this.layoutVertexArray,n.x,n.y,t.x,t.y,0,1,e),a.x+=2*n.x,a.y+=2*n.y,a.vertexCount+=2,e+=r,Rs(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,0,e),Rs(this.layoutVertexArray,o.x,o.y,t.x,t.y,0,1,e),a.x+=2*o.x,a.y+=2*o.y,a.vertexCount+=2;const s=i.vertexLength;this.indexArray.emplaceBack(s,s+2,s+1),this.indexArray.emplaceBack(s+1,s+2,s+3),i.vertexLength+=4,i.primitiveLength+=2}}}}if(i.vertexLength+e>fa.MAX_VERTEX_ARRAY_LENGTH&&(i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray)),"Polygon"!==Ls[t.type])continue;const r=[],n=[],s=i.vertexLength;for(const t of o)if(0!==t.length){t!==o[0]&&n.push(r.length/2);for(let e=0;e$a)||t.y===e.y&&(t.y<0||t.y>$a)}function Vs(t){return t.every((t=>t.x<0))||t.every((t=>t.x>$a))||t.every((t=>t.y<0))||t.every((t=>t.y>$a))}Ir("FillExtrusionBucket",Fs,{omit:["layers","features"]});var Us={paint:new dn({"fill-extrusion-opacity":new ln(rt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new cn(rt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ln(rt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ln(rt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new hn(rt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new cn(rt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new cn(rt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ln(rt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})};function Ns(t,e){return t.x*e.x+t.y*e.y}function $s(t,e){if(1===t.length){let i=0;const r=e[i++];let n;for(;!n||r.equals(n);)if(n=e[i++],!n)return 1/0;for(;it.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new ra,this.layoutVertexArray2=new na,this.indexArray=new ua,this.programConfigurations=new Va(t.layers,t.zoom),this.segments=new fa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasPattern=ms("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,e=ja(o,t);if(!this.layers[0]._featureFilter.filter(new Yr(this.zoom),e,i))continue;const h=n?r.evaluate(e,{},i):void 0,u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:t?e.geometry:Za(o),patterns:{},sortKey:h};a.push(u)}n&&a.sort(((t,e)=>t.sortKey-e.sortKey));for(const o of a){const{geometry:r,index:n,sourceLayerIndex:a}=o;if(this.hasPattern){const t=fs("line",this.layers,o,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(o,r,n,i,{});e.featureIndex.insert(t[n].feature,r,n,a,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i)}addFeatures(t,e,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i)}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,js)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,qs),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(t.properties,"mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,e,i,r,n){const a=this.layers[0].layout,o=a.get("line-join").evaluate(t,{}),s=a.get("line-cap"),l=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const h of e)this.addLine(h,t,o,s,l,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,n,r)}addLine(t,e,i,r,n,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[s-1].equals(t[s-2]);)s--;let l=0;for(;l0;if(b&&g>l){const t=u.dist(p);if(t>2*c){const e=u.sub(u.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,m,0,0,h),p=e}}const T=p&&d;let E=T?i:o?"butt":r;if(T&&"round"===E&&(xn&&(E="bevel"),"bevel"===E&&(x>2&&(E="flipbevel"),x100)e=f.mult(-1);else{const t=x*m.add(f).mag()/m.sub(f).mag();e._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(u,e,0,0,h),this.addCurrentVertex(u,e.mult(-1),0,0,h)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(x*x-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(u,m,e,i,h),"fakeround"===E){const t=Math.round(180*v/Math.PI/20);for(let e=1;e2*c){const e=u.add(d.sub(u)._mult(c/t)._round());this.updateDistance(u,e),this.addCurrentVertex(e,f,0,0,h),u=e}}}}addCurrentVertex(t,e,i,r,n,a=!1){const o=e.y*r-e.x,s=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,a,!1,i,n),this.addHalfVertex(t,o,s,a,!0,-r,n),this.distance>Ws/2&&0===this.totalDistance&&(this.distance=0,this.addCurrentVertex(t,e,i,r,n,a))}addHalfVertex({x:t,y:e},i,r,n,a,o,s){const l=.5*(this.lineClips?this.scaledDistance*(Ws-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(n?1:0),(e<<1)+(a?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),s.primitiveLength++),a?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Ir("LineBucket",Ks,{omit:["layers","patternFeatures"]});const Js=new dn({"line-cap":new ln(rt.layout_line["line-cap"]),"line-join":new cn(rt.layout_line["line-join"]),"line-miter-limit":new ln(rt.layout_line["line-miter-limit"]),"line-round-limit":new ln(rt.layout_line["line-round-limit"]),"line-sort-key":new cn(rt.layout_line["line-sort-key"])});var Ys={paint:new dn({"line-opacity":new cn(rt.paint_line["line-opacity"]),"line-color":new cn(rt.paint_line["line-color"]),"line-translate":new ln(rt.paint_line["line-translate"]),"line-translate-anchor":new ln(rt.paint_line["line-translate-anchor"]),"line-width":new cn(rt.paint_line["line-width"]),"line-gap-width":new cn(rt.paint_line["line-gap-width"]),"line-offset":new cn(rt.paint_line["line-offset"]),"line-blur":new cn(rt.paint_line["line-blur"]),"line-dasharray":new un(rt.paint_line["line-dasharray"]),"line-pattern":new hn(rt.paint_line["line-pattern"]),"line-gradient":new pn(rt.paint_line["line-gradient"])}),layout:Js};const Qs=new class extends cn{possiblyEvaluate(t,e){return e=new Yr(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=s({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}}(Ys.paint.properties["line-width"].specification);function tl(t,e){return e>0?e+2*t:t}Qs.useIntegerZoom=!0;const el=xn([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),il=xn([{name:"a_projected_pos",components:3,type:"Float32"}],4);xn([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const rl=xn([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);xn([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const nl=xn([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),al=xn([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function ol(t,e,i){return t.sections.forEach((t=>{t.text=function(t,e,i){const r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),Jr.applyArabicShaping&&(t=Jr.applyArabicShaping(t)),t}(t.text,e,i)})),t}xn([{name:"triangle",components:3,type:"Uint16"}]),xn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),xn([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),xn([{type:"Float32",name:"offsetX"}]),xn([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const sl={"!":"\ufe15","#":"\uff03",$:"\uff04","%":"\uff05","&":"\uff06","(":"\ufe35",")":"\ufe36","*":"\uff0a","+":"\uff0b",",":"\ufe10","-":"\ufe32",".":"\u30fb","/":"\uff0f",":":"\ufe13",";":"\ufe14","<":"\ufe3f","=":"\uff1d",">":"\ufe40","?":"\ufe16","@":"\uff20","[":"\ufe47","\\":"\uff3c","]":"\ufe48","^":"\uff3e",_:"\ufe33","`":"\uff40","{":"\ufe37","|":"\u2015","}":"\ufe38","~":"\uff5e","\xa2":"\uffe0","\xa3":"\uffe1","\xa5":"\uffe5","\xa6":"\uffe4","\xac":"\uffe2","\xaf":"\uffe3","\u2013":"\ufe32","\u2014":"\ufe31","\u2018":"\ufe43","\u2019":"\ufe44","\u201c":"\ufe41","\u201d":"\ufe42","\u2026":"\ufe19","\u2027":"\u30fb","\u20a9":"\uffe6","\u3001":"\ufe11","\u3002":"\ufe12","\u3008":"\ufe3f","\u3009":"\ufe40","\u300a":"\ufe3d","\u300b":"\ufe3e","\u300c":"\ufe41","\u300d":"\ufe42","\u300e":"\ufe43","\u300f":"\ufe44","\u3010":"\ufe3b","\u3011":"\ufe3c","\u3014":"\ufe39","\u3015":"\ufe3a","\u3016":"\ufe17","\u3017":"\ufe18","\uff01":"\ufe15","\uff08":"\ufe35","\uff09":"\ufe36","\uff0c":"\ufe10","\uff0d":"\ufe32","\uff0e":"\u30fb","\uff1a":"\ufe13","\uff1b":"\ufe14","\uff1c":"\ufe3f","\uff1e":"\ufe40","\uff1f":"\ufe16","\uff3b":"\ufe47","\uff3d":"\ufe48","\uff3f":"\ufe33","\uff5b":"\ufe37","\uff5c":"\u2015","\uff5d":"\ufe38","\uff5f":"\ufe35","\uff60":"\ufe36","\uff61":"\ufe12","\uff62":"\ufe41","\uff63":"\ufe42"};var ll=24,cl=pl,hl=function(t,e,i,r,n){var a,o,s=8*n-r-1,l=(1<>1,h=-7,u=i?n-1:0,p=i?-1:1,d=t[e+u];for(u+=p,a=d&(1<<-h)-1,d>>=-h,h+=s;h>0;a=256*a+t[e+u],u+=p,h-=8);for(o=a&(1<<-h)-1,a>>=-h,h+=r;h>0;o=256*o+t[e+u],u+=p,h-=8);if(0===a)a=1-c;else{if(a===l)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),a-=c}return(d?-1:1)*o*Math.pow(2,a-r)},ul=function(t,e,i,r,n,a){var o,s,l,c=8*a-n-1,h=(1<>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:a-1,m=r?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),(e+=o+u>=1?p/l:p*Math.pow(2,1-u))*l>=2&&(o++,l/=2),o+u>=h?(s=0,o=h):o+u>=1?(s=(e*l-1)*Math.pow(2,n),o+=u):(s=e*Math.pow(2,u-1)*Math.pow(2,n),o=0));n>=8;t[i+d]=255&s,d+=m,s/=256,n-=8);for(o=o<0;t[i+d]=255&o,d+=m,o/=256,c-=8);t[i+d-m]|=128*f};function pl(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}pl.Varint=0,pl.Fixed64=1,pl.Bytes=2,pl.Fixed32=5;var dl,ml=4294967296,fl=1/ml,gl="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function _l(t){return t.type===pl.Bytes?t.readVarint()+t.pos:t.pos+1}function yl(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function xl(t,e,i){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=t;n--)i.buf[n+r]=i.buf[n]}function vl(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function Ml(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}function Pl(t,e,i){1===t&&i.readMessage(Dl,e)}function Dl(t,e,i){if(3===t){const{id:t,bitmap:r,width:n,height:a,left:o,top:s,advance:l}=i.readMessage(Ll,{});e.push({id:t,bitmap:new Ao({width:n+6,height:a+6},r),metrics:{width:n,height:a,left:o,top:s,advance:l}})}}function Ll(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function Bl(t){let e=0,i=0;for(const o of t)e+=o.w*o.h,i=Math.max(i,o.w);t.sort(((t,e)=>e.h-t.h));const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let n=0,a=0;for(const o of t)for(let t=r.length-1;t>=0;t--){const e=r[t];if(!(o.w>e.w||o.h>e.h)){if(o.x=e.x,o.y=e.y,a=Math.max(a,o.y+o.h),n=Math.max(n,o.x+o.w),o.w===e.w&&o.h===e.h){const e=r.pop();t>3,a=this.pos;this.type=7&r,t(n,e,this),this.pos===a&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=Al(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Ml(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=Al(this.buf,this.pos)+Al(this.buf,this.pos+4)*ml;return this.pos+=8,t},readSFixed64:function(){var t=Al(this.buf,this.pos)+Ml(this.buf,this.pos+4)*ml;return this.pos+=8,t},readFloat:function(){var t=hl(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=hl(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,r=this.buf;return e=127&(i=r[this.pos++]),i<128?e:(e|=(127&(i=r[this.pos++]))<<7,i<128?e:(e|=(127&(i=r[this.pos++]))<<14,i<128?e:(e|=(127&(i=r[this.pos++]))<<21,i<128?e:function(t,e,i){var r,n,a=i.buf;if(r=(112&(n=a[i.pos++]))>>4,n<128)return yl(t,r,e);if(r|=(127&(n=a[i.pos++]))<<3,n<128)return yl(t,r,e);if(r|=(127&(n=a[i.pos++]))<<10,n<128)return yl(t,r,e);if(r|=(127&(n=a[i.pos++]))<<17,n<128)return yl(t,r,e);if(r|=(127&(n=a[i.pos++]))<<24,n<128)return yl(t,r,e);if(r|=(1&(n=a[i.pos++]))<<31,n<128)return yl(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&gl?function(t,e,i){return gl.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var r="",n=e;n239?4:l>223?3:l>191?2:1;if(n+h>i)break;1===h?l<128&&(c=l):2===h?128==(192&(a=t[n+1]))&&(c=(31&l)<<6|63&a)<=127&&(c=null):3===h?(o=t[n+2],128==(192&(a=t[n+1]))&&128==(192&o)&&((c=(15&l)<<12|(63&a)<<6|63&o)<=2047||c>=55296&&c<=57343)&&(c=null)):4===h&&(o=t[n+2],s=t[n+3],128==(192&(a=t[n+1]))&&128==(192&o)&&128==(192&s)&&((c=(15&l)<<18|(63&a)<<12|(63&o)<<6|63&s)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,h=1):c>65535&&(c-=65536,r+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),r+=String.fromCharCode(c),n+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==pl.Bytes)return t.push(this.readVarint(e));var i=_l(this);for(t=t||[];this.pos127;);else if(e===pl.Bytes)this.pos=this.readVarint()+this.pos;else if(e===pl.Fixed32)this.pos+=4;else{if(e!==pl.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 i,r;if(t>=0?(i=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,r=r+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var r,n,a=0;a55295&&r<57344){if(!n){r>56319||a+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):n=r;continue}if(r<56320){t[i++]=239,t[i++]=191,t[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(t[i++]=239,t[i++]=191,t[i++]=189,n=null);r<128?t[i++]=r:(r<2048?t[i++]=r>>6|192:(r<65536?t[i++]=r>>12|224:(t[i++]=r>>18|240,t[i++]=r>>12&63|128),t[i++]=r>>6&63|128),t[i++]=63&r|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&xl(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),ul(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ul(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 i=0;i=128&&xl(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,i){this.writeTag(t,pl.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,vl,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,bl,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,El,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,wl,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,Tl,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,Sl,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Il,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,zl,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Cl,e)},writeBytesField:function(t,e){this.writeTag(t,pl.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,pl.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,pl.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,pl.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,pl.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,pl.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,pl.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,pl.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,pl.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,pl.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};class Rl{constructor(t,{pixelRatio:e,version:i,stretchX:r,stretchY:n,content:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=r,this.stretchY=n,this.content=a,this.version=i}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 tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class Fl{constructor(t,e){const i={},r={};this.haveRenderCallbacks=[];const n=[];this.addImages(t,i,n),this.addImages(e,r,n);const{w:a,h:o}=Bl(n),s=new ko({width:a||1,height:o||1});for(const l in t){const e=t[l],r=i[l].paddedRect;ko.copy(e.data,s,{x:0,y:0},{x:r.x+1,y:r.y+1},e.data)}for(const l in e){const t=e[l],i=r[l].paddedRect,n=i.x+1,a=i.y+1,o=t.data.width,c=t.data.height;ko.copy(t.data,s,{x:0,y:0},{x:n,y:a},t.data),ko.copy(t.data,s,{x:0,y:c-1},{x:n,y:a-1},{width:o,height:1}),ko.copy(t.data,s,{x:0,y:0},{x:n,y:a+c},{width:o,height:1}),ko.copy(t.data,s,{x:o-1,y:0},{x:n-1,y:a},{width:1,height:c}),ko.copy(t.data,s,{x:0,y:0},{x:n+o,y:a},{width:1,height:c})}this.image=s,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(const r in t){const n=t[r],a={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(a),e[r]=new Rl(a,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[r,n]=t.tl;i.update(e.data,void 0,{x:r,y:n})}}Ir("ImagePosition",Rl),Ir("ImageAtlas",Fl),t.WritingMode=void 0,(dl=t.WritingMode||(t.WritingMode={}))[dl.none=0]="none",dl[dl.horizontal=1]="horizontal",dl[dl.vertical=2]="vertical",dl[dl.horizontalOnly=3]="horizontalOnly";const Ol=-17;class Vl{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Vl;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Vl;return e.imageName=t,e}}class Ul{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Ul;for(let r=0;r=0&&i>=t&&$l[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Ul;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Vl.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let r=0;r=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Nl(e,i,r,n,a,o,s,l,c,h,u,p,d,m,f,g){const _=Ul.fromFeature(e,a);let y;p===t.WritingMode.vertical&&_.verticalizePunctuation();const{processBidirectionalText:x,processStyledBidirectionalText:v}=Jr;if(x&&1===_.sections.length){y=[];const t=x(_.toString(),Wl(_,h,o,i,n,m,f));for(const e of t){const t=new Ul;t.text=e,t.sections=_.sections;for(let i=0;i0&&r>b&&(b=r)}else{const t=r[l.fontStack],e=t&&t[g];if(e&&e.rect)w=e.rect,y=e.metrics;else{const t=i[l.fontStack],e=t&&t[g];if(!e)continue;y=e.metrics}_=(a-l.scale)*ll}I?(e.verticalizable=!0,v.push({glyph:g,imageName:E,x:d,y:m+_,vertical:I,scale:l.scale,fontStack:l.fontStack,sectionIndex:f,metrics:y,rect:w}),d+=S*l.scale+h):(v.push({glyph:g,imageName:E,x:d,y:m+_,vertical:I,scale:l.scale,fontStack:l.fontStack,sectionIndex:f,metrics:y,rect:w}),d+=y.advance*l.scale+h)}0!==v.length&&(f=Math.max(d-h,f),Jl(v,0,v.length-1,_,b)),d=0;const w=o*a+b;l.lineOffset=Math.max(b,s),m+=w,g=Math.max(w,g),++y}var x;const v=m-Ol,{horizontalAlign:b,verticalAlign:w}=Kl(s);(function(t,e,i,r,n,a,o,s,l){const c=(e-i)*n;let h=0;h=a!==o?-s*r-Ol:(-r*l+.5)*o;for(const u of t)for(const t of u.positionedGlyphs)t.x+=c,t.y+=h})(e.positionedLines,_,b,w,f,g,o,v,a.length),e.top+=-w*v,e.bottom=e.top+v,e.left+=-b*f,e.right=e.left+f}(w,i,r,n,y,s,l,c,p,h,d,g),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(b)&&w}const $l={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Gl={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function ql(t,e,i,r,n,a){if(e.imageName){const t=r[e.imageName];return t?t.displaySize[0]*e.scale*ll/a+n:0}{const r=i[e.fontStack],a=r&&r[t];return a?a.metrics.advance*e.scale+n:0}}function Zl(t,e,i,r){const n=Math.pow(t-e,2);return r?t=0;let h=0;for(let p=0;p-i/2;){if(o--,o<0)return!1;s-=t[o].dist(a),a=t[o]}s+=t[o].dist(t[o+1]),o++;const l=[];let c=0;for(;sr;)c-=l.shift().angleDelta;if(c>n)return!1;o++,s+=e.dist(i)}return!0}function nc(t){let e=0;for(let i=0;ic){const a=(c-l)/n,u=Se(i.x,r.x,a),p=Se(i.y,r.y,a),d=new ic(u,p,r.angleTo(i),h);return d._round(),!o||rc(t,d,s,o,e)?d:void 0}l+=n}}function lc(t,e,i,r,n,a,o,s,l){const c=ac(r,a,o),h=oc(r,n),u=h*o,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-u=0&&_=0&&y=0&&p+c<=h){const e=new ic(_,y,f,m);e._round(),r&&!rc(t,e,a,r,n)||d.push(e)}}u+=s}return s||d.length||o||(d=cc(t,u/2,i,r,n,a,o,!0,l)),d}function hc(t,e,i,r,n){const a=[];for(let o=0;o=r&&c.x>=r||(o.x>=r?o=new S(r,o.y+(r-o.x)/(c.x-o.x)*(c.y-o.y))._round():c.x>=r&&(c=new S(r,o.y+(r-o.x)/(c.x-o.x)*(c.y-o.y))._round()),o.y>=n&&c.y>=n||(o.y>=n?o=new S(o.x+(n-o.y)/(c.y-o.y)*(c.x-o.x),n)._round():c.y>=n&&(c=new S(o.x+(n-o.y)/(c.y-o.y)*(c.x-o.x),n)._round()),l&&o.equals(l[l.length-1])||(l=[o],a.push(l)),l.push(c)))))}}return a}function uc(t,e,i,r){const n=[],a=t.image,o=a.pixelRatio,s=a.paddedRect.w-2,l=a.paddedRect.h-2,c=t.right-t.left,h=t.bottom-t.top,u=a.stretchX||[[0,s]],p=a.stretchY||[[0,l]],d=(t,e)=>t+e[1]-e[0],m=u.reduce(d,0),f=p.reduce(d,0),g=s-m,_=l-f;let y=0,x=m,v=0,b=f,w=0,T=g,E=0,I=_;if(a.content&&r){const t=a.content;y=pc(u,0,t[0]),v=pc(p,0,t[1]),x=pc(u,t[0],t[2]),b=pc(p,t[1],t[3]),w=t[0]-y,E=t[1]-v,T=t[2]-t[0]-x,I=t[3]-t[1]-b}const z=(r,n,s,l)=>{const u=mc(r.stretch-y,x,c,t.left),p=fc(r.fixed-w,T,r.stretch,m),d=mc(n.stretch-v,b,h,t.top),g=fc(n.fixed-E,I,n.stretch,f),_=mc(s.stretch-y,x,c,t.left),z=fc(s.fixed-w,T,s.stretch,m),C=mc(l.stretch-v,b,h,t.top),A=fc(l.fixed-E,I,l.stretch,f),k=new S(u,d),M=new S(_,d),P=new S(_,C),D=new S(u,C),L=new S(p/o,g/o),B=new S(z/o,A/o),R=e*Math.PI/180;if(R){const t=Math.sin(R),e=Math.cos(R),i=[e,-t,t,e];k._matMult(i),M._matMult(i),D._matMult(i),P._matMult(i)}const F=r.stretch+r.fixed,O=n.stretch+n.fixed;return{tl:k,tr:M,bl:D,br:P,tex:{x:a.paddedRect.x+1+F,y:a.paddedRect.y+1+O,w:s.stretch+s.fixed-F,h:l.stretch+l.fixed-O},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:L,pixelOffsetBR:B,minFontScaleX:T/o/c,minFontScaleY:I/o/h,isSDF:i}};if(r&&(a.stretchX||a.stretchY)){const t=dc(u,g,m),e=dc(p,_,f);for(let i=0;i0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=a.top*o-s[0],h=a.bottom*o+s[2],u=a.left*o-s[3],p=a.right*o+s[1];const d=a.collisionPadding;if(d&&(u-=d[0]*o,l-=d[1]*o,p+=d[2]*o,h+=d[3]*o),c){const t=new S(u,l),e=new S(p,l),i=new S(u,h),r=new S(p,h),n=c*Math.PI/180;t._rotate(n),e._rotate(n),i._rotate(n),r._rotate(n),u=Math.min(t.x,e.x,i.x,r.x),p=Math.max(t.x,e.x,i.x,r.x),l=Math.min(t.y,e.y,i.y,r.y),h=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,u,l,p,h,i,r,n)}this.boxEndIndex=t.length}}class _c{constructor(t=[],e=yc){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}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:i}=this,r=e[t];for(;t>0;){const n=t-1>>1,a=e[n];if(i(r,a)>=0)break;e[t]=a,t=n}e[t]=r}_down(t){const{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t=0)break;e[t]=a,t=r}e[t]=n}}function yc(t,e){return te?1:0}function xc(t,e=1,i=!1){let r=1/0,n=1/0,a=-1/0,o=-1/0;const s=t[0];for(let d=0;da)&&(a=t.x),(!d||t.y>o)&&(o=t.y)}const l=Math.min(a-r,o-n);let c=l/2;const h=new _c([],vc);if(0===l)return new S(r,n);for(let d=r;du.d||!u.d)&&(u=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,p)),r.max-u.d<=e||(c=r.h/2,h.push(new bc(r.p.x-c,r.p.y-c,c,t)),h.push(new bc(r.p.x+c,r.p.y-c,c,t)),h.push(new bc(r.p.x-c,r.p.y+c,c,t)),h.push(new bc(r.p.x+c,r.p.y+c,c,t)),p+=4)}return i&&(console.log(`num probes: ${p}`),console.log(`best distance: ${u.d}`)),u.p}function vc(t,e){return e.max-t.max}function bc(t,e,i,r){this.p=new S(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let n=0;nt.y!=s.y>t.y&&t.x<(s.x-n.x)*(t.y-n.y)/(s.y-n.y)+n.x&&(i=!i),r=Math.min(r,io(t,n,s))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const wc=Number.POSITIVE_INFINITY;function Tc(t,e){return e[1]!==wc?function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1]):function(t,e){let i=0,r=0;e<0&&(e=0);const n=e/Math.sqrt(2);switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0])}function Ec(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 Sc(e,i,r,n,a,o,s,l,c,h,u){let p=o.textMaxSize.evaluate(i,{});void 0===p&&(p=s);const d=e.layers[0].layout,f=d.get("icon-offset").evaluate(i,{},u),g=Cc(r.horizontal),_=s/24,y=e.tilePixelRatio*_,x=e.tilePixelRatio*p/24,v=e.tilePixelRatio*l,b=e.tilePixelRatio*d.get("symbol-spacing"),w=d.get("text-padding")*e.tilePixelRatio,T=function(t,e,i,r=1){const n=t.get("icon-padding").evaluate(e,{},i),a=n&&n.values;return[a[0]*r,a[1]*r,a[2]*r,a[3]*r]}(d,i,u,e.tilePixelRatio),E=d.get("text-max-angle")/180*Math.PI,S="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),I="map"===d.get("icon-rotation-alignment")&&"point"!==d.get("symbol-placement"),z=d.get("symbol-placement"),C=b/2,A=d.get("icon-text-fit");let k;n&&"none"!==A&&(e.allowVerticalPlacement&&r.vertical&&(k=Ql(n,r.vertical,A,d.get("icon-text-fit-padding"),f,_)),g&&(n=Ql(n,g,A,d.get("icon-text-fit-padding"),f,_)));const M=(l,p)=>{p.x<0||p.x>=$a||p.y<0||p.y>=$a||function(e,i,r,n,a,o,s,l,c,h,u,p,d,f,g,_,y,x,v,b,w,T,E,S,I){const z=e.addToLineVertexArray(i,r);let C,A,k,M,P=0,D=0,L=0,B=0,R=-1,F=-1;const O={};let V=ya.exports(""),U=0,N=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[U,N]=l.layout.get("text-offset").evaluate(w,{},S).map((t=>t*ll)):(U=l.layout.get("text-radial-offset").evaluate(w,{},S)*ll,N=wc),e.allowVerticalPlacement&&n.vertical){const t=l.layout.get("text-rotate").evaluate(w,{},S)+90;k=new gc(c,i,h,u,p,n.vertical,d,f,g,t),s&&(M=new gc(c,i,h,u,p,s,y,x,g,t))}if(a){const r=l.layout.get("icon-rotate").evaluate(w,{}),n="none"!==l.layout.get("icon-text-fit"),o=uc(a,r,E,n),d=s?uc(s,r,E,n):void 0;A=new gc(c,i,h,u,p,a,y,x,!1,r),P=4*o.length;const f=e.iconSizeData;let g=null;"source"===f.kind?(g=[tc*l.layout.get("icon-size").evaluate(w,{})],g[0]>Ic&&m(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(g=[tc*T.compositeIconSizes[0].evaluate(w,{},S),tc*T.compositeIconSizes[1].evaluate(w,{},S)],(g[0]>Ic||g[1]>Ic)&&m(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,o,g,b,v,w,t.WritingMode.none,i,z.lineStartIndex,z.lineLength,-1,S),R=e.icon.placedSymbolArray.length-1,d&&(D=4*d.length,e.addSymbols(e.icon,d,g,b,v,w,t.WritingMode.vertical,i,z.lineStartIndex,z.lineLength,-1,S),F=e.icon.placedSymbolArray.length-1)}const $=Object.keys(n.horizontal);for(const m of $){const r=n.horizontal[m];if(!C){V=ya.exports(r.text);const t=l.layout.get("text-rotate").evaluate(w,{},S);C=new gc(c,i,h,u,p,r,d,f,g,t)}const a=1===r.positionedLines.length;if(L+=zc(e,i,r,o,l,g,w,_,z,n.vertical?t.WritingMode.horizontal:t.WritingMode.horizontalOnly,a?$:[m],O,R,T,S),a)break}n.vertical&&(B+=zc(e,i,n.vertical,o,l,g,w,_,z,t.WritingMode.vertical,["vertical"],O,F,T,S));const G=C?C.boxStartIndex:e.collisionBoxArray.length,q=C?C.boxEndIndex:e.collisionBoxArray.length,Z=k?k.boxStartIndex:e.collisionBoxArray.length,j=k?k.boxEndIndex:e.collisionBoxArray.length,X=A?A.boxStartIndex:e.collisionBoxArray.length,H=A?A.boxEndIndex:e.collisionBoxArray.length,W=M?M.boxStartIndex:e.collisionBoxArray.length,K=M?M.boxEndIndex:e.collisionBoxArray.length;let J=-1;const Y=(t,e)=>t&&t.circleDiameter?Math.max(t.circleDiameter,e):e;J=Y(C,J),J=Y(k,J),J=Y(A,J),J=Y(M,J);const Q=J>-1?1:0;Q&&(J*=I/ll),e.glyphOffsetArray.length>=Fc.MAX_GLYPHS&&m("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,w.sortKey),e.symbolInstances.emplaceBack(i.x,i.y,O.right>=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,R,F,V,G,q,Z,j,X,H,W,K,h,L,B,P,D,Q,0,d,U,N,J)}(e,p,l,r,n,a,k,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,y,[w,w,w,w],S,c,v,T,I,f,i,o,h,u,s)};if("line"===z)for(const t of hc(i.geometry,0,0,$a,$a)){const i=lc(t,b,E,r.vertical||g,n,24,x,e.overscaling,$a);for(const r of i)g&&Ac(e,g.text,C,r)||M(t,r)}else if("line-center"===z){for(const t of i.geometry)if(t.length>1){const e=sc(t,E,r.vertical||g,n,24,x);e&&M(t,e)}}else if("Polygon"===i.type)for(const t of ps(i.geometry,0)){const e=xc(t,16);M(t[0],new ic(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry)M(t,new ic(t[0].x,t[0].y,0));else if("Point"===i.type)for(const t of i.geometry)for(const e of t)M([e],new ic(e.x,e.y,0))}const Ic=32640;function zc(t,e,i,r,n,a,o,s,l,c,h,u,p,d,f){const g=function(t,e,i,r,n,a,o,s){const l=r.layout.get("text-rotate").evaluate(a,{})*Math.PI/180,c=[];for(const h of e.positionedLines)for(const t of h.positionedGlyphs){if(!t.rect)continue;const r=t.rect||{};let a=4,u=!0,p=1,d=0;const m=(n||s)&&t.vertical,f=t.metrics.advance*t.scale/2;if(s&&e.verticalizable){const e=(t.scale-1)*ll,i=(ll-t.metrics.width*t.scale)/2;d=h.lineOffset/2-(t.imageName?-i:e)}if(t.imageName){const e=o[t.imageName];u=e.sdf,p=e.pixelRatio,a=1/p}const g=n?[t.x+f,t.y]:[0,0];let _=n?[0,0]:[t.x+f+i[0],t.y+i[1]-d],y=[0,0];m&&(y=_,_=[0,0]);const x=(t.metrics.left-a)*t.scale-f+_[0],v=(-t.metrics.top-a)*t.scale+_[1],b=x+r.w*t.scale/p,w=v+r.h*t.scale/p,T=new S(x,v),E=new S(b,v),I=new S(x,w),z=new S(b,w);if(m){const e=new S(-f,f-Ol),i=-Math.PI/2,r=12-f,n=new S(22-r,-(t.imageName?r:0)),a=new S(...y);T._rotateAround(i,e)._add(n)._add(a),E._rotateAround(i,e)._add(n)._add(a),I._rotateAround(i,e)._add(n)._add(a),z._rotateAround(i,e)._add(n)._add(a)}if(l){const t=Math.sin(l),e=Math.cos(l),i=[e,-t,t,e];T._matMult(i),E._matMult(i),I._matMult(i),z._matMult(i)}const C=new S(0,0),A=new S(0,0);c.push({tl:T,tr:E,bl:I,br:z,tex:r,writingMode:e.writingMode,glyphOffset:g,sectionIndex:t.sectionIndex,isSDF:u,pixelOffsetTL:C,pixelOffsetBR:A,minFontScaleX:0,minFontScaleY:0})}return c}(0,i,s,n,a,o,r,t.allowVerticalPlacement),_=t.textSizeData;let y=null;"source"===_.kind?(y=[tc*n.layout.get("text-size").evaluate(o,{})],y[0]>Ic&&m(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(y=[tc*d.compositeTextSizes[0].evaluate(o,{},f),tc*d.compositeTextSizes[1].evaluate(o,{},f)],(y[0]>Ic||y[1]>Ic)&&m(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,g,y,s,a,o,c,e,l.lineStartIndex,l.lineLength,p,f);for(const m of h)u[m]=t.text.placedSymbolArray.length-1;return 4*g.length}function Cc(t){for(const e in t)return t[e];return null}function Ac(t,e,i,r){const n=t.compareText;if(e in n){const t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])t.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=fo([]),this.placementViewportMatrix=fo([]);const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ec(this.zoom,i["text-size"]),this.iconSizeData=ec(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),a=r.get("symbol-z-order");this.canOverlap="never"!==$c(r,"text-overlap","text-allow-overlap")||"never"!==$c(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==a&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===a||"auto"===a&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map((e=>t.WritingMode[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Bc(new Va(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new Bc(new Va(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new Wn,this.lineVertexArray=new Kn,this.symbolInstances=new Hn}calculateGlyphDependencies(t,e,i,r,n){for(let a=0;a0)&&("constant"!==o.value.kind||o.value.value.length>0),h="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,u=a.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const p=i.iconDependencies,d=i.glyphDependencies,m=i.availableImages,f=new Yr(this.zoom);for(const{feature:g,id:_,index:y,sourceLayerIndex:x}of e){const e=n._featureFilter.needGeometry,i=ja(g,e);if(!n._featureFilter.filter(f,i,r))continue;let s,l;if(e||(i.geometry=Za(g)),c){const t=n.getValueAndResolveTokens("text-field",i,r,m),e=Ft.factory(t);Lc(e)&&(this.hasRTLText=!0),(!this.hasRTLText||"unavailable"===Wr()||this.hasRTLText&&Jr.isParsed())&&(s=ol(e,n,i))}if(h){const t=n.getValueAndResolveTokens("icon-image",i,r,m);l=t instanceof Vt?t:Vt.fromString(t)}if(!s&&!l)continue;const v=this.sortFeaturesByKey?u.evaluate(i,{},r):void 0;if(this.features.push({id:_,text:s,icon:l,index:y,sourceLayerIndex:x,geometry:i.geometry,properties:g.properties,type:kc[g.type],sortKey:v}),l&&(p[l.name]=!0),s){const e=o.evaluate(i,{},r).join(","),n="viewport"!==a.get("text-rotation-alignment")&&"point"!==a.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(t.WritingMode.vertical)>=0;for(const t of s.sections)if(t.image)p[t.image.name]=!0;else{const i=Pr(s.toString()),r=t.fontStack||e,a=d[r]=d[r]||{};this.calculateGlyphDependencies(t.text,a,n,this.allowVerticalPlacement,i)}}}"line"===a.get("symbol-placement")&&(this.features=function(t){const e={},i={},r=[];let n=0;function a(e){r.push(t[e]),n++}function o(t,e,n){const a=i[t];return delete i[t],i[e]=a,r[a].geometry[0].pop(),r[a].geometry[0]=r[a].geometry[0].concat(n[0]),a}function s(t,i,n){const a=e[i];return delete e[i],e[t]=a,r[a].geometry[0].shift(),r[a].geometry[0]=n[0].concat(r[a].geometry[0]),a}function l(t,e,i){const r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]);const n={};for(let a=t.segment+1;a=0;a--)n[a]={x:e[a].x,y:e[a].y,tileUnitDistanceFromAnchor:r},a>0&&(r+=e[a-1].dist(e[a]));for(let t=0;t0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let n=i.vertexStartIndex;nr[t]-r[e]||n[e]-n[t])),a}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex),[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex].forEach(((t,e,i)=>{t>=0&&i.indexOf(t)===e&&this.addIndicesForPlacedSymbol(this.text,t)})),e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ir("SymbolBucket",Fc,{omit:["layers","collisionBoxArray","features","compareText"]}),Fc.MAX_GLYPHS=65535,Fc.addDynamicAttributes=Dc;const Oc=new dn({"symbol-placement":new ln(rt.layout_symbol["symbol-placement"]),"symbol-spacing":new ln(rt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ln(rt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new cn(rt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ln(rt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ln(rt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new ln(rt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new ln(rt.layout_symbol["icon-ignore-placement"]),"icon-optional":new ln(rt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ln(rt.layout_symbol["icon-rotation-alignment"]),"icon-size":new cn(rt.layout_symbol["icon-size"]),"icon-text-fit":new ln(rt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ln(rt.layout_symbol["icon-text-fit-padding"]),"icon-image":new cn(rt.layout_symbol["icon-image"]),"icon-rotate":new cn(rt.layout_symbol["icon-rotate"]),"icon-padding":new cn(rt.layout_symbol["icon-padding"]),"icon-keep-upright":new ln(rt.layout_symbol["icon-keep-upright"]),"icon-offset":new cn(rt.layout_symbol["icon-offset"]),"icon-anchor":new cn(rt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ln(rt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ln(rt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ln(rt.layout_symbol["text-rotation-alignment"]),"text-field":new cn(rt.layout_symbol["text-field"]),"text-font":new cn(rt.layout_symbol["text-font"]),"text-size":new cn(rt.layout_symbol["text-size"]),"text-max-width":new cn(rt.layout_symbol["text-max-width"]),"text-line-height":new ln(rt.layout_symbol["text-line-height"]),"text-letter-spacing":new cn(rt.layout_symbol["text-letter-spacing"]),"text-justify":new cn(rt.layout_symbol["text-justify"]),"text-radial-offset":new cn(rt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ln(rt.layout_symbol["text-variable-anchor"]),"text-anchor":new cn(rt.layout_symbol["text-anchor"]),"text-max-angle":new ln(rt.layout_symbol["text-max-angle"]),"text-writing-mode":new ln(rt.layout_symbol["text-writing-mode"]),"text-rotate":new cn(rt.layout_symbol["text-rotate"]),"text-padding":new ln(rt.layout_symbol["text-padding"]),"text-keep-upright":new ln(rt.layout_symbol["text-keep-upright"]),"text-transform":new cn(rt.layout_symbol["text-transform"]),"text-offset":new cn(rt.layout_symbol["text-offset"]),"text-allow-overlap":new ln(rt.layout_symbol["text-allow-overlap"]),"text-overlap":new ln(rt.layout_symbol["text-overlap"]),"text-ignore-placement":new ln(rt.layout_symbol["text-ignore-placement"]),"text-optional":new ln(rt.layout_symbol["text-optional"])});var Vc={paint:new dn({"icon-opacity":new cn(rt.paint_symbol["icon-opacity"]),"icon-color":new cn(rt.paint_symbol["icon-color"]),"icon-halo-color":new cn(rt.paint_symbol["icon-halo-color"]),"icon-halo-width":new cn(rt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new cn(rt.paint_symbol["icon-halo-blur"]),"icon-translate":new ln(rt.paint_symbol["icon-translate"]),"icon-translate-anchor":new ln(rt.paint_symbol["icon-translate-anchor"]),"text-opacity":new cn(rt.paint_symbol["text-opacity"]),"text-color":new cn(rt.paint_symbol["text-color"],{runtimeType:ft,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new cn(rt.paint_symbol["text-halo-color"]),"text-halo-width":new cn(rt.paint_symbol["text-halo-width"]),"text-halo-blur":new cn(rt.paint_symbol["text-halo-blur"]),"text-translate":new ln(rt.paint_symbol["text-translate"]),"text-translate-anchor":new ln(rt.paint_symbol["text-translate-anchor"])}),layout:Oc};class Uc{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:ut,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}}Ir("FormatSectionOverride",Uc,{omit:["defaultValue"]});class Nc extends fn{constructor(t){super(t,Vc)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.indexOf(i)<0&&e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,r){const n=this.layout.get(t).evaluate(e,{},i,r),a=this._unevaluatedLayout._values[t];return a.isDataDriven()||Di(a.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Fc(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Vc.paint.overridableProperties){if(!Nc.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Uc(e),r=new Pi(i,e.property.specification);let n=null;n="constant"===e.value.kind||"source"===e.value.kind?new Bi("source",r):new Ri("composite",r,e.value.zoomStops),this.paint._values[t]=new on(e.property,n,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Nc.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),r=Vc.paint.properties[e];let n=!1;const a=t=>{for(const e of t)if(r.overrides&&r.overrides.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ft)a(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{n||(e instanceof qt&&$t(e.value)===xt?a(e.value.sections):e instanceof hi?a(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}}function $c(t,e,i){let r="never";const n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}var Gc={paint:new dn({"background-color":new ln(rt.paint_background["background-color"]),"background-pattern":new un(rt.paint_background["background-pattern"]),"background-opacity":new ln(rt.paint_background["background-opacity"])})},qc={paint:new dn({"raster-opacity":new ln(rt.paint_raster["raster-opacity"]),"raster-hue-rotate":new ln(rt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ln(rt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ln(rt.paint_raster["raster-brightness-max"]),"raster-saturation":new ln(rt.paint_raster["raster-saturation"]),"raster-contrast":new ln(rt.paint_raster["raster-contrast"]),"raster-resampling":new ln(rt.paint_raster["raster-resampling"]),"raster-fade-duration":new ln(rt.paint_raster["raster-fade-duration"])})};class Zc extends fn{constructor(t){super(t,{}),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}const jc={circle:class extends fn{constructor(t){super(t,ho)}createBucket(t){return new Ha(t)}queryRadius(t){const e=t;return oo("circle-radius",this,e)+oo("circle-stroke-width",this,e)+so(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,r,n,a,o,s){const l=lo(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),a.angle,o),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),h="map"===this.paint.get("circle-pitch-alignment"),u=h?l:function(t,e){return t.map((t=>To(t,e)))}(l,s),p=h?c*o:c;for(const d of r)for(const t of d){const e=h?t:To(t,s);let i=p;const r=bo([],[t.x,t.y,0,1],s);if("viewport"===this.paint.get("circle-pitch-scale")&&"map"===this.paint.get("circle-pitch-alignment")?i*=r[3]/a.cameraToCenterDistance:"map"===this.paint.get("circle-pitch-scale")&&"viewport"===this.paint.get("circle-pitch-alignment")&&(i*=a.cameraToCenterDistance/r[3]),Ka(u,e,i))return!0}return!1}},heatmap:class extends fn{constructor(t){super(t,So),this._updateColorRamp()}createBucket(t){return new Eo(t)}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Mo({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(){return 0}queryIntersectsFeature(){return!1}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}},hillshade:class extends fn{constructor(t){super(t,Po)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}},fill:class extends fn{constructor(t){super(t,ys)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new gs(t)}queryRadius(){return so(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,r,n,a,o){return Ja(lo(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),a.angle,o),r)}isTileClipped(){return!0}},"fill-extrusion":class extends fn{constructor(t){super(t,Us)}createBucket(t){return new Fs(t)}queryRadius(){return so(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(t,e,i,r,n,a,o,s){const l=lo(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),a.angle,o),c=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=function(t,e,i,r){const n=[];for(const a of t){const t=[a.x,a.y,0,1];bo(t,t,e),n.push(new S(t[0]/t[3],t[1]/t[3]))}return n}(l,s),p=function(t,e,i,r){const n=[],a=[],o=r[8]*e,s=r[9]*e,l=r[10]*e,c=r[11]*e,h=r[8]*i,u=r[9]*i,p=r[10]*i,d=r[11]*i;for(const m of t){const t=[],e=[];for(const i of m){const n=i.x,a=i.y,m=r[0]*n+r[4]*a+r[12],f=r[1]*n+r[5]*a+r[13],g=r[2]*n+r[6]*a+r[14],_=r[3]*n+r[7]*a+r[15],y=g+l,x=_+c,v=m+h,b=f+u,w=g+p,T=_+d,E=new S((m+o)/x,(f+s)/x);E.z=y/x,t.push(E);const I=new S(v/T,b/T);I.z=w/T,e.push(I)}n.push(t),a.push(e)}return[n,a]}(r,h,c,s);return function(t,e,i){let r=1/0;Ja(i,e)&&(r=$s(i,e[0]));for(let n=0;n=3)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(){delete this._channel,this._callback=()=>{}}}const Hc=6371008.8;class Wc{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Wc(o(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Hc*Math.acos(Math.min(n,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new Kc(new Wc(this.lng-i,this.lat-e),new Wc(this.lng+i,this.lat+e))}static convert(t){if(t instanceof Wc)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Wc(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Wc(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class Kc{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Wc?new Wc(t.lng,t.lat):Wc.convert(t),this}setSouthWest(t){return this._sw=t instanceof Wc?new Wc(t.lng,t.lat):Wc.convert(t),this}extend(t){const e=this._sw,i=this._ne;let r,n;if(t instanceof Wc)r=t,n=t;else{if(!(t instanceof Kc))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(Kc.convert(t)):this.extend(Wc.convert(t)):this;if(r=t._sw,n=t._ne,!r||!n)return this}return e||i?(e.lng=Math.min(r.lng,e.lng),e.lat=Math.min(r.lat,e.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new Wc(r.lng,r.lat),this._ne=new Wc(n.lng,n.lat)),this}getCenter(){return new Wc((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Wc(this.getWest(),this.getNorth())}getSouthEast(){return new Wc(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Wc.convert(t);let r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(t){return t instanceof Kc?t:t?new Kc(t):t}}const Jc=2*Math.PI*Hc;function Yc(t){return Jc*Math.cos(t*Math.PI/180)}function Qc(t){return(180+t)/360}function th(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function eh(t,e){return t/Yc(e)}function ih(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}class rh{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Wc.convert(t);return new rh(Qc(i.lng),th(i.lat),eh(e,i.lat))}toLngLat(){return new Wc(360*this.x-180,ih(this.y))}toAltitude(){return this.z*Yc(ih(this.y))}meterInMercatorCoordinateUnits(){return 1/Jc*(t=ih(this.y),1/Math.cos(t*Math.PI/180));var t}}function nh(t,e,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[t*r-2*Math.PI*6378137/2,e*r-2*Math.PI*6378137/2]}class ah{constructor(t,e,i){if(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=lh(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const r=(a=this.y,o=this.z,s=nh(256*(n=this.x),256*(a=Math.pow(2,o)-a-1),o),l=nh(256*(n+1),256*(a+1),o),s[0]+","+s[1]+","+l[0]+","+l[1]);var n,a,o,s,l;const c=function(t,e,i){let r,n="";for(let a=t;a>0;a--)r=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new S((t.x*e-this.x)*$a,(t.y*e-this.y)*$a)}toString(){return`${this.z}/${this.x}/${this.y}`}}class oh{constructor(t,e){this.wrap=t,this.canonical=e,this.key=lh(t,e.z,e.z,e.x,e.y)}}class sh{constructor(t,e,i,r,n){if(t= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new ah(i,+r,+n),this.key=lh(e,t,i,r,n)}clone(){return new sh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new sh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new sh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?lh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):lh(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new sh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new sh(e,this.wrap,e,i,r),new sh(e,this.wrap,e,i+1,r),new sh(e,this.wrap,e,i,r+1),new sh(e,this.wrap,e,i+1,r+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.ythis.max&&(this.max=e),e=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,i){return(256*t*256+256*e+i)/10-1e4}_unpackTerrarium(t,e,i){return 256*t+e+i/256-32768}getPixels(){return new ko({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,a=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:a=o-1;break;case 1:o=a+1}const s=-e*this.dim,l=-i*this.dim;for(let c=a;c=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class uh{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,t._z=e,t._x=i,t._y=r,this.properties=t.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&(t[e]=this[e]);return t}}class ph{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Er($a,16,0),this.grid3D=new Er($a,16,0),this.featureIndexArray=new Yn,this.promoteId=e}insert(t,e,i,r,n,a){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const s=a?this.grid3D:this.grid;for(let l=0;l=0&&i[3]>=0&&s.insert(o,i[0],i[1],i[2],i[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new ws.VectorTile(new cl(this.rawTileData)).layers,this.sourceLayerCoder=new hh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();const n=t.params||{},a=$a/t.tileSize/t.scale,o=Hi(n.filter),s=t.queryGeometry,l=t.queryPadding*a,c=mh(s),h=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),u=mh(t.cameraQueryGeometry),p=this.grid3D.query(u.minX-l,u.minY-l,u.maxX+l,u.maxY+l,((e,i,r,n)=>function(t,e,i,r,n){for(const o of t)if(e<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const a=[new S(e,i),new S(e,n),new S(r,n),new S(r,i)];if(t.length>2)for(const o of a)if(no(t,o))return!0;for(let o=0;o(u||(u=Za(e)),i.queryIntersectsFeature(s,e,r,u,this.z,t.transform,a,t.pixelPosMatrix))))}return d}loadMatchingFeature(t,e,i,r,n,a,o,l,c,h,u){const p=this.bucketLayerIDs[e];if(a&&!function(t,e){for(let i=0;i=0)return!0;return!1}(a,p))return;const d=this.sourceLayerCoder.decode(i),m=this.vtLayers[d].feature(r);if(n.needGeometry){const t=ja(m,!0);if(!n.filter(new Yr(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new Yr(this.tileID.overscaledZ),m))return;const f=this.getId(m,d);for(let g=0;g{const o=e instanceof sn?e.get(a):null;return o&&o.evaluate?o.evaluate(i,r,n):o}))}function mh(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(const a of t)e=Math.min(e,a.x),i=Math.min(i,a.y),r=Math.max(r,a.x),n=Math.max(n,a.y);return{minX:e,minY:i,maxX:r,maxY:n}}function fh(t,e){return e-t}var gh;Ir("FeatureIndex",ph,{omit:["rawTileData","sourceLayerCoder"]}),t.PerformanceMarkers=void 0,(gh=t.PerformanceMarkers||(t.PerformanceMarkers={})).create="create",gh.load="load",gh.fullLoad="fullLoad";let _h=null,yh=[];const xh=1e3/30,vh={mark(t){performance.mark(t)},frame(t){const e=t;null!=_h&&yh.push(e-_h),_h=e},clearMetrics(){_h=null,yh=[],performance.clearMeasures("loadTime"),performance.clearMeasures("fullLoadTime");for(const e in t.PerformanceMarkers)performance.clearMarks(t.PerformanceMarkers[e])},getPerformanceMetrics(){performance.measure("loadTime",t.PerformanceMarkers.create,t.PerformanceMarkers.load),performance.measure("fullLoadTime",t.PerformanceMarkers.create,t.PerformanceMarkers.fullLoad);const e=performance.getEntriesByName("loadTime")[0].duration,i=performance.getEntriesByName("fullLoadTime")[0].duration,r=yh.length,n=1/(yh.reduce(((t,e)=>t+e),0)/r/1e3),a=yh.filter((t=>t>xh)).reduce(((t,e)=>t+(e-xh)/xh),0);return{loadTime:e,fullLoadTime:i,fps:n,percentDroppedFrames:a/(r+a)*100}}};t.AJAXError=$,t.ARRAY_TYPE=po,t.Actor=class{constructor(t,e,i){this.target=t,this.parent=e,this.mapId=i,this.callbacks={},this.tasks={},this.taskQueue=[],this.cancelCallbacks={},c(["receive","process"],this),this.invoker=new Xc(this.process),this.target.addEventListener("message",this.receive,!1),this.globalScope=_()?t:window}send(t,e,i,r,n=!1){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(this.callbacks[a]=i);const o=w(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:t,hasCallback:!!i,targetMapId:r,mustQueue:n,sourceMapId:this.mapId,data:Cr(e,o)},o),{cancel:()=>{i&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){delete this.tasks[i];const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t()}else _()||e.mustQueue?(this.tasks[i]=e,this.taskQueue.push(i),this.invoker.trigger()):this.processTask(i,e)}process(){if(!this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,e){if(""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i(Ar(e.error)):i(null,Ar(e.data)))}else{let i=!1;const r=w(this.globalScope)?void 0:[],n=e.hasCallback?(e,n)=>{i=!0,delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Cr(e):null,data:Cr(n,r)},r)}:t=>{i=!0};let a=null;const o=Ar(e.data);if(this.parent[e.type])a=this.parent[e.type](e.sourceMapId,o,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");a=this.parent.getWorkerSource(e.sourceMapId,t[0],o.source)[t[1]](o,n)}else n(new Error(`Could not find function ${e.type}`));!i&&a&&a.cancel&&(this.cancelCallbacks[t]=a.cancel)}}remove(){this.invoker.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.AlphaImage=Ao,t.CanonicalTileID=ah,t.CollisionBoxArray=qn,t.CollisionCircleLayoutArray=class extends Pn{},t.Color=Lt,t.DEMData=ch,t.DataConstantProperty=ln,t.DictionaryCoder=hh,t.EXTENT=$a,t.ErrorEvent=et,t.EvaluationParameters=Yr,t.Event=tt,t.Evented=it,t.FeatureIndex=ph,t.FillBucket=gs,t.FillExtrusionBucket=Fs,t.GeoJSONFeature=uh,t.ImageAtlas=Fl,t.ImagePosition=Rl,t.LineBucket=Ks,t.LineStripIndexArray=class extends Nn{},t.LngLat=Wc,t.LngLatBounds=Kc,t.MercatorCoordinate=rh,t.ONE_EM=ll,t.OverscaledTileID=sh,t.PerformanceUtils=vh,t.PosArray=Qn,t.Properties=dn,t.QuadTriangleArray=class extends Ln{},t.RGBAImage=ko,t.RasterBoundsArray=class extends wn{},t.RequestPerformance=class{constructor(t){this._marks={start:[t.url,"start"].join("#"),end:[t.url,"end"].join("#"),measure:t.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let t=performance.getEntriesByName(this._marks.measure);return 0===t.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),t=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),t}},t.ResourceType=N,t.SegmentVector=fa,t.SymbolBucket=Fc,t.Transitionable=en,t.TriangleIndexArray=ua,t.Uniform1f=Ca,t.Uniform1i=class extends za{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.Uniform2f=class extends za{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.Uniform3f=class extends za{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.Uniform4f=Aa,t.UniformColor=ka,t.UniformMatrix4f=class extends za{constructor(t,e){super(t,e),this.current=Ma}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.UnwrappedTileID=oh,t.ValidationError=nt,t.ZoomHistory=kr,t.add=function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t},t.addDynamicAttributes=Dc,t.asyncAll=function(t,e,i){if(!t.length)return i(null,[]);let r=t.length;const n=new Array(t.length);let a=null;t.forEach(((t,o)=>{e(t,((t,e)=>{t&&(a=t),n[o]=e,0==--r&&i(a,n)}))}))},t.bezier=r,t.bindAll=c,t.cacheEntryPossiblyAdded=function(t){L++,L>P&&(t.getActor().send("enforceCacheSizeLimit",M),L=0)},t.clamp=a,t.clearTileCache=function(t){const e=caches.delete(C);t&&e.catch(t).then((()=>t()))},t.clipLine=hc,t.clone=function(t){var e=new po(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=p,t.clone$2=function(t){var e=new po(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.collisionCircleLayout=al,t.config=z,t.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.create=function(){var t=new po(16);return po!=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=mo,t.createExpression=Li,t.createFilter=Hi,t.createLayout=xn,t.createStyleLayer=function(t){return"custom"===t.type?new Zc(t):new jc[t.type](t)},t.cross=function(t,e,i){var r=e[0],n=e[1],a=e[2],o=i[0],s=i[1],l=i[2];return t[0]=n*l-a*s,t[1]=a*o-r*l,t[2]=r*s-n*o,t},t.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.dot$1=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},t.ease=n,t.emitValidationErrors=Tr,t.enforceCacheSizeLimit=function(t){D(),A&&A.then((e=>{e.keys().then((i=>{for(let r=0;r{}}},t.identity=fo,t.invert=function(t,e){var i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],s=e[5],l=e[6],c=e[7],h=e[8],u=e[9],p=e[10],d=e[11],m=e[12],f=e[13],g=e[14],_=e[15],y=i*s-r*o,x=i*l-n*o,v=i*c-a*o,b=r*l-n*s,w=r*c-a*s,T=n*c-a*l,E=h*f-u*m,S=h*g-p*m,I=h*_-d*m,z=u*g-p*f,C=u*_-d*f,A=p*_-d*g,k=y*A-x*C+v*z+b*I-w*S+T*E;return k?(t[0]=(s*A-l*C+c*z)*(k=1/k),t[1]=(n*C-r*A-a*z)*k,t[2]=(f*T-g*w+_*b)*k,t[3]=(p*w-u*T-d*b)*k,t[4]=(l*I-o*A-c*S)*k,t[5]=(i*A-n*I+a*S)*k,t[6]=(g*v-m*T-_*x)*k,t[7]=(h*T-p*v+d*x)*k,t[8]=(o*C-s*I+c*E)*k,t[9]=(r*I-i*C-a*E)*k,t[10]=(m*w-f*v+_*y)*k,t[11]=(u*v-h*w-d*y)*k,t[12]=(s*S-o*z-l*E)*k,t[13]=(i*z-r*S+n*E)*k,t[14]=(f*x-m*b-g*y)*k,t[15]=(h*b-u*x+p*y)*k,t):null},t.isImageBitmap=T,t.isSafari=w,t.isWorker=_,t.keysDifference=function(t,e){const i=[];for(const r in t)r in e||i.push(r);return i},t.lazyLoadRTLTextPlugin=function(){Jr.isLoading()||Jr.isLoaded()||"deferred"!==Wr()||Kr()},t.makeRequest=Z,t.mapObject=h,t.mercatorXfromLng=Qc,t.mercatorYfromLat=th,t.mercatorZfromAltitude=eh,t.mul=yo,t.mul$1=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t},t.multiply=go,t.nextPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.normalize=function(t,e){var i=e[0],r=e[1],n=e[2],a=i*i+r*r+n*n;return a>0&&(a=1/Math.sqrt(a)),t[0]=e[0]*a,t[1]=e[1]*a,t[2]=e[2]*a,t},t.number=Se,t.ortho=function(t,e,i,r,n,a,o){var s=1/(e-i),l=1/(r-n),c=1/(a-o);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+i)*s,t[13]=(n+r)*l,t[14]=(o+a)*c,t[15]=1,t},t.parseCacheControl=y,t.parseGlyphPbf=function(t){return new cl(t).readFields(Pl,[])},t.pbf=cl,t.performSymbolLayout=function(e){e.bucket.createArrays(),e.bucket.tilePixelRatio=$a/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const i=e.bucket.layers[0].layout,r=e.bucket.layers[0]._unevaluatedLayout._values,n={layoutIconSize:r["icon-size"].possiblyEvaluate(new Yr(e.bucket.zoom+1),e.canonical),layoutTextSize:r["text-size"].possiblyEvaluate(new Yr(e.bucket.zoom+1),e.canonical),textMaxSize:r["text-size"].possiblyEvaluate(new Yr(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.textSizeData;n.compositeTextSizes=[r["text-size"].possiblyEvaluate(new Yr(t),e.canonical),r["text-size"].possiblyEvaluate(new Yr(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;n.compositeIconSizes=[r["icon-size"].possiblyEvaluate(new Yr(t),e.canonical),r["icon-size"].possiblyEvaluate(new Yr(i),e.canonical)]}const a=i.get("text-line-height")*ll,o="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement"),s=i.get("text-keep-upright"),l=i.get("text-size");for(const c of e.bucket.features){const r=i.get("text-font").evaluate(c,{},e.canonical).join(","),h=l.evaluate(c,{},e.canonical),u=n.layoutTextSize.evaluate(c,{},e.canonical),p=n.layoutIconSize.evaluate(c,{},e.canonical),d={horizontal:{},vertical:void 0},f=c.text;let g,_=[0,0];if(f){const n=f.toString(),l=i.get("text-letter-spacing").evaluate(c,{},e.canonical)*ll,p=Dr(n)?l:0,m=i.get("text-anchor").evaluate(c,{},e.canonical),g=i.get("text-variable-anchor");if(!g){const t=i.get("text-radial-offset").evaluate(c,{},e.canonical);_=t?Tc(m,[t*ll,wc]):i.get("text-offset").evaluate(c,{},e.canonical).map((t=>t*ll))}let y=o?"center":i.get("text-justify").evaluate(c,{},e.canonical);const x=i.get("symbol-placement"),v="point"===x?i.get("text-max-width").evaluate(c,{},e.canonical)*ll:0,b=()=>{e.bucket.allowVerticalPlacement&&Pr(n)&&(d.vertical=Nl(f,e.glyphMap,e.glyphPositions,e.imagePositions,r,v,a,m,"left",p,_,t.WritingMode.vertical,!0,x,u,h))};if(!o&&g){const i="auto"===y?g.map((t=>Ec(t))):[y];let n=!1;for(let o=0;othis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const a=i.sourceLayer||"_geojsonTileLayer";let o=n[a];o||(o=n[a]=[]),o.push(e)}}}class n{constructor(e){const i={},r=[];for(const t in e){const n=e[t],a=i[t]={};for(const t in n){const e=n[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};r.push(i),a[t]={rect:i,metrics:e.metrics}}}const{w:n,h:a}=t.potpack(r),o=new t.AlphaImage({width:n||1,height:a||1});for(const s in e){const r=e[s];for(const e in r){const n=r[+e];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const a=i[s][e].rect;t.AlphaImage.copy(n.bitmap,o,{x:0,y:0},{x:a.x+1,y:a.y+1},n.bitmap)}}this.image=o,this.positions=i}}t.register("GlyphAtlas",n);class a{constructor(e){this.tileID=new t.OverscaledTileID(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId}parse(e,i,r,a,s){this.status="parsing",this.data=e,this.collisionBoxArray=new t.CollisionBoxArray;const l=new t.DictionaryCoder(Object.keys(e.layers).sort()),c=new t.FeatureIndex(this.tileID,this.promoteId);c.bucketLayerIDs=[];const h={},u={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:r},p=i.familiesBySource[this.source];for(const n in p){const i=e.layers[n];if(!i)continue;1===i.version&&t.warnOnce(`Vector tile source "${this.source}" layer "${n}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const a=l.encode(n),s=[];for(let t=0;t=i.maxzoom||"none"!==i.visibility&&(o(e,this.zoom,r),(h[i.id]=i.createBucket({index:c.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:a,sourceID:this.source})).populate(s,u,this.tileID.canonical),c.bucketLayerIDs.push(e.map((t=>t.id))))}}let d,m,f,g;const _=t.mapObject(u.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(_).length?a.send("getGlyphs",{uid:this.uid,stacks:_},((t,e)=>{d||(d=t,m=e,v.call(this))})):m={};const y=Object.keys(u.iconDependencies);y.length?a.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{d||(d=t,f=e,v.call(this))})):f={};const x=Object.keys(u.patternDependencies);function v(){if(d)return s(d);if(m&&f&&g){const e=new n(m),i=new t.ImageAtlas(f,g);for(const n in h){const a=h[n];a instanceof t.SymbolBucket?(o(a.layers,this.zoom,r),t.performSymbolLayout({bucket:a,glyphMap:m,glyphPositions:e.positions,imageMap:f,imagePositions:i.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):a.hasPattern&&(a instanceof t.LineBucket||a instanceof t.FillBucket||a instanceof t.FillExtrusionBucket)&&(o(a.layers,this.zoom,r),a.addFeatures(u,this.tileID.canonical,i.patternPositions))}this.status="done",s(null,{buckets:Object.values(h).filter((t=>!t.isEmpty())),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,imageAtlas:i,glyphMap:this.returnDependencies?m:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}x.length?a.send("getImages",{icons:x,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{d||(d=t,g=e,v.call(this))})):g={},v.call(this)}}function o(e,i,r){const n=new t.EvaluationParameters(i);for(const t of e)t.recalculate(n,r)}function s(e,i){const r=t.getArrayBuffer(e.request,((e,r,n,a)=>{e?i(e):r&&i(null,{vectorTile:new t.vectorTile.VectorTile(new t.pbf(r)),rawData:r,cacheControl:n,expires:a})}));return()=>{r.cancel(),i()}}class l{constructor(t,e,i,r){this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=r||s,this.loading={},this.loaded={}}loadTile(e,i){const r=e.uid;this.loading||(this.loading={});const n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request),o=this.loading[r]=new a(e);o.abort=this.loadVectorData(e,((e,a)=>{if(delete this.loading[r],e||!a)return o.status="done",this.loaded[r]=o,i(e);const s=a.rawData,l={};a.expires&&(l.expires=a.expires),a.cacheControl&&(l.cacheControl=a.cacheControl);const c={};if(n){const t=n.finish();t&&(c.resourceTiming=JSON.parse(JSON.stringify(t)))}o.vectorTile=a.vectorTile,o.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,((e,r)=>{if(e||!r)return i(e);i(null,t.extend({rawTileData:s.slice(0)},r,l,c))})),this.loaded=this.loaded||{},this.loaded[r]=o}))}reloadTile(t,e){const i=this.loaded,r=t.uid,n=this;if(i&&i[r]){const a=i[r];a.showCollisionBoxes=t.showCollisionBoxes;const o=(t,i)=>{const r=a.reloadCallback;r&&(delete a.reloadCallback,a.parse(a.vectorTile,n.layerIndex,this.availableImages,n.actor,r)),e(t,i)};"parsing"===a.status?a.reloadCallback=o:"done"===a.status&&(a.vectorTile?a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.actor,o):o())}}abortTile(t,e){const i=this.loading,r=t.uid;i&&i[r]&&i[r].abort&&(i[r].abort(),delete i[r]),e()}removeTile(t,e){const i=this.loaded,r=t.uid;i&&i[r]&&delete i[r],e()}}class c{constructor(){this.loaded={}}loadTile(e,i){const{uid:r,encoding:n,rawImageData:a}=e,o=t.isImageBitmap(a)?this.getImageData(a):a,s=new t.DEMData(r,o,n);this.loaded=this.loaded||{},this.loaded[r]=s,i(null,s)}getImageData(e){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 i=this.offscreenCanvasContext.getImageData(-1,-1,e.width+2,e.height+2);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),new t.RGBAImage({width:i.width,height:i.height},i.data)}removeTile(t){const e=this.loaded,i=t.uid;e&&e[i]&&delete e[i]}}var h=function t(e,i){var r,n=e&&e.type;if("FeatureCollection"===n)for(r=0;r=Math.abs(s)?i-l+s:s-l+i,i=l}i+r>=0!=!!e&&t.reverse()}const d=t.vectorTile.VectorTileFeature.prototype.toGeoJSON;class m{constructor(e){this._feature=e,this.extent=t.EXTENT,this.type=e.type,this.properties=e.tags,"id"in e&&!isNaN(e.id)&&(this.id=parseInt(e.id,10))}loadGeometry(){if(1===this._feature.type){const e=[];for(const i of this._feature.geometry)e.push([new t.pointGeometry(i[0],i[1])]);return e}{const e=[];for(const i of this._feature.geometry){const r=[];for(const e of i)r.push(new t.pointGeometry(e[0],e[1]));e.push(r)}return e}}toGeoJSON(t,e,i){return d.call(this,t,e,i)}}class f{constructor(e){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=t.EXTENT,this.length=e.length,this._features=e}feature(t){return new m(this._features[t])}}var g={exports:{}},_=t.pointGeometry,y=t.vectorTile.VectorTileFeature,x=v;function v(t,e){this.options=e||{},this.features=t,this.length=t.length}function b(t,e){this.id="number"==typeof t.id?t.id:void 0,this.type=t.type,this.rawGeometry=1===t.type?[t.geometry]:t.geometry,this.properties=t.tags,this.extent=e||4096}v.prototype.feature=function(t){return new b(this.features[t],this.options.extent)},b.prototype.loadGeometry=function(){var t=this.rawGeometry;this.geometry=[];for(var e=0;e>31}function k(t,e){for(var i=t.loadGeometry(),r=t.type,n=0,a=0,o=i.length,s=0;s>1;D(t,e,o,r,n,a%2),P(t,e,i,r,o-1,a+1),P(t,e,i,o+1,n,a+1)}function D(t,e,i,r,n,a){for(;n>r;){if(n-r>600){const o=n-r+1,s=i-r+1,l=Math.log(o),c=.5*Math.exp(2*l/3),h=.5*Math.sqrt(l*c*(o-c)/o)*(s-o/2<0?-1:1);D(t,e,i,Math.max(r,Math.floor(i-s*c/o+h)),Math.min(n,Math.floor(i+(o-s)*c/o+h)),a)}const o=e[2*i+a];let s=r,l=n;for(L(t,e,r,i),e[2*n+a]>o&&L(t,e,r,n);so;)l--}e[2*r+a]===o?L(t,e,r,l):(l++,L(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function L(t,e,i,r){B(t,i,r),B(e,2*i,2*r),B(e,2*i+1,2*r+1)}function B(t,e,i){const r=t[e];t[e]=t[i],t[i]=r}function R(t,e,i,r){const n=t-i,a=e-r;return n*n+a*a}g.exports=E,g.exports.fromVectorTileJs=E,g.exports.fromGeojsonVt=function(t,e){e=e||{};var i={};for(var r in t)i[r]=new T(t[r].features,e),i[r].name=r,i[r].version=e.version,i[r].extent=e.extent;return E({layers:i})},g.exports.GeoJSONWrapper=T;const F=t=>t[0],O=t=>t[1];class V{constructor(t,e=F,i=O,r=64,n=Float64Array){this.nodeSize=r,this.points=t;const a=t.length<65536?Uint16Array:Uint32Array,o=this.ids=new a(t.length),s=this.coords=new n(2*t.length);for(let l=0;l=i&&c<=n&&h>=r&&h<=a&&l.push(t[o]);continue}const m=Math.floor((d+p)/2);c=e[2*m],h=e[2*m+1],c>=i&&c<=n&&h>=r&&h<=a&&l.push(t[m]);const f=(u+1)%2;(0===u?i<=c:r<=h)&&(s.push(d),s.push(m-1),s.push(f)),(0===u?n>=c:a>=h)&&(s.push(m+1),s.push(p),s.push(f))}return l}(this.ids,this.coords,t,e,i,r,this.nodeSize)}within(t,e,i){return function(t,e,i,r,n,a){const o=[0,t.length-1,0],s=[],l=n*n;for(;o.length;){const c=o.pop(),h=o.pop(),u=o.pop();if(h-u<=a){for(let n=u;n<=h;n++)R(e[2*n],e[2*n+1],i,r)<=l&&s.push(t[n]);continue}const p=Math.floor((u+h)/2),d=e[2*p],m=e[2*p+1];R(d,m,i,r)<=l&&s.push(t[p]);const f=(c+1)%2;(0===c?i-n<=d:r-n<=m)&&(o.push(u),o.push(p-1),o.push(f)),(0===c?i+n>=d:r+n>=m)&&(o.push(p+1),o.push(h),o.push(f))}return s}(this.ids,this.coords,t,e,i,this.nodeSize)}}const U={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t},N=Math.fround||($=new Float32Array(1),t=>($[0]=+t,$[0]));var $;class G{constructor(t){this.options=J(Object.create(U),t),this.trees=new Array(this.options.maxZoom+1)}load(t){const{log:e,minZoom:i,maxZoom:r,nodeSize:n}=this.options;e&&console.time("total time");const a=`prepare ${t.length} points`;e&&console.time(a),this.points=t;let o=[];for(let s=0;s=i;s--){const t=+Date.now();o=this._cluster(o,s),this.trees[s]=new V(o,Y,Q,n,Float32Array),e&&console.log("z%d: %d clusters in %dms",s,o.length,+Date.now()-t)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[1]));let n=180===t[2]?180:((t[2]+180)%360+360)%360-180;const a=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,n=180;else if(i>n){const t=this.getClusters([i,r,180,a],e),o=this.getClusters([-180,r,n,a],e);return t.concat(o)}const o=this.trees[this._limitZoom(e)],s=o.range(H(i),W(a),H(n),W(r)),l=[];for(const c of s){const t=o.points[c];l.push(t.numPoints?j(t):this.points[t.index])}return l}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const a=n.points[e];if(!a)throw new Error(r);const o=this.options.radius/(this.options.extent*Math.pow(2,i-1)),s=n.within(a.x,a.y,o),l=[];for(const c of s){const e=n.points[c];e.parentId===t&&l.push(e.numPoints?j(e):this.points[e.index])}if(0===l.length)throw new Error(r);return l}getLeaves(t,e,i){const r=[];return this._appendLeaves(r,t,e=e||10,i=i||0,0),r}getTile(t,e,i){const r=this.trees[this._limitZoom(t)],n=Math.pow(2,t),{extent:a,radius:o}=this.options,s=o/a,l=(i-s)/n,c=(i+1+s)/n,h={features:[]};return this._addTileFeatures(r.range((e-s)/n,l,(e+1+s)/n,c),r.points,e,i,n,h),0===e&&this._addTileFeatures(r.range(1-s/n,l,1,c),r.points,n,i,n,h),e===n-1&&this._addTileFeatures(r.range(0,l,s/n,c),r.points,-1,i,n,h),h.features.length?h:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,r,n){const a=this.getChildren(e);for(const o of a){const e=o.properties;if(e&&e.cluster?n+e.point_count<=r?n+=e.point_count:n=this._appendLeaves(t,e.cluster_id,i,r,n):ne&&(u+=i.numPoints||1)}if(u>h&&u>=o){let t=r.x*h,o=r.y*h,s=a&&h>1?this._map(r,!0):null;const p=(l<<5)+(e+1)+this.points.length;for(const i of c){const l=n.points[i];if(l.zoom<=e)continue;l.zoom=e;const c=l.numPoints||1;t+=l.x*c,o+=l.y*c,l.parentId=p,a&&(s||(s=this._map(r,!0)),a(s,this._map(l)))}r.parentId=p,i.push(q(t/u,o/u,p,u,s))}else if(i.push(r),u>1)for(const t of c){const r=n.points[t];r.zoom<=e||(r.zoom=e,i.push(r))}}return i}_getOriginId(t){return t-this.points.length>>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e){if(t.numPoints)return e?J({},t.properties):t.properties;const i=this.points[t.index].properties,r=this.options.map(i);return e&&r===i?J({},r):r}}function q(t,e,i,r,n){return{x:N(t),y:N(e),zoom:1/0,id:i,parentId:-1,numPoints:r,properties:n}}function Z(t,e){const[i,r]=t.geometry.coordinates;return{x:N(H(i)),y:N(W(r)),zoom:1/0,index:e,parentId:-1}}function j(t){return{type:"Feature",id:t.id,properties:X(t),geometry:{type:"Point",coordinates:[(e=t.x,360*(e-.5)),K(t.y)]}};var e}function X(t){const e=t.numPoints,i=e>=1e4?`${Math.round(e/1e3)}k`:e>=1e3?Math.round(e/100)/10+"k":e;return J(J({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:i})}function H(t){return t/360+.5}function W(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function K(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function J(t,e){for(const i in e)t[i]=e[i];return t}function Y(t){return t.x}function Q(t){return t.y}function tt(t,e,i,r){for(var n,a=r,o=i-e>>1,s=i-e,l=t[e],c=t[e+1],h=t[i],u=t[i+1],p=e+3;pa)n=p,a=d;else if(d===a){var m=Math.abs(p-o);mr&&(n-e>3&&tt(t,e,n,r),t[n+2]=a,i-n>3&&tt(t,n,i,r))}function et(t,e,i,r,n,a){var o=n-i,s=a-r;if(0!==o||0!==s){var l=((t-i)*o+(e-r)*s)/(o*o+s*s);l>1?(i=n,r=a):l>0&&(i+=o*l,r+=s*l)}return(o=t-i)*o+(s=e-r)*s}function it(t,e,i,r){var n={id:void 0===t?null:t,type:e,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)rt(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var r=0;r0&&(o+=r?(n*c-l*a)/2:Math.sqrt(Math.pow(l-n,2)+Math.pow(c-a,2))),n=l,a=c}var h=e.length-3;e[2]=1,tt(e,0,h,i),e[h+2]=1,e.size=Math.abs(o),e.start=0,e.end=e.size}function st(t,e,i,r){for(var n=0;n1?1:i}function ht(t,e,i,r,n,a,o,s){if(r/=e,a>=(i/=e)&&o=r)return null;for(var l=[],c=0;c=i&&m=r)){var f=[];if("Point"===p||"MultiPoint"===p)ut(u,f,i,r,n);else if("LineString"===p)pt(u,f,i,r,n,!1,s.lineMetrics);else if("MultiLineString"===p)mt(u,f,i,r,n,!1);else if("Polygon"===p)mt(u,f,i,r,n,!0);else if("MultiPolygon"===p)for(var g=0;g=i&&o<=r&&(e.push(t[a]),e.push(t[a+1]),e.push(t[a+2]))}}function pt(t,e,i,r,n,a,o){for(var s,l,c=dt(t),h=0===n?gt:_t,u=t.start,p=0;pi&&(l=h(c,d,m,g,_,i),o&&(c.start=u+s*l)):y>r?x=i&&(l=h(c,d,m,g,_,i),v=!0),x>r&&y<=r&&(l=h(c,d,m,g,_,r),v=!0),!a&&v&&(o&&(c.end=u+s*l),e.push(c),c=dt(t)),o&&(u+=s)}var b=t.length-3;d=t[b],m=t[b+1],f=t[b+2],(y=0===n?d:m)>=i&&y<=r&&ft(c,d,m,f),b=c.length-3,a&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&ft(c,c[0],c[1],c[2]),c.length&&e.push(c)}function dt(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function mt(t,e,i,r,n,a){for(var o=0;oo.maxX&&(o.maxX=h),u>o.maxY&&(o.maxY=u)}return o}function Tt(t,e,i,r){var n=e.geometry,a=e.type,o=[];if("Point"===a||"MultiPoint"===a)for(var s=0;s0&&e.size<(n?o:r))i.numPoints+=e.length/3;else{for(var s=[],l=0;lo)&&(i.numSimplified++,s.push(e[l]),s.push(e[l+1])),i.numPoints++;n&&function(t,e){for(var i=0,r=0,n=t.length,a=n-2;r0===e)for(r=0,n=t.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var r=0;r1&&console.time("creation"),p=this.tiles[u]=wt(t,e,i,r,l),this.tileCoords.push({z:e,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,r,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=t,n){if(e===l.maxZoom||e===n)continue;var m=1<1&&console.time("clipping");var f,g,_,y,x,v,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;f=g=_=y=null,x=ht(t,h,i-b,i+T,0,p.minX,p.maxX,l),v=ht(t,h,i+w,i+E,0,p.minX,p.maxX,l),t=null,x&&(f=ht(x,h,r-b,r+T,1,p.minY,p.maxY,l),g=ht(x,h,r+w,r+E,1,p.minY,p.maxY,l),x=null),v&&(_=ht(v,h,r-b,r+T,1,p.minY,p.maxY,l),y=ht(v,h,r+w,r+E,1,p.minY,p.maxY,l),v=null),c>1&&console.timeEnd("clipping"),s.push(f||[],e+1,2*i,2*r),s.push(g||[],e+1,2*i,2*r+1),s.push(_||[],e+1,2*i+1,2*r),s.push(y||[],e+1,2*i+1,2*r+1)}}},St.prototype.getTile=function(t,e,i){var r=this.options,n=r.extent,a=r.debug;if(t<0||t>24)return null;var o=1<1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,h=e,u=i;!l&&c>0;)c--,h=Math.floor(h/2),u=Math.floor(u/2),l=this.tiles[It(c,h,u)];return l&&l.source?(a>1&&console.log("found parent tile z%d-%d-%d",c,h,u),a>1&&console.time("drilling down"),this.splitTile(l.source,c,h,u,t,e,i),a>1&&console.timeEnd("drilling down"),this.tiles[s]?vt(this.tiles[s],n):null):null};class Ct extends l{constructor(t,e,i,r){super(t,e,i,zt),r&&(this.loadGeoJSON=r)}loadData(e,i){var r;null===(r=this._pendingRequest)||void 0===r||r.cancel(),this._pendingCallback&&this._pendingCallback(null,{abandoned:!0});const n=!!(e&&e.request&&e.request.collectResourceTiming)&&new t.RequestPerformance(e.request);this._pendingCallback=i,this._pendingRequest=this.loadGeoJSON(e,((r,a)=>{if(delete this._pendingCallback,delete this._pendingRequest,r||!a)return i(r);if("object"!=typeof a)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{h(a,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const r=a.features.filter((t=>i.value.evaluate({zoom:0},t)));a={type:"FeatureCollection",features:r}}this._geoJSONIndex=e.cluster?new G(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const r={},n={},a={accumulated:null,zoom:0},o={properties:null},s=Object.keys(i);for(const l of s){const[e,a]=i[l],o=t.createExpression(a),s=t.createExpression("string"==typeof e?[e,["accumulated"],["get",l]]:e);r[l]=o.value,n[l]=s.value}return e.map=t=>{o.properties=t;const e={};for(const i of s)e[i]=r[i].evaluate(a,o);return e},e.reduce=(t,e)=>{o.properties=e;for(const i of s)a.accumulated=t[i],t[i]=n[i].evaluate(a,o)},e}(e)).load(a.features):function(t,e){return new St(t,e)}(a,e.geojsonVtOptions)}catch(r){return i(r)}this.loaded={};const o={};if(n){const t=n.finish();t&&(o.resourceTiming={},o.resourceTiming[e.source]=JSON.parse(JSON.stringify(t)))}i(null,o)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)return t.getJSON(e.request,i);if("string"==typeof e.data)try{i(null,JSON.parse(e.data))}catch(t){i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}else i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));return{cancel:()=>{}}}removeSource(t,e){this._pendingCallback&&this._pendingCallback(null,{abandoned:!0}),e()}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class At{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.workerSourceTypes={vector:l,geojson:Ct},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=e=>{if(t.plugin.isParsed())throw new Error("RTL text plugin already registered.");t.plugin.applyArabicShaping=e.applyArabicShaping,t.plugin.processBidirectionalText=e.processBidirectionalText,t.plugin.processStyledBidirectionalText=e.processStyledBidirectionalText}}setReferrer(t,e){this.referrer=e}setImages(t,e,i){this.availableImages[t]=e;for(const r in this.workerSources[t]){const i=this.workerSources[t][r];for(const t in i)i[t].availableImages=e}i()}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(t,e,i){this.getWorkerSource(t,e.type,e.source).loadTile(e,i)}loadDEMTile(t,e,i){this.getDEMWorkerSource(t,e.source).loadTile(e,i)}reloadTile(t,e,i){this.getWorkerSource(t,e.type,e.source).reloadTile(e,i)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeDEMTile(t,e){this.getDEMWorkerSource(t,e.source).removeTile(e)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const r=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==r.removeSource?r.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,r){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();r(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){r(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new r),e}getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const r={send:(e,i,r)=>{this.actor.send(e,i,r,t)}};this.workerSources[t][e][i]=new this.workerSourceTypes[e](r,this.getLayerIndex(t),this.getAvailableImages(t))}return this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new c),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}}return t.isWorker()&&(self.worker=new At(self)),At})),r(["./shared"],(function(t){var e=i;function i(t){return!function(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var t,e,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{e=new Worker(r),t=!0}catch(e){t=!1}return e&&e.terminate(),URL.revokeObjectURL(r),t}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var t=document.createElement("canvas");t.width=t.height=1;var e=t.getContext("2d");if(!e)return!1;var i=e.getImageData(0,0,1,1);return i&&i.width===t.width}()?(void 0===r[e=t&&t.failIfMajorPerformanceCaveat]&&(r[e]=function(t){var e,r=function(t){var e=document.createElement("canvas"),r=Object.create(i.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,e.getContext("webgl",r)||e.getContext("experimental-webgl",r)}(t);if(!r)return!1;try{e=r.createShader(r.VERTEX_SHADER)}catch(t){return!1}return!(!e||r.isContextLost())&&(r.shaderSource(e,"void main() {}"),r.compileShader(e),!0===r.getShaderParameter(e,r.COMPILE_STATUS))}(e)),r[e]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var e}(t)}var r={};function n(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i{window.removeEventListener("click",a.suppressClickInternal,!0)}),0)}static mousePos(e,i){const r=e.getBoundingClientRect();return new t.pointGeometry(i.clientX-r.left-e.clientLeft,i.clientY-r.top-e.clientTop)}static touchPos(e,i){const r=e.getBoundingClientRect(),n=[];for(let a=0;a-1);l++,a[l]=s,o[l]=c,o[l+1]=u}for(let s=0,l=0;s{let r=this.entries[t];r||(r=this.entries[t]={glyphs:{},requests:{},ranges:{}});let n=r.glyphs[e];if(void 0!==n)return void i(null,{stack:t,id:e,glyph:n});if(n=this._tinySDF(r,t,e),n)return r.glyphs[e]=n,void i(null,{stack:t,id:e,glyph:n});const a=Math.floor(e/256);if(256*a>65535)return void i(new Error("glyphs > 65535 not supported"));if(r.ranges[a])return void i(null,{stack:t,id:e,glyph:n});let o=r.requests[a];o||(o=r.requests[a]=[],m.loadGlyphRange(t,a,this.url,this.requestManager,((t,e)=>{if(e){for(const t in e)this._doesCharSupportLocalGlyph(+t)||(r.glyphs[+t]=e[+t]);r.ranges[a]=!0}for(const i of o)i(t,e);delete r.requests[a]}))),o.push(((r,n)=>{r?i(r):n&&i(null,{stack:t,id:e,glyph:n[e]||null})}))}),((t,e)=>{if(t)i(t);else if(e){const t={};for(const{stack:i,id:r,glyph:n}of e)(t[i]||(t[i]={}))[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};i(null,t)}}))}_doesCharSupportLocalGlyph(e){return!!this.localIdeographFontFamily&&(t.unicodeBlockLookup["CJK Unified Ideographs"](e)||t.unicodeBlockLookup["Hangul Syllables"](e)||t.unicodeBlockLookup.Hiragana(e)||t.unicodeBlockLookup.Katakana(e))}_tinySDF(e,i,r){const n=this.localIdeographFontFamily;if(!n)return;if(!this._doesCharSupportLocalGlyph(r))return;let a=e.tinySDF;if(!a){let t="400";/bold/i.test(i)?t="900":/medium/i.test(i)?t="500":/light/i.test(i)&&(t="200"),a=e.tinySDF=new m.TinySDF({fontSize:24,buffer:3,radius:8,cutoff:.25,fontFamily:n,fontWeight:t})}const o=a.draw(String.fromCharCode(r));return{id:r,bitmap:new t.AlphaImage({width:o.width||30,height:o.height||30},o.data),metrics:{width:o.glyphWidth||24,height:o.glyphHeight||24,left:o.glyphLeft||0,top:o.glyphTop-27||-8,advance:o.glyphAdvance||24}}}}m.loadGlyphRange=function(e,i,r,n,a){const o=256*i,s=o+255,l=n.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),t.ResourceType.Glyphs);t.getArrayBuffer(l,((e,i)=>{if(e)a(e);else if(i){const e={};for(const r of t.parseGlyphPbf(i))e[r.id]=r;a(null,e)}}))},m.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:a="normal",fontStyle:o="normal"}={}){this.buffer=e,this.cutoff=r,this.radius=i;const s=this.size=t+4*e,l=this._createCanvas(s),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${a} ${t}px ${n}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:a}=this.ctx.measureText(t),o=Math.ceil(i),s=Math.min(this.size-this.buffer,Math.ceil(a-n)),l=Math.min(this.size-this.buffer,o+Math.ceil(r)),c=s+2*this.buffer,h=l+2*this.buffer,d=Math.max(c*h,0),m=new Uint8ClampedArray(d),f={data:m,width:c,height:h,glyphWidth:s,glyphHeight:l,glyphTop:o,glyphLeft:0,glyphAdvance:e};if(0===s||0===l)return f;const{ctx:g,buffer:_,gridInner:y,gridOuter:x}=this;g.clearRect(_,_,s,l),g.fillText(t,_,_+o);const v=g.getImageData(_,_,s,l);x.fill(u,0,d),y.fill(0,0,d);for(let p=0;p0?t*t:0,y[i]=t<0?t*t:0}}p(x,0,0,c,h,c,this.f,this.v,this.z),p(y,_,_,s,l,c,this.f,this.v,this.z);for(let u=0;u1&&(o=t[++a]);const l=Math.abs(s-o.left),c=Math.abs(s-o.right),h=Math.min(l,c);let u;const p=n/i*(r+1);if(o.isDash){const t=r-Math.abs(p);u=Math.sqrt(h*h+t*t)}else u=r-Math.sqrt(h*h+p*p);this.data[e+s]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let o=t.length-1;o>=0;--o){const e=t[o],i=t[o+1];e.zeroLength?t.splice(o,1):i&&i.isDash===e.isDash&&(i.left=e.left,t.splice(o,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const r=this.width*this.nextRow;let n=0,a=t[n];for(let o=0;o1&&(a=t[++n]);const e=Math.abs(o-a.left),i=Math.abs(o-a.right),s=Math.min(e,i);this.data[r+o]=Math.max(0,Math.min(255,(a.isDash?s:-s)+128))}}addDash(e,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return t.warnOnce("LineAtlas out of space"),null;let a=0;for(let t=0;t{t.send(e,i,r)}),r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function v(e,i,r){const n=function(i,n){if(i)return r(i);if(n){const i=t.pick(t.extend(n,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);n.vector_layers&&(i.vectorLayers=n.vector_layers,i.vectorLayerIds=i.vectorLayers.map((t=>t.id))),r(null,i)}};return e.url?t.getJSON(i.transformRequest(e.url,t.ResourceType.Source),n):t.exported.frame((()=>n(null,e)))}x.Actor=t.Actor;class b{constructor(e,i,r){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=r||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),n=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),a=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),o=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=r&&e.x=n&&e.y{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new b(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.cancel(),t(),this.load()}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}loadTile(e,i){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n={request:this.map._requestManager.transformRequest(r,t.ResourceType.Tile),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function a(r,n){return delete e.request,e.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(e.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&e.setExpiryData(n),e.loadVectorData(n,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}n.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state?"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",n,a.bind(this)):(e.actor=this.dispatcher.getActor(),e.request=e.actor.send("loadTile",n,a.bind(this)))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id},void 0)}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class T extends t.Evented{constructor(e,i,r,n){super(),this.id=e,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.extend({type:"raster"},i),t.extend(this,t.pick(i,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=v(this._options,this.map._requestManager,((e,i)=>{this._tileJSONRequest=null,this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(t.extend(this,i),i.bounds&&(this.tileBounds=new b(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})))}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),((r,n,a)=>{if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(n){this.map._refreshExpiredTiles&&e.setExpiryData(a);const r=this.map.painter.context,o=r.gl;e.texture=this.map.painter.getTileTexture(n.width),e.texture?e.texture.update(n,{useMipmap:!0}):(e.texture=new l(r,n,o.RGBA,{useMipmap:!0}),e.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),r.extTextureFilterAnisotropic&&o.texParameterf(o.TEXTURE_2D,r.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,r.extTextureFilterAnisotropicMax)),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),i(null)}}))}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}}let E;class S extends T{constructor(e,i,r,n){super(e,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}serialize(){return{type:"raster-dem",url:this.url,tileSize:this.tileSize,tiles:this.tiles,bounds:this.bounds,encoding:this.encoding}}loadTile(e,i){const r=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);function n(t,r){t&&(e.state="errored",i(t)),r&&(e.dem=r,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),function(r,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(r)e.state="errored",i(r);else if(a){this.map._refreshExpiredTiles&&e.setExpiryData(a),delete a.cacheControl,delete a.expires;const i=t.isImageBitmap(a)&&(null==E&&(E="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),E)?a:t.exported.getImageData(a,1),r={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:i,encoding:this.encoding};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",r,n.bind(this)))}}.bind(this)),e.neighboringTiles=this._getNeighboringTiles(e.tileID)}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,a=0===i.x?e.wrap-1:e.wrap,o=(i.x+1+r)%r,s=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,a,i.z,n,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,i.z,o,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,a,i.z,n,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,s,i.z,o,i.y-1).key]={backfilled:!1}),i.y+1{if(this._pendingLoads--,this._removed||r&&r.abandoned)return void this.fire(new t.Event("dataabort",{dataType:"source",sourceDataType:e}));let n=null;if(r&&r.resourceTiming&&r.resourceTiming[this.id]&&(n=r.resourceTiming[this.id].slice(0)),i)return void this.fire(new t.ErrorEvent(i));const a={dataType:"source",sourceDataType:e};this._collectResourceTiming&&n&&n.length>0&&t.extend(a,{resourceTiming:n}),this.fire(new t.Event("data",a))}))}loaded(){return 0===this._pendingLoads}loadTile(t,e){const i=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const r={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.request=this.actor.send(i,r,((r,n)=>(delete t.request,t.unloadVectorData(),t.aborted?e(null):r?e(r):(t.loadVectorData(n,this.map.painter,"reloadTile"===i),e(null)))))}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._removed=!0,this.actor.send("removeSource",{type:this.type,source:this.id})}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var z=t.createLayout([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class C extends t.Evented{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=e}load(e,i){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((r,n)=>{this._loaded=!0,r?this.fire(new t.ErrorEvent(r)):n&&(this.image=n,e&&(this.coordinates=e),i&&i(),this._finishLoading())}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this.options.url=t.url,this.load(t.coordinates,(()=>{this.texture=null})),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}setCoordinates(e){this.coordinates=e;const i=e.map(t.MercatorCoordinate.fromLngLat);this.tileID=function(e){let i=1/0,r=1/0,n=-1/0,a=-1/0;for(const t of e)i=Math.min(i,t.x),r=Math.min(r,t.y),n=Math.max(n,t.x),a=Math.max(a,t.y);const o=Math.max(n-i,a-r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),l=Math.pow(2,s);return new t.CanonicalTileID(s,Math.floor((i+n)/2*l),Math.floor((r+a)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z;const r=i.map((t=>this.tileID.getTilePoint(t)._round()));return this._boundsArray=new t.RasterBoundsArray,this._boundsArray.emplaceBack(r[0].x,r[0].y,0,0),this._boundsArray.emplaceBack(r[1].x,r[1].y,t.EXTENT,0),this._boundsArray.emplaceBack(r[3].x,r[3].y,0,t.EXTENT),this._boundsArray.emplaceBack(r[2].x,r[2].y,t.EXTENT,t.EXTENT),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,z.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture||(this.texture=new l(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}loadTile(t,e){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={},e(null)):(t.state="errored",e(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class A extends C{constructor(t,e,i,r){super(t,e,i,r),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,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(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.ErrorEvent(new t.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=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.boundsBuffer||(this.boundsBuffer=e.createVertexBuffer(this._boundsArray,z.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),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 l(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class k extends C{constructor(e,i,r,n){super(e,i,r,n),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,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 t.ErrorEvent(new t.ValidationError(`sources.${e}`,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 HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.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(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.boundsBuffer||(this.boundsBuffer=i.createVertexBuffer(this._boundsArray,z.members)),this.boundsSegments||(this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)),this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new l(i,this.canvas,r.RGBA,{premultiply:!0});for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const M={vector:w,raster:T,"raster-dem":S,geojson:I,video:A,image:C,canvas:k};function P(e,i){const r=t.create();return t.translate(r,r,[1,1,0]),t.scale(r,r,[.5*e.width,.5*e.height,1]),t.multiply(r,r,e.calculatePosMatrix(i.toUnwrapped()))}function D(t,e,i,r,n,a){const o=function(t,e,i){if(t)for(const r of t){const t=e[r];if(t&&t.source===i&&"fill-extrusion"===t.type)return!0}else for(const r in e){const t=e[r];if(t.source===i&&"fill-extrusion"===t.type)return!0}return!1}(n&&n.layers,e,t.id),s=a.maxPitchScaleFactor(),l=t.tilesIn(r,s,o);l.sort(L);const c=[];for(const u of l)c.push({wrappedTileID:u.tileID.wrapped().key,queryResults:u.tile.queryRenderedFeatures(e,i,t._state,u.queryGeometry,u.cameraQueryGeometry,u.scale,n,a,s,P(t.transform,u.tileID))});const h=function(t){const e={},i={};for(const r of t){const t=r.queryResults,n=r.wrappedTileID,a=i[n]=i[n]||{};for(const i in t){const r=t[i],n=a[i]=a[i]||{},o=e[i]=e[i]||[];for(const t of r)n[t.featureIndex]||(n[t.featureIndex]=!0,o.push(t))}}return e}(c);for(const u in h)h[u].forEach((e=>{const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}));return h}function L(t,e){const i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}class B{constructor(e,i){this.tileID=e,this.uid=t.uniqueId(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.textures=[],this.textureCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(e){const i=e+this.timeAdded;it.saveTileTexture(e))),this.demTexture=null,this.textures=[],this.textureCoords={}}loadVectorData(e,i,r){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const r of t){const t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=r}}return i}(e.buckets,i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.SymbolBucket){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.SymbolBucket&&i.hasRTLText){this.hasRTLText=!0,t.lazyLoadRTLTextPlugin();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage)}else this.collisionBoxArray=new t.CollisionBoxArray}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const i in this.buckets){const e=this.buckets[i];e.uploadPending()&&e.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new l(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new l(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,a,o,s,l,c){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:a,tileSize:this.tileSize,pixelPosMatrix:c,transform:s,params:o,queryPadding:this.queryPadding*l},t,e,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),a=i?i.sourceLayer:"",o=n._geojsonTileLayer||n[a];if(!o)return;const s=t.createFilter(i&&i.filter),{z:l,x:c,y:h}=this.tileID.canonical,u={z:l,x:c,y:h};for(let p=0;pt)e=!1;else if(i)if(this.expirationTime{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const r of this.data[i])t(r.value)||e.push(r);for(const i of e)this.remove(i.value.tileID,i)}}class F{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,i,r){const n=String(i);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},t.extend(this.stateChanges[e][n],r),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])r[t]||(this.deletedStates[e][n][t]=null)}else for(const t in r)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;const r=String(e);if(this.deletedStates[t]=this.deletedStates[t]||{},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]=this.deletedStates[t][r]||{},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]&&this.stateChanges[t][r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(e,i){const r=String(i),n=t.extend({},(this.state[e]||{})[r],(this.stateChanges[e]||{})[r]);if(null===this.deletedStates[e])return{};if(this.deletedStates[e]){const t=this.deletedStates[e][i];if(null===t)return{};for(const e in t)delete n[e]}return n}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(e,i){const r={};for(const n in this.stateChanges){this.state[n]=this.state[n]||{};const e={};for(const i in this.stateChanges[n])this.state[n][i]||(this.state[n][i]={}),t.extend(this.state[n][i],this.stateChanges[n][i]),e[i]=this.state[n][i];r[n]=e}for(const n in this.deletedStates){this.state[n]=this.state[n]||{};const e={};if(null===this.deletedStates[n])for(const t in this.state[n])e[t]={},this.state[n][t]={};else for(const t in this.deletedStates[n]){if(null===this.deletedStates[n][t])this.state[n][t]={};else for(const e of Object.keys(this.deletedStates[n][t]))delete this.state[n][t][e];e[t]=this.state[n][t]}r[n]=r[n]||{},t.extend(r[n],e)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(r).length)for(const t in e)e[t].setFeatureState(r,i)}}class O extends t.Evented{constructor(e,i,r){super(),this.id=e,this.dispatcher=r,this.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,this.terrain))})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=function(e,i,r,n){const a=new M[i.type](e,i,r,n);if(a.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${a.id}`);return t.bindAll(["load","abort","unload","serialize","prepare"],a),a}(e,i,r,this),this._tiles={},this._cache=new R(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new F}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,e){return this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(e){this._source.abortTile&&this._source.abortTile(e,(()=>{})),this._source.fire(new t.Event("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map((t=>t.tileID)).sort(V).map((t=>t.key))}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort(((e,i)=>{const r=e.tileID,n=i.tileID,a=new t.pointGeometry(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),o=new t.pointGeometry(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||o.y-a.y||o.x-a.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(V).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 i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(e,i,r,n){if(n)return e.state="errored",void(404!==n.status?this._source.fire(new t.ErrorEvent(n,{tile:e})):this.update(this.transform,this.terrain));e.timeAdded=t.exported.now(),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.Event("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(t){const e=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles&&t.neighboringTiles[a]&&(t.neighboringTiles[a].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,r){for(const n in this._tiles){let a=this._tiles[n];if(r[n]||!a.hasData()||a.tileID.overscaledZ<=e||a.tileID.overscaledZ>i)continue;let o=a.tileID;for(;a&&a.tileID.overscaledZ>e+1;){const t=a.tileID.scaledTo(a.tileID.overscaledZ-1);a=this._tiles[t.key],a&&a.hasData()&&(o=t)}let s=o;for(;s.overscaledZ>e;)if(s=s.scaledTo(s.overscaledZ-1),t[s.key]){r[o.key]=o;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),r=this._getLoadedTile(e);if(r)return r}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const e=Math.ceil(t.width/this._source.tileSize)+1,i=Math.ceil(t.height/this._source.tileSize)+1,r=Math.floor(e*i*5),n="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(n)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+e),t[r.tileID.key]=r}this._tiles=t;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}}update(e,i){if(this.transform=e,this.terrain=i,!this._sourceLoaded||this._paused)return;let r;this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map((e=>new t.OverscaledTileID(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y))):(r=e.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i}),this._source.hasTile&&(r=r.filter((t=>this._source.hasTile(t))))):r=[];const n=e.coveringZoomLevel(this._source),a=Math.max(n-O.maxOverzooming,this._source.minzoom),o=Math.max(n+O.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const t={};for(const e of r)if(e.canonical.z>this._source.minzoom){const i=e.scaledTo(e.canonical.z-1);t[i.key]=i;const r=e.scaledTo(Math.max(this._source.minzoom,Math.min(e.canonical.z,5)));t[r.key]=r}r=r.concat(Object.values(t))}const s=this._updateRetainedTiles(r,n);if(U(this._source.type)){const e={},l={},c=Object.keys(s);for(const i of c){const r=s[i],n=this._tiles[i];if(!n||n.fadeEndTime&&n.fadeEndTime<=t.exported.now())continue;const o=this.findLoadedParent(r,a);o&&(this._addTile(o.tileID),e[o.tileID.key]=o.tileID),l[i]=r}this._retainLoadedChildren(l,n,o,s);for(const t in e)s[t]||(this._coveredTiles[t]=!0,s[t]=e[t]);if(i){const t={},e={};for(const i of r)this._tiles[i.key].hasData()?t[i.key]=i:e[i.key]=i;for(const i in e){const r=e[i].children(this._source.maxzoom);this._tiles[r[0].key]&&this._tiles[r[1].key]&&this._tiles[r[2].key]&&this._tiles[r[3].key]&&(t[r[0].key]=s[r[0].key]=r[0],t[r[1].key]=s[r[1].key]=r[1],t[r[2].key]=s[r[2].key]=r[2],t[r[3].key]=s[r[3].key]=r[3],delete e[i])}for(const i in e){const r=this.findLoadedParent(e[i],this._source.minzoom);if(r){t[r.tileID.key]=s[r.tileID.key]=r.tileID;for(const e in t)t[e].isChildOf(r.tileID)&&delete t[e]}}for(const i in this._tiles)t[i]||(this._coveredTiles[i]=!0)}}for(const t in s)this._tiles[t].clearFadeHold();const l=t.keysDifference(this._tiles,s);for(const t of l){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(t)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){const i={},r={},n=Math.max(e-O.maxOverzooming,this._source.minzoom),a=Math.max(e+O.maxUnderzooming,this._source.minzoom),o={};for(const s of t){const t=this._addTile(s);i[s.key]=s,t.hasData()||ethis._source.maxzoom){const t=s.children(this._source.maxzoom)[0],e=this.getTile(t);if(e&&e.hasData()){i[t.key]=t;continue}}else{const t=s.children(this._source.maxzoom);if(i[t[0].key]&&i[t[1].key]&&i[t[2].key]&&i[t[3].key])continue}let a=t.wasRequested();for(let e=s.overscaledZ-1;e>=n;--e){const n=s.scaledTo(e);if(r[n.key])break;if(r[n.key]=!0,t=this.getTile(n),!t&&a&&(t=this._addTile(n)),t&&(i[n.key]=n,a=t.wasRequested(),t.hasData()))break}}return i}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,r=this._tiles[t].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}e.push(r.key);const t=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;r=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,i)));const r=i;return i||(i=new B(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,this._tileLoaded.bind(this,i,e.key,i.state))),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.Event("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const e=this._tiles[t];e&&(e.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._cache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(e,i,r){const n=[],a=this.transform;if(!a)return n;const o=r?a.getCameraQueryGeometry(e):e,s=e.map((t=>a.pointCoordinate(t,this.terrain))),l=o.map((t=>a.pointCoordinate(t,this.terrain))),c=this.getIds();let h=1/0,u=1/0,p=-1/0,d=-1/0;for(const t of l)h=Math.min(h,t.x),u=Math.min(u,t.y),p=Math.max(p,t.x),d=Math.max(d,t.y);for(let m=0;m=0&&g[1].y+f>=0){const t=s.map((t=>r.getTilePoint(t))),i=l.map((t=>r.getTilePoint(t)));n.push({tile:e,tileID:r,queryGeometry:t,cameraQueryGeometry:i,scale:o})}}return n}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const i of e)i.posMatrix=this.transform.calculatePosMatrix(i.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(U(this._source.type))for(const e in this._tiles){const i=this._tiles[e];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=t.exported.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const r=this._tiles[t];r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}}function V(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function U(t){return"raster"===t||"image"===t||"video"===t}O.maxOverzooming=10,O.maxUnderzooming=3;const N="mapboxgl_preloaded_worker_pool";class ${constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<$.workerCount;)this.workers.push(new Worker(bn.workerUrl));return this.active[t]=!0,this.workers.slice()}release(t){delete this.active[t],0===this.numActive()&&(this.workers.forEach((t=>{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[N]}numActive(){return Object.keys(this.active).length}}const G=Math.floor(t.exported.hardwareConcurrency/2);let q;function Z(){return q||(q=new $),q}function j(e,i){const r={};for(const t in e)"ref"!==t&&(r[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(r[t]=i[t])})),r}function X(t){t=t.slice();const e=Object.create(null);for(let i=0;i0?(n-o)/s:0;return this.points[a].mult(1-l).add(this.points[i].mult(l))}}function rt(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class nt{constructor(t,e,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let a=0;athis.width||r<0||e>this.height)return[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:t,y1:e,x2:i,y2:r}];for(let t=0;t0}hitTestCircle(t,e,i,r,n){const a=t-i,o=t+i,s=e-i,l=e+i;if(o<0||a>this.width||l<0||s>this.height)return!1;const c=[];return this._forEachCell(a,s,o,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(t,e,i,r,n,a,o,s){const{seenUids:l,hitTest:c,overlapMode:h}=o,u=this.boxCells[n];if(null!==u){const n=this.bboxes;for(const o of u)if(!l.box[o]){l.box[o]=!0;const u=4*o,p=this.boxKeys[o];if(t<=n[u+2]&&e<=n[u+3]&&i>=n[u+0]&&r>=n[u+1]&&(!s||s(p))&&(!c||!rt(h,p.overlapMode))&&(a.push({key:p,x1:n[u],y1:n[u+1],x2:n[u+2],y2:n[u+3]}),c))return!0}}const p=this.circleCells[n];if(null!==p){const n=this.circles;for(const o of p)if(!l.circle[o]){l.circle[o]=!0;const u=3*o,p=this.circleKeys[o];if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],t,e,i,r)&&(!s||s(p))&&(!c||!rt(h,p.overlapMode))){const t=n[u],e=n[u+1],i=n[u+2];if(a.push({key:p,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),c)return!0}}}return!1}_queryCellCircle(t,e,i,r,n,a,o,s){const{circle:l,seenUids:c,overlapMode:h}=o,u=this.boxCells[n];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!s||s(r))&&!rt(h,r.overlapMode))return a.push(!0),!0}}const p=this.circleCells[n];if(null!==p){const t=this.circles;for(const e of p)if(!c.circle[e]){c.circle[e]=!0;const i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!s||s(r))&&!rt(h,r.overlapMode))return a.push(!0),!0}}}_forEachCell(t,e,i,r,n,a,o,s){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),h=this._convertToXCellCoord(i),u=this._convertToYCellCoord(r);for(let p=l;p<=h;p++)for(let l=c;l<=u;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+p,a,o,s))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,r,n,a){const o=r-t,s=n-e,l=i+a;return l*l>o*o+s*s}_circleAndRectCollide(t,e,i,r,n,a,o){const s=(a-r)/2,l=Math.abs(t-(r+s));if(l>s+i)return!1;const c=(o-n)/2,h=Math.abs(e-(n+c));if(h>c+i)return!1;if(l<=s||h<=c)return!0;const u=l-s,p=h-c;return u*u+p*p<=i*i}}function at(e,i,r,n,a){const o=t.create();return i?(t.scale(o,o,[1/a,1/a,1]),r||t.rotateZ(o,o,n.angle)):t.multiply(o,n.labelPlaneMatrix,e),o}function ot(e,i,r,n,a){if(i){const i=t.clone(e);return t.scale(i,i,[a,a,1]),r||t.rotateZ(i,i,-n.angle),i}return n.glCoordMatrix}function st(e,i,r){let n;r?(n=[e.x,e.y,r(e.x,e.y),1],t.transformMat4(n,n,i)):(n=[e.x,e.y,0,1],yt(n,n,i));const a=n[3];return{point:new t.pointGeometry(n[0]/a,n[1]/a),signedDistanceFromCamera:a}}function lt(t,e){return.5+t/e*.5}function ct(t,e){const i=t[0]/t[3],r=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&r>=-e[1]&&r<=e[1]}function ht(e,i,r,n,a,o,s,l,c,h){const u=n?e.textSizeData:e.iconSizeData,p=t.evaluateSizeForZoom(u,r.transform.zoom),d=[256/r.width*2+1,256/r.height*2+1],m=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;m.clear();const f=e.lineVertexArray,g=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,_=r.transform.width/r.transform.height;let y=!1;for(let x=0;xMath.abs(r.x-i.x)*n?{useVertical:!0}:(e===t.WritingMode.vertical?i.yr.x)?{needsFlipping:!0}:null}function dt(e,i,r,n,a,o,s,l,c,h,u,p,d,m,f,g){const _=i/24,y=e.lineOffsetX*_,x=e.lineOffsetY*_;let v;if(e.numGlyphs>1){const t=e.glyphStartIndex+e.numGlyphs,i=e.lineStartIndex,a=e.lineStartIndex+e.lineLength,h=ut(_,l,y,x,r,u,p,e,c,o,d,f,g);if(!h)return{notEnoughRoom:!0};const b=st(h.first.point,s,g).point,w=st(h.last.point,s,g).point;if(n&&!r){const t=pt(e.writingMode,b,w,m);if(t)return t}v=[h.first];for(let n=e.glyphStartIndex+1;n0?o.point:mt(p,n,i,1,a,g),l=pt(e.writingMode,i,s,m);if(l)return l}const i=ft(_*l.getoffsetX(e.glyphStartIndex),y,x,r,u,p,e.segment,e.lineStartIndex,e.lineStartIndex+e.lineLength,c,o,d,f,g);if(!i)return{notEnoughRoom:!0};v=[i]}for(const b of v)t.addDynamicAttributes(h,b.point,b.angle);return{}}function mt(t,e,i,r,n,a){const o=st(t.add(t.sub(e)._unit()),n,a).point,s=i.sub(o);return i.add(s._mult(r/s.mag()))}function ft(e,i,r,n,a,o,s,l,c,h,u,p,d,m){const f=n?e-i:e+i;let g=f>0?1:-1,_=0;n&&(g*=-1,_=Math.PI),g<0&&(_+=Math.PI);let y=g>0?l+s:l+s+1,x=a,v=a,b=0,w=0;const T=Math.abs(f),E=[];for(;b+w<=T;){if(y+=g,y=c)return null;if(v=x,E.push(x),x=p[y],void 0===x){const e=new t.pointGeometry(h.getx(y),h.gety(y)),i=st(e,u,m);if(i.signedDistanceFromCamera>0)x=p[y]=i.point;else{const i=y-g;x=mt(0===b?o:new t.pointGeometry(h.getx(i),h.gety(i)),e,v,T-b+1,u,m)}}b+=w,w=v.dist(x)}const S=(T-b)/w,I=x.sub(v),z=I.mult(S)._add(v);z._add(I._unit()._perp()._mult(r*g));const C=_+Math.atan2(x.y-v.y,x.x-v.x);return E.push(z),{point:z,angle:d?C:0,path:E}}const gt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _t(t,e){for(let i=0;i=1;t--)h.push(o.path[t]);for(let t=1;tst(t,l,m)));h=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(h.length>0){const e=h[0].clone(),i=h[0].clone();for(let t=1;t=r.x&&i.x<=n.x&&e.y>=r.y&&i.y<=n.y?[h]:i.xn.x||i.yn.y?[]:t.clipLine([h],r.x,r.y,n.x,n.y)}for(const t of _){a.reset(t,.25*i);let r=0;r=a.length<=.5*i?1:Math.ceil(a.paddedLength/g)+1;for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t=0&&et.collisionGroupID===e}}return this.collisionGroups[t]}}function Ct(e,i,r,n,a){const{horizontalAlign:o,verticalAlign:s}=t.getAnchorAlignment(e),l=-(o-.5)*i,c=-(s-.5)*r,h=t.evaluateVariableOffset(e,n);return new t.pointGeometry(l+h[0]*a,c+h[1]*a)}function At(e,i,r,n,a,o){const{x1:s,x2:l,y1:c,y2:h,anchorPointX:u,anchorPointY:p}=e,d=new t.pointGeometry(i,r);return n&&d._rotate(a?o:-o),{x1:s+d.x,y1:c+d.y,x2:l+d.x,y2:h+d.y,anchorPointX:u,anchorPointY:p}}class kt{constructor(t,e,i,r,n){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new vt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new zt(r),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,r,n){const a=r.getBucket(i),o=r.latestFeatureIndex;if(!a||!o||i.id!==a.layerIds[0])return;const s=r.collisionBoxArray,l=a.layers[0].layout,c=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/t.EXTENT,u=this.transform.calculatePosMatrix(r.tileID.toUnwrapped()),p="map"===l.get("text-pitch-alignment"),d="map"===l.get("text-rotation-alignment"),m=bt(r,1,this.transform.zoom),f=at(u,p,d,this.transform,m);let g=null;if(p){const e=ot(u,p,d,this.transform,m);g=t.multiply([],this.transform.labelPlaneMatrix,e)}this.retainedQueryData[a.bucketInstanceId]=new It(a.bucketInstanceId,o,a.sourceLayerIndex,a.index,r.tileID);const _={bucket:a,layout:l,posMatrix:u,textLabelPlaneMatrix:f,labelToScreenMatrix:g,scale:c,textPixelRatio:h,holdingForFade:r.holdingForFade(),collisionBoxArray:s,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(a.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(a.sourceID)};if(n)for(const t of a.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:_})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:a.symbolInstances.length,parameters:_})}attemptAnchorPlacement(t,e,i,r,n,a,o,s,l,c,h,u,p,d,m,f){const g=[u.textOffset0,u.textOffset1],_=Ct(t,i,r,g,n),y=this.collisionIndex.placeCollisionBox(At(e,_.x,_.y,a,o,this.transform.angle),h,s,l,c.predicate,f);if((!m||0!==this.collisionIndex.placeCollisionBox(At(m,_.x,_.y,a,o,this.transform.angle),h,s,l,c.predicate,f).box.length)&&y.box.length>0){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID]&&this.prevPlacement.placements[u.crossTileID].text&&(e=this.prevPlacement.variableOffsets[u.crossTileID].anchor),0===u.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[u.crossTileID]={textOffset:g,width:i,height:r,anchor:t,textBoxScale:n,prevAnchor:e},this.markUsedJustification(p,t,u,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,u),this.placedOrientations[u.crossTileID]=d),{shift:_,placedGlyphBoxes:y}}}placeLayerBucketPart(e,i,r){const{bucket:n,layout:a,posMatrix:o,textLabelPlaneMatrix:s,labelToScreenMatrix:l,textPixelRatio:c,holdingForFade:h,collisionBoxArray:u,partiallyEvaluatedTextSize:p,collisionGroup:d}=e.parameters,m=a.get("text-optional"),f=a.get("icon-optional"),g=t.getOverlapMode(a,"text-overlap","text-allow-overlap"),_="always"===g,y=t.getOverlapMode(a,"icon-overlap","icon-allow-overlap"),x="always"===y,v="map"===a.get("text-rotation-alignment"),b="map"===a.get("text-pitch-alignment"),w="none"!==a.get("icon-text-fit"),T="viewport-y"===a.get("symbol-z-order"),E=_&&(x||!n.hasIconData()||f),S=x&&(_||!n.hasTextData()||m);!n.collisionArrays&&u&&n.deserializeCollisionBoxes(u);const I=(e,u)=>{if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new Et(!1,!1,!1));let x=!1,T=!1,I=!0,z=null,C={box:null,offscreen:null},A={box:null,offscreen:null},k=null,M=null,P=null,D=0,L=0,B=0;u.textFeatureIndex?D=u.textFeatureIndex:e.useRuntimeCollisionCircles&&(D=e.featureIndex),u.verticalTextFeatureIndex&&(L=u.verticalTextFeatureIndex);const R=this.retainedQueryData[n.bucketInstanceId].tileID,F=this.terrain?(t,e)=>this.terrain.getElevation(R,t,e):null;for(const t of["textBox","verticalTextBox","iconBox","verticalIconBox"]){const e=u[t];e&&(e.elevation=F?F(e.anchorPointX,e.anchorPointY):0)}const O=u.textBox;if(O){const i=i=>{let r=t.WritingMode.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},r=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&u.verticalTextBox){for(const e of n.writingModes)if(e===t.WritingMode.vertical?(C=r(),A=C):C=i(),C&&C.box&&C.box.length)break}else C=i()};if(a.get("text-variable-anchor")){let s=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[e.crossTileID]){const t=this.prevPlacement.variableOffsets[e.crossTileID];s.indexOf(t.anchor)>0&&(s=s.filter((e=>e!==t.anchor)),s.unshift(t.anchor))}const l=(t,i,r)=>{const a=t.x2-t.x1,l=t.y2-t.y1,h=e.textBoxScale,u=w&&"never"===y?i:null;let p={box:[],offscreen:!1};const m="never"!==g?2*s.length:s.length;for(let f=0;f=s.length?g:"never",e,n,r,u,F);if(i&&(p=i.placedGlyphBoxes,p&&p.box&&p.box.length)){x=!0,z=i.shift;break}}return p};r((()=>l(O,u.iconBox,t.WritingMode.horizontal)),(()=>{const i=u.verticalTextBox;return n.allowVerticalPlacement&&!(C&&C.box&&C.box.length)&&e.numVerticalGlyphVertices>0&&i?l(i,u.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null}})),C&&(x=C.box,I=C.offscreen);const h=i(C&&C.box);if(!x&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,h))}}else{const a=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,g,c,o,d.predicate,F);return r&&r.box&&r.box.length&&(this.markUsedOrientation(n,i,e),this.placedOrientations[e.crossTileID]=i),r};r((()=>a(O,t.WritingMode.horizontal)),(()=>{const i=u.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?a(i,t.WritingMode.vertical):{box:null,offscreen:null}})),i(C&&C.box&&C.box.length)}}if(k=C,x=k&&k.box&&k.box.length>0,I=k&&k.offscreen,e.useRuntimeCollisionCircles){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),c=t.evaluateSizeForFeature(n.textSizeData,p,i),h=a.get("text-padding");M=this.collisionIndex.placeCollisionCircles(g,i,n.lineVertexArray,n.glyphOffsetArray,c,o,s,l,r,b,d.predicate,e.collisionCircleDiameter,h,F),M.circles.length&&M.collisionDetected&&!r&&t.warnOnce("Collisions detected, but collision boxes are not shown"),x=_||M.circles.length>0&&!M.collisionDetected,I=I&&M.offscreen}if(u.iconFeatureIndex&&(B=u.iconFeatureIndex),u.iconBox){const t=t=>{const e=w&&z?At(t,z.x,z.y,v,b,this.transform.angle):t;return this.collisionIndex.placeCollisionBox(e,y,c,o,d.predicate,F)};A&&A.box&&A.box.length&&u.verticalIconBox?(P=t(u.verticalIconBox),T=P.box.length>0):(P=t(u.iconBox),T=P.box.length>0),I=I&&P.offscreen}const V=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,U=f||0===e.numIconVertices;if(V||U?U?V||(T=T&&x):x=T&&x:T=x=T&&x,x&&k&&k.box&&this.collisionIndex.insertCollisionBox(k.box,g,a.get("text-ignore-placement"),n.bucketInstanceId,A&&A.box&&L?L:D,d.ID),T&&P&&this.collisionIndex.insertCollisionBox(P.box,y,a.get("icon-ignore-placement"),n.bucketInstanceId,B,d.ID),M&&(x&&this.collisionIndex.insertCollisionCircles(M.circles,g,a.get("text-ignore-placement"),n.bucketInstanceId,D,d.ID),r)){const t=n.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new St);for(let i=0;i=0;--e){const i=t[e];I(n.symbolInstances.get(i),n.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=a>=0&&t!==a?0:r.crossTileID)}markUsedOrientation(e,i,r){const n=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,a=i===t.WritingMode.vertical?i:0,o=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of o)e.text.placedSymbolArray.get(t).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=a)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},a=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const s in this.placements){const t=this.placements[s],e=n[s];e?(this.opacities[s]=new Tt(e,r,t.text,t.icon),i=i||t.text!==e.text.placed||t.icon!==e.icon.placed):(this.opacities[s]=new Tt(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const s in n){const t=n[s];if(!this.opacities[s]){const e=new Tt(t,r,!1,!1);e.isHidden()||(this.opacities[s]=e,i=i||t.text.placed||t.icon.placed)}}for(const s in a)this.variableOffsets[s]||!this.opacities[s]||this.opacities[s].isHidden()||(this.variableOffsets[s]=a[s]);for(const s in o)this.placedOrientations[s]||!this.opacities[s]||this.opacities[s].isHidden()||(this.placedOrientations[s]=o[s]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const r of e){const e=r.getBucket(t);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const n=e.layers[0].layout,a=new Tt(null,0,!1,!1,!0),o=n.get("text-allow-overlap"),s=n.get("icon-allow-overlap"),l=n.get("text-variable-anchor"),c="map"===n.get("text-rotation-alignment"),h="map"===n.get("text-pitch-alignment"),u="none"!==n.get("icon-text-fit"),p=new Tt(null,0,o&&(s||!e.hasIconData()||n.get("icon-optional")),s&&(o||!e.hasTextData()||n.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const d=(t,e,i)=>{for(let r=0;r0,_=this.placedOrientations[r.crossTileID],y=_===t.WritingMode.vertical,x=_===t.WritingMode.horizontal||_===t.WritingMode.horizontalOnly;if(n>0||o>0){const t=Vt(f.text);d(e.text,n,y?Ut:t),d(e.text,o,x?Ut:t);const i=f.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach((t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)})),r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||x?1:0);const a=this.variableOffsets[r.crossTileID];a&&this.markUsedJustification(e,a.anchor,r,_);const s=this.placedOrientations[r.crossTileID];s&&(this.markUsedJustification(e,"left",r,s),this.markUsedOrientation(e,s,r))}if(g){const t=Vt(f.icon),i=!(u&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(d(e.icon,r.numIconVertices,i?t:Ut),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=f.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(d(e.icon,r.numVerticalIconVertices,i?Ut:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=f.icon.isHidden())}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[m];if(i){let r=new t.pointGeometry(0,0);if(i.textBox||i.verticalTextBox){let t=!0;if(l){const e=this.variableOffsets[s];e?(r=Ct(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):t=!1}i.textBox&&Mt(e.textCollisionBox.collisionVertexArray,f.text.placed,!t||y,r.x,r.y),i.verticalTextBox&&Mt(e.textCollisionBox.collisionVertexArray,f.text.placed,!t||x,r.x,r.y)}const n=Boolean(!x&&i.verticalIconBox);i.iconBox&&Mt(e.iconCollisionBox.collisionVertexArray,f.icon.placed,n,u?r.x:0,u?r.y:0),i.verticalIconBox&&Mt(e.iconCollisionBox.collisionVertexArray,f.icon.placed,!n,u?r.x:0,u?r.y:0)}}}if(e.sortFeatures(this.transform.angle),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);if(e.bucketInstanceId in this.collisionCircleArrays){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Mt(t,e,i,r,n){t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0),t.emplaceBack(e?1:0,i?1:0,r||0,n||0)}const Pt=Math.pow(2,25),Dt=Math.pow(2,24),Lt=Math.pow(2,17),Bt=Math.pow(2,16),Rt=Math.pow(2,9),Ft=Math.pow(2,8),Ot=Math.pow(2,1);function Vt(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Pt+e*Dt+i*Lt+e*Bt+i*Rt+e*Ft+i*Ot+e}const Ut=0;class Nt{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,r,n){const a=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex{const e=t.exported.now()-n;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],n=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=n)&&(!t.maxzoom||t.maxzoom>n)){if(this._inProgressLayer||(this._inProgressLayer=new Nt(t)),this._inProgressLayer.continuePlacement(r[t.source],this.placement,this._showCollisionBoxes,t,a))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Gt=512/t.EXTENT/2;class qt{constructor(t,e,i){this.tileID=t,this.indexedSymbolInstances={},this.bucketInstanceId=i;for(let r=0;rt.overscaledZ)for(const n in i){const a=i[n];a.tileID.isChildOf(t)&&a.findMatches(e.symbolInstances,t,r)}else{const a=i[t.scaledTo(Number(n)).key];a&&a.findMatches(e.symbolInstances,t,r)}}for(let n=0;n{e[t]=!0}));for(const i in this.layerIndexes)e[i]||delete this.layerIndexes[i]}}var Ht=t.createLayout([{name:"a_pos",type:"Int16",components:2}]);class Wt extends t.Evented{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.renderHistory=[],this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,this.renderHistorySize=t._cache.max,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null;for(const t in this._tiles){const e=this._tiles[t];e.textures.forEach((t=>t.destroy())),e.textures=[]}}update(e,i){this.sourceCache.update(e,i),this._renderableTilesKeys=[];for(const r of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.posMatrix=new Float64Array(16),t.ortho(r.posMatrix,0,t.EXTENT,0,t.EXTENT,0,1),this._tiles[r.key]=new B(r,this.tileSize))}removeOutdated(t){const e={};this.renderHistory=this.renderHistory.filter(((t,e)=>this.renderHistory.indexOf(t)===e)).slice(0,this.renderHistorySize);for(const i of this._renderableTilesKeys)e[i]=!0;for(const i of this.renderHistory)e[i]=!0;for(const i in this._tiles)e[i]||(this._tiles[i].clearTextures(t),delete this._tiles[i])}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(e){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID;if(n.canonical.equals(e.canonical)){const n=e.clone();n.posMatrix=new Float64Array(16),t.ortho(n.posMatrix,0,t.EXTENT,0,t.EXTENT,0,1),i[r]=n}else if(n.canonical.isChildOf(e.canonical)){const a=e.clone();a.posMatrix=new Float64Array(16);const o=n.canonical.z-e.canonical.z,s=n.canonical.x-(n.canonical.x>>o<>o<>o;t.ortho(a.posMatrix,0,c,0,c,0,1),t.translate(a.posMatrix,a.posMatrix,[-s*c,-l*c,0]),i[r]=a}else if(e.canonical.isChildOf(n.canonical)){const a=e.clone();a.posMatrix=new Float64Array(16);const o=e.canonical.z-n.canonical.z,s=e.canonical.x-(e.canonical.x>>o<>o<>o;t.ortho(a.posMatrix,0,t.EXTENT,0,t.EXTENT,0,1),t.translate(a.posMatrix,a.posMatrix,[s*c,l*c,0]),t.scale(a.posMatrix,a.posMatrix,[1/2**o,1/2**o,0]),i[r]=a}}return i}getSourceTile(t,e){const i=this.sourceCache._source;let r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!n||!n.dem);)n=this.sourceCache.getTileByID(t.scaledTo(r--).key);return n}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter((e=>e.timeLoaded>=t))}}class Kt{constructor(t,e,i){this.style=t,this.sourceCache=new Wt(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.elevationOffset="number"==typeof i.elevationOffset?i.elevationOffset:450,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024,this.clearRerenderCache()}getDEMElevation(e,i,r,n=t.EXTENT){if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?n=e.canonical.z-r:t.warnOnce("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const a=e.canonical.x-(e.canonical.x>>n<>n<>8<<4|t>>8,i[a+3]=0;const r=new t.RGBAImage({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new l(e,r,e.gl.RGBA,{premultiply:!1});return n.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(e){const i=new Uint8Array(4),r=this.style.map.painter,n=r.context,a=n.gl;n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),a.readPixels(e.x,r.height/devicePixelRatio-e.y-1,1,1,a.RGBA,a.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const o=i[0]+(i[2]>>4<<8),s=i[1]+((15&i[2])<<8),l=this.coordsIndex[255-i[3]],c=l&&this.sourceCache.getTileByID(l);if(!c)return null;const h=this._coordsTextureSize,u=(1<t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),Yt=t.pick(H,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData"]),Qt=t.pick(H,["setCenter","setZoom","setBearing","setPitch"]),te=function(){const e={},i=t.spec.$version;for(const r in t.spec.$root){const n=t.spec.$root[r];if(n.required){let t=null;t="version"===r?i:"array"===n.type?[]:{},null!=t&&(e[r]=t)}}return e}();class ee extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new x(Z(),this),this.imageManager=new h,this.imageManager.setEventedParent(this),this.glyphManager=new m(e._requestManager,i.localIdeographFontFamily),this.lineAtlas=new y(256,512),this.crossTileSymbolIndex=new Xt,this._layers={},this._serializedLayers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.ZoomHistory,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const r=this;this._rtlTextPluginCallback=ee.registerForPluginStateChange((e=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in r.sourceCaches)r.sourceCaches[t].reload()}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.sourceCaches[t.sourceId];if(!e)return;const i=e.getSource();if(i&&i.vectorLayerIds)for(const r in this._layers){const t=this._layers[r];t.source===i.id&&this._validateLayer(t)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const r="boolean"!=typeof i.validate||i.validate,n=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(n,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,r)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(te,!1)}_load(e,i){if(i&&Jt(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=e;for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});e.sprite?this._loadSprite(e.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(e.glyphs);const r=X(this.stylesheet.layers);this._order=r.map((t=>t.id)),this._layers={},this._serializedLayers={};for(let n of r)n=t.createStyleLayer(n),n.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=n,this._serializedLayers[n.id]=n.serialize();this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new _(this.stylesheet.light),this.setTerrain(this.stylesheet.terrain),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}_loadSprite(e){this._spriteRequest=function(e,i,r,n){let a,o,s;const l=r>1?"@2x":"";let c=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,l,".json"),t.ResourceType.SpriteJSON),((t,e)=>{c=null,s||(s=t,a=e,u())})),h=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,l,".png"),t.ResourceType.SpriteImage),((t,e)=>{h=null,s||(s=t,o=e,u())}));function u(){if(s)n(s);else if(a&&o){const e=t.exported.getImageData(o),i={};for(const r in a){const{width:n,height:o,x:s,y:l,sdf:c,pixelRatio:h,stretchX:u,stretchY:p,content:d}=a[r],m=new t.RGBAImage({width:n,height:o});t.RGBAImage.copy(e,m,{x:s,y:l},{x:0,y:0},{width:n,height:o}),i[r]={data:m,pixelRatio:h,sdf:c,stretchX:u,stretchY:p,content:d}}n(null,i)}}return{cancel(){c&&(c.cancel(),c=null),h&&(h.cancel(),h=null)}}}(e,this.map._requestManager,this.map.getPixelRatio(),((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.sourceCaches[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages();for(const r in this._updatedPaintProps)this._layers[r].updateTransitions(e);this.light.updateTransitions(e),this._resetUpdates()}const r={};for(const t in this.sourceCaches){const e=this.sourceCaches[t];r[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.sourceCaches[i.source].used=!0)}for(const n in r){const e=this.sourceCaches[n];r[n]!==e.used&&e.fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:n}))}this.light.recalculate(e),this.z=e.zoom,i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setTerrain(e){if(this._checkLoaded(),this._terrainDataCallback&&this.off("data",this._terrainDataCallback),this._terrainfreezeElevationCallback&&this.map.off("freezeElevation",this._terrainfreezeElevationCallback),e){const t=this.sourceCaches[e.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain=new Kt(this,t,e),this.map.transform.updateElevation(this.terrain),this._terrainfreezeElevationCallback=t=>{t.freeze?this.map.transform.freezeElevation=!0:(this.map.transform.freezeElevation=!1,this.map.transform.recalculateZoom(this.terrain))},this._terrainDataCallback=t=>{t.tile&&(t.sourceId===e.source?(this.map.transform.updateElevation(this.terrain),this.terrain.rememberForRerender(t.sourceId,t.tile.tileID)):"geojson"===t.source.type&&this.terrain.rememberForRerender(t.sourceId,t.tile.tileID))},this.on("data",this._terrainDataCallback),this.map.on("freezeElevation",this._terrainfreezeElevationCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.map.transform.updateElevation(this.terrain);this.map.fire(new t.Event("terrain",{terrain:e}))}setState(e){if(this._checkLoaded(),Jt(this,t.validateStyle(e)))return!1;(e=t.clone$1(e)).layers=X(e.layers);const i=function(t,e){if(!t)return[{command:H.setStyle,args:[e]}];let i=[];try{if(!n(t.version,e.version))return[{command:H.setStyle,args:[e]}];n(t.center,e.center)||i.push({command:H.setCenter,args:[e.center]}),n(t.zoom,e.zoom)||i.push({command:H.setZoom,args:[e.zoom]}),n(t.bearing,e.bearing)||i.push({command:H.setBearing,args:[e.bearing]}),n(t.pitch,e.pitch)||i.push({command:H.setPitch,args:[e.pitch]}),n(t.sprite,e.sprite)||i.push({command:H.setSprite,args:[e.sprite]}),n(t.glyphs,e.glyphs)||i.push({command:H.setGlyphs,args:[e.glyphs]}),n(t.transition,e.transition)||i.push({command:H.setTransition,args:[e.transition]}),n(t.light,e.light)||i.push({command:H.setLight,args:[e.light]});const r={},a=[];!function(t,e,i,r){let a;for(a in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,a)&&(Object.prototype.hasOwnProperty.call(e,a)||K(a,i,r));for(a in e)Object.prototype.hasOwnProperty.call(e,a)&&(Object.prototype.hasOwnProperty.call(t,a)?n(t[a],e[a])||("geojson"===t[a].type&&"geojson"===e[a].type&&Y(t,e,a)?i.push({command:H.setGeoJSONSourceData,args:[a,e[a].data]}):J(a,e,i,r)):W(a,e,i))}(t.sources,e.sources,a,r);const o=[];t.layers&&t.layers.forEach((t=>{r[t.source]?i.push({command:H.removeLayer,args:[t.id]}):o.push(t)})),i=i.concat(a),function(t,e,i){e=e||[];const r=(t=t||[]).map(tt),a=e.map(tt),o=t.reduce(et,{}),s=e.reduce(et,{}),l=r.slice(),c=Object.create(null);let h,u,p,d,m,f,g;for(h=0,u=0;h!(t.command in Qt)));if(0===i.length)return!1;const r=i.filter((t=>!(t.command in Yt)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((t=>t.command)).join(", ")}.`);return i.forEach((t=>{"setTransition"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=e,!0}addImage(e,i){if(this.getImage(e))return this.fire(new t.ErrorEvent(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){if(!this.getImage(e))return this.fire(new t.ErrorEvent(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new t.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.sourceCaches[e])throw new Error(`Source "${e}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateStyle.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.sourceCaches[e]=new O(e,i,this.dispatcher);n.style=this,n.setEventedParent(this,(()=>({isSourceLoaded:this.loaded(),source:n.serialize(),sourceId:e}))),n.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.sourceCaches[e])throw new Error("There is no source with this ID");for(const r in this._layers)if(this._layers[r].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${r}" is using it.`)));const i=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],i.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.sourceCaches[t])throw new Error(`There is no source with this ID=${t}`);const i=this.sourceCaches[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(e,i,r={}){this._checkLoaded();const n=e.id;if(this.getLayer(n))return void this.fire(new t.ErrorEvent(new Error(`Layer "${n}" already exists on this map.`)));let a;if("custom"===e.type){if(Jt(this,t.validateCustomStyleLayer(e)))return;a=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(n,e.source),e=t.clone$1(e),e=t.extend(e,{source:n})),this._validate(t.validateStyle.layer,`layers.${n}`,e,{arrayIndex:-1},r))return;a=t.createStyleLayer(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:n}}),this._serializedLayers[a.id]=a.serialize()}const o=i?this._order.indexOf(i):this._order.length;if(i&&-1===o)this.fire(new t.ErrorEvent(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(o,0,n),this._layerOrderChanged=!0,this._layers[n]=a,this._removedLayers[n]&&a.source&&"custom"!==a.type){const t=this._removedLayers[n];delete this._removedLayers[n],t.type!==a.type?this._updatedSources[a.source]="clear":(this._updatedSources[a.source]="reload",this.sourceCaches[a.source].pause())}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new t.ErrorEvent(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(n,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const n=this.getLayer(e);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new t.ErrorEvent(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,r={}){this._checkLoaded();const a=this.getLayer(e);if(a){if(!n(a.filter,i))return null==i?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(t.validateStyle.filter,`layers.${a.id}.filter`,i,null,r)||(a.filter=t.clone$1(i),this._updateLayer(a)))}else this.fire(new t.ErrorEvent(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.clone$1(this.getLayer(e).filter)}setLayoutProperty(e,i,r,a={}){this._checkLoaded();const o=this.getLayer(e);o?n(o.getLayoutProperty(i),r)||(o.setLayoutProperty(i,r,a),this._updateLayer(o)):this.fire(new t.ErrorEvent(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,r,a={}){this._checkLoaded();const o=this.getLayer(e);o?n(o.getPaintProperty(i),r)||(o.setPaintProperty(i,r,a)&&this._updateLayer(o),this._changed=!0,this._updatedPaintProps[e]=!0):this.fire(new t.ErrorEvent(new Error(`Cannot style non-existing layer "${e}".`)))}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const r=e.source,n=e.sourceLayer,a=this.sourceCaches[r];if(void 0===a)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=a.getSource().type;"geojson"===o&&n?this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||n?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),a.setFeatureState(n,e.id,i)):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const r=e.source,n=this.sourceCaches[r];if(void 0===n)return void this.fire(new t.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const a=n.getSource().type,o="vector"===a?e.sourceLayer:void 0;"vector"!==a||o?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(o,e.id,i):this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.sourceCaches[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,e.id)):void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.ErrorEvent(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,sources:t.mapObject(this.sourceCaches,(t=>t.serialize())),layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.sourceCaches[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let a=this._order.length-1;a>=0;a--){const n=this._order[a];if(e(n)){i[n]=a;for(const e of t){const t=e[n];if(t)for(const e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const n=[];for(let a=this._order.length-1;a>=0;a--){const o=this._order[a];if(e(o))for(let t=r.length-1;t>=0;t--){const e=r[t].feature;if(i[e.layer.id]{const i=h.featureSortOrder;if(i){const r=i.indexOf(t.featureIndex);return i.indexOf(e.featureIndex)-r}return e.featureIndex-t.featureIndex}));for(const t of r)e.push(t)}}for(const h in s)s[h].forEach((e=>{const r=e.feature,n=i[t[h].source].getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=n}));return s}(this._layers,this._serializedLayers,this.sourceCaches,e,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateStyle.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.sourceCaches[e];return r?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let a=0;at.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const r=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng);o=o||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((a=a||this._layerOrderChanged||0===r)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new $t(e,this.terrain,this._order,a,i,r,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(t.exported.now()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const r=this.sourceCaches[e.source];r&&r.setDependencies(e.tileID.key,e.type,e.icons)}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,r){return t.makeRequest(i,r)}}ee.getSourceType=function(t){return M[t]},ee.setSourceType=function(t,e){M[t]=e},ee.registerForPluginStateChange=t.registerForPluginStateChange;var ie="attribute vec2 a_pos;uniform mat4 u_matrix;varying vec2 v_texture_pos;varying float v_depth;void main() {v_texture_pos=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);v_depth=gl_Position.z/gl_Position.w;}";const re={prelude:ne("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_offset;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return (elevation+u_terrain_offset)*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}"),background:ne("uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:ne("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:ne("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:ne("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:ne("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}"),heatmapTexture:ne("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:ne("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:ne("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:ne("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:ne("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_FragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);}"),fillOutline:ne("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillOutlinePattern:ne("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}"),fillPattern:ne("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:ne("varying vec4 v_color;void main() {gl_FragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:ne("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed;\n#ifdef TERRAIN3D\nattribute vec2 a_centroid;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat baseDelta=10.0;float ele=get_elevation(a_centroid);\n#else\nfloat baseDelta=0.0;float ele=0.0;\n#endif\nbase=max(0.0,ele+base-baseDelta);height=max(0.0,ele+height);float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:ne("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:ne("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;\n#define PI 3.141592653589793\nvoid main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:ne("uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:ne("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:ne("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:ne("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nattribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude;\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}"),raster:ne("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:ne("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:ne("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:ne("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:ne("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",ie),terrainDepth:ne("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",ie),terrainCoords:ne("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",ie)};function ne(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/attribute ([\w]+) ([\w]+)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(n):n,s={};return{fragmentSource:t=t.replace(i,((t,e,i,r,n)=>(s[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,r,n)=>{const a="float"===r?"vec2":"vec4",o=n.match(/color/)?"color":a;return s[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${a} a_${n};\nvarying ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nattribute ${i} ${a} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),staticAttributes:r,staticUniforms:o}}class ae{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,r,n,a,o,s,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==r.length;for(let h=0;!c&&h({u_depth:new t.Uniform1i(e,i.u_depth),u_terrain:new t.Uniform1i(e,i.u_terrain),u_terrain_dim:new t.Uniform1f(e,i.u_terrain_dim),u_terrain_matrix:new t.UniformMatrix4f(e,i.u_terrain_matrix),u_terrain_unpack:new t.Uniform4f(e,i.u_terrain_unpack),u_terrain_offset:new t.Uniform1f(e,i.u_terrain_offset),u_terrain_exaggeration:new t.Uniform1f(e,i.u_terrain_exaggeration)}))(e,w),this.binderUniforms=n?n.getUniforms(e,w):[]}draw(t,e,i,r,n,a,o,s,l,c,h,u,p,d,m,f,g,_){const y=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(a),s){t.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,s.depthTexture),t.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,s.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(s[t])}for(const v in this.fixedUniforms)this.fixedUniforms[v].set(o[v]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});let x=0;switch(e){case y.LINES:x=2;break;case y.TRIANGLES:x=3;break;case y.LINE_STRIP:x=1}for(const v of u.get()){const i=v.vaos||(v.vaos={});(i[l]||(i[l]=new ae)).bind(t,this,c,m?m.getPaintVertexBuffers():[],h,v.vertexOffset,f,g,_),y.drawElements(e,v.primitiveLength*x,y.UNSIGNED_SHORT,v.primitiveOffset*x*2)}}}function le(t,e,i){const r=1/bt(i,1,e.transform.tileZoom),n=Math.pow(2,i.tileID.overscaledZ),a=i.tileSize*Math.pow(2,e.transform.tileZoom)/n,o=a*(i.tileID.canonical.x+i.tileID.wrap*n),s=a*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}const ce=(e,i,r,n)=>{const a=i.style.light,o=a.properties.get("position"),s=[o.x,o.y,o.z],l=t.create$1();"viewport"===a.properties.get("anchor")&&t.fromRotation(l,-i.transform.angle),t.transformMat3(s,s,l);const c=a.properties.get("color");return{u_matrix:e,u_lightpos:s,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+r,u_opacity:n}},he=(e,i,r,n,a,o,s)=>t.extend(ce(e,i,r,n),le(o,i,s),{u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8}),ue=t=>({u_matrix:t}),pe=(e,i,r,n)=>t.extend(ue(e),le(r,i,n)),de=(t,e)=>({u_matrix:t,u_world:e}),me=(e,i,r,n,a)=>t.extend(pe(e,i,r,n),{u_world:a}),fe=(t,e,i,r)=>{const n=t.transform;let a,o;if("map"===r.paint.get("circle-pitch-alignment")){const t=bt(i,1,n.zoom);a=!0,o=[t,t]}else a=!1,o=n.pixelsToGLUnits;return{u_camera_to_center_distance:n.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,r.paint.get("circle-translate"),r.paint.get("circle-translate-anchor")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:o}},ge=(t,e,i)=>{const r=bt(i,1,e.zoom),n=Math.pow(2,e.zoom-i.tileID.overscaledZ),a=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:r,u_extrude_scale:[e.pixelsToGLUnits[0]/(r*n),e.pixelsToGLUnits[1]/(r*n)],u_overscale_factor:a}},_e=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),ye=t=>({u_matrix:t}),xe=(t,e,i,r)=>({u_matrix:t,u_extrude_scale:bt(e,1,i),u_intensity:r});function ve(e,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new t.MercatorCoordinate(0,n/r).toLngLat().lat,new t.MercatorCoordinate(0,(n+1)/r).toLngLat().lat]}const be=(t,e,i,r)=>{const n=t.transform;return{u_matrix:Ie(t,e,i,r),u_ratio:1/bt(e,1,n.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/n.pixelsToGLUnits[0],1/n.pixelsToGLUnits[1]]}},we=(e,i,r,n,a)=>t.extend(be(e,i,r,a),{u_image:0,u_image_height:n}),Te=(t,e,i,r,n)=>{const a=t.transform,o=Se(e,a);return{u_matrix:Ie(t,e,i,n),u_texsize:e.imageAtlasTexture.size,u_ratio:1/bt(e,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[o,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Ee=(e,i,r,n,a,o)=>{const s=e.lineAtlas,l=Se(i,e.transform),c="round"===r.layout.get("line-cap"),h=s.getDash(n.from,c),u=s.getDash(n.to,c),p=h.width*a.fromScale,d=u.width*a.toScale;return t.extend(be(e,i,r,o),{u_patternscale_a:[l/p,-h.height/2],u_patternscale_b:[l/d,-u.height/2],u_sdfgamma:s.width/(256*Math.min(p,d)*e.pixelRatio)/2,u_image:0,u_tex_y_a:h.y,u_tex_y_b:u.y,u_mix:a.t})};function Se(t,e){return 1/bt(t,1,e.tileZoom)}function Ie(t,e,i,r){return t.translatePosMatrix(r?r.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const ze=(t,e,i,r,n)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:r.mix,u_opacity:r.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(o=n.paint.get("raster-saturation"),o>0?1-1/(1.001-o):-o),u_contrast_factor:(a=n.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:Ce(n.paint.get("raster-hue-rotate"))};var a,o};function Ce(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const Ae=(t,e,i,r,n,a,o,s,l,c)=>{const h=n.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:h.cameraToCenterDistance,u_pitch:h.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:h.width/h.height,u_fade_change:n.options.fadeDuration?n.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+r,u_texsize:c,u_texture:0}},ke=(e,i,r,n,a,o,s,l,c,h,u)=>{const p=a.transform;return t.extend(Ae(e,i,r,n,a,o,s,l,c,h),{u_gamma_scale:n?Math.cos(p._pitch)*p.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:+u})},Me=(e,i,r,n,a,o,s,l,c,h)=>t.extend(ke(e,i,r,n,a,o,s,l,!0,c,!0),{u_texsize_icon:h,u_texture_icon:1}),Pe=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),De=(e,i,r,n,a,o)=>t.extend(function(t,e,i,r){const n=i.imageManager.getPattern(t.from.toString()),a=i.imageManager.getPattern(t.to.toString()),{width:o,height:s}=i.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),c=r.tileSize*Math.pow(2,i.transform.tileZoom)/l,h=c*(r.tileID.canonical.x+r.tileID.wrap*l),u=c*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[o,s],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/bt(r,1,i.transform.tileZoom),u_pixel_coord_upper:[h>>16,u>>16],u_pixel_coord_lower:[65535&h,65535&u]}}(n,o,r,a),{u_matrix:e,u_opacity:i}),Le={fillExtrusion:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fillExtrusionPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_lightpos:new t.Uniform3f(e,i.u_lightpos),u_lightintensity:new t.Uniform1f(e,i.u_lightintensity),u_lightcolor:new t.Uniform3f(e,i.u_lightcolor),u_vertical_gradient:new t.Uniform1f(e,i.u_vertical_gradient),u_height_factor:new t.Uniform1f(e,i.u_height_factor),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade),u_opacity:new t.Uniform1f(e,i.u_opacity)}),fill:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),fillPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),fillOutline:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world)}),fillOutlinePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_texsize:new t.Uniform2f(e,i.u_texsize),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),circle:(e,i)=>({u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_scale_with_map:new t.Uniform1i(e,i.u_scale_with_map),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),collisionBox:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pixels_to_tile_units:new t.Uniform1f(e,i.u_pixels_to_tile_units),u_extrude_scale:new t.Uniform2f(e,i.u_extrude_scale),u_overscale_factor:new t.Uniform1f(e,i.u_overscale_factor)}),collisionCircle:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_inv_matrix:new t.UniformMatrix4f(e,i.u_inv_matrix),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_viewport_size:new t.Uniform2f(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.UniformColor(e,i.u_color),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_overlay:new t.Uniform1i(e,i.u_overlay),u_overlay_scale:new t.Uniform1f(e,i.u_overlay_scale)}),clippingMask:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmap:(e,i)=>({u_extrude_scale:new t.Uniform1f(e,i.u_extrude_scale),u_intensity:new t.Uniform1f(e,i.u_intensity),u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),heatmapTexture:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_world:new t.Uniform2f(e,i.u_world),u_image:new t.Uniform1i(e,i.u_image),u_color_ramp:new t.Uniform1i(e,i.u_color_ramp),u_opacity:new t.Uniform1f(e,i.u_opacity)}),hillshade:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_latrange:new t.Uniform2f(e,i.u_latrange),u_light:new t.Uniform2f(e,i.u_light),u_shadow:new t.UniformColor(e,i.u_shadow),u_highlight:new t.UniformColor(e,i.u_highlight),u_accent:new t.UniformColor(e,i.u_accent)}),hillshadePrepare:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_image:new t.Uniform1i(e,i.u_image),u_dimension:new t.Uniform2f(e,i.u_dimension),u_zoom:new t.Uniform1f(e,i.u_zoom),u_unpack:new t.Uniform4f(e,i.u_unpack)}),line:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_image:new t.Uniform1i(e,i.u_image),u_image_height:new t.Uniform1f(e,i.u_image_height)}),linePattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texsize:new t.Uniform2f(e,i.u_texsize),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_image:new t.Uniform1i(e,i.u_image),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_scale:new t.Uniform3f(e,i.u_scale),u_fade:new t.Uniform1f(e,i.u_fade)}),lineSDF:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_ratio:new t.Uniform1f(e,i.u_ratio),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.Uniform2f(e,i.u_units_to_pixels),u_patternscale_a:new t.Uniform2f(e,i.u_patternscale_a),u_patternscale_b:new t.Uniform2f(e,i.u_patternscale_b),u_sdfgamma:new t.Uniform1f(e,i.u_sdfgamma),u_image:new t.Uniform1i(e,i.u_image),u_tex_y_a:new t.Uniform1f(e,i.u_tex_y_a),u_tex_y_b:new t.Uniform1f(e,i.u_tex_y_b),u_mix:new t.Uniform1f(e,i.u_mix)}),raster:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_tl_parent:new t.Uniform2f(e,i.u_tl_parent),u_scale_parent:new t.Uniform1f(e,i.u_scale_parent),u_buffer_scale:new t.Uniform1f(e,i.u_buffer_scale),u_fade_t:new t.Uniform1f(e,i.u_fade_t),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image0:new t.Uniform1i(e,i.u_image0),u_image1:new t.Uniform1i(e,i.u_image1),u_brightness_low:new t.Uniform1f(e,i.u_brightness_low),u_brightness_high:new t.Uniform1f(e,i.u_brightness_high),u_saturation_factor:new t.Uniform1f(e,i.u_saturation_factor),u_contrast_factor:new t.Uniform1f(e,i.u_contrast_factor),u_spin_weights:new t.Uniform3f(e,i.u_spin_weights)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texture:new t.Uniform1i(e,i.u_texture),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.Uniform1i(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.Uniform1i(e,i.u_is_size_feature_constant),u_size_t:new t.Uniform1f(e,i.u_size_t),u_size:new t.Uniform1f(e,i.u_size),u_camera_to_center_distance:new t.Uniform1f(e,i.u_camera_to_center_distance),u_pitch:new t.Uniform1f(e,i.u_pitch),u_rotate_symbol:new t.Uniform1i(e,i.u_rotate_symbol),u_aspect_ratio:new t.Uniform1f(e,i.u_aspect_ratio),u_fade_change:new t.Uniform1f(e,i.u_fade_change),u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_label_plane_matrix:new t.UniformMatrix4f(e,i.u_label_plane_matrix),u_coord_matrix:new t.UniformMatrix4f(e,i.u_coord_matrix),u_is_text:new t.Uniform1i(e,i.u_is_text),u_pitch_with_map:new t.Uniform1i(e,i.u_pitch_with_map),u_texsize:new t.Uniform2f(e,i.u_texsize),u_texsize_icon:new t.Uniform2f(e,i.u_texsize_icon),u_texture:new t.Uniform1i(e,i.u_texture),u_texture_icon:new t.Uniform1i(e,i.u_texture_icon),u_gamma_scale:new t.Uniform1f(e,i.u_gamma_scale),u_device_pixel_ratio:new t.Uniform1f(e,i.u_device_pixel_ratio),u_is_halo:new t.Uniform1i(e,i.u_is_halo)}),background:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_color:new t.UniformColor(e,i.u_color)}),backgroundPattern:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_opacity:new t.Uniform1f(e,i.u_opacity),u_image:new t.Uniform1i(e,i.u_image),u_pattern_tl_a:new t.Uniform2f(e,i.u_pattern_tl_a),u_pattern_br_a:new t.Uniform2f(e,i.u_pattern_br_a),u_pattern_tl_b:new t.Uniform2f(e,i.u_pattern_tl_b),u_pattern_br_b:new t.Uniform2f(e,i.u_pattern_br_b),u_texsize:new t.Uniform2f(e,i.u_texsize),u_mix:new t.Uniform1f(e,i.u_mix),u_pattern_size_a:new t.Uniform2f(e,i.u_pattern_size_a),u_pattern_size_b:new t.Uniform2f(e,i.u_pattern_size_b),u_scale_a:new t.Uniform1f(e,i.u_scale_a),u_scale_b:new t.Uniform1f(e,i.u_scale_b),u_pixel_coord_upper:new t.Uniform2f(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.Uniform2f(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.Uniform1f(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texture:new t.Uniform1i(e,i.u_texture)}),terrainDepth:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix)}),terrainCoords:(e,i)=>({u_matrix:new t.UniformMatrix4f(e,i.u_matrix),u_texture:new t.Uniform1i(e,i.u_texture),u_terrain_coords_id:new t.Uniform1f(e,i.u_terrain_coords_id)})};class Be{constructor(t,e,i){this.context=t;const r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Re={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Fe{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;const n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i0){const i=t.create(),r=_;t.mul(i,g.placementInvProjMatrix,e.transform.glCoordMatrix),t.mul(i,i,g.placementViewportMatrix),u.push({circleArray:x,circleOffset:d,transform:r,invTransform:i,coord:m}),p+=x.length/4,d=p}y&&h.draw(l,c.LINES,wi.disabled,Ei.disabled,e.colorModeForRenderPass(),Si.disabled,ge(_,e.transform,f),e.style.terrain&&e.style.terrain.getTerrainData(m),r.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,e.transform.zoom,null,null,y.collisionVertexBuffer)}if(!s||!u.length)return;const m=e.useProgram("collisionCircle"),f=new t.CollisionCircleLayoutArray;f.resize(4*p),f._trim();let g=0;for(const t of u)for(let e=0;e=0&&(f[m.associatedIconIndex]={shiftedAnchor:S,angle:I})}else _t(m.numGlyphs,d)}if(h){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.terrain.getElevation(S,t,i):null,i="map"===r.layout.get("text-rotation-alignment");ht(l,S.posMatrix,e,a,R,F,_,h,i,t)}const U=e.translatePosMatrix(S.posMatrix,n,o,s),N=y||a&&T||V?Ci:R,$=e.translatePosMatrix(F,n,o,s,!0),G=p&&0!==r.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1);let q;q=p?l.iconsInText?Me(d.kind,z,x,_,e,U,N,$,A,D):ke(d.kind,z,x,_,e,U,N,$,a,A,!0):Ae(d.kind,z,x,_,e,U,N,$,a,A);const Z={program:I,buffers:c,uniformValues:q,atlasTexture:k,atlasTextureIcon:L,atlasInterpolation:M,atlasInterpolationIcon:P,isSDF:p,hasHalo:G};if(v&&l.canOverlap){b=!0;const e=c.segments.get();for(const i of e)E.push({segments:new t.SegmentVector([i]),sortKey:i.sortKey,state:Z,terrainData:C})}else E.push({segments:c.segments,sortKey:0,state:Z,terrainData:C})}b&&E.sort(((t,e)=>t.sortKey-e.sortKey));for(const t of E){const i=t.state;if(d.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Di(i.buffers,t.segments,r,e,i.program,w,u,p,n,t.terrainData)),n.u_is_halo=0}Di(i.buffers,t.segments,r,e,i.program,w,u,p,i.uniformValues,t.terrainData)}}function Di(t,e,i,r,n,a,o,s,l,c){const h=r.context;n.draw(h,h.gl.TRIANGLES,a,o,s,Si.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Li(t,e,i,r,n,a,o){const s=t.context.gl,l=i.paint.get("fill-pattern"),c=l&&l.constantOr(1),h=i.getCrossfadeParameters();let u,p,d,m,f;o?(p=c&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",u=s.LINES):(p=c?"fillPattern":"fill",u=s.TRIANGLES);for(const g of r){const r=e.getTile(g);if(c&&!r.patternsLoaded())continue;const _=r.getBucket(i);if(!_)continue;const y=_.programConfigurations.get(i.id),x=t.useProgram(p,y),v=t.style.terrain&&t.style.terrain.getTerrainData(g);c&&(t.context.activeTexture.set(s.TEXTURE0),r.imageAtlasTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),y.updatePaintBuffers(h));const b=l.constantOr(null);if(b&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[b.to.toString()],i=t.patternPositions[b.from.toString()];e&&i&&y.setConstantPatternPositions(e,i)}const w=v?g:null,T=t.translatePosMatrix(w?w.posMatrix:g.posMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(o){m=_.indexBuffer2,f=_.segments2;const e=[s.drawingBufferWidth,s.drawingBufferHeight];d="fillOutlinePattern"===p&&c?me(T,t,h,r,e):de(T,e)}else m=_.indexBuffer,f=_.segments,d=c?pe(T,t,h,r):ue(T);x.draw(t.context,u,n,t.stencilModeForClipping(g),a,Si.disabled,d,v,i.id,_.layoutVertexBuffer,m,f,i.paint,t.transform.zoom,y)}}function Bi(t,e,i,r,n,a,o){const s=t.context,l=s.gl,c=i.paint.get("fill-extrusion-pattern"),h=c.constantOr(1),u=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity");for(const d of r){const r=e.getTile(d),m=r.getBucket(i);if(!m)continue;const f=t.style.terrain&&t.style.terrain.getTerrainData(d),g=m.programConfigurations.get(i.id),_=t.useProgram(h?"fillExtrusionPattern":"fillExtrusion",g);h&&(t.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),g.updatePaintBuffers(u));const y=c.constantOr(null);if(y&&r.imageAtlas){const t=r.imageAtlas,e=t.patternPositions[y.to.toString()],i=t.patternPositions[y.from.toString()];e&&i&&g.setConstantPatternPositions(e,i)}const x=t.translatePosMatrix(d.posMatrix,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),b=h?he(x,t,v,p,d,u,r):ce(x,t,v,p);_.draw(s,s.gl.TRIANGLES,n,a,o,Si.backCCW,b,f,i.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,i.paint,t.transform.zoom,g,t.style.terrain&&m.centroidVertexBuffer)}}function Ri(t,e,i,r,n,a,o){const s=t.context,l=s.gl,c=i.fbo;if(!c)return;const h=t.useProgram("hillshade"),u=t.style.terrain&&t.style.terrain.getTerrainData(e);s.activeTexture.set(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,c.colorAttachment.get()),h.draw(s,l.TRIANGLES,n,a,o,Si.disabled,((t,e,i,r)=>{const n=i.paint.get("hillshade-shadow-color"),a=i.paint.get("hillshade-highlight-color"),o=i.paint.get("hillshade-accent-color");let s=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s-=t.transform.angle);const l=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:ve(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),s],u_shadow:n,u_highlight:a,u_accent:o}})(t,i,r,u?e:null),u,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}function Fi(e,i,r,n,a,o){const s=e.context,c=s.gl,h=i.dem;if(h&&h.data){const u=h.dim,p=h.stride,d=h.getPixels();if(s.activeTexture.set(c.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(p),i.demTexture){const t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(c.NEAREST,c.CLAMP_TO_EDGE)}else i.demTexture=new l(s,d,c.RGBA,{premultiply:!1}),i.demTexture.bind(c.NEAREST,c.CLAMP_TO_EDGE);s.activeTexture.set(c.TEXTURE0);let m=i.fbo;if(!m){const t=new l(s,{width:u,height:u,data:null},c.RGBA);t.bind(c.LINEAR,c.CLAMP_TO_EDGE),m=i.fbo=s.createFramebuffer(u,u,!0),m.colorAttachment.set(t.texture)}s.bindFramebuffer.set(m.framebuffer),s.viewport.set([0,0,u,u]),e.useProgram("hillshadePrepare").draw(s,c.TRIANGLES,n,a,o,Si.disabled,((e,i)=>{const r=i.stride,n=t.create();return t.ortho(n,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(n,n,[0,-t.EXTENT,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,h),null,r.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),i.needsHillshadePrepare=!1}}function Oi(e,i,r,n,a,o){const s=n.paint.get("raster-fade-duration");if(!o&&s>0){const n=t.exported.now(),o=(n-e.timeAdded)/s,l=i?(n-i.timeAdded)/s:-1,c=r.getSource(),h=a.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),u=!i||Math.abs(i.tileID.overscaledZ-h)>Math.abs(e.tileID.overscaledZ-h),p=u&&e.refreshedUponExpiration?1:t.clamp(u?o:1-l,0,1);return e.refreshedUponExpiration&&o>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}const Vi=new t.Color(1,0,0,1),Ui=new t.Color(0,1,0,1),Ni=new t.Color(0,0,1,1),$i=new t.Color(1,0,1,1),Gi=new t.Color(0,1,1,1);function qi(t,e,i,r){ji(t,0,e+i/2,t.transform.width,i,r)}function Zi(t,e,i,r){ji(t,e-i/2,0,i,t.transform.height,r)}function ji(t,e,i,r,n,a){const o=t.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function Xi(e,i,r){const n=e.context,a=n.gl,o=r.posMatrix,s=e.useProgram("debug"),l=wi.disabled,c=Ei.disabled,h=e.colorModeForRenderPass(),u="$debug",p=e.style.terrain&&e.style.terrain.getTerrainData(r);n.activeTexture.set(a.TEXTURE0),e.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const d=i.getTileByID(r.key).latestRawTileData,m=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(r).tileSize,g=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5;let _=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(_+=` => ${r.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${_} ${m}kB`),s.draw(n,a.TRIANGLES,l,c,vi.alphaBlended,Si.disabled,_e(o,t.Color.transparent,g),null,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(n,a.LINE_STRIP,l,c,h,Si.disabled,_e(o,t.Color.red),p,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Hi(t,e,i){const r=t.context,n=r.gl,a=t.colorModeForRenderPass(),o=new wi(n.LEQUAL,wi.ReadWrite,t.depthRangeFor3D),s=t.useProgram("terrain"),l=e.getTerrainMesh(),c=e.getTerrainData(i.tileID);r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]),r.activeTexture.set(n.TEXTURE0),n.bindTexture(n.TEXTURE_2D,e.getRTTFramebuffer().colorAttachment.get());const h=t.transform.calculatePosMatrix(i.tileID.toUnwrapped());s.draw(r,n.TRIANGLES,o,Ei.disabled,a,Si.backCCW,{u_matrix:h,u_texture:0},c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}function Wi(t,e,i,r){const n=t.context,a=i.tileSize*e.qualityFactor;i.textures[r]||(i.textures[r]=t.getTileTexture(a)||new l(n,{width:a,height:a,data:null},n.gl.RGBA),i.textures[r].bind(n.gl.LINEAR,n.gl.CLAMP_TO_EDGE),0===r&&e.sourceCache.renderHistory.unshift(i.tileID.key));const o=e.getRTTFramebuffer();o.colorAttachment.set(i.textures[r].texture),n.bindFramebuffer.set(o.framebuffer),n.viewport.set([0,0,a,a])}class Ki{constructor(t){this._coordsDescendingInv={},this._coordsDescendingInvStr={},this.painter=t,this._renderToTexture={background:!0,fill:!0,line:!0,raster:!0},this._coordsDescendingInv={},this._coordsDescendingInvStr={},this._stacks=[],this._prevType=null,this._rerender={},this._renderableTiles=t.style.terrain.sourceCache.getRenderableTiles(),this._init()}_init(){const t=this.painter.style,e=t.terrain;for(const i in t.sourceCaches){this._coordsDescendingInv[i]={};const r=t.sourceCaches[i].getVisibleCoordinates();for(const t of r){const r=e.sourceCache.getTerrainCoords(t);for(const t in r)this._coordsDescendingInv[i][t]||(this._coordsDescendingInv[i][t]=[]),this._coordsDescendingInv[i][t].push(r[t])}}for(const i of t._order){const e=t._layers[i],r=e.source;if(this._renderToTexture[e.type]&&!this._coordsDescendingInvStr[r]){this._coordsDescendingInvStr[r]={};for(const t in this._coordsDescendingInv[r])this._coordsDescendingInvStr[r][t]=this._coordsDescendingInv[r][t].map((t=>t.key)).sort().join()}}return this._renderableTiles.forEach((t=>{for(const i in this._coordsDescendingInvStr){const r=this._coordsDescendingInvStr[i][t.tileID.key];r&&r!==t.textureCoords[i]&&t.clearTextures(this.painter),e.needsRerender(i,t.tileID)&&t.clearTextures(this.painter)}this._rerender[t.tileID.key]=!t.textures.length})),e.clearRerenderCache(),e.sourceCache.removeOutdated(this.painter),this}renderLayer(e){const i=e.type,r=this.painter,n=r.style._order,a=r.currentLayer,o=a+1===n.length;if(this._renderToTexture[i]&&(this._prevType&&this._renderToTexture[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(n[a]),!o))return!0;if(this._renderToTexture[this._prevType]||"hillshade"===i||this._renderToTexture[i]&&o){this._prevType=i;const o=this._stacks.length-1,s=this._stacks[o]||[];for(const e of this._renderableTiles){if(Wi(r,r.style.terrain,e,o),this._rerender[e.tileID.key]){r.context.clear({color:t.Color.transparent});for(let t=0;ti.style.terrain.getElevation(u,t,e):null)}}}(n,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),a),0!==r.paint.get("icon-opacity").constantOr(1)&&Pi(e,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),o,s),0!==r.paint.get("text-opacity").constantOr(1)&&Pi(e,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),o,s),i.map.showCollisionBoxes&&(zi(e,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),zi(e,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,r,n){if("translucent"!==e.renderPass)return;const a=r.paint.get("circle-opacity"),o=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=!r.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;const c=e.context,h=c.gl,u=e.depthModeForSublayer(0,wi.ReadOnly),p=Ei.disabled,d=e.colorModeForRenderPass(),m=[];for(let f=0;ft.sortKey-e.sortKey));for(const t of m){const{programConfiguration:i,program:n,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:l}=t.state;n.draw(c,h.TRIANGLES,u,p,d,Si.disabled,s,l,r.id,a,o,t.segments,r.paint,e.transform.zoom,i)}},heatmap:function(e,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const a=e.context,o=a.gl,s=Ei.disabled,l=new vi([o.ONE,o.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i){const r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let n=i.heatmapFbo;if(n)r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer);else{const a=r.createTexture();r.bindTexture(r.TEXTURE_2D,a),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),n=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1),function(t,e,i,r){const n=t.gl;n.texImage2D(n.TEXTURE_2D,0,n.RGBA,e.width/4,e.height/4,0,n.RGBA,t.extRenderToTextureHalfFloat?t.extTextureHalfFloat.HALF_FLOAT_OES:n.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(t,e,a,n)}}(a,e,r),a.clear({color:t.Color.transparent});for(let t=0;t{const a=t.create();t.ortho(a,0,e.width,e.height,0,0,1);const o=e.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(e,i),null,i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,r))},line:function(e,i,r,n){if("translucent"!==e.renderPass)return;const a=r.paint.get("line-opacity"),o=r.paint.get("line-width");if(0===a.constantOr(1)||0===o.constantOr(1))return;const s=e.depthModeForSublayer(0,wi.ReadOnly),c=e.colorModeForRenderPass(),h=r.paint.get("line-dasharray"),u=r.paint.get("line-pattern"),p=u.constantOr(1),d=r.paint.get("line-gradient"),m=r.getCrossfadeParameters(),f=p?"linePattern":h?"lineSDF":d?"lineGradient":"line",g=e.context,_=g.gl;let y=!0;for(const x of n){const n=i.getTile(x);if(p&&!n.patternsLoaded())continue;const a=n.getBucket(r);if(!a)continue;const o=a.programConfigurations.get(r.id),v=e.context.program.get(),b=e.useProgram(f,o),w=y||b.program!==v,T=e.style.terrain&&e.style.terrain.getTerrainData(x),E=u.constantOr(null);if(E&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&o.setConstantPatternPositions(e,i)}const S=T?x:null,I=p?Te(e,n,r,m,S):h?Ee(e,n,r,h,m,S):d?we(e,n,r,a.lineClipsArray.length,S):be(e,n,r,S);if(p)g.activeTexture.set(_.TEXTURE0),n.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),o.updatePaintBuffers(m);else if(h&&(w||e.lineAtlas.dirty))g.activeTexture.set(_.TEXTURE0),e.lineAtlas.bind(g);else if(d){const n=a.gradients[r.id];let o=n.texture;if(r.gradientVersion!==n.version){let s=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=x.canonical.z===r?Math.ceil(1<256&&this.clearStencil(),i.setColorMode(vi.disabled),i.setDepthMode(wi.disabled);const n=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const a of e){const t=this._tileClippingMaskIDs[a.key]=this.nextStencilID++,e=this.style.terrain&&this.style.terrain.getTerrainData(a);n.draw(i,r.TRIANGLES,wi.disabled,new Ei({func:r.ALWAYS,mask:0},t,255,r.KEEP,r.KEEP,r.REPLACE),vi.disabled,Si.disabled,ye(a.posMatrix),e,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new Ei({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new Ei({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const t={};for(let i=0;i=0;this.currentLayer--){const t=this.style._layers[r[this.currentLayer]],e=n[t.source],i=o[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer{i.source&&!i.isHidden(this.transform.zoom)&&(i.source!==(e&&e.id)&&(e=this.style.sourceCaches[i.source]),(!t||t.getSource().maxzoom0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};const i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new se(this.context,t,re[t],e,Le[t],this._showOverdrawInspector,this.style.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new l(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}}class Qi{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(e,i,r){const n=Math.pow(2,r),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>{const a=1/(r=t.transformMat4([],r,e))[3]/i*n;return t.mul$1(r,r,[a,a,1/r[3],a])})),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((e=>{const i=t.sub([],a[e[0]],a[e[1]]),r=t.sub([],a[e[2]],a[e[1]]),n=t.normalize([],t.cross([],i,r)),o=-t.dot(n,a[e[1]]);return n.concat(o)}));return new Qi(a,o)}}class tr{constructor(e,i){this.min=e,this.max=i,this.center=t.scale$1([],t.add([],this.min,this.max),.5)}quadrant(e){const i=[e%2==0,e<2],r=t.clone$2(this.min),n=t.clone$2(this.max);for(let t=0;t=0&&o++;if(0===o)return 0;o!==i.length&&(r=!1)}if(r)return 2;for(let t=0;t<3;t++){let i=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let n=0;nthis.max[t]-this.min[t])return 0}return 1}}class er{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.clamp((this.left+e-this.right)/2,0,e),n=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.pointGeometry(r,n)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new er(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class ir{constructor(e,i,r,n,a){this.tileSize=512,this.maxValidLatitude=85.051129,this.freezeElevation=!1,this._renderWorldCopies=void 0===a||!!a,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==r?0:r,this._maxPitch=null==n?60:n,this.setMaxBounds(),this.width=0,this.height=0,this._center=new t.LngLat(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new er,this._posMatrixCache={},this._alignedPosMatrixCache={}}clone(){const t=new ir(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.tileSize=this.tileSize,t.latRange=this.latRange,t.width=this.width,t.height=this.height,t._center=this._center,t._elevation=this._elevation,t.zoom=this.zoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._calcMatrices(),t}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.pointGeometry(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const i=-t.wrap(e,-180,180)*Math.PI/180;var r;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(r=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(t,e,i){var r=e[0],n=e[1],a=e[2],o=e[3],s=Math.sin(i),l=Math.cos(i);t[0]=r*l+a*s,t[1]=n*l+o*s,t[2]=r*-s+a*l,t[3]=n*-s+o*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom,this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const e=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,e)}getVisibleUnwrappedCoordinates(e){const i=[new t.UnwrappedTileID(0,e)];if(this._renderWorldCopies){const r=this.pointCoordinate(new t.pointGeometry(0,0)),n=this.pointCoordinate(new t.pointGeometry(this.width,0)),a=this.pointCoordinate(new t.pointGeometry(this.width,this.height)),o=this.pointCoordinate(new t.pointGeometry(0,this.height)),s=Math.floor(Math.min(r.x,n.x,a.x,o.x)),l=Math.floor(Math.max(r.x,n.x,a.x,o.x)),c=1;for(let h=s-c;h<=l+c;h++)0!==h&&i.push(new t.UnwrappedTileID(h,e))}return i}coveringTiles(e){var i,r;let n=this.coveringZoomLevel(e);const a=n;if(void 0!==e.minzoom&&ne.maxzoom&&(n=e.maxzoom);const o=this.pointCoordinate(this.getCameraPoint()),s=t.MercatorCoordinate.fromLngLat(this.center),l=Math.pow(2,n),c=[l*o.x,l*o.y,0],h=[l*s.x,l*s.y,0],u=Qi.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,n);let p=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(p=n);const d=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,m=t=>({aabb:new tr([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),f=[],g=[],_=n,y=e.reparseOverscaled?a:n;if(this._renderWorldCopies)for(let t=1;t<=3;t++)f.push(m(-t)),f.push(m(t));for(f.push(m(0));f.length>0;){const n=f.pop(),a=n.x,o=n.y;let s=n.fullyVisible;if(!s){const t=n.aabb.intersects(u);if(0===t)continue;s=2===t}const l=e.terrain?c:h,m=n.aabb.distanceX(l),x=n.aabb.distanceY(l),v=Math.max(Math.abs(m),Math.abs(x)),b=d+(1<<_-n.zoom)-2;if(n.zoom===_||v>b&&n.zoom>=p){const e=_-n.zoom,i=c[0]-.5-(a<>1),u=n.zoom+1;let p=n.aabb.quadrant(c);if(e.terrain){const a=new t.OverscaledTileID(u,n.wrap,u,l,h),o=e.terrain.getMinMaxElevation(a),s=null!==(i=o.minElevation)&&void 0!==i?i:this.elevation,c=null!==(r=o.maxElevation)&&void 0!==r?r:this.elevation;p=new tr([p.min[0],p.min[1],s],[p.max[0],p.max[1],c])}f.push({aabb:p,zoom:u,x:l,y:h,wrap:n.wrap,fullyVisible:s})}}return g.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.clamp(e.lat,-this.maxValidLatitude,this.maxValidLatitude);return new t.pointGeometry(t.mercatorXfromLng(e.lng)*this.worldSize,t.mercatorYfromLat(i)*this.worldSize)}unproject(e){return new t.MercatorCoordinate(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}updateElevation(t){this.freezeElevation||(this.elevation=t?this.getElevation(this._center,t):0)}getElevation(e,i){const r=t.MercatorCoordinate.fromLngLat(e),n=(1<o&&(n=o-e)}if(this.lngRange){const e=(s+l)/2,i=t.wrap(u.x,e-this.worldSize/2,e+this.worldSize/2),n=c.x/2;i-nl&&(r=l-n)}void 0===r&&void 0===n||(this.center=this.unproject(new t.pointGeometry(void 0!==r?r:u.x,void 0!==n?n:u.y)).wrap()),this._unmodified=h,this._constraining=!1}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,i=this.point.x,r=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=t.mercatorZfromAltitude(1,this.center.lat)*this.worldSize;let n=t.identity(new Float64Array(16));t.scale(n,n,[this.width/2,-this.height/2,1]),t.translate(n,n,[1,-1,0]),this.labelPlaneMatrix=n,n=t.identity(new Float64Array(16)),t.scale(n,n,[1,-1,1]),t.translate(n,n,[-1,-1,0]),t.scale(n,n,[2/this.width,2/this.height,1]),this.glCoordMatrix=n,this.cameraToSeaLevelDistance=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch);const a=Math.PI/2+this._pitch,o=this._fov*(.5+e.y/this.height),s=Math.sin(o)*this.cameraToSeaLevelDistance/Math.sin(t.clamp(Math.PI-a-o,.01,Math.PI-.01)),l=this.getHorizon(),c=2*Math.atan(l/this.cameraToCenterDistance)*(.5+e.y/(2*l)),h=Math.sin(c)*this.cameraToSeaLevelDistance/Math.sin(t.clamp(Math.PI-a-c,.01,Math.PI-.01)),u=Math.cos(Math.PI/2-this._pitch)*s+this.cameraToSeaLevelDistance,p=Math.cos(Math.PI/2-this._pitch)*h+this.cameraToSeaLevelDistance,d=1.01*Math.min(u,p),m=this.height/50;n=new Float64Array(16),t.perspective(n,this._fov,this.width/this.height,m,d),n[8]=2*-e.x/this.width,n[9]=2*e.y/this.height,t.scale(n,n,[1,-1,1]),t.translate(n,n,[0,0,-this.cameraToCenterDistance]),t.rotateX(n,n,this._pitch),t.rotateZ(n,n,this.angle),t.translate(n,n,[-i,-r,0]),this.mercatorMatrix=t.scale([],n,[this.worldSize,this.worldSize,this.worldSize]),t.scale(n,n,[1,1,this._pixelPerMeter]),this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,n),t.translate(n,n,[0,0,-this.elevation]),this.projMatrix=n,this.invProjMatrix=t.invert([],n),this.pixelMatrix3D=t.multiply(new Float64Array(16),this.labelPlaneMatrix,n);const f=this.width%2/2,g=this.height%2/2,_=Math.cos(this.angle),y=Math.sin(this.angle),x=i-Math.round(i)+_*f+y*g,v=r-Math.round(r)+_*g+y*f,b=new Float64Array(n);if(t.translate(b,b,[x>.5?x-1:x,v>.5?v-1:v,0]),this.alignedProjMatrix=b,n=t.invert(new Float64Array(16),this.pixelMatrix),!n)throw new Error("failed to invert matrix");this.pixelMatrixInverse=n,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new t.pointGeometry(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.transformMat4(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.pointGeometry(0,e))}getCameraQueryGeometry(e){const i=this.getCameraPoint();if(1===e.length)return[e[0],i];{let r=i.x,n=i.y,a=i.x,o=i.y;for(const t of e)r=Math.min(r,t.x),n=Math.min(n,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y);return[new t.pointGeometry(r,n),new t.pointGeometry(a,n),new t.pointGeometry(a,o),new t.pointGeometry(r,o),new t.pointGeometry(r,n)]}}}class rr{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=function(t,e){let i=!1,r=null;const n=()=>{r=null,i&&(t(),r=setTimeout(n,300),i=!1)};return()=>(i=!0,r||n(),r)}(this._updateHashUnthrottled.bind(this))}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),a=Math.round(e.lng*n)/n,o=Math.round(e.lat*n)/n,s=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=t?`/${a}/${o}/${i}`:`${i}/${o}/${a}`,(s||l)&&(c+="/"+Math.round(10*s)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const r=i.split("=")[0];return r===t?(e=!0,`${r}=${c}`):i})).filter((t=>t));return e||i.push(`${t}=${c}`),`#${i.join("&")}`}return`#${c}`}_getCurrentHash(){const t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map((t=>t.split("="))).forEach((t=>{t[0]===this._hashName&&(e=t)})),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const t=this._getCurrentHash();if(t.length>=3&&!t.some((t=>isNaN(t)))){const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}}}const nr={linearity:.3,easing:t.bezier(0,0,.3,1)},ar=t.extend({deceleration:2500,maxSpeed:1400},nr),or=t.extend({deceleration:20,maxSpeed:1400},nr),sr=t.extend({deceleration:1e3,maxSpeed:360},nr),lr=t.extend({deceleration:1e3,maxSpeed:90},nr);class cr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const a=ur(i.pan.mag(),r,t.extend({},ar,e||{}));n.offset=i.pan.mult(a.amount/i.pan.mag()),n.center=this._map.transform.center,hr(n,a)}if(i.zoom){const t=ur(i.zoom,r,or);n.zoom=this._map.transform.zoom+t.amount,hr(n,t)}if(i.bearing){const e=ur(i.bearing,r,sr);n.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),hr(n,e)}if(i.pitch){const t=ur(i.pitch,r,lr);n.pitch=this._map.transform.pitch+t.amount,hr(n,t)}if(n.zoom||n.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),t.extend(n,{noMoveStart:!0})}}function hr(t,e){(!t.duration||t.durationi.unproject(t))),l=o.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new t.pointGeometry(0,0));super(e,{points:o,point:l,lngLats:s,lngLat:i.unproject(l),originalEvent:r}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class mr extends t.Event{constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}}class fr{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new mr(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new pr(t.type,this._map,t))}mouseup(t){this._map.fire(new pr(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new pr(t.type,this._map,t))}dblclick(t){return this._firePreventable(new pr(t.type,this._map,t))}mouseover(t){this._map.fire(new pr(t.type,this._map,t))}mouseout(t){this._map.fire(new pr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new dr(t.type,this._map,t))}touchmove(t){this._map.fire(new dr(t.type,this._map,t))}touchend(t){this._map.fire(new dr(t.type,this._map,t))}touchcancel(t){this._map.fire(new dr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class gr{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new pr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new pr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new pr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class _r{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(a.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)t.fitScreenCoordinates(r,n,this._map.getBearing(),{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair","mapboxgl-crosshair"),this._box&&(a.remove(this._box),this._box=null),a.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function yr(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.pointGeometry(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=yr(r,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const r=yr(i,e);for(const n in this.touches){const t=this.touches[n],e=r[n];(!e||e.dist(t)>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class vr{constructor(t){this.singleTap=new xr(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const r=this.singleTap.touchend(t,e,i);if(r){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class br{constructor(){this._zoomIn=new vr({numTouches:1,numTaps:2}),this._zoomOut=new vr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i);return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(n)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const wr={0:1,2:2};class Tr{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}reset(){this._active=!1,this._moved=!1,delete this._lastPoint,delete this._eventButton}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=a.mouseButton(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),function(t,e){const i=wr[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i){this._cancelCooperativeMessage=!1}),200)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._map._cooperativeGestures&&(2===this._minTouches&&i.length<2&&!this._cancelCooperativeMessage?this._map._onCooperativeGesture(t,!1,i.length):this._cancelCooperativeMessage||(this._cancelCooperativeMessage=!0)),this._active&&!(i.length0&&(this._active=!0);const n=yr(r,i),a=new t.pointGeometry(0,0),o=new t.pointGeometry(0,0);let s=0;for(const t in n){const e=n[t],i=this._touches[t];i&&(a._add(e),o._add(e.sub(i)),s++,n[t]=e)}if(this._touches=n,sMath.abs(t.x)}class Br extends Cr{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Lr(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map._cooperativeGestures&&this._currentTouchCount<3)return;const r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const a=t.y>0==e.y>0;return Lr(t)&&Lr(e)&&a}}const Rr={panStep:100,bearingStep:15,pitchStep:10};class Fr{constructor(){const t=Rr;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{const s=o.getZoom();o.easeTo({duration:300,easeId:"keyboardHandler",easing:Or,zoom:e?Math.round(s)+e*(t.shiftKey?2:1):s,bearing:o.getBearing()+i*this._bearingStep,pitch:o.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-a*this._panStep],center:o.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Or(t){return t*(2-t)}const Vr=4.000244140625;class Ur{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!this._map._metaPress)return;e.preventDefault()}let i=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const r=t.exported.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%Vr==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=a.mousePos(this._el,e);this._around=t.LngLat.convert(this._aroundCenter?this._map.getCenter():this._map.unproject(i)),this._aroundPoint=this._map.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>Vr?this._wheelZoomRate:this._defaultZoomRate;let i=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==i&&(i=1/i);const r="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(r*i))),"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"==typeof this._targetZoom?this._targetZoom:e.zoom,r=this._startZoom,n=this._easing;let a,o=!1;if("wheel"===this._type&&r&&n){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),s=n(e);a=t.number(r,i,s),e<1?this._frameId||(this._frameId=!0):o=!0}else a=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!o,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,r=(t.exported.now()-e.start)/e.duration,n=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(n*n+1e-4)*.01,o=Math.sqrt(.0729-a*a);i=t.bezier(a,o,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}reset(){this._active=!1}}class Nr{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class $r{constructor(){this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Gr{constructor(){this._tap=new vr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qr{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan","mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Zr{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class jr{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate","mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Xr=t=>t.zoom||t.drag||t.pitch||t.rotate;class Hr extends t.Event{}function Wr(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class Kr{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new cr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[t,n,o]of this._listeners)a.addEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,o)}destroy(){for(const[t,e,i]of this._listeners)a.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new fr(e,t));const r=e.boxZoom=new _r(e,t);this._add("boxZoom",r);const n=new br,a=new $r;e.doubleClickZoom=new Nr(a,n),this._add("tapZoom",n),this._add("clickZoom",a);const o=new Gr;this._add("tapDragZoom",o);const s=e.touchPitch=new Br(e);this._add("touchPitch",s);const l=new Sr(t),c=new Ir(t);e.dragRotate=new Zr(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const h=new Er(t),u=new zr(t,e);e.dragPan=new qr(i,h,u),this._add("mousePan",h),this._add("touchPan",u,["touchZoom","touchRotate"]);const p=new Dr,d=new Mr;e.touchZoomRotate=new jr(i,d,p,o),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]);const m=e.scrollZoom=new Ur(e,this);this._add("scrollZoom",m,["mousePan"]);const f=e.keyboard=new Fr;this._add("keyboard",f),this._add("blockableMapEvent",new gr(e));for(const g of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[g]&&e[g].enable(t[g])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Xr(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const r in t)if(r!==i&&(!e||e.indexOf(r)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},n={},o={},s=t.touches,l=s?this._getMapTouches(s):void 0,c=l?a.touchPos(this._el,l):a.mousePos(this._el,t);for(const{handlerName:a,handler:p,allowed:d}of this._handlers){if(!p.isEnabled())continue;let s;this._blockedByActive(o,d,a)?p.reset():p[e||t.type]&&(s=p[e||t.type](t,c,l),this.mergeHandlerResult(r,n,s,a,i),s&&s.needsRenderFrame&&this._triggerRenderFrame()),(s||p.isActive())&&(o[a]=p)}const h={};for(const a in this._previousActiveHandlers)o[a]||(h[a]=i);this._previousActiveHandlers=o,(Object.keys(h).length||Wr(r))&&(this._changes.push([r,n,h]),this._triggerRenderFrame()),(Object.keys(o).length||Wr(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,r,n,a){if(!r)return;t.extend(e,r);const o={handlerName:n,originalEvent:r.originalEvent||a};void 0!==r.zoomDelta&&(i.zoom=o),void 0!==r.panDelta&&(i.drag=o),void 0!==r.pitchDelta&&(i.pitch=o),void 0!==r.bearingDelta&&(i.rotate=o)}_applyChanges(){const e={},i={},r={};for(const[n,a,o]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new t.pointGeometry(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),t.extend(i,a),t.extend(r,o);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,i,r){const n=this._map,a=n.transform,o=n.style&&n.style.terrain;if(!(Wr(e)||o&&this._drag))return this._fireEvents(i,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:c,pitchDelta:h,around:u,pinchAround:p}=e;void 0!==p&&(u=p),n._stop(!0),u=u||n.transform.centerPoint;const d=a.pointLocation(s?u.sub(s):u);c&&(a.bearing+=c),h&&(a.pitch+=h),l&&(a.zoom+=l),o?i.drag&&!this._drag?(this._drag={center:a.centerPoint,lngLat:a.pointLocation(u),point:u,handlerName:i.drag.handlerName},n.fire(new t.Event("freezeElevation",{freeze:!0}))):this._drag&&r[this._drag.handlerName]?(n.fire(new t.Event("freezeElevation",{freeze:!1})),this._drag=null):i.drag&&this._drag&&(a.center=a.pointLocation(a.centerPoint.sub(s))):a.setLocationAtPoint(d,u),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,r,!0)}_fireEvents(e,i,r){const n=Xr(this._eventsInProgress),a=Xr(e),o={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(o[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!n&&a&&this._fireEvent("movestart",a.originalEvent);for(const t in o)this._fireEvent(t,o[t]);a&&this._fireEvent("move",a.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const s={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:r}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||r,s[`${t}end`]=l)}for(const t in s)this._fireEvent(t,s[t]);const c=Xr(this._eventsInProgress);if(r&&(n||a)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Hr("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Jr={extend:(e,...i)=>t.extend(e,...i),run(t){t()},logToElement(t,e=!1,i="log"){const r=window.document.getElementById(i);r&&(e&&(r.innerHTML=""),r.innerHTML+=`
${t}`)}};class Yr extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,r){return e=t.pointGeometry.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.extend({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,r){return this.easeTo(t.extend({zoom:e},i),r)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,r){return this.easeTo(t.extend({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing()){if(this._zooming&&(r.zoom=t.number(n,l,e)),this._rotating&&(r.bearing=t.number(a,c,e)),this._pitching&&(r.pitch=t.number(o,h,e)),this._padding&&(r.interpolatePadding(s,u,e),d=r.centerPoint.add(p)),x)r.setLocationAtPoint(x,v);else{const t=r.zoomScale(r.zoom-n),i=l>n?Math.min(2,y):Math.max(.5,y),a=Math.pow(i,1-e),o=r.unproject(g.add(_.mult(e*a)).mult(t));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,d)}this._fireMoveEvents(i)}),(t=>{this._afterEase(i,t)}),e),this}_prepareEase(e,i,r={}){this._moving=!0,this.fire(new t.Event("freezeElevation",{freeze:!0})),i||r.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(e){this.fire(new t.Event("move",e)),this._zooming&&this.fire(new t.Event("zoom",e)),this._rotating&&this.fire(new t.Event("rotate",e)),this._pitching&&this.fire(new t.Event("pitch",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId,this.fire(new t.Event("freezeElevation",{freeze:!1}));const r=this._zooming,n=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new t.Event("zoomend",e)),n&&this.fire(new t.Event("rotateend",e)),a&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(!e.essential&&t.exported.prefersReducedMotion){const r=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const r=this.transform,n=this.getZoom(),a=this.getBearing(),o=this.getPitch(),s=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,r.minZoom,r.maxZoom):n,c="bearing"in e?this._normalizeBearing(e.bearing,a):a,h="pitch"in e?+e.pitch:o,u="padding"in e?e.padding:r.padding,p=r.zoomScale(l-n),d=t.pointGeometry.convert(e.offset);let m=r.centerPoint.add(d);const f=r.pointLocation(m),g=t.LngLat.convert(e.center||f);this._normalizeCenter(g);const _=r.project(f),y=r.project(g).sub(_);let x=e.curve;const v=Math.max(r.width,r.height),b=v/p,w=y.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,n,l),r.minZoom,r.maxZoom),a=v/r.zoomScale(i-n);x=Math.sqrt(a/w*2)}const T=x*x;function E(t){const e=(b*b-v*v+(t?-1:1)*T*T*w*w)/(2*(t?b:v)*T*w);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}const z=E(0);let C=function(t){return I(z)/I(z+x*t)},A=function(t){return v*((I(z)*(S(e=z+x*t)/I(e))-S(z))/T)/w;var e},k=(E(1)-z)/x;if(Math.abs(w)<1e-6||!isFinite(k)){if(Math.abs(v-b)<1e-6)return this.easeTo(e,i);const t=be.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=a!==c,this._pitching=h!==o,this._padding=!r.isPaddingEqual(u),this._prepareEase(i,!1),this._ease((e=>{const p=e*k,f=1/C(p);r.zoom=1===e?l:n+r.scaleZoom(f),this._rotating&&(r.bearing=t.number(a,c,e)),this._pitching&&(r.pitch=t.number(o,h,e)),this._padding&&(r.interpolatePadding(s,u,e),m=r.centerPoint.add(d));const x=1===e?g:r.unproject(_.add(y.mult(A(p))).mult(f));r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,m),this._fireMoveEvents(i)}),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,r){!1===r.animate||0===r.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=r,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)180?-360:i<-180?360:0}}class Qr{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateData","_updateCompact","_updateCompactMinimize"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options&&this.options.compact,this._container=a.create("details","maplibregl-ctrl maplibregl-ctrl-attrib mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=a.create("summary","maplibregl-ctrl-attrib-button mapboxgl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=a.create("div","maplibregl-ctrl-attrib-inner mapboxgl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){a.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_toggleAttribution(){this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")):(this._container.classList.add("maplibregl-compact-show","mapboxgl-compact-show"),this._container.removeAttribute("open")))}_updateData(t){!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.sourceCaches;for(const r in e){const i=e[r];if(i.used||i.usedForTerrain){const e=i.getSource();e.attribution&&t.indexOf(e.attribution)<0&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let r=i+1;r=0)return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty","mapboxgl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty","mapboxgl-attrib-empty"),this._updateCompact(),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","mapboxgl-compact","maplibregl-compact-show","mapboxgl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show","mapboxgl-compact","mapboxgl-compact-show"))}_updateCompactMinimize(){this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show","mapboxgl-compact-show")}}class tn{constructor(e={}){this.options=e,t.bindAll(["_updateCompact"],this)}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=a.create("div","maplibregl-ctrl mapboxgl-ctrl");const e=a.create("a","maplibregl-ctrl-logo mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){a.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact","mapboxgl-compact"):e.classList.remove("maplibregl-compact","mapboxgl-compact")}}}class en{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const r of i)if(r.id===t)return void(r.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}const rn={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.enableTerrain":"Enable terrain","TerrainControl.disableTerrain":"Disable terrain"},nn={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:void 0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",transformRequest:null,fadeDuration:300,crossSourceCollisions:!0},an={showCompass:!0,showZoom:!0,visualizePitch:!1};class on{constructor(e,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Sr({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,r&&(this.mousePitch=new Ir({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),a.addEventListener(i,"mousedown",this.mousedown),a.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),a.addEventListener(i,"touchmove",this.touchmove),a.addEventListener(i,"touchend",this.touchend),a.addEventListener(i,"touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),a.disableDrag()}move(t,e){const i=this.map,r=this.mouseRotate.mousemoveWindow(t,e);if(r&&r.bearingDelta&&i.setBearing(i.getBearing()+r.bearingDelta),this.mousePitch){const r=this.mousePitch.mousemoveWindow(t,e);r&&r.pitchDelta&&i.setPitch(i.getPitch()+r.pitchDelta)}}off(){const t=this.element;a.removeEventListener(t,"mousedown",this.mousedown),a.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),a.removeEventListener(t,"touchmove",this.touchmove),a.removeEventListener(t,"touchend",this.touchend),a.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){a.enableDrag(),a.removeEventListener(window,"mousemove",this.mousemove),a.removeEventListener(window,"mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),a.mousePos(this.element,e)),a.addEventListener(window,"mousemove",this.mousemove),a.addEventListener(window,"mouseup",this.mouseup)}mousemove(t){this.move(t,a.mousePos(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=a.touchPos(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=a.touchPos(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)