diff --git a/docs/index-Cz6yyxK9.js b/docs/index-1cxemBXu.js similarity index 99% rename from docs/index-Cz6yyxK9.js rename to docs/index-1cxemBXu.js index b59728a..3bc130d 100644 --- a/docs/index-Cz6yyxK9.js +++ b/docs/index-1cxemBXu.js @@ -577,7 +577,7 @@ uniform ${T} ${S} u_${k}; #endif `}),staticAttributes:a,staticUniforms:m}}class $a{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,n,a,o,c,m,_,y,b){this.context=e;let T=this.boundPaintVertexBuffers.length!==o.length;for(let S=0;!T&&S({u_matrix:h,u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:a?a.properties.get("fog-color"):p.aM.white,u_fog_ground_blend:a?a.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:a?a.calculateFogBlendOpacity(o):0,u_horizon_color:a?a.properties.get("horizon-color"):p.aM.white,u_horizon_fog_blend:a?a.properties.get("horizon-fog-blend"):1});function Ln(h){const e=[];for(let n=0;n({u_depth:new p.aH(ae,fe.u_depth),u_terrain:new p.aH(ae,fe.u_terrain),u_terrain_dim:new p.aI(ae,fe.u_terrain_dim),u_terrain_matrix:new p.aJ(ae,fe.u_terrain_matrix),u_terrain_unpack:new p.aK(ae,fe.u_terrain_unpack),u_terrain_exaggeration:new p.aI(ae,fe.u_terrain_exaggeration)}))(e,ee),this.binderUniforms=a?a.getUniforms(e,ee):[]}draw(e,n,a,o,c,m,_,y,b,T,S,k,D,B,N,q,Z,X){const F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(o),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const ee in this.terrainUniforms)this.terrainUniforms[ee].set(y[ee])}for(const ee in this.fixedUniforms)this.fixedUniforms[ee].set(_[ee]);N&&N.setUniforms(e,this.binderUniforms,D,{zoom:B});let Y=0;switch(n){case F.LINES:Y=2;break;case F.TRIANGLES:Y=3;break;case F.LINE_STRIP:Y=1}for(const ee of k.get()){const ae=ee.vaos||(ee.vaos={});(ae[b]||(ae[b]=new $a)).bind(e,this,T,N?N.getPaintVertexBuffers():[],S,ee.vertexOffset,q,Z,X),F.drawElements(n,ee.primitiveLength*Y,F.UNSIGNED_SHORT,ee.primitiveOffset*Y*2)}}}function Zs(h,e,n){const a=1/rt(n,1,e.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/o,m=c*(n.tileID.canonical.x+n.tileID.wrap*o),_=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const ys=(h,e,n,a)=>{const o=e.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],_=function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b}();o.properties.get("anchor")==="viewport"&&function(b,T){var S=Math.sin(T),k=Math.cos(T);b[0]=k,b[1]=S,b[2]=0,b[3]=-S,b[4]=k,b[5]=0,b[6]=0,b[7]=0,b[8]=1}(_,-e.transform.angle),function(b,T,S){var k=T[0],D=T[1],B=T[2];b[0]=k*S[0]+D*S[3]+B*S[6],b[1]=k*S[1]+D*S[4]+B*S[7],b[2]=k*S[2]+D*S[5]+B*S[8]}(m,m,_);const y=o.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:a}},Gs=(h,e,n,a,o,c,m)=>p.e(ys(h,e,n,a),Zs(c,e,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),Rn=h=>({u_matrix:h}),Yo=(h,e,n,a)=>p.e(Rn(h),Zs(n,e,a)),sc=(h,e)=>({u_matrix:h,u_world:e}),Qo=(h,e,n,a,o)=>p.e(Yo(h,e,n,a),{u_world:o}),ac=(h,e,n,a)=>{const o=h.transform;let c,m;if(a.paint.get("circle-pitch-alignment")==="map"){const _=rt(n,1,o.zoom);c=!0,m=[_,_]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},mn=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),xs=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),Mi=h=>({u_matrix:h}),ki=(h,e,n,a)=>({u_matrix:h,u_extrude_scale:rt(e,1,n),u_intensity:a}),Hs=(h,e,n,a)=>{const o=p.H();p.aP(o,0,h.width,h.height,0,0,1);const c=h.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}};function Xs(h,e){const n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new p.Z(0,a/n).toLngLat().lat,new p.Z(0,(a+1)/n).toLngLat().lat]}const Ws=(h,e,n,a)=>{const o=h.transform;return{u_matrix:il(h,e,n,a),u_ratio:1/rt(e,1,o.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},el=(h,e,n,a,o)=>p.e(Ws(h,e,n,o),{u_image:0,u_image_height:a}),Bn=(h,e,n,a,o)=>{const c=h.transform,m=tl(e,c);return{u_matrix:il(h,e,n,o),u_texsize:e.imageAtlasTexture.size,u_ratio:1/rt(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},oc=(h,e,n,a,o,c)=>{const m=h.lineAtlas,_=tl(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(a.from,y),T=m.getDash(a.to,y),S=b.width*o.fromScale,k=T.width*o.toScale;return p.e(Ws(h,e,n,c),{u_patternscale_a:[_/S,-b.height/2],u_patternscale_b:[_/k,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,k)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function tl(h,e){return 1/rt(h,1,e.tileZoom)}function il(h,e,n,a){return h.translatePosMatrix(a?a.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const lc=(h,e,n,a,o)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:cc(o.paint.get("raster-hue-rotate"))};var c,m};function cc(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const rl=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>{const B=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:_,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:k,u_texture:0,u_translation:T,u_pitched_scale:D}},vs=(h,e,n,a,o,c,m,_,y,b,T,S,k,D,B)=>{const N=m.transform;return p.e(rl(h,e,n,a,o,c,m,_,y,b,T,S,k,B),{u_gamma_scale:a?Math.cos(N._pitch)*N.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+D})},Ga=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>p.e(vs(h,e,n,a,o,c,m,_,y,b,T,!0,S,!0,D),{u_texsize_icon:k,u_texture_icon:1}),Ks=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),Ha=(h,e,n,a,o,c)=>p.e(function(m,_,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:k,height:D}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),N=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,q=N*(b.tileID.canonical.x+b.tileID.wrap*B),Z=N*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[k,D],u_mix:_.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/rt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[q>>16,Z>>16],u_pixel_coord_lower:[65535&q,65535&Z]}}(a,c,n,o),{u_matrix:h,u_opacity:e}),Xa={fillExtrusion:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_opacity:new p.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_height_factor:new p.aI(h,e.u_height_factor),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade),u_opacity:new p.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new p.aH(h,e.u_scale_with_map),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_extrude_scale:new p.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_matrix:new p.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_pixel_extrude_scale:new p.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_inv_matrix:new p.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_viewport_size:new p.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new p.aL(h,e.u_color),u_matrix:new p.aJ(h,e.u_matrix),u_overlay:new p.aH(h,e.u_overlay),u_overlay_scale:new p.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new p.aI(h,e.u_extrude_scale),u_intensity:new p.aI(h,e.u_intensity),u_matrix:new p.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_color_ramp:new p.aH(h,e.u_color_ramp),u_opacity:new p.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_latrange:new p.aO(h,e.u_latrange),u_light:new p.aO(h,e.u_light),u_shadow:new p.aL(h,e.u_shadow),u_highlight:new p.aL(h,e.u_highlight),u_accent:new p.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_dimension:new p.aO(h,e.u_dimension),u_zoom:new p.aI(h,e.u_zoom),u_unpack:new p.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_image:new p.aH(h,e.u_image),u_image_height:new p.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texsize:new p.aO(h,e.u_texsize),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_image:new p.aH(h,e.u_image),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_patternscale_a:new p.aO(h,e.u_patternscale_a),u_patternscale_b:new p.aO(h,e.u_patternscale_b),u_sdfgamma:new p.aI(h,e.u_sdfgamma),u_image:new p.aH(h,e.u_image),u_tex_y_a:new p.aI(h,e.u_tex_y_a),u_tex_y_b:new p.aI(h,e.u_tex_y_b),u_mix:new p.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_tl_parent:new p.aO(h,e.u_tl_parent),u_scale_parent:new p.aI(h,e.u_scale_parent),u_buffer_scale:new p.aI(h,e.u_buffer_scale),u_fade_t:new p.aI(h,e.u_fade_t),u_opacity:new p.aI(h,e.u_opacity),u_image0:new p.aH(h,e.u_image0),u_image1:new p.aH(h,e.u_image1),u_brightness_low:new p.aI(h,e.u_brightness_low),u_brightness_high:new p.aI(h,e.u_brightness_high),u_saturation_factor:new p.aI(h,e.u_saturation_factor),u_contrast_factor:new p.aI(h,e.u_contrast_factor),u_spin_weights:new p.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texsize_icon:new p.aO(h,e.u_texsize_icon),u_texture:new p.aH(h,e.u_texture),u_texture_icon:new p.aH(h,e.u_texture_icon),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_color:new p.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_image:new p.aH(h,e.u_image),u_pattern_tl_a:new p.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new p.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new p.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new p.aO(h,e.u_pattern_br_b),u_texsize:new p.aO(h,e.u_texsize),u_mix:new p.aI(h,e.u_mix),u_pattern_size_a:new p.aO(h,e.u_pattern_size_a),u_pattern_size_b:new p.aO(h,e.u_pattern_size_b),u_scale_a:new p.aI(h,e.u_scale_a),u_scale_b:new p.aI(h,e.u_scale_b),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_ele_delta:new p.aI(h,e.u_ele_delta),u_fog_matrix:new p.aJ(h,e.u_fog_matrix),u_fog_color:new p.aL(h,e.u_fog_color),u_fog_ground_blend:new p.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon_fog_blend:new p.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ele_delta:new p.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_terrain_coords_id:new p.aI(h,e.u_terrain_coords_id),u_ele_delta:new p.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new p.aL(h,e.u_sky_color),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon:new p.aI(h,e.u_horizon),u_sky_horizon_blend:new p.aI(h,e.u_sky_horizon_blend)})};class kr{constructor(e,n,a){this.context=e;const o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const hc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Wa{constructor(e,n,a,o){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=o,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a0){const ae=p.H();p.aQ(ae,F.placementInvProjMatrix,h.transform.glCoordMatrix),p.aQ(ae,ae,F.placementViewportMatrix),y.push({circleArray:ee,circleOffset:T,transform:X.posMatrix,invTransform:ae,coord:X}),b+=ee.length/4,T=b}Y&&_.draw(c,m.LINES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,{u_matrix:X.posMatrix,u_pixel_extrude_scale:[1/(S=h.transform).width,1/S.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(X),n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,null,h.transform.zoom,null,null,Y.collisionVertexBuffer)}var S;if(!o||!y.length)return;const k=h.useProgram("collisionCircle"),D=new p.aR;D.resize(4*b),D._trim();let B=0;for(const Z of y)for(let X=0;X=0&&(Z[F.associatedIconIndex]={shiftedAnchor:qe,angle:Tt})}else Ne(F.numGlyphs,N)}if(b){q.clear();const X=h.icon.placedSymbolArray;for(let F=0;Fh.style.map.terrain.getElevation(we,is,rs):null,In=n.layout.get("text-rotation-alignment")==="map";R(Re,we.posMatrix,h,o,es,ts,Z,b,In,N,we.toUnwrapped(),B.width,B.height,ir,at)}const rr=we.posMatrix,nr=o&&_e||ko,tn=X||nr?Ts:es,gr=va,ei=Ce&&n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let ci;ci=Ce?Re.iconsInText?Ga(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,oi,bi,ke):vs(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,!0,ke):rl(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,ke);const Gi={program:Ye,buffers:Xe,uniformValues:ci,atlasTexture:mr,atlasTextureIcon:li,atlasInterpolation:It,atlasInterpolationIcon:Ei,isSDF:Ce,hasHalo:ei};if(ee&&Re.canOverlap){ae=!0;const at=Xe.segments.get();for(const In of at)Pe.push({segments:new p.a0([In]),sortKey:In.sortKey,state:Gi,terrainData:St})}else Pe.push({segments:Xe.segments,sortKey:0,state:Gi,terrainData:St})}ae&&Pe.sort((we,be)=>we.sortKey-be.sortKey);for(const we of Pe){const be=we.state;if(k.activeTexture.set(D.TEXTURE0),be.atlasTexture.bind(be.atlasInterpolation,D.CLAMP_TO_EDGE),be.atlasTextureIcon&&(k.activeTexture.set(D.TEXTURE1),be.atlasTextureIcon&&be.atlasTextureIcon.bind(be.atlasInterpolationIcon,D.CLAMP_TO_EDGE)),be.isSDF){const Re=be.uniformValues;be.hasHalo&&(Re.u_is_halo=1,so(be.buffers,we.segments,n,h,be.program,fe,T,S,Re,we.terrainData)),Re.u_is_halo=0}so(be.buffers,we.segments,n,h,be.program,fe,T,S,be.uniformValues,we.terrainData)}}function so(h,e,n,a,o,c,m,_,y,b){const T=a.context;o.draw(T,T.gl.TRIANGLES,c,m,_,gt.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function ao(h,e,n,a){const o=h.context,c=o.gl,m=vt.disabled,_=new Rt([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;const b=a.key;let T=n.heatmapFbos.get(b);T||(T=Ss(o,e.tileSize,e.tileSize),n.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,e.tileSize,e.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(n.id),k=h.useProgram("heatmap",S),D=h.style.map.terrain.getTerrainData(a);k.draw(o,c.TRIANGLES,it.disabled,m,_,gt.disabled,ki(a.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),D,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,S)}function bn(h,e,n){const a=h.context,o=a.gl;a.setColorMode(h.colorModeForRenderPass());const c=Is(a,e),m=n.key,_=e.heatmapFbos.get(m);_&&(a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,_.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(a,o.TRIANGLES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,Hs(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),_.destroy(),e.heatmapFbos.delete(m))}function Ss(h,e,n){var a,o;const c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:c.UNSIGNED_BYTE,y=(o=h.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,_,null);const b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function Is(h,e){return e.colorRampTexture||(e.colorRampTexture=new et(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function Vn(h,e,n,a,o){if(!n||!a||!a.imageAtlas)return;const c=a.imageAtlas.patternPositions;let m=c[n.to.toString()],_=c[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){const y=o.getPaintProperty(e);m=c[y],_=c[y]}m&&_&&h.setConstantPatternPositions(m,_)}function Ps(h,e,n,a,o,c,m){const _=h.context.gl,y="fill-pattern",b=n.paint.get(y),T=b&&b.constantOr(1),S=n.getCrossfadeParameters();let k,D,B,N,q;m?(D=T&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",k=_.LINES):(D=T?"fillPattern":"fill",k=_.TRIANGLES);const Z=b.constantOr(null);for(const X of a){const F=e.getTile(X);if(T&&!F.patternsLoaded())continue;const Y=F.getBucket(n);if(!Y)continue;const ee=Y.programConfigurations.get(n.id),ae=h.useProgram(D,ee),fe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(X);T&&(h.context.activeTexture.set(_.TEXTURE0),F.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ee.updatePaintBuffers(S)),Vn(ee,y,Z,F,n);const _e=fe?X:null,Pe=h.translatePosMatrix(_e?_e.posMatrix:X.posMatrix,F,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){N=Y.indexBuffer2,q=Y.segments2;const ke=[_.drawingBufferWidth,_.drawingBufferHeight];B=D==="fillOutlinePattern"&&T?Qo(Pe,h,S,F,ke):sc(Pe,ke)}else N=Y.indexBuffer,q=Y.segments,B=T?Yo(Pe,h,S,F):Rn(Pe);ae.draw(h.context,k,o,h.stencilModeForClipping(X),c,gt.disabled,B,fe,n.id,Y.layoutVertexBuffer,N,q,n.paint,h.transform.zoom,ee)}}function ia(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b="fill-extrusion-pattern",T=n.paint.get(b),S=T.constantOr(1),k=n.getCrossfadeParameters(),D=n.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const N of a){const q=e.getTile(N),Z=q.getBucket(n);if(!Z)continue;const X=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),F=Z.programConfigurations.get(n.id),Y=h.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(h.context.activeTexture.set(y.TEXTURE0),q.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(k)),Vn(F,b,B,q,n);const ee=h.translatePosMatrix(N.posMatrix,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ae=n.paint.get("fill-extrusion-vertical-gradient"),fe=S?Gs(ee,h,ae,D,N,k,q):ys(ee,h,ae,D);Y.draw(_,_.gl.TRIANGLES,o,c,m,gt.backCCW,fe,X,n.id,Z.layoutVertexBuffer,Z.indexBuffer,Z.segments,n.paint,h.transform.zoom,F,h.style.map.terrain&&Z.centroidVertexBuffer)}}function Nn(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b=n.fbo;if(!b)return;const T=h.useProgram("hillshade"),S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(_,y.TRIANGLES,o,c,m,gt.disabled,((k,D,B,N)=>{const q=B.paint.get("hillshade-shadow-color"),Z=B.paint.get("hillshade-highlight-color"),X=B.paint.get("hillshade-accent-color");let F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=k.transform.angle);const Y=!k.options.moving;return{u_matrix:N?N.posMatrix:k.transform.calculatePosMatrix(D.tileID.toUnwrapped(),Y),u_image:0,u_latrange:Xs(0,D.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:q,u_highlight:Z,u_accent:X}})(h,n,a,S?e:null),S,a.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function Un(h,e,n,a,o,c){const m=h.context,_=m.gl,y=e.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(_.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(T),e.demTexture){const D=e.demTexture;D.update(S,{premultiply:!1}),D.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else e.demTexture=new et(m,S,_.RGBA,{premultiply:!1}),e.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);m.activeTexture.set(_.TEXTURE0);let k=e.fbo;if(!k){const D=new et(m,{width:b,height:b,data:null},_.RGBA);D.bind(_.LINEAR,_.CLAMP_TO_EDGE),k=e.fbo=m.createFramebuffer(b,b,!0,!1),k.colorAttachment.set(D.texture)}m.bindFramebuffer.set(k.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,_.TRIANGLES,a,o,c,gt.disabled,((D,B)=>{const N=B.stride,q=p.H();return p.aP(q,0,p.X,-p.X,0,0,1),p.J(q,q,[0,-p.X,0]),{u_matrix:q,u_image:1,u_dimension:[N,N],u_zoom:D.overscaledZ,u_unpack:B.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function gl(h,e,n,a,o,c){const m=a.paint.get("raster-fade-duration");if(!c&&m>0){const _=de.now(),y=(_-h.timeAdded)/m,b=e?(_-e.timeAdded)/m:-1,T=n.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),k=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),D=k&&h.refreshedUponExpiration?1:p.ac(k?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-D}:{opacity:D,mix:0}}return{opacity:1,mix:0}}const oo=new p.aM(1,0,0,1),ct=new p.aM(0,1,0,1),ra=new p.aM(0,0,1,1),vc=new p.aM(1,0,1,1),_l=new p.aM(0,1,1,1);function jn(h,e,n,a){na(h,0,e+n/2,h.transform.width,n,a)}function yl(h,e,n,a){na(h,e-n/2,0,n,h.transform.height,a)}function na(h,e,n,a,o,c){const m=h.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,o*h.pixelRatio),m.clear({color:c}),_.disable(_.SCISSOR_TEST)}function xl(h,e,n){const a=h.context,o=a.gl,c=n.posMatrix,m=h.useProgram("debug"),_=it.disabled,y=vt.disabled,b=h.colorModeForRenderPass(),T="$debug",S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(o.TEXTURE0);const k=e.getTileByID(n.key).latestRawTileData,D=Math.floor((k&&k.byteLength||0)/1024),B=e.getTile(n).tileSize,N=512/Math.min(B,512)*(n.overscaledZ/h.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),function(Z,X){Z.initDebugOverlayCanvas();const F=Z.debugOverlayCanvas,Y=Z.context.gl,ee=Z.debugOverlayCanvas.getContext("2d");ee.clearRect(0,0,F.width,F.height),ee.shadowColor="white",ee.shadowBlur=2,ee.lineWidth=1.5,ee.strokeStyle="white",ee.textBaseline="top",ee.font="bold 36px Open Sans, sans-serif",ee.fillText(X,5,5),ee.strokeText(X,5,5),Z.debugOverlayTexture.update(F),Z.debugOverlayTexture.bind(Y.LINEAR,Y.CLAMP_TO_EDGE)}(h,`${q} ${D}kB`),m.draw(a,o.TRIANGLES,_,y,Rt.alphaBlended,gt.disabled,xs(c,p.aM.transparent,N),null,T,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(a,o.LINE_STRIP,_,y,b,gt.disabled,xs(c,p.aM.red),S,T,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function vl(h,e,n){const a=h.context,o=a.gl,c=h.colorModeForRenderPass(),m=new it(o.LEQUAL,it.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),y=e.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,h.width,h.height]);for(const b of n){const T=h.renderToTexture.getTexture(b),S=e.getTerrainData(b.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const k=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),D=e.getMeshFrameDelta(h.transform.zoom),B=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),N=qa(k,D,B,h.style.sky,h.transform.pitch);_.draw(a,o.TRIANGLES,m,vt.disabled,c,gt.backCCW,N,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class sa{constructor(e,n,a){this.vertexBuffer=e,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class aa{constructor(e,n){this.context=new xc(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$e.maxUnderzooming+$e.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ja}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const e=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=e.createVertexBuffer(n,fn.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const a=new p.aX;a.emplaceBack(0,0),a.emplaceBack(p.X,0),a.emplaceBack(0,p.X),a.emplaceBack(p.X,p.X),this.debugBuffer=e.createVertexBuffer(a,fn.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,Kr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,fn.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);const m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new p.aY;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const y=this.context.gl;this.stencilClearMode=new vt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=p.H();p.aP(a,0,this.width,this.height,0,0,1),p.K(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,it.disabled,this.stencilClearMode,Rt.disabled,gt.disabled,Mi(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;const a=this.context,o=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(Rt.disabled),a.setDepthMode(it.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of n){const _=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(a,o.TRIANGLES,it.disabled,new vt({func:o.ALWAYS,mask:0},_,255,o.KEEP,o.KEEP,o.REPLACE),Rt.disabled,gt.disabled,Mi(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new vt({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new vt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){const n=this.context.gl,a=e.sort((m,_)=>_.overscaledZ-m.overscaledZ),o=a[a.length-1].overscaledZ,c=a[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let _=0;_({u_sky_color:Z.properties.get("sky-color"),u_horizon_color:Z.properties.get("horizon-color"),u_horizon:(X.height/2+X.getHorizon())*F,u_sky_horizon_blend:Z.properties.get("sky-horizon-blend")*X.height/2*F}))(b,y.style.map.transform,y.pixelRatio),D=new it(S.LEQUAL,it.ReadWrite,[0,1]),B=vt.disabled,N=y.colorModeForRenderPass(),q=y.useProgram("sky");if(!b.mesh){const Z=new p.aX;Z.emplaceBack(-1,-1),Z.emplaceBack(1,-1),Z.emplaceBack(1,1),Z.emplaceBack(-1,1);const X=new p.aY;X.emplaceBack(0,1,2),X.emplaceBack(0,2,3),b.mesh=new sa(T.createVertexBuffer(Z,fn.members),T.createIndexBuffer(X),p.a0.simpleSegment(0,0,Z.length,X.length))}q.draw(T,S.TRIANGLES,D,B,N,gt.disabled,k,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[a[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerq.source&&!q.isHidden(T)?[b.sourceCaches[q.source]]:[]),D=k.filter(q=>q.getSource().type==="vector"),B=k.filter(q=>q.getSource().type!=="vector"),N=q=>{(!S||S.getSource().maxzoomN(q)),S||B.forEach(q=>N(q)),S}(this.style,this.transform.zoom);y&&function(b,T,S){for(let k=0;k0),o&&(p.b0(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.sourceCache.getRenderableTiles(),D=c.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1});for(const B of k){const N=m.getTerrainData(B.tileID),q={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};D.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,q,N,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain),function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.getCoordsTexture(),D=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const N of D){const q=m.getTerrainData(N.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,k.texture);const Z={u_matrix:c.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,Z,q,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(N.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,o){if(!a.isHidden(this.transform.zoom)&&(a.type==="background"||a.type==="custom"||(o||[]).length))switch(this.id=a.id,a.type){case"symbol":(function(c,m,_,y,b){if(c.renderPass!=="translucent")return;const T=vt.disabled,S=c.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(k,D,B,N,q,Z,X,F,Y){const ee=D.transform,ae=pn(),fe=q==="map",_e=Z==="map";for(const Pe of k){const ke=N.getTile(Pe),we=ke.getBucket(B);if(!we||!we.text||!we.text.segments.get().length)continue;const be=p.ag(we.textSizeData,ee.zoom),Re=rt(ke,1,D.transform.zoom),Xe=Yr(Pe.posMatrix,_e,fe,D.transform,Re),Se=B.layout.get("icon-text-fit")!=="none"&&we.hasIconData();if(be){const Ce=Math.pow(2,ee.zoom-ke.tileID.overscaledZ),qe=D.style.map.terrain?(Ye,nt)=>D.style.map.terrain.getElevation(Pe,Ye,nt):null,Tt=ae.translatePosition(ee,ke,X,F);On(we,fe,_e,Y,ee,Xe,Pe.posMatrix,Ce,be,Se,ae,Tt,Pe.toUnwrapped(),qe)}}}(y,c,_,m,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&no(c,m,_,y,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),T,S),_.paint.get("text-opacity").constantOr(1)!==0&&no(c,m,_,y,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(ws(c,m,_,y,!0),ws(c,m,_,y,!1))})(e,n,a,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,_,y){if(c.renderPass!=="translucent")return;const b=_.paint.get("circle-opacity"),T=_.paint.get("circle-stroke-width"),S=_.paint.get("circle-stroke-opacity"),k=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const D=c.context,B=D.gl,N=c.depthModeForSublayer(0,it.ReadOnly),q=vt.disabled,Z=c.colorModeForRenderPass(),X=[];for(let F=0;FF.sortKey-Y.sortKey);for(const F of X){const{programConfiguration:Y,program:ee,layoutVertexBuffer:ae,indexBuffer:fe,uniformValues:_e,terrainData:Pe}=F.state;ee.draw(D,B.TRIANGLES,N,q,Z,gt.disabled,_e,Pe,_.id,ae,fe,F.segments,_.paint,c.transform.zoom,Y)}})(e,n,a,o);break;case"heatmap":(function(c,m,_,y){if(_.paint.get("heatmap-opacity")===0)return;const b=c.context;if(c.style.map.terrain){for(const T of y){const S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?ao(c,S,_,T):c.renderPass==="translucent"&&bn(c,_,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?function(T,S,k,D){const B=T.context,N=B.gl,q=vt.disabled,Z=new Rt([N.ONE,N.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(X,F,Y){const ee=X.gl;X.activeTexture.set(ee.TEXTURE1),X.viewport.set([0,0,F.width/4,F.height/4]);let ae=Y.heatmapFbos.get(p.aU);ae?(ee.bindTexture(ee.TEXTURE_2D,ae.colorAttachment.get()),X.bindFramebuffer.set(ae.framebuffer)):(ae=Ss(X,F.width/4,F.height/4),Y.heatmapFbos.set(p.aU,ae))})(B,T,k),B.clear({color:p.aM.transparent});for(let X=0;X20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const we=c.style.map.terrain&&c.style.map.terrain.getTerrainData(X),be=we?X:null,Re=be?be.posMatrix:c.transform.calculatePosMatrix(X.toUnwrapped(),Z),Xe=lc(Re,Pe||[0,0],_e||1,fe,_);S instanceof Nr?k.draw(b,T.TRIANGLES,F,vt.disabled,D,gt.disabled,Xe,we,_.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):k.draw(b,T.TRIANGLES,F,B[X.overscaledZ],D,gt.disabled,Xe,we,_.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,a,o);break;case"background":(function(c,m,_,y){const b=_.paint.get("background-color"),T=_.paint.get("background-opacity");if(T===0)return;const S=c.context,k=S.gl,D=c.transform,B=D.tileSize,N=_.paint.get("background-pattern");if(c.isPatternMissing(N))return;const q=!N&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==q)return;const Z=vt.disabled,X=c.depthModeForSublayer(0,q==="opaque"?it.ReadWrite:it.ReadOnly),F=c.colorModeForRenderPass(),Y=c.useProgram(N?"backgroundPattern":"background"),ee=y||D.coveringTiles({tileSize:B,terrain:c.style.map.terrain});N&&(S.activeTexture.set(k.TEXTURE0),c.imageManager.bind(c.context));const ae=_.getCrossfadeParameters();for(const fe of ee){const _e=y?fe.posMatrix:c.transform.calculatePosMatrix(fe.toUnwrapped()),Pe=N?Ha(_e,T,c,N,{tileID:fe,tileSize:B},ae):Ks(_e,T,b),ke=c.style.map.terrain&&c.style.map.terrain.getTerrainData(fe);Y.draw(S,k.TRIANGLES,X,Z,F,gt.disabled,Pe,ke,_.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,a,o);break;case"custom":(function(c,m,_){const y=c.context,b=_.implementation;if(c.renderPass==="offscreen"){const T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(vt.disabled);const T=b.renderingMode==="3d"?new it(c.context.gl.LEQUAL,it.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,it.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,a)}}translatePosMatrix(e,n,a,o,c){if(!a[0]&&!a[1])return e;const m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){const b=Math.sin(m),T=Math.cos(m);a=[a[0]*T-a[1]*b,a[0]*b+a[1]*T]}const _=[c?a[0]:rt(n,a[0],this.transform.zoom),c?a[1]:rt(n,a[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,e,_),y}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n){this.cache=this.cache||{};const a=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Za(this.context,Qr[e],n,Xa[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new et(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class $n{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,a){const o=Math.pow(2,a),c=[[-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(_=>{const y=1/(_=p.af([],_,e))[3]/n*o;return p.b1(_,_,[y,y,1/_[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(_=>{const y=function(k,D){var B=D[0],N=D[1],q=D[2],Z=B*B+N*N+q*q;return Z>0&&(Z=1/Math.sqrt(Z)),k[0]=D[0]*Z,k[1]=D[1]*Z,k[2]=D[2]*Z,k}([],function(k,D,B){var N=D[0],q=D[1],Z=D[2],X=B[0],F=B[1],Y=B[2];return k[0]=q*Y-Z*F,k[1]=Z*X-N*Y,k[2]=N*F-q*X,k}([],gi([],c[_[0]],c[_[1]]),gi([],c[_[2]],c[_[1]]))),b=-((T=y)[0]*(S=c[_[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)});return new $n(c,m)}}class qn{constructor(e,n){this.min=e,this.max=n,this.center=function(a,o,c){return a[0]=.5*o[0],a[1]=.5*o[1],a[2]=.5*o[2],a}([],function(a,o,c){return a[0]=o[0]+c[0],a[1]=o[1]+c[1],a[2]=o[2]+c[2],a}([],this.min,this.max))}quadrant(e){const n=[e%2==0,e<2],a=mi(this.min),o=mi(this.max);for(let c=0;c=0&&m++;if(m===0)return 0;m!==n.length&&(a=!1)}if(a)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let _=0;_this.max[o]-this.min[o])return 0}return 1}}class Zn{constructor(e=0,n=0,a=0,o=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=o}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=p.y.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=p.y.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=p.y.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=p.y.number(e.right,n.right,a)),this}getCenter(e,n){const a=p.ac((this.left+e-this.right)/2,0,e),o=p.ac((this.top+n-this.bottom)/2,0,n);return new p.P(a,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Zn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const lo=85.051129;class Gn{constructor(e,n,a,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Zn,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const e=new Gn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,this.latRange=e.latRange,this.lngRange=e.lngRange,this.width=e.width,this.height=e.height,this._center=e._center,this._elevation=e._elevation,this.minElevationForCurrentTile=e.minElevationForCurrentTile,this.zoom=e.zoom,this.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const n=-p.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new p.A(4);return p.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,o,c){var m=o[0],_=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);a[0]=m*S+y*T,a[1]=_*S+b*T,a[2]=m*-T+y*S,a[3]=_*-T+b*S}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const n=p.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){const n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){const n=[new p.b4(0,e)];if(this._renderWorldCopies){const a=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),_=Math.floor(Math.min(a.x,o.x,c.x,m.x)),y=Math.floor(Math.max(a.x,o.x,c.x,m.x)),b=1;for(let T=_-b;T<=y+b;T++)T!==0&&n.push(new p.b4(T,e))}return n}coveringTiles(e){var n,a;let o=this.coveringZoomLevel(e);const c=o;if(e.minzoom!==void 0&&oe.maxzoom&&(o=e.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),_=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*_.x,y*_.y,0],S=$n.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let k=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(k=o);const D=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,B=F=>({aabb:new qn([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),N=[],q=[],Z=o,X=e.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)N.push(B(-F)),N.push(B(F));for(N.push(B(0));N.length>0;){const F=N.pop(),Y=F.x,ee=F.y;let ae=F.fullyVisible;if(!ae){const we=F.aabb.intersects(S);if(we===0)continue;ae=we===2}const fe=e.terrain?b:T,_e=F.aabb.distanceX(fe),Pe=F.aabb.distanceY(fe),ke=Math.max(Math.abs(_e),Math.abs(Pe));if(F.zoom===Z||ke>D+(1<=k){const we=Z-F.zoom,be=b[0]-.5-(Y<>1),Xe=F.zoom+1;let Se=F.aabb.quadrant(we);if(e.terrain){const Ce=new p.S(Xe,F.wrap,Xe,be,Re),qe=e.terrain.getMinMaxElevation(Ce),Tt=(n=qe.minElevation)!==null&&n!==void 0?n:this.elevation,Ye=(a=qe.maxElevation)!==null&&a!==void 0?a:this.elevation;Se=new qn([Se.min[0],Se.min[1],Tt],[Se.max[0],Se.max[1],Ye])}N.push({aabb:Se,zoom:Xe,x:be,y:Re,wrap:F.wrap,fullyVisible:ae})}}return q.sort((F,Y)=>F.distanceSq-Y.distanceSq).map(F=>F.tileID)}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const n=p.ac(e.lat,-85.051129,lo);return new p.P(p.O(e.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(e){return new p.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){const n=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=a+n-c,_=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(_/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(e,n){const a=this.pointCoordinate(n),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new p.Z(c.x-(a.x-o.x),c.y-(a.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return p.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){const k=n.pointCoordinate(e);if(k!=null)return k}const a=[e.x,e.y,0,1],o=[e.x,e.y,1,1];p.af(a,a,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=a[3],m=o[3],_=a[1]/c,y=o[1]/m,b=a[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(a[0]/c,o[0]/m,S)/this.worldSize,p.y.number(_,y,S)/this.worldSize)}coordinatePoint(e,n=0,a=this.pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,n,1];return p.af(o,o,a),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this.height/2-this.getHorizon());return new le().extend(this.pointLocation(new p.P(0,e))).extend(this.pointLocation(new p.P(this.width,e))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new le([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,lo])}calculateTileMatrix(e){const n=e.canonical,a=this.worldSize/this.zoomScale(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*a,n.y*a,0]),p.K(c,c,[a/p.X,a/p.X,1]),c}calculatePosMatrix(e,n=!1){const a=e.key,o=n?this._alignedPosMatrixCache:this._posMatrixCache;if(o[a])return o[a];const c=this.calculateTileMatrix(e);return p.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[a]=new Float32Array(c),o[a]}calculateFogMatrix(e){const n=e.key,a=this._fogMatrixCache;if(a[n])return a[n];const o=this.calculateTileMatrix(e);return p.L(o,this.fogMatrix,o),a[n]=new Float32Array(o),a[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=p.ac(+n,this.minZoom,this.maxZoom);const a={center:new p.N(e.lng,e.lat),zoom:n};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(a.zoom);let m=0,_=c,y=0,b=c,T=0,S=0;const{x:k,y:D}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,_=p.Q(F[0])*c,_-m_&&(Z=_-F)}if(o){const F=(y+b)/2;let Y=B;this._renderWorldCopies&&(Y=p.b3(B,F-c/2,F+c/2));const ee=k/2;Y-eeb&&(q=b-ee)}if(q!==void 0||Z!==void 0){const F=new p.P(q??B,Z??N);a.center=this.unproject.call({worldSize:c},F).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=a,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;const c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),_=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?_:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+e.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),k=this.getHorizon(),D=2*Math.atan(k/this.cameraToCenterDistance)*(.5+e.y/(2*k)),B=Math.sin(D)*y/Math.sin(p.ac(Math.PI-b-D,.01,Math.PI-.01)),N=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*N+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-e.x/this.width,o[9]=2*e.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-n,-a,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-a,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);const q=this.width%2/2,Z=this.height%2/2,X=Math.cos(this.angle),F=Math.sin(this.angle),Y=n-Math.round(n)+X*q+F*Z,ee=a-Math.round(a)+X*Z+F*q,ae=new Float64Array(o);if(p.J(ae,ae,[Y>.5?Y-1:Y,ee>.5?ee-1:ee,0]),this.alignedModelViewProjectionMatrix=ae,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new p.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return p.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,e))}getCameraQueryGeometry(e){const n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let a=n.x,o=n.y,c=n.x,m=n.y;for(const _ of e)a=Math.min(a,_.x),o=Math.min(o,_.y),c=Math.max(c,_.x),m=Math.max(m,_.y);return[new p.P(a,o),new p.P(c,o),new p.P(c,m),new p.P(a,m),new p.P(a,o)]}}lngLatToCameraDepth(e,n){const a=this.locationCoordinate(e),o=[a.x*this.worldSize,a.y*this.worldSize,n,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function As(h,e){let n,a=!1,o=null,c=null;const m=()=>{o=null,a&&(h.apply(c,n),o=setTimeout(m,e),a=!1)};return(..._)=>(a=!0,c=this,n=_,o||m(),o)}class oa{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(o=>o.split("=")).forEach(o=>{o[0]===this._hashName&&(a=o)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const a=n.join("/");let o=a;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${a}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=As(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,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()),this._removeHash(),delete this._map,this}getHashString(e){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,o=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(n.lng*c)/c,_=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=e?`/${m}/${_}/${a}`:`${a}/${_}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let k=!1;const D=window.location.hash.slice(1).split("&").map(B=>{const N=B.split("=")[0];return N===S?(k=!0,`${N}=${T}`):B}).filter(B=>B);return k||D.push(`${S}=${T}`),`#${D.join("&")}`}return`#${T}`}}const la={linearity:.3,easing:p.b8(0,0,.3,1)},co=p.e({deceleration:2500,maxSpeed:1400},la),bc=p.e({deceleration:20,maxSpeed:1400},la),bl=p.e({deceleration:1e3,maxSpeed:360},la),ca=p.e({deceleration:1e3,maxSpeed:90},la);class ho{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:de.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=de.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){const c=Ms(n.pan.mag(),a,p.e({},co,e||{}));o.offset=n.pan.mult(c.amount/n.pan.mag()),o.center=this._map.transform.center,Cs(o,c)}if(n.zoom){const c=Ms(n.zoom,a,bc);o.zoom=this._map.transform.zoom+c.amount,Cs(o,c)}if(n.bearing){const c=Ms(n.bearing,a,bl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),Cs(o,c)}if(n.pitch){const c=Ms(n.pitch,a,ca);o.pitch=this._map.transform.pitch+c.amount,Cs(o,c)}if(o.zoom||o.bearing){const c=n.pinchAround===void 0?n.around:n.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function Cs(h,e){(!h.duration||h.durationn.unproject(y)),_=c.reduce((y,b,T,S)=>y.add(b.div(S.length)),new p.P(0,0));super(e,{points:c,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class wl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Tl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new wl(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new ai(e.type,this._map,e))}mouseup(e){this._map.fire(new ai(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ai(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ai(e.type,this._map,e))}mouseover(e){this._map.fire(new ai(e.type,this._map,e))}mouseout(e){this._map.fire(new ai(e.type,this._map,e))}touchstart(e){return this._firePreventable(new wn(e.type,this._map,e))}touchmove(e){this._map.fire(new wn(e.type,this._map,e))}touchend(e){this._map.fire(new wn(e.type,this._map,e))}touchcancel(e){this._map.fire(new wn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ai(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ai("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ai(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.pointLocation(p.P.convert(e),this._map.terrain)}}class qi{constructor(e,n){this._map=e,this._tr=new pr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)c.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new p.k(e,{originalEvent:n}))}}function ks(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(o){const c=new p.P(0,0);for(const m of o)c._add(m);return c.div(o.length)}(n),this.touches=ks(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;const o=ks(a,n);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class ha{constructor(e){this.singleTap=new uo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){const o=this.singleTap.touchend(e,n,a);if(o){const c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Hn{constructor(e){this._tr=new pr(e),this._zoomIn=new ha({numTouches:1,numTaps:2}),this._zoomOut=new ha({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){const o=this._zoomIn.touchend(e,n,a),c=this._zoomOut.touchend(e,n,a),m=this._tr;return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $r{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const o=n.length?n[0]:n;return!this._moved&&o.dist(a){h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},mo=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({bearingDelta:(c.x-o.x)*n}),moveStateManager:a,enable:h,assignEvents:da})},go=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({pitchDelta:(c.y-o.y)*n}),moveStateManager:a,enable:h,assignEvents:da})};class Tn{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);const o=ks(a,n),c=new p.P(0,0),m=new p.P(0,0);let _=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),_++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(_)||!m.mag())return;const y=m.div(_);return this._sum._add(y),this._sum.mag()Math.abs(h.x)}class Xn extends pa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;const o=e.mag()>=2,c=n.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const m=e.y>0==n.y>0;return fa(e)&&fa(n)&&m}}const Sl={panStep:100,bearingStep:15,pitchStep:10};class er{constructor(e){this._tr=new pr(e);const n=Sl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,o=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(a=0,o=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Er,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Er(h){return h*(2-h)}const bo=4.000244140625;class fr{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new pr(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=de.now(),o=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%bo==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_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 n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._around=n.y>a.transform.height/2-a.transform.getHorizon()?p.N.convert(this._aroundCenter?a.center:a.unproject(n)):p.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(this._delta!==0){const y=this._type==="wheel"&&Math.abs(this._delta)>bo?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);const T=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,a=this._startZoom,o=this._easing;let c,m=!1;const _=de.now()-this._lastWheelEventTime;if(this._type==="wheel"&&a&&o&&_){const y=Math.min(_/200,1),b=o(y);c=p.y.number(a,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=p.b9;if(this._prevEase){const a=this._prevEase,o=(de.now()-a.start)/a.duration,c=a.easing(o+.01)-a.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=p.b8(m,_,.25,1)}return this._prevEase={start:de.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Sn{constructor(e,n){this._clickZoom=e,this._tapZoom=n}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 wc{constructor(e){this._tr=new pr(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Tc{constructor(){this._tap=new ha({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,a){if(!this._swipePoint)if(this._tapTime){const o=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?a.length>0&&(this._swipePoint=o,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const o=n[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const o=this._tap.touchend(e,n,a);o&&(this._tapTime=e.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Il{constructor(e,n,a){this._el=e,this._mousePan=n,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Pl{constructor(e,n,a){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}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 wo{constructor(e,n,a,o){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Wn{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=n,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const tr=h=>h.zoom||h.drag||h.pitch||h.rotate;class ze extends p.k{}function ma(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class To{constructor(e,n){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=o.type==="renderFrame"?void 0:o,_={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,k=S?se.touchPos(this._map.getCanvas(),S):se.mousePos(this._map.getCanvas(),o);for(const{handlerName:N,handler:q,allowed:Z}of this._handlers){if(!q.isEnabled())continue;let X;this._blockedByActive(b,Z,N)?q.reset():q[c||o.type]&&(X=q[c||o.type](o,k,S),this.mergeHandlerResult(_,y,X,N,m),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||q.isActive())&&(b[N]=q)}const D={};for(const N in this._previousActiveHandlers)b[N]||(D[N]=m);this._previousActiveHandlers=b,(Object.keys(D).length||ma(_))&&(this._changes.push([_,y,D]),this._triggerRenderFrame()),(Object.keys(b).length||ma(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=_;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ho(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)se.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Tl(n,e));const o=n.boxZoom=new qi(n,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const c=n.cooperativeGestures=new Wn(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();const m=new Hn(n),_=new wc(n);n.doubleClickZoom=new Sn(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const y=new Tc;this._add("tapDragZoom",y);const b=n.touchPitch=new Xn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const T=mo(e),S=go(e);n.dragRotate=new Pl(e,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const k=(({enable:X,clickTolerance:F})=>{const Y=new ua({checkCorrectEvent:ee=>se.mouseButton(ee)===0&&!ee.ctrlKey});return new $r({clickTolerance:F,move:(ee,ae)=>({around:ae,panDelta:ae.sub(ee)}),activateOnStart:!0,moveStateManager:Y,enable:X,assignEvents:da})})(e),D=new Tn(e,n);n.dragPan=new Il(a,k,D),this._add("mousePan",k),this._add("touchPan",D,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const B=new vo,N=new yo;n.touchZoomRotate=new wo(a,N,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const q=n.scrollZoom=new fr(n,()=>this._triggerRenderFrame());this._add("scrollZoom",q,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const Z=n.keyboard=new er(n);this._add("keyboard",Z),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Bt(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!tr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(const o in e)if(o!==a&&(!n||n.indexOf(o)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,o,c){if(!a)return;p.e(e,a);const m={handlerName:o,originalEvent:a.originalEvent||c};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const e={},n={},a={};for(const[o,c,m]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(e.around=o.around),o.pinchAround!==void 0&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),p.e(n,c),p.e(a,m);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(ma(e)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:k}=e;k!==void 0&&(S=k),o._stop(!0),S=S||o.transform.centerPoint;const D=c.pointLocation(_?S.sub(_):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(_)):c.setLocationAtPoint(D,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(D,S)):c.setLocationAtPoint(D,S),o._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){const o=tr(this._eventsInProgress),c=tr(e),m={};for(const S in e){const{originalEvent:k}=e[S];this._eventsInProgress[S]||(m[`${S}start`]=k),this._eventsInProgress[S]=e[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(const S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(const S in e){const{originalEvent:k}=e[S];this._fireEvent(S,k)}const _={};let y;for(const S in this._eventsInProgress){const{handlerName:k,originalEvent:D}=this._eventsInProgress[S];this._handlersById[k].isActive()||(delete this._eventsInProgress[S],y=n[k]||D,_[`${S}end`]=y)}for(const S in _)this._fireEvent(S,_[S]);const b=tr(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),k=D=>D!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ze("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Al extends p.E{constructor(e,n){super(),this._renderFrameCallback=()=>{const a=Math.min((de.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,a){return e=p.P.convert(e).mult(-1),this.panTo(this.transform.center,p.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(p.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(p.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(p.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,p.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing()){if(this._zooming&&(o.zoom=p.y.number(c,q,fe)),this._rotating&&(o.bearing=p.y.number(m,b,fe)),this._pitching&&(o.pitch=p.y.number(_,T,fe)),this._padding&&(o.interpolatePadding(y,S,fe),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(fe),Y)o.setLocationAtPoint(Y,ee);else{const _e=o.zoomScale(o.zoom-c),Pe=q>c?Math.min(2,F):Math.max(.5,F),ke=Math.pow(Pe,1-fe),we=o.unproject(Z.add(X.mult(fe*ke)).mult(_e));o.setLocationAtPoint(o.renderWorldCopies?we.wrap():we,D)}this._applyUpdatedTransform(o),this._fireMoveEvents(n)},fe=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,fe)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new p.k("movestart",e)),this._zooming&&!a.zooming&&this.fire(new p.k("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new p.k("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new p.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){const n=e.getCameraPosition(),a=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitudethis._elevateCameraIfInsideTerrain(o)),this.transformCameraUpdate&&n.push(o=>this.transformCameraUpdate(o)),!n.length)return;const a=e.clone();for(const o of n){const c=a.clone(),{center:m,zoom:_,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),_!==void 0&&(c.zoom=_),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),a.apply(c)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new p.k("move",e)),this._zooming&&this.fire(new p.k("zoom",e)),this._rotating&&this.fire(new p.k("rotate",e)),this._pitching&&this.fire(new p.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new p.k("zoomend",e)),o&&this.fire(new p.k("rotateend",e)),c&&this.fire(new p.k("pitchend",e)),this.fire(new p.k("moveend",e))}flyTo(e,n){var a;if(!e.essential&&de.prefersReducedMotion){const Ce=p.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ce,n)}this.stop(),e=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},e);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,_=o.pitch,y=o.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,T="pitch"in e?+e.pitch:_,S="padding"in e?e.padding:o.padding,k=p.P.convert(e.offset);let D=o.centerPoint.add(k);const B=o.pointLocation(D),{center:N,zoom:q}=o.getConstrained(p.N.convert(e.center||B),(a=e.zoom)!==null&&a!==void 0?a:c);this._normalizeCenter(N,o);const Z=o.zoomScale(q-c),X=o.project(B),F=o.project(N).sub(X);let Y=e.curve;const ee=Math.max(o.width,o.height),ae=ee/Z,fe=F.mag();if("minZoom"in e){const Ce=p.ac(Math.min(e.minZoom,c,q),o.minZoom,o.maxZoom),qe=ee/o.zoomScale(Ce-c);Y=Math.sqrt(qe/fe*2)}const _e=Y*Y;function Pe(Ce){const qe=(ae*ae-ee*ee+(Ce?-1:1)*_e*_e*fe*fe)/(2*(Ce?ae:ee)*_e*fe);return Math.log(Math.sqrt(qe*qe+1)-qe)}function ke(Ce){return(Math.exp(Ce)-Math.exp(-Ce))/2}function we(Ce){return(Math.exp(Ce)+Math.exp(-Ce))/2}const be=Pe(!1);let Re=function(Ce){return we(be)/we(be+Y*Ce)},Xe=function(Ce){return ee*((we(be)*(ke(qe=be+Y*Ce)/we(qe))-ke(be))/_e)/fe;var qe},Se=(Pe(!0)-be)/Y;if(Math.abs(fe)<1e-6||!isFinite(Se)){if(Math.abs(ee-ae)<1e-6)return this.easeTo(e,n);const Ce=ae0,Re=qe=>Math.exp(Ce*Y*qe)}return e.duration="duration"in e?+e.duration:1e3*Se/("screenSpeed"in e?+e.screenSpeed/Y:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==_,this._padding=!o.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N),this._ease(Ce=>{const qe=Ce*Se,Tt=1/Re(qe);o.zoom=Ce===1?q:c+o.scaleZoom(Tt),this._rotating&&(o.bearing=p.y.number(m,b,Ce)),this._pitching&&(o.pitch=p.y.number(_,T,Ce)),this._padding&&(o.interpolatePadding(y,S,Ce),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(Ce);const Ye=Ce===1?N:o.unproject(X.add(F.mult(Xe(qe))).mult(Tt));o.setLocationAtPoint(o.renderWorldCopies?Ye.wrap():Ye,D),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=de.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=p.b3(e,-180,180);const a=Math.abs(e-n);return Math.abs(e-360-n)180?-360:a<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}const Kn={compact:!0,customAttribution:'MapLibre'};class Jn{constructor(e=Kn){this._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")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.create("div","maplibregl-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(){se.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(e,n){const a=this._map._getUIString(`AttributionControl.${n}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(o=>typeof o!="string"?"":o)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const n=this._map.style.sourceCaches;for(const o in n){const c=n[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter(o=>String(o).trim()),e.sort((o,c)=>o.length-c.length),e=e.filter((o,c)=>{for(let m=c+1;m=0)return!1;return!0});const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class So{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class st{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const o of a)if(o.id===e)return void(o.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Io=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Sc extends p.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const a={};for(const o of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Jr(o,this.tileSize));for(const o in this._tiles)a[o]||delete this._tiles[o]}freeRtt(e){for(const n in this._tiles){const a=this._tiles[n];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){const n={};for(const a of this._renderableTilesKeys){const o=this._tiles[a].tileID;if(o.canonical.equals(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),n[a]=c}else if(o.canonical.isChildOf(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-e.canonical.z,_=o.canonical.x-(o.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-_*b,-y*b,0]),n[a]=c}else if(e.canonical.isChildOf(o.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=e.canonical.z-o.canonical.z,_=e.canonical.x-(e.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[_*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[a]=c}}return n}getSourceTile(e,n){const a=this.sourceCache._source;let o=e.overscaledZ-this.deltaZoom;if(o>a.maxzoom&&(o=a.maxzoom),o=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(o--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=e)}}class Po{constructor(e,n,a){this.painter=e,this.sourceCache=new Sc(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,a,o=p.X){var c;if(!(n>=0&&n=0&&ae.canonical.z&&(e.canonical.z>=o?c=e.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|c>>8,n[m+3]=0;const a=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),o=new et(e,a,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,o=a.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,_-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const k=this._coordsTextureSize,D=(1<e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)===!1}}const Yn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Cl{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new Ic(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in e.sourceCaches){this._coordsDescendingInv[a]={};const o=e.sourceCaches[a].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const _ in m)this._coordsDescendingInv[a][_]||(this._coordsDescendingInv[a][_]=[]),this._coordsDescendingInv[a][_].push(m[_])}}this._coordsDescendingInvStr={};for(const a of e._order){const o=e._layers[a],c=o.source;if(Yn[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][a.tileID.key];c&&c!==a.rttCoords[o]&&(a.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;const n=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yn[n]&&(this._prevType&&Yn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(Yn[this._prevType]||Yn[n]&&o){this._prevType=n;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const _ of this._renderableTiles){if(this.pool.isFull()&&(vl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[c]){const b=this.pool.getObjectForId(_.rtt[c].id);if(b.stamp===_.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),_.rtt[c]={id:y.id,stamp:y.stamp},a.context.bindFramebuffer.set(y.fbo.framebuffer),a.context.clear({color:p.aM.transparent,stencil:0}),a.currentStencilSource=void 0;for(let b=0;b{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},Ac={showCompass:!0,showZoom:!0,visualizePitch:!1};class Cc{constructor(e,n,a=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),se.mousePos(this.element,m)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,se.mousePos(this.element,m))},this.mouseup=m=>{this.mouseRotate.dragEnd(m),this.mousePitch&&this.mousePitch.dragEnd(m),this.offTemp()},this.touchstart=m=>{m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.moveTouch(m,this._lastPos))},this.touchend=m=>{m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const o=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=mo({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:_,bearingDegreesPerPixelMoved:y=.8})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:o,enable:!0}),this.map=e,a&&(this.mousePitch=go({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:_,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:c,enable:!0})),se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),se.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),se.disableDrag()}moveMouse(e,n){const a=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}moveTouch(e,n){const a=this.map,{bearingDelta:o}=this.touchRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}off(){const e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let Zi;function wt(h,e,n){const a=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),e){const o=new p.N(h.lng-360,h.lat),c=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(o).distSqr(e)180;){const o=n.locationPoint(h);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:a}const Qn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ga(h,e,n){const a=h.classList;for(const o in Qn)a.remove(`maplibregl-${n}-anchor-${o}`);a.add(`maplibregl-${n}-anchor-${e}`)}class _a extends p.E{constructor(e){if(super(),this._onKeyPress=n=>{const a=n.code,o=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,o=this._element;this._popup&&(a===o||o.contains(a))&&this.togglePopup()},this._update=n=>{var a;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?wt(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Qn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),de.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.k("dragstart"))),this.fire(new p.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new p.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=p.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${o}px`),n.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);const c=se.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");const m=se.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=se.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const Z of y){const X=se.createNS("http://www.w3.org/2000/svg","ellipse");X.setAttributeNS(null,"opacity","0.04"),X.setAttributeNS(null,"cx","10.5"),X.setAttributeNS(null,"cy","5.80029008"),X.setAttributeNS(null,"rx",Z.rx),X.setAttributeNS(null,"ry",Z.ry),_.appendChild(X)}const b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=se.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const k=se.createNS("http://www.w3.org/2000/svg","path");k.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(k);const D=se.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(6.0, 7.0)"),D.setAttributeNS(null,"fill","#FFFFFF");const B=se.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const N=se.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");const q=se.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#FFFFFF"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962"),B.appendChild(N),B.appendChild(q),m.appendChild(_),m.appendChild(b),m.appendChild(S),m.appendChild(D),m.appendChild(B),n.appendChild(m),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),ga(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=p.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const o=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[o,-1*(38.1-13.5+o)],"bottom-right":[-o,-1*(38.1-13.5+o)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,a;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);const _=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*_,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=p.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const kl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let zs=0,Ds=!1;const zr={maxWidth:100,unit:"metric"};function Ls(h,e,n){const a=n&&n.maxWidth||100,o=h._container.clientHeight/2,c=h.unproject([0,o]),m=h.unproject([a,o]),_=c.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*_;y>5280?Le(e,a,y/5280,h._getUIString("ScaleControl.Miles")):Le(e,a,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Le(e,a,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?Le(e,a,_/1e3,h._getUIString("ScaleControl.Kilometers")):Le(e,a,_,h._getUIString("ScaleControl.Meters"))}function Le(h,e,n,a){const o=function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let _=c/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(_),m*_}(n);h.style.width=e*(o/n)+"px",h.innerHTML=`${o} ${a}`}const je={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ya=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function xa(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(e,e),"top-right":new p.P(-e,e),bottom:new p.P(0,-h),"bottom-left":new p.P(e,-e),"bottom-right":new p.P(-e,-e),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){const e=p.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return xa(new p.P(0,0))}const Mo=Je;M.AJAXError=p.bh,M.Evented=p.E,M.LngLat=p.N,M.MercatorCoordinate=p.Z,M.Point=p.P,M.addProtocol=p.bi,M.config=p.a,M.removeProtocol=p.bj,M.AttributionControl=Jn,M.BoxZoomHandler=qi,M.CanvasSource=Ji,M.CooperativeGesturesHandler=Wn,M.DoubleClickZoomHandler=Sn,M.DragPanHandler=Il,M.DragRotateHandler=Pl,M.EdgeInsets=Zn,M.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},M.GeoJSONSource=fs,M.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new p.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new p.N(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=le.fromLngLat(n,a);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new p.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ds)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=se.create("button","maplibregl-ctrl-geolocate",this._container),se.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new _a({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _a({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))})}},this.options=p.e({},kl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return p._(this,arguments,void 0,function*(e=!1){if(Zi!==void 0&&!e)return Zi;if(window.navigator.permissions===void 0)return Zi=!!window.navigator.geolocation,Zi;try{Zi=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Zi=!!window.navigator.geolocation}return Zi})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),se.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,zs=0,Ds=!1}_isOutOfMapMaxBounds(h){const e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitudee.getEast()||n.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),a=e.distanceTo(n),o=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":zs--,Ds=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new p.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new p.k("trackuserlocationstart")),this.fire(new p.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),zs++,zs>1?(h={maximumAge:6e5,timeout:0},Ds=!0):(h=this.options.positionOptions,Ds=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},M.Hash=oa,M.ImageSource=Nr,M.KeyboardHandler=er,M.LngLatBounds=le,M.LogoControl=So,M.Map=class extends Al{constructor(h){p.bf.mark(p.bg.create);const e=Object.assign(Object.assign({},Pc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Gn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new st,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ao),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Mt.addThrottleControl(()=>this.isMoving()),this._requestManager=new ln(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1;const a=As(o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())},50);this._resizeObserver=new ResizeObserver(o=>{n?a(o):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new To(this,e),this._hash=e.hash&&new oa(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,p.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new Jn(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new So,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new p.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h){var e;const n=this._containerDimensions(),a=n[0],o=n[1],c=this._getClampedPixelRatio(a,o);if(this._resizeCanvas(a,o,c),this.painter.resize(a,o,c),this.painter.overLimit()){const _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];const y=this._getClampedPixelRatio(a,o);this._resizeCanvas(a,o,y),this.painter.resize(a,o,y)}this.transform.resize(a,o),(e=this._requestedCameraState)===null||e===void 0||e.resize(a,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,e){const{0:n,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),c=h*o,m=e*o;return Math.min(c>n?n/c:1,m>a?a/m:1)*o}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(le.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{const m=e.filter(y=>this.getLayer(y)),_=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];_.length?a||(a=!0,n.call(this,new ai(h,this,c.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))}}}}{const a=o=>{const c=e.filter(_=>this.getLayer(_)),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,n.call(this,o),delete o.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let o=0;oe.includes(m))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void a.splice(o,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const a=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,a);for(const o in a.delegates)this.on(o,a.delegates[o]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,n);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(..._)=>{this._removeDelegatedListener(h,a,n),m(..._)}}this._saveDelegatedListener(h,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const a=h instanceof p.P||Array.isArray(h),o=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},o instanceof p.P||typeof o[0]=="number")n=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);n=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new qs(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new qs(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new p.j(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&p.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Po(this.painter,e,h),this.painter.renderToTexture=new Cl(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const a in n){const o=n[a];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){const{pixelRatio:a=1,sdf:o=!1,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||p.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:T,height:S,data:k}=e,D=e;return this.style.addImage(h,{data:new p.R({width:T,height:S},new Uint8Array(k)),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:D}),D.onAdd&&D.onAdd(this,h),this}}{const{width:T,height:S,data:k}=de.getImageData(e);this.style.addImage(h,{data:new p.R({width:T,height:S},k),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||p.b(e)?de.getImageData(e):e,{width:o,height:c,data:m}=a;if(o===void 0||c===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==n.data.width||c!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||p.b(e));return n.data.replace(m,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Mt.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const o=this._controlContainer=se.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{c[m]=se.create("div",`maplibregl-ctrl-${m} `,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new aa(n,this.transform),Ot.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){const e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=de.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=m.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Mt.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,de.frameAsync(this._frameRequest).then(h=>{p.bf.frame(h),this._frameRequest=null,this._render(h)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Ml}getCameraTargetElevation(){return this.transform.elevation}},M.MapMouseEvent=ai,M.MapTouchEvent=wn,M.MapWheelEvent=wl,M.Marker=_a,M.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=p.e({},Ac,h),this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Cc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},M.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new p.k("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const _ of this.options.className.split(" "))this._container.classList.add(_);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?wt(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;const a=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let o=this.options.anchor;const c=xa(this.options.offset);if(!o){const _=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=a.y+c.bottom.ythis._map.transform.height-y?["bottom"]:[],a.x<_/2?b.push("left"):a.x>this._map.transform.width-_/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=a.add(c[o]);this.options.subpixelPositioning||(m=m.round()),se.setTransform(this._container,`${Qn[o]} translate(${m.x}px,${m.y}px)`),ga(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(je),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(ya);h&&h.focus()}},M.RasterDEMTileSource=Et,M.RasterTileSource=ut,M.ScaleControl=class{constructor(h){this._onMove=()=>{Ls(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ls(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},zr),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},M.ScrollZoomHandler=fr,M.Style=qs,M.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},M.TwoFingersTouchPitchHandler=Xn,M.TwoFingersTouchRotateHandler=vo,M.TwoFingersTouchZoomHandler=yo,M.TwoFingersTouchZoomRotateHandler=wo,M.VectorTileSource=ps,M.VideoSource=En,M.addSourceType=(h,e)=>p._(void 0,void 0,void 0,function*(){if(gs(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{ms[n]=a})(h,e)}),M.clearPrewarmedResources=function(){const h=Yt;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(or),Yt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},M.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},M.getRTLTextPluginStatus=function(){return Ar().getRTLTextPluginStatus()},M.getVersion=function(){return Mo},M.getWorkerCount=function(){return si.workerCount},M.getWorkerUrl=function(){return p.a.WORKER_URL},M.importScriptInWorkers=function(h){return Xr().broadcast("IS",h)},M.prewarm=function(){Ir().acquire(or)},M.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},M.setRTLTextPlugin=function(h,e){return Ar().setRTLTextPlugin(h,e)},M.setWorkerCount=function(h){si.workerCount=h},M.setWorkerUrl=function(h){p.a.WORKER_URL=h}});var ye=G;return ye})}(ec)),ec.exports}var tc=Cf(),Tr=Uint8Array,Oa=Uint16Array,Mf=Int32Array,fd=new Tr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),md=new Tr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kf=new Tr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gd=function(J,j){for(var G=new Oa(31),re=0;re<31;++re)G[re]=j+=1<>1|(Lt&21845)<<1;ds=(ds&52428)>>2|(ds&13107)<<2,ds=(ds&61680)>>4|(ds&3855)<<4,vh[Lt]=((ds&65280)>>8|(ds&255)<<8)>>1}var Wo=function(J,j,G){for(var re=J.length,he=0,ye=new Oa(j);he>Je]=Ge}else for(p=new Oa(re),he=0;he>15-J[he]);return p},Jo=new Tr(288);for(var Lt=0;Lt<144;++Lt)Jo[Lt]=8;for(var Lt=144;Lt<256;++Lt)Jo[Lt]=9;for(var Lt=256;Lt<280;++Lt)Jo[Lt]=7;for(var Lt=280;Lt<288;++Lt)Jo[Lt]=8;var xd=new Tr(32);for(var Lt=0;Lt<32;++Lt)xd[Lt]=5;var Lf=Wo(Jo,9,1),Rf=Wo(xd,5,1),yh=function(J){for(var j=J[0],G=1;Gj&&(j=J[G]);return j},Hr=function(J,j,G){var re=j/8|0;return(J[re]|J[re+1]<<8)>>(j&7)&G},xh=function(J,j){var G=j/8|0;return(J[G]|J[G+1]<<8|J[G+2]<<16)>>(j&7)},Bf=function(J){return(J+7)/8|0},Ff=function(J,j,G){return(G==null||G>J.length)&&(G=J.length),new Tr(J.subarray(j,G))},Of=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wr=function(J,j,G){var re=new Error(j||Of[J]);if(re.code=J,Error.captureStackTrace&&Error.captureStackTrace(re,wr),!G)throw re;return re},wh=function(J,j,G,re){var he=J.length,ye=0;if(!he||j.f&&!j.l)return G||new Tr(0);var M=!G,p=M||j.i!=2,Je=j.i;M&&(G=new Tr(he*3));var Ge=function(Xr){var Ki=G.length;if(Xr>Ki){var lr=new Tr(Math.max(Ki*2,Xr));lr.set(G),G=lr}},He=j.f||0,de=j.p||0,se=j.b||0,Ot=j.l,qt=j.d,kt=j.m,Ii=j.n,Oi=he*8;do{if(!Ot){He=Hr(J,de,1);var Fr=Hr(J,de+1,3);if(de+=3,Fr)if(Fr==1)Ot=Lf,qt=Rf,kt=9,Ii=5;else if(Fr==2){var Pi=Hr(J,de,31)+257,gi=Hr(J,de+10,15)+4,cn=Pi+Hr(J,de+5,31)+1;de+=14;for(var ii=new Tr(cn),Or=new Tr(19),et=0;et>4;if(Mt<16)ii[et++]=Mt;else{var Vi=0,_i=0;for(Mt==16?(_i=3+Hr(J,de,3),de+=2,Vi=ii[et-1]):Mt==17?(_i=3+Hr(J,de,7),de+=3):Mt==18&&(_i=11+Hr(J,de,127),de+=7);_i--;)ii[et++]=Vi}}var un=ii.subarray(0,Pi),ri=ii.subarray(Pi);kt=yh(un),Ii=yh(ri),Ot=Wo(un,kt,1),qt=Wo(ri,Ii,1)}else wr(1);else{var Mt=Bf(de)+4,ln=J[Mt-4]|J[Mt-3]<<8,mi=Mt+ln;if(mi>he){Je&&wr(0);break}p&&Ge(se+ln),G.set(J.subarray(Mt,mi),se),j.b=se+=ln,j.p=de=mi*8,j.f=He;continue}if(de>Oi){Je&&wr(0);break}}p&&Ge(se+131072);for(var ar=(1<>4;if(de+=Vi&15,de>Oi){Je&&wr(0);break}if(Vi||wr(2),Ni<256)G[se++]=Ni;else if(Ni==256){yi=de,Ot=null;break}else{var or=Ni-254;if(Ni>264){var et=Ni-257,si=fd[et];or=Hr(J,de,(1<>4;Sr||wr(3),de+=Sr&15;var ri=Df[Yt];if(Yt>3){var si=md[Yt];ri+=xh(J,de)&(1<Oi){Je&&wr(0);break}p&&Ge(se+131072);var Ai=se+or;if(se>3&1)+(j>>4&1);re>0;re-=!J[G++]);return G+(j&2)},Uf=function(J){var j=J.length;return(J[j-4]|J[j-3]<<8|J[j-2]<<16|J[j-1]<<24)>>>0},jf=function(J,j){return((J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31)&&wr(6,"invalid zlib data"),(J[1]>>5&1)==+!j&&wr(6,"invalid zlib data: "+(J[1]&32?"need":"unexpected")+" dictionary"),(J[1]>>3&4)+2};function $f(J,j){return wh(J,{i:2},j,j)}function qf(J,j){var G=Nf(J);return G+8>J.length&&wr(6,"invalid gzip data"),wh(J.subarray(G,-8),{i:2},new Tr(Uf(J)),j)}function Zf(J,j){return wh(J.subarray(jf(J,j),-4),{i:2},j,j)}function Gf(J,j){return J[0]==31&&J[1]==139&&J[2]==8?qf(J,j):(J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31?$f(J,j):Zf(J,j)}var Hf=typeof TextDecoder<"u"&&new TextDecoder,Xf=0;try{Hf.decode(Vf,{stream:!0}),Xf=1}catch{}var Wf=Object.defineProperty,Ko=Math.pow,At=(J,j)=>Wf(J,"name",{value:j,configurable:!0}),fi=(J,j,G)=>new Promise((re,he)=>{var ye=Je=>{try{p(G.next(Je))}catch(Ge){he(Ge)}},M=Je=>{try{p(G.throw(Je))}catch(Ge){he(Ge)}},p=Je=>Je.done?re(Je.value):Promise.resolve(Je.value).then(ye,M);p((G=G.apply(J,j)).next())});At((J,j)=>{let G=!1,re="",he=L.GridLayer.extend({createTile:At((ye,M)=>{let p=document.createElement("img"),Je=new AbortController,Ge=Je.signal;return p.cancel=()=>{Je.abort()},G||(J.getHeader().then(He=>{He.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):He.tileType===2?re="image/png":He.tileType===3?re="image/jpeg":He.tileType===4?re="image/webp":He.tileType===5&&(re="image/avif")}),G=!0),J.getZxy(ye.z,ye.x,ye.y,Ge).then(He=>{if(He){let de=new Blob([He.data],{type:re}),se=window.URL.createObjectURL(de);p.src=se,p.cancel=void 0,M(void 0,p)}}).catch(He=>{if(He.name!=="AbortError")throw He}),p},"createTile"),_removeTile:At(function(ye){let M=this._tiles[ye];M&&(M.el.cancel&&M.el.cancel(),M.el.width=0,M.el.height=0,M.el.deleted=!0,L.DomUtil.remove(M.el),delete this._tiles[ye],this.fire("tileunload",{tile:M.el,coords:this._keyToTileCoords(ye)}))},"_removeTile")});return new he(j)},"leafletRasterLayer");var Kf=At(J=>(j,G)=>{if(G instanceof AbortController)return J(j,G);let re=new AbortController;return J(j,re).then(he=>G(void 0,he.data,he.cacheControl||"",he.expires||""),he=>G(he)).catch(he=>G(he)),{cancel:At(()=>re.abort(),"cancel")}},"v3compat"),vd=class{constructor(j){this.tilev4=At((G,re)=>fi(this,null,function*(){if(G.type==="json"){let Ot=G.url.substr(10),qt=this.tiles.get(Ot);if(qt||(qt=new dd(Ot),this.tiles.set(Ot,qt)),this.metadata)return{data:yield qt.getTileJson(G.url)};let kt=yield qt.getHeader();return{data:{tiles:[`${G.url}/{z}/{x}/{y}`],minzoom:kt.minZoom,maxzoom:kt.maxZoom,bounds:[kt.minLon,kt.minLat,kt.maxLon,kt.maxLat]}}}let he=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),ye=G.url.match(he);if(!ye)throw new Error("Invalid PMTiles protocol URL");let M=ye[1],p=this.tiles.get(M);p||(p=new dd(M),this.tiles.set(M,p));let Je=ye[2],Ge=ye[3],He=ye[4],de=yield p.getHeader(),se=yield p==null?void 0:p.getZxy(+Je,+Ge,+He,re.signal);return se?{data:new Uint8Array(se.data),cacheControl:se.cacheControl,expires:se.expires}:de.tileType===1?{data:new Uint8Array}:{data:null}}),"tilev4"),this.tile=Kf(this.tilev4),this.tiles=new Map,this.metadata=(j==null?void 0:j.metadata)||!1}add(j){this.tiles.set(j.source.getKey(),j)}get(j){return this.tiles.get(j)}};At(vd,"Protocol");var Jf=vd;function bd(J,j){return(j>>>0)*4294967296+(J>>>0)}At(bd,"toNum");function wd(J,j){let G=j.buf,re=G[j.pos++],he=(re&112)>>4;if(re<128||(re=G[j.pos++],he|=(re&127)<<3,re<128)||(re=G[j.pos++],he|=(re&127)<<10,re<128)||(re=G[j.pos++],he|=(re&127)<<17,re<128)||(re=G[j.pos++],he|=(re&127)<<24,re<128)||(re=G[j.pos++],he|=(re&1)<<31,re<128))return bd(J,he);throw new Error("Expected varint not more than 10 bytes")}At(wd,"readVarintRemainder");function Fa(J){let j=J.buf,G=j[J.pos++],re=G&127;return G<128||(G=j[J.pos++],re|=(G&127)<<7,G<128)||(G=j[J.pos++],re|=(G&127)<<14,G<128)||(G=j[J.pos++],re|=(G&127)<<21,G<128)?re:(G=j[J.pos],re|=(G&15)<<28,wd(re,J))}At(Fa,"readVarint");function Th(J,j,G,re){if(re===0){G===1&&(j[0]=J-1-j[0],j[1]=J-1-j[1]);let he=j[0];j[0]=j[1],j[1]=he}}At(Th,"rotate");function Td(J,j){let G=Ko(2,J),re=j,he=j,ye=j,M=[0,0],p=1;for(;p26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(j>Ko(2,J)-1||G>Ko(2,J)-1)throw Error("tile x/y outside zoom level bounds");let re=Yf[J],he=Ko(2,J),ye=0,M=0,p=0,Je=[j,G],Ge=he/2;for(;Ge>0;)ye=(Je[0]&Ge)>0?1:0,M=(Je[1]&Ge)>0?1:0,p+=Ge*Ge*(3*ye^M),Th(Ge,Je,ye,M),Ge=Ge/2;return re+p}At(Sd,"zxyToTileId");function Qf(J){let j=0;for(let G=0;G<27;G++){let re=(1<J)return Td(G,J-j);j+=re}throw Error("Tile zoom level exceeds max safe number limit (26)")}At(Qf,"tileIdToZxy");var em=(J=>(J[J.Unknown=0]="Unknown",J[J.None=1]="None",J[J.Gzip=2]="Gzip",J[J.Brotli=3]="Brotli",J[J.Zstd=4]="Zstd",J))(em||{});function ic(J,j){return fi(this,null,function*(){if(j===1||j===0)return J;if(j===2){if(typeof globalThis.DecompressionStream>"u")return Gf(new Uint8Array(J));let G=new Response(J).body;if(!G)throw Error("Failed to read response stream");let re=G.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(re).arrayBuffer()}throw Error("Compression method not supported")})}At(ic,"defaultDecompress");var tm=(J=>(J[J.Unknown=0]="Unknown",J[J.Mvt=1]="Mvt",J[J.Png=2]="Png",J[J.Jpeg=3]="Jpeg",J[J.Webp=4]="Webp",J[J.Avif=5]="Avif",J))(tm||{});function Id(J){return J===1?".mvt":J===2?".png":J===3?".jpg":J===4?".webp":J===5?".avif":""}At(Id,"tileTypeExt");var im=127;function Pd(J,j){let G=0,re=J.length-1;for(;G<=re;){let he=re+G>>1,ye=j-J[he].tileId;if(ye>0)G=he+1;else if(ye<0)re=he-1;else return J[he]}return re>=0&&(J[re].runLength===0||j-J[re].tileId-1,ye=/Chrome|Chromium|Edg|OPR|Brave/.test(re);this.chromeWindowsNoCache=!1,he&&ye&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(j){this.customHeaders=j}getBytes(j,G,re,he){return fi(this,null,function*(){let ye,M;re?M=re:(ye=new AbortController,M=ye.signal);let p=new Headers(this.customHeaders);p.set("range",`bytes=${j}-${j+G-1}`);let Je;this.mustReload?Je="reload":this.chromeWindowsNoCache&&(Je="no-store");let Ge=yield fetch(this.url,{signal:M,cache:Je,headers:p});if(j===0&&Ge.status===416){let se=Ge.headers.get("Content-Range");if(!se||!se.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let Ot=+se.substr(8);Ge=yield fetch(this.url,{signal:M,cache:"reload",headers:{range:`bytes=0-${Ot-1}`}})}let He=Ge.headers.get("Etag");if(He!=null&&He.startsWith("W/")&&(He=null),Ge.status===416||he&&He&&He!==he)throw this.mustReload=!0,new bh(`Server returned non-matching ETag ${he} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(Ge.status>=300)throw Error(`Bad response code: ${Ge.status}`);let de=Ge.headers.get("Content-Length");if(Ge.status===200&&(!de||+de>G))throw ye&&ye.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield Ge.arrayBuffer(),etag:He||void 0,cacheControl:Ge.headers.get("Cache-Control")||void 0,expires:Ge.headers.get("Expires")||void 0}})}};At(Ad,"FetchSource");var nm=Ad;function Br(J,j){let G=J.getUint32(j+4,!0),re=J.getUint32(j+0,!0);return G*Ko(2,32)+re}At(Br,"getUint64");function Cd(J,j){let G=new DataView(J),re=G.getUint8(7);if(re>3)throw Error(`Archive is spec version ${re} but this library supports up to spec version 3`);return{specVersion:re,rootDirectoryOffset:Br(G,8),rootDirectoryLength:Br(G,16),jsonMetadataOffset:Br(G,24),jsonMetadataLength:Br(G,32),leafDirectoryOffset:Br(G,40),leafDirectoryLength:Br(G,48),tileDataOffset:Br(G,56),tileDataLength:Br(G,64),numAddressedTiles:Br(G,72),numTileEntries:Br(G,80),numTileContents:Br(G,88),clustered:G.getUint8(96)===1,internalCompression:G.getUint8(97),tileCompression:G.getUint8(98),tileType:G.getUint8(99),minZoom:G.getUint8(100),maxZoom:G.getUint8(101),minLon:G.getInt32(102,!0)/1e7,minLat:G.getInt32(106,!0)/1e7,maxLon:G.getInt32(110,!0)/1e7,maxLat:G.getInt32(114,!0)/1e7,centerZoom:G.getUint8(118),centerLon:G.getInt32(119,!0)/1e7,centerLat:G.getInt32(123,!0)/1e7,etag:j}}At(Cd,"bytesToHeader");function Sh(J){let j={buf:new Uint8Array(J),pos:0},G=Fa(j),re=[],he=0;for(let ye=0;ye0?re[ye].offset=re[ye-1].offset+re[ye-1].length:re[ye].offset=M-1}return re}At(Sh,"deserializeIndex");var Md=class extends Error{};At(Md,"EtagMismatch");var bh=Md;function Ih(J,j){return fi(this,null,function*(){let G=yield J.getBytes(0,16384);if(new DataView(G.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let re=G.data.slice(0,im),he=Cd(re,G.etag),ye=G.data.slice(he.rootDirectoryOffset,he.rootDirectoryOffset+he.rootDirectoryLength),M=`${J.getKey()}|${he.etag||""}|${he.rootDirectoryOffset}|${he.rootDirectoryLength}`,p=Sh(yield j(ye,he.internalCompression));return[he,[M,p.length,p]]})}At(Ih,"getHeaderAndRoot");function Ph(J,j,G,re,he){return fi(this,null,function*(){let ye=yield J.getBytes(G,re,void 0,he.etag),M=yield j(ye.data,he.internalCompression),p=Sh(M);if(p.length===0)throw new Error("Empty directory is invalid");return p})}At(Ph,"getDirectory");var sm=class{constructor(j=100,G=!0,re=ic){this.cache=new Map,this.maxCacheEntries=j,this.counter=1,this.decompress=re}getHeader(j){return fi(this,null,function*(){let G=j.getKey(),re=this.cache.get(G);if(re)return re.lastUsed=this.counter++,re.data;let he=yield Ih(j,this.decompress);return he[1]&&this.cache.set(he[1][0],{lastUsed:this.counter++,data:he[1][2]}),this.cache.set(G,{lastUsed:this.counter++,data:he[0]}),this.prune(),he[0]})}getDirectory(j,G,re,he){return fi(this,null,function*(){let ye=`${j.getKey()}|${he.etag||""}|${G}|${re}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,M.data;let p=yield Ph(j,this.decompress,G,re,he);return this.cache.set(ye,{lastUsed:this.counter++,data:p}),this.prune(),p})}prune(){if(this.cache.size>this.maxCacheEntries){let j=1/0,G;this.cache.forEach((re,he)=>{re.lastUsed{Ih(j,this.decompress).then(p=>{p[1]&&this.cache.set(p[1][0],{lastUsed:this.counter++,data:Promise.resolve(p[1][2])}),ye(p[0]),this.prune()}).catch(p=>{M(p)})});return this.cache.set(G,{lastUsed:this.counter++,data:he}),he})}getDirectory(j,G,re,he){return fi(this,null,function*(){let ye=`${j.getKey()}|${he.etag||""}|${G}|${re}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,yield M.data;let p=new Promise((Je,Ge)=>{Ph(j,this.decompress,G,re,he).then(He=>{Je(He),this.prune()}).catch(He=>{Ge(He)})});return this.cache.set(ye,{lastUsed:this.counter++,data:p}),p})}prune(){if(this.cache.size>=this.maxCacheEntries){let j=1/0,G;this.cache.forEach((re,he)=>{re.lastUsed{this.getHeader(j).then(M=>{he(),this.invalidations.delete(G)}).catch(M=>{ye(M)})});this.invalidations.set(G,re)})}};At(kd,"SharedPromiseCache");var am=kd,Ed=class{constructor(j,G,re){typeof j=="string"?this.source=new nm(j):this.source=j,re?this.decompress=re:this.decompress=ic,G?this.cache=G:this.cache=new am}getHeader(){return fi(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(j,G,re,he){return fi(this,null,function*(){let ye=Sd(j,G,re),M=yield this.cache.getHeader(this.source);if(jM.maxZoom)return;let p=M.rootDirectoryOffset,Je=M.rootDirectoryLength;for(let Ge=0;Ge<=3;Ge++){let He=yield this.cache.getDirectory(this.source,p,Je,M),de=Pd(He,ye);if(de){if(de.runLength>0){let se=yield this.source.getBytes(M.tileDataOffset+de.offset,de.length,he,M.etag);return{data:yield this.decompress(se.data,M.tileCompression),cacheControl:se.cacheControl,expires:se.expires}}p=M.leafDirectoryOffset+de.offset,Je=de.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(j,G,re,he){return fi(this,null,function*(){try{return yield this.getZxyAttempt(j,G,re,he)}catch(ye){if(ye instanceof bh)return this.cache.invalidate(this.source),yield this.getZxyAttempt(j,G,re,he);throw ye}})}getMetadataAttempt(){return fi(this,null,function*(){let j=yield this.cache.getHeader(this.source),G=yield this.source.getBytes(j.jsonMetadataOffset,j.jsonMetadataLength,void 0,j.etag),re=yield this.decompress(G.data,j.internalCompression),he=new TextDecoder("utf-8");return JSON.parse(he.decode(re))})}getMetadata(){return fi(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(j){if(j instanceof bh)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw j}})}getTileJson(j){return fi(this,null,function*(){let G=yield this.getHeader(),re=yield this.getMetadata(),he=Id(G.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${j}/{z}/{x}/{y}${he}`],vector_layers:re.vector_layers,attribution:re.attribution,description:re.description,name:re.name,version:re.version,bounds:[G.minLon,G.minLat,G.maxLon,G.maxLat],center:[G.centerLon,G.centerLat,G.centerZoom],minzoom:G.minZoom,maxzoom:G.maxZoom}})}};At(Ed,"PMTiles");var dd=Ed;const om=["click"];class lm{constructor(j,G=!0){Fi(this,"button");Fi(this,"clickCallback");this.button=this.createButton();const re=document.createElement("div");re.classList.add("maplibregl-ctrl","maplibregl-ctrl-group"),re.appendChild(this.button),G||(re.style.display="none"),j.appendChild(re)}on(j,G){if(!om.includes(j))throw new Error(`Event type ${j} is not supported.`);switch(j){case"click":this.clickCallback=G;break}}turnOn(){this.button.classList.add("maplibregl-ctrl-compass-heading-active"),this.startLoading()}turnOff(){this.button.classList.remove("maplibregl-ctrl-compass-heading-active"),this.stopLoading()}disable(){this.button.setAttribute("disabled","disabled")}startLoading(){this.button.classList.add("maplibregl-ctrl-compass-heading-waiting")}stopLoading(){this.button.classList.remove("maplibregl-ctrl-compass-heading-waiting")}createButton(){const j=document.createElement("button");j.classList.add("maplibregl-ctrl-compass-heading"),j.addEventListener("click",()=>{this.clickCallback&&this.clickCallback()});const G=document.createElement("span");return G.classList.add("maplibregl-ctrl-icon"),j.appendChild(G),j}}class cm{constructor(j){Fi(this,"element");this.element=document.createElement("div"),this.element.classList.add("maplibregl-ctrl"),this.element.innerHTML=` +`),F=_.createShader(_.FRAGMENT_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(F,Z),_.compileShader(F),!_.getShaderParameter(F,_.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${_.getShaderInfoLog(F)}`);_.attachShader(this.program,F);const Y=_.createShader(_.VERTEX_SHADER);if(_.isContextLost())return void(this.failedToCreate=!0);if(_.shaderSource(Y,X),_.compileShader(Y),!_.getShaderParameter(Y,_.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${_.getShaderInfoLog(Y)}`);_.attachShader(this.program,Y),this.attributes={};const ee={};this.numAttributes=T.length;for(let ae=0;ae({u_depth:new p.aH(ae,fe.u_depth),u_terrain:new p.aH(ae,fe.u_terrain),u_terrain_dim:new p.aI(ae,fe.u_terrain_dim),u_terrain_matrix:new p.aJ(ae,fe.u_terrain_matrix),u_terrain_unpack:new p.aK(ae,fe.u_terrain_unpack),u_terrain_exaggeration:new p.aI(ae,fe.u_terrain_exaggeration)}))(e,ee),this.binderUniforms=a?a.getUniforms(e,ee):[]}draw(e,n,a,o,c,m,_,y,b,T,S,k,D,B,N,q,Z,X){const F=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(a),e.setStencilMode(o),e.setColorMode(c),e.setCullFace(m),y){e.activeTexture.set(F.TEXTURE2),F.bindTexture(F.TEXTURE_2D,y.depthTexture),e.activeTexture.set(F.TEXTURE3),F.bindTexture(F.TEXTURE_2D,y.texture);for(const ee in this.terrainUniforms)this.terrainUniforms[ee].set(y[ee])}for(const ee in this.fixedUniforms)this.fixedUniforms[ee].set(_[ee]);N&&N.setUniforms(e,this.binderUniforms,D,{zoom:B});let Y=0;switch(n){case F.LINES:Y=2;break;case F.TRIANGLES:Y=3;break;case F.LINE_STRIP:Y=1}for(const ee of k.get()){const ae=ee.vaos||(ee.vaos={});(ae[b]||(ae[b]=new $a)).bind(e,this,T,N?N.getPaintVertexBuffers():[],S,ee.vertexOffset,q,Z,X),F.drawElements(n,ee.primitiveLength*Y,F.UNSIGNED_SHORT,ee.primitiveOffset*Y*2)}}}function Zs(h,e,n){const a=1/rt(n,1,e.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,e.transform.tileZoom)/o,m=c*(n.tileID.canonical.x+n.tileID.wrap*o),_=c*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[a,h.fromScale,h.toScale],u_fade:h.t,u_pixel_coord_upper:[m>>16,_>>16],u_pixel_coord_lower:[65535&m,65535&_]}}const ys=(h,e,n,a)=>{const o=e.style.light,c=o.properties.get("position"),m=[c.x,c.y,c.z],_=function(){var b=new p.A(9);return p.A!=Float32Array&&(b[1]=0,b[2]=0,b[3]=0,b[5]=0,b[6]=0,b[7]=0),b[0]=1,b[4]=1,b[8]=1,b}();o.properties.get("anchor")==="viewport"&&function(b,T){var S=Math.sin(T),k=Math.cos(T);b[0]=k,b[1]=S,b[2]=0,b[3]=-S,b[4]=k,b[5]=0,b[6]=0,b[7]=0,b[8]=1}(_,-e.transform.angle),function(b,T,S){var k=T[0],D=T[1],B=T[2];b[0]=k*S[0]+D*S[3]+B*S[6],b[1]=k*S[1]+D*S[4]+B*S[7],b[2]=k*S[2]+D*S[5]+B*S[8]}(m,m,_);const y=o.properties.get("color");return{u_matrix:h,u_lightpos:m,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[y.r,y.g,y.b],u_vertical_gradient:+n,u_opacity:a}},Gs=(h,e,n,a,o,c,m)=>p.e(ys(h,e,n,a),Zs(c,e,m),{u_height_factor:-Math.pow(2,o.overscaledZ)/m.tileSize/8}),Rn=h=>({u_matrix:h}),Yo=(h,e,n,a)=>p.e(Rn(h),Zs(n,e,a)),sc=(h,e)=>({u_matrix:h,u_world:e}),Qo=(h,e,n,a,o)=>p.e(Yo(h,e,n,a),{u_world:o}),ac=(h,e,n,a)=>{const o=h.transform;let c,m;if(a.paint.get("circle-pitch-alignment")==="map"){const _=rt(n,1,o.zoom);c=!0,m=[_,_]}else c=!1,m=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(a.paint.get("circle-pitch-scale")==="map"),u_matrix:h.translatePosMatrix(e.posMatrix,n,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_pitch_with_map:+c,u_device_pixel_ratio:h.pixelRatio,u_extrude_scale:m}},mn=(h,e,n)=>({u_matrix:h,u_inv_matrix:e,u_camera_to_center_distance:n.cameraToCenterDistance,u_viewport_size:[n.width,n.height]}),xs=(h,e,n=1)=>({u_matrix:h,u_color:e,u_overlay:0,u_overlay_scale:n}),Mi=h=>({u_matrix:h}),ki=(h,e,n,a)=>({u_matrix:h,u_extrude_scale:rt(e,1,n),u_intensity:a}),Hs=(h,e,n,a)=>{const o=p.H();p.aP(o,0,h.width,h.height,0,0,1);const c=h.context.gl;return{u_matrix:o,u_world:[c.drawingBufferWidth,c.drawingBufferHeight],u_image:n,u_color_ramp:a,u_opacity:e.paint.get("heatmap-opacity")}};function Xs(h,e){const n=Math.pow(2,e.canonical.z),a=e.canonical.y;return[new p.Z(0,a/n).toLngLat().lat,new p.Z(0,(a+1)/n).toLngLat().lat]}const Ws=(h,e,n,a)=>{const o=h.transform;return{u_matrix:il(h,e,n,a),u_ratio:1/rt(e,1,o.zoom),u_device_pixel_ratio:h.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},el=(h,e,n,a,o)=>p.e(Ws(h,e,n,o),{u_image:0,u_image_height:a}),Bn=(h,e,n,a,o)=>{const c=h.transform,m=tl(e,c);return{u_matrix:il(h,e,n,o),u_texsize:e.imageAtlasTexture.size,u_ratio:1/rt(e,1,c.zoom),u_device_pixel_ratio:h.pixelRatio,u_image:0,u_scale:[m,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/c.pixelsToGLUnits[0],1/c.pixelsToGLUnits[1]]}},oc=(h,e,n,a,o,c)=>{const m=h.lineAtlas,_=tl(e,h.transform),y=n.layout.get("line-cap")==="round",b=m.getDash(a.from,y),T=m.getDash(a.to,y),S=b.width*o.fromScale,k=T.width*o.toScale;return p.e(Ws(h,e,n,c),{u_patternscale_a:[_/S,-b.height/2],u_patternscale_b:[_/k,-T.height/2],u_sdfgamma:m.width/(256*Math.min(S,k)*h.pixelRatio)/2,u_image:0,u_tex_y_a:b.y,u_tex_y_b:T.y,u_mix:o.t})};function tl(h,e){return 1/rt(h,1,e.tileZoom)}function il(h,e,n,a){return h.translatePosMatrix(a?a.posMatrix:e.tileID.posMatrix,e,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const lc=(h,e,n,a,o)=>{return{u_matrix:h,u_tl_parent:e,u_scale_parent:n,u_buffer_scale:1,u_fade_t:a.mix,u_opacity:a.opacity*o.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:o.paint.get("raster-brightness-min"),u_brightness_high:o.paint.get("raster-brightness-max"),u_saturation_factor:(m=o.paint.get("raster-saturation"),m>0?1-1/(1.001-m):-m),u_contrast_factor:(c=o.paint.get("raster-contrast"),c>0?1/(1-c):1+c),u_spin_weights:cc(o.paint.get("raster-hue-rotate"))};var c,m};function cc(h){h*=Math.PI/180;const e=Math.sin(h),n=Math.cos(h);return[(2*n+1)/3,(-Math.sqrt(3)*e-n+1)/3,(Math.sqrt(3)*e-n+1)/3]}const rl=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>{const B=m.transform;return{u_is_size_zoom_constant:+(h==="constant"||h==="source"),u_is_size_feature_constant:+(h==="constant"||h==="camera"),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:B.cameraToCenterDistance,u_pitch:B.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:B.width/B.height,u_fade_change:m.options.fadeDuration?m.symbolFadeChange:1,u_matrix:_,u_label_plane_matrix:y,u_coord_matrix:b,u_is_text:+S,u_pitch_with_map:+a,u_is_along_line:o,u_is_variable_anchor:c,u_texsize:k,u_texture:0,u_translation:T,u_pitched_scale:D}},vs=(h,e,n,a,o,c,m,_,y,b,T,S,k,D,B)=>{const N=m.transform;return p.e(rl(h,e,n,a,o,c,m,_,y,b,T,S,k,B),{u_gamma_scale:a?Math.cos(N._pitch)*N.cameraToCenterDistance:1,u_device_pixel_ratio:m.pixelRatio,u_is_halo:+D})},Ga=(h,e,n,a,o,c,m,_,y,b,T,S,k,D)=>p.e(vs(h,e,n,a,o,c,m,_,y,b,T,!0,S,!0,D),{u_texsize_icon:k,u_texture_icon:1}),Ks=(h,e,n)=>({u_matrix:h,u_opacity:e,u_color:n}),Ha=(h,e,n,a,o,c)=>p.e(function(m,_,y,b){const T=y.imageManager.getPattern(m.from.toString()),S=y.imageManager.getPattern(m.to.toString()),{width:k,height:D}=y.imageManager.getPixelSize(),B=Math.pow(2,b.tileID.overscaledZ),N=b.tileSize*Math.pow(2,y.transform.tileZoom)/B,q=N*(b.tileID.canonical.x+b.tileID.wrap*B),Z=N*b.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:T.tl,u_pattern_br_a:T.br,u_pattern_tl_b:S.tl,u_pattern_br_b:S.br,u_texsize:[k,D],u_mix:_.t,u_pattern_size_a:T.displaySize,u_pattern_size_b:S.displaySize,u_scale_a:_.fromScale,u_scale_b:_.toScale,u_tile_units_to_pixels:1/rt(b,1,y.transform.tileZoom),u_pixel_coord_upper:[q>>16,Z>>16],u_pixel_coord_lower:[65535&q,65535&Z]}}(a,c,n,o),{u_matrix:h,u_opacity:e}),Xa={fillExtrusion:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_opacity:new p.aI(h,e.u_opacity)}),fillExtrusionPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_lightpos:new p.aN(h,e.u_lightpos),u_lightintensity:new p.aI(h,e.u_lightintensity),u_lightcolor:new p.aN(h,e.u_lightcolor),u_vertical_gradient:new p.aI(h,e.u_vertical_gradient),u_height_factor:new p.aI(h,e.u_height_factor),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade),u_opacity:new p.aI(h,e.u_opacity)}),fill:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),fillPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),fillOutline:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world)}),fillOutlinePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_texsize:new p.aO(h,e.u_texsize),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),circle:(h,e)=>({u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_scale_with_map:new p.aH(h,e.u_scale_with_map),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_extrude_scale:new p.aO(h,e.u_extrude_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_matrix:new p.aJ(h,e.u_matrix)}),collisionBox:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_pixel_extrude_scale:new p.aO(h,e.u_pixel_extrude_scale)}),collisionCircle:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_inv_matrix:new p.aJ(h,e.u_inv_matrix),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_viewport_size:new p.aO(h,e.u_viewport_size)}),debug:(h,e)=>({u_color:new p.aL(h,e.u_color),u_matrix:new p.aJ(h,e.u_matrix),u_overlay:new p.aH(h,e.u_overlay),u_overlay_scale:new p.aI(h,e.u_overlay_scale)}),clippingMask:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix)}),heatmap:(h,e)=>({u_extrude_scale:new p.aI(h,e.u_extrude_scale),u_intensity:new p.aI(h,e.u_intensity),u_matrix:new p.aJ(h,e.u_matrix)}),heatmapTexture:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_world:new p.aO(h,e.u_world),u_image:new p.aH(h,e.u_image),u_color_ramp:new p.aH(h,e.u_color_ramp),u_opacity:new p.aI(h,e.u_opacity)}),hillshade:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_latrange:new p.aO(h,e.u_latrange),u_light:new p.aO(h,e.u_light),u_shadow:new p.aL(h,e.u_shadow),u_highlight:new p.aL(h,e.u_highlight),u_accent:new p.aL(h,e.u_accent)}),hillshadePrepare:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_image:new p.aH(h,e.u_image),u_dimension:new p.aO(h,e.u_dimension),u_zoom:new p.aI(h,e.u_zoom),u_unpack:new p.aK(h,e.u_unpack)}),line:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels)}),lineGradient:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_image:new p.aH(h,e.u_image),u_image_height:new p.aI(h,e.u_image_height)}),linePattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texsize:new p.aO(h,e.u_texsize),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_image:new p.aH(h,e.u_image),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_scale:new p.aN(h,e.u_scale),u_fade:new p.aI(h,e.u_fade)}),lineSDF:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ratio:new p.aI(h,e.u_ratio),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_units_to_pixels:new p.aO(h,e.u_units_to_pixels),u_patternscale_a:new p.aO(h,e.u_patternscale_a),u_patternscale_b:new p.aO(h,e.u_patternscale_b),u_sdfgamma:new p.aI(h,e.u_sdfgamma),u_image:new p.aH(h,e.u_image),u_tex_y_a:new p.aI(h,e.u_tex_y_a),u_tex_y_b:new p.aI(h,e.u_tex_y_b),u_mix:new p.aI(h,e.u_mix)}),raster:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_tl_parent:new p.aO(h,e.u_tl_parent),u_scale_parent:new p.aI(h,e.u_scale_parent),u_buffer_scale:new p.aI(h,e.u_buffer_scale),u_fade_t:new p.aI(h,e.u_fade_t),u_opacity:new p.aI(h,e.u_opacity),u_image0:new p.aH(h,e.u_image0),u_image1:new p.aH(h,e.u_image1),u_brightness_low:new p.aI(h,e.u_brightness_low),u_brightness_high:new p.aI(h,e.u_brightness_high),u_saturation_factor:new p.aI(h,e.u_saturation_factor),u_contrast_factor:new p.aI(h,e.u_contrast_factor),u_spin_weights:new p.aN(h,e.u_spin_weights)}),symbolIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolSDF:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texture:new p.aH(h,e.u_texture),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),symbolTextAndIcon:(h,e)=>({u_is_size_zoom_constant:new p.aH(h,e.u_is_size_zoom_constant),u_is_size_feature_constant:new p.aH(h,e.u_is_size_feature_constant),u_size_t:new p.aI(h,e.u_size_t),u_size:new p.aI(h,e.u_size),u_camera_to_center_distance:new p.aI(h,e.u_camera_to_center_distance),u_pitch:new p.aI(h,e.u_pitch),u_rotate_symbol:new p.aH(h,e.u_rotate_symbol),u_aspect_ratio:new p.aI(h,e.u_aspect_ratio),u_fade_change:new p.aI(h,e.u_fade_change),u_matrix:new p.aJ(h,e.u_matrix),u_label_plane_matrix:new p.aJ(h,e.u_label_plane_matrix),u_coord_matrix:new p.aJ(h,e.u_coord_matrix),u_is_text:new p.aH(h,e.u_is_text),u_pitch_with_map:new p.aH(h,e.u_pitch_with_map),u_is_along_line:new p.aH(h,e.u_is_along_line),u_is_variable_anchor:new p.aH(h,e.u_is_variable_anchor),u_texsize:new p.aO(h,e.u_texsize),u_texsize_icon:new p.aO(h,e.u_texsize_icon),u_texture:new p.aH(h,e.u_texture),u_texture_icon:new p.aH(h,e.u_texture_icon),u_gamma_scale:new p.aI(h,e.u_gamma_scale),u_device_pixel_ratio:new p.aI(h,e.u_device_pixel_ratio),u_is_halo:new p.aH(h,e.u_is_halo),u_translation:new p.aO(h,e.u_translation),u_pitched_scale:new p.aI(h,e.u_pitched_scale)}),background:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_color:new p.aL(h,e.u_color)}),backgroundPattern:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_opacity:new p.aI(h,e.u_opacity),u_image:new p.aH(h,e.u_image),u_pattern_tl_a:new p.aO(h,e.u_pattern_tl_a),u_pattern_br_a:new p.aO(h,e.u_pattern_br_a),u_pattern_tl_b:new p.aO(h,e.u_pattern_tl_b),u_pattern_br_b:new p.aO(h,e.u_pattern_br_b),u_texsize:new p.aO(h,e.u_texsize),u_mix:new p.aI(h,e.u_mix),u_pattern_size_a:new p.aO(h,e.u_pattern_size_a),u_pattern_size_b:new p.aO(h,e.u_pattern_size_b),u_scale_a:new p.aI(h,e.u_scale_a),u_scale_b:new p.aI(h,e.u_scale_b),u_pixel_coord_upper:new p.aO(h,e.u_pixel_coord_upper),u_pixel_coord_lower:new p.aO(h,e.u_pixel_coord_lower),u_tile_units_to_pixels:new p.aI(h,e.u_tile_units_to_pixels)}),terrain:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_ele_delta:new p.aI(h,e.u_ele_delta),u_fog_matrix:new p.aJ(h,e.u_fog_matrix),u_fog_color:new p.aL(h,e.u_fog_color),u_fog_ground_blend:new p.aI(h,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new p.aI(h,e.u_fog_ground_blend_opacity),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon_fog_blend:new p.aI(h,e.u_horizon_fog_blend)}),terrainDepth:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_ele_delta:new p.aI(h,e.u_ele_delta)}),terrainCoords:(h,e)=>({u_matrix:new p.aJ(h,e.u_matrix),u_texture:new p.aH(h,e.u_texture),u_terrain_coords_id:new p.aI(h,e.u_terrain_coords_id),u_ele_delta:new p.aI(h,e.u_ele_delta)}),sky:(h,e)=>({u_sky_color:new p.aL(h,e.u_sky_color),u_horizon_color:new p.aL(h,e.u_horizon_color),u_horizon:new p.aI(h,e.u_horizon),u_sky_horizon_blend:new p.aI(h,e.u_sky_horizon_blend)})};class kr{constructor(e,n,a){this.context=e;const o=e.gl;this.buffer=o.createBuffer(),this.dynamicDraw=!!a,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?o.DYNAMIC_DRAW:o.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const hc={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Wa{constructor(e,n,a,o){this.length=n.length,this.attributes=a,this.itemSize=n.bytesPerElement,this.dynamicDraw=o,this.context=e;const c=e.gl;this.buffer=c.createBuffer(),e.bindVertexBuffer.set(this.buffer),c.bufferData(c.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?c.DYNAMIC_DRAW:c.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,n){for(let a=0;a0){const ae=p.H();p.aQ(ae,F.placementInvProjMatrix,h.transform.glCoordMatrix),p.aQ(ae,ae,F.placementViewportMatrix),y.push({circleArray:ee,circleOffset:T,transform:X.posMatrix,invTransform:ae,coord:X}),b+=ee.length/4,T=b}Y&&_.draw(c,m.LINES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,{u_matrix:X.posMatrix,u_pixel_extrude_scale:[1/(S=h.transform).width,1/S.height]},h.style.map.terrain&&h.style.map.terrain.getTerrainData(X),n.id,Y.layoutVertexBuffer,Y.indexBuffer,Y.segments,null,h.transform.zoom,null,null,Y.collisionVertexBuffer)}var S;if(!o||!y.length)return;const k=h.useProgram("collisionCircle"),D=new p.aR;D.resize(4*b),D._trim();let B=0;for(const Z of y)for(let X=0;X=0&&(Z[F.associatedIconIndex]={shiftedAnchor:qe,angle:Tt})}else Ne(F.numGlyphs,N)}if(b){q.clear();const X=h.icon.placedSymbolArray;for(let F=0;Fh.style.map.terrain.getElevation(we,is,rs):null,In=n.layout.get("text-rotation-alignment")==="map";R(Re,we.posMatrix,h,o,es,ts,Z,b,In,N,we.toUnwrapped(),B.width,B.height,ir,at)}const rr=we.posMatrix,nr=o&&_e||ko,tn=X||nr?Ts:es,gr=va,ei=Ce&&n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let ci;ci=Ce?Re.iconsInText?Ga(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,oi,bi,ke):vs(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,!0,ke):rl(qe.kind,nt,F,Z,X,nr,h,rr,tn,gr,ir,o,oi,ke);const Gi={program:Ye,buffers:Xe,uniformValues:ci,atlasTexture:mr,atlasTextureIcon:li,atlasInterpolation:It,atlasInterpolationIcon:Ei,isSDF:Ce,hasHalo:ei};if(ee&&Re.canOverlap){ae=!0;const at=Xe.segments.get();for(const In of at)Pe.push({segments:new p.a0([In]),sortKey:In.sortKey,state:Gi,terrainData:St})}else Pe.push({segments:Xe.segments,sortKey:0,state:Gi,terrainData:St})}ae&&Pe.sort((we,be)=>we.sortKey-be.sortKey);for(const we of Pe){const be=we.state;if(k.activeTexture.set(D.TEXTURE0),be.atlasTexture.bind(be.atlasInterpolation,D.CLAMP_TO_EDGE),be.atlasTextureIcon&&(k.activeTexture.set(D.TEXTURE1),be.atlasTextureIcon&&be.atlasTextureIcon.bind(be.atlasInterpolationIcon,D.CLAMP_TO_EDGE)),be.isSDF){const Re=be.uniformValues;be.hasHalo&&(Re.u_is_halo=1,so(be.buffers,we.segments,n,h,be.program,fe,T,S,Re,we.terrainData)),Re.u_is_halo=0}so(be.buffers,we.segments,n,h,be.program,fe,T,S,be.uniformValues,we.terrainData)}}function so(h,e,n,a,o,c,m,_,y,b){const T=a.context;o.draw(T,T.gl.TRIANGLES,c,m,_,gt.disabled,y,b,n.id,h.layoutVertexBuffer,h.indexBuffer,e,n.paint,a.transform.zoom,h.programConfigurations.get(n.id),h.dynamicLayoutVertexBuffer,h.opacityVertexBuffer)}function ao(h,e,n,a){const o=h.context,c=o.gl,m=vt.disabled,_=new Rt([c.ONE,c.ONE],p.aM.transparent,[!0,!0,!0,!0]),y=e.getBucket(n);if(!y)return;const b=a.key;let T=n.heatmapFbos.get(b);T||(T=Ss(o,e.tileSize,e.tileSize),n.heatmapFbos.set(b,T)),o.bindFramebuffer.set(T.framebuffer),o.viewport.set([0,0,e.tileSize,e.tileSize]),o.clear({color:p.aM.transparent});const S=y.programConfigurations.get(n.id),k=h.useProgram("heatmap",S),D=h.style.map.terrain.getTerrainData(a);k.draw(o,c.TRIANGLES,it.disabled,m,_,gt.disabled,ki(a.posMatrix,e,h.transform.zoom,n.paint.get("heatmap-intensity")),D,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,h.transform.zoom,S)}function bn(h,e,n){const a=h.context,o=a.gl;a.setColorMode(h.colorModeForRenderPass());const c=Is(a,e),m=n.key,_=e.heatmapFbos.get(m);_&&(a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,_.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE),h.useProgram("heatmapTexture").draw(a,o.TRIANGLES,it.disabled,vt.disabled,h.colorModeForRenderPass(),gt.disabled,Hs(h,e,0,1),null,e.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments,e.paint,h.transform.zoom),_.destroy(),e.heatmapFbos.delete(m))}function Ss(h,e,n){var a,o;const c=h.gl,m=c.createTexture();c.bindTexture(c.TEXTURE_2D,m),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.LINEAR);const _=(a=h.HALF_FLOAT)!==null&&a!==void 0?a:c.UNSIGNED_BYTE,y=(o=h.RGBA16F)!==null&&o!==void 0?o:c.RGBA;c.texImage2D(c.TEXTURE_2D,0,y,e,n,0,c.RGBA,_,null);const b=h.createFramebuffer(e,n,!1,!1);return b.colorAttachment.set(m),b}function Is(h,e){return e.colorRampTexture||(e.colorRampTexture=new et(h,e.colorRamp,h.gl.RGBA)),e.colorRampTexture}function Vn(h,e,n,a,o){if(!n||!a||!a.imageAtlas)return;const c=a.imageAtlas.patternPositions;let m=c[n.to.toString()],_=c[n.from.toString()];if(!m&&_&&(m=_),!_&&m&&(_=m),!m||!_){const y=o.getPaintProperty(e);m=c[y],_=c[y]}m&&_&&h.setConstantPatternPositions(m,_)}function Ps(h,e,n,a,o,c,m){const _=h.context.gl,y="fill-pattern",b=n.paint.get(y),T=b&&b.constantOr(1),S=n.getCrossfadeParameters();let k,D,B,N,q;m?(D=T&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",k=_.LINES):(D=T?"fillPattern":"fill",k=_.TRIANGLES);const Z=b.constantOr(null);for(const X of a){const F=e.getTile(X);if(T&&!F.patternsLoaded())continue;const Y=F.getBucket(n);if(!Y)continue;const ee=Y.programConfigurations.get(n.id),ae=h.useProgram(D,ee),fe=h.style.map.terrain&&h.style.map.terrain.getTerrainData(X);T&&(h.context.activeTexture.set(_.TEXTURE0),F.imageAtlasTexture.bind(_.LINEAR,_.CLAMP_TO_EDGE),ee.updatePaintBuffers(S)),Vn(ee,y,Z,F,n);const _e=fe?X:null,Pe=h.translatePosMatrix(_e?_e.posMatrix:X.posMatrix,F,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(m){N=Y.indexBuffer2,q=Y.segments2;const ke=[_.drawingBufferWidth,_.drawingBufferHeight];B=D==="fillOutlinePattern"&&T?Qo(Pe,h,S,F,ke):sc(Pe,ke)}else N=Y.indexBuffer,q=Y.segments,B=T?Yo(Pe,h,S,F):Rn(Pe);ae.draw(h.context,k,o,h.stencilModeForClipping(X),c,gt.disabled,B,fe,n.id,Y.layoutVertexBuffer,N,q,n.paint,h.transform.zoom,ee)}}function ia(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b="fill-extrusion-pattern",T=n.paint.get(b),S=T.constantOr(1),k=n.getCrossfadeParameters(),D=n.paint.get("fill-extrusion-opacity"),B=T.constantOr(null);for(const N of a){const q=e.getTile(N),Z=q.getBucket(n);if(!Z)continue;const X=h.style.map.terrain&&h.style.map.terrain.getTerrainData(N),F=Z.programConfigurations.get(n.id),Y=h.useProgram(S?"fillExtrusionPattern":"fillExtrusion",F);S&&(h.context.activeTexture.set(y.TEXTURE0),q.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),F.updatePaintBuffers(k)),Vn(F,b,B,q,n);const ee=h.translatePosMatrix(N.posMatrix,q,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ae=n.paint.get("fill-extrusion-vertical-gradient"),fe=S?Gs(ee,h,ae,D,N,k,q):ys(ee,h,ae,D);Y.draw(_,_.gl.TRIANGLES,o,c,m,gt.backCCW,fe,X,n.id,Z.layoutVertexBuffer,Z.indexBuffer,Z.segments,n.paint,h.transform.zoom,F,h.style.map.terrain&&Z.centroidVertexBuffer)}}function Nn(h,e,n,a,o,c,m){const _=h.context,y=_.gl,b=n.fbo;if(!b)return;const T=h.useProgram("hillshade"),S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(e);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,b.colorAttachment.get()),T.draw(_,y.TRIANGLES,o,c,m,gt.disabled,((k,D,B,N)=>{const q=B.paint.get("hillshade-shadow-color"),Z=B.paint.get("hillshade-highlight-color"),X=B.paint.get("hillshade-accent-color");let F=B.paint.get("hillshade-illumination-direction")*(Math.PI/180);B.paint.get("hillshade-illumination-anchor")==="viewport"&&(F-=k.transform.angle);const Y=!k.options.moving;return{u_matrix:N?N.posMatrix:k.transform.calculatePosMatrix(D.tileID.toUnwrapped(),Y),u_image:0,u_latrange:Xs(0,D.tileID),u_light:[B.paint.get("hillshade-exaggeration"),F],u_shadow:q,u_highlight:Z,u_accent:X}})(h,n,a,S?e:null),S,a.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments)}function Un(h,e,n,a,o,c){const m=h.context,_=m.gl,y=e.dem;if(y&&y.data){const b=y.dim,T=y.stride,S=y.getPixels();if(m.activeTexture.set(_.TEXTURE1),m.pixelStoreUnpackPremultiplyAlpha.set(!1),e.demTexture=e.demTexture||h.getTileTexture(T),e.demTexture){const D=e.demTexture;D.update(S,{premultiply:!1}),D.bind(_.NEAREST,_.CLAMP_TO_EDGE)}else e.demTexture=new et(m,S,_.RGBA,{premultiply:!1}),e.demTexture.bind(_.NEAREST,_.CLAMP_TO_EDGE);m.activeTexture.set(_.TEXTURE0);let k=e.fbo;if(!k){const D=new et(m,{width:b,height:b,data:null},_.RGBA);D.bind(_.LINEAR,_.CLAMP_TO_EDGE),k=e.fbo=m.createFramebuffer(b,b,!0,!1),k.colorAttachment.set(D.texture)}m.bindFramebuffer.set(k.framebuffer),m.viewport.set([0,0,b,b]),h.useProgram("hillshadePrepare").draw(m,_.TRIANGLES,a,o,c,gt.disabled,((D,B)=>{const N=B.stride,q=p.H();return p.aP(q,0,p.X,-p.X,0,0,1),p.J(q,q,[0,-p.X,0]),{u_matrix:q,u_image:1,u_dimension:[N,N],u_zoom:D.overscaledZ,u_unpack:B.getUnpackVector()}})(e.tileID,y),null,n.id,h.rasterBoundsBuffer,h.quadTriangleIndexBuffer,h.rasterBoundsSegments),e.needsHillshadePrepare=!1}}function gl(h,e,n,a,o,c){const m=a.paint.get("raster-fade-duration");if(!c&&m>0){const _=de.now(),y=(_-h.timeAdded)/m,b=e?(_-e.timeAdded)/m:-1,T=n.getSource(),S=o.coveringZoomLevel({tileSize:T.tileSize,roundZoom:T.roundZoom}),k=!e||Math.abs(e.tileID.overscaledZ-S)>Math.abs(h.tileID.overscaledZ-S),D=k&&h.refreshedUponExpiration?1:p.ac(k?y:1-b,0,1);return h.refreshedUponExpiration&&y>=1&&(h.refreshedUponExpiration=!1),e?{opacity:1,mix:1-D}:{opacity:D,mix:0}}return{opacity:1,mix:0}}const oo=new p.aM(1,0,0,1),ct=new p.aM(0,1,0,1),ra=new p.aM(0,0,1,1),vc=new p.aM(1,0,1,1),_l=new p.aM(0,1,1,1);function jn(h,e,n,a){na(h,0,e+n/2,h.transform.width,n,a)}function yl(h,e,n,a){na(h,e-n/2,0,n,h.transform.height,a)}function na(h,e,n,a,o,c){const m=h.context,_=m.gl;_.enable(_.SCISSOR_TEST),_.scissor(e*h.pixelRatio,n*h.pixelRatio,a*h.pixelRatio,o*h.pixelRatio),m.clear({color:c}),_.disable(_.SCISSOR_TEST)}function xl(h,e,n){const a=h.context,o=a.gl,c=n.posMatrix,m=h.useProgram("debug"),_=it.disabled,y=vt.disabled,b=h.colorModeForRenderPass(),T="$debug",S=h.style.map.terrain&&h.style.map.terrain.getTerrainData(n);a.activeTexture.set(o.TEXTURE0);const k=e.getTileByID(n.key).latestRawTileData,D=Math.floor((k&&k.byteLength||0)/1024),B=e.getTile(n).tileSize,N=512/Math.min(B,512)*(n.overscaledZ/h.transform.zoom)*.5;let q=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(q+=` => ${n.overscaledZ}`),function(Z,X){Z.initDebugOverlayCanvas();const F=Z.debugOverlayCanvas,Y=Z.context.gl,ee=Z.debugOverlayCanvas.getContext("2d");ee.clearRect(0,0,F.width,F.height),ee.shadowColor="white",ee.shadowBlur=2,ee.lineWidth=1.5,ee.strokeStyle="white",ee.textBaseline="top",ee.font="bold 36px Open Sans, sans-serif",ee.fillText(X,5,5),ee.strokeText(X,5,5),Z.debugOverlayTexture.update(F),Z.debugOverlayTexture.bind(Y.LINEAR,Y.CLAMP_TO_EDGE)}(h,`${q} ${D}kB`),m.draw(a,o.TRIANGLES,_,y,Rt.alphaBlended,gt.disabled,xs(c,p.aM.transparent,N),null,T,h.debugBuffer,h.quadTriangleIndexBuffer,h.debugSegments),m.draw(a,o.LINE_STRIP,_,y,b,gt.disabled,xs(c,p.aM.red),S,T,h.debugBuffer,h.tileBorderIndexBuffer,h.debugSegments)}function vl(h,e,n){const a=h.context,o=a.gl,c=h.colorModeForRenderPass(),m=new it(o.LEQUAL,it.ReadWrite,h.depthRangeFor3D),_=h.useProgram("terrain"),y=e.getTerrainMesh();a.bindFramebuffer.set(null),a.viewport.set([0,0,h.width,h.height]);for(const b of n){const T=h.renderToTexture.getTexture(b),S=e.getTerrainData(b.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,T.texture);const k=h.transform.calculatePosMatrix(b.tileID.toUnwrapped()),D=e.getMeshFrameDelta(h.transform.zoom),B=h.transform.calculateFogMatrix(b.tileID.toUnwrapped()),N=qa(k,D,B,h.style.sky,h.transform.pitch);_.draw(a,o.TRIANGLES,m,vt.disabled,c,gt.backCCW,N,S,"terrain",y.vertexBuffer,y.indexBuffer,y.segments)}}class sa{constructor(e,n,a){this.vertexBuffer=e,this.indexBuffer=n,this.segments=a}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class aa{constructor(e,n){this.context=new xc(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:p.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$e.maxUnderzooming+$e.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new ja}resize(e,n,a){if(this.width=Math.floor(e*a),this.height=Math.floor(n*a),this.pixelRatio=a,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const o of this.style._order)this.style._layers[o].resize()}setup(){const e=this.context,n=new p.aX;n.emplaceBack(0,0),n.emplaceBack(p.X,0),n.emplaceBack(0,p.X),n.emplaceBack(p.X,p.X),this.tileExtentBuffer=e.createVertexBuffer(n,fn.members),this.tileExtentSegments=p.a0.simpleSegment(0,0,4,2);const a=new p.aX;a.emplaceBack(0,0),a.emplaceBack(p.X,0),a.emplaceBack(0,p.X),a.emplaceBack(p.X,p.X),this.debugBuffer=e.createVertexBuffer(a,fn.members),this.debugSegments=p.a0.simpleSegment(0,0,4,5);const o=new p.$;o.emplaceBack(0,0,0,0),o.emplaceBack(p.X,0,p.X,0),o.emplaceBack(0,p.X,0,p.X),o.emplaceBack(p.X,p.X,p.X,p.X),this.rasterBoundsBuffer=e.createVertexBuffer(o,Kr.members),this.rasterBoundsSegments=p.a0.simpleSegment(0,0,4,2);const c=new p.aX;c.emplaceBack(0,0),c.emplaceBack(1,0),c.emplaceBack(0,1),c.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(c,fn.members),this.viewportSegments=p.a0.simpleSegment(0,0,4,2);const m=new p.aZ;m.emplaceBack(0),m.emplaceBack(1),m.emplaceBack(3),m.emplaceBack(2),m.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(m);const _=new p.aY;_.emplaceBack(0,1,2),_.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(_);const y=this.context.gl;this.stencilClearMode=new vt({func:y.ALWAYS,mask:0},0,255,y.ZERO,y.ZERO,y.ZERO)}clearStencil(){const e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const a=p.H();p.aP(a,0,this.width,this.height,0,0,1),p.K(a,a,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(e,n.TRIANGLES,it.disabled,this.stencilClearMode,Rt.disabled,gt.disabled,Mi(a),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!n||!n.length)return;this.currentStencilSource=e.source;const a=this.context,o=a.gl;this.nextStencilID+n.length>256&&this.clearStencil(),a.setColorMode(Rt.disabled),a.setDepthMode(it.disabled);const c=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const m of n){const _=this._tileClippingMaskIDs[m.key]=this.nextStencilID++,y=this.style.map.terrain&&this.style.map.terrain.getTerrainData(m);c.draw(a,o.TRIANGLES,it.disabled,new vt({func:o.ALWAYS,mask:0},_,255,o.KEEP,o.KEEP,o.REPLACE),Rt.disabled,gt.disabled,Mi(m.posMatrix),y,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,n=this.context.gl;return new vt({func:n.NOTEQUAL,mask:255},e,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(e){const n=this.context.gl;return new vt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(e){const n=this.context.gl,a=e.sort((m,_)=>_.overscaledZ-m.overscaledZ),o=a[a.length-1].overscaledZ,c=a[0].overscaledZ-o+1;if(c>1){this.currentStencilSource=void 0,this.nextStencilID+c>256&&this.clearStencil();const m={};for(let _=0;_({u_sky_color:Z.properties.get("sky-color"),u_horizon_color:Z.properties.get("horizon-color"),u_horizon:(X.height/2+X.getHorizon())*F,u_sky_horizon_blend:Z.properties.get("sky-horizon-blend")*X.height/2*F}))(b,y.style.map.transform,y.pixelRatio),D=new it(S.LEQUAL,it.ReadWrite,[0,1]),B=vt.disabled,N=y.colorModeForRenderPass(),q=y.useProgram("sky");if(!b.mesh){const Z=new p.aX;Z.emplaceBack(-1,-1),Z.emplaceBack(1,-1),Z.emplaceBack(1,1),Z.emplaceBack(-1,1);const X=new p.aY;X.emplaceBack(0,1,2),X.emplaceBack(0,2,3),b.mesh=new sa(T.createVertexBuffer(Z,fn.members),T.createIndexBuffer(X),p.a0.simpleSegment(0,0,Z.length,X.length))}q.draw(T,S.TRIANGLES,D,B,N,gt.disabled,k,void 0,"sky",b.mesh.vertexBuffer,b.mesh.indexBuffer,b.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=a.length-1;this.currentLayer>=0;this.currentLayer--){const y=this.style._layers[a[this.currentLayer]],b=o[y.source],T=c[y.source];this._renderTileClippingMasks(y,T),this.renderLayer(this,b,y,T)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerq.source&&!q.isHidden(T)?[b.sourceCaches[q.source]]:[]),D=k.filter(q=>q.getSource().type==="vector"),B=k.filter(q=>q.getSource().type!=="vector"),N=q=>{(!S||S.getSource().maxzoomN(q)),S||B.forEach(q=>N(q)),S}(this.style,this.transform.zoom);y&&function(b,T,S){for(let k=0;k0),o&&(p.b0(n,a),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.sourceCache.getRenderableTiles(),D=c.useProgram("terrainDepth");_.bindFramebuffer.set(m.getFramebuffer("depth").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1});for(const B of k){const N=m.getTerrainData(B.tileID),q={u_matrix:c.transform.calculatePosMatrix(B.tileID.toUnwrapped()),u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};D.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,q,N,"terrain",S.vertexBuffer,S.indexBuffer,S.segments)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain),function(c,m){const _=c.context,y=_.gl,b=Rt.unblended,T=new it(y.LEQUAL,it.ReadWrite,[0,1]),S=m.getTerrainMesh(),k=m.getCoordsTexture(),D=m.sourceCache.getRenderableTiles(),B=c.useProgram("terrainCoords");_.bindFramebuffer.set(m.getFramebuffer("coords").framebuffer),_.viewport.set([0,0,c.width/devicePixelRatio,c.height/devicePixelRatio]),_.clear({color:p.aM.transparent,depth:1}),m.coordsIndex=[];for(const N of D){const q=m.getTerrainData(N.tileID);_.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,k.texture);const Z={u_matrix:c.transform.calculatePosMatrix(N.tileID.toUnwrapped()),u_terrain_coords_id:(255-m.coordsIndex.length)/255,u_texture:0,u_ele_delta:m.getMeshFrameDelta(c.transform.zoom)};B.draw(_,y.TRIANGLES,T,vt.disabled,b,gt.backCCW,Z,q,"terrain",S.vertexBuffer,S.indexBuffer,S.segments),m.coordsIndex.push(N.tileID.key)}_.bindFramebuffer.set(null),_.viewport.set([0,0,c.width,c.height])}(this,this.style.map.terrain))}renderLayer(e,n,a,o){if(!a.isHidden(this.transform.zoom)&&(a.type==="background"||a.type==="custom"||(o||[]).length))switch(this.id=a.id,a.type){case"symbol":(function(c,m,_,y,b){if(c.renderPass!=="translucent")return;const T=vt.disabled,S=c.colorModeForRenderPass();(_._unevaluatedLayout.hasValue("text-variable-anchor")||_._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(k,D,B,N,q,Z,X,F,Y){const ee=D.transform,ae=pn(),fe=q==="map",_e=Z==="map";for(const Pe of k){const ke=N.getTile(Pe),we=ke.getBucket(B);if(!we||!we.text||!we.text.segments.get().length)continue;const be=p.ag(we.textSizeData,ee.zoom),Re=rt(ke,1,D.transform.zoom),Xe=Yr(Pe.posMatrix,_e,fe,D.transform,Re),Se=B.layout.get("icon-text-fit")!=="none"&&we.hasIconData();if(be){const Ce=Math.pow(2,ee.zoom-ke.tileID.overscaledZ),qe=D.style.map.terrain?(Ye,nt)=>D.style.map.terrain.getElevation(Pe,Ye,nt):null,Tt=ae.translatePosition(ee,ke,X,F);On(we,fe,_e,Y,ee,Xe,Pe.posMatrix,Ce,be,Se,ae,Tt,Pe.toUnwrapped(),qe)}}}(y,c,_,m,_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),b),_.paint.get("icon-opacity").constantOr(1)!==0&&no(c,m,_,y,!1,_.paint.get("icon-translate"),_.paint.get("icon-translate-anchor"),_.layout.get("icon-rotation-alignment"),_.layout.get("icon-pitch-alignment"),_.layout.get("icon-keep-upright"),T,S),_.paint.get("text-opacity").constantOr(1)!==0&&no(c,m,_,y,!0,_.paint.get("text-translate"),_.paint.get("text-translate-anchor"),_.layout.get("text-rotation-alignment"),_.layout.get("text-pitch-alignment"),_.layout.get("text-keep-upright"),T,S),m.map.showCollisionBoxes&&(ws(c,m,_,y,!0),ws(c,m,_,y,!1))})(e,n,a,o,this.style.placement.variableOffsets);break;case"circle":(function(c,m,_,y){if(c.renderPass!=="translucent")return;const b=_.paint.get("circle-opacity"),T=_.paint.get("circle-stroke-width"),S=_.paint.get("circle-stroke-opacity"),k=!_.layout.get("circle-sort-key").isConstant();if(b.constantOr(1)===0&&(T.constantOr(1)===0||S.constantOr(1)===0))return;const D=c.context,B=D.gl,N=c.depthModeForSublayer(0,it.ReadOnly),q=vt.disabled,Z=c.colorModeForRenderPass(),X=[];for(let F=0;FF.sortKey-Y.sortKey);for(const F of X){const{programConfiguration:Y,program:ee,layoutVertexBuffer:ae,indexBuffer:fe,uniformValues:_e,terrainData:Pe}=F.state;ee.draw(D,B.TRIANGLES,N,q,Z,gt.disabled,_e,Pe,_.id,ae,fe,F.segments,_.paint,c.transform.zoom,Y)}})(e,n,a,o);break;case"heatmap":(function(c,m,_,y){if(_.paint.get("heatmap-opacity")===0)return;const b=c.context;if(c.style.map.terrain){for(const T of y){const S=m.getTile(T);m.hasRenderableParent(T)||(c.renderPass==="offscreen"?ao(c,S,_,T):c.renderPass==="translucent"&&bn(c,_,T))}b.viewport.set([0,0,c.width,c.height])}else c.renderPass==="offscreen"?function(T,S,k,D){const B=T.context,N=B.gl,q=vt.disabled,Z=new Rt([N.ONE,N.ONE],p.aM.transparent,[!0,!0,!0,!0]);(function(X,F,Y){const ee=X.gl;X.activeTexture.set(ee.TEXTURE1),X.viewport.set([0,0,F.width/4,F.height/4]);let ae=Y.heatmapFbos.get(p.aU);ae?(ee.bindTexture(ee.TEXTURE_2D,ae.colorAttachment.get()),X.bindFramebuffer.set(ae.framebuffer)):(ae=Ss(X,F.width/4,F.height/4),Y.heatmapFbos.set(p.aU,ae))})(B,T,k),B.clear({color:p.aM.transparent});for(let X=0;X20&&T.texParameterf(T.TEXTURE_2D,b.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,b.extTextureFilterAnisotropicMax);const we=c.style.map.terrain&&c.style.map.terrain.getTerrainData(X),be=we?X:null,Re=be?be.posMatrix:c.transform.calculatePosMatrix(X.toUnwrapped(),Z),Xe=lc(Re,Pe||[0,0],_e||1,fe,_);S instanceof Nr?k.draw(b,T.TRIANGLES,F,vt.disabled,D,gt.disabled,Xe,we,_.id,S.boundsBuffer,c.quadTriangleIndexBuffer,S.boundsSegments):k.draw(b,T.TRIANGLES,F,B[X.overscaledZ],D,gt.disabled,Xe,we,_.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}})(e,n,a,o);break;case"background":(function(c,m,_,y){const b=_.paint.get("background-color"),T=_.paint.get("background-opacity");if(T===0)return;const S=c.context,k=S.gl,D=c.transform,B=D.tileSize,N=_.paint.get("background-pattern");if(c.isPatternMissing(N))return;const q=!N&&b.a===1&&T===1&&c.opaquePassEnabledForLayer()?"opaque":"translucent";if(c.renderPass!==q)return;const Z=vt.disabled,X=c.depthModeForSublayer(0,q==="opaque"?it.ReadWrite:it.ReadOnly),F=c.colorModeForRenderPass(),Y=c.useProgram(N?"backgroundPattern":"background"),ee=y||D.coveringTiles({tileSize:B,terrain:c.style.map.terrain});N&&(S.activeTexture.set(k.TEXTURE0),c.imageManager.bind(c.context));const ae=_.getCrossfadeParameters();for(const fe of ee){const _e=y?fe.posMatrix:c.transform.calculatePosMatrix(fe.toUnwrapped()),Pe=N?Ha(_e,T,c,N,{tileID:fe,tileSize:B},ae):Ks(_e,T,b),ke=c.style.map.terrain&&c.style.map.terrain.getTerrainData(fe);Y.draw(S,k.TRIANGLES,X,Z,F,gt.disabled,Pe,ke,_.id,c.tileExtentBuffer,c.quadTriangleIndexBuffer,c.tileExtentSegments)}})(e,0,a,o);break;case"custom":(function(c,m,_){const y=c.context,b=_.implementation;if(c.renderPass==="offscreen"){const T=b.prerender;T&&(c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),T.call(b,y.gl,c.transform.customLayerMatrix()),y.setDirty(),c.setBaseState())}else if(c.renderPass==="translucent"){c.setCustomLayerDefaults(),y.setColorMode(c.colorModeForRenderPass()),y.setStencilMode(vt.disabled);const T=b.renderingMode==="3d"?new it(c.context.gl.LEQUAL,it.ReadWrite,c.depthRangeFor3D):c.depthModeForSublayer(0,it.ReadOnly);y.setDepthMode(T),b.render(y.gl,c.transform.customLayerMatrix(),{farZ:c.transform.farZ,nearZ:c.transform.nearZ,fov:c.transform._fov,modelViewProjectionMatrix:c.transform.modelViewProjectionMatrix,projectionMatrix:c.transform.projectionMatrix}),y.setDirty(),c.setBaseState(),y.bindFramebuffer.set(null)}})(e,0,a)}}translatePosMatrix(e,n,a,o,c){if(!a[0]&&!a[1])return e;const m=c?o==="map"?this.transform.angle:0:o==="viewport"?-this.transform.angle:0;if(m){const b=Math.sin(m),T=Math.cos(m);a=[a[0]*T-a[1]*b,a[0]*b+a[1]*T]}const _=[c?a[0]:rt(n,a[0],this.transform.zoom),c?a[1]:rt(n,a[1],this.transform.zoom),0],y=new Float32Array(16);return p.J(y,e,_),y}saveTileTexture(e){const n=this._tileTextures[e.size[0]];n?n.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){const n=this._tileTextures[e];return n&&n.length>0?n.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const n=this.imageManager.getPattern(e.from.toString()),a=this.imageManager.getPattern(e.to.toString());return!n||!a}useProgram(e,n){this.cache=this.cache||{};const a=e+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[a]||(this.cache[a]=new Za(this.context,Qr[e],n,Xa[e],this._showOverdrawInspector,this.style.map.terrain)),this.cache[a]}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 e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new et(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:n}=this.context.gl;return this.width!==e||this.height!==n}}class $n{constructor(e,n){this.points=e,this.planes=n}static fromInvProjectionMatrix(e,n,a){const o=Math.pow(2,a),c=[[-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(_=>{const y=1/(_=p.af([],_,e))[3]/n*o;return p.b1(_,_,[y,y,1/_[3],y])}),m=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(_=>{const y=function(k,D){var B=D[0],N=D[1],q=D[2],Z=B*B+N*N+q*q;return Z>0&&(Z=1/Math.sqrt(Z)),k[0]=D[0]*Z,k[1]=D[1]*Z,k[2]=D[2]*Z,k}([],function(k,D,B){var N=D[0],q=D[1],Z=D[2],X=B[0],F=B[1],Y=B[2];return k[0]=q*Y-Z*F,k[1]=Z*X-N*Y,k[2]=N*F-q*X,k}([],gi([],c[_[0]],c[_[1]]),gi([],c[_[2]],c[_[1]]))),b=-((T=y)[0]*(S=c[_[1]])[0]+T[1]*S[1]+T[2]*S[2]);var T,S;return y.concat(b)});return new $n(c,m)}}class qn{constructor(e,n){this.min=e,this.max=n,this.center=function(a,o,c){return a[0]=.5*o[0],a[1]=.5*o[1],a[2]=.5*o[2],a}([],function(a,o,c){return a[0]=o[0]+c[0],a[1]=o[1]+c[1],a[2]=o[2]+c[2],a}([],this.min,this.max))}quadrant(e){const n=[e%2==0,e<2],a=mi(this.min),o=mi(this.max);for(let c=0;c=0&&m++;if(m===0)return 0;m!==n.length&&(a=!1)}if(a)return 2;for(let o=0;o<3;o++){let c=Number.MAX_VALUE,m=-Number.MAX_VALUE;for(let _=0;_this.max[o]-this.min[o])return 0}return 1}}class Zn{constructor(e=0,n=0,a=0,o=0){if(isNaN(e)||e<0||isNaN(n)||n<0||isNaN(a)||a<0||isNaN(o)||o<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=n,this.left=a,this.right=o}interpolate(e,n,a){return n.top!=null&&e.top!=null&&(this.top=p.y.number(e.top,n.top,a)),n.bottom!=null&&e.bottom!=null&&(this.bottom=p.y.number(e.bottom,n.bottom,a)),n.left!=null&&e.left!=null&&(this.left=p.y.number(e.left,n.left,a)),n.right!=null&&e.right!=null&&(this.right=p.y.number(e.right,n.right,a)),this}getCenter(e,n){const a=p.ac((this.left+e-this.right)/2,0,e),o=p.ac((this.top+n-this.bottom)/2,0,n);return new p.P(a,o)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Zn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const lo=85.051129;class Gn{constructor(e,n,a,o,c){this.tileSize=512,this._renderWorldCopies=c===void 0||!!c,this._minZoom=e||0,this._maxZoom=n||22,this._minPitch=a??0,this._maxPitch=o??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new p.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Zn,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const e=new Gn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return e.apply(this),e}apply(e){this.tileSize=e.tileSize,this.latRange=e.latRange,this.lngRange=e.lngRange,this.width=e.width,this.height=e.height,this._center=e._center,this._elevation=e._elevation,this.minElevationForCurrentTile=e.minElevationForCurrentTile,this.zoom=e.zoom,this.angle=e.angle,this._fov=e._fov,this._pitch=e._pitch,this._unmodified=e._unmodified,this._edgeInsets=e._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new p.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(e){const n=-p.b3(e,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var a=new p.A(4);return p.A!=Float32Array&&(a[1]=0,a[2]=0),a[0]=1,a[3]=1,a}(),function(a,o,c){var m=o[0],_=o[1],y=o[2],b=o[3],T=Math.sin(c),S=Math.cos(c);a[0]=m*S+y*T,a[1]=_*S+b*T,a[2]=m*-T+y*S,a[3]=_*-T+b*S}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const n=p.ac(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=e/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(e){const n=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,n,a){this._unmodified=!1,this._edgeInsets.interpolate(e,n,a),this._constrain(),this._calcMatrices()}coveringZoomLevel(e){const n=(e.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/e.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(e){const n=[new p.b4(0,e)];if(this._renderWorldCopies){const a=this.pointCoordinate(new p.P(0,0)),o=this.pointCoordinate(new p.P(this.width,0)),c=this.pointCoordinate(new p.P(this.width,this.height)),m=this.pointCoordinate(new p.P(0,this.height)),_=Math.floor(Math.min(a.x,o.x,c.x,m.x)),y=Math.floor(Math.max(a.x,o.x,c.x,m.x)),b=1;for(let T=_-b;T<=y+b;T++)T!==0&&n.push(new p.b4(T,e))}return n}coveringTiles(e){var n,a;let o=this.coveringZoomLevel(e);const c=o;if(e.minzoom!==void 0&&oe.maxzoom&&(o=e.maxzoom);const m=this.pointCoordinate(this.getCameraPoint()),_=p.Z.fromLngLat(this.center),y=Math.pow(2,o),b=[y*m.x,y*m.y,0],T=[y*_.x,y*_.y,0],S=$n.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,o);let k=e.minzoom||0;!e.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(k=o);const D=e.terrain?2/Math.min(this.tileSize,e.tileSize)*this.tileSize:3,B=F=>({aabb:new qn([F*y,0,0],[(F+1)*y,y,0]),zoom:0,x:0,y:0,wrap:F,fullyVisible:!1}),N=[],q=[],Z=o,X=e.reparseOverscaled?c:o;if(this._renderWorldCopies)for(let F=1;F<=3;F++)N.push(B(-F)),N.push(B(F));for(N.push(B(0));N.length>0;){const F=N.pop(),Y=F.x,ee=F.y;let ae=F.fullyVisible;if(!ae){const we=F.aabb.intersects(S);if(we===0)continue;ae=we===2}const fe=e.terrain?b:T,_e=F.aabb.distanceX(fe),Pe=F.aabb.distanceY(fe),ke=Math.max(Math.abs(_e),Math.abs(Pe));if(F.zoom===Z||ke>D+(1<=k){const we=Z-F.zoom,be=b[0]-.5-(Y<>1),Xe=F.zoom+1;let Se=F.aabb.quadrant(we);if(e.terrain){const Ce=new p.S(Xe,F.wrap,Xe,be,Re),qe=e.terrain.getMinMaxElevation(Ce),Tt=(n=qe.minElevation)!==null&&n!==void 0?n:this.elevation,Ye=(a=qe.maxElevation)!==null&&a!==void 0?a:this.elevation;Se=new qn([Se.min[0],Se.min[1],Tt],[Se.max[0],Se.max[1],Ye])}N.push({aabb:Se,zoom:Xe,x:be,y:Re,wrap:F.wrap,fullyVisible:ae})}}return q.sort((F,Y)=>F.distanceSq-Y.distanceSq).map(F=>F.tileID)}resize(e,n){this.width=e,this.height=n,this.pixelsToGLUnits=[2/e,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(e){const n=p.ac(e.lat,-85.051129,lo);return new p.P(p.O(e.lng)*this.worldSize,p.Q(n)*this.worldSize)}unproject(e){return new p.Z(e.x/this.worldSize,e.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(e){const n=this.elevation,a=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,o=this.pointLocation(this.centerPoint,e),c=e.getElevationForLngLatZoom(o,this.tileZoom);if(!(this.elevation-c))return;const m=a+n-c,_=Math.cos(this._pitch)*this.cameraToCenterDistance/m/p.b5(1,o.lat),y=this.scaleZoom(_/this.tileSize);this._elevation=c,this._center=o,this.zoom=y}setLocationAtPoint(e,n){const a=this.pointCoordinate(n),o=this.pointCoordinate(this.centerPoint),c=this.locationCoordinate(e),m=new p.Z(c.x-(a.x-o.x),c.y-(a.y-o.y));this.center=this.coordinateLocation(m),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(e,n){return n?this.coordinatePoint(this.locationCoordinate(e),n.getElevationForLngLatZoom(e,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(e))}pointLocation(e,n){return this.coordinateLocation(this.pointCoordinate(e,n))}locationCoordinate(e){return p.Z.fromLngLat(e)}coordinateLocation(e){return e&&e.toLngLat()}pointCoordinate(e,n){if(n){const k=n.pointCoordinate(e);if(k!=null)return k}const a=[e.x,e.y,0,1],o=[e.x,e.y,1,1];p.af(a,a,this.pixelMatrixInverse),p.af(o,o,this.pixelMatrixInverse);const c=a[3],m=o[3],_=a[1]/c,y=o[1]/m,b=a[2]/c,T=o[2]/m,S=b===T?0:(0-b)/(T-b);return new p.Z(p.y.number(a[0]/c,o[0]/m,S)/this.worldSize,p.y.number(_,y,S)/this.worldSize)}coordinatePoint(e,n=0,a=this.pixelMatrix){const o=[e.x*this.worldSize,e.y*this.worldSize,n,1];return p.af(o,o,a),new p.P(o[0]/o[3],o[1]/o[3])}getBounds(){const e=Math.max(0,this.height/2-this.getHorizon());return new le().extend(this.pointLocation(new p.P(0,e))).extend(this.pointLocation(new p.P(this.width,e))).extend(this.pointLocation(new p.P(this.width,this.height))).extend(this.pointLocation(new p.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new le([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(e){e?(this.lngRange=[e.getWest(),e.getEast()],this.latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,lo])}calculateTileMatrix(e){const n=e.canonical,a=this.worldSize/this.zoomScale(n.z),o=n.x+Math.pow(2,n.z)*e.wrap,c=p.an(new Float64Array(16));return p.J(c,c,[o*a,n.y*a,0]),p.K(c,c,[a/p.X,a/p.X,1]),c}calculatePosMatrix(e,n=!1){const a=e.key,o=n?this._alignedPosMatrixCache:this._posMatrixCache;if(o[a])return o[a];const c=this.calculateTileMatrix(e);return p.L(c,n?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,c),o[a]=new Float32Array(c),o[a]}calculateFogMatrix(e){const n=e.key,a=this._fogMatrixCache;if(a[n])return a[n];const o=this.calculateTileMatrix(e);return p.L(o,this.fogMatrix,o),a[n]=new Float32Array(o),a[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(e,n){n=p.ac(+n,this.minZoom,this.maxZoom);const a={center:new p.N(e.lng,e.lat),zoom:n};let o=this.lngRange;if(!this._renderWorldCopies&&o===null){const F=179.9999999999;o=[-F,F]}const c=this.tileSize*this.zoomScale(a.zoom);let m=0,_=c,y=0,b=c,T=0,S=0;const{x:k,y:D}=this.size;if(this.latRange){const F=this.latRange;m=p.Q(F[1])*c,_=p.Q(F[0])*c,_-m_&&(Z=_-F)}if(o){const F=(y+b)/2;let Y=B;this._renderWorldCopies&&(Y=p.b3(B,F-c/2,F+c/2));const ee=k/2;Y-eeb&&(q=b-ee)}if(q!==void 0||Z!==void 0){const F=new p.P(q??B,Z??N);a.center=this.unproject.call({worldSize:c},F).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:n,zoom:a}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=a,this._unmodified=e,this._constraining=!1}_calcMatrices(){if(!this.height)return;const e=this.centerOffset,n=this.point.x,a=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=p.b5(1,this.center.lat)*this.worldSize;let o=p.an(new Float64Array(16));p.K(o,o,[this.width/2,-this.height/2,1]),p.J(o,o,[1,-1,0]),this.labelPlaneMatrix=o,o=p.an(new Float64Array(16)),p.K(o,o,[1,-1,1]),p.J(o,o,[-1,-1,0]),p.K(o,o,[2/this.width,2/this.height,1]),this.glCoordMatrix=o;const c=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),m=Math.min(this.elevation,this.minElevationForCurrentTile),_=c-m*this._pixelPerMeter/Math.cos(this._pitch),y=m<0?_:c,b=Math.PI/2+this._pitch,T=this._fov*(.5+e.y/this.height),S=Math.sin(T)*y/Math.sin(p.ac(Math.PI-b-T,.01,Math.PI-.01)),k=this.getHorizon(),D=2*Math.atan(k/this.cameraToCenterDistance)*(.5+e.y/(2*k)),B=Math.sin(D)*y/Math.sin(p.ac(Math.PI-b-D,.01,Math.PI-.01)),N=Math.min(S,B);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*N+y),this.nearZ=this.height/50,o=new Float64Array(16),p.b6(o,this._fov,this.width/this.height,this.nearZ,this.farZ),o[8]=2*-e.x/this.width,o[9]=2*e.y/this.height,this.projectionMatrix=p.ae(o),p.K(o,o,[1,-1,1]),p.J(o,o,[0,0,-this.cameraToCenterDistance]),p.b7(o,o,this._pitch),p.ad(o,o,this.angle),p.J(o,o,[-n,-a,0]),this.mercatorMatrix=p.K([],o,[this.worldSize,this.worldSize,this.worldSize]),p.K(o,o,[1,1,this._pixelPerMeter]),this.pixelMatrix=p.L(new Float64Array(16),this.labelPlaneMatrix,o),p.J(o,o,[0,0,-this.elevation]),this.modelViewProjectionMatrix=o,this.invModelViewProjectionMatrix=p.as([],o),this.fogMatrix=new Float64Array(16),p.b6(this.fogMatrix,this._fov,this.width/this.height,c,this.farZ),this.fogMatrix[8]=2*-e.x/this.width,this.fogMatrix[9]=2*e.y/this.height,p.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),p.b7(this.fogMatrix,this.fogMatrix,this._pitch),p.ad(this.fogMatrix,this.fogMatrix,this.angle),p.J(this.fogMatrix,this.fogMatrix,[-n,-a,0]),p.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),p.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=p.L(new Float64Array(16),this.labelPlaneMatrix,o);const q=this.width%2/2,Z=this.height%2/2,X=Math.cos(this.angle),F=Math.sin(this.angle),Y=n-Math.round(n)+X*q+F*Z,ee=a-Math.round(a)+X*Z+F*q,ae=new Float64Array(o);if(p.J(ae,ae,[Y>.5?Y-1:Y,ee>.5?ee-1:ee,0]),this.alignedModelViewProjectionMatrix=ae,o=p.as(new Float64Array(16),this.pixelMatrix),!o)throw new Error("failed to invert matrix");this.pixelMatrixInverse=o,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const e=this.pointCoordinate(new p.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return p.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new p.P(0,e))}getCameraQueryGeometry(e){const n=this.getCameraPoint();if(e.length===1)return[e[0],n];{let a=n.x,o=n.y,c=n.x,m=n.y;for(const _ of e)a=Math.min(a,_.x),o=Math.min(o,_.y),c=Math.max(c,_.x),m=Math.max(m,_.y);return[new p.P(a,o),new p.P(c,o),new p.P(c,m),new p.P(a,m),new p.P(a,o)]}}lngLatToCameraDepth(e,n){const a=this.locationCoordinate(e),o=[a.x*this.worldSize,a.y*this.worldSize,n,1];return p.af(o,o,this.modelViewProjectionMatrix),o[2]/o[3]}}function As(h,e){let n,a=!1,o=null,c=null;const m=()=>{o=null,a&&(h.apply(c,n),o=setTimeout(m,e),a=!1)};return(..._)=>(a=!0,c=this,n=_,o||m(),o)}class oa{constructor(e){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let a;return n.split("&").map(o=>o.split("=")).forEach(o=>{o[0]===this._hashName&&(a=o)}),(a&&a[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(a=>isNaN(a))){const a=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:a,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,n)},this._removeHash=()=>{const n=this._getCurrentHash();if(n.length===0)return;const a=n.join("/");let o=a;o.split("&").length>0&&(o=o.split("&")[0]),this._hashName&&(o=`${this._hashName}=${a}`);let c=window.location.hash.replace(o,"");c.startsWith("#&")?c=c.slice(0,1)+c.slice(2):c==="#"&&(c="");let m=window.location.href.replace(/(#.+)?$/,c);m=m.replace("&&","&"),window.history.replaceState(window.history.state,null,m)},this._updateHash=As(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,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()),this._removeHash(),delete this._map,this}getHashString(e){const n=this._map.getCenter(),a=Math.round(100*this._map.getZoom())/100,o=Math.ceil((a*Math.LN2+Math.log(512/360/.5))/Math.LN10),c=Math.pow(10,o),m=Math.round(n.lng*c)/c,_=Math.round(n.lat*c)/c,y=this._map.getBearing(),b=this._map.getPitch();let T="";if(T+=e?`/${m}/${_}/${a}`:`${a}/${_}/${m}`,(y||b)&&(T+="/"+Math.round(10*y)/10),b&&(T+=`/${Math.round(b)}`),this._hashName){const S=this._hashName;let k=!1;const D=window.location.hash.slice(1).split("&").map(B=>{const N=B.split("=")[0];return N===S?(k=!0,`${N}=${T}`):B}).filter(B=>B);return k||D.push(`${S}=${T}`),`#${D.join("&")}`}return`#${T}`}}const la={linearity:.3,easing:p.b8(0,0,.3,1)},co=p.e({deceleration:2500,maxSpeed:1400},la),bc=p.e({deceleration:20,maxSpeed:1400},la),bl=p.e({deceleration:1e3,maxSpeed:360},la),ca=p.e({deceleration:1e3,maxSpeed:90},la);class ho{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:de.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,n=de.now();for(;e.length>0&&n-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new p.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:c}of this._inertiaBuffer)n.zoom+=c.zoomDelta||0,n.bearing+=c.bearingDelta||0,n.pitch+=c.pitchDelta||0,c.panDelta&&n.pan._add(c.panDelta),c.around&&(n.around=c.around),c.pinchAround&&(n.pinchAround=c.pinchAround);const a=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,o={};if(n.pan.mag()){const c=Ms(n.pan.mag(),a,p.e({},co,e||{}));o.offset=n.pan.mult(c.amount/n.pan.mag()),o.center=this._map.transform.center,Cs(o,c)}if(n.zoom){const c=Ms(n.zoom,a,bc);o.zoom=this._map.transform.zoom+c.amount,Cs(o,c)}if(n.bearing){const c=Ms(n.bearing,a,bl);o.bearing=this._map.transform.bearing+p.ac(c.amount,-179,179),Cs(o,c)}if(n.pitch){const c=Ms(n.pitch,a,ca);o.pitch=this._map.transform.pitch+c.amount,Cs(o,c)}if(o.zoom||o.bearing){const c=n.pinchAround===void 0?n.around:n.pinchAround;o.around=c?this._map.unproject(c):this._map.getCenter()}return this.clear(),p.e(o,{noMoveStart:!0})}}function Cs(h,e){(!h.duration||h.durationn.unproject(y)),_=c.reduce((y,b,T,S)=>y.add(b.div(S.length)),new p.P(0,0));super(e,{points:c,point:_,lngLats:m,lngLat:n.unproject(_),originalEvent:a}),this._defaultPrevented=!1}}class wl extends p.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,a){super(e,{originalEvent:a}),this._defaultPrevented=!1}}class Tl{constructor(e,n){this._map=e,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new wl(e.type,this._map,e))}mousedown(e,n){return this._mousedownPos=n,this._firePreventable(new ai(e.type,this._map,e))}mouseup(e){this._map.fire(new ai(e.type,this._map,e))}click(e,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new ai(e.type,this._map,e))}dblclick(e){return this._firePreventable(new ai(e.type,this._map,e))}mouseover(e){this._map.fire(new ai(e.type,this._map,e))}mouseout(e){this._map.fire(new ai(e.type,this._map,e))}touchstart(e){return this._firePreventable(new wn(e.type,this._map,e))}touchmove(e){this._map.fire(new wn(e.type,this._map,e))}touchend(e){this._map.fire(new wn(e.type,this._map,e))}touchcancel(e){this._map.fire(new wn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bt{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new ai(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ai("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new ai(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.pointLocation(p.P.convert(e),this._map.terrain)}}class qi{constructor(e,n){this._map=e,this._tr=new pr(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,n){this.isEnabled()&&e.shiftKey&&e.button===0&&(se.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(e,n){if(!this._active)return;const a=n;if(this._lastPos.equals(a)||!this._box&&a.dist(this._startPos)c.fitScreenCoordinates(a,o,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(se.remove(this._box),this._box=null),se.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new p.k(e,{originalEvent:n}))}}function ks(h,e){if(h.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${h.length}, points ${e.length}`);const n={};for(let a=0;athis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),a.length===this.numTouches&&(this.centroid=function(o){const c=new p.P(0,0);for(const m of o)c._add(m);return c.div(o.length)}(n),this.touches=ks(a,n)))}touchmove(e,n,a){if(this.aborted||!this.centroid)return;const o=ks(a,n);for(const c in this.touches){const m=o[c];(!m||m.dist(this.touches[c])>30)&&(this.aborted=!0)}}touchend(e,n,a){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),a.length===0){const o=!this.aborted&&this.centroid;if(this.reset(),o)return o}}}class ha{constructor(e){this.singleTap=new uo(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,n,a){this.singleTap.touchstart(e,n,a)}touchmove(e,n,a){this.singleTap.touchmove(e,n,a)}touchend(e,n,a){const o=this.singleTap.touchend(e,n,a);if(o){const c=e.timeStamp-this.lastTime<500,m=!this.lastTap||this.lastTap.dist(o)<30;if(c&&m||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=o,this.count===this.numTaps)return this.reset(),o}}}class Hn{constructor(e){this._tr=new pr(e),this._zoomIn=new ha({numTouches:1,numTaps:2}),this._zoomOut=new ha({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,n,a){this._zoomIn.touchstart(e,n,a),this._zoomOut.touchstart(e,n,a)}touchmove(e,n,a){this._zoomIn.touchmove(e,n,a),this._zoomOut.touchmove(e,n,a)}touchend(e,n,a){const o=this._zoomIn.touchend(e,n,a),c=this._zoomOut.touchend(e,n,a),m=this._tr;return o?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom+1,around:m.unproject(o)},{originalEvent:e})}):c?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:_=>_.easeTo({duration:300,zoom:m.zoom-1,around:m.unproject(c)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $r{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const n=this._moveFunction(...e);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(e,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,n){if(!this.isEnabled())return;const a=this._lastPoint;if(!a)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const o=n.length?n[0]:n;return!this._moved&&o.dist(a){h.mousedown=h.dragStart,h.mousemoveWindow=h.dragMove,h.mouseup=h.dragEnd,h.contextmenu=e=>{e.preventDefault()}},mo=({enable:h,clickTolerance:e,bearingDegreesPerPixelMoved:n=.8})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({bearingDelta:(c.x-o.x)*n}),moveStateManager:a,enable:h,assignEvents:da})},go=({enable:h,clickTolerance:e,pitchDegreesPerPixelMoved:n=-.5})=>{const a=new ua({checkCorrectEvent:o=>se.mouseButton(o)===0&&o.ctrlKey||se.mouseButton(o)===2});return new $r({clickTolerance:e,move:(o,c)=>({pitchDelta:(c.y-o.y)*n}),moveStateManager:a,enable:h,assignEvents:da})};class Tn{constructor(e,n){this._clickTolerance=e.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new p.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,n,a){return this._calculateTransform(e,n,a)}touchmove(e,n,a){if(this._active){if(!this._shouldBePrevented(a.length))return e.preventDefault(),this._calculateTransform(e,n,a);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,n,a){this._calculateTransform(e,n,a),this._active&&this._shouldBePrevented(a.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,a){a.length>0&&(this._active=!0);const o=ks(a,n),c=new p.P(0,0),m=new p.P(0,0);let _=0;for(const b in o){const T=o[b],S=this._touches[b];S&&(c._add(T),m._add(T.sub(S)),_++,o[b]=T)}if(this._touches=o,this._shouldBePrevented(_)||!m.mag())return;const y=m.div(_);return this._sum._add(y),this._sum.mag()Math.abs(h.x)}class Xn extends pa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,n,a){super.touchstart(e,n,a),this._currentTouchCount=a.length}_start(e){this._lastPoints=e,fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,n,a){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const o=e[0].sub(this._lastPoints[0]),c=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(o,c,a.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+c.y)/2*-.5}):void 0}gestureBeginsVertically(e,n,a){if(this._valid!==void 0)return this._valid;const o=e.mag()>=2,c=n.mag()>=2;if(!o&&!c)return;if(!o||!c)return this._firstMove===void 0&&(this._firstMove=a),a-this._firstMove<100&&void 0;const m=e.y>0==n.y>0;return fa(e)&&fa(n)&&m}}const Sl={panStep:100,bearingStep:15,pitchStep:10};class er{constructor(e){this._tr=new pr(e);const n=Sl;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let n=0,a=0,o=0,c=0,m=0;switch(e.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:e.shiftKey?a=-1:(e.preventDefault(),c=-1);break;case 39:e.shiftKey?a=1:(e.preventDefault(),c=1);break;case 38:e.shiftKey?o=1:(e.preventDefault(),m=-1);break;case 40:e.shiftKey?o=-1:(e.preventDefault(),m=1);break;default:return}return this._rotationDisabled&&(a=0,o=0),{cameraAnimation:_=>{const y=this._tr;_.easeTo({duration:300,easeId:"keyboardHandler",easing:Er,zoom:n?Math.round(y.zoom)+n*(e.shiftKey?2:1):y.zoom,bearing:y.bearing+a*this._bearingStep,pitch:y.pitch+o*this._pitchStep,offset:[-c*this._panStep,-m*this._panStep],center:y.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Er(h){return h*(2-h)}const bo=4.000244140625;class fr{constructor(e,n){this._onTimeout=a=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(a)},this._map=e,this._tr=new pr(e),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let n=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const a=de.now(),o=a-(this._lastWheelEventTime||0);this._lastWheelEventTime=a,n!==0&&n%bo==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":o>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(o*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),e.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=e,this._delta-=n,this._active||this._start(e)),e.preventDefault()}_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 n=se.mousePos(this._map.getCanvas(),e),a=this._tr;this._around=n.y>a.transform.height/2-a.transform.getHorizon()?p.N.convert(this._aroundCenter?a.center:a.unproject(n)):p.N.convert(a.center),this._aroundPoint=a.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const e=this._tr.transform;if(this._delta!==0){const y=this._type==="wheel"&&Math.abs(this._delta)>bo?this._wheelZoomRate:this._defaultZoomRate;let b=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&b!==0&&(b=1/b);const T=typeof this._targetZoom=="number"?e.zoomScale(this._targetZoom):e.scale;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(T*b))),this._type==="wheel"&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:e.zoom,a=this._startZoom,o=this._easing;let c,m=!1;const _=de.now()-this._lastWheelEventTime;if(this._type==="wheel"&&a&&o&&_){const y=Math.min(_/200,1),b=o(y);c=p.y.number(a,n,b),y<1?this._frameId||(this._frameId=!0):m=!0}else c=n,m=!0;return this._active=!0,m&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!m,zoomDelta:c-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=p.b9;if(this._prevEase){const a=this._prevEase,o=(de.now()-a.start)/a.duration,c=a.easing(o+.01)-a.easing(o),m=.27/Math.sqrt(c*c+1e-4)*.01,_=Math.sqrt(.0729-m*m);n=p.b8(m,_,.25,1)}return this._prevEase={start:de.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Sn{constructor(e,n){this._clickZoom=e,this._tapZoom=n}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 wc{constructor(e){this._tr=new pr(e),this.reset()}reset(){this._active=!1}dblclick(e,n){return e.preventDefault(),{cameraAnimation:a=>{a.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Tc{constructor(){this._tap=new ha({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,n,a){if(!this._swipePoint)if(this._tapTime){const o=n[0],c=e.timeStamp-this._tapTime<500,m=this._tapPoint.dist(o)<30;c&&m?a.length>0&&(this._swipePoint=o,this._swipeTouch=a[0].identifier):this.reset()}else this._tap.touchstart(e,n,a)}touchmove(e,n,a){if(this._tapTime){if(this._swipePoint){if(a[0].identifier!==this._swipeTouch)return;const o=n[0],c=o.y-this._swipePoint.y;return this._swipePoint=o,e.preventDefault(),this._active=!0,{zoomDelta:c/128}}}else this._tap.touchmove(e,n,a)}touchend(e,n,a){if(this._tapTime)this._swipePoint&&a.length===0&&this.reset();else{const o=this._tap.touchend(e,n,a);o&&(this._tapTime=e.timeStamp,this._tapPoint=o)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Il{constructor(e,n,a){this._el=e,this._mousePan=n,this._touchPan=a}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Pl{constructor(e,n,a){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=n,this._mousePitch=a}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 wo{constructor(e,n,a,o){this._el=e,this._touchZoom=n,this._touchRotate=a,this._tapDragZoom=o,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class Wn{constructor(e,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=e,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=se.create("div","maplibregl-cooperative-gesture-screen",e);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const a=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),o=document.createElement("div");o.className="maplibregl-desktop-message",o.textContent=n,this._container.appendChild(o);const c=document.createElement("div");c.className="maplibregl-mobile-message",c.textContent=a,this._container.appendChild(c),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(se.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new p.k("cooperativegestureprevented",{gestureType:e,originalEvent:n})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const tr=h=>h.zoom||h.drag||h.pitch||h.rotate;class ze extends p.k{}function ma(h){return h.panDelta&&h.panDelta.mag()||h.zoomDelta||h.bearingDelta||h.pitchDelta}class To{constructor(e,n){this.handleWindowEvent=o=>{this.handleEvent(o,`${o.type}Window`)},this.handleEvent=(o,c)=>{if(o.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const m=o.type==="renderFrame"?void 0:o,_={needsRenderFrame:!1},y={},b={},T=o.touches,S=T?this._getMapTouches(T):void 0,k=S?se.touchPos(this._map.getCanvas(),S):se.mousePos(this._map.getCanvas(),o);for(const{handlerName:N,handler:q,allowed:Z}of this._handlers){if(!q.isEnabled())continue;let X;this._blockedByActive(b,Z,N)?q.reset():q[c||o.type]&&(X=q[c||o.type](o,k,S),this.mergeHandlerResult(_,y,X,N,m),X&&X.needsRenderFrame&&this._triggerRenderFrame()),(X||q.isActive())&&(b[N]=q)}const D={};for(const N in this._previousActiveHandlers)b[N]||(D[N]=m);this._previousActiveHandlers=b,(Object.keys(D).length||ma(_))&&(this._changes.push([_,y,D]),this._triggerRenderFrame()),(Object.keys(b).length||ma(_))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:B}=_;B&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],B(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ho(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const a=this._el;this._listeners=[[a,"touchstart",{passive:!0}],[a,"touchmove",{passive:!1}],[a,"touchend",void 0],[a,"touchcancel",void 0],[a,"mousedown",void 0],[a,"mousemove",void 0],[a,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[a,"mouseover",void 0],[a,"mouseout",void 0],[a,"dblclick",void 0],[a,"click",void 0],[a,"keydown",{capture:!1}],[a,"keyup",void 0],[a,"wheel",{passive:!1}],[a,"contextmenu",void 0],[window,"blur",void 0]];for(const[o,c,m]of this._listeners)se.addEventListener(o,c,o===document?this.handleWindowEvent:this.handleEvent,m)}destroy(){for(const[e,n,a]of this._listeners)se.removeEventListener(e,n,e===document?this.handleWindowEvent:this.handleEvent,a)}_addDefaultHandlers(e){const n=this._map,a=n.getCanvasContainer();this._add("mapEvent",new Tl(n,e));const o=n.boxZoom=new qi(n,e);this._add("boxZoom",o),e.interactive&&e.boxZoom&&o.enable();const c=n.cooperativeGestures=new Wn(n,e.cooperativeGestures);this._add("cooperativeGestures",c),e.cooperativeGestures&&c.enable();const m=new Hn(n),_=new wc(n);n.doubleClickZoom=new Sn(_,m),this._add("tapZoom",m),this._add("clickZoom",_),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();const y=new Tc;this._add("tapDragZoom",y);const b=n.touchPitch=new Xn(n);this._add("touchPitch",b),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);const T=mo(e),S=go(e);n.dragRotate=new Pl(e,T,S),this._add("mouseRotate",T,["mousePitch"]),this._add("mousePitch",S,["mouseRotate"]),e.interactive&&e.dragRotate&&n.dragRotate.enable();const k=(({enable:X,clickTolerance:F})=>{const Y=new ua({checkCorrectEvent:ee=>se.mouseButton(ee)===0&&!ee.ctrlKey});return new $r({clickTolerance:F,move:(ee,ae)=>({around:ae,panDelta:ae.sub(ee)}),activateOnStart:!0,moveStateManager:Y,enable:X,assignEvents:da})})(e),D=new Tn(e,n);n.dragPan=new Il(a,k,D),this._add("mousePan",k),this._add("touchPan",D,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);const B=new vo,N=new yo;n.touchZoomRotate=new wo(a,N,B,y),this._add("touchRotate",B,["touchPan","touchZoom"]),this._add("touchZoom",N,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);const q=n.scrollZoom=new fr(n,()=>this._triggerRenderFrame());this._add("scrollZoom",q,["mousePan"]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);const Z=n.keyboard=new er(n);this._add("keyboard",Z),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new Bt(n))}_add(e,n,a){this._handlers.push({handlerName:e,handler:n,allowed:a}),this._handlersById[e]=n}stop(e){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!tr(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,n,a){for(const o in e)if(o!==a&&(!n||n.indexOf(o)<0))return!0;return!1}_getMapTouches(e){const n=[];for(const a of e)this._el.contains(a.target)&&n.push(a);return n}mergeHandlerResult(e,n,a,o,c){if(!a)return;p.e(e,a);const m={handlerName:o,originalEvent:a.originalEvent||c};a.zoomDelta!==void 0&&(n.zoom=m),a.panDelta!==void 0&&(n.drag=m),a.pitchDelta!==void 0&&(n.pitch=m),a.bearingDelta!==void 0&&(n.rotate=m)}_applyChanges(){const e={},n={},a={};for(const[o,c,m]of this._changes)o.panDelta&&(e.panDelta=(e.panDelta||new p.P(0,0))._add(o.panDelta)),o.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+o.zoomDelta),o.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+o.bearingDelta),o.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+o.pitchDelta),o.around!==void 0&&(e.around=o.around),o.pinchAround!==void 0&&(e.pinchAround=o.pinchAround),o.noInertia&&(e.noInertia=o.noInertia),p.e(n,c),p.e(a,m);this._updateMapTransform(e,n,a),this._changes=[]}_updateMapTransform(e,n,a){const o=this._map,c=o._getTransformForUpdate(),m=o.terrain;if(!(ma(e)||m&&this._terrainMovement))return this._fireEvents(n,a,!0);let{panDelta:_,zoomDelta:y,bearingDelta:b,pitchDelta:T,around:S,pinchAround:k}=e;k!==void 0&&(S=k),o._stop(!0),S=S||o.transform.centerPoint;const D=c.pointLocation(_?S.sub(_):S);b&&(c.bearing+=b),T&&(c.pitch+=T),y&&(c.zoom+=y),m?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?c.center=c.pointLocation(c.centerPoint.sub(_)):c.setLocationAtPoint(D,S):(this._terrainMovement=!0,this._map._elevationFreeze=!0,c.setLocationAtPoint(D,S)):c.setLocationAtPoint(D,S),o._applyUpdatedTransform(c),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(n,a,!0)}_fireEvents(e,n,a){const o=tr(this._eventsInProgress),c=tr(e),m={};for(const S in e){const{originalEvent:k}=e[S];this._eventsInProgress[S]||(m[`${S}start`]=k),this._eventsInProgress[S]=e[S]}!o&&c&&this._fireEvent("movestart",c.originalEvent);for(const S in m)this._fireEvent(S,m[S]);c&&this._fireEvent("move",c.originalEvent);for(const S in e){const{originalEvent:k}=e[S];this._fireEvent(S,k)}const _={};let y;for(const S in this._eventsInProgress){const{handlerName:k,originalEvent:D}=this._eventsInProgress[S];this._handlersById[k].isActive()||(delete this._eventsInProgress[S],y=n[k]||D,_[`${S}end`]=y)}for(const S in _)this._fireEvent(S,_[S]);const b=tr(this._eventsInProgress),T=(o||c)&&!b;if(T&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const S=this._map._getTransformForUpdate();S.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(S)}if(a&&T){this._updatingCamera=!0;const S=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),k=D=>D!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new ze("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Al extends p.E{constructor(e,n){super(),this._renderFrameCallback=()=>{const a=Math.min((de.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(a)),a<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new p.N(this.transform.center.lng,this.transform.center.lat)}setCenter(e,n){return this.jumpTo({center:e},n)}panBy(e,n,a){return e=p.P.convert(e).mult(-1),this.panTo(this.transform.center,p.e({offset:e},n),a)}panTo(e,n,a){return this.easeTo(p.e({center:e},n),a)}getZoom(){return this.transform.zoom}setZoom(e,n){return this.jumpTo({zoom:e},n),this}zoomTo(e,n,a){return this.easeTo(p.e({zoom:e},n),a)}zoomIn(e,n){return this.zoomTo(this.getZoom()+1,e,n),this}zoomOut(e,n){return this.zoomTo(this.getZoom()-1,e,n),this}getBearing(){return this.transform.bearing}setBearing(e,n){return this.jumpTo({bearing:e},n),this}getPadding(){return this.transform.padding}setPadding(e,n){return this.jumpTo({padding:e},n),this}rotateTo(e,n,a){return this.easeTo(p.e({bearing:e},n),a)}resetNorth(e,n){return this.rotateTo(0,p.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(p.e({bearing:0,pitch:0,duration:1e3},e),n),this}snapToNorth(e,n){return Math.abs(this.getBearing()){if(this._zooming&&(o.zoom=p.y.number(c,q,fe)),this._rotating&&(o.bearing=p.y.number(m,b,fe)),this._pitching&&(o.pitch=p.y.number(_,T,fe)),this._padding&&(o.interpolatePadding(y,S,fe),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(fe),Y)o.setLocationAtPoint(Y,ee);else{const _e=o.zoomScale(o.zoom-c),Pe=q>c?Math.min(2,F):Math.max(.5,F),ke=Math.pow(Pe,1-fe),we=o.unproject(Z.add(X.mult(fe*ke)).mult(_e));o.setLocationAtPoint(o.renderWorldCopies?we.wrap():we,D)}this._applyUpdatedTransform(o),this._fireMoveEvents(n)},fe=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,fe)},e),this}_prepareEase(e,n,a={}){this._moving=!0,n||a.moving||this.fire(new p.k("movestart",e)),this._zooming&&!a.zooming&&this.fire(new p.k("zoomstart",e)),this._rotating&&!a.rotating&&this.fire(new p.k("rotatestart",e)),this._pitching&&!a.pitching&&this.fire(new p.k("pitchstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){const a=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(a-(n-(a*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.elevation=p.y.number(this._elevationStart,this._elevationTarget,e)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){const n=e.getCameraPosition(),a=this.terrain.getElevationForLngLatZoom(n.lngLat,e.zoom);if(n.altitudethis._elevateCameraIfInsideTerrain(o)),this.transformCameraUpdate&&n.push(o=>this.transformCameraUpdate(o)),!n.length)return;const a=e.clone();for(const o of n){const c=a.clone(),{center:m,zoom:_,pitch:y,bearing:b,elevation:T}=o(c);m&&(c.center=m),_!==void 0&&(c.zoom=_),y!==void 0&&(c.pitch=y),b!==void 0&&(c.bearing=b),T!==void 0&&(c.elevation=T),a.apply(c)}this.transform.apply(a)}_fireMoveEvents(e){this.fire(new p.k("move",e)),this._zooming&&this.fire(new p.k("zoom",e)),this._rotating&&this.fire(new p.k("rotate",e)),this._pitching&&this.fire(new p.k("pitch",e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const a=this._zooming,o=this._rotating,c=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,a&&this.fire(new p.k("zoomend",e)),o&&this.fire(new p.k("rotateend",e)),c&&this.fire(new p.k("pitchend",e)),this.fire(new p.k("moveend",e))}flyTo(e,n){var a;if(!e.essential&&de.prefersReducedMotion){const Ce=p.M(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Ce,n)}this.stop(),e=p.e({offset:[0,0],speed:1.2,curve:1.42,easing:p.b9},e);const o=this._getTransformForUpdate(),c=o.zoom,m=o.bearing,_=o.pitch,y=o.padding,b="bearing"in e?this._normalizeBearing(e.bearing,m):m,T="pitch"in e?+e.pitch:_,S="padding"in e?e.padding:o.padding,k=p.P.convert(e.offset);let D=o.centerPoint.add(k);const B=o.pointLocation(D),{center:N,zoom:q}=o.getConstrained(p.N.convert(e.center||B),(a=e.zoom)!==null&&a!==void 0?a:c);this._normalizeCenter(N,o);const Z=o.zoomScale(q-c),X=o.project(B),F=o.project(N).sub(X);let Y=e.curve;const ee=Math.max(o.width,o.height),ae=ee/Z,fe=F.mag();if("minZoom"in e){const Ce=p.ac(Math.min(e.minZoom,c,q),o.minZoom,o.maxZoom),qe=ee/o.zoomScale(Ce-c);Y=Math.sqrt(qe/fe*2)}const _e=Y*Y;function Pe(Ce){const qe=(ae*ae-ee*ee+(Ce?-1:1)*_e*_e*fe*fe)/(2*(Ce?ae:ee)*_e*fe);return Math.log(Math.sqrt(qe*qe+1)-qe)}function ke(Ce){return(Math.exp(Ce)-Math.exp(-Ce))/2}function we(Ce){return(Math.exp(Ce)+Math.exp(-Ce))/2}const be=Pe(!1);let Re=function(Ce){return we(be)/we(be+Y*Ce)},Xe=function(Ce){return ee*((we(be)*(ke(qe=be+Y*Ce)/we(qe))-ke(be))/_e)/fe;var qe},Se=(Pe(!0)-be)/Y;if(Math.abs(fe)<1e-6||!isFinite(Se)){if(Math.abs(ee-ae)<1e-6)return this.easeTo(e,n);const Ce=ae0,Re=qe=>Math.exp(Ce*Y*qe)}return e.duration="duration"in e?+e.duration:1e3*Se/("screenSpeed"in e?+e.screenSpeed/Y:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=m!==b,this._pitching=T!==_,this._padding=!o.isPaddingEqual(S),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(N),this._ease(Ce=>{const qe=Ce*Se,Tt=1/Re(qe);o.zoom=Ce===1?q:c+o.scaleZoom(Tt),this._rotating&&(o.bearing=p.y.number(m,b,Ce)),this._pitching&&(o.pitch=p.y.number(_,T,Ce)),this._padding&&(o.interpolatePadding(y,S,Ce),D=o.centerPoint.add(k)),this.terrain&&!e.freezeElevation&&this._updateElevation(Ce);const Ye=Ce===1?N:o.unproject(X.add(F.mult(Xe(qe))).mult(Tt));o.setLocationAtPoint(o.renderWorldCopies?Ye.wrap():Ye,D),this._applyUpdatedTransform(o),this._fireMoveEvents(n)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,n){var a;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const o=this._onEaseEnd;delete this._onEaseEnd,o.call(this,n)}return e||(a=this.handlers)===null||a===void 0||a.stop(!1),this}_ease(e,n,a){a.animate===!1||a.duration===0?(e(1),n()):(this._easeStart=de.now(),this._easeOptions=a,this._onEaseFrame=e,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=p.b3(e,-180,180);const a=Math.abs(e-n);return Math.abs(e-360-n)180?-360:a<-180?360:0}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(p.N.convert(e),this.transform.tileZoom)-this.transform.elevation:null}}const Kn={compact:!0,customAttribution:'MapLibre'};class Jn{constructor(e=Kn){this._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")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?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","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=se.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=se.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=se.create("div","maplibregl-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(){se.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(e,n){const a=this._map._getUIString(`AttributionControl.${n}`);e.title=a,e.setAttribute("aria-label",a)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(o=>typeof o!="string"?"":o)):typeof this.options.customAttribution=="string"&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const o=this._map.style.stylesheet;this.styleOwner=o.owner,this.styleId=o.id}const n=this._map.style.sourceCaches;for(const o in n){const c=n[o];if(c.used||c.usedForTerrain){const m=c.getSource();m.attribution&&e.indexOf(m.attribution)<0&&e.push(m.attribution)}}e=e.filter(o=>String(o).trim()),e.sort((o,c)=>o.length-c.length),e=e.filter((o,c)=>{for(let m=c+1;m=0)return!1;return!0});const a=e.join(" | ");a!==this._attribHTML&&(this._attribHTML=a,e.length?(this._innerContainer.innerHTML=a,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class So{constructor(e={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const a=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&a.classList.add("maplibregl-compact"):a.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=se.create("div","maplibregl-ctrl");const n=se.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){se.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class st{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const n=++this._id;return this._queue.push({callback:e,id:n,cancelled:!1}),n}remove(e){const n=this._currentlyRunning,a=n?this._queue.concat(n):this._queue;for(const o of a)if(o.id===e)return void(o.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const a of n)if(!a.cancelled&&(a.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Io=p.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Sc extends p.E{constructor(e){super(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,e.usedForTerrain=!0,e.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];const a={};for(const o of e.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))a[o.key]=!0,this._renderableTilesKeys.push(o.key),this._tiles[o.key]||(o.posMatrix=new Float64Array(16),p.aP(o.posMatrix,0,p.X,0,p.X,0,1),this._tiles[o.key]=new Jr(o,this.tileSize));for(const o in this._tiles)a[o]||delete this._tiles[o]}freeRtt(e){for(const n in this._tiles){const a=this._tiles[n];(!e||a.tileID.equals(e)||a.tileID.isChildOf(e)||e.isChildOf(a.tileID))&&(a.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e){const n={};for(const a of this._renderableTilesKeys){const o=this._tiles[a].tileID;if(o.canonical.equals(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16),p.aP(c.posMatrix,0,p.X,0,p.X,0,1),n[a]=c}else if(o.canonical.isChildOf(e.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=o.canonical.z-e.canonical.z,_=o.canonical.x-(o.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,b,0,b,0,1),p.J(c.posMatrix,c.posMatrix,[-_*b,-y*b,0]),n[a]=c}else if(e.canonical.isChildOf(o.canonical)){const c=e.clone();c.posMatrix=new Float64Array(16);const m=e.canonical.z-o.canonical.z,_=e.canonical.x-(e.canonical.x>>m<>m<>m;p.aP(c.posMatrix,0,p.X,0,p.X,0,1),p.J(c.posMatrix,c.posMatrix,[_*b,y*b,0]),p.K(c.posMatrix,c.posMatrix,[1/2**m,1/2**m,0]),n[a]=c}}return n}getSourceTile(e,n){const a=this.sourceCache._source;let o=e.overscaledZ-this.deltaZoom;if(o>a.maxzoom&&(o=a.maxzoom),o=a.minzoom&&(!c||!c.dem);)c=this.sourceCache.getTileByID(e.scaledTo(o--).key);return c}tilesAfterTime(e=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=e)}}class Po{constructor(e,n,a){this.painter=e,this.sourceCache=new Sc(n),this.options=a,this.exaggeration=typeof a.exaggeration=="number"?a.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,a,o=p.X){var c;if(!(n>=0&&n=0&&ae.canonical.z&&(e.canonical.z>=o?c=e.canonical.z-o:p.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const m=e.canonical.x-(e.canonical.x>>c<>c<>8<<4|c>>8,n[m+3]=0;const a=new p.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),o=new et(e,a,e.gl.RGBA,{premultiply:!1});return o.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=o,o}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),a=this.painter.context,o=a.gl,c=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),m=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),_=Math.round(this.painter.height/devicePixelRatio);a.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),o.readPixels(c,_-m-1,1,1,o.RGBA,o.UNSIGNED_BYTE,n),a.bindFramebuffer.set(null);const y=n[0]+(n[2]>>4<<8),b=n[1]+((15&n[2])<<8),T=this.coordsIndex[255-n[3]],S=T&&this.sourceCache.getTileByID(T);if(!S)return null;const k=this._coordsTextureSize,D=(1<e.id!==n),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)===!1}}const Yn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Cl{constructor(e,n){this.painter=e,this.terrain=n,this.pool=new Ic(e.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter(a=>!e._layers[a].isHidden(n)),this._coordsDescendingInv={};for(const a in e.sourceCaches){this._coordsDescendingInv[a]={};const o=e.sourceCaches[a].getVisibleCoordinates();for(const c of o){const m=this.terrain.sourceCache.getTerrainCoords(c);for(const _ in m)this._coordsDescendingInv[a][_]||(this._coordsDescendingInv[a][_]=[]),this._coordsDescendingInv[a][_].push(m[_])}}this._coordsDescendingInvStr={};for(const a of e._order){const o=e._layers[a],c=o.source;if(Yn[o.type]&&!this._coordsDescendingInvStr[c]){this._coordsDescendingInvStr[c]={};for(const m in this._coordsDescendingInv[c])this._coordsDescendingInvStr[c][m]=this._coordsDescendingInv[c][m].map(_=>_.key).sort().join()}}for(const a of this._renderableTiles)for(const o in this._coordsDescendingInvStr){const c=this._coordsDescendingInvStr[o][a.tileID.key];c&&c!==a.rttCoords[o]&&(a.rtt=[])}}renderLayer(e){if(e.isHidden(this.painter.transform.zoom))return!1;const n=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yn[n]&&(this._prevType&&Yn[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(Yn[this._prevType]||Yn[n]&&o){this._prevType=n;const c=this._stacks.length-1,m=this._stacks[c]||[];for(const _ of this._renderableTiles){if(this.pool.isFull()&&(vl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(_),_.rtt[c]){const b=this.pool.getObjectForId(_.rtt[c].id);if(b.stamp===_.rtt[c].stamp){this.pool.useObject(b);continue}}const y=this.pool.getOrCreateFreeObject();this.pool.useObject(y),this.pool.stampObject(y),_.rtt[c]={id:y.id,stamp:y.stamp},a.context.bindFramebuffer.set(y.fbo.framebuffer),a.context.clear({color:p.aM.transparent,stencil:0}),a.currentStencilSource=void 0;for(let b=0;b{h.touchstart=h.dragStart,h.touchmoveWindow=h.dragMove,h.touchend=h.dragEnd},Ac={showCompass:!0,showZoom:!0,visualizePitch:!1};class Cc{constructor(e,n,a=!1){this.mousedown=m=>{this.startMouse(p.e({},m,{ctrlKey:!0,preventDefault:()=>m.preventDefault()}),se.mousePos(this.element,m)),se.addEventListener(window,"mousemove",this.mousemove),se.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=m=>{this.moveMouse(m,se.mousePos(this.element,m))},this.mouseup=m=>{this.mouseRotate.dragEnd(m),this.mousePitch&&this.mousePitch.dragEnd(m),this.offTemp()},this.touchstart=m=>{m.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.startTouch(m,this._startPos),se.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.addEventListener(window,"touchend",this.touchend))},this.touchmove=m=>{m.targetTouches.length!==1?this.reset():(this._lastPos=se.touchPos(this.element,m.targetTouches)[0],this.moveTouch(m,this._lastPos))},this.touchend=m=>{m.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const o=e.dragRotate._mouseRotate.getClickTolerance(),c=e.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=mo({clickTolerance:o,enable:!0}),this.touchRotate=(({enable:m,clickTolerance:_,bearingDegreesPerPixelMoved:y=.8})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({bearingDelta:(S.x-T.x)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:o,enable:!0}),this.map=e,a&&(this.mousePitch=go({clickTolerance:c,enable:!0}),this.touchPitch=(({enable:m,clickTolerance:_,pitchDegreesPerPixelMoved:y=-.5})=>{const b=new fo;return new $r({clickTolerance:_,move:(T,S)=>({pitchDelta:(S.y-T.y)*y}),moveStateManager:b,enable:m,assignEvents:Co})})({clickTolerance:c,enable:!0})),se.addEventListener(n,"mousedown",this.mousedown),se.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),se.addEventListener(n,"touchcancel",this.reset)}startMouse(e,n){this.mouseRotate.dragStart(e,n),this.mousePitch&&this.mousePitch.dragStart(e,n),se.disableDrag()}startTouch(e,n){this.touchRotate.dragStart(e,n),this.touchPitch&&this.touchPitch.dragStart(e,n),se.disableDrag()}moveMouse(e,n){const a=this.map,{bearingDelta:o}=this.mouseRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.mousePitch){const{pitchDelta:c}=this.mousePitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}moveTouch(e,n){const a=this.map,{bearingDelta:o}=this.touchRotate.dragMove(e,n)||{};if(o&&a.setBearing(a.getBearing()+o),this.touchPitch){const{pitchDelta:c}=this.touchPitch.dragMove(e,n)||{};c&&a.setPitch(a.getPitch()+c)}}off(){const e=this.element;se.removeEventListener(e,"mousedown",this.mousedown),se.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend),se.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){se.enableDrag(),se.removeEventListener(window,"mousemove",this.mousemove),se.removeEventListener(window,"mouseup",this.mouseup),se.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),se.removeEventListener(window,"touchend",this.touchend)}}let Zi;function wt(h,e,n){const a=new p.N(h.lng,h.lat);if(h=new p.N(h.lng,h.lat),e){const o=new p.N(h.lng-360,h.lat),c=new p.N(h.lng+360,h.lat),m=n.locationPoint(h).distSqr(e);n.locationPoint(o).distSqr(e)180;){const o=n.locationPoint(h);if(o.x>=0&&o.y>=0&&o.x<=n.width&&o.y<=n.height)break;h.lng>n.center.lng?h.lng-=360:h.lng+=360}return h.lng!==a.lng&&n.locationPoint(h).y>n.height/2-n.getHorizon()?h:a}const Qn={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function ga(h,e,n){const a=h.classList;for(const o in Qn)a.remove(`maplibregl-${n}-anchor-${o}`);a.add(`maplibregl-${n}-anchor-${e}`)}class _a extends p.E{constructor(e){if(super(),this._onKeyPress=n=>{const a=n.code,o=n.charCode||n.keyCode;a!=="Space"&&a!=="Enter"&&o!==32&&o!==13||this.togglePopup()},this._onMapClick=n=>{const a=n.originalEvent.target,o=this._element;this._popup&&(a===o||o.contains(a))&&this.togglePopup()},this._update=n=>{var a;if(!this._map)return;const o=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!o)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?wt(this._lngLat,this._flatPos,this._map.transform):(a=this._lngLat)===null||a===void 0?void 0:a.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let c="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?c=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(c=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let m="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?m="rotateX(0deg)":this._pitchAlignment==="map"&&(m=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||n&&n.type!=="moveend"||(this._pos=this._pos.round()),se.setTransform(this._element,`${Qn[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${m} ${c}`),de.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const a=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=a}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new p.k("dragstart"))),this.fire(new p.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new p.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!=="auto"?e.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(e==null?void 0:e.opacity,e==null?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=p.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=se.create("div");const n=se.createNS("http://www.w3.org/2000/svg","svg"),a=41,o=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${a}px`),n.setAttributeNS(null,"width",`${o}px`),n.setAttributeNS(null,"viewBox",`0 0 ${o} ${a}`);const c=se.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"stroke","none"),c.setAttributeNS(null,"stroke-width","1"),c.setAttributeNS(null,"fill","none"),c.setAttributeNS(null,"fill-rule","evenodd");const m=se.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"fill-rule","nonzero");const _=se.createNS("http://www.w3.org/2000/svg","g");_.setAttributeNS(null,"transform","translate(3.0, 29.0)"),_.setAttributeNS(null,"fill","#000000");const y=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const Z of y){const X=se.createNS("http://www.w3.org/2000/svg","ellipse");X.setAttributeNS(null,"opacity","0.04"),X.setAttributeNS(null,"cx","10.5"),X.setAttributeNS(null,"cy","5.80029008"),X.setAttributeNS(null,"rx",Z.rx),X.setAttributeNS(null,"ry",Z.ry),_.appendChild(X)}const b=se.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"fill",this._color);const T=se.createNS("http://www.w3.org/2000/svg","path");T.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),b.appendChild(T);const S=se.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"opacity","0.25"),S.setAttributeNS(null,"fill","#000000");const k=se.createNS("http://www.w3.org/2000/svg","path");k.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),S.appendChild(k);const D=se.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"transform","translate(6.0, 7.0)"),D.setAttributeNS(null,"fill","#FFFFFF");const B=se.createNS("http://www.w3.org/2000/svg","g");B.setAttributeNS(null,"transform","translate(8.0, 8.0)");const N=se.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#000000"),N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962");const q=se.createNS("http://www.w3.org/2000/svg","circle");q.setAttributeNS(null,"fill","#FFFFFF"),q.setAttributeNS(null,"cx","5.5"),q.setAttributeNS(null,"cy","5.5"),q.setAttributeNS(null,"r","5.4999962"),B.appendChild(N),B.appendChild(q),m.appendChild(_),m.appendChild(b),m.appendChild(S),m.appendChild(D),m.appendChild(B),n.appendChild(m),n.setAttributeNS(null,"height",a*this._scale+"px"),n.setAttributeNS(null,"width",o*this._scale+"px"),this._element.appendChild(n),this._offset=p.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),ga(this._element,this._anchor,"marker"),e&&e.className)for(const n of e.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),se.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=p.N.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const o=Math.abs(13.5)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[o,-1*(38.1-13.5+o)],"bottom-right":[-o,-1*(38.1-13.5+o)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var n,a;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const o=this._map,c=o.terrain.depthAtPoint(this._pos),m=o.terrain.getElevationForLngLatZoom(this._lngLat,o.transform.tileZoom);if(o.transform.lngLatToCameraDepth(this._lngLat,m)-c<.006)return void(this._element.style.opacity=this._opacity);const _=-this._offset.y/o.transform._pixelPerMeter,y=Math.sin(o.getPitch()*Math.PI/180)*_,b=o.terrain.depthAtPoint(new p.P(this._pos.x,this._pos.y-this._offset.y)),T=o.transform.lngLatToCameraDepth(this._lngLat,m+y)-b>.006;!((a=this._popup)===null||a===void 0)&&a.isOpen()&&T&&this._popup.remove(),this._element.style.opacity=T?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=p.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!=="auto"?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,n){return e===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),e!==void 0&&(this._opacity=e),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const kl={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let zs=0,Ds=!1;const zr={maxWidth:100,unit:"metric"};function Ls(h,e,n){const a=n&&n.maxWidth||100,o=h._container.clientHeight/2,c=h.unproject([0,o]),m=h.unproject([a,o]),_=c.distanceTo(m);if(n&&n.unit==="imperial"){const y=3.2808*_;y>5280?Le(e,a,y/5280,h._getUIString("ScaleControl.Miles")):Le(e,a,y,h._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?Le(e,a,_/1852,h._getUIString("ScaleControl.NauticalMiles")):_>=1e3?Le(e,a,_/1e3,h._getUIString("ScaleControl.Kilometers")):Le(e,a,_,h._getUIString("ScaleControl.Meters"))}function Le(h,e,n,a){const o=function(c){const m=Math.pow(10,`${Math.floor(c)}`.length-1);let _=c/m;return _=_>=10?10:_>=5?5:_>=3?3:_>=2?2:_>=1?1:function(y){const b=Math.pow(10,Math.ceil(-Math.log(y)/Math.LN10));return Math.round(y*b)/b}(_),m*_}(n);h.style.width=e*(o/n)+"px",h.innerHTML=`${o} ${a}`}const je={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},ya=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function xa(h){if(h){if(typeof h=="number"){const e=Math.round(Math.abs(h)/Math.SQRT2);return{center:new p.P(0,0),top:new p.P(0,h),"top-left":new p.P(e,e),"top-right":new p.P(-e,e),bottom:new p.P(0,-h),"bottom-left":new p.P(e,-e),"bottom-right":new p.P(-e,-e),left:new p.P(h,0),right:new p.P(-h,0)}}if(h instanceof p.P||Array.isArray(h)){const e=p.P.convert(h);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:p.P.convert(h.center||[0,0]),top:p.P.convert(h.top||[0,0]),"top-left":p.P.convert(h["top-left"]||[0,0]),"top-right":p.P.convert(h["top-right"]||[0,0]),bottom:p.P.convert(h.bottom||[0,0]),"bottom-left":p.P.convert(h["bottom-left"]||[0,0]),"bottom-right":p.P.convert(h["bottom-right"]||[0,0]),left:p.P.convert(h.left||[0,0]),right:p.P.convert(h.right||[0,0])}}return xa(new p.P(0,0))}const Mo=Je;M.AJAXError=p.bh,M.Evented=p.E,M.LngLat=p.N,M.MercatorCoordinate=p.Z,M.Point=p.P,M.addProtocol=p.bi,M.config=p.a,M.removeProtocol=p.bj,M.AttributionControl=Jn,M.BoxZoomHandler=qi,M.CanvasSource=Ji,M.CooperativeGesturesHandler=Wn,M.DoubleClickZoomHandler=Sn,M.DragPanHandler=Il,M.DragRotateHandler=Pl,M.EdgeInsets=Zn,M.FullscreenControl=class extends p.E{constructor(h={}){super(),this._onFullscreenChange=()=>{var e;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((e=n==null?void 0:n.shadowRoot)===null||e===void 0)&&e.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,h&&h.container&&(h.container instanceof HTMLElement?this._container=h.container:p.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(h){return this._map=h,this._container||(this._container=this._map.getContainer()),this._controlContainer=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){se.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const h=this._fullscreenButton=se.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);se.create("span","maplibregl-ctrl-icon",h).setAttribute("aria-hidden","true"),h.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const h=this._getTitle();this._fullscreenButton.setAttribute("aria-label",h),this._fullscreenButton.title=h}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new p.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new p.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},M.GeoJSONSource=fs,M.GeolocateControl=class extends p.E{constructor(h){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new p.k("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new p.k("geolocate",e)),this._finish()}},this._updateCamera=e=>{const n=new p.N(e.coords.longitude,e.coords.latitude),a=e.coords.accuracy,o=this._map.getBearing(),c=p.e({bearing:o},this.options.fitBoundsOptions),m=le.fromLngLat(n,a);this._map.fitBounds(m,c,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const n=new p.N(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(this.options.trackUserLocation)if(e.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ds)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new p.k("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=se.create("button","maplibregl-ctrl-geolocate",this._container),se.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(e===!1){p.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=se.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new _a({element:this._dotElement}),this._circleElement=se.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new _a({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new p.k("trackuserlocationend")),this.fire(new p.k("userlocationlostfocus")))})}},this.options=p.e({},kl,h)}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return p._(this,arguments,void 0,function*(e=!1){if(Zi!==void 0&&!e)return Zi;if(window.navigator.permissions===void 0)return Zi=!!window.navigator.geolocation,Zi;try{Zi=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Zi=!!window.navigator.geolocation}return Zi})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),se.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,zs=0,Ds=!1}_isOutOfMapMaxBounds(h){const e=this._map.getMaxBounds(),n=h.coords;return e&&(n.longitudee.getEast()||n.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const h=this._map.getBounds(),e=h.getSouthEast(),n=h.getNorthEast(),a=e.distanceTo(n),o=Math.ceil(this._accuracy/(a/this._map._container.clientHeight)*2);this._circleElement.style.width=`${o}px`,this._circleElement.style.height=`${o}px`}trigger(){if(!this._setup)return p.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new p.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":zs--,Ds=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new p.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new p.k("trackuserlocationstart")),this.fire(new p.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let h;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),zs++,zs>1?(h={maximumAge:6e5,timeout:0},Ds=!0):(h=this.options.positionOptions,Ds=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,h)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},M.Hash=oa,M.ImageSource=Nr,M.KeyboardHandler=er,M.LngLatBounds=le,M.LogoControl=So,M.Map=class extends Al{constructor(h){p.bf.mark(p.bg.create);const e=Object.assign(Object.assign({},Pc),h);if(e.minZoom!=null&&e.maxZoom!=null&&e.minZoom>e.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(e.minPitch!=null&&e.maxPitch!=null&&e.minPitch>e.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(e.minPitch!=null&&e.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(e.maxPitch!=null&&e.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Gn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),{bearingSnap:e.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new st,this._controls=[],this._mapId=p.a4(),this._contextLost=n=>{n.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new p.k("webglcontextlost",{originalEvent:n}))},this._contextRestored=n=>{this._setupPainter(),this.resize(),this._update(),this.fire(new p.k("webglcontextrestored",{originalEvent:n}))},this._onMapScroll=n=>{if(n.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=e.preserveDrawingBuffer===!0,this._antialias=e.antialias===!0,this._trackResize=e.trackResize===!0,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles===!0,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=e.crossSourceCollisions===!0,this._collectResourceTiming=e.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ao),e.locale),this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this.transformCameraUpdate=e.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=e.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Mt.addThrottleControl(()=>this.isMoving()),this._requestManager=new ln(e.transformRequest),typeof e.container=="string"){if(this._container=document.getElementById(e.container),!this._container)throw new Error(`Container '${e.container}' not found.`)}else{if(!(e.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let n=!1;const a=As(o=>{this._trackResize&&!this._removed&&(this.resize(o),this.redraw())},50);this._resizeObserver=new ResizeObserver(o=>{n?a(o):n=!0}),this._resizeObserver.observe(this._container)}this.handlers=new To(this,e),this._hash=e.hash&&new oa(typeof e.hash=="string"&&e.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:e.center,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,p.e({},e.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new Jn(typeof e.attributionControl=="boolean"?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new So,e.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",n=>{this._update(n.dataType==="style"),this.fire(new p.k(`${n.dataType}data`,n))}),this.on("dataloading",n=>{this.fire(new p.k(`${n.dataType}dataloading`,n))}),this.on("dataabort",n=>{this.fire(new p.k("sourcedataabort",n))})}_getMapId(){return this._mapId}addControl(h,e){if(e===void 0&&(e=h.getDefaultPosition?h.getDefaultPosition():"top-right"),!h||!h.onAdd)return this.fire(new p.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=h.onAdd(this);this._controls.push(h);const a=this._controlPositions[e];return e.indexOf("bottom")!==-1?a.insertBefore(n,a.firstChild):a.appendChild(n),this}removeControl(h){if(!h||!h.onRemove)return this.fire(new p.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const e=this._controls.indexOf(h);return e>-1&&this._controls.splice(e,1),h.onRemove(this),this}hasControl(h){return this._controls.indexOf(h)>-1}calculateCameraOptionsFromTo(h,e,n,a){return a==null&&this.terrain&&(a=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(h,e,n,a)}resize(h){var e;const n=this._containerDimensions(),a=n[0],o=n[1],c=this._getClampedPixelRatio(a,o);if(this._resizeCanvas(a,o,c),this.painter.resize(a,o,c),this.painter.overLimit()){const _=this.painter.context.gl;this._maxCanvasSize=[_.drawingBufferWidth,_.drawingBufferHeight];const y=this._getClampedPixelRatio(a,o);this._resizeCanvas(a,o,y),this.painter.resize(a,o,y)}this.transform.resize(a,o),(e=this._requestedCameraState)===null||e===void 0||e.resize(a,o);const m=!this._moving;return m&&(this.stop(),this.fire(new p.k("movestart",h)).fire(new p.k("move",h))),this.fire(new p.k("resize",h)),m&&this.fire(new p.k("moveend",h)),this}_getClampedPixelRatio(h,e){const{0:n,1:a}=this._maxCanvasSize,o=this.getPixelRatio(),c=h*o,m=e*o;return Math.min(c>n?n/c:1,m>a?a/m:1)*o}getPixelRatio(){var h;return(h=this._overridePixelRatio)!==null&&h!==void 0?h:devicePixelRatio}setPixelRatio(h){this._overridePixelRatio=h,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(h){return this.transform.setMaxBounds(le.convert(h)),this._update()}setMinZoom(h){if((h=h??-2)>=-2&&h<=this.transform.maxZoom)return this.transform.minZoom=h,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=h,this._update(),this.getZoom()>h&&this.setZoom(h),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(h){if((h=h??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(h>=0&&h<=this.transform.maxPitch)return this.transform.minPitch=h,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(h>=this.transform.minPitch)return this.transform.maxPitch=h,this._update(),this.getPitch()>h&&this.setPitch(h),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(h){return this.transform.renderWorldCopies=h,this._update()}project(h){return this.transform.locationPoint(p.N.convert(h),this.style&&this.terrain)}unproject(h){return this.transform.pointLocation(p.P.convert(h),this.terrain)}isMoving(){var h;return this._moving||((h=this.handlers)===null||h===void 0?void 0:h.isMoving())}isZooming(){var h;return this._zooming||((h=this.handlers)===null||h===void 0?void 0:h.isZooming())}isRotating(){var h;return this._rotating||((h=this.handlers)===null||h===void 0?void 0:h.isRotating())}_createDelegatedListener(h,e,n){if(h==="mouseenter"||h==="mouseover"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:c=>{const m=e.filter(y=>this.getLayer(y)),_=m.length!==0?this.queryRenderedFeatures(c.point,{layers:m}):[];_.length?a||(a=!0,n.call(this,new ai(h,this,c.originalEvent,{features:_}))):a=!1},mouseout:()=>{a=!1}}}}if(h==="mouseleave"||h==="mouseout"){let a=!1;return{layers:e,listener:n,delegates:{mousemove:m=>{const _=e.filter(y=>this.getLayer(y));(_.length!==0?this.queryRenderedFeatures(m.point,{layers:_}):[]).length?a=!0:a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))},mouseout:m=>{a&&(a=!1,n.call(this,new ai(h,this,m.originalEvent)))}}}}{const a=o=>{const c=e.filter(_=>this.getLayer(_)),m=c.length!==0?this.queryRenderedFeatures(o.point,{layers:c}):[];m.length&&(o.features=m,n.call(this,o),delete o.features)};return{layers:e,listener:n,delegates:{[h]:a}}}}_saveDelegatedListener(h,e){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[h]=this._delegatedListeners[h]||[],this._delegatedListeners[h].push(e)}_removeDelegatedListener(h,e,n){if(!this._delegatedListeners||!this._delegatedListeners[h])return;const a=this._delegatedListeners[h];for(let o=0;oe.includes(m))){for(const m in c.delegates)this.off(m,c.delegates[m]);return void a.splice(o,1)}}}on(h,e,n){if(n===void 0)return super.on(h,e);const a=this._createDelegatedListener(h,typeof e=="string"?[e]:e,n);this._saveDelegatedListener(h,a);for(const o in a.delegates)this.on(o,a.delegates[o]);return this}once(h,e,n){if(n===void 0)return super.once(h,e);const a=typeof e=="string"?[e]:e,o=this._createDelegatedListener(h,a,n);for(const c in o.delegates){const m=o.delegates[c];o.delegates[c]=(..._)=>{this._removeDelegatedListener(h,a,n),m(..._)}}this._saveDelegatedListener(h,o);for(const c in o.delegates)this.once(c,o.delegates[c]);return this}off(h,e,n){return n===void 0?super.off(h,e):(this._removeDelegatedListener(h,typeof e=="string"?[e]:e,n),this)}queryRenderedFeatures(h,e){if(!this.style)return[];let n;const a=h instanceof p.P||Array.isArray(h),o=a?h:[[0,0],[this.transform.width,this.transform.height]];if(e=e||(a?{}:h)||{},o instanceof p.P||typeof o[0]=="number")n=[p.P.convert(o)];else{const c=p.P.convert(o[0]),m=p.P.convert(o[1]);n=[c,new p.P(m.x,c.y),m,new p.P(c.x,m.y),c]}return this.style.queryRenderedFeatures(n,e,this.transform)}querySourceFeatures(h,e){return this.style.querySourceFeatures(h,e)}setStyle(h,e){return(e=p.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e)).diff!==!1&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&h?(this._diffStyle(h,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(h,e))}setTransformRequest(h){return this._requestManager.setTransformRequest(h),this}_getUIString(h){const e=this._locale[h];if(e==null)throw new Error(`Missing UI string '${h}'`);return e}_updateStyle(h,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(h,e));const n=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!h)),h?(this.style=new qs(this,e||{}),this.style.setEventedParent(this,{style:this.style}),typeof h=="string"?this.style.loadURL(h,e,n):this.style.loadJSON(h,e,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new qs(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(h,e){if(typeof h=="string"){const n=this._requestManager.transformRequest(h,"Style");p.h(n,new AbortController).then(a=>{this._updateDiff(a.data,e)}).catch(a=>{a&&this.fire(new p.j(a))})}else typeof h=="object"&&this._updateDiff(h,e)}_updateDiff(h,e){try{this.style.setState(h,e)&&this._update(!0)}catch(n){p.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(h,e)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():p.w("There is no style added to the map.")}addSource(h,e){return this._lazyInitEmptyStyle(),this.style.addSource(h,e),this._update(!0)}isSourceLoaded(h){const e=this.style&&this.style.sourceCaches[h];if(e!==void 0)return e.loaded();this.fire(new p.j(new Error(`There is no source with ID '${h}'`)))}setTerrain(h){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),h){const e=this.style.sourceCaches[h.source];if(!e)throw new Error(`cannot load terrain, because there exists no source with ID: ${h.source}`);this.terrain===null&&e.reload();for(const n in this.style._layers){const a=this.style._layers[n];a.type==="hillshade"&&a.source===h.source&&p.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Po(this.painter,e,h),this.painter.renderToTexture=new Cl(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==h.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new p.k("terrain",{terrain:h})),this}getTerrain(){var h,e;return(e=(h=this.terrain)===null||h===void 0?void 0:h.options)!==null&&e!==void 0?e:null}areTilesLoaded(){const h=this.style&&this.style.sourceCaches;for(const e in h){const n=h[e]._tiles;for(const a in n){const o=n[a];if(o.state!=="loaded"&&o.state!=="errored")return!1}}return!0}removeSource(h){return this.style.removeSource(h),this._update(!0)}getSource(h){return this.style.getSource(h)}addImage(h,e,n={}){const{pixelRatio:a=1,sdf:o=!1,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b}=n;if(this._lazyInitEmptyStyle(),!(e instanceof HTMLImageElement||p.b(e))){if(e.width===void 0||e.height===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:T,height:S,data:k}=e,D=e;return this.style.addImage(h,{data:new p.R({width:T,height:S},new Uint8Array(k)),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0,userImage:D}),D.onAdd&&D.onAdd(this,h),this}}{const{width:T,height:S,data:k}=de.getImageData(e);this.style.addImage(h,{data:new p.R({width:T,height:S},k),pixelRatio:a,stretchX:c,stretchY:m,content:_,textFitWidth:y,textFitHeight:b,sdf:o,version:0})}}updateImage(h,e){const n=this.style.getImage(h);if(!n)return this.fire(new p.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const a=e instanceof HTMLImageElement||p.b(e)?de.getImageData(e):e,{width:o,height:c,data:m}=a;if(o===void 0||c===void 0)return this.fire(new p.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(o!==n.data.width||c!==n.data.height)return this.fire(new p.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const _=!(e instanceof HTMLImageElement||p.b(e));return n.data.replace(m,_),this.style.updateImage(h,n),this}getImage(h){return this.style.getImage(h)}hasImage(h){return h?!!this.style.getImage(h):(this.fire(new p.j(new Error("Missing required image id"))),!1)}removeImage(h){this.style.removeImage(h)}loadImage(h){return Mt.getImage(this._requestManager.transformRequest(h,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(h,e){return this._lazyInitEmptyStyle(),this.style.addLayer(h,e),this._update(!0)}moveLayer(h,e){return this.style.moveLayer(h,e),this._update(!0)}removeLayer(h){return this.style.removeLayer(h),this._update(!0)}getLayer(h){return this.style.getLayer(h)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(h,e,n){return this.style.setLayerZoomRange(h,e,n),this._update(!0)}setFilter(h,e,n={}){return this.style.setFilter(h,e,n),this._update(!0)}getFilter(h){return this.style.getFilter(h)}setPaintProperty(h,e,n,a={}){return this.style.setPaintProperty(h,e,n,a),this._update(!0)}getPaintProperty(h,e){return this.style.getPaintProperty(h,e)}setLayoutProperty(h,e,n,a={}){return this.style.setLayoutProperty(h,e,n,a),this._update(!0)}getLayoutProperty(h,e){return this.style.getLayoutProperty(h,e)}setGlyphs(h,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(h,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(h,e,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(h,e,n,a=>{a||this._update(!0)}),this}removeSprite(h){return this._lazyInitEmptyStyle(),this.style.removeSprite(h),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(h,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(h,e,n=>{n||this._update(!0)}),this}setLight(h,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(h,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(h){return this._lazyInitEmptyStyle(),this.style.setSky(h),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(h,e){return this.style.setFeatureState(h,e),this._update()}removeFeatureState(h,e){return this.style.removeFeatureState(h,e),this._update()}getFeatureState(h){return this.style.getFeatureState(h)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let h=0,e=0;return this._container&&(h=this._container.clientWidth||400,e=this._container.clientHeight||300),[h,e]}_setupContainer(){const h=this._container;h.classList.add("maplibregl-map");const e=this._canvasContainer=se.create("div","maplibregl-canvas-container",h);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=se.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),a=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],a);const o=this._controlContainer=se.create("div","maplibregl-control-container",h),c=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(m=>{c[m]=se.create("div",`maplibregl-ctrl-${m} `,o)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(h,e,n){this._canvas.width=Math.floor(n*h),this._canvas.height=Math.floor(n*e),this._canvas.style.width=`${h}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const h={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let e=null;this._canvas.addEventListener("webglcontextcreationerror",a=>{e={requestedAttributes:h},a&&(e.statusMessage=a.statusMessage,e.type=a.type)},{once:!0});const n=this._canvas.getContext("webgl2",h)||this._canvas.getContext("webgl",h);if(!n){const a="Failed to initialize WebGL";throw e?(e.message=a,new Error(JSON.stringify(e))):new Error(a)}this.painter=new aa(n,this.transform),Ot.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(h){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||h,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(h){return this._update(),this._renderTaskQueue.add(h)}_cancelRenderFrame(h){this._renderTaskQueue.remove(h)}_render(h){const e=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(h),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const o=this.transform.zoom,c=de.now();this.style.zoomHistory.update(o,c);const m=new p.z(o,{now:c,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),_=m.crossFadingFactor();_===1&&_===this._crossFadingFactor||(n=!0,this._crossFadingFactor=_),this.style.update(m)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,e,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding}),this.fire(new p.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,p.bf.mark(p.bg.load),this.fire(new p.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const a=this._sourcesDirty||this._styleDirty||this._placementDirty;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new p.k("idle")),!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,p.bf.mark(p.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var h;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Mt.removeThrottleControl(this._imageQueueHandle),(h=this._resizeObserver)===null||h===void 0||h.disconnect();const e=this.painter.context.gl.getExtension("WEBGL_lose_context");e!=null&&e.loseContext&&e.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),se.remove(this._canvasContainer),se.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),p.bf.clearMetrics(),this._removed=!0,this.fire(new p.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,de.frameAsync(this._frameRequest).then(h=>{p.bf.frame(h),this._frameRequest=null,this._render(h)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(h){this._showTileBoundaries!==h&&(this._showTileBoundaries=h,this._update())}get showPadding(){return!!this._showPadding}set showPadding(h){this._showPadding!==h&&(this._showPadding=h,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(h){this._showCollisionBoxes!==h&&(this._showCollisionBoxes=h,h?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(h){this._showOverdrawInspector!==h&&(this._showOverdrawInspector=h,this._update())}get repaint(){return!!this._repaint}set repaint(h){this._repaint!==h&&(this._repaint=h,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(h){this._vertices=h,this._update()}get version(){return Ml}getCameraTargetElevation(){return this.transform.elevation}},M.MapMouseEvent=ai,M.MapTouchEvent=wn,M.MapWheelEvent=wl,M.Marker=_a,M.NavigationControl=class{constructor(h){this._updateZoomButtons=()=>{const e=this._map.getZoom(),n=e===this._map.getMaxZoom(),a=e===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=a,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",a.toString())},this._rotateCompassArrow=()=>{const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._setButtonTitle=(e,n)=>{const a=this._map._getUIString(`NavigationControl.${n}`);e.title=a,e.setAttribute("aria-label",a)},this.options=p.e({},Ac,h),this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),se.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=se.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(h){return this._map=h,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Cc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){se.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(h,e){const n=se.create("button",h,this._container);return n.type="button",n.addEventListener("click",e),n}},M.Popup=class extends p.E{constructor(h){super(),this.remove=()=>(this._content&&se.remove(this._content),this._container&&(se.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new p.k("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=se.create("div","maplibregl-popup",this._map.getContainer()),this._tip=se.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const _ of this.options.className.split(" "))this._container.classList.add(_);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?wt(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!e)return;const a=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationPoint(this._lngLat));let o=this.options.anchor;const c=xa(this.options.offset);if(!o){const _=this._container.offsetWidth,y=this._container.offsetHeight;let b;b=a.y+c.bottom.ythis._map.transform.height-y?["bottom"]:[],a.x<_/2?b.push("left"):a.x>this._map.transform.width-_/2&&b.push("right"),o=b.length===0?"bottom":b.join("-")}let m=a.add(c[o]);this.options.subpixelPositioning||(m=m.round()),se.setTransform(this._container,`${Qn[o]} translate(${m.x}px,${m.y}px)`),ga(this._container,o,"popup")},this._onClose=()=>{this.remove()},this.options=p.e(Object.create(je),h)}addTo(h){return this._map&&this.remove(),this._map=h,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new p.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(h){return this._lngLat=p.N.convert(h),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(h){return this.setDOMContent(document.createTextNode(h))}setHTML(h){const e=document.createDocumentFragment(),n=document.createElement("body");let a;for(n.innerHTML=h;a=n.firstChild,a;)e.appendChild(a);return this.setDOMContent(e)}getMaxWidth(){var h;return(h=this._container)===null||h===void 0?void 0:h.style.maxWidth}setMaxWidth(h){return this.options.maxWidth=h,this._update(),this}setDOMContent(h){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=se.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(h),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(h){return this._container&&this._container.classList.add(h),this}removeClassName(h){return this._container&&this._container.classList.remove(h),this}setOffset(h){return this.options.offset=h,this._update(),this}toggleClassName(h){if(this._container)return this._container.classList.toggle(h)}setSubpixelPositioning(h){this.options.subpixelPositioning=h}_createCloseButton(){this.options.closeButton&&(this._closeButton=se.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const h=this._container.querySelector(ya);h&&h.focus()}},M.RasterDEMTileSource=Et,M.RasterTileSource=ut,M.ScaleControl=class{constructor(h){this._onMove=()=>{Ls(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Ls(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},zr),h)}getDefaultPosition(){return"bottom-left"}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-scale",h.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){se.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},M.ScrollZoomHandler=fr,M.Style=qs,M.TerrainControl=class{constructor(h){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=h}onAdd(h){return this._map=h,this._container=se.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=se.create("button","maplibregl-ctrl-terrain",this._container),se.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){se.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},M.TwoFingersTouchPitchHandler=Xn,M.TwoFingersTouchRotateHandler=vo,M.TwoFingersTouchZoomHandler=yo,M.TwoFingersTouchZoomRotateHandler=wo,M.VectorTileSource=ps,M.VideoSource=En,M.addSourceType=(h,e)=>p._(void 0,void 0,void 0,function*(){if(gs(h))throw new Error(`A source type called "${h}" already exists.`);((n,a)=>{ms[n]=a})(h,e)}),M.clearPrewarmedResources=function(){const h=Yt;h&&(h.isPreloaded()&&h.numActive()===1?(h.release(or),Yt=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},M.getMaxParallelImageRequests=function(){return p.a.MAX_PARALLEL_IMAGE_REQUESTS},M.getRTLTextPluginStatus=function(){return Ar().getRTLTextPluginStatus()},M.getVersion=function(){return Mo},M.getWorkerCount=function(){return si.workerCount},M.getWorkerUrl=function(){return p.a.WORKER_URL},M.importScriptInWorkers=function(h){return Xr().broadcast("IS",h)},M.prewarm=function(){Ir().acquire(or)},M.setMaxParallelImageRequests=function(h){p.a.MAX_PARALLEL_IMAGE_REQUESTS=h},M.setRTLTextPlugin=function(h,e){return Ar().setRTLTextPlugin(h,e)},M.setWorkerCount=function(h){si.workerCount=h},M.setWorkerUrl=function(h){p.a.WORKER_URL=h}});var ye=G;return ye})}(ec)),ec.exports}var tc=Cf(),Tr=Uint8Array,Oa=Uint16Array,Mf=Int32Array,fd=new Tr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),md=new Tr([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),kf=new Tr([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gd=function(J,j){for(var G=new Oa(31),re=0;re<31;++re)G[re]=j+=1<>1|(Lt&21845)<<1;ds=(ds&52428)>>2|(ds&13107)<<2,ds=(ds&61680)>>4|(ds&3855)<<4,vh[Lt]=((ds&65280)>>8|(ds&255)<<8)>>1}var Wo=function(J,j,G){for(var re=J.length,he=0,ye=new Oa(j);he>Je]=Ge}else for(p=new Oa(re),he=0;he>15-J[he]);return p},Jo=new Tr(288);for(var Lt=0;Lt<144;++Lt)Jo[Lt]=8;for(var Lt=144;Lt<256;++Lt)Jo[Lt]=9;for(var Lt=256;Lt<280;++Lt)Jo[Lt]=7;for(var Lt=280;Lt<288;++Lt)Jo[Lt]=8;var xd=new Tr(32);for(var Lt=0;Lt<32;++Lt)xd[Lt]=5;var Lf=Wo(Jo,9,1),Rf=Wo(xd,5,1),yh=function(J){for(var j=J[0],G=1;Gj&&(j=J[G]);return j},Hr=function(J,j,G){var re=j/8|0;return(J[re]|J[re+1]<<8)>>(j&7)&G},xh=function(J,j){var G=j/8|0;return(J[G]|J[G+1]<<8|J[G+2]<<16)>>(j&7)},Bf=function(J){return(J+7)/8|0},Ff=function(J,j,G){return(G==null||G>J.length)&&(G=J.length),new Tr(J.subarray(j,G))},Of=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],wr=function(J,j,G){var re=new Error(j||Of[J]);if(re.code=J,Error.captureStackTrace&&Error.captureStackTrace(re,wr),!G)throw re;return re},wh=function(J,j,G,re){var he=J.length,ye=0;if(!he||j.f&&!j.l)return G||new Tr(0);var M=!G,p=M||j.i!=2,Je=j.i;M&&(G=new Tr(he*3));var Ge=function(Xr){var Ki=G.length;if(Xr>Ki){var lr=new Tr(Math.max(Ki*2,Xr));lr.set(G),G=lr}},He=j.f||0,de=j.p||0,se=j.b||0,Ot=j.l,qt=j.d,kt=j.m,Ii=j.n,Oi=he*8;do{if(!Ot){He=Hr(J,de,1);var Fr=Hr(J,de+1,3);if(de+=3,Fr)if(Fr==1)Ot=Lf,qt=Rf,kt=9,Ii=5;else if(Fr==2){var Pi=Hr(J,de,31)+257,gi=Hr(J,de+10,15)+4,cn=Pi+Hr(J,de+5,31)+1;de+=14;for(var ii=new Tr(cn),Or=new Tr(19),et=0;et>4;if(Mt<16)ii[et++]=Mt;else{var Vi=0,_i=0;for(Mt==16?(_i=3+Hr(J,de,3),de+=2,Vi=ii[et-1]):Mt==17?(_i=3+Hr(J,de,7),de+=3):Mt==18&&(_i=11+Hr(J,de,127),de+=7);_i--;)ii[et++]=Vi}}var un=ii.subarray(0,Pi),ri=ii.subarray(Pi);kt=yh(un),Ii=yh(ri),Ot=Wo(un,kt,1),qt=Wo(ri,Ii,1)}else wr(1);else{var Mt=Bf(de)+4,ln=J[Mt-4]|J[Mt-3]<<8,mi=Mt+ln;if(mi>he){Je&&wr(0);break}p&&Ge(se+ln),G.set(J.subarray(Mt,mi),se),j.b=se+=ln,j.p=de=mi*8,j.f=He;continue}if(de>Oi){Je&&wr(0);break}}p&&Ge(se+131072);for(var ar=(1<>4;if(de+=Vi&15,de>Oi){Je&&wr(0);break}if(Vi||wr(2),Ni<256)G[se++]=Ni;else if(Ni==256){yi=de,Ot=null;break}else{var or=Ni-254;if(Ni>264){var et=Ni-257,si=fd[et];or=Hr(J,de,(1<>4;Sr||wr(3),de+=Sr&15;var ri=Df[Yt];if(Yt>3){var si=md[Yt];ri+=xh(J,de)&(1<Oi){Je&&wr(0);break}p&&Ge(se+131072);var Ai=se+or;if(se>3&1)+(j>>4&1);re>0;re-=!J[G++]);return G+(j&2)},Uf=function(J){var j=J.length;return(J[j-4]|J[j-3]<<8|J[j-2]<<16|J[j-1]<<24)>>>0},jf=function(J,j){return((J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31)&&wr(6,"invalid zlib data"),(J[1]>>5&1)==+!j&&wr(6,"invalid zlib data: "+(J[1]&32?"need":"unexpected")+" dictionary"),(J[1]>>3&4)+2};function $f(J,j){return wh(J,{i:2},j,j)}function qf(J,j){var G=Nf(J);return G+8>J.length&&wr(6,"invalid gzip data"),wh(J.subarray(G,-8),{i:2},new Tr(Uf(J)),j)}function Zf(J,j){return wh(J.subarray(jf(J,j),-4),{i:2},j,j)}function Gf(J,j){return J[0]==31&&J[1]==139&&J[2]==8?qf(J,j):(J[0]&15)!=8||J[0]>>4>7||(J[0]<<8|J[1])%31?$f(J,j):Zf(J,j)}var Hf=typeof TextDecoder<"u"&&new TextDecoder,Xf=0;try{Hf.decode(Vf,{stream:!0}),Xf=1}catch{}var Wf=Object.defineProperty,Ko=Math.pow,At=(J,j)=>Wf(J,"name",{value:j,configurable:!0}),fi=(J,j,G)=>new Promise((re,he)=>{var ye=Je=>{try{p(G.next(Je))}catch(Ge){he(Ge)}},M=Je=>{try{p(G.throw(Je))}catch(Ge){he(Ge)}},p=Je=>Je.done?re(Je.value):Promise.resolve(Je.value).then(ye,M);p((G=G.apply(J,j)).next())});At((J,j)=>{let G=!1,re="",he=L.GridLayer.extend({createTile:At((ye,M)=>{let p=document.createElement("img"),Je=new AbortController,Ge=Je.signal;return p.cancel=()=>{Je.abort()},G||(J.getHeader().then(He=>{He.tileType===1?console.error("Error: archive contains MVT vector tiles, but leafletRasterLayer is for displaying raster tiles. See https://github.com/protomaps/PMTiles/tree/main/js for details."):He.tileType===2?re="image/png":He.tileType===3?re="image/jpeg":He.tileType===4?re="image/webp":He.tileType===5&&(re="image/avif")}),G=!0),J.getZxy(ye.z,ye.x,ye.y,Ge).then(He=>{if(He){let de=new Blob([He.data],{type:re}),se=window.URL.createObjectURL(de);p.src=se,p.cancel=void 0,M(void 0,p)}}).catch(He=>{if(He.name!=="AbortError")throw He}),p},"createTile"),_removeTile:At(function(ye){let M=this._tiles[ye];M&&(M.el.cancel&&M.el.cancel(),M.el.width=0,M.el.height=0,M.el.deleted=!0,L.DomUtil.remove(M.el),delete this._tiles[ye],this.fire("tileunload",{tile:M.el,coords:this._keyToTileCoords(ye)}))},"_removeTile")});return new he(j)},"leafletRasterLayer");var Kf=At(J=>(j,G)=>{if(G instanceof AbortController)return J(j,G);let re=new AbortController;return J(j,re).then(he=>G(void 0,he.data,he.cacheControl||"",he.expires||""),he=>G(he)).catch(he=>G(he)),{cancel:At(()=>re.abort(),"cancel")}},"v3compat"),vd=class{constructor(j){this.tilev4=At((G,re)=>fi(this,null,function*(){if(G.type==="json"){let Ot=G.url.substr(10),qt=this.tiles.get(Ot);if(qt||(qt=new dd(Ot),this.tiles.set(Ot,qt)),this.metadata)return{data:yield qt.getTileJson(G.url)};let kt=yield qt.getHeader();return{data:{tiles:[`${G.url}/{z}/{x}/{y}`],minzoom:kt.minZoom,maxzoom:kt.maxZoom,bounds:[kt.minLon,kt.minLat,kt.maxLon,kt.maxLat]}}}let he=new RegExp(/pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)/),ye=G.url.match(he);if(!ye)throw new Error("Invalid PMTiles protocol URL");let M=ye[1],p=this.tiles.get(M);p||(p=new dd(M),this.tiles.set(M,p));let Je=ye[2],Ge=ye[3],He=ye[4],de=yield p.getHeader(),se=yield p==null?void 0:p.getZxy(+Je,+Ge,+He,re.signal);return se?{data:new Uint8Array(se.data),cacheControl:se.cacheControl,expires:se.expires}:de.tileType===1?{data:new Uint8Array}:{data:null}}),"tilev4"),this.tile=Kf(this.tilev4),this.tiles=new Map,this.metadata=(j==null?void 0:j.metadata)||!1}add(j){this.tiles.set(j.source.getKey(),j)}get(j){return this.tiles.get(j)}};At(vd,"Protocol");var Jf=vd;function bd(J,j){return(j>>>0)*4294967296+(J>>>0)}At(bd,"toNum");function wd(J,j){let G=j.buf,re=G[j.pos++],he=(re&112)>>4;if(re<128||(re=G[j.pos++],he|=(re&127)<<3,re<128)||(re=G[j.pos++],he|=(re&127)<<10,re<128)||(re=G[j.pos++],he|=(re&127)<<17,re<128)||(re=G[j.pos++],he|=(re&127)<<24,re<128)||(re=G[j.pos++],he|=(re&1)<<31,re<128))return bd(J,he);throw new Error("Expected varint not more than 10 bytes")}At(wd,"readVarintRemainder");function Fa(J){let j=J.buf,G=j[J.pos++],re=G&127;return G<128||(G=j[J.pos++],re|=(G&127)<<7,G<128)||(G=j[J.pos++],re|=(G&127)<<14,G<128)||(G=j[J.pos++],re|=(G&127)<<21,G<128)?re:(G=j[J.pos],re|=(G&15)<<28,wd(re,J))}At(Fa,"readVarint");function Th(J,j,G,re){if(re===0){G===1&&(j[0]=J-1-j[0],j[1]=J-1-j[1]);let he=j[0];j[0]=j[1],j[1]=he}}At(Th,"rotate");function Td(J,j){let G=Ko(2,J),re=j,he=j,ye=j,M=[0,0],p=1;for(;p26)throw Error("Tile zoom level exceeds max safe number limit (26)");if(j>Ko(2,J)-1||G>Ko(2,J)-1)throw Error("tile x/y outside zoom level bounds");let re=Yf[J],he=Ko(2,J),ye=0,M=0,p=0,Je=[j,G],Ge=he/2;for(;Ge>0;)ye=(Je[0]&Ge)>0?1:0,M=(Je[1]&Ge)>0?1:0,p+=Ge*Ge*(3*ye^M),Th(Ge,Je,ye,M),Ge=Ge/2;return re+p}At(Sd,"zxyToTileId");function Qf(J){let j=0;for(let G=0;G<27;G++){let re=(1<J)return Td(G,J-j);j+=re}throw Error("Tile zoom level exceeds max safe number limit (26)")}At(Qf,"tileIdToZxy");var em=(J=>(J[J.Unknown=0]="Unknown",J[J.None=1]="None",J[J.Gzip=2]="Gzip",J[J.Brotli=3]="Brotli",J[J.Zstd=4]="Zstd",J))(em||{});function ic(J,j){return fi(this,null,function*(){if(j===1||j===0)return J;if(j===2){if(typeof globalThis.DecompressionStream>"u")return Gf(new Uint8Array(J));let G=new Response(J).body;if(!G)throw Error("Failed to read response stream");let re=G.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(re).arrayBuffer()}throw Error("Compression method not supported")})}At(ic,"defaultDecompress");var tm=(J=>(J[J.Unknown=0]="Unknown",J[J.Mvt=1]="Mvt",J[J.Png=2]="Png",J[J.Jpeg=3]="Jpeg",J[J.Webp=4]="Webp",J[J.Avif=5]="Avif",J))(tm||{});function Id(J){return J===1?".mvt":J===2?".png":J===3?".jpg":J===4?".webp":J===5?".avif":""}At(Id,"tileTypeExt");var im=127;function Pd(J,j){let G=0,re=J.length-1;for(;G<=re;){let he=re+G>>1,ye=j-J[he].tileId;if(ye>0)G=he+1;else if(ye<0)re=he-1;else return J[he]}return re>=0&&(J[re].runLength===0||j-J[re].tileId-1,ye=/Chrome|Chromium|Edg|OPR|Brave/.test(re);this.chromeWindowsNoCache=!1,he&&ye&&(this.chromeWindowsNoCache=!0)}getKey(){return this.url}setHeaders(j){this.customHeaders=j}getBytes(j,G,re,he){return fi(this,null,function*(){let ye,M;re?M=re:(ye=new AbortController,M=ye.signal);let p=new Headers(this.customHeaders);p.set("range",`bytes=${j}-${j+G-1}`);let Je;this.mustReload?Je="reload":this.chromeWindowsNoCache&&(Je="no-store");let Ge=yield fetch(this.url,{signal:M,cache:Je,headers:p});if(j===0&&Ge.status===416){let se=Ge.headers.get("Content-Range");if(!se||!se.startsWith("bytes */"))throw Error("Missing content-length on 416 response");let Ot=+se.substr(8);Ge=yield fetch(this.url,{signal:M,cache:"reload",headers:{range:`bytes=0-${Ot-1}`}})}let He=Ge.headers.get("Etag");if(He!=null&&He.startsWith("W/")&&(He=null),Ge.status===416||he&&He&&He!==he)throw this.mustReload=!0,new bh(`Server returned non-matching ETag ${he} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(Ge.status>=300)throw Error(`Bad response code: ${Ge.status}`);let de=Ge.headers.get("Content-Length");if(Ge.status===200&&(!de||+de>G))throw ye&&ye.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield Ge.arrayBuffer(),etag:He||void 0,cacheControl:Ge.headers.get("Cache-Control")||void 0,expires:Ge.headers.get("Expires")||void 0}})}};At(Ad,"FetchSource");var nm=Ad;function Br(J,j){let G=J.getUint32(j+4,!0),re=J.getUint32(j+0,!0);return G*Ko(2,32)+re}At(Br,"getUint64");function Cd(J,j){let G=new DataView(J),re=G.getUint8(7);if(re>3)throw Error(`Archive is spec version ${re} but this library supports up to spec version 3`);return{specVersion:re,rootDirectoryOffset:Br(G,8),rootDirectoryLength:Br(G,16),jsonMetadataOffset:Br(G,24),jsonMetadataLength:Br(G,32),leafDirectoryOffset:Br(G,40),leafDirectoryLength:Br(G,48),tileDataOffset:Br(G,56),tileDataLength:Br(G,64),numAddressedTiles:Br(G,72),numTileEntries:Br(G,80),numTileContents:Br(G,88),clustered:G.getUint8(96)===1,internalCompression:G.getUint8(97),tileCompression:G.getUint8(98),tileType:G.getUint8(99),minZoom:G.getUint8(100),maxZoom:G.getUint8(101),minLon:G.getInt32(102,!0)/1e7,minLat:G.getInt32(106,!0)/1e7,maxLon:G.getInt32(110,!0)/1e7,maxLat:G.getInt32(114,!0)/1e7,centerZoom:G.getUint8(118),centerLon:G.getInt32(119,!0)/1e7,centerLat:G.getInt32(123,!0)/1e7,etag:j}}At(Cd,"bytesToHeader");function Sh(J){let j={buf:new Uint8Array(J),pos:0},G=Fa(j),re=[],he=0;for(let ye=0;ye0?re[ye].offset=re[ye-1].offset+re[ye-1].length:re[ye].offset=M-1}return re}At(Sh,"deserializeIndex");var Md=class extends Error{};At(Md,"EtagMismatch");var bh=Md;function Ih(J,j){return fi(this,null,function*(){let G=yield J.getBytes(0,16384);if(new DataView(G.data).getUint16(0,!0)!==19792)throw new Error("Wrong magic number for PMTiles archive");let re=G.data.slice(0,im),he=Cd(re,G.etag),ye=G.data.slice(he.rootDirectoryOffset,he.rootDirectoryOffset+he.rootDirectoryLength),M=`${J.getKey()}|${he.etag||""}|${he.rootDirectoryOffset}|${he.rootDirectoryLength}`,p=Sh(yield j(ye,he.internalCompression));return[he,[M,p.length,p]]})}At(Ih,"getHeaderAndRoot");function Ph(J,j,G,re,he){return fi(this,null,function*(){let ye=yield J.getBytes(G,re,void 0,he.etag),M=yield j(ye.data,he.internalCompression),p=Sh(M);if(p.length===0)throw new Error("Empty directory is invalid");return p})}At(Ph,"getDirectory");var sm=class{constructor(j=100,G=!0,re=ic){this.cache=new Map,this.maxCacheEntries=j,this.counter=1,this.decompress=re}getHeader(j){return fi(this,null,function*(){let G=j.getKey(),re=this.cache.get(G);if(re)return re.lastUsed=this.counter++,re.data;let he=yield Ih(j,this.decompress);return he[1]&&this.cache.set(he[1][0],{lastUsed:this.counter++,data:he[1][2]}),this.cache.set(G,{lastUsed:this.counter++,data:he[0]}),this.prune(),he[0]})}getDirectory(j,G,re,he){return fi(this,null,function*(){let ye=`${j.getKey()}|${he.etag||""}|${G}|${re}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,M.data;let p=yield Ph(j,this.decompress,G,re,he);return this.cache.set(ye,{lastUsed:this.counter++,data:p}),this.prune(),p})}prune(){if(this.cache.size>this.maxCacheEntries){let j=1/0,G;this.cache.forEach((re,he)=>{re.lastUsed{Ih(j,this.decompress).then(p=>{p[1]&&this.cache.set(p[1][0],{lastUsed:this.counter++,data:Promise.resolve(p[1][2])}),ye(p[0]),this.prune()}).catch(p=>{M(p)})});return this.cache.set(G,{lastUsed:this.counter++,data:he}),he})}getDirectory(j,G,re,he){return fi(this,null,function*(){let ye=`${j.getKey()}|${he.etag||""}|${G}|${re}`,M=this.cache.get(ye);if(M)return M.lastUsed=this.counter++,yield M.data;let p=new Promise((Je,Ge)=>{Ph(j,this.decompress,G,re,he).then(He=>{Je(He),this.prune()}).catch(He=>{Ge(He)})});return this.cache.set(ye,{lastUsed:this.counter++,data:p}),p})}prune(){if(this.cache.size>=this.maxCacheEntries){let j=1/0,G;this.cache.forEach((re,he)=>{re.lastUsed{this.getHeader(j).then(M=>{he(),this.invalidations.delete(G)}).catch(M=>{ye(M)})});this.invalidations.set(G,re)})}};At(kd,"SharedPromiseCache");var am=kd,Ed=class{constructor(j,G,re){typeof j=="string"?this.source=new nm(j):this.source=j,re?this.decompress=re:this.decompress=ic,G?this.cache=G:this.cache=new am}getHeader(){return fi(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(j,G,re,he){return fi(this,null,function*(){let ye=Sd(j,G,re),M=yield this.cache.getHeader(this.source);if(jM.maxZoom)return;let p=M.rootDirectoryOffset,Je=M.rootDirectoryLength;for(let Ge=0;Ge<=3;Ge++){let He=yield this.cache.getDirectory(this.source,p,Je,M),de=Pd(He,ye);if(de){if(de.runLength>0){let se=yield this.source.getBytes(M.tileDataOffset+de.offset,de.length,he,M.etag);return{data:yield this.decompress(se.data,M.tileCompression),cacheControl:se.cacheControl,expires:se.expires}}p=M.leafDirectoryOffset+de.offset,Je=de.length}else return}throw Error("Maximum directory depth exceeded")})}getZxy(j,G,re,he){return fi(this,null,function*(){try{return yield this.getZxyAttempt(j,G,re,he)}catch(ye){if(ye instanceof bh)return this.cache.invalidate(this.source),yield this.getZxyAttempt(j,G,re,he);throw ye}})}getMetadataAttempt(){return fi(this,null,function*(){let j=yield this.cache.getHeader(this.source),G=yield this.source.getBytes(j.jsonMetadataOffset,j.jsonMetadataLength,void 0,j.etag),re=yield this.decompress(G.data,j.internalCompression),he=new TextDecoder("utf-8");return JSON.parse(he.decode(re))})}getMetadata(){return fi(this,null,function*(){try{return yield this.getMetadataAttempt()}catch(j){if(j instanceof bh)return this.cache.invalidate(this.source),yield this.getMetadataAttempt();throw j}})}getTileJson(j){return fi(this,null,function*(){let G=yield this.getHeader(),re=yield this.getMetadata(),he=Id(G.tileType);return{tilejson:"3.0.0",scheme:"xyz",tiles:[`${j}/{z}/{x}/{y}${he}`],vector_layers:re.vector_layers,attribution:re.attribution,description:re.description,name:re.name,version:re.version,bounds:[G.minLon,G.minLat,G.maxLon,G.maxLat],center:[G.centerLon,G.centerLat,G.centerZoom],minzoom:G.minZoom,maxzoom:G.maxZoom}})}};At(Ed,"PMTiles");var dd=Ed;const om=["click"];class lm{constructor(j,G=!0){Fi(this,"button");Fi(this,"clickCallback");this.button=this.createButton();const re=document.createElement("div");re.classList.add("maplibregl-ctrl","maplibregl-ctrl-group"),re.appendChild(this.button),G||(re.style.display="none"),j.appendChild(re)}on(j,G){if(!om.includes(j))throw new Error(`Event type ${j} is not supported.`);switch(j){case"click":this.clickCallback=G;break}}turnOn(){this.button.classList.add("maplibregl-ctrl-compass-heading-active"),this.button.setAttribute("aria-pressed","true"),this.startLoading()}turnOff(){this.button.classList.remove("maplibregl-ctrl-compass-heading-active"),this.button.setAttribute("aria-pressed","false"),this.stopLoading()}disable(){this.button.setAttribute("title","Compass not available"),this.button.setAttribute("aria-label","Compass not available"),this.button.setAttribute("disabled","disabled")}startLoading(){this.button.classList.add("maplibregl-ctrl-compass-heading-waiting")}stopLoading(){this.button.classList.remove("maplibregl-ctrl-compass-heading-waiting")}createButton(){const j=document.createElement("button");j.classList.add("maplibregl-ctrl-compass-heading"),j.setAttribute("title","Rotate map to heading-up"),j.setAttribute("aria-label","Rotate map to heading-up"),j.addEventListener("click",()=>{this.clickCallback&&this.clickCallback()});const G=document.createElement("span");return G.classList.add("maplibregl-ctrl-icon"),j.appendChild(G),j}}class cm{constructor(j){Fi(this,"element");this.element=document.createElement("div"),this.element.classList.add("maplibregl-ctrl"),this.element.innerHTML=`
  • bearing:
  • accuracy:
  • diff --git a/docs/index.html b/docs/index.html index c76c0ee..0cf6f4d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ maplibre-gl-compass - + diff --git a/src/components/CompassButton.ts b/src/components/CompassButton.ts index 1e5a040..cec9a85 100644 --- a/src/components/CompassButton.ts +++ b/src/components/CompassButton.ts @@ -30,15 +30,19 @@ export class CompassButton { turnOn() { this.button.classList.add('maplibregl-ctrl-compass-heading-active') + this.button.setAttribute('aria-pressed', 'true') this.startLoading() } turnOff() { this.button.classList.remove('maplibregl-ctrl-compass-heading-active') + this.button.setAttribute('aria-pressed', 'false') this.stopLoading() } disable() { + this.button.setAttribute('title', 'Compass not available') + this.button.setAttribute('aria-label', 'Compass not available') this.button.setAttribute('disabled', 'disabled') } @@ -53,6 +57,8 @@ export class CompassButton { private createButton() { const button = document.createElement('button') button.classList.add('maplibregl-ctrl-compass-heading') + button.setAttribute('title', 'Rotate map to heading-up') + button.setAttribute('aria-label', 'Rotate map to heading-up') button.addEventListener('click', () => { if (this.clickCallback) { this.clickCallback() diff --git a/tests/CompassButton.test.ts b/tests/CompassButton.test.ts index c9d6c53..26abd8c 100644 --- a/tests/CompassButton.test.ts +++ b/tests/CompassButton.test.ts @@ -39,14 +39,18 @@ describe('CompassButton', () => { expect( button.classList.contains('maplibregl-ctrl-compass-heading-active'), ).toBe(true) + expect(button.getAttribute('aria-pressed')).toBe('true') compassButton.turnOff() expect( button.classList.contains('maplibregl-ctrl-compass-heading-active'), ).toBe(false) + expect(button.getAttribute('aria-pressed')).toBe('false') compassButton.disable() expect(button.disabled).toBe(true) + expect(button.getAttribute('title')).toBe('Compass not available') + expect(button.getAttribute('aria-label')).toBe('Compass not available') }) it('should toggle loading state', () => {