mobility-toolbox-js 3.0.0-beta.1 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mbt.min.js CHANGED
@@ -574,7 +574,7 @@ uniform ${D} ${z} u_${G};
574
574
  #endif
575
575
  `}),staticAttributes:d,staticUniforms:C}}class sl{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(i,c,d,f,y,C,E,M,P){this.context=i;let D=this.boundPaintVertexBuffers.length!==f.length;for(let z=0;!D&&z<f.length;z++)this.boundPaintVertexBuffers[z]!==f[z]&&(D=!0);!this.vao||this.boundProgram!==c||this.boundLayoutVertexBuffer!==d||D||this.boundIndexBuffer!==y||this.boundVertexOffset!==C||this.boundDynamicVertexBuffer!==E||this.boundDynamicVertexBuffer2!==M||this.boundDynamicVertexBuffer3!==P?this.freshBind(c,d,f,y,C,E,M,P):(i.bindVertexArray.set(this.vao),E&&E.bind(),y&&y.dynamicDraw&&y.bind(),M&&M.bind(),P&&P.bind())}freshBind(i,c,d,f,y,C,E,M){let P=i.numAttributes,D=this.context,z=D.gl;this.vao&&this.destroy(),this.vao=D.createVertexArray(),D.bindVertexArray.set(this.vao),this.boundProgram=i,this.boundLayoutVertexBuffer=c,this.boundPaintVertexBuffers=d,this.boundIndexBuffer=f,this.boundVertexOffset=y,this.boundDynamicVertexBuffer=C,this.boundDynamicVertexBuffer2=E,this.boundDynamicVertexBuffer3=M,c.enableAttributes(z,i);for(let G of d)G.enableAttributes(z,i);C&&C.enableAttributes(z,i),E&&E.enableAttributes(z,i),M&&M.enableAttributes(z,i),c.bind(),c.setVertexAttribPointers(z,i,y);for(let G of d)G.bind(),G.setVertexAttribPointers(z,i,y);C&&(C.bind(),C.setVertexAttribPointers(z,i,y)),f&&f.bind(),E&&(E.bind(),E.setVertexAttribPointers(z,i,y)),M&&(M.bind(),M.setVertexAttribPointers(z,i,y)),D.currentNumAttributes=P}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}function ko(m){let i=[];for(let c=0;c<m.length;c++){if(m[c]===null)continue;let d=m[c].split(" ");i.push(d.pop())}return i}class Es{constructor(i,c,d,f,y,C){let E=i.gl;this.program=E.createProgram();let M=ko(c.staticAttributes),P=d?d.getBinderAttributes():[],D=M.concat(P),z=ma.prelude.staticUniforms?ko(ma.prelude.staticUniforms):[],G=c.staticUniforms?ko(c.staticUniforms):[],Y=d?d.getBinderUniforms():[],K=z.concat(G).concat(Y),te=[];for(let be of K)te.indexOf(be)<0&&te.push(be);let X=d?d.defines():[];y&&X.push("#define OVERDRAW_INSPECTOR;"),C&&X.push("#define TERRAIN3D;");let le=X.concat(ma.prelude.fragmentSource,c.fragmentSource).join(`
576
576
  `),xe=X.concat(ma.prelude.vertexSource,c.vertexSource).join(`
577
- `),ie=E.createShader(E.FRAGMENT_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(ie,le),E.compileShader(ie),!E.getShaderParameter(ie,E.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${E.getShaderInfoLog(ie)}`);E.attachShader(this.program,ie);let pe=E.createShader(E.VERTEX_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(pe,xe),E.compileShader(pe),!E.getShaderParameter(pe,E.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${E.getShaderInfoLog(pe)}`);E.attachShader(this.program,pe),this.attributes={};let we={};this.numAttributes=D.length;for(let be=0;be<this.numAttributes;be++)D[be]&&(E.bindAttribLocation(this.program,be,D[be]),this.attributes[D[be]]=be);if(E.linkProgram(this.program),!E.getProgramParameter(this.program,E.LINK_STATUS))throw new Error(`Program failed to link: ${E.getProgramInfoLog(this.program)}`);E.deleteShader(pe),E.deleteShader(ie);for(let be=0;be<te.length;be++){let Ae=te[be];if(Ae&&!we[Ae]){let De=E.getUniformLocation(this.program,Ae);De&&(we[Ae]=De)}}this.fixedUniforms=f(i,we),this.terrainUniforms=((be,Ae)=>({u_depth:new o.aG(be,Ae.u_depth),u_terrain:new o.aG(be,Ae.u_terrain),u_terrain_dim:new o.aH(be,Ae.u_terrain_dim),u_terrain_matrix:new o.aI(be,Ae.u_terrain_matrix),u_terrain_unpack:new o.aJ(be,Ae.u_terrain_unpack),u_terrain_exaggeration:new o.aH(be,Ae.u_terrain_exaggeration)}))(i,we),this.binderUniforms=d?d.getUniforms(i,we):[]}draw(i,c,d,f,y,C,E,M,P,D,z,G,Y,K,te,X,le,xe){let ie=i.gl;if(this.failedToCreate)return;if(i.program.set(this.program),i.setDepthMode(d),i.setStencilMode(f),i.setColorMode(y),i.setCullFace(C),M){i.activeTexture.set(ie.TEXTURE2),ie.bindTexture(ie.TEXTURE_2D,M.depthTexture),i.activeTexture.set(ie.TEXTURE3),ie.bindTexture(ie.TEXTURE_2D,M.texture);for(let we in this.terrainUniforms)this.terrainUniforms[we].set(M[we])}for(let we in this.fixedUniforms)this.fixedUniforms[we].set(E[we]);te&&te.setUniforms(i,this.binderUniforms,Y,{zoom:K});let pe=0;switch(c){case ie.LINES:pe=2;break;case ie.TRIANGLES:pe=3;break;case ie.LINE_STRIP:pe=1}for(let we of G.get()){let be=we.vaos||(we.vaos={});(be[P]||(be[P]=new sl)).bind(i,this,D,te?te.getPaintVertexBuffers():[],z,we.vertexOffset,X,le,xe),ie.drawElements(c,we.primitiveLength*pe,ie.UNSIGNED_SHORT,we.primitiveOffset*pe*2)}}}function ol(m,i,c){let d=1/_t(c,1,i.transform.tileZoom),f=Math.pow(2,c.tileID.overscaledZ),y=c.tileSize*Math.pow(2,i.transform.tileZoom)/f,C=y*(c.tileID.canonical.x+c.tileID.wrap*f),E=y*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[d,m.fromScale,m.toScale],u_fade:m.t,u_pixel_coord_upper:[C>>16,E>>16],u_pixel_coord_lower:[65535&C,65535&E]}}let ga=(m,i,c,d)=>{let f=i.style.light,y=f.properties.get("position"),C=[y.x,y.y,y.z],E=function(){var P=new o.A(9);return o.A!=Float32Array&&(P[1]=0,P[2]=0,P[3]=0,P[5]=0,P[6]=0,P[7]=0),P[0]=1,P[4]=1,P[8]=1,P}();f.properties.get("anchor")==="viewport"&&function(P,D){var z=Math.sin(D),G=Math.cos(D);P[0]=G,P[1]=z,P[2]=0,P[3]=-z,P[4]=G,P[5]=0,P[6]=0,P[7]=0,P[8]=1}(E,-i.transform.angle),function(P,D,z){var G=D[0],Y=D[1],K=D[2];P[0]=G*z[0]+Y*z[3]+K*z[6],P[1]=G*z[1]+Y*z[4]+K*z[7],P[2]=G*z[2]+Y*z[5]+K*z[8]}(C,C,E);let M=f.properties.get("color");return{u_matrix:m,u_lightpos:C,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[M.r,M.g,M.b],u_vertical_gradient:+c,u_opacity:d}},Rp=(m,i,c,d,f,y,C)=>o.e(ga(m,i,c,d),ol(y,i,C),{u_height_factor:-Math.pow(2,f.overscaledZ)/C.tileSize/8}),vu=m=>({u_matrix:m}),al=(m,i,c,d)=>o.e(vu(m),ol(c,i,d)),kp=(m,i)=>({u_matrix:m,u_world:i}),bu=(m,i,c,d,f)=>o.e(al(m,i,c,d),{u_world:f}),Lp=(m,i,c,d)=>{let f=m.transform,y,C;if(d.paint.get("circle-pitch-alignment")==="map"){let E=_t(c,1,f.zoom);y=!0,C=[E,E]}else y=!1,C=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+(d.paint.get("circle-pitch-scale")==="map"),u_matrix:m.translatePosMatrix(i.posMatrix,c,d.paint.get("circle-translate"),d.paint.get("circle-translate-anchor")),u_pitch_with_map:+y,u_device_pixel_ratio:m.pixelRatio,u_extrude_scale:C}},wu=(m,i,c)=>{let d=_t(c,1,i.zoom),f=Math.pow(2,i.zoom-c.tileID.overscaledZ),y=c.tileID.overscaleFactor();return{u_matrix:m,u_camera_to_center_distance:i.cameraToCenterDistance,u_pixels_to_tile_units:d,u_extrude_scale:[i.pixelsToGLUnits[0]/(d*f),i.pixelsToGLUnits[1]/(d*f)],u_overscale_factor:y}},Su=(m,i,c=1)=>({u_matrix:m,u_color:i,u_overlay:0,u_overlay_scale:c}),ll=m=>({u_matrix:m}),Cu=(m,i,c,d)=>({u_matrix:m,u_extrude_scale:_t(i,1,c),u_intensity:d});function Iu(m,i){let c=Math.pow(2,i.canonical.z),d=i.canonical.y;return[new o.Y(0,d/c).toLngLat().lat,new o.Y(0,(d+1)/c).toLngLat().lat]}let cl=(m,i,c,d)=>{let f=m.transform;return{u_matrix:ya(m,i,c,d),u_ratio:1/_t(i,1,f.zoom),u_device_pixel_ratio:m.pixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},Eu=(m,i,c,d,f)=>o.e(cl(m,i,c,f),{u_image:0,u_image_height:d}),Ys=(m,i,c,d,f)=>{let y=m.transform,C=tn(i,y);return{u_matrix:ya(m,i,c,f),u_texsize:i.imageAtlasTexture.size,u_ratio:1/_t(i,1,y.zoom),u_device_pixel_ratio:m.pixelRatio,u_image:0,u_scale:[C,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]]}},hl=(m,i,c,d,f,y)=>{let C=m.lineAtlas,E=tn(i,m.transform),M=c.layout.get("line-cap")==="round",P=C.getDash(d.from,M),D=C.getDash(d.to,M),z=P.width*f.fromScale,G=D.width*f.toScale;return o.e(cl(m,i,c,y),{u_patternscale_a:[E/z,-P.height/2],u_patternscale_b:[E/G,-D.height/2],u_sdfgamma:C.width/(256*Math.min(z,G)*m.pixelRatio)/2,u_image:0,u_tex_y_a:P.y,u_tex_y_b:D.y,u_mix:f.t})};function tn(m,i){return 1/_t(m,1,i.tileZoom)}function ya(m,i,c,d){return m.translatePosMatrix(d?d.posMatrix:i.tileID.posMatrix,i,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}let ul=(m,i,c,d,f)=>{return{u_matrix:m,u_tl_parent:i,u_scale_parent:c,u_buffer_scale:1,u_fade_t:d.mix,u_opacity:d.opacity*f.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:f.paint.get("raster-brightness-min"),u_brightness_high:f.paint.get("raster-brightness-max"),u_saturation_factor:(C=f.paint.get("raster-saturation"),C>0?1-1/(1.001-C):-C),u_contrast_factor:(y=f.paint.get("raster-contrast"),y>0?1/(1-y):1+y),u_spin_weights:_a(f.paint.get("raster-hue-rotate"))};var y,C};function _a(m){m*=Math.PI/180;let i=Math.sin(m),c=Math.cos(m);return[(2*c+1)/3,(-Math.sqrt(3)*i-c+1)/3,(Math.sqrt(3)*i-c+1)/3]}let xa=(m,i,c,d,f,y,C,E,M,P)=>{let D=f.transform;return{u_is_size_zoom_constant:+(m==="constant"||m==="source"),u_is_size_feature_constant:+(m==="constant"||m==="camera"),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:D.cameraToCenterDistance,u_pitch:D.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:D.width/D.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_matrix:y,u_label_plane_matrix:C,u_coord_matrix:E,u_is_text:+M,u_pitch_with_map:+d,u_texsize:P,u_texture:0}},va=(m,i,c,d,f,y,C,E,M,P,D)=>{let z=f.transform;return o.e(xa(m,i,c,d,f,y,C,E,M,P),{u_gamma_scale:d?Math.cos(z._pitch)*z.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:+D})},ba=(m,i,c,d,f,y,C,E,M,P)=>o.e(va(m,i,c,d,f,y,C,E,!0,M,!0),{u_texsize_icon:P,u_texture_icon:1}),Dp=(m,i,c)=>({u_matrix:m,u_opacity:i,u_color:c}),Fp=(m,i,c,d,f,y)=>o.e(function(C,E,M,P){let D=M.imageManager.getPattern(C.from.toString()),z=M.imageManager.getPattern(C.to.toString()),{width:G,height:Y}=M.imageManager.getPixelSize(),K=Math.pow(2,P.tileID.overscaledZ),te=P.tileSize*Math.pow(2,M.transform.tileZoom)/K,X=te*(P.tileID.canonical.x+P.tileID.wrap*K),le=te*P.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:D.tl,u_pattern_br_a:D.br,u_pattern_tl_b:z.tl,u_pattern_br_b:z.br,u_texsize:[G,Y],u_mix:E.t,u_pattern_size_a:D.displaySize,u_pattern_size_b:z.displaySize,u_scale_a:E.fromScale,u_scale_b:E.toScale,u_tile_units_to_pixels:1/_t(P,1,M.transform.tileZoom),u_pixel_coord_upper:[X>>16,le>>16],u_pixel_coord_lower:[65535&X,65535&le]}}(d,y,c,f),{u_matrix:m,u_opacity:i}),Tu={fillExtrusion:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_lightpos:new o.aK(m,i.u_lightpos),u_lightintensity:new o.aH(m,i.u_lightintensity),u_lightcolor:new o.aK(m,i.u_lightcolor),u_vertical_gradient:new o.aH(m,i.u_vertical_gradient),u_opacity:new o.aH(m,i.u_opacity)}),fillExtrusionPattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_lightpos:new o.aK(m,i.u_lightpos),u_lightintensity:new o.aH(m,i.u_lightintensity),u_lightcolor:new o.aK(m,i.u_lightcolor),u_vertical_gradient:new o.aH(m,i.u_vertical_gradient),u_height_factor:new o.aH(m,i.u_height_factor),u_image:new o.aG(m,i.u_image),u_texsize:new o.aL(m,i.u_texsize),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade),u_opacity:new o.aH(m,i.u_opacity)}),fill:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix)}),fillPattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_image:new o.aG(m,i.u_image),u_texsize:new o.aL(m,i.u_texsize),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade)}),fillOutline:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_world:new o.aL(m,i.u_world)}),fillOutlinePattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_world:new o.aL(m,i.u_world),u_image:new o.aG(m,i.u_image),u_texsize:new o.aL(m,i.u_texsize),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade)}),circle:(m,i)=>({u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_scale_with_map:new o.aG(m,i.u_scale_with_map),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_extrude_scale:new o.aL(m,i.u_extrude_scale),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_matrix:new o.aI(m,i.u_matrix)}),collisionBox:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pixels_to_tile_units:new o.aH(m,i.u_pixels_to_tile_units),u_extrude_scale:new o.aL(m,i.u_extrude_scale),u_overscale_factor:new o.aH(m,i.u_overscale_factor)}),collisionCircle:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_inv_matrix:new o.aI(m,i.u_inv_matrix),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_viewport_size:new o.aL(m,i.u_viewport_size)}),debug:(m,i)=>({u_color:new o.aM(m,i.u_color),u_matrix:new o.aI(m,i.u_matrix),u_overlay:new o.aG(m,i.u_overlay),u_overlay_scale:new o.aH(m,i.u_overlay_scale)}),clippingMask:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix)}),heatmap:(m,i)=>({u_extrude_scale:new o.aH(m,i.u_extrude_scale),u_intensity:new o.aH(m,i.u_intensity),u_matrix:new o.aI(m,i.u_matrix)}),heatmapTexture:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_world:new o.aL(m,i.u_world),u_image:new o.aG(m,i.u_image),u_color_ramp:new o.aG(m,i.u_color_ramp),u_opacity:new o.aH(m,i.u_opacity)}),hillshade:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_image:new o.aG(m,i.u_image),u_latrange:new o.aL(m,i.u_latrange),u_light:new o.aL(m,i.u_light),u_shadow:new o.aM(m,i.u_shadow),u_highlight:new o.aM(m,i.u_highlight),u_accent:new o.aM(m,i.u_accent)}),hillshadePrepare:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_image:new o.aG(m,i.u_image),u_dimension:new o.aL(m,i.u_dimension),u_zoom:new o.aH(m,i.u_zoom),u_unpack:new o.aJ(m,i.u_unpack)}),line:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels)}),lineGradient:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels),u_image:new o.aG(m,i.u_image),u_image_height:new o.aH(m,i.u_image_height)}),linePattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_texsize:new o.aL(m,i.u_texsize),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_image:new o.aG(m,i.u_image),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade)}),lineSDF:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels),u_patternscale_a:new o.aL(m,i.u_patternscale_a),u_patternscale_b:new o.aL(m,i.u_patternscale_b),u_sdfgamma:new o.aH(m,i.u_sdfgamma),u_image:new o.aG(m,i.u_image),u_tex_y_a:new o.aH(m,i.u_tex_y_a),u_tex_y_b:new o.aH(m,i.u_tex_y_b),u_mix:new o.aH(m,i.u_mix)}),raster:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_tl_parent:new o.aL(m,i.u_tl_parent),u_scale_parent:new o.aH(m,i.u_scale_parent),u_buffer_scale:new o.aH(m,i.u_buffer_scale),u_fade_t:new o.aH(m,i.u_fade_t),u_opacity:new o.aH(m,i.u_opacity),u_image0:new o.aG(m,i.u_image0),u_image1:new o.aG(m,i.u_image1),u_brightness_low:new o.aH(m,i.u_brightness_low),u_brightness_high:new o.aH(m,i.u_brightness_high),u_saturation_factor:new o.aH(m,i.u_saturation_factor),u_contrast_factor:new o.aH(m,i.u_contrast_factor),u_spin_weights:new o.aK(m,i.u_spin_weights)}),symbolIcon:(m,i)=>({u_is_size_zoom_constant:new o.aG(m,i.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(m,i.u_is_size_feature_constant),u_size_t:new o.aH(m,i.u_size_t),u_size:new o.aH(m,i.u_size),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pitch:new o.aH(m,i.u_pitch),u_rotate_symbol:new o.aG(m,i.u_rotate_symbol),u_aspect_ratio:new o.aH(m,i.u_aspect_ratio),u_fade_change:new o.aH(m,i.u_fade_change),u_matrix:new o.aI(m,i.u_matrix),u_label_plane_matrix:new o.aI(m,i.u_label_plane_matrix),u_coord_matrix:new o.aI(m,i.u_coord_matrix),u_is_text:new o.aG(m,i.u_is_text),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_texsize:new o.aL(m,i.u_texsize),u_texture:new o.aG(m,i.u_texture)}),symbolSDF:(m,i)=>({u_is_size_zoom_constant:new o.aG(m,i.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(m,i.u_is_size_feature_constant),u_size_t:new o.aH(m,i.u_size_t),u_size:new o.aH(m,i.u_size),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pitch:new o.aH(m,i.u_pitch),u_rotate_symbol:new o.aG(m,i.u_rotate_symbol),u_aspect_ratio:new o.aH(m,i.u_aspect_ratio),u_fade_change:new o.aH(m,i.u_fade_change),u_matrix:new o.aI(m,i.u_matrix),u_label_plane_matrix:new o.aI(m,i.u_label_plane_matrix),u_coord_matrix:new o.aI(m,i.u_coord_matrix),u_is_text:new o.aG(m,i.u_is_text),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_texsize:new o.aL(m,i.u_texsize),u_texture:new o.aG(m,i.u_texture),u_gamma_scale:new o.aH(m,i.u_gamma_scale),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_is_halo:new o.aG(m,i.u_is_halo)}),symbolTextAndIcon:(m,i)=>({u_is_size_zoom_constant:new o.aG(m,i.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(m,i.u_is_size_feature_constant),u_size_t:new o.aH(m,i.u_size_t),u_size:new o.aH(m,i.u_size),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pitch:new o.aH(m,i.u_pitch),u_rotate_symbol:new o.aG(m,i.u_rotate_symbol),u_aspect_ratio:new o.aH(m,i.u_aspect_ratio),u_fade_change:new o.aH(m,i.u_fade_change),u_matrix:new o.aI(m,i.u_matrix),u_label_plane_matrix:new o.aI(m,i.u_label_plane_matrix),u_coord_matrix:new o.aI(m,i.u_coord_matrix),u_is_text:new o.aG(m,i.u_is_text),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_texsize:new o.aL(m,i.u_texsize),u_texsize_icon:new o.aL(m,i.u_texsize_icon),u_texture:new o.aG(m,i.u_texture),u_texture_icon:new o.aG(m,i.u_texture_icon),u_gamma_scale:new o.aH(m,i.u_gamma_scale),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_is_halo:new o.aG(m,i.u_is_halo)}),background:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_opacity:new o.aH(m,i.u_opacity),u_color:new o.aM(m,i.u_color)}),backgroundPattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_opacity:new o.aH(m,i.u_opacity),u_image:new o.aG(m,i.u_image),u_pattern_tl_a:new o.aL(m,i.u_pattern_tl_a),u_pattern_br_a:new o.aL(m,i.u_pattern_br_a),u_pattern_tl_b:new o.aL(m,i.u_pattern_tl_b),u_pattern_br_b:new o.aL(m,i.u_pattern_br_b),u_texsize:new o.aL(m,i.u_texsize),u_mix:new o.aH(m,i.u_mix),u_pattern_size_a:new o.aL(m,i.u_pattern_size_a),u_pattern_size_b:new o.aL(m,i.u_pattern_size_b),u_scale_a:new o.aH(m,i.u_scale_a),u_scale_b:new o.aH(m,i.u_scale_b),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aH(m,i.u_tile_units_to_pixels)}),terrain:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_texture:new o.aG(m,i.u_texture),u_ele_delta:new o.aH(m,i.u_ele_delta)}),terrainDepth:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ele_delta:new o.aH(m,i.u_ele_delta)}),terrainCoords:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_texture:new o.aG(m,i.u_texture),u_terrain_coords_id:new o.aH(m,i.u_terrain_coords_id),u_ele_delta:new o.aH(m,i.u_ele_delta)})};class zp{constructor(i,c,d){this.context=i;let f=i.gl;this.buffer=f.createBuffer(),this.dynamicDraw=!!d,this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){let c=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),c.bufferSubData(c.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let Ks={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class dl{constructor(i,c,d,f){this.length=c.length,this.attributes=d,this.itemSize=c.bytesPerElement,this.dynamicDraw=f,this.context=i;let y=i.gl;this.buffer=y.createBuffer(),i.bindVertexBuffer.set(this.buffer),y.bufferData(y.ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){if(i.length!==this.length)throw new Error(`Length of new data is ${i.length}, which doesn't match current length of ${this.length}`);let c=this.context.gl;this.bind(),c.bufferSubData(c.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,c){for(let d=0;d<this.attributes.length;d++){let f=c.attributes[this.attributes[d].name];f!==void 0&&i.enableVertexAttribArray(f)}}setVertexAttribPointers(i,c,d){for(let f=0;f<this.attributes.length;f++){let y=this.attributes[f],C=c.attributes[y.name];C!==void 0&&i.vertexAttribPointer(C,y.components,i[Ks[y.type]],!1,this.itemSize,y.offset+this.itemSize*(d||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let Sr=new WeakMap;function cr(m){var i;if(Sr.has(m))return Sr.get(m);{let c=(i=m.getParameter(m.VERSION))===null||i===void 0?void 0:i.startsWith("WebGL 2.0");return Sr.set(m,c),c}}class jt{constructor(i){this.gl=i.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(i){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class pl extends jt{getDefault(){return o.aO.transparent}set(i){let c=this.current;(i.r!==c.r||i.g!==c.g||i.b!==c.b||i.a!==c.a||this.dirty)&&(this.gl.clearColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class fl extends jt{getDefault(){return 1}set(i){(i!==this.current||this.dirty)&&(this.gl.clearDepth(i),this.current=i,this.dirty=!1)}}class bc extends jt{getDefault(){return 0}set(i){(i!==this.current||this.dirty)&&(this.gl.clearStencil(i),this.current=i,this.dirty=!1)}}class wc extends jt{getDefault(){return[!0,!0,!0,!0]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||i[2]!==c[2]||i[3]!==c[3]||this.dirty)&&(this.gl.colorMask(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class ml extends jt{getDefault(){return!0}set(i){(i!==this.current||this.dirty)&&(this.gl.depthMask(i),this.current=i,this.dirty=!1)}}class Sc extends jt{getDefault(){return 255}set(i){(i!==this.current||this.dirty)&&(this.gl.stencilMask(i),this.current=i,this.dirty=!1)}}class Cc extends jt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(i){let c=this.current;(i.func!==c.func||i.ref!==c.ref||i.mask!==c.mask||this.dirty)&&(this.gl.stencilFunc(i.func,i.ref,i.mask),this.current=i,this.dirty=!1)}}class gl extends jt{getDefault(){let i=this.gl;return[i.KEEP,i.KEEP,i.KEEP]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||i[2]!==c[2]||this.dirty)&&(this.gl.stencilOp(i[0],i[1],i[2]),this.current=i,this.dirty=!1)}}class Mu extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.STENCIL_TEST):c.disable(c.STENCIL_TEST),this.current=i,this.dirty=!1}}class Au extends jt{getDefault(){return[0,1]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||this.dirty)&&(this.gl.depthRange(i[0],i[1]),this.current=i,this.dirty=!1)}}class Lo extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST),this.current=i,this.dirty=!1}}class Op extends jt{getDefault(){return this.gl.LESS}set(i){(i!==this.current||this.dirty)&&(this.gl.depthFunc(i),this.current=i,this.dirty=!1)}}class Bp extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.BLEND):c.disable(c.BLEND),this.current=i,this.dirty=!1}}class Np extends jt{getDefault(){let i=this.gl;return[i.ONE,i.ZERO]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||this.dirty)&&(this.gl.blendFunc(i[0],i[1]),this.current=i,this.dirty=!1)}}class Vp extends jt{getDefault(){return o.aO.transparent}set(i){let c=this.current;(i.r!==c.r||i.g!==c.g||i.b!==c.b||i.a!==c.a||this.dirty)&&(this.gl.blendColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class Gp extends jt{getDefault(){return this.gl.FUNC_ADD}set(i){(i!==this.current||this.dirty)&&(this.gl.blendEquation(i),this.current=i,this.dirty=!1)}}class jp extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.CULL_FACE):c.disable(c.CULL_FACE),this.current=i,this.dirty=!1}}class Ic extends jt{getDefault(){return this.gl.BACK}set(i){(i!==this.current||this.dirty)&&(this.gl.cullFace(i),this.current=i,this.dirty=!1)}}class yl extends jt{getDefault(){return this.gl.CCW}set(i){(i!==this.current||this.dirty)&&(this.gl.frontFace(i),this.current=i,this.dirty=!1)}}class Ec extends jt{getDefault(){return null}set(i){(i!==this.current||this.dirty)&&(this.gl.useProgram(i),this.current=i,this.dirty=!1)}}class Tc extends jt{getDefault(){return this.gl.TEXTURE0}set(i){(i!==this.current||this.dirty)&&(this.gl.activeTexture(i),this.current=i,this.dirty=!1)}}class Do extends jt{getDefault(){let i=this.gl;return[0,0,i.drawingBufferWidth,i.drawingBufferHeight]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||i[2]!==c[2]||i[3]!==c[3]||this.dirty)&&(this.gl.viewport(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class Pu extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindFramebuffer(c.FRAMEBUFFER,i),this.current=i,this.dirty=!1}}class Ru extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindRenderbuffer(c.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class Mc extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindTexture(c.TEXTURE_2D,i),this.current=i,this.dirty=!1}}class Js extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindBuffer(c.ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class ku extends jt{getDefault(){return null}set(i){let c=this.gl;c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class Fo extends jt{getDefault(){return null}set(i){var c;if(i===this.current&&!this.dirty)return;let d=this.gl;cr(d)?d.bindVertexArray(i):(c=d.getExtension("OES_vertex_array_object"))===null||c===void 0||c.bindVertexArrayOES(i),this.current=i,this.dirty=!1}}class zo extends jt{getDefault(){return 4}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.pixelStorei(c.UNPACK_ALIGNMENT,i),this.current=i,this.dirty=!1}}class Lu extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i),this.current=i,this.dirty=!1}}class Ac extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,i),this.current=i,this.dirty=!1}}class Vt extends jt{constructor(i,c){super(i),this.context=i,this.parent=c}getDefault(){return null}}class _l extends Vt{setDirty(){this.dirty=!0}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let c=this.gl;c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,i,0),this.current=i,this.dirty=!1}}class Up extends Vt{set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let c=this.gl;c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class Du extends Vt{set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let c=this.gl;c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class wa{constructor(i,c,d,f,y){this.context=i,this.width=c,this.height=d;let C=i.gl,E=this.framebuffer=C.createFramebuffer();if(this.colorAttachment=new _l(i,E),f)this.depthAttachment=y?new Du(i,E):new Up(i,E);else if(y)throw new Error("Stencil cannot be set without depth");if(C.checkFramebufferStatus(C.FRAMEBUFFER)!==C.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){let i=this.context.gl,c=this.colorAttachment.get();if(c&&i.deleteTexture(c),this.depthAttachment){let d=this.depthAttachment.get();d&&i.deleteRenderbuffer(d)}i.deleteFramebuffer(this.framebuffer)}}class vi{constructor(i,c,d){this.blendFunction=i,this.blendColor=c,this.mask=d}}vi.Replace=[1,0],vi.disabled=new vi(vi.Replace,o.aO.transparent,[!1,!1,!1,!1]),vi.unblended=new vi(vi.Replace,o.aO.transparent,[!0,!0,!0,!0]),vi.alphaBlended=new vi([1,771],o.aO.transparent,[!0,!0,!0,!0]);class $p{constructor(i){var c,d;if(this.gl=i,this.clearColor=new pl(this),this.clearDepth=new fl(this),this.clearStencil=new bc(this),this.colorMask=new wc(this),this.depthMask=new ml(this),this.stencilMask=new Sc(this),this.stencilFunc=new Cc(this),this.stencilOp=new gl(this),this.stencilTest=new Mu(this),this.depthRange=new Au(this),this.depthTest=new Lo(this),this.depthFunc=new Op(this),this.blend=new Bp(this),this.blendFunc=new Np(this),this.blendColor=new Vp(this),this.blendEquation=new Gp(this),this.cullFace=new jp(this),this.cullFaceSide=new Ic(this),this.frontFace=new yl(this),this.program=new Ec(this),this.activeTexture=new Tc(this),this.viewport=new Do(this),this.bindFramebuffer=new Pu(this),this.bindRenderbuffer=new Ru(this),this.bindTexture=new Mc(this),this.bindVertexBuffer=new Js(this),this.bindElementBuffer=new ku(this),this.bindVertexArray=new Fo(this),this.pixelStoreUnpack=new zo(this),this.pixelStoreUnpackPremultiplyAlpha=new Lu(this),this.pixelStoreUnpackFlipY=new Ac(this),this.extTextureFilterAnisotropic=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=i.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),cr(i)){this.HALF_FLOAT=i.HALF_FLOAT;let f=i.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(c=i.RGBA16F)!==null&&c!==void 0?c:f?.RGBA16F_EXT,this.RGB16F=(d=i.RGB16F)!==null&&d!==void 0?d:f?.RGB16F_EXT,i.getExtension("EXT_color_buffer_float")}else{i.getExtension("EXT_color_buffer_half_float"),i.getExtension("OES_texture_half_float_linear");let f=i.getExtension("OES_texture_half_float");this.HALF_FLOAT=f?.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(i,c){return new zp(this,i,c)}createVertexBuffer(i,c,d){return new dl(this,i,c,d)}createRenderbuffer(i,c,d){let f=this.gl,y=f.createRenderbuffer();return this.bindRenderbuffer.set(y),f.renderbufferStorage(f.RENDERBUFFER,i,c,d),this.bindRenderbuffer.set(null),y}createFramebuffer(i,c,d,f){return new wa(this,i,c,d,f)}clear({color:i,depth:c,stencil:d}){let f=this.gl,y=0;i&&(y|=f.COLOR_BUFFER_BIT,this.clearColor.set(i),this.colorMask.set([!0,!0,!0,!0])),c!==void 0&&(y|=f.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(c),this.depthMask.set(!0)),d!==void 0&&(y|=f.STENCIL_BUFFER_BIT,this.clearStencil.set(d),this.stencilMask.set(255)),f.clear(y)}setCullFace(i){i.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(i.mode),this.frontFace.set(i.frontFace))}setDepthMode(i){i.func!==this.gl.ALWAYS||i.mask?(this.depthTest.set(!0),this.depthFunc.set(i.func),this.depthMask.set(i.mask),this.depthRange.set(i.range)):this.depthTest.set(!1)}setStencilMode(i){i.test.func!==this.gl.ALWAYS||i.mask?(this.stencilTest.set(!0),this.stencilMask.set(i.mask),this.stencilOp.set([i.fail,i.depthFail,i.pass]),this.stencilFunc.set({func:i.test.func,ref:i.ref,mask:i.test.mask})):this.stencilTest.set(!1)}setColorMode(i){o.aD(i.blendFunction,vi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor)),this.colorMask.set(i.mask)}createVertexArray(){var i;return cr(this.gl)?this.gl.createVertexArray():(i=this.gl.getExtension("OES_vertex_array_object"))===null||i===void 0?void 0:i.createVertexArrayOES()}deleteVertexArray(i){var c;return cr(this.gl)?this.gl.deleteVertexArray(i):(c=this.gl.getExtension("OES_vertex_array_object"))===null||c===void 0?void 0:c.deleteVertexArrayOES(i)}unbindVAO(){this.bindVertexArray.set(null)}}class Ot{constructor(i,c,d){this.func=i,this.mask=c,this.range=d}}Ot.ReadOnly=!1,Ot.ReadWrite=!0,Ot.disabled=new Ot(519,Ot.ReadOnly,[0,1]);let Pc=7680;class Jt{constructor(i,c,d,f,y,C){this.test=i,this.ref=c,this.mask=d,this.fail=f,this.depthFail=y,this.pass=C}}Jt.disabled=new Jt({func:519,mask:0},0,0,Pc,Pc,Pc);class Kt{constructor(i,c,d){this.enable=i,this.mode=c,this.frontFace=d}}let Qs;function xl(m,i,c,d,f,y,C){let E=m.context,M=E.gl,P=m.useProgram("collisionBox"),D=[],z=0,G=0;for(let ie=0;ie<d.length;ie++){let pe=d[ie],we=i.getTile(pe),be=we.getBucket(c);if(!be)continue;let Ae=pe.posMatrix;f[0]===0&&f[1]===0||(Ae=m.translatePosMatrix(pe.posMatrix,we,f,y));let De=C?be.textCollisionBox:be.iconCollisionBox,Le=be.collisionCircleArray;if(Le.length>0){let Be=o.F(),et=Ae;o.aP(Be,be.placementInvProjMatrix,m.transform.glCoordMatrix),o.aP(Be,Be,be.placementViewportMatrix),D.push({circleArray:Le,circleOffset:G,transform:et,invTransform:Be,coord:pe}),z+=Le.length/4,G=z}De&&P.draw(E,M.LINES,Ot.disabled,Jt.disabled,m.colorModeForRenderPass(),Kt.disabled,wu(Ae,m.transform,we),m.style.map.terrain&&m.style.map.terrain.getTerrainData(pe),c.id,De.layoutVertexBuffer,De.indexBuffer,De.segments,null,m.transform.zoom,null,null,De.collisionVertexBuffer)}if(!C||!D.length)return;let Y=m.useProgram("collisionCircle"),K=new o.aQ;K.resize(4*z),K._trim();let te=0;for(let ie of D)for(let pe=0;pe<ie.circleArray.length/4;pe++){let we=4*pe,be=ie.circleArray[we+0],Ae=ie.circleArray[we+1],De=ie.circleArray[we+2],Le=ie.circleArray[we+3];K.emplace(te++,be,Ae,De,Le,0),K.emplace(te++,be,Ae,De,Le,1),K.emplace(te++,be,Ae,De,Le,2),K.emplace(te++,be,Ae,De,Le,3)}(!Qs||Qs.length<2*z)&&(Qs=function(ie){let pe=2*ie,we=new o.aS;we.resize(pe),we._trim();for(let be=0;be<pe;be++){let Ae=6*be;we.uint16[Ae+0]=4*be+0,we.uint16[Ae+1]=4*be+1,we.uint16[Ae+2]=4*be+2,we.uint16[Ae+3]=4*be+2,we.uint16[Ae+4]=4*be+3,we.uint16[Ae+5]=4*be+0}return we}(z));let X=E.createIndexBuffer(Qs,!0),le=E.createVertexBuffer(K,o.aR.members,!0);for(let ie of D){let pe={u_matrix:ie.transform,u_inv_matrix:ie.invTransform,u_camera_to_center_distance:(xe=m.transform).cameraToCenterDistance,u_viewport_size:[xe.width,xe.height]};Y.draw(E,M.TRIANGLES,Ot.disabled,Jt.disabled,m.colorModeForRenderPass(),Kt.disabled,pe,m.style.map.terrain&&m.style.map.terrain.getTerrainData(ie.coord),c.id,le,X,o.$.simpleSegment(0,2*ie.circleOffset,ie.circleArray.length,ie.circleArray.length/2),null,m.transform.zoom,null,null,null)}var xe;le.destroy(),X.destroy()}Kt.disabled=new Kt(!1,1029,2305),Kt.backCCW=new Kt(!0,1029,2305);let Rc=o.an(new Float32Array(16));function Fu(m,i,c,d,f,y){let{horizontalAlign:C,verticalAlign:E}=o.at(m);return new o.P((-(C-.5)*i/f+d[0])*y,(-(E-.5)*c/f+d[1])*y)}function vl(m,i,c,d,f,y,C,E,M,P,D){let z=m.text.placedSymbolArray,G=m.text.dynamicLayoutVertexArray,Y=m.icon.dynamicLayoutVertexArray,K={};G.clear();for(let te=0;te<z.length;te++){let X=z.get(te),le=X.hidden||!X.crossTileID||m.allowVerticalPlacement&&!X.placedOrientation?null:d[X.crossTileID];if(le){let xe=new o.P(X.anchorX,X.anchorY),ie=yi(xe,c?C:y,D),pe=Q(f.cameraToCenterDistance,ie.signedDistanceFromCamera),we=o.ai(m.textSizeData,M,X)*pe/o.ao;c&&(we*=m.tilePixelRatio/E);let{width:be,height:Ae,anchor:De,textOffset:Le,textBoxScale:Be}=le,et=Fu(De,be,Ae,Le,Be,we),ht=c?yi(xe.add(et),y,D).point:ie.point.add(i?et.rotate(-f.angle):et),$e=m.allowVerticalPlacement&&X.placedOrientation===o.ah.vertical?Math.PI/2:0;for(let ct=0;ct<X.numGlyphs;ct++)o.aj(G,ht,$e);P&&X.associatedIconIndex>=0&&(K[X.associatedIconIndex]={shiftedAnchor:ht,angle:$e})}else Ce(X.numGlyphs,G)}if(P){Y.clear();let te=m.icon.placedSymbolArray;for(let X=0;X<te.length;X++){let le=te.get(X);if(le.hidden)Ce(le.numGlyphs,Y);else{let xe=K[X];if(xe)for(let ie=0;ie<le.numGlyphs;ie++)o.aj(Y,xe.shiftedAnchor,xe.angle);else Ce(le.numGlyphs,Y)}}m.icon.dynamicLayoutVertexBuffer.updateData(Y)}m.text.dynamicLayoutVertexBuffer.updateData(G)}function bl(m,i,c){return c.iconsInText&&i?"symbolTextAndIcon":m?"symbolSDF":"symbolIcon"}function wl(m,i,c,d,f,y,C,E,M,P,D,z){let G=m.context,Y=G.gl,K=m.transform,te=E==="map",X=M==="map",le=E!=="viewport"&&c.layout.get("symbol-placement")!=="point",xe=te&&!X&&!le,ie=!c.layout.get("symbol-sort-key").isConstant(),pe=!1,we=m.depthModeForSublayer(0,Ot.ReadOnly),be=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ae=[];for(let De of d){let Le=i.getTile(De),Be=Le.getBucket(c);if(!Be)continue;let et=f?Be.text:Be.icon;if(!et||!et.segments.get().length||!et.hasVisibleVertices)continue;let ht=et.programConfigurations.get(c.id),$e=f||Be.sdfIcons,ct=f?Be.textSizeData:Be.iconSizeData,nt=X||K.pitch!==0,ei=m.useProgram(bl($e,f,Be),ht),kt=o.ag(ct,K.zoom),It=m.style.map.terrain&&m.style.map.terrain.getTerrainData(De),Lt,wi,Zt,Er,Hi=[0,0],pi=null;if(f)wi=Le.glyphAtlasTexture,Zt=Y.LINEAR,Lt=Le.glyphAtlasTexture.size,Be.iconsInText&&(Hi=Le.imageAtlasTexture.size,pi=Le.imageAtlasTexture,Er=nt||m.options.rotating||m.options.zooming||ct.kind==="composite"||ct.kind==="camera"?Y.LINEAR:Y.NEAREST);else{let ti=c.layout.get("icon-size").constantOr(0)!==1||Be.iconsNeedLinear;wi=Le.imageAtlasTexture,Zt=$e||m.options.rotating||m.options.zooming||ti||nt?Y.LINEAR:Y.NEAREST,Lt=Le.imageAtlasTexture.size}let hr=_t(Le,1,m.transform.zoom),ur=vt(De.posMatrix,X,te,m.transform,hr),_n=On(De.posMatrix,X,te,m.transform,hr),Ps=be&&Be.hasTextData(),jo=c.layout.get("icon-text-fit")!=="none"&&Ps&&Be.hasIconData();if(le){let ti=m.style.map.terrain?(Yi,Oi)=>m.style.map.terrain.getElevation(De,Yi,Oi):null,zi=c.layout.get("text-rotation-alignment")==="map";N(Be,De.posMatrix,m,f,ur,_n,X,P,zi,ti)}let Uo=m.translatePosMatrix(De.posMatrix,Le,y,C),Rs=le||f&&be||jo?Rc:ur,Fi=m.translatePosMatrix(_n,Le,y,C,!0),Si=$e&&c.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1)!==0,fi;fi=$e?Be.iconsInText?ba(ct.kind,kt,xe,X,m,Uo,Rs,Fi,Lt,Hi):va(ct.kind,kt,xe,X,m,Uo,Rs,Fi,f,Lt,!0):xa(ct.kind,kt,xe,X,m,Uo,Rs,Fi,f,Lt);let Tr={program:ei,buffers:et,uniformValues:fi,atlasTexture:wi,atlasTextureIcon:pi,atlasInterpolation:Zt,atlasInterpolationIcon:Er,isSDF:$e,hasHalo:Si};if(ie&&Be.canOverlap){pe=!0;let ti=et.segments.get();for(let zi of ti)Ae.push({segments:new o.$([zi]),sortKey:zi.sortKey,state:Tr,terrainData:It})}else Ae.push({segments:et.segments,sortKey:0,state:Tr,terrainData:It})}pe&&Ae.sort((De,Le)=>De.sortKey-Le.sortKey);for(let De of Ae){let Le=De.state;if(G.activeTexture.set(Y.TEXTURE0),Le.atlasTexture.bind(Le.atlasInterpolation,Y.CLAMP_TO_EDGE),Le.atlasTextureIcon&&(G.activeTexture.set(Y.TEXTURE1),Le.atlasTextureIcon&&Le.atlasTextureIcon.bind(Le.atlasInterpolationIcon,Y.CLAMP_TO_EDGE)),Le.isSDF){let Be=Le.uniformValues;Le.hasHalo&&(Be.u_is_halo=1,zu(Le.buffers,De.segments,c,m,Le.program,we,D,z,Be,De.terrainData)),Be.u_is_halo=0}zu(Le.buffers,De.segments,c,m,Le.program,we,D,z,Le.uniformValues,De.terrainData)}}function zu(m,i,c,d,f,y,C,E,M,P){let D=d.context;f.draw(D,D.gl.TRIANGLES,y,C,E,Kt.disabled,M,P,c.id,m.layoutVertexBuffer,m.indexBuffer,i,c.paint,d.transform.zoom,m.programConfigurations.get(c.id),m.dynamicLayoutVertexBuffer,m.opacityVertexBuffer)}function Sl(m,i,c,d,f){if(!c||!d||!d.imageAtlas)return;let y=d.imageAtlas.patternPositions,C=y[c.to.toString()],E=y[c.from.toString()];if(!C&&E&&(C=E),!E&&C&&(E=C),!C||!E){let M=f.getPaintProperty(i);C=y[M],E=y[M]}C&&E&&m.setConstantPatternPositions(C,E)}function Ou(m,i,c,d,f,y,C){let E=m.context.gl,M="fill-pattern",P=c.paint.get(M),D=P&&P.constantOr(1),z=c.getCrossfadeParameters(),G,Y,K,te,X;C?(Y=D&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",G=E.LINES):(Y=D?"fillPattern":"fill",G=E.TRIANGLES);let le=P.constantOr(null);for(let xe of d){let ie=i.getTile(xe);if(D&&!ie.patternsLoaded())continue;let pe=ie.getBucket(c);if(!pe)continue;let we=pe.programConfigurations.get(c.id),be=m.useProgram(Y,we),Ae=m.style.map.terrain&&m.style.map.terrain.getTerrainData(xe);D&&(m.context.activeTexture.set(E.TEXTURE0),ie.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),we.updatePaintBuffers(z)),Sl(we,M,le,ie,c);let De=Ae?xe:null,Le=m.translatePosMatrix(De?De.posMatrix:xe.posMatrix,ie,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(C){te=pe.indexBuffer2,X=pe.segments2;let Be=[E.drawingBufferWidth,E.drawingBufferHeight];K=Y==="fillOutlinePattern"&&D?bu(Le,m,z,ie,Be):kp(Le,Be)}else te=pe.indexBuffer,X=pe.segments,K=D?al(Le,m,z,ie):vu(Le);be.draw(m.context,G,f,m.stencilModeForClipping(xe),y,Kt.disabled,K,Ae,c.id,pe.layoutVertexBuffer,te,X,c.paint,m.transform.zoom,we)}}function Cl(m,i,c,d,f,y,C){let E=m.context,M=E.gl,P="fill-extrusion-pattern",D=c.paint.get(P),z=D.constantOr(1),G=c.getCrossfadeParameters(),Y=c.paint.get("fill-extrusion-opacity"),K=D.constantOr(null);for(let te of d){let X=i.getTile(te),le=X.getBucket(c);if(!le)continue;let xe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(te),ie=le.programConfigurations.get(c.id),pe=m.useProgram(z?"fillExtrusionPattern":"fillExtrusion",ie);z&&(m.context.activeTexture.set(M.TEXTURE0),X.imageAtlasTexture.bind(M.LINEAR,M.CLAMP_TO_EDGE),ie.updatePaintBuffers(G)),Sl(ie,P,K,X,c);let we=m.translatePosMatrix(te.posMatrix,X,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),be=c.paint.get("fill-extrusion-vertical-gradient"),Ae=z?Rp(we,m,be,Y,te,G,X):ga(we,m,be,Y);pe.draw(E,E.gl.TRIANGLES,f,y,C,Kt.backCCW,Ae,xe,c.id,le.layoutVertexBuffer,le.indexBuffer,le.segments,c.paint,m.transform.zoom,ie,m.style.map.terrain&&le.centroidVertexBuffer)}}function Il(m,i,c,d,f,y,C){let E=m.context,M=E.gl,P=c.fbo;if(!P)return;let D=m.useProgram("hillshade"),z=m.style.map.terrain&&m.style.map.terrain.getTerrainData(i);E.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,P.colorAttachment.get()),D.draw(E,M.TRIANGLES,f,y,C,Kt.disabled,((G,Y,K,te)=>{let X=K.paint.get("hillshade-shadow-color"),le=K.paint.get("hillshade-highlight-color"),xe=K.paint.get("hillshade-accent-color"),ie=K.paint.get("hillshade-illumination-direction")*(Math.PI/180);K.paint.get("hillshade-illumination-anchor")==="viewport"&&(ie-=G.transform.angle);let pe=!G.options.moving;return{u_matrix:te?te.posMatrix:G.transform.calculatePosMatrix(Y.tileID.toUnwrapped(),pe),u_image:0,u_latrange:Iu(0,Y.tileID),u_light:[K.paint.get("hillshade-exaggeration"),ie],u_shadow:X,u_highlight:le,u_accent:xe}})(m,c,d,z?i:null),z,d.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments)}function kc(m,i,c,d,f,y){let C=m.context,E=C.gl,M=i.dem;if(M&&M.data){let P=M.dim,D=M.stride,z=M.getPixels();if(C.activeTexture.set(E.TEXTURE1),C.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||m.getTileTexture(D),i.demTexture){let Y=i.demTexture;Y.update(z,{premultiply:!1}),Y.bind(E.NEAREST,E.CLAMP_TO_EDGE)}else i.demTexture=new Ye(C,z,E.RGBA,{premultiply:!1}),i.demTexture.bind(E.NEAREST,E.CLAMP_TO_EDGE);C.activeTexture.set(E.TEXTURE0);let G=i.fbo;if(!G){let Y=new Ye(C,{width:P,height:P,data:null},E.RGBA);Y.bind(E.LINEAR,E.CLAMP_TO_EDGE),G=i.fbo=C.createFramebuffer(P,P,!0,!1),G.colorAttachment.set(Y.texture)}C.bindFramebuffer.set(G.framebuffer),C.viewport.set([0,0,P,P]),m.useProgram("hillshadePrepare").draw(C,E.TRIANGLES,d,f,y,Kt.disabled,((Y,K)=>{let te=K.stride,X=o.F();return o.aN(X,0,o.W,-o.W,0,0,1),o.H(X,X,[0,-o.W,0]),{u_matrix:X,u_image:1,u_dimension:[te,te],u_zoom:Y.overscaledZ,u_unpack:K.getUnpackVector()}})(i.tileID,M),null,c.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments),i.needsHillshadePrepare=!1}}function Bu(m,i,c,d,f,y){let C=d.paint.get("raster-fade-duration");if(!y&&C>0){let E=T.now(),M=(E-m.timeAdded)/C,P=i?(E-i.timeAdded)/C:-1,D=c.getSource(),z=f.coveringZoomLevel({tileSize:D.tileSize,roundZoom:D.roundZoom}),G=!i||Math.abs(i.tileID.overscaledZ-z)>Math.abs(m.tileID.overscaledZ-z),Y=G&&m.refreshedUponExpiration?1:o.ac(G?M:1-P,0,1);return m.refreshedUponExpiration&&M>=1&&(m.refreshedUponExpiration=!1),i?{opacity:1,mix:1-Y}:{opacity:Y,mix:0}}return{opacity:1,mix:0}}let Nu=new o.aO(1,0,0,1),El=new o.aO(0,1,0,1),Lc=new o.aO(0,0,1,1),qp=new o.aO(1,0,1,1),Vu=new o.aO(0,1,1,1);function ui(m,i,c,d){Cr(m,0,i+c/2,m.transform.width,c,d)}function Ts(m,i,c,d){Cr(m,i-c/2,0,c,m.transform.height,d)}function Cr(m,i,c,d,f,y){let C=m.context,E=C.gl;E.enable(E.SCISSOR_TEST),E.scissor(i*m.pixelRatio,c*m.pixelRatio,d*m.pixelRatio,f*m.pixelRatio),C.clear({color:y}),E.disable(E.SCISSOR_TEST)}function Dc(m,i,c){let d=m.context,f=d.gl,y=c.posMatrix,C=m.useProgram("debug"),E=Ot.disabled,M=Jt.disabled,P=m.colorModeForRenderPass(),D="$debug",z=m.style.map.terrain&&m.style.map.terrain.getTerrainData(c);d.activeTexture.set(f.TEXTURE0);let G=i.getTileByID(c.key).latestRawTileData,Y=Math.floor((G&&G.byteLength||0)/1024),K=i.getTile(c).tileSize,te=512/Math.min(K,512)*(c.overscaledZ/m.transform.zoom)*.5,X=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(X+=` => ${c.overscaledZ}`),function(le,xe){le.initDebugOverlayCanvas();let ie=le.debugOverlayCanvas,pe=le.context.gl,we=le.debugOverlayCanvas.getContext("2d");we.clearRect(0,0,ie.width,ie.height),we.shadowColor="white",we.shadowBlur=2,we.lineWidth=1.5,we.strokeStyle="white",we.textBaseline="top",we.font="bold 36px Open Sans, sans-serif",we.fillText(xe,5,5),we.strokeText(xe,5,5),le.debugOverlayTexture.update(ie),le.debugOverlayTexture.bind(pe.LINEAR,pe.CLAMP_TO_EDGE)}(m,`${X} ${Y}kB`),C.draw(d,f.TRIANGLES,E,M,vi.alphaBlended,Kt.disabled,Su(y,o.aO.transparent,te),null,D,m.debugBuffer,m.quadTriangleIndexBuffer,m.debugSegments),C.draw(d,f.LINE_STRIP,E,M,P,Kt.disabled,Su(y,o.aO.red),z,D,m.debugBuffer,m.tileBorderIndexBuffer,m.debugSegments)}function Tl(m,i,c){let d=m.context,f=d.gl,y=m.colorModeForRenderPass(),C=new Ot(f.LEQUAL,Ot.ReadWrite,m.depthRangeFor3D),E=m.useProgram("terrain"),M=i.getTerrainMesh();d.bindFramebuffer.set(null),d.viewport.set([0,0,m.width,m.height]);for(let P of c){let D=m.renderToTexture.getTexture(P),z=i.getTerrainData(P.tileID);d.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,D.texture);let G={u_matrix:m.transform.calculatePosMatrix(P.tileID.toUnwrapped()),u_texture:0,u_ele_delta:i.getMeshFrameDelta(m.transform.zoom)};E.draw(d,f.TRIANGLES,C,Jt.disabled,y,Kt.backCCW,G,z,"terrain",M.vertexBuffer,M.indexBuffer,M.segments)}}class Gu{constructor(i,c){this.context=new $p(i),this.transform=c,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.F(),renderTime:0},this.setup(),this.numSublayers=Li.maxUnderzooming+Li.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Is}resize(i,c,d){if(this.width=Math.floor(i*d),this.height=Math.floor(c*d),this.pixelRatio=d,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let f of this.style._order)this.style._layers[f].resize()}setup(){let i=this.context,c=new o.aV;c.emplaceBack(0,0),c.emplaceBack(o.W,0),c.emplaceBack(0,o.W),c.emplaceBack(o.W,o.W),this.tileExtentBuffer=i.createVertexBuffer(c,nl.members),this.tileExtentSegments=o.$.simpleSegment(0,0,4,2);let d=new o.aV;d.emplaceBack(0,0),d.emplaceBack(o.W,0),d.emplaceBack(0,o.W),d.emplaceBack(o.W,o.W),this.debugBuffer=i.createVertexBuffer(d,nl.members),this.debugSegments=o.$.simpleSegment(0,0,4,5);let f=new o.Z;f.emplaceBack(0,0,0,0),f.emplaceBack(o.W,0,o.W,0),f.emplaceBack(0,o.W,0,o.W),f.emplaceBack(o.W,o.W,o.W,o.W),this.rasterBoundsBuffer=i.createVertexBuffer(f,ci.members),this.rasterBoundsSegments=o.$.simpleSegment(0,0,4,2);let y=new o.aV;y.emplaceBack(0,0),y.emplaceBack(1,0),y.emplaceBack(0,1),y.emplaceBack(1,1),this.viewportBuffer=i.createVertexBuffer(y,nl.members),this.viewportSegments=o.$.simpleSegment(0,0,4,2);let C=new o.aW;C.emplaceBack(0),C.emplaceBack(1),C.emplaceBack(3),C.emplaceBack(2),C.emplaceBack(0),this.tileBorderIndexBuffer=i.createIndexBuffer(C);let E=new o.aX;E.emplaceBack(0,1,2),E.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=i.createIndexBuffer(E);let M=this.context.gl;this.stencilClearMode=new Jt({func:M.ALWAYS,mask:0},0,255,M.ZERO,M.ZERO,M.ZERO)}clearStencil(){let i=this.context,c=i.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let d=o.F();o.aN(d,0,this.width,this.height,0,0,1),o.J(d,d,[c.drawingBufferWidth,c.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(i,c.TRIANGLES,Ot.disabled,this.stencilClearMode,vi.disabled,Kt.disabled,ll(d),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(i,c){if(this.currentStencilSource===i.source||!i.isTileClipped()||!c||!c.length)return;this.currentStencilSource=i.source;let d=this.context,f=d.gl;this.nextStencilID+c.length>256&&this.clearStencil(),d.setColorMode(vi.disabled),d.setDepthMode(Ot.disabled);let y=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let C of c){let E=this._tileClippingMaskIDs[C.key]=this.nextStencilID++,M=this.style.map.terrain&&this.style.map.terrain.getTerrainData(C);y.draw(d,f.TRIANGLES,Ot.disabled,new Jt({func:f.ALWAYS,mask:0},E,255,f.KEEP,f.KEEP,f.REPLACE),vi.disabled,Kt.disabled,ll(C.posMatrix),M,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let i=this.nextStencilID++,c=this.context.gl;return new Jt({func:c.NOTEQUAL,mask:255},i,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(i){let c=this.context.gl;return new Jt({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[i.key],0,c.KEEP,c.KEEP,c.REPLACE)}stencilConfigForOverlap(i){let c=this.context.gl,d=i.sort((C,E)=>E.overscaledZ-C.overscaledZ),f=d[d.length-1].overscaledZ,y=d[0].overscaledZ-f+1;if(y>1){this.currentStencilSource=void 0,this.nextStencilID+y>256&&this.clearStencil();let C={};for(let E=0;E<y;E++)C[E+f]=new Jt({func:c.GEQUAL,mask:255},E+this.nextStencilID,255,c.KEEP,c.KEEP,c.REPLACE);return this.nextStencilID+=y,[C,d]}return[{[f]:Jt.disabled},d]}colorModeForRenderPass(){let i=this.context.gl;return this._showOverdrawInspector?new vi([i.CONSTANT_COLOR,i.ONE],new o.aO(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?vi.unblended:vi.alphaBlended}depthModeForSublayer(i,c,d){if(!this.opaquePassEnabledForLayer())return Ot.disabled;let f=1-((1+this.currentLayer)*this.numSublayers+i)*this.depthEpsilon;return new Ot(d||this.context.gl.LEQUAL,c,[f,f])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(i,c){this.style=i,this.options=c,this.lineAtlas=i.lineAtlas,this.imageManager=i.imageManager,this.glyphManager=i.glyphManager,this.symbolFadeChange=i.placement.symbolFadeChange(T.now()),this.imageManager.beginFrame();let d=this.style._order,f=this.style.sourceCaches,y={},C={},E={};for(let M in f){let P=f[M];P.used&&P.prepare(this.context),y[M]=P.getVisibleCoordinates(),C[M]=y[M].slice().reverse(),E[M]=P.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let M=0;M<d.length;M++)if(this.style._layers[d[M]].is3D()){this.opaquePassCutoff=M;break}if(this.renderToTexture){this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0;let M=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!o.aY(this.terrainFacilitator.matrix,this.transform.projMatrix)||M.length)&&(o.aZ(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(P,D){let z=P.context,G=z.gl,Y=vi.unblended,K=new Ot(G.LEQUAL,Ot.ReadWrite,[0,1]),te=D.getTerrainMesh(),X=D.sourceCache.getRenderableTiles(),le=P.useProgram("terrainDepth");z.bindFramebuffer.set(D.getFramebuffer("depth").framebuffer),z.viewport.set([0,0,P.width/devicePixelRatio,P.height/devicePixelRatio]),z.clear({color:o.aO.transparent,depth:1});for(let xe of X){let ie=D.getTerrainData(xe.tileID),pe={u_matrix:P.transform.calculatePosMatrix(xe.tileID.toUnwrapped()),u_ele_delta:D.getMeshFrameDelta(P.transform.zoom)};le.draw(z,G.TRIANGLES,K,Jt.disabled,Y,Kt.backCCW,pe,ie,"terrain",te.vertexBuffer,te.indexBuffer,te.segments)}z.bindFramebuffer.set(null),z.viewport.set([0,0,P.width,P.height])}(this,this.style.map.terrain),function(P,D){let z=P.context,G=z.gl,Y=vi.unblended,K=new Ot(G.LEQUAL,Ot.ReadWrite,[0,1]),te=D.getTerrainMesh(),X=D.getCoordsTexture(),le=D.sourceCache.getRenderableTiles(),xe=P.useProgram("terrainCoords");z.bindFramebuffer.set(D.getFramebuffer("coords").framebuffer),z.viewport.set([0,0,P.width/devicePixelRatio,P.height/devicePixelRatio]),z.clear({color:o.aO.transparent,depth:1}),D.coordsIndex=[];for(let ie of le){let pe=D.getTerrainData(ie.tileID);z.activeTexture.set(G.TEXTURE0),G.bindTexture(G.TEXTURE_2D,X.texture);let we={u_matrix:P.transform.calculatePosMatrix(ie.tileID.toUnwrapped()),u_terrain_coords_id:(255-D.coordsIndex.length)/255,u_texture:0,u_ele_delta:D.getMeshFrameDelta(P.transform.zoom)};xe.draw(z,G.TRIANGLES,K,Jt.disabled,Y,Kt.backCCW,we,pe,"terrain",te.vertexBuffer,te.indexBuffer,te.segments),D.coordsIndex.push(ie.tileID.key)}z.bindFramebuffer.set(null),z.viewport.set([0,0,P.width,P.height])}(this,this.style.map.terrain))}this.renderPass="offscreen";for(let M of d){let P=this.style._layers[M];if(!P.hasOffscreenPass()||P.isHidden(this.transform.zoom))continue;let D=C[P.source];(P.type==="custom"||D.length)&&this.renderLayer(this,f[P.source],P,D)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:c.showOverdrawInspector?o.aO.black:o.aO.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=c.showOverdrawInspector,this.depthRangeFor3D=[0,1-(i._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){let M=this.style._layers[d[this.currentLayer]],P=f[M.source],D=y[M.source];this._renderTileClippingMasks(M,D),this.renderLayer(this,P,M,D)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let M=this.style._layers[d[this.currentLayer]],P=f[M.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(M))continue;let D=(M.type==="symbol"?E:C)[M.source];this._renderTileClippingMasks(M,y[M.source]),this.renderLayer(this,P,M,D)}if(this.options.showTileBoundaries){let M=function(P,D){let z=null,G=Object.values(P._layers).flatMap(X=>X.source&&!X.isHidden(D)?[P.sourceCaches[X.source]]:[]),Y=G.filter(X=>X.getSource().type==="vector"),K=G.filter(X=>X.getSource().type!=="vector"),te=X=>{(!z||z.getSource().maxzoom<X.getSource().maxzoom)&&(z=X)};return Y.forEach(X=>te(X)),z||K.forEach(X=>te(X)),z}(this.style,this.transform.zoom);M&&function(P,D,z){for(let G=0;G<z.length;G++)Dc(P,D,z[G])}(this,M,M.getVisibleCoordinates())}this.options.showPadding&&function(M){let P=M.transform.padding;ui(M,M.transform.height-(P.top||0),3,Nu),ui(M,P.bottom||0,3,El),Ts(M,P.left||0,3,Lc),Ts(M,M.transform.width-(P.right||0),3,qp);let D=M.transform.centerPoint;(function(z,G,Y,K){Cr(z,G-1,Y-10,2,20,K),Cr(z,G-10,Y-1,20,2,K)})(M,D.x,M.transform.height-D.y,Vu)}(this),this.context.setDefault()}renderLayer(i,c,d,f){if(!d.isHidden(this.transform.zoom)&&(d.type==="background"||d.type==="custom"||(f||[]).length))switch(this.id=d.id,d.type){case"symbol":(function(y,C,E,M,P){if(y.renderPass!=="translucent")return;let D=Jt.disabled,z=y.colorModeForRenderPass();(E._unevaluatedLayout.hasValue("text-variable-anchor")||E._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(G,Y,K,te,X,le,xe){let ie=Y.transform,pe=X==="map",we=le==="map";for(let be of G){let Ae=te.getTile(be),De=Ae.getBucket(K);if(!De||!De.text||!De.text.segments.get().length)continue;let Le=o.ag(De.textSizeData,ie.zoom),Be=_t(Ae,1,Y.transform.zoom),et=vt(be.posMatrix,we,pe,Y.transform,Be),ht=K.layout.get("icon-text-fit")!=="none"&&De.hasIconData();if(Le){let $e=Math.pow(2,ie.zoom-Ae.tileID.overscaledZ);vl(De,pe,we,xe,ie,et,be.posMatrix,$e,Le,ht,Y.style.map.terrain?(ct,nt)=>Y.style.map.terrain.getElevation(be,ct,nt):null)}}}(M,y,E,C,E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),P),E.paint.get("icon-opacity").constantOr(1)!==0&&wl(y,C,E,M,!1,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),E.layout.get("icon-rotation-alignment"),E.layout.get("icon-pitch-alignment"),E.layout.get("icon-keep-upright"),D,z),E.paint.get("text-opacity").constantOr(1)!==0&&wl(y,C,E,M,!0,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.layout.get("text-keep-upright"),D,z),C.map.showCollisionBoxes&&(xl(y,C,E,M,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),!0),xl(y,C,E,M,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),!1))})(i,c,d,f,this.style.placement.variableOffsets);break;case"circle":(function(y,C,E,M){if(y.renderPass!=="translucent")return;let P=E.paint.get("circle-opacity"),D=E.paint.get("circle-stroke-width"),z=E.paint.get("circle-stroke-opacity"),G=!E.layout.get("circle-sort-key").isConstant();if(P.constantOr(1)===0&&(D.constantOr(1)===0||z.constantOr(1)===0))return;let Y=y.context,K=Y.gl,te=y.depthModeForSublayer(0,Ot.ReadOnly),X=Jt.disabled,le=y.colorModeForRenderPass(),xe=[];for(let ie=0;ie<M.length;ie++){let pe=M[ie],we=C.getTile(pe),be=we.getBucket(E);if(!be)continue;let Ae=be.programConfigurations.get(E.id),De=y.useProgram("circle",Ae),Le=be.layoutVertexBuffer,Be=be.indexBuffer,et=y.style.map.terrain&&y.style.map.terrain.getTerrainData(pe),ht={programConfiguration:Ae,program:De,layoutVertexBuffer:Le,indexBuffer:Be,uniformValues:Lp(y,pe,we,E),terrainData:et};if(G){let $e=be.segments.get();for(let ct of $e)xe.push({segments:new o.$([ct]),sortKey:ct.sortKey,state:ht})}else xe.push({segments:be.segments,sortKey:0,state:ht})}G&&xe.sort((ie,pe)=>ie.sortKey-pe.sortKey);for(let ie of xe){let{programConfiguration:pe,program:we,layoutVertexBuffer:be,indexBuffer:Ae,uniformValues:De,terrainData:Le}=ie.state;we.draw(Y,K.TRIANGLES,te,X,le,Kt.disabled,De,Le,E.id,be,Ae,ie.segments,E.paint,y.transform.zoom,pe)}})(i,c,d,f);break;case"heatmap":(function(y,C,E,M){if(E.paint.get("heatmap-opacity")!==0)if(y.renderPass==="offscreen"){let P=y.context,D=P.gl,z=Jt.disabled,G=new vi([D.ONE,D.ONE],o.aO.transparent,[!0,!0,!0,!0]);(function(Y,K,te){let X=Y.gl;Y.activeTexture.set(X.TEXTURE1),Y.viewport.set([0,0,K.width/4,K.height/4]);let le=te.heatmapFbo;if(le)X.bindTexture(X.TEXTURE_2D,le.colorAttachment.get()),Y.bindFramebuffer.set(le.framebuffer);else{let xe=X.createTexture();X.bindTexture(X.TEXTURE_2D,xe),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_S,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_T,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MIN_FILTER,X.LINEAR),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MAG_FILTER,X.LINEAR),le=te.heatmapFbo=Y.createFramebuffer(K.width/4,K.height/4,!1,!1),function(ie,pe,we,be){var Ae,De;let Le=ie.gl,Be=(Ae=ie.HALF_FLOAT)!==null&&Ae!==void 0?Ae:Le.UNSIGNED_BYTE,et=(De=ie.RGBA16F)!==null&&De!==void 0?De:Le.RGBA;Le.texImage2D(Le.TEXTURE_2D,0,et,pe.width/4,pe.height/4,0,Le.RGBA,Be,null),be.colorAttachment.set(we)}(Y,K,xe,le)}})(P,y,E),P.clear({color:o.aO.transparent});for(let Y=0;Y<M.length;Y++){let K=M[Y];if(C.hasRenderableParent(K))continue;let te=C.getTile(K),X=te.getBucket(E);if(!X)continue;let le=X.programConfigurations.get(E.id),xe=y.useProgram("heatmap",le),{zoom:ie}=y.transform;xe.draw(P,D.TRIANGLES,Ot.disabled,z,G,Kt.disabled,Cu(K.posMatrix,te,ie,E.paint.get("heatmap-intensity")),null,E.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,E.paint,y.transform.zoom,le)}P.viewport.set([0,0,y.width,y.height])}else y.renderPass==="translucent"&&(y.context.setColorMode(y.colorModeForRenderPass()),function(P,D){let z=P.context,G=z.gl,Y=D.heatmapFbo;if(!Y)return;z.activeTexture.set(G.TEXTURE0),G.bindTexture(G.TEXTURE_2D,Y.colorAttachment.get()),z.activeTexture.set(G.TEXTURE1);let K=D.colorRampTexture;K||(K=D.colorRampTexture=new Ye(z,D.colorRamp,G.RGBA)),K.bind(G.LINEAR,G.CLAMP_TO_EDGE),P.useProgram("heatmapTexture").draw(z,G.TRIANGLES,Ot.disabled,Jt.disabled,P.colorModeForRenderPass(),Kt.disabled,((te,X,le,xe)=>{let ie=o.F();o.aN(ie,0,te.width,te.height,0,0,1);let pe=te.context.gl;return{u_matrix:ie,u_world:[pe.drawingBufferWidth,pe.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:X.paint.get("heatmap-opacity")}})(P,D),null,D.id,P.viewportBuffer,P.quadTriangleIndexBuffer,P.viewportSegments,D.paint,P.transform.zoom)}(y,E))})(i,c,d,f);break;case"line":(function(y,C,E,M){if(y.renderPass!=="translucent")return;let P=E.paint.get("line-opacity"),D=E.paint.get("line-width");if(P.constantOr(1)===0||D.constantOr(1)===0)return;let z=y.depthModeForSublayer(0,Ot.ReadOnly),G=y.colorModeForRenderPass(),Y=E.paint.get("line-dasharray"),K=E.paint.get("line-pattern"),te=K.constantOr(1),X=E.paint.get("line-gradient"),le=E.getCrossfadeParameters(),xe=te?"linePattern":Y?"lineSDF":X?"lineGradient":"line",ie=y.context,pe=ie.gl,we=!0;for(let be of M){let Ae=C.getTile(be);if(te&&!Ae.patternsLoaded())continue;let De=Ae.getBucket(E);if(!De)continue;let Le=De.programConfigurations.get(E.id),Be=y.context.program.get(),et=y.useProgram(xe,Le),ht=we||et.program!==Be,$e=y.style.map.terrain&&y.style.map.terrain.getTerrainData(be),ct=K.constantOr(null);if(ct&&Ae.imageAtlas){let kt=Ae.imageAtlas,It=kt.patternPositions[ct.to.toString()],Lt=kt.patternPositions[ct.from.toString()];It&&Lt&&Le.setConstantPatternPositions(It,Lt)}let nt=$e?be:null,ei=te?Ys(y,Ae,E,le,nt):Y?hl(y,Ae,E,Y,le,nt):X?Eu(y,Ae,E,De.lineClipsArray.length,nt):cl(y,Ae,E,nt);if(te)ie.activeTexture.set(pe.TEXTURE0),Ae.imageAtlasTexture.bind(pe.LINEAR,pe.CLAMP_TO_EDGE),Le.updatePaintBuffers(le);else if(Y&&(ht||y.lineAtlas.dirty))ie.activeTexture.set(pe.TEXTURE0),y.lineAtlas.bind(ie);else if(X){let kt=De.gradients[E.id],It=kt.texture;if(E.gradientVersion!==kt.version){let Lt=256;if(E.stepInterpolant){let wi=C.getSource().maxzoom,Zt=be.canonical.z===wi?Math.ceil(1<<y.transform.maxZoom-be.canonical.z):1;Lt=o.ac(o.aT(De.maxLineLength/o.W*1024*Zt),256,ie.maxTextureSize)}kt.gradient=o.aU({expression:E.gradientExpression(),evaluationKey:"lineProgress",resolution:Lt,image:kt.gradient||void 0,clips:De.lineClipsArray}),kt.texture?kt.texture.update(kt.gradient):kt.texture=new Ye(ie,kt.gradient,pe.RGBA),kt.version=E.gradientVersion,It=kt.texture}ie.activeTexture.set(pe.TEXTURE0),It.bind(E.stepInterpolant?pe.NEAREST:pe.LINEAR,pe.CLAMP_TO_EDGE)}et.draw(ie,pe.TRIANGLES,z,y.stencilModeForClipping(be),G,Kt.disabled,ei,$e,E.id,De.layoutVertexBuffer,De.indexBuffer,De.segments,E.paint,y.transform.zoom,Le,De.layoutVertexBuffer2),we=!1}})(i,c,d,f);break;case"fill":(function(y,C,E,M){let P=E.paint.get("fill-color"),D=E.paint.get("fill-opacity");if(D.constantOr(1)===0)return;let z=y.colorModeForRenderPass(),G=E.paint.get("fill-pattern"),Y=y.opaquePassEnabledForLayer()&&!G.constantOr(1)&&P.constantOr(o.aO.transparent).a===1&&D.constantOr(0)===1?"opaque":"translucent";if(y.renderPass===Y){let K=y.depthModeForSublayer(1,y.renderPass==="opaque"?Ot.ReadWrite:Ot.ReadOnly);Ou(y,C,E,M,K,z,!1)}if(y.renderPass==="translucent"&&E.paint.get("fill-antialias")){let K=y.depthModeForSublayer(E.getPaintProperty("fill-outline-color")?2:0,Ot.ReadOnly);Ou(y,C,E,M,K,z,!0)}})(i,c,d,f);break;case"fill-extrusion":(function(y,C,E,M){let P=E.paint.get("fill-extrusion-opacity");if(P!==0&&y.renderPass==="translucent"){let D=new Ot(y.context.gl.LEQUAL,Ot.ReadWrite,y.depthRangeFor3D);if(P!==1||E.paint.get("fill-extrusion-pattern").constantOr(1))Cl(y,C,E,M,D,Jt.disabled,vi.disabled),Cl(y,C,E,M,D,y.stencilModeFor3D(),y.colorModeForRenderPass());else{let z=y.colorModeForRenderPass();Cl(y,C,E,M,D,Jt.disabled,z)}}})(i,c,d,f);break;case"hillshade":(function(y,C,E,M){if(y.renderPass!=="offscreen"&&y.renderPass!=="translucent")return;let P=y.context,D=y.depthModeForSublayer(0,Ot.ReadOnly),z=y.colorModeForRenderPass(),[G,Y]=y.renderPass==="translucent"?y.stencilConfigForOverlap(M):[{},M];for(let K of Y){let te=C.getTile(K);te.needsHillshadePrepare!==void 0&&te.needsHillshadePrepare&&y.renderPass==="offscreen"?kc(y,te,E,D,Jt.disabled,z):y.renderPass==="translucent"&&Il(y,K,te,E,D,G[K.overscaledZ],z)}P.viewport.set([0,0,y.width,y.height])})(i,c,d,f);break;case"raster":(function(y,C,E,M){if(y.renderPass!=="translucent"||E.paint.get("raster-opacity")===0||!M.length)return;let P=y.context,D=P.gl,z=C.getSource(),G=y.useProgram("raster"),Y=y.colorModeForRenderPass(),[K,te]=z instanceof Vr?[{},M]:y.stencilConfigForOverlap(M),X=te[te.length-1].overscaledZ,le=!y.options.moving;for(let xe of te){let ie=y.depthModeForSublayer(xe.overscaledZ-X,E.paint.get("raster-opacity")===1?Ot.ReadWrite:Ot.ReadOnly,D.LESS),pe=C.getTile(xe);pe.registerFadeDuration(E.paint.get("raster-fade-duration"));let we=C.findLoadedParent(xe,0),be=Bu(pe,we,C,E,y.transform,y.style.map.terrain),Ae,De,Le=E.paint.get("raster-resampling")==="nearest"?D.NEAREST:D.LINEAR;P.activeTexture.set(D.TEXTURE0),pe.texture.bind(Le,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),P.activeTexture.set(D.TEXTURE1),we?(we.texture.bind(Le,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),Ae=Math.pow(2,we.tileID.overscaledZ-pe.tileID.overscaledZ),De=[pe.tileID.canonical.x*Ae%1,pe.tileID.canonical.y*Ae%1]):pe.texture.bind(Le,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST);let Be=y.style.map.terrain&&y.style.map.terrain.getTerrainData(xe),et=Be?xe:null,ht=et?et.posMatrix:y.transform.calculatePosMatrix(xe.toUnwrapped(),le),$e=ul(ht,De||[0,0],Ae||1,be,E);z instanceof Vr?G.draw(P,D.TRIANGLES,ie,Jt.disabled,Y,Kt.disabled,$e,Be,E.id,z.boundsBuffer,y.quadTriangleIndexBuffer,z.boundsSegments):G.draw(P,D.TRIANGLES,ie,K[xe.overscaledZ],Y,Kt.disabled,$e,Be,E.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments)}})(i,c,d,f);break;case"background":(function(y,C,E,M){let P=E.paint.get("background-color"),D=E.paint.get("background-opacity");if(D===0)return;let z=y.context,G=z.gl,Y=y.transform,K=Y.tileSize,te=E.paint.get("background-pattern");if(y.isPatternMissing(te))return;let X=!te&&P.a===1&&D===1&&y.opaquePassEnabledForLayer()?"opaque":"translucent";if(y.renderPass!==X)return;let le=Jt.disabled,xe=y.depthModeForSublayer(0,X==="opaque"?Ot.ReadWrite:Ot.ReadOnly),ie=y.colorModeForRenderPass(),pe=y.useProgram(te?"backgroundPattern":"background"),we=M||Y.coveringTiles({tileSize:K,terrain:y.style.map.terrain});te&&(z.activeTexture.set(G.TEXTURE0),y.imageManager.bind(y.context));let be=E.getCrossfadeParameters();for(let Ae of we){let De=M?Ae.posMatrix:y.transform.calculatePosMatrix(Ae.toUnwrapped()),Le=te?Fp(De,D,y,te,{tileID:Ae,tileSize:K},be):Dp(De,D,P),Be=y.style.map.terrain&&y.style.map.terrain.getTerrainData(Ae);pe.draw(z,G.TRIANGLES,xe,le,ie,Kt.disabled,Le,Be,E.id,y.tileExtentBuffer,y.quadTriangleIndexBuffer,y.tileExtentSegments)}})(i,0,d,f);break;case"custom":(function(y,C,E){let M=y.context,P=E.implementation;if(y.renderPass==="offscreen"){let D=P.prerender;D&&(y.setCustomLayerDefaults(),M.setColorMode(y.colorModeForRenderPass()),D.call(P,M.gl,y.transform.customLayerMatrix()),M.setDirty(),y.setBaseState())}else if(y.renderPass==="translucent"){y.setCustomLayerDefaults(),M.setColorMode(y.colorModeForRenderPass()),M.setStencilMode(Jt.disabled);let D=P.renderingMode==="3d"?new Ot(y.context.gl.LEQUAL,Ot.ReadWrite,y.depthRangeFor3D):y.depthModeForSublayer(0,Ot.ReadOnly);M.setDepthMode(D),P.render(M.gl,y.transform.customLayerMatrix()),M.setDirty(),y.setBaseState(),M.bindFramebuffer.set(null)}})(i,0,d)}}translatePosMatrix(i,c,d,f,y){if(!d[0]&&!d[1])return i;let C=y?f==="map"?this.transform.angle:0:f==="viewport"?-this.transform.angle:0;if(C){let P=Math.sin(C),D=Math.cos(C);d=[d[0]*D-d[1]*P,d[0]*P+d[1]*D]}let E=[y?d[0]:_t(c,d[0],this.transform.zoom),y?d[1]:_t(c,d[1],this.transform.zoom),0],M=new Float32Array(16);return o.H(M,i,E),M}saveTileTexture(i){let c=this._tileTextures[i.size[0]];c?c.push(i):this._tileTextures[i.size[0]]=[i]}getTileTexture(i){let c=this._tileTextures[i];return c&&c.length>0?c.pop():null}isPatternMissing(i){if(!i)return!1;if(!i.from||!i.to)return!0;let c=this.imageManager.getPattern(i.from.toString()),d=this.imageManager.getPattern(i.to.toString());return!c||!d}useProgram(i,c){this.cache=this.cache||{};let d=i+(c?c.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[d]||(this.cache[d]=new Es(this.context,ma[i],c,Tu[i],this._showOverdrawInspector,this.style.map.terrain)),this.cache[d]}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(){let i=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(i.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ye(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:i,drawingBufferHeight:c}=this.context.gl;return this.width!==i||this.height!==c}}class Ms{constructor(i,c){this.points=i,this.planes=c}static fromInvProjectionMatrix(i,c,d){let f=Math.pow(2,d),y=[[-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(E=>{let M=1/(E=o.af([],E,i))[3]/c*f;return o.a_(E,E,[M,M,1/E[3],M])}),C=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{let M=function(G,Y){var K=Y[0],te=Y[1],X=Y[2],le=K*K+te*te+X*X;return le>0&&(le=1/Math.sqrt(le)),G[0]=Y[0]*le,G[1]=Y[1]*le,G[2]=Y[2]*le,G}([],function(G,Y,K){var te=Y[0],X=Y[1],le=Y[2],xe=K[0],ie=K[1],pe=K[2];return G[0]=X*pe-le*ie,G[1]=le*xe-te*pe,G[2]=te*ie-X*xe,G}([],Ee([],y[E[0]],y[E[1]]),Ee([],y[E[2]],y[E[1]]))),P=-((D=M)[0]*(z=y[E[1]])[0]+D[1]*z[1]+D[2]*z[2]);var D,z;return M.concat(P)});return new Ms(y,C)}}class As{constructor(i,c){this.min=i,this.max=c,this.center=function(d,f,y){return d[0]=.5*f[0],d[1]=.5*f[1],d[2]=.5*f[2],d}([],function(d,f,y){return d[0]=f[0]+y[0],d[1]=f[1]+y[1],d[2]=f[2]+y[2],d}([],this.min,this.max))}quadrant(i){let c=[i%2==0,i<2],d=fe(this.min),f=fe(this.max);for(let y=0;y<c.length;y++)d[y]=c[y]?this.min[y]:this.center[y],f[y]=c[y]?this.center[y]:this.max[y];return f[2]=this.max[2],new As(d,f)}distanceX(i){return Math.max(Math.min(this.max[0],i[0]),this.min[0])-i[0]}distanceY(i){return Math.max(Math.min(this.max[1],i[1]),this.min[1])-i[1]}intersects(i){let c=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]],d=!0;for(let f=0;f<i.planes.length;f++){let y=i.planes[f],C=0;for(let E=0;E<c.length;E++)o.a$(y,c[E])>=0&&C++;if(C===0)return 0;C!==c.length&&(d=!1)}if(d)return 2;for(let f=0;f<3;f++){let y=Number.MAX_VALUE,C=-Number.MAX_VALUE;for(let E=0;E<i.points.length;E++){let M=i.points[E][f]-this.min[f];y=Math.min(y,M),C=Math.max(C,M)}if(C<0||y>this.max[f]-this.min[f])return 0}return 1}}class Oo{constructor(i=0,c=0,d=0,f=0){if(isNaN(i)||i<0||isNaN(c)||c<0||isNaN(d)||d<0||isNaN(f)||f<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=i,this.bottom=c,this.left=d,this.right=f}interpolate(i,c,d){return c.top!=null&&i.top!=null&&(this.top=o.z.number(i.top,c.top,d)),c.bottom!=null&&i.bottom!=null&&(this.bottom=o.z.number(i.bottom,c.bottom,d)),c.left!=null&&i.left!=null&&(this.left=o.z.number(i.left,c.left,d)),c.right!=null&&i.right!=null&&(this.right=o.z.number(i.right,c.right,d)),this}getCenter(i,c){let d=o.ac((this.left+i-this.right)/2,0,i),f=o.ac((this.top+c-this.bottom)/2,0,c);return new o.P(d,f)}equals(i){return this.top===i.top&&this.bottom===i.bottom&&this.left===i.left&&this.right===i.right}clone(){return new Oo(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class Ml{constructor(i,c,d,f,y){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=y===void 0||!!y,this._minZoom=i||0,this._maxZoom=c||22,this._minPitch=d??0,this._maxPitch=f??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Oo,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){let i=new Ml(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return i.apply(this),i}apply(i){this.tileSize=i.tileSize,this.latRange=i.latRange,this.width=i.width,this.height=i.height,this._center=i._center,this._elevation=i._elevation,this.minElevationForCurrentTile=i.minElevationForCurrentTile,this.zoom=i.zoom,this.angle=i.angle,this._fov=i._fov,this._pitch=i._pitch,this._unmodified=i._unmodified,this._edgeInsets=i._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(i){this._minZoom!==i&&(this._minZoom=i,this.zoom=Math.max(this.zoom,i))}get maxZoom(){return this._maxZoom}set maxZoom(i){this._maxZoom!==i&&(this._maxZoom=i,this.zoom=Math.min(this.zoom,i))}get minPitch(){return this._minPitch}set minPitch(i){this._minPitch!==i&&(this._minPitch=i,this.pitch=Math.max(this.pitch,i))}get maxPitch(){return this._maxPitch}set maxPitch(i){this._maxPitch!==i&&(this._maxPitch=i,this.pitch=Math.min(this.pitch,i))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(i){i===void 0?i=!0:i===null&&(i=!1),this._renderWorldCopies=i}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(i){let c=-o.b0(i,-180,180)*Math.PI/180;this.angle!==c&&(this._unmodified=!1,this.angle=c,this._calcMatrices(),this.rotationMatrix=function(){var d=new o.A(4);return o.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}(),function(d,f,y){var C=f[0],E=f[1],M=f[2],P=f[3],D=Math.sin(y),z=Math.cos(y);d[0]=C*z+M*D,d[1]=E*z+P*D,d[2]=C*-D+M*z,d[3]=E*-D+P*z}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(i){let c=o.ac(i,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==c&&(this._unmodified=!1,this._pitch=c,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=i/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(i){let c=Math.min(Math.max(i,this.minZoom),this.maxZoom);this._zoom!==c&&(this._unmodified=!1,this._zoom=c,this.tileZoom=Math.max(0,Math.floor(c)),this.scale=this.zoomScale(c),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(i){i.lat===this._center.lat&&i.lng===this._center.lng||(this._unmodified=!1,this._center=i,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(i){i!==this._elevation&&(this._elevation=i,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(i){this._edgeInsets.equals(i)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,i,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(i){return this._edgeInsets.equals(i)}interpolatePadding(i,c,d){this._unmodified=!1,this._edgeInsets.interpolate(i,c,d),this._constrain(),this._calcMatrices()}coveringZoomLevel(i){let c=(i.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/i.tileSize));return Math.max(0,c)}getVisibleUnwrappedCoordinates(i){let c=[new o.b1(0,i)];if(this._renderWorldCopies){let d=this.pointCoordinate(new o.P(0,0)),f=this.pointCoordinate(new o.P(this.width,0)),y=this.pointCoordinate(new o.P(this.width,this.height)),C=this.pointCoordinate(new o.P(0,this.height)),E=Math.floor(Math.min(d.x,f.x,y.x,C.x)),M=Math.floor(Math.max(d.x,f.x,y.x,C.x)),P=1;for(let D=E-P;D<=M+P;D++)D!==0&&c.push(new o.b1(D,i))}return c}coveringTiles(i){var c,d;let f=this.coveringZoomLevel(i),y=f;if(i.minzoom!==void 0&&f<i.minzoom)return[];i.maxzoom!==void 0&&f>i.maxzoom&&(f=i.maxzoom);let C=this.pointCoordinate(this.getCameraPoint()),E=o.Y.fromLngLat(this.center),M=Math.pow(2,f),P=[M*C.x,M*C.y,0],D=[M*E.x,M*E.y,0],z=Ms.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,f),G=i.minzoom||0;!i.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(G=f);let Y=i.terrain?2/Math.min(this.tileSize,i.tileSize)*this.tileSize:3,K=ie=>({aabb:new As([ie*M,0,0],[(ie+1)*M,M,0]),zoom:0,x:0,y:0,wrap:ie,fullyVisible:!1}),te=[],X=[],le=f,xe=i.reparseOverscaled?y:f;if(this._renderWorldCopies)for(let ie=1;ie<=3;ie++)te.push(K(-ie)),te.push(K(ie));for(te.push(K(0));te.length>0;){let ie=te.pop(),pe=ie.x,we=ie.y,be=ie.fullyVisible;if(!be){let et=ie.aabb.intersects(z);if(et===0)continue;be=et===2}let Ae=i.terrain?P:D,De=ie.aabb.distanceX(Ae),Le=ie.aabb.distanceY(Ae),Be=Math.max(Math.abs(De),Math.abs(Le));if(ie.zoom===le||Be>Y+(1<<le-ie.zoom)-2&&ie.zoom>=G){let et=le-ie.zoom,ht=P[0]-.5-(pe<<et),$e=P[1]-.5-(we<<et);X.push({tileID:new o.Q(ie.zoom===le?xe:ie.zoom,ie.wrap,ie.zoom,pe,we),distanceSq:Re([D[0]-.5-pe,D[1]-.5-we]),tileDistanceToCamera:Math.sqrt(ht*ht+$e*$e)})}else for(let et=0;et<4;et++){let ht=(pe<<1)+et%2,$e=(we<<1)+(et>>1),ct=ie.zoom+1,nt=ie.aabb.quadrant(et);if(i.terrain){let ei=new o.Q(ct,ie.wrap,ct,ht,$e),kt=i.terrain.getMinMaxElevation(ei),It=(c=kt.minElevation)!==null&&c!==void 0?c:this.elevation,Lt=(d=kt.maxElevation)!==null&&d!==void 0?d:this.elevation;nt=new As([nt.min[0],nt.min[1],It],[nt.max[0],nt.max[1],Lt])}te.push({aabb:nt,zoom:ct,x:ht,y:$e,wrap:ie.wrap,fullyVisible:be})}}return X.sort((ie,pe)=>ie.distanceSq-pe.distanceSq).map(ie=>ie.tileID)}resize(i,c){this.width=i,this.height=c,this.pixelsToGLUnits=[2/i,-2/c],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(i){return Math.pow(2,i)}scaleZoom(i){return Math.log(i)/Math.LN2}project(i){let c=o.ac(i.lat,-this.maxValidLatitude,this.maxValidLatitude);return new o.P(o.N(i.lng)*this.worldSize,o.O(c)*this.worldSize)}unproject(i){return new o.Y(i.x/this.worldSize,i.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(i){let c=this.pointLocation(this.centerPoint,i),d=i.getElevationForLngLatZoom(c,this.tileZoom);if(!(this.elevation-d))return;let f=this.getCameraPosition(),y=o.Y.fromLngLat(f.lngLat,f.altitude),C=o.Y.fromLngLat(c,d),E=y.x-C.x,M=y.y-C.y,P=y.z-C.z,D=Math.sqrt(E*E+M*M+P*P),z=this.scaleZoom(this.cameraToCenterDistance/D/this.tileSize);this._elevation=d,this._center=c,this.zoom=z}setLocationAtPoint(i,c){let d=this.pointCoordinate(c),f=this.pointCoordinate(this.centerPoint),y=this.locationCoordinate(i),C=new o.Y(y.x-(d.x-f.x),y.y-(d.y-f.y));this.center=this.coordinateLocation(C),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(i,c){return c?this.coordinatePoint(this.locationCoordinate(i),c.getElevationForLngLatZoom(i,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(i))}pointLocation(i,c){return this.coordinateLocation(this.pointCoordinate(i,c))}locationCoordinate(i){return o.Y.fromLngLat(i)}coordinateLocation(i){return i&&i.toLngLat()}pointCoordinate(i,c){if(c){let G=c.pointCoordinate(i);if(G!=null)return G}let d=[i.x,i.y,0,1],f=[i.x,i.y,1,1];o.af(d,d,this.pixelMatrixInverse),o.af(f,f,this.pixelMatrixInverse);let y=d[3],C=f[3],E=d[1]/y,M=f[1]/C,P=d[2]/y,D=f[2]/C,z=P===D?0:(0-P)/(D-P);return new o.Y(o.z.number(d[0]/y,f[0]/C,z)/this.worldSize,o.z.number(E,M,z)/this.worldSize)}coordinatePoint(i,c=0,d=this.pixelMatrix){let f=[i.x*this.worldSize,i.y*this.worldSize,c,1];return o.af(f,f,d),new o.P(f[0]/f[3],f[1]/f[3])}getBounds(){let i=Math.max(0,this.height/2-this.getHorizon());return new oi().extend(this.pointLocation(new o.P(0,i))).extend(this.pointLocation(new o.P(this.width,i))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new oi([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(i){i?(this.lngRange=[i.getWest(),i.getEast()],this.latRange=[i.getSouth(),i.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(i,c=!1){let d=i.key,f=c?this._alignedPosMatrixCache:this._posMatrixCache;if(f[d])return f[d];let y=i.canonical,C=this.worldSize/this.zoomScale(y.z),E=y.x+Math.pow(2,y.z)*i.wrap,M=o.an(new Float64Array(16));return o.H(M,M,[E*C,y.y*C,0]),o.J(M,M,[C/o.W,C/o.W,1]),o.K(M,c?this.alignedProjMatrix:this.projMatrix,M),f[d]=new Float32Array(M),f[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let i,c,d,f,y=-90,C=90,E=-180,M=180,P=this.size,D=this._unmodified;if(this.latRange){let Y=this.latRange;y=o.O(Y[1])*this.worldSize,C=o.O(Y[0])*this.worldSize,i=C-y<P.y?P.y/(C-y):0}if(this.lngRange){let Y=this.lngRange;E=o.b0(o.N(Y[0])*this.worldSize,0,this.worldSize),M=o.b0(o.N(Y[1])*this.worldSize,0,this.worldSize),M<E&&(M+=this.worldSize),c=M-E<P.x?P.x/(M-E):0}let z=this.point,G=Math.max(c||0,i||0);if(G)return this.center=this.unproject(new o.P(c?(M+E)/2:z.x,i?(C+y)/2:z.y)),this.zoom+=this.scaleZoom(G),this._unmodified=D,void(this._constraining=!1);if(this.latRange){let Y=z.y,K=P.y/2;Y-K<y&&(f=y+K),Y+K>C&&(f=C-K)}if(this.lngRange){let Y=(E+M)/2,K=o.b0(z.x,Y-this.worldSize/2,Y+this.worldSize/2),te=P.x/2;K-te<E&&(d=E+te),K+te>M&&(d=M-te)}d===void 0&&f===void 0||(this.center=this.unproject(new o.P(d!==void 0?d:z.x,f!==void 0?f:z.y)).wrap()),this._unmodified=D,this._constraining=!1}_calcMatrices(){if(!this.height)return;let i=this.centerOffset,c=this.point.x,d=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=o.b2(1,this.center.lat)*this.worldSize;let f=o.an(new Float64Array(16));o.J(f,f,[this.width/2,-this.height/2,1]),o.H(f,f,[1,-1,0]),this.labelPlaneMatrix=f,f=o.an(new Float64Array(16)),o.J(f,f,[1,-1,1]),o.H(f,f,[-1,-1,0]),o.J(f,f,[2/this.width,2/this.height,1]),this.glCoordMatrix=f;let y=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),C=Math.min(this.elevation,this.minElevationForCurrentTile),E=y-C*this._pixelPerMeter/Math.cos(this._pitch),M=C<0?E:y,P=Math.PI/2+this._pitch,D=this._fov*(.5+i.y/this.height),z=Math.sin(D)*M/Math.sin(o.ac(Math.PI-P-D,.01,Math.PI-.01)),G=this.getHorizon(),Y=2*Math.atan(G/this.cameraToCenterDistance)*(.5+i.y/(2*G)),K=Math.sin(Y)*M/Math.sin(o.ac(Math.PI-P-Y,.01,Math.PI-.01)),te=Math.min(z,K),X=1.01*(Math.cos(Math.PI/2-this._pitch)*te+M),le=this.height/50;f=new Float64Array(16),o.b3(f,this._fov,this.width/this.height,le,X),f[8]=2*-i.x/this.width,f[9]=2*i.y/this.height,o.J(f,f,[1,-1,1]),o.H(f,f,[0,0,-this.cameraToCenterDistance]),o.b4(f,f,this._pitch),o.ad(f,f,this.angle),o.H(f,f,[-c,-d,0]),this.mercatorMatrix=o.J([],f,[this.worldSize,this.worldSize,this.worldSize]),o.J(f,f,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.K(new Float64Array(16),this.labelPlaneMatrix,f),o.H(f,f,[0,0,-this.elevation]),this.projMatrix=f,this.invProjMatrix=o.ar([],f),this.pixelMatrix3D=o.K(new Float64Array(16),this.labelPlaneMatrix,f);let xe=this.width%2/2,ie=this.height%2/2,pe=Math.cos(this.angle),we=Math.sin(this.angle),be=c-Math.round(c)+pe*xe+we*ie,Ae=d-Math.round(d)+pe*ie+we*xe,De=new Float64Array(f);if(o.H(De,De,[be>.5?be-1:be,Ae>.5?Ae-1:Ae,0]),this.alignedProjMatrix=De,f=o.ar(new Float64Array(16),this.pixelMatrix),!f)throw new Error("failed to invert matrix");this.pixelMatrixInverse=f,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let i=this.pointCoordinate(new o.P(0,0)),c=[i.x*this.worldSize,i.y*this.worldSize,0,1];return o.af(c,c,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let i=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,i))}getCameraQueryGeometry(i){let c=this.getCameraPoint();if(i.length===1)return[i[0],c];{let d=c.x,f=c.y,y=c.x,C=c.y;for(let E of i)d=Math.min(d,E.x),f=Math.min(f,E.y),y=Math.max(y,E.x),C=Math.max(C,E.y);return[new o.P(d,f),new o.P(y,f),new o.P(y,C),new o.P(d,C),new o.P(d,f)]}}lngLatToCameraDepth(i,c){let d=this.locationCoordinate(i),f=[d.x*this.worldSize,d.y*this.worldSize,c,1];return o.af(f,f,this.projMatrix),f[2]/f[3]}}function Fc(m,i){let c,d=!1,f=null,y=null,C=()=>{f=null,d&&(m.apply(y,c),f=setTimeout(C,i),d=!1)};return(...E)=>(d=!0,y=this,c=E,f||C(),f)}class zc{constructor(i){this._getCurrentHash=()=>{let c=window.location.hash.replace("#","");if(this._hashName){let d;return c.split("&").map(f=>f.split("=")).forEach(f=>{f[0]===this._hashName&&(d=f)}),(d&&d[1]||"").split("/")}return c.split("/")},this._onHashChange=()=>{let c=this._getCurrentHash();if(c.length>=3&&!c.some(d=>isNaN(d))){let d=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(c[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+c[2],+c[1]],zoom:+c[0],bearing:d,pitch:+(c[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let c=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,c)}catch{}},this._updateHash=Fc(this._updateHashUnthrottled,300),this._hashName=i&&encodeURIComponent(i)}addTo(i){return this._map=i,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(i){let c=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,f=Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10),y=Math.pow(10,f),C=Math.round(c.lng*y)/y,E=Math.round(c.lat*y)/y,M=this._map.getBearing(),P=this._map.getPitch(),D="";if(D+=i?`/${C}/${E}/${d}`:`${d}/${E}/${C}`,(M||P)&&(D+="/"+Math.round(10*M)/10),P&&(D+=`/${Math.round(P)}`),this._hashName){let z=this._hashName,G=!1,Y=window.location.hash.slice(1).split("&").map(K=>{let te=K.split("=")[0];return te===z?(G=!0,`${te}=${D}`):K}).filter(K=>K);return G||Y.push(`${z}=${D}`),`#${Y.join("&")}`}return`#${D}`}}let Sa={linearity:.3,easing:o.b5(0,0,.3,1)},ju=o.e({deceleration:2500,maxSpeed:1400},Sa),eo=o.e({deceleration:20,maxSpeed:1400},Sa),Uu=o.e({deceleration:1e3,maxSpeed:360},Sa),$u=o.e({deceleration:1e3,maxSpeed:90},Sa);class qu{constructor(i){this._map=i,this.clear()}clear(){this._inertiaBuffer=[]}record(i){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:T.now(),settings:i})}_drainInertiaBuffer(){let i=this._inertiaBuffer,c=T.now();for(;i.length>0&&c-i[0].time>160;)i.shift()}_onMoveEnd(i){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let c={zoom:0,bearing:0,pitch:0,pan:new o.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:y}of this._inertiaBuffer)c.zoom+=y.zoomDelta||0,c.bearing+=y.bearingDelta||0,c.pitch+=y.pitchDelta||0,y.panDelta&&c.pan._add(y.panDelta),y.around&&(c.around=y.around),y.pinchAround&&(c.pinchAround=y.pinchAround);let d=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(c.pan.mag()){let y=Ia(c.pan.mag(),d,o.e({},ju,i||{}));f.offset=c.pan.mult(y.amount/c.pan.mag()),f.center=this._map.transform.center,Ca(f,y)}if(c.zoom){let y=Ia(c.zoom,d,eo);f.zoom=this._map.transform.zoom+y.amount,Ca(f,y)}if(c.bearing){let y=Ia(c.bearing,d,Uu);f.bearing=this._map.transform.bearing+o.ac(y.amount,-179,179),Ca(f,y)}if(c.pitch){let y=Ia(c.pitch,d,$u);f.pitch=this._map.transform.pitch+y.amount,Ca(f,y)}if(f.zoom||f.bearing){let y=c.pinchAround===void 0?c.around:c.pinchAround;f.around=y?this._map.unproject(y):this._map.getCenter()}return this.clear(),o.e(f,{noMoveStart:!0})}}function Ca(m,i){(!m.duration||m.duration<i.duration)&&(m.duration=i.duration,m.easing=i.easing)}function Ia(m,i,c){let{maxSpeed:d,linearity:f,deceleration:y}=c,C=o.ac(m*f/(i/1e3),-d,d),E=Math.abs(C)/(y*f);return{easing:c.easing,duration:1e3*E,amount:C*(E/2)}}class Ur extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,c,d,f={}){let y=S.mousePos(c.getCanvas(),d),C=c.unproject(y);super(i,o.e({point:y,lngLat:C,originalEvent:d},f)),this._defaultPrevented=!1,this.target=c}}class Bo extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,c,d){let f=i==="touchend"?d.changedTouches:d.touches,y=S.touchPos(c.getCanvasContainer(),f),C=y.map(M=>c.unproject(M)),E=y.reduce((M,P,D,z)=>M.add(P.div(z.length)),new o.P(0,0));super(i,{points:y,point:E,lngLats:C,lngLat:c.unproject(E),originalEvent:d}),this._defaultPrevented=!1}}class to extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,c,d){super(i,{originalEvent:d}),this._defaultPrevented=!1}}class Wu{constructor(i,c){this._map=i,this._clickTolerance=c.clickTolerance}reset(){delete this._mousedownPos}wheel(i){return this._firePreventable(new to(i.type,this._map,i))}mousedown(i,c){return this._mousedownPos=c,this._firePreventable(new Ur(i.type,this._map,i))}mouseup(i){this._map.fire(new Ur(i.type,this._map,i))}click(i,c){this._mousedownPos&&this._mousedownPos.dist(c)>=this._clickTolerance||this._map.fire(new Ur(i.type,this._map,i))}dblclick(i){return this._firePreventable(new Ur(i.type,this._map,i))}mouseover(i){this._map.fire(new Ur(i.type,this._map,i))}mouseout(i){this._map.fire(new Ur(i.type,this._map,i))}touchstart(i){return this._firePreventable(new Bo(i.type,this._map,i))}touchmove(i){this._map.fire(new Bo(i.type,this._map,i))}touchend(i){this._map.fire(new Bo(i.type,this._map,i))}touchcancel(i){this._map.fire(new Bo(i.type,this._map,i))}_firePreventable(i){if(this._map.fire(i),i.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bn{constructor(i){this._map=i}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(i){this._map.fire(new Ur(i.type,this._map,i))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ur("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(i){this._delayContextMenu?this._contextMenuEvent=i:this._ignoreContextMenu||this._map.fire(new Ur(i.type,this._map,i)),this._map.listens("contextmenu")&&i.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class $r{constructor(i){this._map=i}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(i){return this.transform.pointLocation(o.P.convert(i),this._map.terrain)}}class Oc{constructor(i,c){this._map=i,this._tr=new $r(i),this._el=i.getCanvasContainer(),this._container=i.getContainer(),this._clickTolerance=c.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(i,c){this.isEnabled()&&i.shiftKey&&i.button===0&&(S.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(i,c){if(!this._active)return;let d=c;if(this._lastPos.equals(d)||!this._box&&d.dist(this._startPos)<this._clickTolerance)return;let f=this._startPos;this._lastPos=d,this._box||(this._box=S.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",i));let y=Math.min(f.x,d.x),C=Math.max(f.x,d.x),E=Math.min(f.y,d.y),M=Math.max(f.y,d.y);S.setTransform(this._box,`translate(${y}px,${E}px)`),this._box.style.width=C-y+"px",this._box.style.height=M-E+"px"}mouseupWindow(i,c){if(!this._active||i.button!==0)return;let d=this._startPos,f=c;if(this.reset(),S.suppressClick(),d.x!==f.x||d.y!==f.y)return this._map.fire(new o.k("boxzoomend",{originalEvent:i})),{cameraAnimation:y=>y.fitScreenCoordinates(d,f,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",i)}keydown(i){this._active&&i.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",i))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(S.remove(this._box),this._box=null),S.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(i,c){return this._map.fire(new o.k(i,{originalEvent:c}))}}function yn(m,i){if(m.length!==i.length)throw new Error(`The number of touches and points are not equal - touches ${m.length}, points ${i.length}`);let c={};for(let d=0;d<m.length;d++)c[m[d].identifier]=i[d];return c}class Ea{constructor(i){this.reset(),this.numTouches=i.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(i,c,d){(this.centroid||d.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=i.timeStamp),d.length===this.numTouches&&(this.centroid=function(f){let y=new o.P(0,0);for(let C of f)y._add(C);return y.div(f.length)}(c),this.touches=yn(d,c)))}touchmove(i,c,d){if(this.aborted||!this.centroid)return;let f=yn(d,c);for(let y in this.touches){let C=f[y];(!C||C.dist(this.touches[y])>30)&&(this.aborted=!0)}}touchend(i,c,d){if((!this.centroid||i.timeStamp-this.startTime>500)&&(this.aborted=!0),d.length===0){let f=!this.aborted&&this.centroid;if(this.reset(),f)return f}}}class Bc{constructor(i){this.singleTap=new Ea(i),this.numTaps=i.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(i,c,d){this.singleTap.touchstart(i,c,d)}touchmove(i,c,d){this.singleTap.touchmove(i,c,d)}touchend(i,c,d){let f=this.singleTap.touchend(i,c,d);if(f){let y=i.timeStamp-this.lastTime<500,C=!this.lastTap||this.lastTap.dist(f)<30;if(y&&C||this.reset(),this.count++,this.lastTime=i.timeStamp,this.lastTap=f,this.count===this.numTaps)return this.reset(),f}}}class Wp{constructor(i){this._tr=new $r(i),this._zoomIn=new Bc({numTouches:1,numTaps:2}),this._zoomOut=new Bc({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(i,c,d){this._zoomIn.touchstart(i,c,d),this._zoomOut.touchstart(i,c,d)}touchmove(i,c,d){this._zoomIn.touchmove(i,c,d),this._zoomOut.touchmove(i,c,d)}touchend(i,c,d){let f=this._zoomIn.touchend(i,c,d),y=this._zoomOut.touchend(i,c,d),C=this._tr;return f?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:C.zoom+1,around:C.unproject(f)},{originalEvent:i})}):y?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:C.zoom-1,around:C.unproject(y)},{originalEvent:i})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ta{constructor(i){this._enabled=!!i.enable,this._moveStateManager=i.moveStateManager,this._clickTolerance=i.clickTolerance||1,this._moveFunction=i.move,this._activateOnStart=!!i.activateOnStart,i.assignEvents(this),this.reset()}reset(i){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(i)}_move(...i){let c=this._moveFunction(...i);if(c.bearingDelta||c.pitchDelta||c.around||c.panDelta)return this._active=!0,c}dragStart(i,c){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(i)&&(this._moveStateManager.startMove(i),this._lastPoint=c.length?c[0]:c,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(i,c){if(!this.isEnabled())return;let d=this._lastPoint;if(!d)return;if(i.preventDefault(),!this._moveStateManager.isValidMoveEvent(i))return void this.reset(i);let f=c.length?c[0]:c;return!this._moved&&f.dist(d)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=f,this._move(d,f))}dragEnd(i){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(i)&&(this._moved&&S.suppressClick(),this.reset(i))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let Zu={0:1,2:2};class io{constructor(i){this._correctEvent=i.checkCorrectEvent}startMove(i){let c=S.mouseButton(i);this._eventButton=c}endMove(i){delete this._eventButton}isValidStartEvent(i){return this._correctEvent(i)}isValidMoveEvent(i){return!function(c,d){let f=Zu[d];return c.buttons===void 0||(c.buttons&f)!==f}(i,this._eventButton)}isValidEndEvent(i){return S.mouseButton(i)===this._eventButton}}class as{constructor(){this._firstTouch=void 0}_isOneFingerTouch(i){return i.targetTouches.length===1}_isSameTouchEvent(i){return i.targetTouches[0].identifier===this._firstTouch}startMove(i){this._firstTouch=i.targetTouches[0].identifier}endMove(i){delete this._firstTouch}isValidStartEvent(i){return this._isOneFingerTouch(i)}isValidMoveEvent(i){return this._isOneFingerTouch(i)&&this._isSameTouchEvent(i)}isValidEndEvent(i){return this._isOneFingerTouch(i)&&this._isSameTouchEvent(i)}}let Je=m=>{m.mousedown=m.dragStart,m.mousemoveWindow=m.dragMove,m.mouseup=m.dragEnd,m.contextmenu=function(i){i.preventDefault()}},Nc=({enable:m,clickTolerance:i,bearingDegreesPerPixelMoved:c=.8})=>{let d=new io({checkCorrectEvent:f=>S.mouseButton(f)===0&&f.ctrlKey||S.mouseButton(f)===2});return new Ta({clickTolerance:i,move:(f,y)=>({bearingDelta:(y.x-f.x)*c}),moveStateManager:d,enable:m,assignEvents:Je})},No=({enable:m,clickTolerance:i,pitchDegreesPerPixelMoved:c=-.5})=>{let d=new io({checkCorrectEvent:f=>S.mouseButton(f)===0&&f.ctrlKey||S.mouseButton(f)===2});return new Ta({clickTolerance:i,move:(f,y)=>({pitchDelta:(y.y-f.y)*c}),moveStateManager:d,enable:m,assignEvents:Je})};class Ma{constructor(i,c){this._clickTolerance=i.clickTolerance||1,this._map=c,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(i,c,d){return this._calculateTransform(i,c,d)}touchmove(i,c,d){if(this._active&&!(d.length<this.minTouchs()))return i.preventDefault(),this._calculateTransform(i,c,d)}touchend(i,c,d){this._calculateTransform(i,c,d),this._active&&d.length<this.minTouchs()&&this.reset()}touchcancel(){this.reset()}_calculateTransform(i,c,d){d.length>0&&(this._active=!0);let f=yn(d,c),y=new o.P(0,0),C=new o.P(0,0),E=0;for(let P in f){let D=f[P],z=this._touches[P];z&&(y._add(D),C._add(D.sub(z)),E++,f[P]=D)}if(this._touches=f,E<this.minTouchs()||!C.mag())return;let M=C.div(E);return this._sum._add(M),this._sum.mag()<this._clickTolerance?void 0:{around:y.div(E),panDelta:M}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Al{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(i,c,d){this._firstTwoTouches||d.length<2||(this._firstTwoTouches=[d[0].identifier,d[1].identifier],this._start([c[0],c[1]]))}touchmove(i,c,d){if(!this._firstTwoTouches)return;i.preventDefault();let[f,y]=this._firstTwoTouches,C=Ze(d,c,f),E=Ze(d,c,y);if(!C||!E)return;let M=this._aroundCenter?null:C.add(E).div(2);return this._move([C,E],M,i)}touchend(i,c,d){if(!this._firstTwoTouches)return;let[f,y]=this._firstTwoTouches,C=Ze(d,c,f),E=Ze(d,c,y);C&&E||(this._active&&S.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(i){this._enabled=!0,this._aroundCenter=!!i&&i.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ze(m,i,c){for(let d=0;d<m.length;d++)if(m[d].identifier===c)return i[d]}function Pl(m,i){return Math.log(m/i)/Math.LN2}class Xu extends Al{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(i){this._startDistance=this._distance=i[0].dist(i[1])}_move(i,c){let d=this._distance;if(this._distance=i[0].dist(i[1]),this._active||!(Math.abs(Pl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Pl(this._distance,d),pinchAround:c}}}function Hu(m,i){return 180*m.angleWith(i)/Math.PI}class Rl extends Al{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(i){this._startVector=this._vector=i[0].sub(i[1]),this._minDiameter=i[0].dist(i[1])}_move(i,c,d){let f=this._vector;if(this._vector=i[0].sub(i[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Hu(this._vector,f),pinchAround:c}}_isBelowThreshold(i){this._minDiameter=Math.min(this._minDiameter,i.mag());let c=25/(Math.PI*this._minDiameter)*360,d=Hu(i,this._startVector);return Math.abs(d)<c}}function kl(m){return Math.abs(m.y)>Math.abs(m.x)}class Vc extends Al{constructor(i){super(),this._currentTouchCount=0,this._map=i}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(i,c,d){super.touchstart(i,c,d),this._currentTouchCount=d.length}_start(i){this._lastPoints=i,kl(i[0].sub(i[1]))&&(this._valid=!1)}_move(i,c,d){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let f=i[0].sub(this._lastPoints[0]),y=i[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(f,y,d.timeStamp),this._valid?(this._lastPoints=i,this._active=!0,{pitchDelta:(f.y+y.y)/2*-.5}):void 0}gestureBeginsVertically(i,c,d){if(this._valid!==void 0)return this._valid;let f=i.mag()>=2,y=c.mag()>=2;if(!f&&!y)return;if(!f||!y)return this._firstMove===void 0&&(this._firstMove=d),d-this._firstMove<100&&void 0;let C=i.y>0==c.y>0;return kl(i)&&kl(c)&&C}}let Zp={panStep:100,bearingStep:15,pitchStep:10};class Yu{constructor(i){this._tr=new $r(i);let c=Zp;this._panStep=c.panStep,this._bearingStep=c.bearingStep,this._pitchStep=c.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let c=0,d=0,f=0,y=0,C=0;switch(i.keyCode){case 61:case 107:case 171:case 187:c=1;break;case 189:case 109:case 173:c=-1;break;case 37:i.shiftKey?d=-1:(i.preventDefault(),y=-1);break;case 39:i.shiftKey?d=1:(i.preventDefault(),y=1);break;case 38:i.shiftKey?f=1:(i.preventDefault(),C=-1);break;case 40:i.shiftKey?f=-1:(i.preventDefault(),C=1);break;default:return}return this._rotationDisabled&&(d=0,f=0),{cameraAnimation:E=>{let M=this._tr;E.easeTo({duration:300,easeId:"keyboardHandler",easing:ro,zoom:c?Math.round(M.zoom)+c*(i.shiftKey?2:1):M.zoom,bearing:M.bearing+d*this._bearingStep,pitch:M.pitch+f*this._pitchStep,offset:[-y*this._panStep,-C*this._panStep],center:M.center},{originalEvent:i})}}}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 ro(m){return m*(2-m)}let Qt=4.000244140625;class Aa{constructor(i,c){this._onTimeout=d=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(d)},this._map=i,this._tr=new $r(i),this._triggerRenderFrame=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(i){this._defaultZoomRate=i}setWheelZoomRate(i){this._wheelZoomRate=i}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(i){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!i&&i.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(i){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!i[this._map.cooperativeGestures._bypassKey])return;let c=i.deltaMode===WheelEvent.DOM_DELTA_LINE?40*i.deltaY:i.deltaY,d=T.now(),f=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,c!==0&&c%Qt==0?this._type="wheel":c!==0&&Math.abs(c)<4?this._type="trackpad":f>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,i)):this._type||(this._type=Math.abs(f*c)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),i.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=i,this._delta-=c,this._active||this._start(i)),i.preventDefault()}_start(i){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);let c=S.mousePos(this._map.getCanvas(),i),d=this._tr;this._around=c.y>d.transform.height/2-d.transform.getHorizon()?o.M.convert(this._aroundCenter?d.center:d.unproject(c)):o.M.convert(d.center),this._aroundPoint=d.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let i=this._tr.transform;if(this._delta!==0){let E=this._type==="wheel"&&Math.abs(this._delta)>Qt?this._wheelZoomRate:this._defaultZoomRate,M=2/(1+Math.exp(-Math.abs(this._delta*E)));this._delta<0&&M!==0&&(M=1/M);let P=typeof this._targetZoom=="number"?i.zoomScale(this._targetZoom):i.scale;this._targetZoom=Math.min(i.maxZoom,Math.max(i.minZoom,i.scaleZoom(P*M))),this._type==="wheel"&&(this._startZoom=i.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let c=typeof this._targetZoom=="number"?this._targetZoom:i.zoom,d=this._startZoom,f=this._easing,y,C=!1;if(this._type==="wheel"&&d&&f){let E=Math.min((T.now()-this._lastWheelEventTime)/200,1),M=f(E);y=o.z.number(d,c,M),E<1?this._frameId||(this._frameId=!0):C=!0}else y=c,C=!0;return this._active=!0,C&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!C,zoomDelta:y-i.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(i){let c=o.b6;if(this._prevEase){let d=this._prevEase,f=(T.now()-d.start)/d.duration,y=d.easing(f+.01)-d.easing(f),C=.27/Math.sqrt(y*y+1e-4)*.01,E=Math.sqrt(.0729-C*C);c=o.b5(C,E,.25,1)}return this._prevEase={start:T.now(),duration:i,easing:c},c}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ll{constructor(i,c){this._clickZoom=i,this._tapZoom=c}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 Ku{constructor(i){this._tr=new $r(i),this.reset()}reset(){this._active=!1}dblclick(i,c){return i.preventDefault(),{cameraAnimation:d=>{d.easeTo({duration:300,zoom:this._tr.zoom+(i.shiftKey?-1:1),around:this._tr.unproject(c)},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ju{constructor(){this._tap=new Bc({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(i,c,d){if(!this._swipePoint)if(this._tapTime){let f=c[0],y=i.timeStamp-this._tapTime<500,C=this._tapPoint.dist(f)<30;y&&C?d.length>0&&(this._swipePoint=f,this._swipeTouch=d[0].identifier):this.reset()}else this._tap.touchstart(i,c,d)}touchmove(i,c,d){if(this._tapTime){if(this._swipePoint){if(d[0].identifier!==this._swipeTouch)return;let f=c[0],y=f.y-this._swipePoint.y;return this._swipePoint=f,i.preventDefault(),this._active=!0,{zoomDelta:y/128}}}else this._tap.touchmove(i,c,d)}touchend(i,c,d){if(this._tapTime)this._swipePoint&&d.length===0&&this.reset();else{let f=this._tap.touchend(i,c,d);f&&(this._tapTime=i.timeStamp,this._tapPoint=f)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Gc{constructor(i,c,d){this._el=i,this._mousePan=c,this._touchPan=d}enable(i){this._inertiaOptions=i||{},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 Qu{constructor(i,c,d){this._pitchWithRotate=i.pitchWithRotate,this._mouseRotate=c,this._mousePitch=d}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 Nn{constructor(i,c,d,f){this._el=i,this._touchZoom=c,this._touchRotate=d,this._tapDragZoom=f,this._rotationDisabled=!1,this._enabled=!0}enable(i){this._touchZoom.enable(i),this._rotationDisabled||this._touchRotate.enable(i),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 Pa{constructor(i,c){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=i,this._options=c,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let i=this._map.getCanvasContainer();i.classList.add("maplibregl-cooperative-gestures"),this._container=S.create("div","maplibregl-cooperative-gesture-screen",i);let c=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(c=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let d=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),f=document.createElement("div");f.className="maplibregl-desktop-message",f.textContent=c,this._container.appendChild(f);let y=document.createElement("div");y.className="maplibregl-mobile-message",y.textContent=d,this._container.appendChild(y),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(S.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._destoryUI()}isEnabled(){return this._enabled}touchmove(i){this._onCooperativeGesture(i.touches.length===1)}wheel(i){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!i[this._bypassKey])}_onCooperativeGesture(i){this._enabled&&i&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let ot=m=>m.zoom||m.drag||m.pitch||m.rotate;class pt extends o.k{}function Vo(m){return m.panDelta&&m.panDelta.mag()||m.zoomDelta||m.bearingDelta||m.pitchDelta}class jc{constructor(i,c){this.handleWindowEvent=f=>{this.handleEvent(f,`${f.type}Window`)},this.handleEvent=(f,y)=>{if(f.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let C=f.type==="renderFrame"?void 0:f,E={needsRenderFrame:!1},M={},P={},D=f.touches,z=D?this._getMapTouches(D):void 0,G=z?S.touchPos(this._map.getCanvas(),z):S.mousePos(this._map.getCanvas(),f);for(let{handlerName:te,handler:X,allowed:le}of this._handlers){if(!X.isEnabled())continue;let xe;this._blockedByActive(P,le,te)?X.reset():X[y||f.type]&&(xe=X[y||f.type](f,G,z),this.mergeHandlerResult(E,M,xe,te,C),xe&&xe.needsRenderFrame&&this._triggerRenderFrame()),(xe||X.isActive())&&(P[te]=X)}let Y={};for(let te in this._previousActiveHandlers)P[te]||(Y[te]=C);this._previousActiveHandlers=P,(Object.keys(Y).length||Vo(E))&&(this._changes.push([E,M,Y]),this._triggerRenderFrame()),(Object.keys(P).length||Vo(E))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:K}=E;K&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],K(this._map))},this._map=i,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new qu(i),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(c);let d=this._el;this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[window,"blur",void 0]];for(let[f,y,C]of this._listeners)S.addEventListener(f,y,f===document?this.handleWindowEvent:this.handleEvent,C)}destroy(){for(let[i,c,d]of this._listeners)S.removeEventListener(i,c,i===document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(i){let c=this._map,d=c.getCanvasContainer();this._add("mapEvent",new Wu(c,i));let f=c.boxZoom=new Oc(c,i);this._add("boxZoom",f),i.interactive&&i.boxZoom&&f.enable();let y=c.cooperativeGestures=new Pa(c,i.cooperativeGestures);this._add("cooperativeGestures",y),i.cooperativeGestures&&y.enable();let C=new Wp(c),E=new Ku(c);c.doubleClickZoom=new Ll(E,C),this._add("tapZoom",C),this._add("clickZoom",E),i.interactive&&i.doubleClickZoom&&c.doubleClickZoom.enable();let M=new Ju;this._add("tapDragZoom",M);let P=c.touchPitch=new Vc(c);this._add("touchPitch",P),i.interactive&&i.touchPitch&&c.touchPitch.enable(i.touchPitch);let D=Nc(i),z=No(i);c.dragRotate=new Qu(i,D,z),this._add("mouseRotate",D,["mousePitch"]),this._add("mousePitch",z,["mouseRotate"]),i.interactive&&i.dragRotate&&c.dragRotate.enable();let G=(({enable:xe,clickTolerance:ie})=>{let pe=new io({checkCorrectEvent:we=>S.mouseButton(we)===0&&!we.ctrlKey});return new Ta({clickTolerance:ie,move:(we,be)=>({around:be,panDelta:be.sub(we)}),activateOnStart:!0,moveStateManager:pe,enable:xe,assignEvents:Je})})(i),Y=new Ma(i,c);c.dragPan=new Gc(d,G,Y),this._add("mousePan",G),this._add("touchPan",Y,["touchZoom","touchRotate"]),i.interactive&&i.dragPan&&c.dragPan.enable(i.dragPan);let K=new Rl,te=new Xu;c.touchZoomRotate=new Nn(d,te,K,M),this._add("touchRotate",K,["touchPan","touchZoom"]),this._add("touchZoom",te,["touchPan","touchRotate"]),i.interactive&&i.touchZoomRotate&&c.touchZoomRotate.enable(i.touchZoomRotate);let X=c.scrollZoom=new Aa(c,()=>this._triggerRenderFrame());this._add("scrollZoom",X,["mousePan"]),i.interactive&&i.scrollZoom&&c.scrollZoom.enable(i.scrollZoom);let le=c.keyboard=new Yu(c);this._add("keyboard",le),i.interactive&&i.keyboard&&c.keyboard.enable(),this._add("blockableMapEvent",new Bn(c))}_add(i,c,d){this._handlers.push({handlerName:i,handler:c,allowed:d}),this._handlersById[i]=c}stop(i){if(!this._updatingCamera){for(let{handler:c}of this._handlers)c.reset();this._inertia.clear(),this._fireEvents({},{},i),this._changes=[]}}isActive(){for(let{handler:i}of this._handlers)if(i.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ot(this._eventsInProgress)||this.isZooming()}_blockedByActive(i,c,d){for(let f in i)if(f!==d&&(!c||c.indexOf(f)<0))return!0;return!1}_getMapTouches(i){let c=[];for(let d of i)this._el.contains(d.target)&&c.push(d);return c}mergeHandlerResult(i,c,d,f,y){if(!d)return;o.e(i,d);let C={handlerName:f,originalEvent:d.originalEvent||y};d.zoomDelta!==void 0&&(c.zoom=C),d.panDelta!==void 0&&(c.drag=C),d.pitchDelta!==void 0&&(c.pitch=C),d.bearingDelta!==void 0&&(c.rotate=C)}_applyChanges(){let i={},c={},d={};for(let[f,y,C]of this._changes)f.panDelta&&(i.panDelta=(i.panDelta||new o.P(0,0))._add(f.panDelta)),f.zoomDelta&&(i.zoomDelta=(i.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(i.bearingDelta=(i.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(i.pitchDelta=(i.pitchDelta||0)+f.pitchDelta),f.around!==void 0&&(i.around=f.around),f.pinchAround!==void 0&&(i.pinchAround=f.pinchAround),f.noInertia&&(i.noInertia=f.noInertia),o.e(c,y),o.e(d,C);this._updateMapTransform(i,c,d),this._changes=[]}_updateMapTransform(i,c,d){let f=this._map,y=f._getTransformForUpdate(),C=f.terrain;if(!(Vo(i)||C&&this._terrainMovement))return this._fireEvents(c,d,!0);let{panDelta:E,zoomDelta:M,bearingDelta:P,pitchDelta:D,around:z,pinchAround:G}=i;G!==void 0&&(z=G),f._stop(!0),z=z||f.transform.centerPoint;let Y=y.pointLocation(E?z.sub(E):z);P&&(y.bearing+=P),D&&(y.pitch+=D),M&&(y.zoom+=M),C?this._terrainMovement||!c.drag&&!c.zoom?c.drag&&this._terrainMovement?y.center=y.pointLocation(y.centerPoint.sub(E)):y.setLocationAtPoint(Y,z):(this._terrainMovement=!0,this._map._elevationFreeze=!0,y.setLocationAtPoint(Y,z),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,y.recalculateZoom(f.terrain)})):y.setLocationAtPoint(Y,z),f._applyUpdatedTransform(y),this._map._update(),i.noInertia||this._inertia.record(i),this._fireEvents(c,d,!0)}_fireEvents(i,c,d){let f=ot(this._eventsInProgress),y=ot(i),C={};for(let D in i){let{originalEvent:z}=i[D];this._eventsInProgress[D]||(C[`${D}start`]=z),this._eventsInProgress[D]=i[D]}!f&&y&&this._fireEvent("movestart",y.originalEvent);for(let D in C)this._fireEvent(D,C[D]);y&&this._fireEvent("move",y.originalEvent);for(let D in i){let{originalEvent:z}=i[D];this._fireEvent(D,z)}let E={},M;for(let D in this._eventsInProgress){let{handlerName:z,originalEvent:G}=this._eventsInProgress[D];this._handlersById[z].isActive()||(delete this._eventsInProgress[D],M=c[z]||G,E[`${D}end`]=M)}for(let D in E)this._fireEvent(D,E[D]);let P=ot(this._eventsInProgress);if(d&&(f||y)&&!P){this._updatingCamera=!0;let D=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),z=G=>G!==0&&-this._bearingSnap<G&&G<this._bearingSnap;!D||!D.essential&&T.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:M})),z(this._map.getBearing())&&this._map.resetNorth()):(z(D.bearing||this._map.getBearing())&&(D.bearing=0),D.freezeElevation=!0,this._map.easeTo(D,{originalEvent:M})),this._updatingCamera=!1}}_fireEvent(i,c){this._map.fire(new o.k(i,c?{originalEvent:c}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(i=>{delete this._frameId,this.handleEvent(new pt("renderFrame",{timeStamp:i})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Uc extends o.E{constructor(i,c){super(),this._renderFrameCallback=()=>{let d=Math.min((T.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(d)),d<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=i,this._bearingSnap=c.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.M(this.transform.center.lng,this.transform.center.lat)}setCenter(i,c){return this.jumpTo({center:i},c)}panBy(i,c,d){return i=o.P.convert(i).mult(-1),this.panTo(this.transform.center,o.e({offset:i},c),d)}panTo(i,c,d){return this.easeTo(o.e({center:i},c),d)}getZoom(){return this.transform.zoom}setZoom(i,c){return this.jumpTo({zoom:i},c),this}zoomTo(i,c,d){return this.easeTo(o.e({zoom:i},c),d)}zoomIn(i,c){return this.zoomTo(this.getZoom()+1,i,c),this}zoomOut(i,c){return this.zoomTo(this.getZoom()-1,i,c),this}getBearing(){return this.transform.bearing}setBearing(i,c){return this.jumpTo({bearing:i},c),this}getPadding(){return this.transform.padding}setPadding(i,c){return this.jumpTo({padding:i},c),this}rotateTo(i,c,d){return this.easeTo(o.e({bearing:i},c),d)}resetNorth(i,c){return this.rotateTo(0,o.e({duration:1e3},i),c),this}resetNorthPitch(i,c){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},i),c),this}snapToNorth(i,c){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(i,c):this}getPitch(){return this.transform.pitch}setPitch(i,c){return this.jumpTo({pitch:i},c),this}cameraForBounds(i,c){i=oi.convert(i);let d=c&&c.bearing||0;return this._cameraForBoxAndBearing(i.getNorthWest(),i.getSouthEast(),d,c)}_cameraForBoxAndBearing(i,c,d,f){let y={top:0,bottom:0,right:0,left:0};if(typeof(f=o.e({padding:y,offset:[0,0],maxZoom:this.transform.maxZoom},f)).padding=="number"){let et=f.padding;f.padding={top:et,bottom:et,right:et,left:et}}f.padding=o.e(y,f.padding);let C=this.transform,E=C.padding,M=new oi(i,c),P=C.project(M.getNorthWest()),D=C.project(M.getNorthEast()),z=C.project(M.getSouthEast()),G=C.project(M.getSouthWest()),Y=o.b7(-d),K=P.rotate(Y),te=D.rotate(Y),X=z.rotate(Y),le=G.rotate(Y),xe=new o.P(Math.max(K.x,te.x,le.x,X.x),Math.max(K.y,te.y,le.y,X.y)),ie=new o.P(Math.min(K.x,te.x,le.x,X.x),Math.min(K.y,te.y,le.y,X.y)),pe=xe.sub(ie),we=(C.width-(E.left+E.right+f.padding.left+f.padding.right))/pe.x,be=(C.height-(E.top+E.bottom+f.padding.top+f.padding.bottom))/pe.y;if(be<0||we<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let Ae=Math.min(C.scaleZoom(C.scale*Math.min(we,be)),f.maxZoom),De=o.P.convert(f.offset),Le=new o.P((f.padding.left-f.padding.right)/2,(f.padding.top-f.padding.bottom)/2).rotate(o.b7(d)),Be=De.add(Le).mult(C.scale/C.zoomScale(Ae));return{center:C.unproject(P.add(z).div(2).sub(Be)),zoom:Ae,bearing:d}}fitBounds(i,c,d){return this._fitInternal(this.cameraForBounds(i,c),c,d)}fitScreenCoordinates(i,c,d,f,y){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(i)),this.transform.pointLocation(o.P.convert(c)),d,f),f,y)}_fitInternal(i,c,d){return i?(delete(c=o.e(i,c)).padding,c.linear?this.easeTo(c,d):this.flyTo(c,d)):this}jumpTo(i,c){this.stop();let d=this._getTransformForUpdate(),f=!1,y=!1,C=!1;return"zoom"in i&&d.zoom!==+i.zoom&&(f=!0,d.zoom=+i.zoom),i.center!==void 0&&(d.center=o.M.convert(i.center)),"bearing"in i&&d.bearing!==+i.bearing&&(y=!0,d.bearing=+i.bearing),"pitch"in i&&d.pitch!==+i.pitch&&(C=!0,d.pitch=+i.pitch),i.padding==null||d.isPaddingEqual(i.padding)||(d.padding=i.padding),this._applyUpdatedTransform(d),this.fire(new o.k("movestart",c)).fire(new o.k("move",c)),f&&this.fire(new o.k("zoomstart",c)).fire(new o.k("zoom",c)).fire(new o.k("zoomend",c)),y&&this.fire(new o.k("rotatestart",c)).fire(new o.k("rotate",c)).fire(new o.k("rotateend",c)),C&&this.fire(new o.k("pitchstart",c)).fire(new o.k("pitch",c)).fire(new o.k("pitchend",c)),this.fire(new o.k("moveend",c))}calculateCameraOptionsFromTo(i,c,d,f=0){let y=o.Y.fromLngLat(i,c),C=o.Y.fromLngLat(d,f),E=C.x-y.x,M=C.y-y.y,P=C.z-y.z,D=Math.hypot(E,M,P);if(D===0)throw new Error("Can't calculate camera options with same From and To");let z=Math.hypot(E,M),G=this.transform.scaleZoom(this.transform.cameraToCenterDistance/D/this.transform.tileSize),Y=180*Math.atan2(E,-M)/Math.PI,K=180*Math.acos(z/D)/Math.PI;return K=P<0?90-K:90+K,{center:C.toLngLat(),zoom:G,pitch:K,bearing:Y}}easeTo(i,c){this._stop(!1,i.easeId),((i=o.e({offset:[0,0],duration:500,easing:o.b6},i)).animate===!1||!i.essential&&T.prefersReducedMotion)&&(i.duration=0);let d=this._getTransformForUpdate(),f=this.getZoom(),y=this.getBearing(),C=this.getPitch(),E=this.getPadding(),M="zoom"in i?+i.zoom:f,P="bearing"in i?this._normalizeBearing(i.bearing,y):y,D="pitch"in i?+i.pitch:C,z="padding"in i?i.padding:d.padding,G=o.P.convert(i.offset),Y=d.centerPoint.add(G),K=d.pointLocation(Y),te=o.M.convert(i.center||K);this._normalizeCenter(te);let X=d.project(K),le=d.project(te).sub(X),xe=d.zoomScale(M-f),ie,pe;i.around&&(ie=o.M.convert(i.around),pe=d.locationPoint(ie));let we={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||M!==f,this._rotating=this._rotating||y!==P,this._pitching=this._pitching||D!==C,this._padding=!d.isPaddingEqual(z),this._easeId=i.easeId,this._prepareEase(c,i.noMoveStart,we),this.terrain&&this._prepareElevation(te),this._ease(be=>{if(this._zooming&&(d.zoom=o.z.number(f,M,be)),this._rotating&&(d.bearing=o.z.number(y,P,be)),this._pitching&&(d.pitch=o.z.number(C,D,be)),this._padding&&(d.interpolatePadding(E,z,be),Y=d.centerPoint.add(G)),this.terrain&&!i.freezeElevation&&this._updateElevation(be),ie)d.setLocationAtPoint(ie,pe);else{let Ae=d.zoomScale(d.zoom-f),De=M>f?Math.min(2,xe):Math.max(.5,xe),Le=Math.pow(De,1-be),Be=d.unproject(X.add(le.mult(be*Le)).mult(Ae));d.setLocationAtPoint(d.renderWorldCopies?Be.wrap():Be,Y)}this._applyUpdatedTransform(d),this._fireMoveEvents(c)},be=>{this.terrain&&this._finalizeElevation(),this._afterEase(c,be)},i),this}_prepareEase(i,c,d={}){this._moving=!0,c||d.moving||this.fire(new o.k("movestart",i)),this._zooming&&!d.zooming&&this.fire(new o.k("zoomstart",i)),this._rotating&&!d.rotating&&this.fire(new o.k("rotatestart",i)),this._pitching&&!d.pitching&&this.fire(new o.k("pitchstart",i))}_prepareElevation(i){this._elevationCenter=i,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(i){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let c=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(i<1&&c!==this._elevationTarget){let d=this._elevationTarget-this._elevationStart;this._elevationStart+=i*(d-(c-(d*i+this._elevationStart))/(1-i)),this._elevationTarget=c}this.transform.elevation=o.z.number(this._elevationStart,this._elevationTarget,i)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(i){if(!this.transformCameraUpdate)return;let c=i.clone(),{center:d,zoom:f,pitch:y,bearing:C,elevation:E}=this.transformCameraUpdate(c);d&&(c.center=d),f!==void 0&&(c.zoom=f),y!==void 0&&(c.pitch=y),C!==void 0&&(c.bearing=C),E!==void 0&&(c.elevation=E),this.transform.apply(c)}_fireMoveEvents(i){this.fire(new o.k("move",i)),this._zooming&&this.fire(new o.k("zoom",i)),this._rotating&&this.fire(new o.k("rotate",i)),this._pitching&&this.fire(new o.k("pitch",i))}_afterEase(i,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId;let d=this._zooming,f=this._rotating,y=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new o.k("zoomend",i)),f&&this.fire(new o.k("rotateend",i)),y&&this.fire(new o.k("pitchend",i)),this.fire(new o.k("moveend",i))}flyTo(i,c){if(!i.essential&&T.prefersReducedMotion){let nt=o.L(i,["center","zoom","bearing","pitch","around"]);return this.jumpTo(nt,c)}this.stop(),i=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b6},i);let d=this._getTransformForUpdate(),f=this.getZoom(),y=this.getBearing(),C=this.getPitch(),E=this.getPadding(),M="zoom"in i?o.ac(+i.zoom,d.minZoom,d.maxZoom):f,P="bearing"in i?this._normalizeBearing(i.bearing,y):y,D="pitch"in i?+i.pitch:C,z="padding"in i?i.padding:d.padding,G=d.zoomScale(M-f),Y=o.P.convert(i.offset),K=d.centerPoint.add(Y),te=d.pointLocation(K),X=o.M.convert(i.center||te);this._normalizeCenter(X);let le=d.project(te),xe=d.project(X).sub(le),ie=i.curve,pe=Math.max(d.width,d.height),we=pe/G,be=xe.mag();if("minZoom"in i){let nt=o.ac(Math.min(i.minZoom,f,M),d.minZoom,d.maxZoom),ei=pe/d.zoomScale(nt-f);ie=Math.sqrt(ei/be*2)}let Ae=ie*ie;function De(nt){let ei=(we*we-pe*pe+(nt?-1:1)*Ae*Ae*be*be)/(2*(nt?we:pe)*Ae*be);return Math.log(Math.sqrt(ei*ei+1)-ei)}function Le(nt){return(Math.exp(nt)-Math.exp(-nt))/2}function Be(nt){return(Math.exp(nt)+Math.exp(-nt))/2}let et=De(!1),ht=function(nt){return Be(et)/Be(et+ie*nt)},$e=function(nt){return pe*((Be(et)*(Le(ei=et+ie*nt)/Be(ei))-Le(et))/Ae)/be;var ei},ct=(De(!0)-et)/ie;if(Math.abs(be)<1e-6||!isFinite(ct)){if(Math.abs(pe-we)<1e-6)return this.easeTo(i,c);let nt=we<pe?-1:1;ct=Math.abs(Math.log(we/pe))/ie,$e=function(){return 0},ht=function(ei){return Math.exp(nt*ie*ei)}}return i.duration="duration"in i?+i.duration:1e3*ct/("screenSpeed"in i?+i.screenSpeed/ie:+i.speed),i.maxDuration&&i.duration>i.maxDuration&&(i.duration=0),this._zooming=!0,this._rotating=y!==P,this._pitching=D!==C,this._padding=!d.isPaddingEqual(z),this._prepareEase(c,!1),this.terrain&&this._prepareElevation(X),this._ease(nt=>{let ei=nt*ct,kt=1/ht(ei);d.zoom=nt===1?M:f+d.scaleZoom(kt),this._rotating&&(d.bearing=o.z.number(y,P,nt)),this._pitching&&(d.pitch=o.z.number(C,D,nt)),this._padding&&(d.interpolatePadding(E,z,nt),K=d.centerPoint.add(Y)),this.terrain&&!i.freezeElevation&&this._updateElevation(nt);let It=nt===1?X:d.unproject(le.add(xe.mult($e(ei))).mult(kt));d.setLocationAtPoint(d.renderWorldCopies?It.wrap():It,K),this._applyUpdatedTransform(d),this._fireMoveEvents(c)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(c)},i),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(i,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let d=this._onEaseEnd;delete this._onEaseEnd,d.call(this,c)}if(!i){let d=this.handlers;d&&d.stop(!1)}return this}_ease(i,c,d){d.animate===!1||d.duration===0?(i(1),c()):(this._easeStart=T.now(),this._easeOptions=d,this._onEaseFrame=i,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(i,c){i=o.b0(i,-180,180);let d=Math.abs(i-c);return Math.abs(i-360-c)<d&&(i-=360),Math.abs(i+360-c)<d&&(i+=360),i}_normalizeCenter(i){let c=this.transform;if(!c.renderWorldCopies||c.lngRange)return;let d=i.lng-c.center.lng;i.lng+=d>180?-360:d<-180?360:0}queryTerrainElevation(i){return this.terrain?this.terrain.getElevationForLngLatZoom(o.M.convert(i),this.transform.tileZoom)-this.transform.elevation:null}}let Ir={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class $c{constructor(i=Ir){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=c=>{!c||c.sourceDataType!=="metadata"&&c.sourceDataType!=="visibility"&&c.dataType!=="style"&&c.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=i}getDefaultPosition(){return"bottom-right"}onAdd(i){return this._map=i,this._compact=this.options.compact,this._container=S.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=S.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=S.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(){S.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(i,c){let d=this._map._getUIString(`AttributionControl.${c}`);i.title=d,i.setAttribute("aria-label",d)}_updateAttributions(){if(!this._map.style)return;let i=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?i=i.concat(this.options.customAttribution.map(f=>typeof f!="string"?"":f)):typeof this.options.customAttribution=="string"&&i.push(this.options.customAttribution)),this._map.style.stylesheet){let f=this._map.style.stylesheet;this.styleOwner=f.owner,this.styleId=f.id}let c=this._map.style.sourceCaches;for(let f in c){let y=c[f];if(y.used||y.usedForTerrain){let C=y.getSource();C.attribution&&i.indexOf(C.attribution)<0&&i.push(C.attribution)}}i=i.filter(f=>String(f).trim()),i.sort((f,y)=>f.length-y.length),i=i.filter((f,y)=>{for(let C=y+1;C<i.length;C++)if(i[C].indexOf(f)>=0)return!1;return!0});let d=i.join(" | ");d!==this._attribHTML&&(this._attribHTML=d,i.length?(this._innerContainer.innerHTML=d,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Vn{constructor(i={}){this._updateCompact=()=>{let c=this._container.children;if(c.length){let d=c[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&d.classList.add("maplibregl-compact"):d.classList.remove("maplibregl-compact")}},this.options=i}getDefaultPosition(){return"bottom-left"}onAdd(i){this._map=i,this._compact=this.options&&this.options.compact,this._container=S.create("div","maplibregl-ctrl");let c=S.create("a","maplibregl-ctrl-logo");return c.target="_blank",c.rel="noopener nofollow",c.href="https://maplibre.org/",c.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),c.setAttribute("rel","noopener nofollow"),this._container.appendChild(c),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){S.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Xp{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(i){let c=++this._id;return this._queue.push({callback:i,id:c,cancelled:!1}),c}remove(i){let c=this._currentlyRunning,d=c?this._queue.concat(c):this._queue;for(let f of d)if(f.id===i)return void(f.cancelled=!0)}run(i=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let c=this._currentlyRunning=this._queue;this._queue=[];for(let d of c)if(!d.cancelled&&(d.callback(i),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ra=o.X([{name:"a_pos3d",type:"Int16",components:3}]);class di extends o.E{constructor(i){super(),this.sourceCache=i,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,i.usedForTerrain=!0,i.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(i,c){this.sourceCache.update(i,c),this._renderableTilesKeys=[];let d={};for(let f of i.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:c}))d[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.posMatrix=new Float64Array(16),o.aN(f.posMatrix,0,o.W,0,o.W,0,1),this._tiles[f.key]=new br(f,this.tileSize));for(let f in this._tiles)d[f]||delete this._tiles[f]}freeRtt(i){for(let c in this._tiles){let d=this._tiles[c];(!i||d.tileID.equals(i)||d.tileID.isChildOf(i)||i.isChildOf(d.tileID))&&(d.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(i=>this.getTileByID(i))}getTileByID(i){return this._tiles[i]}getTerrainCoords(i){let c={};for(let d of this._renderableTilesKeys){let f=this._tiles[d].tileID;if(f.canonical.equals(i.canonical)){let y=i.clone();y.posMatrix=new Float64Array(16),o.aN(y.posMatrix,0,o.W,0,o.W,0,1),c[d]=y}else if(f.canonical.isChildOf(i.canonical)){let y=i.clone();y.posMatrix=new Float64Array(16);let C=f.canonical.z-i.canonical.z,E=f.canonical.x-(f.canonical.x>>C<<C),M=f.canonical.y-(f.canonical.y>>C<<C),P=o.W>>C;o.aN(y.posMatrix,0,P,0,P,0,1),o.H(y.posMatrix,y.posMatrix,[-E*P,-M*P,0]),c[d]=y}else if(i.canonical.isChildOf(f.canonical)){let y=i.clone();y.posMatrix=new Float64Array(16);let C=i.canonical.z-f.canonical.z,E=i.canonical.x-(i.canonical.x>>C<<C),M=i.canonical.y-(i.canonical.y>>C<<C),P=o.W>>C;o.aN(y.posMatrix,0,o.W,0,o.W,0,1),o.H(y.posMatrix,y.posMatrix,[E*P,M*P,0]),o.J(y.posMatrix,y.posMatrix,[1/2**C,1/2**C,0]),c[d]=y}}return c}getSourceTile(i,c){let d=this.sourceCache._source,f=i.overscaledZ-this.deltaZoom;if(f>d.maxzoom&&(f=d.maxzoom),f<d.minzoom)return null;this._sourceTileCache[i.key]||(this._sourceTileCache[i.key]=i.scaledTo(f).key);let y=this.sourceCache.getTileByID(this._sourceTileCache[i.key]);if((!y||!y.dem)&&c)for(;f>=d.minzoom&&(!y||!y.dem);)y=this.sourceCache.getTileByID(i.scaledTo(f--).key);return y}tilesAfterTime(i=Date.now()){return Object.values(this._tiles).filter(c=>c.timeAdded>=i)}}class bi{constructor(i,c,d){this.painter=i,this.sourceCache=new di(c),this.options=d,this.exaggeration=typeof d.exaggeration=="number"?d.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(i,c,d,f=o.W){var y;if(!(c>=0&&c<f&&d>=0&&d<f))return 0;let C=this.getTerrainData(i),E=(y=C.tile)===null||y===void 0?void 0:y.dem;if(!E)return 0;let M=function(K,te,X){var le=te[0],xe=te[1];return K[0]=X[0]*le+X[4]*xe+X[12],K[1]=X[1]*le+X[5]*xe+X[13],K}([],[c/f*o.W,d/f*o.W],C.u_terrain_matrix),P=[M[0]*E.dim,M[1]*E.dim],D=Math.floor(P[0]),z=Math.floor(P[1]),G=P[0]-D,Y=P[1]-z;return E.get(D,z)*(1-G)*(1-Y)+E.get(D+1,z)*G*(1-Y)+E.get(D,z+1)*(1-G)*Y+E.get(D+1,z+1)*G*Y}getElevationForLngLatZoom(i,c){let{tileID:d,mercatorX:f,mercatorY:y}=this._getOverscaledTileIDFromLngLatZoom(i,c);return this.getElevation(d,f%o.W,y%o.W,o.W)}getElevation(i,c,d,f=o.W){return this.getDEMElevation(i,c,d,f)*this.exaggeration}getTerrainData(i){if(!this._emptyDemTexture){let f=this.painter.context,y=new o.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ye(f,y,f.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ye(f,new o.R({width:1,height:1}),f.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(f.gl.NEAREST,f.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=o.an([])}let c=this.sourceCache.getSourceTile(i,!0);if(c&&c.dem&&(!c.demTexture||c.needsTerrainPrepare)){let f=this.painter.context;c.demTexture=this.painter.getTileTexture(c.dem.stride),c.demTexture?c.demTexture.update(c.dem.getPixels(),{premultiply:!1}):c.demTexture=new Ye(f,c.dem.getPixels(),f.gl.RGBA,{premultiply:!1}),c.demTexture.bind(f.gl.NEAREST,f.gl.CLAMP_TO_EDGE),c.needsTerrainPrepare=!1}let d=c&&c+c.tileID.key+i.key;if(d&&!this._demMatrixCache[d]){let f=this.sourceCache.sourceCache._source.maxzoom,y=i.canonical.z-c.tileID.canonical.z;i.overscaledZ>i.canonical.z&&(i.canonical.z>=f?y=i.canonical.z-f:o.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let C=i.canonical.x-(i.canonical.x>>y<<y),E=i.canonical.y-(i.canonical.y>>y<<y),M=o.b8(new Float64Array(16),[1/(o.W<<y),1/(o.W<<y),0]);o.H(M,M,[C*o.W,E*o.W,0]),this._demMatrixCache[i.key]={matrix:M,coord:i}}return{u_depth:2,u_terrain:3,u_terrain_dim:c&&c.dem&&c.dem.dim||1,u_terrain_matrix:d?this._demMatrixCache[i.key].matrix:this._emptyDemMatrix,u_terrain_unpack:c&&c.dem&&c.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(c&&c.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:c}}getFramebuffer(i){let c=this.painter,d=c.width/devicePixelRatio,f=c.height/devicePixelRatio;return!this._fbo||this._fbo.width===d&&this._fbo.height===f||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ye(c.context,{width:d,height:f,data:null},c.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(c.context.gl.NEAREST,c.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ye(c.context,{width:d,height:f,data:null},c.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(c.context.gl.NEAREST,c.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=c.context.createFramebuffer(d,f,!0,!1),this._fbo.depthAttachment.set(c.context.createRenderbuffer(c.context.gl.DEPTH_COMPONENT16,d,f))),this._fbo.colorAttachment.set(i==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let i=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let c=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let y=0,C=0;y<this._coordsTextureSize;y++)for(let E=0;E<this._coordsTextureSize;E++,C+=4)c[C+0]=255&E,c[C+1]=255&y,c[C+2]=E>>8<<4|y>>8,c[C+3]=0;let d=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(c.buffer)),f=new Ye(i,d,i.gl.RGBA,{premultiply:!1});return f.bind(i.gl.NEAREST,i.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(i){let c=new Uint8Array(4),d=this.painter.context,f=d.gl;d.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(i.x,this.painter.height/devicePixelRatio-i.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),d.bindFramebuffer.set(null);let y=c[0]+(c[2]>>4<<8),C=c[1]+((15&c[2])<<8),E=this.coordsIndex[255-c[3]],M=E&&this.sourceCache.getTileByID(E);if(!M)return null;let P=this._coordsTextureSize,D=(1<<M.tileID.canonical.z)*P;return new o.Y((M.tileID.canonical.x*P+y)/D+M.tileID.wrap,(M.tileID.canonical.y*P+C)/D,this.getElevation(M.tileID,y,C,P))}depthAtPoint(i){let c=new Uint8Array(4),d=this.painter.context,f=d.gl;return d.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),f.readPixels(i.x,this.painter.height/devicePixelRatio-i.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),d.bindFramebuffer.set(null),(c[0]/16777216+c[1]/65536+c[2]/256+c[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let i=this.painter.context,c=new o.b9,d=new o.aX,f=this.meshSize,y=o.W/f,C=f*f;for(let z=0;z<=f;z++)for(let G=0;G<=f;G++)c.emplaceBack(G*y,z*y,0);for(let z=0;z<C;z+=f+1)for(let G=0;G<f;G++)d.emplaceBack(G+z,f+G+z+1,f+G+z+2),d.emplaceBack(G+z,f+G+z+2,G+z+1);let E=c.length,M=E+2*(f+1);for(let z of[0,1])for(let G=0;G<=f;G++)for(let Y of[0,1])c.emplaceBack(G*y,z*o.W,Y);for(let z=0;z<2*f;z+=2)d.emplaceBack(M+z,M+z+1,M+z+3),d.emplaceBack(M+z,M+z+3,M+z+2),d.emplaceBack(E+z,E+z+3,E+z+1),d.emplaceBack(E+z,E+z+2,E+z+3);let P=c.length,D=P+2*(f+1);for(let z of[0,1])for(let G=0;G<=f;G++)for(let Y of[0,1])c.emplaceBack(z*o.W,G*y,Y);for(let z=0;z<2*f;z+=2)d.emplaceBack(P+z,P+z+1,P+z+3),d.emplaceBack(P+z,P+z+3,P+z+2),d.emplaceBack(D+z,D+z+3,D+z+1),d.emplaceBack(D+z,D+z+2,D+z+3);return this._mesh={indexBuffer:i.createIndexBuffer(d),vertexBuffer:i.createVertexBuffer(c,Ra.members),segments:o.$.simpleSegment(0,0,c.length,d.length)},this._mesh}getMeshFrameDelta(i){return 2*Math.PI*o.ba/Math.pow(2,i)/5}getMinTileElevationForLngLatZoom(i,c){var d;let{tileID:f}=this._getOverscaledTileIDFromLngLatZoom(i,c);return(d=this.getMinMaxElevation(f).minElevation)!==null&&d!==void 0?d:0}getMinMaxElevation(i){let c=this.getTerrainData(i).tile,d={minElevation:null,maxElevation:null};return c&&c.dem&&(d.minElevation=c.dem.min*this.exaggeration,d.maxElevation=c.dem.max*this.exaggeration),d}_getOverscaledTileIDFromLngLatZoom(i,c){let d=o.Y.fromLngLat(i.wrap()),f=(1<<c)*o.W,y=d.x*f,C=d.y*f,E=Math.floor(y/o.W),M=Math.floor(C/o.W);return{tileID:new o.Q(c,0,c,E,M),mercatorX:y,mercatorY:C}}}class ed{constructor(i,c,d){this._context=i,this._size=c,this._tileSize=d,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let i of this._objects)i.texture.destroy(),i.fbo.destroy()}_createObject(i){let c=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),d=new Ye(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return d.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),c.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),c.colorAttachment.set(d.texture),{id:i,fbo:c,texture:d,stamp:-1,inUse:!1}}getObjectForId(i){return this._objects[i]}useObject(i){i.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(c=>i.id!==c),this._recentlyUsed.push(i.id)}stampObject(i){i.stamp=++this._stamp}getOrCreateFreeObject(){for(let c of this._recentlyUsed)if(!this._objects[c].inUse)return this._objects[c];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let i=this._createObject(this._objects.length);return this._objects.push(i),i}freeObject(i){i.inUse=!1}freeAllObjects(){for(let i of this._objects)this.freeObject(i)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(i=>!i.inUse)===!1}}let Kn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Dl{constructor(i,c){this.painter=i,this.terrain=c,this.pool=new ed(i.context,30,c.sourceCache.tileSize*c.qualityFactor)}destruct(){this.pool.destruct()}getTexture(i){return this.pool.getObjectForId(i.rtt[this._stacks.length-1].id).texture}prepareForRender(i,c){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=i._order.filter(d=>!i._layers[d].isHidden(c)),this._coordsDescendingInv={};for(let d in i.sourceCaches){this._coordsDescendingInv[d]={};let f=i.sourceCaches[d].getVisibleCoordinates();for(let y of f){let C=this.terrain.sourceCache.getTerrainCoords(y);for(let E in C)this._coordsDescendingInv[d][E]||(this._coordsDescendingInv[d][E]=[]),this._coordsDescendingInv[d][E].push(C[E])}}this._coordsDescendingInvStr={};for(let d of i._order){let f=i._layers[d],y=f.source;if(Kn[f.type]&&!this._coordsDescendingInvStr[y]){this._coordsDescendingInvStr[y]={};for(let C in this._coordsDescendingInv[y])this._coordsDescendingInvStr[y][C]=this._coordsDescendingInv[y][C].map(E=>E.key).sort().join()}}for(let d of this._renderableTiles)for(let f in this._coordsDescendingInvStr){let y=this._coordsDescendingInvStr[f][d.tileID.key];y&&y!==d.rttCoords[f]&&(d.rtt=[])}}renderLayer(i){if(i.isHidden(this.painter.transform.zoom))return!1;let c=i.type,d=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===i.id;if(Kn[c]&&(this._prevType&&Kn[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(i.id),!f))return!0;if(Kn[this._prevType]||Kn[c]&&f){this._prevType=c;let y=this._stacks.length-1,C=this._stacks[y]||[];for(let E of this._renderableTiles){if(this.pool.isFull()&&(Tl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(E),E.rtt[y]){let P=this.pool.getObjectForId(E.rtt[y].id);if(P.stamp===E.rtt[y].stamp){this.pool.useObject(P);continue}}let M=this.pool.getOrCreateFreeObject();this.pool.useObject(M),this.pool.stampObject(M),E.rtt[y]={id:M.id,stamp:M.stamp},d.context.bindFramebuffer.set(M.fbo.framebuffer),d.context.clear({color:o.aO.transparent,stencil:0}),d.currentStencilSource=void 0;for(let P=0;P<C.length;P++){let D=d.style._layers[C[P]],z=D.source?this._coordsDescendingInv[D.source][E.tileID.key]:[E.tileID];d.context.viewport.set([0,0,M.fbo.width,M.fbo.height]),d._renderTileClippingMasks(D,z),d.renderLayer(d,d.style.sourceCaches[D.source],D,z),D.source&&(E.rttCoords[D.source]=this._coordsDescendingInvStr[D.source][E.tileID.key])}}return Tl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Kn[c]}return!1}}let qc={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Wc=g,Zc={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:Ir,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:o.a.MAX_TILE_CACHE_ZOOM_LEVELS,localIdeographFontFamily:"sans-serif",transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,validateStyle:!0,maxCanvasSize:[4096,4096]},Go=m=>{m.touchstart=m.dragStart,m.touchmoveWindow=m.dragMove,m.touchend=m.dragEnd},Xc={showCompass:!0,showZoom:!0,visualizePitch:!1};class Hc{constructor(i,c,d=!1){this.mousedown=C=>{this.startMouse(o.e({},C,{ctrlKey:!0,preventDefault:()=>C.preventDefault()}),S.mousePos(this.element,C)),S.addEventListener(window,"mousemove",this.mousemove),S.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=C=>{this.moveMouse(C,S.mousePos(this.element,C))},this.mouseup=C=>{this.mouseRotate.dragEnd(C),this.mousePitch&&this.mousePitch.dragEnd(C),this.offTemp()},this.touchstart=C=>{C.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=S.touchPos(this.element,C.targetTouches)[0],this.startTouch(C,this._startPos),S.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),S.addEventListener(window,"touchend",this.touchend))},this.touchmove=C=>{C.targetTouches.length!==1?this.reset():(this._lastPos=S.touchPos(this.element,C.targetTouches)[0],this.moveTouch(C,this._lastPos))},this.touchend=C=>{C.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{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;let f=i.dragRotate._mouseRotate.getClickTolerance(),y=i.dragRotate._mousePitch.getClickTolerance();this.element=c,this.mouseRotate=Nc({clickTolerance:f,enable:!0}),this.touchRotate=(({enable:C,clickTolerance:E,bearingDegreesPerPixelMoved:M=.8})=>{let P=new as;return new Ta({clickTolerance:E,move:(D,z)=>({bearingDelta:(z.x-D.x)*M}),moveStateManager:P,enable:C,assignEvents:Go})})({clickTolerance:f,enable:!0}),this.map=i,d&&(this.mousePitch=No({clickTolerance:y,enable:!0}),this.touchPitch=(({enable:C,clickTolerance:E,pitchDegreesPerPixelMoved:M=-.5})=>{let P=new as;return new Ta({clickTolerance:E,move:(D,z)=>({pitchDelta:(z.y-D.y)*M}),moveStateManager:P,enable:C,assignEvents:Go})})({clickTolerance:y,enable:!0})),S.addEventListener(c,"mousedown",this.mousedown),S.addEventListener(c,"touchstart",this.touchstart,{passive:!1}),S.addEventListener(c,"touchcancel",this.reset)}startMouse(i,c){this.mouseRotate.dragStart(i,c),this.mousePitch&&this.mousePitch.dragStart(i,c),S.disableDrag()}startTouch(i,c){this.touchRotate.dragStart(i,c),this.touchPitch&&this.touchPitch.dragStart(i,c),S.disableDrag()}moveMouse(i,c){let d=this.map,{bearingDelta:f}=this.mouseRotate.dragMove(i,c)||{};if(f&&d.setBearing(d.getBearing()+f),this.mousePitch){let{pitchDelta:y}=this.mousePitch.dragMove(i,c)||{};y&&d.setPitch(d.getPitch()+y)}}moveTouch(i,c){let d=this.map,{bearingDelta:f}=this.touchRotate.dragMove(i,c)||{};if(f&&d.setBearing(d.getBearing()+f),this.touchPitch){let{pitchDelta:y}=this.touchPitch.dragMove(i,c)||{};y&&d.setPitch(d.getPitch()+y)}}off(){let i=this.element;S.removeEventListener(i,"mousedown",this.mousedown),S.removeEventListener(i,"touchstart",this.touchstart,{passive:!1}),S.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),S.removeEventListener(window,"touchend",this.touchend),S.removeEventListener(i,"touchcancel",this.reset),this.offTemp()}offTemp(){S.enableDrag(),S.removeEventListener(window,"mousemove",this.mousemove),S.removeEventListener(window,"mouseup",this.mouseup),S.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),S.removeEventListener(window,"touchend",this.touchend)}}let ls;function Fl(m,i,c){let d=new o.M(m.lng,m.lat);if(m=new o.M(m.lng,m.lat),i){let f=new o.M(m.lng-360,m.lat),y=new o.M(m.lng+360,m.lat),C=c.locationPoint(m).distSqr(i);c.locationPoint(f).distSqr(i)<C?m=f:c.locationPoint(y).distSqr(i)<C&&(m=y)}for(;Math.abs(m.lng-c.center.lng)>180;){let f=c.locationPoint(m);if(f.x>=0&&f.y>=0&&f.x<=c.width&&f.y<=c.height)break;m.lng>c.center.lng?m.lng-=360:m.lng+=360}return m.lng!==d.lng&&c.locationPoint(m).y>c.height/2-c.getHorizon()?m:d}let ka={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 zl(m,i,c){let d=m.classList;for(let f in ka)d.remove(`maplibregl-${c}-anchor-${f}`);d.add(`maplibregl-${c}-anchor-${i}`)}class La extends o.E{constructor(i){if(super(),this._onKeyPress=c=>{let d=c.code,f=c.charCode||c.keyCode;d!=="Space"&&d!=="Enter"&&f!==32&&f!==13||this.togglePopup()},this._onMapClick=c=>{let d=c.originalEvent.target,f=this._element;this._popup&&(d===f||f.contains(d))&&this.togglePopup()},this._update=c=>{if(!this._map)return;let d=this._map.loaded()&&!this._map.isMoving();(c?.type==="terrain"||c?.type==="render"&&!d)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=Fl(this._lngLat,this._flatPos,this._map.transform)),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 f="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?f=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(f=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let y="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?y="rotateX(0deg)":this._pitchAlignment==="map"&&(y=`rotateX(${this._map.getPitch()}deg)`),c&&c.type!=="moveend"||(this._pos=this._pos.round()),S.setTransform(this._element,`${ka[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${y} ${f}`),T.frameAsync(new AbortController).then(()=>{this._updateOpacity(c&&c.type==="moveend")}).catch(()=>{})},this._onMove=c=>{if(!this._isDragging){let d=this._clickTolerance||this._map._clickTolerance;this._isDragging=c.point.dist(this._pointerdownPos)>=d}this._isDragging&&(this._pos=c.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 o.k("dragstart"))),this.fire(new o.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 o.k("dragend")),this._state="inactive"},this._addDragHandler=c=>{this._element.contains(c.originalEvent.target)&&(c.preventDefault(),this._positionDelta=c.point.sub(this._pos).add(this._offset),this._pointerdownPos=c.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=i&&i.anchor||"center",this._color=i&&i.color||"#3FB1CE",this._scale=i&&i.scale||1,this._draggable=i&&i.draggable||!1,this._clickTolerance=i&&i.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=i&&i.rotation||0,this._rotationAlignment=i&&i.rotationAlignment||"auto",this._pitchAlignment=i&&i.pitchAlignment&&i.pitchAlignment!=="auto"?i.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(i?.opacity,i?.opacityWhenCovered),i&&i.element)this._element=i.element,this._offset=o.P.convert(i&&i.offset||[0,0]);else{this._defaultMarker=!0,this._element=S.create("div"),this._element.setAttribute("aria-label","Map marker");let c=S.createNS("http://www.w3.org/2000/svg","svg"),d=41,f=27;c.setAttributeNS(null,"display","block"),c.setAttributeNS(null,"height",`${d}px`),c.setAttributeNS(null,"width",`${f}px`),c.setAttributeNS(null,"viewBox",`0 0 ${f} ${d}`);let y=S.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"stroke","none"),y.setAttributeNS(null,"stroke-width","1"),y.setAttributeNS(null,"fill","none"),y.setAttributeNS(null,"fill-rule","evenodd");let C=S.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"fill-rule","nonzero");let E=S.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(3.0, 29.0)"),E.setAttributeNS(null,"fill","#000000");let M=[{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(let le of M){let xe=S.createNS("http://www.w3.org/2000/svg","ellipse");xe.setAttributeNS(null,"opacity","0.04"),xe.setAttributeNS(null,"cx","10.5"),xe.setAttributeNS(null,"cy","5.80029008"),xe.setAttributeNS(null,"rx",le.rx),xe.setAttributeNS(null,"ry",le.ry),E.appendChild(xe)}let P=S.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"fill",this._color);let D=S.createNS("http://www.w3.org/2000/svg","path");D.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"),P.appendChild(D);let z=S.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"opacity","0.25"),z.setAttributeNS(null,"fill","#000000");let G=S.createNS("http://www.w3.org/2000/svg","path");G.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"),z.appendChild(G);let Y=S.createNS("http://www.w3.org/2000/svg","g");Y.setAttributeNS(null,"transform","translate(6.0, 7.0)"),Y.setAttributeNS(null,"fill","#FFFFFF");let K=S.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"transform","translate(8.0, 8.0)");let te=S.createNS("http://www.w3.org/2000/svg","circle");te.setAttributeNS(null,"fill","#000000"),te.setAttributeNS(null,"opacity","0.25"),te.setAttributeNS(null,"cx","5.5"),te.setAttributeNS(null,"cy","5.5"),te.setAttributeNS(null,"r","5.4999962");let X=S.createNS("http://www.w3.org/2000/svg","circle");X.setAttributeNS(null,"fill","#FFFFFF"),X.setAttributeNS(null,"cx","5.5"),X.setAttributeNS(null,"cy","5.5"),X.setAttributeNS(null,"r","5.4999962"),K.appendChild(te),K.appendChild(X),C.appendChild(E),C.appendChild(P),C.appendChild(z),C.appendChild(Y),C.appendChild(K),c.appendChild(C),c.setAttributeNS(null,"height",d*this._scale+"px"),c.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(c),this._offset=o.P.convert(i&&i.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",c=>{c.preventDefault()}),this._element.addEventListener("mousedown",c=>{c.preventDefault()}),zl(this._element,this._anchor,"marker"),i&&i.className)for(let c of i.className.split(" "))this._element.classList.add(c);this._popup=null}addTo(i){return this.remove(),this._map=i,i.getCanvasContainer().appendChild(this._element),i.on("move",this._update),i.on("moveend",this._update),i.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("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),S.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(i){return this._lngLat=o.M.convert(i),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(i){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),i){if(!("offset"in i.options)){let f=Math.abs(13.5)/Math.SQRT2;i.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[f,-1*(38.1-13.5+f)],"bottom-right":[-f,-1*(38.1-13.5+f)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=i,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){let i=this._popup;return i?(i.isOpen()?i.remove():i.addTo(this._map),this):this}_updateOpacity(i=!1){var c;if(!(!((c=this._map)===null||c===void 0)&&c.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(i)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let d=this._map,f=d.terrain.depthAtPoint(this._pos),y=d.terrain.getElevationForLngLatZoom(this._lngLat,d.transform.tileZoom);if(d.transform.lngLatToCameraDepth(this._lngLat,y)-f<.006)return void(this._element.style.opacity=this._opacity);let C=-this._offset.y/d.transform._pixelPerMeter,E=Math.sin(d.getPitch()*Math.PI/180)*C,M=d.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),P=d.transform.lngLatToCameraDepth(this._lngLat,y+E);this._element.style.opacity=P-M>.006?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(i){return this._offset=o.P.convert(i),this._update(),this}addClassName(i){this._element.classList.add(i)}removeClassName(i){this._element.classList.remove(i)}toggleClassName(i){return this._element.classList.toggle(i)}setDraggable(i){return this._draggable=!!i,this._map&&(i?(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(i){return this._rotation=i||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(i){return this._rotationAlignment=i||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(i){return this._pitchAlignment=i&&i!=="auto"?i:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(i,c){return i===void 0&&c===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),i!==void 0&&(this._opacity=i),c!==void 0&&(this._opacityWhenCovered=c),this._map&&this._updateOpacity(!0),this}}let Yc={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},no=0,so=!1,Kc={maxWidth:100,unit:"metric"};function Da(m,i,c){let d=c&&c.maxWidth||100,f=m._container.clientHeight/2,y=m.unproject([0,f]),C=m.unproject([d,f]),E=y.distanceTo(C);if(c&&c.unit==="imperial"){let M=3.2808*E;M>5280?oo(i,d,M/5280,m._getUIString("ScaleControl.Miles")):oo(i,d,M,m._getUIString("ScaleControl.Feet"))}else c&&c.unit==="nautical"?oo(i,d,E/1852,m._getUIString("ScaleControl.NauticalMiles")):E>=1e3?oo(i,d,E/1e3,m._getUIString("ScaleControl.Kilometers")):oo(i,d,E,m._getUIString("ScaleControl.Meters"))}function oo(m,i,c,d){let f=function(y){let C=Math.pow(10,`${Math.floor(y)}`.length-1),E=y/C;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:E>=1?1:function(M){let P=Math.pow(10,Math.ceil(-Math.log(M)/Math.LN10));return Math.round(M*P)/P}(E),C*E}(c);m.style.width=i*(f/c)+"px",m.innerHTML=`${f}&nbsp;${d}`}let Jc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Qc=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ol(m){if(m){if(typeof m=="number"){let i=Math.round(Math.abs(m)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,m),"top-left":new o.P(i,i),"top-right":new o.P(-i,i),bottom:new o.P(0,-m),"bottom-left":new o.P(i,-i),"bottom-right":new o.P(-i,-i),left:new o.P(m,0),right:new o.P(-m,0)}}if(m instanceof o.P||Array.isArray(m)){let i=o.P.convert(m);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:o.P.convert(m.center||[0,0]),top:o.P.convert(m.top||[0,0]),"top-left":o.P.convert(m["top-left"]||[0,0]),"top-right":o.P.convert(m["top-right"]||[0,0]),bottom:o.P.convert(m.bottom||[0,0]),"bottom-left":o.P.convert(m["bottom-left"]||[0,0]),"bottom-right":o.P.convert(m["bottom-right"]||[0,0]),left:o.P.convert(m.left||[0,0]),right:o.P.convert(m.right||[0,0])}}return Ol(new o.P(0,0))}let eh=g;a.AJAXError=o.bd,a.Evented=o.E,a.LngLat=o.M,a.MercatorCoordinate=o.Y,a.Point=o.P,a.addProtocol=o.be,a.config=o.a,a.removeProtocol=o.bf,a.AttributionControl=$c,a.BoxZoomHandler=Oc,a.CanvasSource=pn,a.CooperativeGesturesHandler=Pa,a.DoubleClickZoomHandler=Ll,a.DragPanHandler=Gc,a.DragRotateHandler=Qu,a.EdgeInsets=Oo,a.FullscreenControl=class extends o.E{constructor(m={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,m&&m.container&&(m.container instanceof HTMLElement?this._container=m.container:o.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(m){return this._map=m,this._container||(this._container=this._map.getContainer()),this._controlContainer=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){S.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let m=this._fullscreenButton=S.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);S.create("span","maplibregl-ctrl-icon",m).setAttribute("aria-hidden","true"),m.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let m=this._getTitle();this._fullscreenButton.setAttribute("aria-label",m),this._fullscreenButton.title=m}_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 o.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new o.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()}},a.GeoJSONSource=Et,a.GeolocateControl=class extends o.E{constructor(m){super(),this._onSuccess=i=>{if(this._map){if(this._isOutOfMapMaxBounds(i))return this._setErrorState(),this.fire(new o.k("outofmaxbounds",i)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=i,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(i),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(i),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new o.k("geolocate",i)),this._finish()}},this._updateCamera=i=>{let c=new o.M(i.coords.longitude,i.coords.latitude),d=i.coords.accuracy,f=this._map.getBearing(),y=o.e({bearing:f},this.options.fitBoundsOptions),C=oi.fromLngLat(c,d);this._map.fitBounds(C,y,{geolocateSource:!0})},this._updateMarker=i=>{if(i){let c=new o.M(i.coords.longitude,i.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=i.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=i=>{if(this._map){if(this.options.trackUserLocation)if(i.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;let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(i.code===3&&so)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.k("error",i)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=i=>{if(this._map){if(this._container.addEventListener("contextmenu",c=>c.preventDefault()),this._geolocateButton=S.create("button","maplibregl-ctrl-geolocate",this._container),S.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",i===!1){o.w("Geolocation support is not available so the GeolocateControl will be disabled.");let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}else{let c=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=S.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new La({element:this._dotElement}),this._circleElement=S.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new La({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",c=>{c.geolocateSource||this._watchState!=="ACTIVE_LOCK"||c.originalEvent&&c.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 o.k("trackuserlocationend")))})}},this.options=o.e({},Yc,m)}onAdd(m){return this._map=m,this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(i=!1){return o._(this,void 0,void 0,function*(){if(ls!==void 0&&!i)return ls;if(window.navigator.permissions===void 0)return ls=!!window.navigator.geolocation,ls;try{ls=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{ls=!!window.navigator.geolocation}return ls})}().then(i=>this._setupUI(i)),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(),S.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,no=0,so=!1}_isOutOfMapMaxBounds(m){let i=this._map.getMaxBounds(),c=m.coords;return i&&(c.longitude<i.getWest()||c.longitude>i.getEast()||c.latitude<i.getSouth()||c.latitude>i.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(){let m=this._map.getBounds(),i=m.getSouthEast(),c=m.getNorthEast(),d=i.distanceTo(c),f=Math.ceil(this._accuracy/(d/this._map._container.clientHeight)*2);this._circleElement.style.width=`${f}px`,this._circleElement.style.height=`${f}px`}trigger(){if(!this._setup)return o.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 o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":no--,so=!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 o.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 o.k("trackuserlocationstart"));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 m;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),no++,no>1?(m={maximumAge:6e5,timeout:0},so=!0):(m=this.options.positionOptions,so=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,m)}}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)}},a.Hash=zc,a.ImageSource=Vr,a.KeyboardHandler=Yu,a.LngLatBounds=oi,a.LogoControl=Vn,a.Map=class extends Uc{constructor(m){if(o.bb.mark(o.bc.create),(m=o.e({},Zc,m)).minZoom!=null&&m.maxZoom!=null&&m.minZoom>m.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(m.minPitch!=null&&m.maxPitch!=null&&m.minPitch>m.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(m.minPitch!=null&&m.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(m.maxPitch!=null&&m.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Ml(m.minZoom,m.maxZoom,m.minPitch,m.maxPitch,m.renderWorldCopies),{bearingSnap:m.bearingSnap}),this._contextLost=i=>{i.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:i}))},this._contextRestored=i=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:i}))},this._onMapScroll=i=>{if(i.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=m.interactive,this._maxTileCacheSize=m.maxTileCacheSize,this._maxTileCacheZoomLevels=m.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=m.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=m.preserveDrawingBuffer,this._antialias=m.antialias,this._trackResize=m.trackResize,this._bearingSnap=m.bearingSnap,this._refreshExpiredTiles=m.refreshExpiredTiles,this._fadeDuration=m.fadeDuration,this._crossSourceCollisions=m.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=m.collectResourceTiming,this._renderTaskQueue=new Xp,this._controls=[],this._mapId=o.a3(),this._locale=o.e({},qc,m.locale),this._clickTolerance=m.clickTolerance,this._overridePixelRatio=m.pixelRatio,this._maxCanvasSize=m.maxCanvasSize,this.transformCameraUpdate=m.transformCameraUpdate,this._imageQueueHandle=Z.addThrottleControl(()=>this.isMoving()),this._requestManager=new me(m.transformRequest),typeof m.container=="string"){if(this._container=document.getElementById(m.container),!this._container)throw new Error(`Container '${m.container}' not found.`)}else{if(!(m.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=m.container}if(m.maxBounds&&this.setMaxBounds(m.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let i=!1,c=Fc(d=>{this._trackResize&&!this._removed&&this.resize(d)._update()},50);this._resizeObserver=new ResizeObserver(d=>{i?c(d):i=!0}),this._resizeObserver.observe(this._container)}this.handlers=new jc(this,m),this._hash=m.hash&&new zc(typeof m.hash=="string"&&m.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:m.center,zoom:m.zoom,bearing:m.bearing,pitch:m.pitch}),m.bounds&&(this.resize(),this.fitBounds(m.bounds,o.e({},m.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=m.localIdeographFontFamily,this._validateStyle=m.validateStyle,m.style&&this.setStyle(m.style,{localIdeographFontFamily:m.localIdeographFontFamily}),m.attributionControl&&this.addControl(new $c(typeof m.attributionControl=="boolean"?void 0:m.attributionControl)),m.maplibreLogo&&this.addControl(new Vn,m.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",i=>{this._update(i.dataType==="style"),this.fire(new o.k(`${i.dataType}data`,i))}),this.on("dataloading",i=>{this.fire(new o.k(`${i.dataType}dataloading`,i))}),this.on("dataabort",i=>{this.fire(new o.k("sourcedataabort",i))})}_getMapId(){return this._mapId}addControl(m,i){if(i===void 0&&(i=m.getDefaultPosition?m.getDefaultPosition():"top-right"),!m||!m.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let c=m.onAdd(this);this._controls.push(m);let d=this._controlPositions[i];return i.indexOf("bottom")!==-1?d.insertBefore(c,d.firstChild):d.appendChild(c),this}removeControl(m){if(!m||!m.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(m);return i>-1&&this._controls.splice(i,1),m.onRemove(this),this}hasControl(m){return this._controls.indexOf(m)>-1}calculateCameraOptionsFromTo(m,i,c,d){return d==null&&this.terrain&&(d=this.terrain.getElevationForLngLatZoom(c,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(m,i,c,d)}resize(m){var i;let c=this._containerDimensions(),d=c[0],f=c[1],y=this._getClampedPixelRatio(d,f);if(this._resizeCanvas(d,f,y),this.painter.resize(d,f,y),this.painter.overLimit()){let E=this.painter.context.gl;this._maxCanvasSize=[E.drawingBufferWidth,E.drawingBufferHeight];let M=this._getClampedPixelRatio(d,f);this._resizeCanvas(d,f,M),this.painter.resize(d,f,M)}this.transform.resize(d,f),(i=this._requestedCameraState)===null||i===void 0||i.resize(d,f);let C=!this._moving;return C&&(this.stop(),this.fire(new o.k("movestart",m)).fire(new o.k("move",m))),this.fire(new o.k("resize",m)),C&&this.fire(new o.k("moveend",m)),this}_getClampedPixelRatio(m,i){let{0:c,1:d}=this._maxCanvasSize,f=this.getPixelRatio(),y=m*f,C=i*f;return Math.min(y>c?c/y:1,C>d?d/C:1)*f}getPixelRatio(){var m;return(m=this._overridePixelRatio)!==null&&m!==void 0?m:devicePixelRatio}setPixelRatio(m){this._overridePixelRatio=m,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(m){return this.transform.setMaxBounds(oi.convert(m)),this._update()}setMinZoom(m){if((m=m??-2)>=-2&&m<=this.transform.maxZoom)return this.transform.minZoom=m,this._update(),this.getZoom()<m&&this.setZoom(m),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(m){if((m=m??22)>=this.transform.minZoom)return this.transform.maxZoom=m,this._update(),this.getZoom()>m&&this.setZoom(m),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(m){if((m=m??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(m>=0&&m<=this.transform.maxPitch)return this.transform.minPitch=m,this._update(),this.getPitch()<m&&this.setPitch(m),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(m){if((m=m??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(m>=this.transform.minPitch)return this.transform.maxPitch=m,this._update(),this.getPitch()>m&&this.setPitch(m),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(m){return this.transform.renderWorldCopies=m,this._update()}project(m){return this.transform.locationPoint(o.M.convert(m),this.style&&this.terrain)}unproject(m){return this.transform.pointLocation(o.P.convert(m),this.terrain)}isMoving(){var m;return this._moving||((m=this.handlers)===null||m===void 0?void 0:m.isMoving())}isZooming(){var m;return this._zooming||((m=this.handlers)===null||m===void 0?void 0:m.isZooming())}isRotating(){var m;return this._rotating||((m=this.handlers)===null||m===void 0?void 0:m.isRotating())}_createDelegatedListener(m,i,c){if(m==="mouseenter"||m==="mouseover"){let d=!1;return{layer:i,listener:c,delegates:{mousemove:y=>{let C=this.getLayer(i)?this.queryRenderedFeatures(y.point,{layers:[i]}):[];C.length?d||(d=!0,c.call(this,new Ur(m,this,y.originalEvent,{features:C}))):d=!1},mouseout:()=>{d=!1}}}}if(m==="mouseleave"||m==="mouseout"){let d=!1;return{layer:i,listener:c,delegates:{mousemove:C=>{(this.getLayer(i)?this.queryRenderedFeatures(C.point,{layers:[i]}):[]).length?d=!0:d&&(d=!1,c.call(this,new Ur(m,this,C.originalEvent)))},mouseout:C=>{d&&(d=!1,c.call(this,new Ur(m,this,C.originalEvent)))}}}}{let d=f=>{let y=this.getLayer(i)?this.queryRenderedFeatures(f.point,{layers:[i]}):[];y.length&&(f.features=y,c.call(this,f),delete f.features)};return{layer:i,listener:c,delegates:{[m]:d}}}}on(m,i,c){if(c===void 0)return super.on(m,i);let d=this._createDelegatedListener(m,i,c);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[m]=this._delegatedListeners[m]||[],this._delegatedListeners[m].push(d);for(let f in d.delegates)this.on(f,d.delegates[f]);return this}once(m,i,c){if(c===void 0)return super.once(m,i);let d=this._createDelegatedListener(m,i,c);for(let f in d.delegates)this.once(f,d.delegates[f]);return this}off(m,i,c){return c===void 0?super.off(m,i):(this._delegatedListeners&&this._delegatedListeners[m]&&(d=>{let f=this._delegatedListeners[m];for(let y=0;y<f.length;y++){let C=f[y];if(C.layer===i&&C.listener===c){for(let E in C.delegates)this.off(E,C.delegates[E]);return f.splice(y,1),this}}})(),this)}queryRenderedFeatures(m,i){if(!this.style)return[];let c,d=m instanceof o.P||Array.isArray(m),f=d?m:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(d?{}:m)||{},f instanceof o.P||typeof f[0]=="number")c=[o.P.convert(f)];else{let y=o.P.convert(f[0]),C=o.P.convert(f[1]);c=[y,new o.P(C.x,y.y),C,new o.P(y.x,C.y),y]}return this.style.queryRenderedFeatures(c,i,this.transform)}querySourceFeatures(m,i){return this.style.querySourceFeatures(m,i)}setStyle(m,i){return(i=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff!==!1&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&m?(this._diffStyle(m,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(m,i))}setTransformRequest(m){return this._requestManager.setTransformRequest(m),this}_getUIString(m){let i=this._locale[m];if(i==null)throw new Error(`Missing UI string '${m}'`);return i}_updateStyle(m,i){if(i.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(m,i));let c=this.style&&i.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!m)),m?(this.style=new en(this,i||{}),this.style.setEventedParent(this,{style:this.style}),typeof m=="string"?this.style.loadURL(m,i,c):this.style.loadJSON(m,i,c),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new en(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(m,i){if(typeof m=="string"){let c=this._requestManager.transformRequest(m,ne.Style);o.h(c,new AbortController).then(d=>{this._updateDiff(d.data,i)}).catch(d=>{d&&this.fire(new o.j(d))})}else typeof m=="object"&&this._updateDiff(m,i)}_updateDiff(m,i){try{this.style.setState(m,i)&&this._update(!0)}catch(c){o.w(`Unable to perform style diff: ${c.message||c.error||c}. Rebuilding the style from scratch.`),this._updateStyle(m,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(m,i){return this._lazyInitEmptyStyle(),this.style.addSource(m,i),this._update(!0)}isSourceLoaded(m){let i=this.style&&this.style.sourceCaches[m];if(i!==void 0)return i.loaded();this.fire(new o.j(new Error(`There is no source with ID '${m}'`)))}setTerrain(m){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),m){let i=this.style.sourceCaches[m.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${m.source}`);this.terrain===null&&i.reload();for(let c in this.style._layers){let d=this.style._layers[c];d.type==="hillshade"&&d.source===m.source&&o.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 bi(this.painter,i,m),this.painter.renderToTexture=new Dl(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=c=>{c.dataType==="style"?this.terrain.sourceCache.freeRtt():c.dataType==="source"&&c.tile&&(c.sourceId!==m.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(c.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 o.k("terrain",{terrain:m})),this}getTerrain(){var m,i;return(i=(m=this.terrain)===null||m===void 0?void 0:m.options)!==null&&i!==void 0?i:null}areTilesLoaded(){let m=this.style&&this.style.sourceCaches;for(let i in m){let c=m[i]._tiles;for(let d in c){let f=c[d];if(f.state!=="loaded"&&f.state!=="errored")return!1}}return!0}removeSource(m){return this.style.removeSource(m),this._update(!0)}getSource(m){return this.style.getSource(m)}addImage(m,i,c={}){let{pixelRatio:d=1,sdf:f=!1,stretchX:y,stretchY:C,content:E}=c;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||o.b(i))){if(i.width===void 0||i.height===void 0)return this.fire(new o.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`")));{let{width:M,height:P,data:D}=i,z=i;return this.style.addImage(m,{data:new o.R({width:M,height:P},new Uint8Array(D)),pixelRatio:d,stretchX:y,stretchY:C,content:E,sdf:f,version:0,userImage:z}),z.onAdd&&z.onAdd(this,m),this}}{let{width:M,height:P,data:D}=T.getImageData(i);this.style.addImage(m,{data:new o.R({width:M,height:P},D),pixelRatio:d,stretchX:y,stretchY:C,content:E,sdf:f,version:0})}}updateImage(m,i){let c=this.style.getImage(m);if(!c)return this.fire(new o.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let d=i instanceof HTMLImageElement||o.b(i)?T.getImageData(i):i,{width:f,height:y,data:C}=d;if(f===void 0||y===void 0)return this.fire(new o.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(f!==c.data.width||y!==c.data.height)return this.fire(new o.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let E=!(i instanceof HTMLImageElement||o.b(i));return c.data.replace(C,E),this.style.updateImage(m,c),this}getImage(m){return this.style.getImage(m)}hasImage(m){return m?!!this.style.getImage(m):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(m){this.style.removeImage(m)}loadImage(m){return Z.getImage(this._requestManager.transformRequest(m,ne.Image),new AbortController)}listImages(){return this.style.listImages()}addLayer(m,i){return this._lazyInitEmptyStyle(),this.style.addLayer(m,i),this._update(!0)}moveLayer(m,i){return this.style.moveLayer(m,i),this._update(!0)}removeLayer(m){return this.style.removeLayer(m),this._update(!0)}getLayer(m){return this.style.getLayer(m)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(m,i,c){return this.style.setLayerZoomRange(m,i,c),this._update(!0)}setFilter(m,i,c={}){return this.style.setFilter(m,i,c),this._update(!0)}getFilter(m){return this.style.getFilter(m)}setPaintProperty(m,i,c,d={}){return this.style.setPaintProperty(m,i,c,d),this._update(!0)}getPaintProperty(m,i){return this.style.getPaintProperty(m,i)}setLayoutProperty(m,i,c,d={}){return this.style.setLayoutProperty(m,i,c,d),this._update(!0)}getLayoutProperty(m,i){return this.style.getLayoutProperty(m,i)}setGlyphs(m,i={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(m,i),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(m,i,c={}){return this._lazyInitEmptyStyle(),this.style.addSprite(m,i,c,d=>{d||this._update(!0)}),this}removeSprite(m){return this._lazyInitEmptyStyle(),this.style.removeSprite(m),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(m,i={}){return this._lazyInitEmptyStyle(),this.style.setSprite(m,i,c=>{c||this._update(!0)}),this}setLight(m,i={}){return this._lazyInitEmptyStyle(),this.style.setLight(m,i),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(m,i){return this.style.setFeatureState(m,i),this._update()}removeFeatureState(m,i){return this.style.removeFeatureState(m,i),this._update()}getFeatureState(m){return this.style.getFeatureState(m)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let m=0,i=0;return this._container&&(m=this._container.clientWidth||400,i=this._container.clientHeight||300),[m,i]}_setupContainer(){let m=this._container;m.classList.add("maplibregl-map");let i=this._canvasContainer=S.create("div","maplibregl-canvas-container",m);this._interactive&&i.classList.add("maplibregl-interactive"),this._canvas=S.create("canvas","maplibregl-canvas",i),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");let c=this._containerDimensions(),d=this._getClampedPixelRatio(c[0],c[1]);this._resizeCanvas(c[0],c[1],d);let f=this._controlContainer=S.create("div","maplibregl-control-container",m),y=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(C=>{y[C]=S.create("div",`maplibregl-ctrl-${C} `,f)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(m,i,c){this._canvas.width=Math.floor(c*m),this._canvas.height=Math.floor(c*i),this._canvas.style.width=`${m}px`,this._canvas.style.height=`${i}px`}_setupPainter(){let m={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},i=null;this._canvas.addEventListener("webglcontextcreationerror",d=>{i={requestedAttributes:m},d&&(i.statusMessage=d.statusMessage,i.type=d.type)},{once:!0});let c=this._canvas.getContext("webgl2",m)||this._canvas.getContext("webgl",m);if(!c){let d="Failed to initialize WebGL";throw i?(i.message=d,new Error(JSON.stringify(i))):new Error(d)}this.painter=new Gu(c,this.transform),k.testSupport(c)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(m){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||m,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(m){return this._update(),this._renderTaskQueue.add(m)}_cancelRenderFrame(m){this._renderTaskQueue.remove(m)}_render(m){let i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(m),this._removed)return;let c=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let f=this.transform.zoom,y=T.now();this.style.zoomHistory.update(f,y);let C=new o.a8(f,{now:y,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),E=C.crossFadingFactor();E===1&&E===this._crossFadingFactor||(c=!0,this._crossFadingFactor=E),this.style.update(C)}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,i,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:i,showPadding:this.showPadding}),this.fire(new o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bb.mark(o.bc.load),this.fire(new o.k("load"))),this.style&&(this.style.hasTransitions()||c)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new o.k("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,o.bb.mark(o.bc.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var m;this._hash&&this._hash.remove();for(let c of this._controls)c.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),Z.removeThrottleControl(this._imageQueueHandle),(m=this._resizeObserver)===null||m===void 0||m.disconnect();let i=this.painter.context.gl.getExtension("WEBGL_lose_context");i&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),S.remove(this._canvasContainer),S.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),o.bb.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,T.frameAsync(this._frameRequest).then(m=>{o.bb.frame(m),this._frameRequest=null,this._render(m)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(m){this._showTileBoundaries!==m&&(this._showTileBoundaries=m,this._update())}get showPadding(){return!!this._showPadding}set showPadding(m){this._showPadding!==m&&(this._showPadding=m,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(m){this._showCollisionBoxes!==m&&(this._showCollisionBoxes=m,m?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(m){this._showOverdrawInspector!==m&&(this._showOverdrawInspector=m,this._update())}get repaint(){return!!this._repaint}set repaint(m){this._repaint!==m&&(this._repaint=m,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(m){this._vertices=m,this._update()}get version(){return Wc}getCameraTargetElevation(){return this.transform.elevation}},a.MapMouseEvent=Ur,a.MapTouchEvent=Bo,a.MapWheelEvent=to,a.Marker=La,a.NavigationControl=class{constructor(m){this._updateZoomButtons=()=>{let i=this._map.getZoom(),c=i===this._map.getMaxZoom(),d=i===this._map.getMinZoom();this._zoomInButton.disabled=c,this._zoomOutButton.disabled=d,this._zoomInButton.setAttribute("aria-disabled",c.toString()),this._zoomOutButton.setAttribute("aria-disabled",d.toString())},this._rotateCompassArrow=()=>{let i=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=i},this._setButtonTitle=(i,c)=>{let d=this._map._getUIString(`NavigationControl.${c}`);i.title=d,i.setAttribute("aria-label",d)},this.options=o.e({},Xc,m),this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",i=>i.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",i=>this._map.zoomIn({},{originalEvent:i})),S.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",i=>this._map.zoomOut({},{originalEvent:i})),S.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",i=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:i}):this._map.resetNorth({},{originalEvent:i})}),this._compassIcon=S.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(m){return this._map=m,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 Hc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){S.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(m,i){let c=S.create("button",m,this._container);return c.type="button",c.addEventListener("click",i),c}},a.Popup=class extends o.E{constructor(m){super(),this.remove=()=>(this._content&&S.remove(this._content),this._container&&(S.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 o.k("close")),this),this._onMouseUp=i=>{this._update(i.point)},this._onMouseMove=i=>{this._update(i.point)},this._onDrag=i=>{this._update(i.point)},this._update=i=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=S.create("div","maplibregl-popup",this._map.getContainer()),this._tip=S.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let C of this.options.className.split(" "))this._container.classList.add(C);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._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Fl(this._lngLat,this._flatPos,this._map.transform)),this._trackPointer&&!i)return;let c=this._flatPos=this._pos=this._trackPointer&&i?i:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&i?i:this._map.transform.locationPoint(this._lngLat));let d=this.options.anchor,f=Ol(this.options.offset);if(!d){let C=this._container.offsetWidth,E=this._container.offsetHeight,M;M=c.y+f.bottom.y<E?["top"]:c.y>this._map.transform.height-E?["bottom"]:[],c.x<C/2?M.push("left"):c.x>this._map.transform.width-C/2&&M.push("right"),d=M.length===0?"bottom":M.join("-")}let y=c.add(f[d]).round();S.setTransform(this._container,`${ka[d]} translate(${y.x}px,${y.y}px)`),zl(this._container,d,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(Jc),m)}addTo(m){return this._map&&this.remove(),this._map=m,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 o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(m){return this._lngLat=o.M.convert(m),this._pos=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._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(m){return this.setDOMContent(document.createTextNode(m))}setHTML(m){let i=document.createDocumentFragment(),c=document.createElement("body"),d;for(c.innerHTML=m;d=c.firstChild,d;)i.appendChild(d);return this.setDOMContent(i)}getMaxWidth(){var m;return(m=this._container)===null||m===void 0?void 0:m.style.maxWidth}setMaxWidth(m){return this.options.maxWidth=m,this._update(),this}setDOMContent(m){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=S.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(m),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(m){this._container&&this._container.classList.add(m)}removeClassName(m){this._container&&this._container.classList.remove(m)}setOffset(m){return this.options.offset=m,this._update(),this}toggleClassName(m){if(this._container)return this._container.classList.toggle(m)}_createCloseButton(){this.options.closeButton&&(this._closeButton=S.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let m=this._container.querySelector(Qc);m&&m.focus()}},a.RasterDEMTileSource=Ti,a.RasterTileSource=tr,a.ScaleControl=class{constructor(m){this._onMove=()=>{Da(this._map,this._container,this.options)},this.setUnit=i=>{this.options.unit=i,Da(this._map,this._container,this.options)},this.options=o.e({},Kc,m)}getDefaultPosition(){return"bottom-left"}onAdd(m){return this._map=m,this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-scale",m.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){S.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},a.ScrollZoomHandler=Aa,a.Style=en,a.TerrainControl=class{constructor(m){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=m}onAdd(m){return this._map=m,this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=S.create("button","maplibregl-ctrl-terrain",this._container),S.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(){S.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},a.TwoFingersTouchPitchHandler=Vc,a.TwoFingersTouchRotateHandler=Rl,a.TwoFingersTouchZoomHandler=Xu,a.TwoFingersTouchZoomRotateHandler=Nn,a.VectorTileSource=Ie,a.VideoSource=Fn,a.addSourceType=(m,i)=>o._(void 0,void 0,void 0,function*(){if(fn(m))throw new Error(`A source type called "${m}" already exists.`);((c,d)=>{os[c]=d})(m,i)}),a.clearPrewarmedResources=function(){let m=Ue;m&&(m.isPreloaded()&&m.numActive()===1?(m.release(Ft),Ue=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()"))},a.getMaxParallelImageRequests=function(){return o.a.MAX_PARALLEL_IMAGE_REQUESTS},a.getRTLTextPluginStatus=function(){return Oe().getRTLTextPluginStatus()},a.getVersion=function(){return eh},a.getWorkerCount=function(){return Bt.workerCount},a.getWorkerUrl=function(){return o.a.WORKER_URL},a.importScriptInWorkers=function(m){return ar().broadcast("importScript",m)},a.prewarm=function(){xi().acquire(Ft)},a.setMaxParallelImageRequests=function(m){o.a.MAX_PARALLEL_IMAGE_REQUESTS=m},a.setRTLTextPlugin=function(m,i){return Oe().setRTLTextPlugin(m,i)},a.setWorkerCount=function(m){Bt.workerCount=m},a.setWorkerUrl=function(m){o.a.WORKER_URL=m}});var l=h;return l})});var vp=vh((g3,Pb)=>{var DC="Expected a function",Mb=NaN,FC="[object Symbol]",zC=/^\s+|\s+$/g,OC=/^[-+]0x[0-9a-f]+$/i,BC=/^0b[01]+$/i,NC=/^0o[0-7]+$/i,VC=parseInt,GC=typeof global=="object"&&global&&global.Object===Object&&global,jC=typeof self=="object"&&self&&self.Object===Object&&self,UC=GC||jC||Function("return this")(),$C=Object.prototype,qC=$C.toString,WC=Math.max,ZC=Math.min,Fy=function(){return UC.Date.now()};function XC(h,e,r){var l,a,o,g,v,w,T=0,S=!1,k=!1,F=!0;if(typeof h!="function")throw new TypeError(DC);e=Ab(e)||0,zy(r)&&(S=!!r.leading,k="maxWait"in r,o=k?WC(Ab(r.maxWait)||0,e):o,F="trailing"in r?!!r.trailing:F);function j(ve){var Ee=l,Re=a;return l=a=void 0,T=ve,g=h.apply(Re,Ee),g}function J(ve){return T=ve,v=setTimeout(Z,e),S?j(ve):g}function he(ve){var Ee=ve-w,Re=ve-T,Pe=e-Ee;return k?ZC(Pe,o-Re):Pe}function q(ve){var Ee=ve-w,Re=ve-T;return w===void 0||Ee>=e||Ee<0||k&&Re>=o}function Z(){var ve=Fy();if(q(ve))return ne(ve);v=setTimeout(Z,he(ve))}function ne(ve){return v=void 0,F&&l?j(ve):(l=a=void 0,g)}function me(){v!==void 0&&clearTimeout(v),T=0,l=w=a=v=void 0}function _e(){return v===void 0?g:ne(Fy())}function fe(){var ve=Fy(),Ee=q(ve);if(l=arguments,a=this,w=ve,Ee){if(v===void 0)return J(w);if(k)return v=setTimeout(Z,e),j(w)}return v===void 0&&(v=setTimeout(Z,e)),g}return fe.cancel=me,fe.flush=_e,fe}function zy(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function HC(h){return!!h&&typeof h=="object"}function YC(h){return typeof h=="symbol"||HC(h)&&qC.call(h)==FC}function Ab(h){if(typeof h=="number")return h;if(YC(h))return Mb;if(zy(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=zy(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(zC,"");var r=BC.test(h);return r||NC.test(h)?VC(h.slice(2),r?2:8):OC.test(h)?Mb:+h}Pb.exports=XC});var Vb=vh((lB,Nb)=>{var Bb="Expected a function",zb=NaN,QC="[object Symbol]",eI=/^\s+|\s+$/g,tI=/^[-+]0x[0-9a-f]+$/i,iI=/^0b[01]+$/i,rI=/^0o[0-7]+$/i,nI=parseInt,sI=typeof global=="object"&&global&&global.Object===Object&&global,oI=typeof self=="object"&&self&&self.Object===Object&&self,aI=sI||oI||Function("return this")(),lI=Object.prototype,cI=lI.toString,hI=Math.max,uI=Math.min,Gy=function(){return aI.Date.now()};function dI(h,e,r){var l,a,o,g,v,w,T=0,S=!1,k=!1,F=!0;if(typeof h!="function")throw new TypeError(Bb);e=Ob(e)||0,bp(r)&&(S=!!r.leading,k="maxWait"in r,o=k?hI(Ob(r.maxWait)||0,e):o,F="trailing"in r?!!r.trailing:F);function j(ve){var Ee=l,Re=a;return l=a=void 0,T=ve,g=h.apply(Re,Ee),g}function J(ve){return T=ve,v=setTimeout(Z,e),S?j(ve):g}function he(ve){var Ee=ve-w,Re=ve-T,Pe=e-Ee;return k?uI(Pe,o-Re):Pe}function q(ve){var Ee=ve-w,Re=ve-T;return w===void 0||Ee>=e||Ee<0||k&&Re>=o}function Z(){var ve=Gy();if(q(ve))return ne(ve);v=setTimeout(Z,he(ve))}function ne(ve){return v=void 0,F&&l?j(ve):(l=a=void 0,g)}function me(){v!==void 0&&clearTimeout(v),T=0,l=w=a=v=void 0}function _e(){return v===void 0?g:ne(Gy())}function fe(){var ve=Gy(),Ee=q(ve);if(l=arguments,a=this,w=ve,Ee){if(v===void 0)return J(w);if(k)return v=setTimeout(Z,e),j(w)}return v===void 0&&(v=setTimeout(Z,e)),g}return fe.cancel=me,fe.flush=_e,fe}function pI(h,e,r){var l=!0,a=!0;if(typeof h!="function")throw new TypeError(Bb);return bp(r)&&(l="leading"in r?!!r.leading:l,a="trailing"in r?!!r.trailing:a),dI(h,e,{leading:l,maxWait:e,trailing:a})}function bp(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function fI(h){return!!h&&typeof h=="object"}function mI(h){return typeof h=="symbol"||fI(h)&&cI.call(h)==QC}function Ob(h){if(typeof h=="number")return h;if(mI(h))return zb;if(bp(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=bp(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(eI,"");var r=iI.test(h);return r||rI.test(h)?nI(h.slice(2),r?2:8):tI.test(h)?zb:+h}Nb.exports=pI});var Cp={};Of(Cp,{CopyrightControl:()=>ev,MaplibreLayer:()=>fu,MaplibreStyleLayer:()=>Fb,RealtimeAPI:()=>Ch,RealtimeLayer:()=>$b,RealtimeModes:()=>Ki,RoutingAPI:()=>bh,RoutingControl:()=>Sb,StopFinderControl:()=>Eb,StopsAPI:()=>wh,VECTOR_TILE_FEATURE_PROPERTY:()=>ra,compareDepartures:()=>Zh,createCanvas:()=>xs,createRealtimeFilters:()=>Uf,debounceDeparturesMessages:()=>Lm,debounceWebsocketMessages:()=>Sh,fullTrajectoryDelayStyle:()=>Gb,fullTrajectoryStyle:()=>Sp,getCircleCanvas:()=>Gm,getDelayBgCanvas:()=>Nm,getDelayTextCanvas:()=>Vm,getFeatureInfoAtCoordinate:()=>qb,getHoursAndMinutes:()=>O0,getLayersAsFlatArray:()=>ja,getMapGlCopyrights:()=>Ga,getTextCanvas:()=>jm,getUTCDateString:()=>F0,getUTCTimeString:()=>z0,getUrlWithParams:()=>Na,getVehiclePosition:()=>qh,pad:()=>Ed,realtimeConfig:()=>oc,realtimeDefaultStyle:()=>Ya,realtimeDelayStyle:()=>Um,realtimeSimpleStyle:()=>$m,removeDuplicate:()=>Va,renderTrajectories:()=>Wh,routingStyle:()=>Ub,sortAndFilterDepartures:()=>Xh,sortByDelay:()=>$f});var aS=(h,e)=>{let r=new URL(h);return Object.entries(e||{}).forEach(([a,o])=>{o!=null&&r.searchParams.set(a,o)}),r},Na=aS;var Bf=class{constructor(e){this.url=e.url,this.apiKey=e.apiKey}async fetch(e,r,l){if(!this.url)throw new Error(`No url defined for request to ${this.url}/${e}`);if(!this.url&&!this.apiKey&&!/key=/.test(this.url))throw new Error(`No apiKey defined for request to ${this.url}`);let a=r||{},o=Na(`${this.url}${e||""}`,{key:this.apiKey,...a}),v=await(await fetch(o.toString(),l)).json();if(v.error)throw new Error(v.error);return v}},Id=Bf;var Nf=class extends Id{constructor(e={}){super({url:"https://api.geops.io/routing/v1/",...e})}route(e,r){return this.fetch("",e,r)}},bh=Nf;var Vf=class extends Id{constructor(e={}){super({url:"https://api.geops.io/stops/v1/",...e})}search(e,r){return this.fetch("",e,r)}},wh=Vf;var Gf=class h{constructor(){this.defineProperties()}defineProperties(){Object.defineProperties(this,{closed:{get:()=>!this.websocket||this.websocket.readyState===this.websocket.CLOSED},closing:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CLOSING)},connecting:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CONNECTING)},open:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.OPEN)},messagesOnOpen:{value:[],writable:!0},subscriptions:{value:[],writable:!0},subscribed:{value:{},writable:!0}})}static getRequestString(e,r={}){let l=`${e} ${r.channel}`;return l+=r.args?` ${r.args}`:"",l+=r.id?` ${r.id}`:"",l.trim()}connect(e,r=()=>{}){if(!e){this.websocket?.close();return}if(this.websocket){if(this.websocket.url===e&&(this.open||this.connecting))return;this.websocket.url!==e&&(this.open||this.connecting)&&this.websocket.close()}this.websocket=new WebSocket(e),this.open?(r(),this.subscribePreviousSubscriptions()):this.websocket.addEventListener("open",()=>{r(),this.subscribePreviousSubscriptions()})}close(){this.websocket&&(this.open||this.connecting)&&(this.websocket.onclose=()=>{},this.websocket.close(),this.messagesOnOpen=[])}send(e){if(!this.websocket||this.closed||this.closing)return;let r=()=>{this.websocket?.send(e)};this.open?this.messagesOnOpen.includes(e)||r():this.messagesOnOpen.includes(e)||(this.messagesOnOpen.push(e),this.websocket.addEventListener("open",()=>{this.messagesOnOpen=[],r()}),this.websocket.addEventListener("close",()=>{this.messagesOnOpen=[]}))}addEvents(e,r){this.websocket&&(this.websocket.addEventListener("message",e),r&&(this.websocket.addEventListener("error",r),this.websocket.addEventListener("close",r)))}removeEvents(e,r){this.websocket&&(this.websocket.removeEventListener("message",e),r&&(this.websocket.removeEventListener("error",r),this.websocket.removeEventListener("close",r)))}listen(e,r,l){this.unlisten(e,r);let a=o=>{let g;try{g=JSON.parse(o.data)}catch(T){console.error("WebSocket: unable to parse JSON data",T,o.data);return}let v=e.channel;v+=e.args?` ${e.args}`:"";let w;g.source==="buffer"?w=g.content:w=[g],w.forEach(T=>{T?.source===v&&(!e.id||e.id===g.client_reference)&&r(T)})};return this.addEvents(a,l),{onMessageCb:a,onErrorCb:l}}unlisten(e,r){[...this.subscriptions||[],...this.requests||[]].filter(l=>l.params.channel===e.channel&&(!r||l.cb===r)).forEach(({onMessageCb:l,onErrorCb:a})=>{this.removeEvents(l,a)})}get(e,r,l){let a=h.getRequestString("GET",e);this.send(a);let o=S=>(...k)=>{S(...k);let F=this.requests.findIndex(he=>a===he.requestString&&r===he.cb),{onMessageCb:j,onErrorCb:J}=this.requests[F];this.removeEvents(j,J),this.requests.splice(F,1)},{onMessageCb:g,onErrorCb:v}=this.listen(e,o(r),l&&o(l));this.requests||(this.requests=[]);let w=this.requests.findIndex(S=>a===S.requestString&&r===S.cb),T={params:e,requestString:a,cb:r,errorCb:l,onMessageCb:g,onErrorCb:v};w>-1?this.requests[w]=T:this.requests.push(T)}subscribe(e,r,l,a=!1){let{onMessageCb:o,onErrorCb:g}=this.listen(e,r,l),v=h.getRequestString("",e),w=this.subscriptions.findIndex(S=>e.channel===S.params.channel&&r===S.cb),T={params:e,cb:r,errorCb:l,onMessageCb:o,onErrorCb:g,quiet:a};w>-1?this.subscriptions[w]=T:this.subscriptions.push(T),this.subscribed[v]||(T.quiet||(this.send(`GET ${v}`),this.send(`SUB ${v}`)),this.subscribed[v]=!0)}unsubscribe(e,r){let l=this.subscriptions.filter(a=>a.params.channel===e&&(!r||a.cb===r));l.forEach(({onMessageCb:a,onErrorCb:o})=>{this.removeEvents(a,o)}),this.subscriptions=this.subscriptions.filter(a=>a.params.channel!==e||r&&a.cb!==r),e&&this.subscribed[e]&&!this.subscriptions.find(a=>a.params.channel===e)&&l.find(a=>!a.quiet)&&(this.send(`DEL ${e}`),this.subscribed[e]=!1)}subscribePreviousSubscriptions(){Object.keys(this.subscribed).forEach(e=>{this.subscribed[e]=!1}),[...this.subscriptions].forEach(e=>{this.subscribe(e.params,e.cb,e.errorCb,e.quiet)})}},L0=Gf;var lS=(h,e,r=100)=>{let l={},a={},o=[];return g=>{let{source:v,content:w}=g;l[v]&&window.clearTimeout(l[v]),e?a[e(w)]=w:o.push(w),l[v]=window.setTimeout(()=>{let T=e?Object.values(a):o;h(T)},r)}},Sh=lS;var cS=(h,e)=>h===e.SCHEMATIC?"_schematic":"",fs=cS;var Ki={RAW:"raw",TOPOGRAPHIC:"topographic",SCHEMATIC:"schematic"},jf=class{constructor(e={}){this.version="2";this.defineProperties(e),this.onOpen=this.onOpen.bind(this)}defineProperties(e={}){let r=e||{};typeof e=="string"&&(r={url:e});let{apiKey:l,version:a}=r,{url:o,bbox:g,buffer:v=[100,100]}=r,w=new L0;o||(o="wss://api.geops.io/tracker-ws/v1/"),l&&(o=`${o}?key=${l}`),Object.defineProperties(this,{url:{get:()=>o,set:T=>{o!==T&&(o=T,(this.wsApi.open||this.wsApi.connecting)&&this.open())}},bbox:{get:()=>g,set:T=>{JSON.stringify(T)!==JSON.stringify(g)&&(g=T,this.wsApi&&g&&this.wsApi.send(`BBOX ${g.join(" ")}`))}},buffer:{get:()=>v,set:T=>{JSON.stringify(T)!==JSON.stringify(v)&&(v=T,this.wsApi&&this.wsApi.send(`BUFFER ${v.join(" ")}`))}},version:{value:a,writable:!0},wsApi:{value:w,writable:!0},pingIntervalMs:{value:e.pingIntervalMs||1e4,writable:!0},reconnectTimeoutMs:{value:e.pingIntervalMs||100,writable:!0}})}open(){this.wsApi.connect(this.url,this.onOpen),this.wsApi.websocket&&(this.wsApi.websocket.onclose=()=>{this.onClose()})}close(){this.wsApi.close()}reset(){this.wsApi.send("RESET")}onOpen(){this.bbox&&this.wsApi.send(`BBOX ${this.bbox.join(" ")}`),this.buffer&&this.wsApi.send(`BUFFER ${this.buffer.join(" ")}`),this.pingIntervalMs&&(window.clearInterval(this.pingInterval),this.pingInterval=window.setInterval(()=>{this.wsApi.send("PING")},this.pingIntervalMs))}onClose(){window.clearTimeout(this.pingInterval),window.clearTimeout(this.reconnectTimeout),this.reconnectTimeoutMs&&(this.reconnectTimeout=window.setTimeout(()=>this.open(),this.reconnectTimeoutMs))}get(e){let r=e;return typeof e=="string"&&(r={channel:e}),new Promise((l,a)=>{this.wsApi.get(r,l,a)})}subscribe(e,r,l=()=>{},a=!1){!e||!r||this.wsApi.subscribe({channel:e},r,l,a)}unsubscribe(e,r="",l){let a=fs(Ki.SCHEMATIC,Ki),o=fs(Ki.TOPOGRAPHIC,Ki);this.wsApi.unsubscribe(`${e}${a}${r||""}`,l),this.wsApi.unsubscribe(`${e}${o}${r||""}`,l)}subscribeDepartures(e,r,l=()=>{},a=!1){this.subscribe(`timetable_${e}`,r,l,a)}unsubscribeDepartures(e,r){this.unsubscribe(`timetable_${e}`,"",r)}subscribeDisruptions(e,r,l=()=>{},a=!1){this.subscribe(`${e}_newsticker`,r,l,a)}unsubscribeDisruptions(e,r){this.unsubscribe(`${e}_newsticker`,"",r)}getStation(e,r){let l={channel:`station${fs(r,Ki)}`,args:e};return this.get(l)}getStations(e,r=100){return new Promise(l=>{this.get(`station${fs(e,Ki)}`).then(Sh(l,void 0,r))})}subscribeStations(e,r,l=()=>{},a=!1){this.subscribe(`station${fs(e,Ki)}`,r,l,a)}unsubscribeStations(e){this.unsubscribe("station","",e)}subscribeExtraGeoms(e,r=()=>{},l=!1){this.subscribe("extra_geoms",e,r,l)}unsubscribeExtraGeoms(e){this.unsubscribe("extra_geoms","",e)}getTrajectory(e,r){return this.get(`partial_trajectory${fs(r,Ki)}_${e}`)}subscribeTrajectory(e,r,l=()=>{},a=!1){this.unsubscribeTrajectory(r);let o="";this.version==="1"&&(o=fs(e,Ki)),this.subscribe(`trajectory${o}`,r,l,a)}unsubscribeTrajectory(e){this.unsubscribe("trajectory","",e)}subscribeDeletedVehicles(e,r,l=()=>{},a=!1){this.unsubscribeDeletedVehicles(r);let o="";this.version==="1"&&(o=fs(e,Ki)),this.subscribe(`deleted_vehicles${o}`,r,l,a)}unsubscribeDeletedVehicles(e){this.unsubscribe("deleted_vehicles","",e)}getFullTrajectory(e,r,l){let a="";this.version==="1"&&(a=fs(r,Ki));let o=[`full_trajectory${a}`];return e&&o.push(e),(!r||r===Ki.TOPOGRAPHIC)&&l&&o.push(`gen${l}`),this.get(o.join("_"))}subscribeFullTrajectory(e,r,l,a=()=>{},o=!1){let g="";this.version==="1"&&(g=fs(r,Ki)),this.subscribe(`full_trajectory${g}_${e}`,l,a,o)}unsubscribeFullTrajectory(e,r){this.unsubscribe("full_trajectory",`_${e}`,r)}getStopSequence(e){return this.get(`stopsequence_${e}`)}subscribeStopSequence(e,r,l=()=>{},a=!1){this.subscribe(`stopsequence_${e}`,r,l,a)}unsubscribeStopSequence(e,r){this.unsubscribe("stopsequence",`_${e}`,r)}subscribeHealthCheck(e,r=()=>{},l=!1){this.subscribe("healthcheck",e,r,l)}unsubscribeHealthCheck(e){this.unsubscribe("healthcheck","",e)}},Ch=jf;var hS=h=>{let e=h.filter(o=>o!=null&&o.trim&&o.trim()),r=e.map(o=>o.toLowerCase());return[...new Set(r)].map(o=>e.find(g=>g.toLowerCase()===o))},Va=hS;var uS=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,l=[];return Object.values(r).forEach(a=>{if(a.used){let o=a.getSource(),g=o.attribution||o.options&&o.options.attribution;g&&(l=l.concat(g.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),Va(l)},Ga=uS;var dS=(h,e,r,l)=>{let a=[];if(!h&&!e&&!r&&!l)return null;if(l){let o=typeof l=="string"?[l]:l,g=v=>{let w=v.properties.name||v.properties.line&&v.properties.line.name||"";return w?o.some(T=>new RegExp(T,"i").test(w)):!1};a.push(g)}if(h){let g=(typeof h=="string"?h.split(","):h).map(w=>w.replace(/\s+/g,"").toUpperCase()),v=w=>{let{line:T,name:S}=w.properties,k=(S||T&&T.name||"").toUpperCase();return k?g.includes(k):!1};a.push(v)}if(e){let g=(typeof e=="string"?e.split(","):e).map(w=>parseInt(w,10)),v=w=>{let T=w.properties.route_identifier||w.properties.routeIdentifier||"",S=parseInt(T.split(".")[0],10);return g.includes(S)};a.push(v)}if(r){let o=typeof r=="string"?[r]:r,g=v=>o.some(w=>{let T=v.properties.operator||v.properties.tenant||"";return new RegExp(w,"i").test(T)});a.push(g)}return a.length?o=>{for(let g=0;g<a.length;g+=1)if(!a[g](o))return!1;return!0}:null},Uf=dS;var D0=h=>{let e=h;Array.isArray(e)||(e=[h]);let r=[];return e.forEach(l=>{r.push(l);let{children:a}=l;r=r.concat(D0(a||[]))}),r},ja=D0;var F0=(h=new Date)=>{let e=(h.getUTCMonth()+1).toString();e=e.length===1?`0${e}`:e;let r=h.getUTCDate().toString();return r=r.length===1?`0${r}`:r,[h.getUTCFullYear(),e,r].join("")},z0=h=>[h.getUTCHours(),h.getUTCMinutes(),`${h.getUTCSeconds()}.${h.getUTCMilliseconds()}`].join(":"),Ed=h=>h<10?`0${h}`:`${h}`,O0=h=>{if(!h||h<=0)return"";let e=new Date(h);return`${Ed(e.getHours())}:${Ed(e.getMinutes())}`};var pS=(h,e)=>{let r=h.properties,l=e.properties;return r.delay===null&&l.delay!==null?1:l.delay===null&&r.delay!==null?-1:r.cancelled&&!l.cancelled?l.delay<18e4?-1:1:l.cancelled&&!r.cancelled?r.delay<18e4?1:-1:l.delay-r.delay},$f=pS;function si(h,e){if(!h)throw new Error(e)}var EE=new Array(6);function mr(){return[1,0,0,1,0,0]}function fS(h,e,r,l,a,o,g){return h[0]=e,h[1]=r,h[2]=l,h[3]=a,h[4]=o,h[5]=g,h}function N0(h,e){return h[0]=e[0],h[1]=e[1],h[2]=e[2],h[3]=e[3],h[4]=e[4],h[5]=e[5],h}function rr(h,e){let r=e[0],l=e[1];return e[0]=h[0]*r+h[2]*l+h[4],e[1]=h[1]*r+h[3]*l+h[5],e}function V0(h,e,r){return fS(h,e,0,0,r,0,0)}function an(h,e,r,l,a,o,g,v){let w=Math.sin(o),T=Math.cos(o);return h[0]=l*T,h[1]=a*w,h[2]=-l*w,h[3]=a*T,h[4]=g*l*T-v*l*w+e,h[5]=g*a*w+v*a*T+r,h}function G0(h,e,r,l,a,o,g){return qf(an(mr(),h,e,r,l,a,o,g))}function j0(h,e){let r=mS(e);si(r!==0,"Transformation matrix cannot be inverted");let l=e[0],a=e[1],o=e[2],g=e[3],v=e[4],w=e[5];return h[0]=g/r,h[1]=-a/r,h[2]=-o/r,h[3]=l/r,h[4]=(o*w-g*v)/r,h[5]=-(l*w-a*v)/r,h}function mS(h){return h[0]*h[3]-h[1]*h[2]}var B0=[1e6,1e6,1e6,1e6,2,2];function qf(h){return"matrix("+h.map((r,l)=>Math.round(r*B0[l])/B0[l]).join(", ")+")"}var Wf=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var mi=Wf;var Td={PROPERTYCHANGE:"propertychange"};var Zf=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},U0=Zf;function $0(h,e,r){let l,a;r=r||Ds;let o=0,g=h.length,v=!1;for(;o<g;)l=o+(g-o>>1),a=+r(h[l],e),a<0?o=l+1:(g=l,v=!a);return v?o:~o}function Ds(h,e){return h>e?1:h<e?-1:0}function Md(h,e,r){if(h[0]<=e)return 0;let l=h.length;if(e<=h[l-1])return l-1;if(typeof r=="function"){for(let a=1;a<l;++a){let o=h[a];if(o===e)return a;if(o<e)return r(e,h[a-1],o)>0?a-1:a}return l-1}if(r>0){for(let a=1;a<l;++a)if(h[a]<e)return a-1;return l-1}if(r<0){for(let a=1;a<l;++a)if(h[a]<=e)return a;return l-1}for(let a=1;a<l;++a){if(h[a]==e)return a;if(h[a]<e)return h[a-1]-e<e-h[a]?a-1:a}return l-1}function q0(h,e,r){for(;e<r;){let l=h[e];h[e]=h[r],h[r]=l,++e,--r}}function kr(h,e){let r=Array.isArray(e)?e:[e],l=r.length;for(let a=0;a<l;a++)h[h.length]=r[a]}function vn(h,e){let r=h.length;if(r!==e.length)return!1;for(let l=0;l<r;l++)if(h[l]!==e[l])return!1;return!0}function Ad(){return!0}function ms(){}function Pd(h){let e=!1,r,l,a;return function(){let o=Array.prototype.slice.call(arguments);return(!e||this!==a||!vn(o,l))&&(e=!0,a=this,l=o,r=h.apply(this,arguments)),r}}function Yl(h){for(let e in h)delete h[e]}function qn(h){let e;for(e in h)return!1;return!e}var Xf=class extends U0{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,r){if(!e||!r)return;let l=this.listeners_||(this.listeners_={}),a=l[e]||(l[e]=[]);a.includes(r)||a.push(r)}dispatchEvent(e){let r=typeof e=="string",l=r?e:e.type,a=this.listeners_&&this.listeners_[l];if(!a)return;let o=r?new mi(e):e;o.target||(o.target=this.eventTarget_||this);let g=this.dispatching_||(this.dispatching_={}),v=this.pendingRemovals_||(this.pendingRemovals_={});l in g||(g[l]=0,v[l]=0),++g[l];let w;for(let T=0,S=a.length;T<S;++T)if("handleEvent"in a[T]?w=a[T].handleEvent(o):w=a[T].call(this,o),w===!1||o.propagationStopped){w=!1;break}if(--g[l]===0){let T=v[l];for(delete v[l];T--;)this.removeEventListener(l,ms);delete g[l]}return w}disposeInternal(){this.listeners_&&Yl(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,r){if(!this.listeners_)return;let l=this.listeners_[e];if(!l)return;let a=l.indexOf(r);a!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(l[a]=ms,++this.pendingRemovals_[e]):(l.splice(a,1),l.length===0&&delete this.listeners_[e]))}},Rd=Xf;var li={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function Lr(h,e,r,l,a){if(l&&l!==h&&(r=r.bind(l)),a){let g=r;r=function(){h.removeEventListener(e,r),g.apply(this,arguments)}}let o={target:h,type:e,listener:r};return h.addEventListener(e,r),o}function Hf(h,e,r,l){return Lr(h,e,r,l,!0)}function Yr(h){h&&h.target&&(h.target.removeEventListener(h.type,h.listener),Yl(h))}var Kl=class extends Rd{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(li.CHANGE)}getRevision(){return this.revision_}onInternal(e,r){if(Array.isArray(e)){let l=e.length,a=new Array(l);for(let o=0;o<l;++o)a[o]=Lr(this,e[o],r);return a}return Lr(this,e,r)}onceInternal(e,r){let l;if(Array.isArray(e)){let a=e.length;l=new Array(a);for(let o=0;o<a;++o)l[o]=Hf(this,e[o],r)}else l=Hf(this,e,r);return r.ol_key=l,l}unInternal(e,r){let l=r.ol_key;if(l)Ih(l);else if(Array.isArray(e))for(let a=0,o=e.length;a<o;++a)this.removeEventListener(e[a],r);else this.removeEventListener(e,r)}};Kl.prototype.on;Kl.prototype.once;Kl.prototype.un;function Ih(h){if(Array.isArray(h))for(let e=0,r=h.length;e<r;++e)Yr(h[e]);else Yr(h)}var kd=Kl;function St(){throw new Error("Unimplemented abstract method.")}var gS=0;function Gt(h){return h.ol_uid||(h.ol_uid=String(++gS))}var Ld=class extends mi{constructor(e,r,l){super(e),this.key=r,this.oldValue=l}},Yf=class extends kd{constructor(e){super(),this.on,this.once,this.un,Gt(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let r;return this.values_&&this.values_.hasOwnProperty(e)&&(r=this.values_[e]),r}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,r){let l;l=`change:${e}`,this.hasListener(l)&&this.dispatchEvent(new Ld(l,e,r)),l=Td.PROPERTYCHANGE,this.hasListener(l)&&this.dispatchEvent(new Ld(l,e,r))}addChangeListener(e,r){this.addEventListener(`change:${e}`,r)}removeChangeListener(e,r){this.removeEventListener(`change:${e}`,r)}set(e,r,l){let a=this.values_||(this.values_={});if(l)a[e]=r;else{let o=a[e];a[e]=r,o!==r&&this.notify(e,o)}}setProperties(e,r){for(let l in e)this.set(l,e[l],r)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,r){if(this.values_&&e in this.values_){let l=this.values_[e];delete this.values_[e],qn(this.values_)&&(this.values_=null),r||this.notify(e,l)}}},gr=Yf;var Ji={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Fs(h){let e=Sn();for(let r=0,l=h.length;r<l;++r)Kf(e,h[r]);return e}function yS(h,e,r){let l=Math.min.apply(null,h),a=Math.min.apply(null,e),o=Math.max.apply(null,h),g=Math.max.apply(null,e);return yo(l,a,o,g,r)}function bn(h,e,r){return r?(r[0]=h[0]-e,r[1]=h[1]-e,r[2]=h[2]+e,r[3]=h[3]+e,r):[h[0]-e,h[1]-e,h[2]+e,h[3]+e]}function W0(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h.slice()}function wn(h,e,r){let l,a;return e<h[0]?l=h[0]-e:h[2]<e?l=e-h[2]:l=0,r<h[1]?a=h[1]-r:h[3]<r?a=r-h[3]:a=0,l*l+a*a}function mo(h,e){return Eh(h,e[0],e[1])}function go(h,e){return h[0]<=e[0]&&e[2]<=h[2]&&h[1]<=e[1]&&e[3]<=h[3]}function Eh(h,e,r){return h[0]<=e&&e<=h[2]&&h[1]<=r&&r<=h[3]}function Dd(h,e){let r=h[0],l=h[1],a=h[2],o=h[3],g=e[0],v=e[1],w=Ji.UNKNOWN;return g<r?w=w|Ji.LEFT:g>a&&(w=w|Ji.RIGHT),v<l?w=w|Ji.BELOW:v>o&&(w=w|Ji.ABOVE),w===Ji.UNKNOWN&&(w=Ji.INTERSECTING),w}function Sn(){return[1/0,1/0,-1/0,-1/0]}function yo(h,e,r,l,a){return a?(a[0]=h,a[1]=e,a[2]=r,a[3]=l,a):[h,e,r,l]}function Jl(h){return yo(1/0,1/0,-1/0,-1/0,h)}function Yo(h,e){let r=h[0],l=h[1];return yo(r,l,r,l,e)}function Ql(h,e,r,l,a){let o=Jl(a);return Jf(o,h,e,r,l)}function Fd(h,e){return h[0]==e[0]&&h[2]==e[2]&&h[1]==e[1]&&h[3]==e[3]}function Z0(h,e){return e[0]<h[0]&&(h[0]=e[0]),e[2]>h[2]&&(h[2]=e[2]),e[1]<h[1]&&(h[1]=e[1]),e[3]>h[3]&&(h[3]=e[3]),h}function Kf(h,e){e[0]<h[0]&&(h[0]=e[0]),e[0]>h[2]&&(h[2]=e[0]),e[1]<h[1]&&(h[1]=e[1]),e[1]>h[3]&&(h[3]=e[1])}function Jf(h,e,r,l,a){for(;r<l;r+=a)_S(h,e[r],e[r+1]);return h}function _S(h,e,r){h[0]=Math.min(h[0],e),h[1]=Math.min(h[1],r),h[2]=Math.max(h[2],e),h[3]=Math.max(h[3],r)}function X0(h,e){let r;return r=e(Qf(h)),r||(r=e(em(h)),r)||(r=e(im(h)),r)||(r=e(tm(h)),r)?r:!1}function Qf(h){return[h[0],h[1]]}function em(h){return[h[2],h[1]]}function es(h){return[(h[0]+h[2])/2,(h[1]+h[3])/2]}function H0(h,e,r,l,a){let[o,g,v,w,T,S,k,F]=xS(h,e,r,l);return yo(Math.min(o,v,T,k),Math.min(g,w,S,F),Math.max(o,v,T,k),Math.max(g,w,S,F),a)}function xS(h,e,r,l){let a=e*l[0]/2,o=e*l[1]/2,g=Math.cos(r),v=Math.sin(r),w=a*g,T=a*v,S=o*g,k=o*v,F=h[0],j=h[1];return[F-w+k,j-T-S,F-w-k,j-T+S,F+w-k,j+T+S,F+w+k,j+T-S,F-w+k,j-T-S]}function ln(h){return h[3]-h[1]}function tm(h){return[h[0],h[3]]}function im(h){return[h[2],h[3]]}function $i(h){return h[2]-h[0]}function Qi(h,e){return h[0]<=e[2]&&h[2]>=e[0]&&h[1]<=e[3]&&h[3]>=e[1]}function Th(h){return h[2]<h[0]||h[3]<h[1]}function Y0(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h}function K0(h,e,r){let l=!1,a=Dd(h,e),o=Dd(h,r);if(a===Ji.INTERSECTING||o===Ji.INTERSECTING)l=!0;else{let g=h[0],v=h[1],w=h[2],T=h[3],S=e[0],k=e[1],F=r[0],j=r[1],J=(j-k)/(F-S),he,q;o&Ji.ABOVE&&!(a&Ji.ABOVE)&&(he=F-(j-T)/J,l=he>=g&&he<=w),!l&&o&Ji.RIGHT&&!(a&Ji.RIGHT)&&(q=j-(F-w)*J,l=q>=v&&q<=T),!l&&o&Ji.BELOW&&!(a&Ji.BELOW)&&(he=F-(j-v)/J,l=he>=g&&he<=w),!l&&o&Ji.LEFT&&!(a&Ji.LEFT)&&(q=j-(F-g)*J,l=q>=v&&q<=T)}return l}function J0(h,e,r,l){if(Th(h))return Jl(r);let a=[];if(l>1){let v=h[2]-h[0],w=h[3]-h[1];for(let T=0;T<l;++T)a.push(h[0]+v*T/l,h[1],h[2],h[1]+w*T/l,h[2]-v*T/l,h[3],h[0],h[3]-w*T/l)}else a=[h[0],h[1],h[2],h[1],h[2],h[3],h[0],h[3]];e(a,a,2);let o=[],g=[];for(let v=0,w=a.length;v<w;v+=2)o.push(a[v]),g.push(a[v+1]);return yS(o,g,r)}function rm(h,e){let r=e.getExtent(),l=es(h);if(e.canWrapX()&&(l[0]<r[0]||l[0]>=r[2])){let a=$i(r),g=Math.floor((l[0]-r[0])/a)*a;h[0]-=g,h[2]-=g}return h}function Q0(h,e){if(e.canWrapX()){let r=e.getExtent();if(!isFinite(h[0])||!isFinite(h[2]))return[[r[0],h[1],r[2],h[3]]];rm(h,e);let l=$i(r);if($i(h)>l)return[[r[0],h[1],r[2],h[3]]];if(h[0]<r[0])return[[h[0]+l,h[1],r[2],h[3]],[r[0],h[1],h[2],h[3]]];if(h[2]>r[2])return[[h[0],h[1],r[2],h[3]],[r[0],h[1],h[2]-l,h[3]]]}return[h]}var Mh={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var nm=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Mh[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},zd=nm;var Ah=6378137,ec=Math.PI*Ah,vS=[-ec,-ec,ec,ec],bS=[-180,-85,180,85],Od=Ah*Math.log(Math.tan(Math.PI/2)),Ko=class extends zd{constructor(e){super({code:e,units:"m",extent:vS,global:!0,worldExtent:bS,getPointResolution:function(r,l){return r/Math.cosh(l[1]/Ah)}})}},sm=[new Ko("EPSG:3857"),new Ko("EPSG:102100"),new Ko("EPSG:102113"),new Ko("EPSG:900913"),new Ko("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ko("http://www.opengis.net/gml/srs/epsg.xml#3857")];function ex(h,e,r){let l=h.length;r=r>1?r:2,e===void 0&&(r>2?e=h.slice():e=new Array(l));for(let a=0;a<l;a+=r){e[a]=ec*h[a]/180;let o=Ah*Math.log(Math.tan(Math.PI*(+h[a+1]+90)/360));o>Od?o=Od:o<-Od&&(o=-Od),e[a+1]=o}return e}function tx(h,e,r){let l=h.length;r=r>1?r:2,e===void 0&&(r>2?e=h.slice():e=new Array(l));for(let a=0;a<l;a+=r)e[a]=180*h[a]/ec,e[a+1]=360*Math.atan(Math.exp(h[a+1]/Ah))/Math.PI-90;return e}var wS=6378137,ix=[-180,-90,180,90],SS=Math.PI*wS/180,_o=class extends zd{constructor(e,r){super({code:e,units:"degrees",extent:ix,axisOrientation:r,global:!0,metersPerUnit:SS,worldExtent:ix})}},om=[new _o("CRS:84"),new _o("EPSG:4326","neu"),new _o("urn:ogc:def:crs:OGC:1.3:CRS84"),new _o("urn:ogc:def:crs:OGC:2:84"),new _o("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new _o("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new _o("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var am={};function rx(h){return am[h]||am[h.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function nx(h,e){am[h]=e}var tc={};function Ph(h,e,r){let l=h.getCode(),a=e.getCode();l in tc||(tc[l]={}),tc[l][a]=r}function sx(h,e){let r;return h in tc&&e in tc[h]&&(r=tc[h][e]),r}function Ii(h,e,r){return Math.min(Math.max(h,e),r)}function ox(h,e,r,l,a,o){let g=a-r,v=o-l;if(g!==0||v!==0){let w=((h-r)*g+(e-l)*v)/(g*g+v*v);w>1?(r=a,l=o):w>0&&(r+=g*w,l+=v*w)}return gs(h,e,r,l)}function gs(h,e,r,l){let a=r-h,o=l-e;return a*a+o*o}function ax(h){return h*180/Math.PI}function lx(h){return h*Math.PI/180}function Ua(h,e){let r=h%e;return r*e<0?r+e:r}function Dr(h,e,r){return h+r*(e-h)}function cx(h,e){let r=Math.pow(10,e);return Math.round(h*r)/r}function hx(h,e){return h[0]+=+e[0],h[1]+=+e[1],h}function lm(h,e){let r=h[0],l=h[1],a=e[0],o=e[1],g=a[0],v=a[1],w=o[0],T=o[1],S=w-g,k=T-v,F=S===0&&k===0?0:(S*(r-g)+k*(l-v))/(S*S+k*k||0),j,J;return F<=0?(j=g,J=v):F>=1?(j=w,J=T):(j=g+F*S,J=v+F*k),[j,J]}function cn(h,e){let r=!0;for(let l=h.length-1;l>=0;--l)if(h[l]!=e[l]){r=!1;break}return r}function ux(h,e){let r=Math.cos(e),l=Math.sin(e),a=h[0]*r-h[1]*l,o=h[1]*r+h[0]*l;return h[0]=a,h[1]=o,h}function ic(h,e){let r=h[0]-e[0],l=h[1]-e[1];return r*r+l*l}function cm(h,e){return Math.sqrt(ic(h,e))}function dx(h,e){return ic(h,lm(h,e))}function px(h,e){if(e.canWrapX()){let r=$i(e.getExtent()),l=fx(h,e,r);l&&(h[0]-=l*r)}return h}function fx(h,e,r){let l=e.getExtent(),a=0;return e.canWrapX()&&(h[0]<l[0]||h[0]>l[2])&&(r=r||$i(l),a=Math.floor((h[0]-l[0])/r)),a}var mx={info:1,warn:2,error:3,none:4},CS=mx.info;function gx(...h){CS>mx.warn||console.warn(...h)}var hm=!0;function um(h){hm=!(h===void 0?!0:h)}function dm(h,e){if(e!==void 0){for(let r=0,l=h.length;r<l;++r)e[r]=h[r];e=e}else e=h.slice();return e}function IS(h,e){if(e!==void 0&&h!==e){for(let r=0,l=h.length;r<l;++r)e[r]=h[r];h=e}return h}function ES(h){nx(h.getCode(),h),Ph(h,h,dm)}function TS(h){h.forEach(ES)}function qi(h){return typeof h=="string"?rx(h):h||null}function yx(h){TS(h),h.forEach(function(e){h.forEach(function(r){e!==r&&Ph(e,r,dm)})})}function MS(h,e,r,l){h.forEach(function(a){e.forEach(function(o){Ph(a,o,r),Ph(o,a,l)})})}function Bd(h,e){return h?typeof h=="string"?qi(h):h:qi(e)}function yr(h,e){return um(),Nd(h,"EPSG:4326",e!==void 0?e:"EPSG:3857")}function $a(h,e){let r=Nd(h,e!==void 0?e:"EPSG:3857","EPSG:4326"),l=r[0];return(l<-180||l>180)&&(r[0]=Ua(l+180,360)-180),r}function _x(h,e){if(h===e)return!0;let r=h.getUnits()===e.getUnits();return(h.getCode()===e.getCode()||rc(h,e)===dm)&&r}function rc(h,e){let r=h.getCode(),l=e.getCode(),a=sx(r,l);return a||(a=IS),a}function qa(h,e){let r=qi(h),l=qi(e);return rc(r,l)}function Nd(h,e,r){return qa(e,r)(h,void 0,h.length)}function Rh(h,e,r,l){let a=qa(e,r);return J0(h,a,void 0,l)}var ys=null;function Wn(){return ys}function Wa(h,e){return ys?Nd(h,e,ys):h}function er(h,e){return ys?Nd(h,ys,e):(hm&&!cn(h,[0,0])&&h[0]>=-180&&h[0]<=180&&h[1]>=-90&&h[1]<=90&&(hm=!1,gx("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),h)}function zs(h,e){return ys?Rh(h,e,ys):h}function Os(h,e){return ys?Rh(h,ys,e):h}function xx(h,e){if(!ys)return h;let r=qi(e).getMetersPerUnit(),l=ys.getMetersPerUnit();return r&&l?h*r/l:h}function AS(){yx(sm),yx(om),MS(om,sm,ex,tx)}AS();function Cn(h,e,r,l,a,o){o=o||[];let g=0;for(let v=e;v<r;v+=l){let w=h[v],T=h[v+1];o[g++]=a[0]*w+a[2]*T+a[4],o[g++]=a[1]*w+a[3]*T+a[5]}return o&&o.length!=g&&(o.length=g),o}function Vd(h,e,r,l,a,o,g){g=g||[];let v=Math.cos(a),w=Math.sin(a),T=o[0],S=o[1],k=0;for(let F=e;F<r;F+=l){let j=h[F]-T,J=h[F+1]-S;g[k++]=T+j*v-J*w,g[k++]=S+j*w+J*v;for(let he=F+2;he<F+l;++he)g[k++]=h[he]}return g&&g.length!=k&&(g.length=k),g}function vx(h,e,r,l,a,o,g,v){v=v||[];let w=g[0],T=g[1],S=0;for(let k=e;k<r;k+=l){let F=h[k]-w,j=h[k+1]-T;v[S++]=w+a*F,v[S++]=T+o*j;for(let J=k+2;J<k+l;++J)v[S++]=h[J]}return v&&v.length!=S&&(v.length=S),v}function bx(h,e,r,l,a,o,g){g=g||[];let v=0;for(let w=e;w<r;w+=l){g[v++]=h[w]+a,g[v++]=h[w+1]+o;for(let T=w+2;T<w+l;++T)g[v++]=h[T]}return g&&g.length!=v&&(g.length=v),g}var wx=mr(),pm=class extends gr{constructor(){super(),this.extent_=Sn(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Pd((e,r,l)=>{if(!l)return this.getSimplifiedGeometry(r);let a=this.clone();return a.applyTransform(l),a.getSimplifiedGeometry(r)})}simplifyTransformed(e,r){return this.simplifyTransformedInternal(this.getRevision(),e,r)}clone(){return St()}closestPointXY(e,r,l,a){return St()}containsXY(e,r){let l=this.getClosestPoint([e,r]);return l[0]===e&&l[1]===r}getClosestPoint(e,r){return r=r||[NaN,NaN],this.closestPointXY(e[0],e[1],r,1/0),r}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return St()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let r=this.computeExtent(this.extent_);(isNaN(r[0])||isNaN(r[1]))&&Jl(r),this.extentRevision_=this.getRevision()}return Y0(this.extent_,e)}rotate(e,r){St()}scale(e,r,l){St()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return St()}getType(){return St()}applyTransform(e){St()}intersectsExtent(e){return St()}translate(e,r){St()}transform(e,r){let l=qi(e),a=l.getUnits()=="tile-pixels"?function(o,g,v){let w=l.getExtent(),T=l.getWorldExtent(),S=ln(T)/ln(w);return an(wx,T[0],T[3],S,-S,0,0,0),Cn(o,0,o.length,v,wx,g),qa(l,r)(o,g,v)}:qa(l,r);return this.applyTransform(a),this}},Gd=pm;var fm=class extends Gd{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return Ql(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return St()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=this.getSimplifiedGeometryInternal(e);return r.getFlatCoordinates().length<this.flatCoordinates.length?r:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,r){this.stride=Sx(e),this.layout=e,this.flatCoordinates=r}setCoordinates(e,r){St()}setLayout(e,r,l){let a;if(e)a=Sx(e);else{for(let o=0;o<l;++o){if(r.length===0){this.layout="XY",this.stride=2;return}r=r[0]}a=r.length,e=Jo(a)}this.layout=e,this.stride=a}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.stride),this.changed())}rotate(e,r){let l=this.getFlatCoordinates();if(l){let a=this.getStride();Vd(l,0,l.length,a,e,r,l),this.changed()}}scale(e,r,l){r===void 0&&(r=e),l||(l=es(this.getExtent()));let a=this.getFlatCoordinates();if(a){let o=this.getStride();vx(a,0,a.length,o,e,r,l,a),this.changed()}}translate(e,r){let l=this.getFlatCoordinates();if(l){let a=this.getStride();bx(l,0,l.length,a,e,r,l),this.changed()}}};function Jo(h){let e;return h==2?e="XY":h==3?e="XYZ":h==4&&(e="XYZM"),e}function Sx(h){let e;return h=="XY"?e=2:h=="XYZ"||h=="XYM"?e=3:h=="XYZM"&&(e=4),e}function Cx(h,e,r){let l=h.getFlatCoordinates();if(!l)return null;let a=h.getStride();return Cn(l,0,l.length,a,e,r)}var In=fm;function Ix(h,e,r,l){for(let a=0,o=r.length;a<o;++a)h[e++]=r[a];return e}function Za(h,e,r,l){for(let a=0,o=r.length;a<o;++a){let g=r[a];for(let v=0;v<l;++v)h[e++]=g[v]}return e}function Qo(h,e,r,l,a){a=a||[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=Za(h,e,r[g],l);a[o++]=w,e=w}return a.length=o,a}function jd(h,e,r,l,a){a=a||[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=Qo(h,e,r[g],l,a[o]);w.length===0&&(w[0]=e),a[o++]=w,e=w[w.length-1]}return a.length=o,a}var gm=class h extends Gd{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Yr),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let r=0,l=e.length;r<l;++r)this.changeEventsKeys_.push(Lr(e[r],li.CHANGE,this.changed,this))}clone(){let e=new h(mm(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,r,l,a){if(a<wn(this.getExtent(),e,r))return a;let o=this.geometries_;for(let g=0,v=o.length;g<v;++g)a=o[g].closestPointXY(e,r,l,a);return a}containsXY(e,r){let l=this.geometries_;for(let a=0,o=l.length;a<o;++a)if(l[a].containsXY(e,r))return!0;return!1}computeExtent(e){Jl(e);let r=this.geometries_;for(let l=0,a=r.length;l<a;++l)Z0(e,r[l].getExtent());return e}getGeometries(){return mm(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[],r=this.geometries_;for(let l=0,a=r.length;l<a;++l)r[l].getType()===this.getType()?e=e.concat(r[l].getGeometriesArrayRecursive()):e.push(r[l]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=[],l=this.geometries_,a=!1;for(let o=0,g=l.length;o<g;++o){let v=l[o],w=v.getSimplifiedGeometry(e);r.push(w),w!==v&&(a=!0)}return a?new h(r):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){let r=this.geometries_;for(let l=0,a=r.length;l<a;++l)if(r[l].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,r){let l=this.geometries_;for(let a=0,o=l.length;a<o;++a)l[a].rotate(e,r);this.changed()}scale(e,r,l){l||(l=es(this.getExtent()));let a=this.geometries_;for(let o=0,g=a.length;o<g;++o)a[o].scale(e,r,l);this.changed()}setGeometries(e){this.setGeometriesArray(mm(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){let r=this.geometries_;for(let l=0,a=r.length;l<a;++l)r[l].applyTransform(e);this.changed()}translate(e,r){let l=this.geometries_;for(let a=0,o=l.length;a<o;++a)l[a].translate(e,r);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function mm(h){return h.map(e=>e.clone())}var ym=gm;function Ex(h,e,r,l,a,o,g){let v=h[e],w=h[e+1],T=h[r]-v,S=h[r+1]-w,k;if(T===0&&S===0)k=e;else{let F=((a-v)*T+(o-w)*S)/(T*T+S*S);if(F>1)k=r;else if(F>0){for(let j=0;j<l;++j)g[j]=Dr(h[e+j],h[r+j],F);g.length=l;return}else k=e}for(let F=0;F<l;++F)g[F]=h[k+F];g.length=l}function kh(h,e,r,l,a){let o=h[e],g=h[e+1];for(e+=l;e<r;e+=l){let v=h[e],w=h[e+1],T=gs(o,g,v,w);T>a&&(a=T),o=v,g=w}return a}function Lh(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];a=kh(h,e,v,l,a),e=v}return a}function Tx(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];a=Lh(h,e,v,l,a),e=v[v.length-1]}return a}function Dh(h,e,r,l,a,o,g,v,w,T,S){if(e==r)return T;let k,F;if(a===0){if(F=gs(g,v,h[e],h[e+1]),F<T){for(k=0;k<l;++k)w[k]=h[e+k];return w.length=l,F}return T}S=S||[NaN,NaN];let j=e+l;for(;j<r;)if(Ex(h,j-l,j,l,g,v,S),F=gs(g,v,S[0],S[1]),F<T){for(T=F,k=0;k<l;++k)w[k]=S[k];w.length=l,j+=l}else j+=l*Math.max((Math.sqrt(F)-Math.sqrt(T))/a|0,1);if(o&&(Ex(h,r-l,e,l,g,v,S),F=gs(g,v,S[0],S[1]),F<T)){for(T=F,k=0;k<l;++k)w[k]=S[k];w.length=l}return T}function Fh(h,e,r,l,a,o,g,v,w,T,S){S=S||[NaN,NaN];for(let k=0,F=r.length;k<F;++k){let j=r[k];T=Dh(h,e,j,l,a,o,g,v,w,T,S),e=j}return T}function Mx(h,e,r,l,a,o,g,v,w,T,S){S=S||[NaN,NaN];for(let k=0,F=r.length;k<F;++k){let j=r[k];T=Fh(h,e,j,l,a,o,g,v,w,T,S),e=j[j.length-1]}return T}function Xa(h,e,r,l,a,o,g){let v=(r-e)/l;if(v<3){for(;e<r;e+=l)o[g++]=h[e],o[g++]=h[e+1];return g}let w=new Array(v);w[0]=1,w[v-1]=1;let T=[e,r-l],S=0;for(;T.length>0;){let k=T.pop(),F=T.pop(),j=0,J=h[F],he=h[F+1],q=h[k],Z=h[k+1];for(let ne=F+l;ne<k;ne+=l){let me=h[ne],_e=h[ne+1],fe=ox(me,_e,J,he,q,Z);fe>j&&(S=ne,j=fe)}j>a&&(w[(S-e)/l]=1,F+l<S&&T.push(F,S),S+l<k&&T.push(S,k))}for(let k=0;k<v;++k)w[k]&&(o[g++]=h[e+k*l],o[g++]=h[e+k*l+1]);return g}function Ud(h,e,r,l,a,o,g,v){for(let w=0,T=r.length;w<T;++w){let S=r[w];g=Xa(h,e,S,l,a,o,g),v.push(g),e=S}return g}function ea(h,e){return e*Math.round(h/e)}function PS(h,e,r,l,a,o,g){if(e==r)return g;let v=ea(h[e],a),w=ea(h[e+1],a);e+=l,o[g++]=v,o[g++]=w;let T,S;do if(T=ea(h[e],a),S=ea(h[e+1],a),e+=l,e==r)return o[g++]=T,o[g++]=S,g;while(T==v&&S==w);for(;e<r;){let k=ea(h[e],a),F=ea(h[e+1],a);if(e+=l,k==T&&F==S)continue;let j=T-v,J=S-w,he=k-v,q=F-w;if(j*q==J*he&&(j<0&&he<j||j==he||j>0&&he>j)&&(J<0&&q<J||J==q||J>0&&q>J)){T=k,S=F;continue}o[g++]=T,o[g++]=S,v=T,w=S,T=k,S=F}return o[g++]=T,o[g++]=S,g}function zh(h,e,r,l,a,o,g,v){for(let w=0,T=r.length;w<T;++w){let S=r[w];g=PS(h,e,S,l,a,o,g),v.push(g),e=S}return g}function Ax(h,e,r,l,a,o,g,v){for(let w=0,T=r.length;w<T;++w){let S=r[w],k=[];g=zh(h,e,S,l,a,o,g,k),v.push(k),e=S[S.length-1]}return g}function ts(h,e,r,l,a){a=a!==void 0?a:[];let o=0;for(let g=e;g<r;g+=l)a[o++]=h.slice(g,g+l);return a.length=o,a}function ta(h,e,r,l,a){a=a!==void 0?a:[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=r[g];a[o++]=ts(h,e,w,l,a[o]),e=w}return a.length=o,a}function Oh(h,e,r,l,a){a=a!==void 0?a:[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=r[g];a[o++]=w.length===1&&w[0]===e?[]:ta(h,e,w,l,a[o]),e=w[w.length-1]}return a.length=o,a}function _m(h,e,r,l){let a=0,o=h[r-l],g=h[r-l+1];for(;e<r;e+=l){let v=h[e],w=h[e+1];a+=g*v-o*w,o=v,g=w}return a/2}function xm(h,e,r,l){let a=0;for(let o=0,g=r.length;o<g;++o){let v=r[o];a+=_m(h,e,v,l),e=v}return a}function Px(h,e,r,l){let a=0;for(let o=0,g=r.length;o<g;++o){let v=r[o];a+=xm(h,e,v,l),e=v[v.length-1]}return a}var vm=class h extends In{constructor(e,r){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}clone(){return new h(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Dh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,r,l,a))}getArea(){return _m(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return ts(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){let r=[];return r.length=Xa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Za(this.flatCoordinates,0,e,this.stride),this.changed()}},bm=vm;function $d(h,e,r,l,a){let o;for(e+=l;e<r;e+=l)if(o=a(h.slice(e-l,e),h.slice(e,e+l)),o)return o;return!1}function Ha(h,e,r,l,a,o,g){let v,w,T=(r-e)/l;if(T===1)v=e;else if(T===2)v=e,w=a;else if(T!==0){let S=h[e],k=h[e+1],F=0,j=[0];for(let q=e+l;q<r;q+=l){let Z=h[q],ne=h[q+1];F+=Math.sqrt((Z-S)*(Z-S)+(ne-k)*(ne-k)),j.push(F),S=Z,k=ne}let J=a*F,he=$0(j,J);he<0?(w=(J-j[-he-2])/(j[-he-1]-j[-he-2]),v=e+(-he-2)*l):v=e+he*l}g=g>1?g:2,o=o||new Array(g);for(let S=0;S<g;++S)o[S]=v===void 0?NaN:w===void 0?h[v+S]:Dr(h[v+S],h[v+l+S],w);return o}function qd(h,e,r,l,a,o){if(r==e)return null;let g;if(a<h[e+l-1])return o?(g=h.slice(e,e+l),g[l-1]=a,g):null;if(h[r-1]<a)return o?(g=h.slice(r-l,r),g[l-1]=a,g):null;if(a==h[e+l-1])return h.slice(e,e+l);let v=e/l,w=r/l;for(;v<w;){let F=v+w>>1;a<h[(F+1)*l-1]?w=F:v=F+1}let T=h[v*l-1];if(a==T)return h.slice((v-1)*l,(v-1)*l+l);let S=h[(v+1)*l-1],k=(a-T)/(S-T);g=[];for(let F=0;F<l-1;++F)g.push(Dr(h[(v-1)*l+F],h[v*l+F],k));return g.push(a),g}function Rx(h,e,r,l,a,o,g){if(g)return qd(h,e,r[r.length-1],l,a,o);let v;if(a<h[l-1])return o?(v=h.slice(0,l),v[l-1]=a,v):null;if(h[h.length-1]<a)return o?(v=h.slice(h.length-l),v[l-1]=a,v):null;for(let w=0,T=r.length;w<T;++w){let S=r[w];if(e!=S){if(a<h[e+l-1])return null;if(a<=h[S-1])return qd(h,e,S,l,a,!1);e=S}}return null}function kx(h,e,r,l,a){return!X0(a,function(g){return!ia(h,e,r,l,g[0],g[1])})}function ia(h,e,r,l,a,o){let g=0,v=h[r-l],w=h[r-l+1];for(;e<r;e+=l){let T=h[e],S=h[e+1];w<=o?S>o&&(T-v)*(o-w)-(a-v)*(S-w)>0&&g++:S<=o&&(T-v)*(o-w)-(a-v)*(S-w)<0&&g--,v=T,w=S}return g!==0}function Bh(h,e,r,l,a,o){if(r.length===0||!ia(h,e,r[0],l,a,o))return!1;for(let g=1,v=r.length;g<v;++g)if(ia(h,r[g-1],r[g],l,a,o))return!1;return!0}function Lx(h,e,r,l,a,o){if(r.length===0)return!1;for(let g=0,v=r.length;g<v;++g){let w=r[g];if(Bh(h,e,w,l,a,o))return!0;e=w[w.length-1]}return!1}function Nh(h,e,r,l,a){let o=Jf(Sn(),h,e,r,l);return Qi(a,o)?go(a,o)||o[0]>=a[0]&&o[2]<=a[2]||o[1]>=a[1]&&o[3]<=a[3]?!0:$d(h,e,r,l,function(g,v){return K0(a,g,v)}):!1}function Dx(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){if(Nh(h,e,r[o],l,a))return!0;e=r[o]}return!1}function RS(h,e,r,l,a){return!!(Nh(h,e,r,l,a)||ia(h,e,r,l,a[0],a[1])||ia(h,e,r,l,a[0],a[3])||ia(h,e,r,l,a[2],a[1])||ia(h,e,r,l,a[2],a[3]))}function wm(h,e,r,l,a){if(!RS(h,e,r[0],l,a))return!1;if(r.length===1)return!0;for(let o=1,g=r.length;o<g;++o)if(kx(h,r[o-1],r[o],l,a)&&!Nh(h,r[o-1],r[o],l,a))return!1;return!0}function Fx(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];if(wm(h,e,v,l,a))return!0;e=v[v.length-1]}return!1}function Wd(h,e,r,l){let a=h[e],o=h[e+1],g=0;for(let v=e+l;v<r;v+=l){let w=h[v],T=h[v+1];g+=Math.sqrt((w-a)*(w-a)+(T-o)*(T-o)),a=w,o=T}return g}var Sm=class h extends In{constructor(e,r){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendCoordinate(e){kr(this.flatCoordinates,e),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Dh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,r,l,a))}forEachSegment(e){return $d(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,r){return this.layout!="XYM"&&this.layout!="XYZM"?null:(r=r!==void 0?r:!1,qd(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r))}getCoordinates(){return ts(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,r){return Ha(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,this.stride)}getLength(){return Wd(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){let r=[];return r.length=Xa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LineString"}intersectsExtent(e){return Nh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Za(this.flatCoordinates,0,e,this.stride),this.changed()}},_s=Sm;var Cm=class h extends In{constructor(e,r,l){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,r);else if(r!==void 0&&l)this.setFlatCoordinates(r,e),this.ends_=l;else{let a=e,o=[],g=[];for(let w=0,T=a.length;w<T;++w){let S=a[w];kr(o,S.getFlatCoordinates()),g.push(o.length)}let v=a.length===0?this.getLayout():a[0].getLayout();this.setFlatCoordinates(v,o),this.ends_=g}}appendLineString(e){kr(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Lh(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Fh(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,r,l,a))}getCoordinateAtM(e,r,l){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(r=r!==void 0?r:!1,l=l!==void 0?l:!1,Rx(this.flatCoordinates,0,this.ends_,this.stride,e,r,l))}getCoordinates(){return ta(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new _s(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){let e=this.flatCoordinates,r=this.ends_,l=this.layout,a=[],o=0;for(let g=0,v=r.length;g<v;++g){let w=r[g],T=new _s(e.slice(o,w),l);a.push(T),o=w}return a}getFlatMidpoints(){let e=[],r=this.flatCoordinates,l=0,a=this.ends_,o=this.stride;for(let g=0,v=a.length;g<v;++g){let w=a[g],T=Ha(r,l,w,o,.5);kr(e,T),l=w}return e}getSimplifiedGeometryInternal(e){let r=[],l=[];return r.length=Ud(this.flatCoordinates,0,this.ends_,this.stride,e,r,0,l),new h(r,"XY",l)}getType(){return"MultiLineString"}intersectsExtent(e){return Dx(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let l=Qo(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=l.length===0?0:l[l.length-1],this.changed()}},Im=Cm;var Em=class h extends In{constructor(e,r){super(),this.setCoordinates(e,r)}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,l,a){let o=this.flatCoordinates,g=gs(e,r,o[0],o[1]);if(g<a){let v=this.stride;for(let w=0;w<v;++w)l[w]=o[w];return l.length=v,g}return a}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return Yo(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return Eh(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,r){this.setLayout(r,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ix(this.flatCoordinates,0,e,this.stride),this.changed()}},_r=Em;var Tm=class h extends In{constructor(e,r){super(),r&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendPoint(e){kr(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,l,a){if(a<wn(this.getExtent(),e,r))return a;let o=this.flatCoordinates,g=this.stride;for(let v=0,w=o.length;v<w;v+=g){let T=gs(e,r,o[v],o[v+1]);if(T<a){a=T;for(let S=0;S<g;++S)l[S]=o[v+S];l.length=g}}return a}getCoordinates(){return ts(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){let r=this.flatCoordinates.length/this.stride;return e<0||r<=e?null:new _r(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){let e=this.flatCoordinates,r=this.layout,l=this.stride,a=[];for(let o=0,g=e.length;o<g;o+=l){let v=new _r(e.slice(o,o+l),r);a.push(v)}return a}getType(){return"MultiPoint"}intersectsExtent(e){let r=this.flatCoordinates,l=this.stride;for(let a=0,o=r.length;a<o;a+=l){let g=r[a],v=r[a+1];if(Eh(e,g,v))return!0}return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Za(this.flatCoordinates,0,e,this.stride),this.changed()}},Vh=Tm;function Gh(h,e,r,l,a,o,g){let v,w,T,S,k,F,j,J=a[o+1],he=[];for(let ne=0,me=r.length;ne<me;++ne){let _e=r[ne];for(S=h[_e-l],F=h[_e-l+1],v=e;v<_e;v+=l)k=h[v],j=h[v+1],(J<=F&&j<=J||F<=J&&J<=j)&&(T=(J-F)/(j-F)*(k-S)+S,he.push(T)),S=k,F=j}let q=NaN,Z=-1/0;for(he.sort(Ds),S=he[0],v=1,w=he.length;v<w;++v){k=he[v];let ne=Math.abs(k-S);ne>Z&&(T=(S+k)/2,Bh(h,e,r,l,T,J)&&(q=T,Z=ne)),S=k}return isNaN(q)&&(q=a[o]),g?(g.push(q,J,Z),g):[q,J,Z]}function Zd(h,e,r,l,a){let o=[];for(let g=0,v=r.length;g<v;++g){let w=r[g];o=Gh(h,e,w,l,a,2*g,o),e=w[w.length-1]}return o}function zx(h,e,r,l){for(;e<r-l;){for(let a=0;a<l;++a){let o=h[e+a];h[e+a]=h[r-l+a],h[r-l+a]=o}e+=l,r-=l}}function Mm(h,e,r,l){let a=0,o=h[r-l],g=h[r-l+1];for(;e<r;e+=l){let v=h[e],w=h[e+1];a+=(v-o)*(w+g),o=v,g=w}return a===0?void 0:a>0}function jh(h,e,r,l,a){a=a!==void 0?a:!1;for(let o=0,g=r.length;o<g;++o){let v=r[o],w=Mm(h,e,v,l);if(o===0){if(a&&w||!a&&!w)return!1}else if(a&&!w||!a&&w)return!1;e=v}return!0}function Xd(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];if(!jh(h,e,v,l,a))return!1;v.length&&(e=v[v.length-1])}return!0}function nc(h,e,r,l,a){a=a!==void 0?a:!1;for(let o=0,g=r.length;o<g;++o){let v=r[o],w=Mm(h,e,v,l);(o===0?a&&w||!a&&!w:a&&!w||!a&&w)&&zx(h,e,v,l),e=v}return e}function Uh(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o)e=nc(h,e,r[o],l,a);return e}function Ox(h,e){let r=[],l=0,a=0,o;for(let g=0,v=e.length;g<v;++g){let w=e[g],T=Mm(h,l,w,2);if(o===void 0&&(o=T),T===o)r.push(e.slice(a,g+1));else{if(r.length===0)continue;r[r.length-1].push(e[a])}a=g+1,l=w}return r}var $h=class h extends In{constructor(e,r,l){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,r!==void 0&&l?(this.setFlatCoordinates(r,e),this.ends_=l):this.setCoordinates(e,r)}appendLinearRing(e){this.flatCoordinates?kr(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Lh(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Fh(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,r,l,a))}containsXY(e,r){return Bh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,r)}getArea(){return xm(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),nc(r,0,this.ends_,this.stride,e)):r=this.flatCoordinates,ta(r,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let e=es(this.getExtent());this.flatInteriorPoint_=Gh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new _r(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new bm(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){let e=this.layout,r=this.flatCoordinates,l=this.ends_,a=[],o=0;for(let g=0,v=l.length;g<v;++g){let w=l[g],T=new bm(r.slice(o,w),e);a.push(T),o=w}return a}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;jh(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=nc(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],l=[];return r.length=zh(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),r,0,l),new h(r,"XY",l)}getType(){return"Polygon"}intersectsExtent(e){return wm(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let l=Qo(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=l.length===0?0:l[l.length-1],this.changed()}},sc=$h;function Am(h){if(Th(h))throw new Error("Cannot create polygon from empty extent");let e=h[0],r=h[1],l=h[2],a=h[3],o=[e,r,e,a,l,a,l,r,e,r];return new $h(o,"XY",[o.length])}function Pm(h,e,r){e=e||32;let l=h.getStride(),a=h.getLayout(),o=h.getCenter(),g=l*(e+1),v=new Array(g);for(let S=0;S<g;S+=l){v[S]=0,v[S+1]=0;for(let k=2;k<l;k++)v[S+k]=o[k]}let w=[v.length],T=new $h(v,a,w);return kS(T,o,h.getRadius(),r),T}function kS(h,e,r,l){let a=h.getFlatCoordinates(),o=h.getStride(),g=a.length/o-1,v=l||0;for(let w=0;w<=g;++w){let T=w*o,S=v+Ua(w,g)*2*Math.PI/g;a[T]=e[0]+r*Math.cos(S),a[T+1]=e[1]+r*Math.sin(S)}h.changed()}function Hd(h,e,r,l){let a=[],o=Sn();for(let g=0,v=r.length;g<v;++g){let w=r[g];o=Ql(h,e,w[0],l),a.push((o[0]+o[2])/2,(o[1]+o[3])/2),e=w[w.length-1]}return a}var Rm=class h extends In{constructor(e,r,l){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!l&&!Array.isArray(e[0])){let a=e,o=[],g=[];for(let v=0,w=a.length;v<w;++v){let T=a[v],S=o.length,k=T.getEnds();for(let F=0,j=k.length;F<j;++F)k[F]+=S;kr(o,T.getFlatCoordinates()),g.push(k)}r=a.length===0?this.getLayout():a[0].getLayout(),e=o,l=g}r!==void 0&&l?(this.setFlatCoordinates(r,e),this.endss_=l):this.setCoordinates(e,r)}appendPolygon(e){let r;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),r=e.getEnds().slice(),this.endss_.push();else{let l=this.flatCoordinates.length;kr(this.flatCoordinates,e.getFlatCoordinates()),r=e.getEnds().slice();for(let a=0,o=r.length;a<o;++a)r[a]+=l}this.endss_.push(r),this.changed()}clone(){let e=this.endss_.length,r=new Array(e);for(let a=0;a<e;++a)r[a]=this.endss_[a].slice();let l=new h(this.flatCoordinates.slice(),this.layout,r);return l.applyProperties(this),l}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Tx(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Mx(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,r,l,a))}containsXY(e,r){return Lx(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,r)}getArea(){return Px(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),Uh(r,0,this.endss_,this.stride,e)):r=this.flatCoordinates,Oh(r,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let e=Hd(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Zd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Vh(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;Xd(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Uh(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],l=[];return r.length=Ax(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),r,0,l),new h(r,"XY",l)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let r;if(e===0)r=0;else{let o=this.endss_[e-1];r=o[o.length-1]}let l=this.endss_[e].slice(),a=l[l.length-1];if(r!==0)for(let o=0,g=l.length;o<g;++o)l[o]-=r;return new sc(this.flatCoordinates.slice(r,a),this.layout,l)}getPolygons(){let e=this.layout,r=this.flatCoordinates,l=this.endss_,a=[],o=0;for(let g=0,v=l.length;g<v;++g){let w=l[g].slice(),T=w[w.length-1];if(o!==0)for(let k=0,F=w.length;k<F;++k)w[k]-=o;let S=new sc(r.slice(o,T),e,w);a.push(S),o=T}return a}getType(){return"MultiPolygon"}intersectsExtent(e){return Fx(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,3),this.flatCoordinates||(this.flatCoordinates=[]);let l=jd(this.flatCoordinates,0,e,this.stride,this.endss_);if(l.length===0)this.flatCoordinates.length=0;else{let a=l[l.length-1];this.flatCoordinates.length=a.length===0?0:a[a.length-1]}this.changed()}},km=Rm;var LS=(h,e,r)=>{let{time_intervals:l,olGeometry:a,coordinate:o}=e.properties,{coordinates:g}=e.geometry,{type:v}=e.geometry,w=a,T,S;if(a&&(v=w.getType()),r&&o)T=o;else if(v==="Point")T=g;else if(v==="LineString"){w||(w=new _s(g));let k=l||[[]],F=k[0],j=k[k.length-1];if(h<F[0])[,,S]=F,T=w.getFirstCoordinate();else if(h>j[0])[,,S]=j,T=w.getLastCoordinate();else for(let J=0;J<k.length-1;J+=1){let[he,q]=k[J],[Z,ne]=k[J+1];if(he<=h&&h<=Z){let _e=Math.min((h-he)/(Z-he),1)*(ne-q)+q;T=w.getCoordinateAt(_e),[,,S]=k[J];break}}}else console.error("This geometry type is not supported. Only Point or LineString are. Current geometry: ",w);return{coord:T,rotation:S}},qh=LS;var DS=(h,e,r,l,a)=>{if(!h)return{renderedTrajectories:[]};let{time:o=Date.now(),size:g=[],center:v,resolution:w,rotation:T=0,pixelRatio:S=1}=l;if(!w||!v)return{renderedTrajectories:[]};let{noInterpolate:k=!1,hoverVehicleId:F,selectedVehicleId:j,filter:J,getScreenPixel:he=(Pe,Ye)=>(Ye.zoom||0)<12?Pe.map(je=>Math.floor(je)):Pe}=a,q=h.getContext("2d");q?.clearRect(0,0,h.width,h.height);let[Z,ne]=g;Z&&ne&&(h.width!==Z||h.height!==ne)&&([h.width,h.height]=[Z*S,ne*S]);let me=an(mr(),g[0]/2,g[1]/2,1/w,-1/w,-T,-v[0],-v[1]);h.style&&(h.style.width=`${h.width/S}px`,h.style.height=`${h.height/S}px`);let _e,fe,ve,Ee,Re=[];for(let Pe=e.length-1;Pe>=0;Pe-=1){let Ye=e[Pe];if(J&&!J(Ye))continue;let{train_id:je,timeOffset:Ke}=Ye.properties,{coord:xt,rotation:At}=qh(o-(Ke||0),Ye,k);if(e[Pe].properties.coordinate=xt,e[Pe].properties.rotation=At,!xt)continue;let rt=rr(me,[...xt]);if(!rt||(rt=rt.map(yt=>yt*S),rt[0]<0||rt[0]>h.width||rt[1]<0||rt[1]>h.height))continue;let tt=r(Ye,l,a);if(tt){if(F!==je&&j!==je){let[yt,ut]=he([rt[0]-tt.width/2,rt[1]-tt.height/2],l);q?.drawImage(tt,yt,ut)}F&&F===je&&(_e=tt,fe=rt),j&&j===je&&(ve=tt,Ee=rt),Re.push(Ye)}}return ve&&Ee&&q?.drawImage(ve,Math.floor(Ee[0]-ve.width/2),Math.floor(Ee[1]-ve.height/2)),_e&&fe&&q?.drawImage(_e,Math.floor(fe[0]-_e.width/2),Math.floor(fe[1]-_e.height/2)),{renderedTrajectories:Re}},Wh=DS;var FS=(h,e,r=!1)=>{let l=["HIDDEN","LEAVING","BOARDING"],a=h.has_fzo&&l.indexOf(h.state)>-1,o=e.has_fzo&&l.indexOf(e.state)>-1;if(a||o){if(a!==o)return a?-1:1;if(h.state!==e.state)return l.indexOf(h.state)-l.indexOf(e.state)}let g=null,v=null,w=Date.now();return r?(g=new Date(h.min_arrival_time||h.time).getTime()-w,v=new Date(e.min_arrival_time||e.time).getTime()-w):(g=new Date(h.time).getTime()-w,v=new Date(e.time).getTime()-w),g-v},Zh=FS;var zS=(h,e=!1,r=30)=>{let l=Object.keys(h).map(k=>h[k]);l.sort((k,F)=>Zh(k,F,e));let a=new Date;a.setMinutes(a.getMinutes()+r);let o=a.getTime(),g=new Date;g.setMinutes(g.getMinutes()-r);let v=g.getTime(),w=[],T=[],S=null;for(let k=l.length-1;k>=0;k-=1){let F={...l[k]},j=new Date(F.time).getTime();j>v&&j<o&&(F.state==="BOARDING"&&(T.includes(F.platform)?F.state="HIDDEN":T.push(F.platform)),S&&F.to[0]===S.to[0]&&Math.abs(j-S.time)<1e3&&F.line.name===S.line.name&&(F.state="HIDDEN"),/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(F.state)&&(F.cancelled=!0),S=F,S.time=j,w.unshift(F))}return w},Xh=zS;var OS=(h,e=!1,r=30,l=100)=>{let a={},o={};return g=>{let{source:v,content:w}=g;a[v]&&window.clearTimeout(a[v]),w&&(o[w.call_id]=w,a[v]=window.setTimeout(()=>{let T=Xh(o,e||!1,r);h(T)},l))}},Lm=OS;var BS=(h,e)=>{let r=null;return typeof window>"u"?null:(typeof document<"u"&&document?.createElement?(r=document.createElement("canvas"),r.width=h,r.height=e):OffscreenCanvas?r=new OffscreenCanvas(h,e):console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"),r)},xs=BS;var oc={};Of(oc,{MOTS_ALL:()=>GS,MOTS_ONLY_RAIL:()=>vs,MOTS_WITHOUT_CABLE:()=>Yd,MOTS_WITH_CABLE:()=>VS,bgColors:()=>Nx,getBgColor:()=>US,getDelayColor:()=>WS,getDelayText:()=>ZS,getRadius:()=>jS,getTextColor:()=>$S,getTextSize:()=>qS,getTypeIndex:()=>Kd,textColors:()=>Vx,types:()=>Bx});var NS=[[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15]],vs=["rail"],VS=["cablecar","gondola","funicular","coach"],Yd=["tram","subway","rail","bus"],GS=["tram","subway","rail","bus","ferry","cablecar","gondola","funicular","coach"],Bx=[/^Tram/i,/^Subway( \/ Metro \/ S-Bahn)?/i,/^Train/i,/^Bus/i,/^Ferry/i,/^Cable ?Car/i,/^Gondola/i,/^Funicular/i,/^(Long distance bus|coach)/i,/^Rail/i],Nx=["#ffb400","#ff5400","#ff8080","#ea0000","#3000ff","#ffb400","#41a27b","#00d237","#b5b5b5","#ff8080"],Vx=["#000000","#ffffff","#000000","#ffffff","#ffffff","#000000","#ffffff","#000000","#000000","#000000"],Kd=h=>typeof h=="string"?Bx.findIndex(e=>e.test(h)):h,jS=(h,e)=>{try{let r=Kd(h||0);return NS[r][e]}catch{return 1}},US=h=>{try{let e=Kd(h);return Nx[e]}catch{return"#ffffff"}},$S=h=>{try{let e=Kd(h);return Vx[e]}catch{return"#ffffff"}},qS=(h,e,r,l,a)=>{if(!h)return 0;h.font=a(l,r);let o=h.measureText(r),g=25,v=0;for(;o.width>e-6&&v<g;)l-=.5,h.font=a(l,r),o=h.measureText(r),v+=1;return l},WS=(h,e,r)=>e?r?"#ff0000":"#a0a0a0":h===null?"#a0a0a0":h>=36e5?"#ed004c":h>=5e5?"#e80000":h>=3e5?"#ff4a00":h>=18e4?"#f7bf00":"#00a00c",ZS=(h,e)=>e?String.fromCodePoint(215):h>=36e5?`+${Math.round(h/36e5)}h`:h>=6e4?`+${Math.round(h/6e4)}m`:h>=1e3?`+${Math.round(h/1e3)}s`:h>0?`+${h}ms`:"";var ra="vectorTileFeature";var Dm={},Nm=(h,e,r)=>{let l=`${h}, ${e}, ${r}`;if(!Dm[l]){let a=xs(h*2,h*2);if(a){let o=a.getContext("2d");if(!o)return null;o.beginPath(),o.arc(h,h,e,0,2*Math.PI,!1),o.fillStyle=r,o.filter="blur(1px)",o.fill(),Dm[l]=a}}return Dm[l]},Fm={},Vm=(h,e,r,l,a="#000",o=1)=>{let g=`${h}, ${r}, ${l}, ${a}, ${o}`;if(!Fm[g]){let v=xs(Math.ceil(h.length*e),Math.ceil(e+8*o));if(v){let w=v.getContext("2d");if(!w)return null;w.font=r,w.textAlign="left",w.textBaseline="middle",w.font=r,w.fillStyle=l,w.strokeStyle=a,w.lineWidth=1.5*o,w.strokeText(h,0,e),w.fillText(h,0,e),Fm[g]=v}}return Fm[g]},zm={},Gm=(h,e,r,l,a,o)=>{let g=`${h}, ${e}, ${r}, ${l}, ${a}, ${o}`;if(!zm[g]){let v=xs(h*2,h*2);if(v){let w=v.getContext("2d");if(!w)return null;w.fillStyle=r,l&&(w.lineWidth=1*o,w.strokeStyle="#000000"),w.beginPath(),w.arc(h,h,e,0,2*Math.PI,!1),w.fill(),a&&w.setLineDash([5,3]),l&&w.stroke(),zm[g]=v}}return zm[g]},Om={},jm=(h,e,r,l,a,o,g,v)=>{let w=`${h}, ${e}, ${r}, ${l},${a}, ${o}, ${g}`;if(!Om[w]){let T=xs(e*2,e*2);if(T){let S=T.getContext("2d");if(!S)return null;o&&(S.save(),S.textBaseline="middle",S.textAlign="center",S.font=v(r+2,h),S.strokeStyle=a,S.strokeText(h,e,e),S.restore()),S.textBaseline="middle",S.textAlign="center",S.fillStyle=l,S.font=v(r,h),S.strokeStyle=a,S.strokeText(h,e,e),S.fillText(h,e,e),Om[w]=T}}return Om[w]},Bm={},XS=(h,e,r)=>{let{hoverVehicleId:l,selectedVehicleId:a,useDelayStyle:o,delayOutlineColor:g="#000",delayDisplay:v=3e5,getRadius:w=()=>0,getBgColor:T=()=>"#000",getDelayColor:S=()=>"#000",getDelayText:k=()=>null,getDelayFont:F=Bt=>`bold ${Bt}px arial, sans-serif`,getText:j=Bt=>Bt,getTextFont:J=Bt=>`bold ${Bt}px arial, sans-serif`,getTextColor:he=()=>"#000",getTextSize:q=()=>14,getMaxRadiusForText:Z=()=>10,getMaxRadiusForStrokeAndDelay:ne=()=>7}=r,{zoom:me,pixelRatio:_e=1}=e,{type:fe}=h.properties,{train_id:ve,line:Ee,delay:Re,state:Pe,operator_provides_realtime_journey:Ye}=h.properties,{name:je,text_color:Ke,color:xt}=Ee||{};je=j(je);let At=Pe==="JOURNEY_CANCELLED";fe||(fe="Rail"),je||(je="I"),Ke||(Ke="#000000"),xt&&xt[0]!=="#"&&(xt=`#${xt}`),Ke[0]!=="#"&&(Ke=`#${Ke}`);let rt=Math.min(Math.floor(me||1),16),tt=!!(l&&l===ve),yt=!!(a&&a===ve),ut=w(fe,rt)*_e,Mt=ut>=ne()*_e;(tt||yt)&&(ut=Mt?ut+5*_e:14*_e);let mt=ut>Z()*_e,Ft=`${ut}${tt||yt}`;if(o?(Ft+=`${Ye}${Re}`,Mt&&(Ft+=`${At}`)):(Ft+=`${xt||fe}`,Mt&&(Ft+=`${At}${Re}`)),mt&&(Ft+=`${je}${Ke}`),!Bm[Ft]){if(ut===0)return null;let Bt=1*_e,Ei=ut+2*_e,Ue=ut*2,ki=Ei*2+Bt*2,xi=ki/2,Nr=null;Mt&&Re!==null&&(Nr=Nm(xi,Ei,S(Re,At)));let ar=null,Ln=0;if(Mt&&(tt||(Re||0)>=v||At)){Ln=Math.max(At?19:14,Math.min(At?19:17,ut*1.2))*_e;let Ti=k(Re,At);Ti&&(ar=Vm(Ti,Ln,F(Ln,Ti),S(Re,At,!0),g,_e))}let lr;o?lr=S(Re,At):lr=xt||T(fe);let oi=Gm(xi,ut,lr,Mt||tt||yt,!!Mt&&!!o&&Re===null&&Ye==="yes",_e),Dn=ki+(ar?.width||0)*2,tr=xs(Dn,ki);if(tr){let Ti=tr.getContext("2d");if(!Ti)return null;let Et=ar?.width||0;Nr&&Ti.drawImage(Nr,Et,0),oi&&Ti.drawImage(oi,Et,0);let ci=null;if(mt){let Vr=Math.max(ut,10),Fn=q(Ti,Ue,je,Vr,J),pn=o?"#000000":Ke||he(fe);ci=jm(je,xi,Fn,pn,lr,!!o&&Re===null&&Ye==="yes",_e,J)}ci&&Ti.drawImage(ci,Et,0),ar&&Ti.drawImage(ar,Et+Math.ceil(xi+Ei)+Bt,Math.ceil(xi-Ln)),Bm[Ft]=tr}}return Bm[Ft]},Ya=XS;var HS=(h,e,r)=>Ya(h,e,{...r,useDelayStyle:!0}),Um=HS;var Jd,YS=()=>{if(!Jd){Jd=xs(15,15);let h=Jd?.getContext("2d");h&&(h.arc(8,8,5,0,2*Math.PI,!1),h.fillStyle="#8ED6FF",h.fill(),h.lineWidth=3,h.strokeStyle="black",h.stroke(),h.lineWidth=3)}return Jd},$m=YS;var Ht={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var qm=class extends gr{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;let r=Object.assign({},e);typeof e.properties=="object"&&(delete r.properties,Object.assign(r,e.properties)),r[Ht.OPACITY]=e.opacity!==void 0?e.opacity:1,si(typeof r[Ht.OPACITY]=="number","Layer opacity must be a number"),r[Ht.VISIBLE]=e.visible!==void 0?e.visible:!0,r[Ht.Z_INDEX]=e.zIndex,r[Ht.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,r[Ht.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,r[Ht.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,r[Ht.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=r.className!==void 0?r.className:"ol-layer",delete r.className,this.setProperties(r),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){let r=this.state_||{layer:this,managed:e===void 0?!0:e},l=this.getZIndex();return r.opacity=Ii(Math.round(this.getOpacity()*100)/100,0,1),r.visible=this.getVisible(),r.extent=this.getExtent(),r.zIndex=l===void 0&&!r.managed?1/0:l,r.maxResolution=this.getMaxResolution(),r.minResolution=Math.max(this.getMinResolution(),0),r.minZoom=this.getMinZoom(),r.maxZoom=this.getMaxZoom(),this.state_=r,r}getLayersArray(e){return St()}getLayerStatesArray(e){return St()}getExtent(){return this.get(Ht.EXTENT)}getMaxResolution(){return this.get(Ht.MAX_RESOLUTION)}getMinResolution(){return this.get(Ht.MIN_RESOLUTION)}getMinZoom(){return this.get(Ht.MIN_ZOOM)}getMaxZoom(){return this.get(Ht.MAX_ZOOM)}getOpacity(){return this.get(Ht.OPACITY)}getSourceState(){return St()}getVisible(){return this.get(Ht.VISIBLE)}getZIndex(){return this.get(Ht.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(Ht.EXTENT,e)}setMaxResolution(e){this.set(Ht.MAX_RESOLUTION,e)}setMinResolution(e){this.set(Ht.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(Ht.MAX_ZOOM,e)}setMinZoom(e){this.set(Ht.MIN_ZOOM,e)}setOpacity(e){si(typeof e=="number","Layer opacity must be a number"),this.set(Ht.OPACITY,e)}setVisible(e){this.set(Ht.VISIBLE,e)}setZIndex(e){this.set(Ht.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Gx=qm;var Bs={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var En={ANIMATING:0,INTERACTING:1};var is={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Wm(h,e,r){return function(l,a,o,g,v){if(!l)return;if(!a&&!e)return l;let w=e?0:o[0]*a,T=e?0:o[1]*a,S=v?v[0]:0,k=v?v[1]:0,F=h[0]+w/2+S,j=h[2]-w/2+S,J=h[1]+T/2+k,he=h[3]-T/2+k;F>j&&(F=(j+F)/2,j=F),J>he&&(J=(he+J)/2,he=J);let q=Ii(l[0],F,j),Z=Ii(l[1],J,he);if(g&&r&&a){let ne=30*a;q+=-ne*Math.log(1+Math.max(0,F-l[0])/ne)+ne*Math.log(1+Math.max(0,l[0]-j)/ne),Z+=-ne*Math.log(1+Math.max(0,J-l[1])/ne)+ne*Math.log(1+Math.max(0,l[1]-he)/ne)}return[q,Z]}}function jx(h){return h}function Zm(h,e,r,l){let a=$i(e)/r[0],o=ln(e)/r[1];return l?Math.min(h,Math.max(a,o)):Math.min(h,Math.min(a,o))}function Xm(h,e,r){let l=Math.min(h,e),a=50;return l*=Math.log(1+a*Math.max(0,h/e-1))/a+1,r&&(l=Math.max(l,r),l/=Math.log(1+a*Math.max(0,r/h-1))/a+1),Ii(l,r/2,e*2)}function Ux(h,e,r,l){return e=e!==void 0?e:!0,function(a,o,g,v){if(a!==void 0){let w=h[0],T=h[h.length-1],S=r?Zm(w,r,g,l):w;if(v)return e?Xm(a,S,T):Ii(a,T,S);let k=Math.min(S,a),F=Math.floor(Md(h,k,o));return h[F]>S&&F<h.length-1?h[F+1]:h[F]}}}function $x(h,e,r,l,a,o){return l=l!==void 0?l:!0,r=r!==void 0?r:0,function(g,v,w,T){if(g!==void 0){let S=a?Zm(e,a,w,o):e;if(T)return l?Xm(g,S,r):Ii(g,r,S);let k=1e-9,F=Math.ceil(Math.log(e/S)/Math.log(h)-k),j=-v*(.5-k)+.5,J=Math.min(S,g),he=Math.floor(Math.log(e/J)/Math.log(h)+j),q=Math.max(F,he),Z=e/Math.pow(h,q);return Ii(Z,r,S)}}}function Hm(h,e,r,l,a){return r=r!==void 0?r:!0,function(o,g,v,w){if(o!==void 0){let T=l?Zm(h,l,v,a):h;return!r||!w?Ii(o,e,T):Xm(o,T,e)}}}function qx(h){if(h!==void 0)return 0}function Ym(h){if(h!==void 0)return h}function Wx(h){let e=2*Math.PI/h;return function(r,l){if(l)return r;if(r!==void 0)return r=Math.floor(r/e+.5)*e,r}}function Zx(h){let e=h===void 0?lx(5):h;return function(r,l){return l||r===void 0?r:Math.abs(r)<=e?0:r}}function KS(h){return Math.pow(h,3)}function Xx(h){return 1-KS(1-h)}function Hx(h){return 3*h*h-2*h*h*h}var Km=0,Qm=class extends gr{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Bd(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&um(),e.center&&(e.center=er(e.center,this.projection_)),e.extent&&(e.extent=Os(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){let r=Object.assign({},e);for(let v in is)delete r[v];this.setProperties(r,!0);let l=QS(e);this.maxResolution_=l.maxResolution,this.minResolution_=l.minResolution,this.zoomFactor_=l.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=l.minZoom;let a=JS(e),o=l.constraint,g=e2(e);this.constraints_={center:a,resolution:o,rotation:g},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let r=this.padding_;this.padding_=e;let l=this.getCenterInternal();if(l){let a=e||[0,0,0,0];r=r||[0,0,0,0];let o=this.getResolution(),g=o/2*(a[3]-r[3]+r[1]-a[1]),v=o/2*(a[0]-r[0]+r[2]-a[2]);this.setCenterInternal([l[0]+g,l[1]-v])}}getUpdatedOptions_(e){let r=this.getProperties();return r.resolution!==void 0?r.resolution=this.getResolution():r.zoom=this.getZoom(),r.center=this.getCenterInternal(),r.rotation=this.getRotation(),Object.assign({},r,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let r=new Array(arguments.length);for(let l=0;l<r.length;++l){let a=arguments[l];a.center&&(a=Object.assign({},a),a.center=er(a.center,this.getProjection())),a.anchor&&(a=Object.assign({},a),a.anchor=er(a.anchor,this.getProjection())),r[l]=a}this.animateInternal.apply(this,r)}animateInternal(e){let r=arguments.length,l;r>1&&typeof arguments[r-1]=="function"&&(l=arguments[r-1],--r);let a=0;for(;a<r&&!this.isDef();++a){let S=arguments[a];S.center&&this.setCenterInternal(S.center),S.zoom!==void 0?this.setZoom(S.zoom):S.resolution&&this.setResolution(S.resolution),S.rotation!==void 0&&this.setRotation(S.rotation)}if(a===r){l&&Qd(l,!0);return}let o=Date.now(),g=this.targetCenter_.slice(),v=this.targetResolution_,w=this.targetRotation_,T=[];for(;a<r;++a){let S=arguments[a],k={start:o,complete:!1,anchor:S.anchor,duration:S.duration!==void 0?S.duration:1e3,easing:S.easing||Hx,callback:l};if(S.center&&(k.sourceCenter=g,k.targetCenter=S.center.slice(),g=k.targetCenter),S.zoom!==void 0?(k.sourceResolution=v,k.targetResolution=this.getResolutionForZoom(S.zoom),v=k.targetResolution):S.resolution&&(k.sourceResolution=v,k.targetResolution=S.resolution,v=k.targetResolution),S.rotation!==void 0){k.sourceRotation=w;let F=Ua(S.rotation-w+Math.PI,2*Math.PI)-Math.PI;k.targetRotation=w+F,w=k.targetRotation}t2(k)?k.complete=!0:o+=k.duration,T.push(k)}this.animations_.push(T),this.setHint(En.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[En.ANIMATING]>0}getInteracting(){return this.hints_[En.INTERACTING]>0}cancelAnimations(){this.setHint(En.ANIMATING,-this.hints_[En.ANIMATING]);let e;for(let r=0,l=this.animations_.length;r<l;++r){let a=this.animations_[r];if(a[0].callback&&Qd(a[0].callback,!1),!e)for(let o=0,g=a.length;o<g;++o){let v=a[o];if(!v.complete){e=v.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let e=Date.now(),r=!1;for(let l=this.animations_.length-1;l>=0;--l){let a=this.animations_[l],o=!0;for(let g=0,v=a.length;g<v;++g){let w=a[g];if(w.complete)continue;let T=e-w.start,S=w.duration>0?T/w.duration:1;S>=1?(w.complete=!0,S=1):o=!1;let k=w.easing(S);if(w.sourceCenter){let F=w.sourceCenter[0],j=w.sourceCenter[1],J=w.targetCenter[0],he=w.targetCenter[1];this.nextCenter_=w.targetCenter;let q=F+k*(J-F),Z=j+k*(he-j);this.targetCenter_=[q,Z]}if(w.sourceResolution&&w.targetResolution){let F=k===1?w.targetResolution:w.sourceResolution+k*(w.targetResolution-w.sourceResolution);if(w.anchor){let j=this.getViewportSize_(this.getRotation()),J=this.constraints_.resolution(F,0,j,!0);this.targetCenter_=this.calculateCenterZoom(J,w.anchor)}this.nextResolution_=w.targetResolution,this.targetResolution_=F,this.applyTargetState_(!0)}if(w.sourceRotation!==void 0&&w.targetRotation!==void 0){let F=k===1?Ua(w.targetRotation+Math.PI,2*Math.PI)-Math.PI:w.sourceRotation+k*(w.targetRotation-w.sourceRotation);if(w.anchor){let j=this.constraints_.rotation(F,!0);this.targetCenter_=this.calculateCenterRotate(j,w.anchor)}this.nextRotation_=w.targetRotation,this.targetRotation_=F}if(this.applyTargetState_(!0),r=!0,!w.complete)break}if(o){this.animations_[l]=null,this.setHint(En.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let g=a[0].callback;g&&Qd(g,!0)}}this.animations_=this.animations_.filter(Boolean),r&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,r){let l,a=this.getCenterInternal();return a!==void 0&&(l=[a[0]-r[0],a[1]-r[1]],ux(l,e-this.getRotation()),hx(l,r)),l}calculateCenterZoom(e,r){let l,a=this.getCenterInternal(),o=this.getResolution();if(a!==void 0&&o!==void 0){let g=r[0]-e*(r[0]-a[0])/o,v=r[1]-e*(r[1]-a[1])/o;l=[g,v]}return l}getViewportSize_(e){let r=this.viewportSize_;if(e){let l=r[0],a=r[1];return[Math.abs(l*Math.cos(e))+Math.abs(a*Math.sin(e)),Math.abs(l*Math.sin(e))+Math.abs(a*Math.cos(e))]}return r}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&Wa(e,this.getProjection())}getCenterInternal(){return this.get(is.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){let r=this.calculateExtentInternal(e);return zs(r,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();let r=this.getCenterInternal();si(r,"The view center is not defined");let l=this.getResolution();si(l!==void 0,"The view resolution is not defined");let a=this.getRotation();return si(a!==void 0,"The view rotation is not defined"),H0(r,l,a,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(is.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,r){return this.getResolutionForExtentInternal(Os(e,this.getProjection()),r)}getResolutionForExtentInternal(e,r){r=r||this.getViewportSizeMinusPadding_();let l=$i(e)/r[0],a=ln(e)/r[1];return Math.max(l,a)}getResolutionForValueFunction(e){e=e||2;let r=this.getConstrainedResolution(this.maxResolution_),l=this.minResolution_,a=Math.log(r/l)/Math.log(e);return function(o){return r/Math.pow(e,o*a)}}getRotation(){return this.get(is.ROTATION)}getValueForResolutionFunction(e){let r=Math.log(e||2),l=this.getConstrainedResolution(this.maxResolution_),a=this.minResolution_,o=Math.log(l/a)/r;return function(g){return Math.log(l/g)/r/o}}getViewportSizeMinusPadding_(e){let r=this.getViewportSize_(e),l=this.padding_;return l&&(r=[r[0]-l[1]-l[3],r[1]-l[0]-l[2]]),r}getState(){let e=this.getProjection(),r=this.getResolution(),l=this.getRotation(),a=this.getCenterInternal(),o=this.padding_;if(o){let g=this.getViewportSizeMinusPadding_();a=Jm(a,this.getViewportSize_(),[g[0]/2+o[3],g[1]/2+o[0]],r,l)}return{center:a.slice(0),projection:e!==void 0?e:null,resolution:r,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:l,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,r=this.getResolution();return r!==void 0&&(e=this.getZoomForResolution(r)),e}getZoomForResolution(e){let r=this.minZoom_||0,l,a;if(this.resolutions_){let o=Md(this.resolutions_,e,1);r=o,l=this.resolutions_[o],o==this.resolutions_.length-1?a=2:a=l/this.resolutions_[o+1]}else l=this.maxResolution_,a=this.zoomFactor_;return r+Math.log(l/e)/Math.log(a)}getResolutionForZoom(e){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;let r=Ii(Math.floor(e),0,this.resolutions_.length-2),l=this.resolutions_[r]/this.resolutions_[r+1];return this.resolutions_[r]/Math.pow(l,Ii(e-r,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,r){let l;if(si(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){si(!Th(e),"Cannot fit empty extent provided as `geometry`");let a=Os(e,this.getProjection());l=Am(a)}else if(e.getType()==="Circle"){let a=Os(e.getExtent(),this.getProjection());l=Am(a),l.rotate(this.getRotation(),es(a))}else{let a=Wn();a?l=e.clone().transform(a,this.getProjection()):l=e}this.fitInternal(l,r)}rotatedExtentForGeometry(e){let r=this.getRotation(),l=Math.cos(r),a=Math.sin(-r),o=e.getFlatCoordinates(),g=e.getStride(),v=1/0,w=1/0,T=-1/0,S=-1/0;for(let k=0,F=o.length;k<F;k+=g){let j=o[k]*l-o[k+1]*a,J=o[k]*a+o[k+1]*l;v=Math.min(v,j),w=Math.min(w,J),T=Math.max(T,j),S=Math.max(S,J)}return[v,w,T,S]}fitInternal(e,r){r=r||{};let l=r.size;l||(l=this.getViewportSizeMinusPadding_());let a=r.padding!==void 0?r.padding:[0,0,0,0],o=r.nearest!==void 0?r.nearest:!1,g;r.minResolution!==void 0?g=r.minResolution:r.maxZoom!==void 0?g=this.getResolutionForZoom(r.maxZoom):g=0;let v=this.rotatedExtentForGeometry(e),w=this.getResolutionForExtentInternal(v,[l[0]-a[1]-a[3],l[1]-a[0]-a[2]]);w=isNaN(w)?g:Math.max(w,g),w=this.getConstrainedResolution(w,o?0:1);let T=this.getRotation(),S=Math.sin(T),k=Math.cos(T),F=es(v);F[0]+=(a[1]-a[3])/2*w,F[1]+=(a[0]-a[2])/2*w;let j=F[0]*k-F[1]*S,J=F[1]*k+F[0]*S,he=this.getConstrainedCenter([j,J],w),q=r.callback?r.callback:ms;r.duration!==void 0?this.animateInternal({resolution:w,center:he,duration:r.duration,easing:r.easing},q):(this.targetResolution_=w,this.targetCenter_=he,this.applyTargetState_(!1,!0),Qd(q,!0))}centerOn(e,r,l){this.centerOnInternal(er(e,this.getProjection()),r,l)}centerOnInternal(e,r,l){this.setCenterInternal(Jm(e,r,l,this.getResolution(),this.getRotation()))}calculateCenterShift(e,r,l,a){let o,g=this.padding_;if(g&&e){let v=this.getViewportSizeMinusPadding_(-l),w=Jm(e,a,[v[0]/2+g[3],v[1]/2+g[0]],r,l);o=[e[0]-w[0],e[1]-w[1]]}return o}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){let r=Wa(this.targetCenter_,this.getProjection());this.setCenter([r[0]+e[0],r[1]+e[1]])}adjustCenterInternal(e){let r=this.targetCenter_;this.setCenterInternal([r[0]+e[0],r[1]+e[1]])}adjustResolution(e,r){r=r&&er(r,this.getProjection()),this.adjustResolutionInternal(e,r)}adjustResolutionInternal(e,r){let l=this.getAnimating()||this.getInteracting(),a=this.getViewportSize_(this.getRotation()),o=this.constraints_.resolution(this.targetResolution_*e,0,a,l);r&&(this.targetCenter_=this.calculateCenterZoom(o,r)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,r){this.adjustResolution(Math.pow(this.zoomFactor_,-e),r)}adjustRotation(e,r){r&&(r=er(r,this.getProjection())),this.adjustRotationInternal(e,r)}adjustRotationInternal(e,r){let l=this.getAnimating()||this.getInteracting(),a=this.constraints_.rotation(this.targetRotation_+e,l);r&&(this.targetCenter_=this.calculateCenterRotate(a,r)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&er(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,r){return this.hints_[e]+=r,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,r){let l=this.getAnimating()||this.getInteracting()||r,a=this.constraints_.rotation(this.targetRotation_,l),o=this.getViewportSize_(a),g=this.constraints_.resolution(this.targetResolution_,0,o,l),v=this.constraints_.center(this.targetCenter_,g,o,l,this.calculateCenterShift(this.targetCenter_,g,a,o));this.get(is.ROTATION)!==a&&this.set(is.ROTATION,a),this.get(is.RESOLUTION)!==g&&(this.set(is.RESOLUTION,g),this.set("zoom",this.getZoom(),!0)),(!v||!this.get(is.CENTER)||!cn(this.get(is.CENTER),v))&&this.set(is.CENTER,v),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,r,l){e=e!==void 0?e:200;let a=r||0,o=this.constraints_.rotation(this.targetRotation_),g=this.getViewportSize_(o),v=this.constraints_.resolution(this.targetResolution_,a,g),w=this.constraints_.center(this.targetCenter_,v,g,!1,this.calculateCenterShift(this.targetCenter_,v,o,g));if(e===0&&!this.cancelAnchor_){this.targetResolution_=v,this.targetRotation_=o,this.targetCenter_=w,this.applyTargetState_();return}l=l||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==v||this.getRotation()!==o||!this.getCenterInternal()||!cn(this.getCenterInternal(),w))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:o,center:w,resolution:v,duration:e,easing:Xx,anchor:l}))}beginInteraction(){this.resolveConstraints(0),this.setHint(En.INTERACTING,1)}endInteraction(e,r,l){l=l&&er(l,this.getProjection()),this.endInteractionInternal(e,r,l)}endInteractionInternal(e,r,l){this.getInteracting()&&(this.setHint(En.INTERACTING,-1),this.resolveConstraints(e,r,l))}getConstrainedCenter(e,r){let l=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,r||this.getResolution(),l)}getConstrainedZoom(e,r){let l=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(l,r))}getConstrainedResolution(e,r){r=r||0;let l=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,r,l)}};function Qd(h,e){setTimeout(function(){h(e)},0)}function JS(h){if(h.extent!==void 0){let r=h.smoothExtentConstraint!==void 0?h.smoothExtentConstraint:!0;return Wm(h.extent,h.constrainOnlyCenter,r)}let e=Bd(h.projection,"EPSG:3857");if(h.multiWorld!==!0&&e.isGlobal()){let r=e.getExtent().slice();return r[0]=-1/0,r[2]=1/0,Wm(r,!1,!1)}return jx}function QS(h){let e,r,l,g=h.minZoom!==void 0?h.minZoom:Km,v=h.maxZoom!==void 0?h.maxZoom:28,w=h.zoomFactor!==void 0?h.zoomFactor:2,T=h.multiWorld!==void 0?h.multiWorld:!1,S=h.smoothResolutionConstraint!==void 0?h.smoothResolutionConstraint:!0,k=h.showFullExtent!==void 0?h.showFullExtent:!1,F=Bd(h.projection,"EPSG:3857"),j=F.getExtent(),J=h.constrainOnlyCenter,he=h.extent;if(!T&&!he&&F.isGlobal()&&(J=!1,he=j),h.resolutions!==void 0){let q=h.resolutions;r=q[g],l=q[v]!==void 0?q[v]:q[q.length-1],h.constrainResolution?e=Ux(q,S,!J&&he,k):e=Hm(r,l,S,!J&&he,k)}else{let Z=(j?Math.max($i(j),ln(j)):360*Mh.degrees/F.getMetersPerUnit())/256/Math.pow(2,Km),ne=Z/Math.pow(2,28-Km);r=h.maxResolution,r!==void 0?g=0:r=Z/Math.pow(w,g),l=h.minResolution,l===void 0&&(h.maxZoom!==void 0?h.maxResolution!==void 0?l=r/Math.pow(w,v):l=Z/Math.pow(w,v):l=ne),v=g+Math.floor(Math.log(r/l)/Math.log(w)),l=r/Math.pow(w,v-g),h.constrainResolution?e=$x(w,r,l,S,!J&&he,k):e=Hm(r,l,S,!J&&he,k)}return{constraint:e,maxResolution:r,minResolution:l,minZoom:g,zoomFactor:w}}function e2(h){if(h.enableRotation!==void 0?h.enableRotation:!0){let r=h.constrainRotation;return r===void 0||r===!0?Zx():r===!1?Ym:typeof r=="number"?Wx(r):Ym}return qx}function t2(h){return!(h.sourceCenter&&h.targetCenter&&!cn(h.sourceCenter,h.targetCenter)||h.sourceResolution!==h.targetResolution||h.sourceRotation!==h.targetRotation)}function Jm(h,e,r,l,a){let o=Math.cos(-a),g=Math.sin(-a),v=h[0]*o-h[1]*g,w=h[1]*o+h[0]*g;v+=(e[0]/2-r[0])*l,w+=(r[1]-e[1]/2)*l,g=-g;let T=v*o-w*g,S=w*o+v*g;return[T,S]}var eg=Qm;var tg=class extends Gx{constructor(e){let r=Object.assign({},e);delete r.source,super(r),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(Ht.SOURCE,this.handleSourcePropertyChange_);let l=e.source?e.source:null;this.setSource(l)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(Ht.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(Yr(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let e=this.getSource();e&&(this.sourceChangeKey_=Lr(e,li.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let r,l=this.getMapInternal();!e&&l&&(e=l.getView()),e instanceof eg?r={viewState:e.getState(),extent:e.calculateExtent()}:r=e,!r.layerStatesArray&&l&&(r.layerStatesArray=l.getLayerGroup().getLayerStatesArray());let a;r.layerStatesArray?a=r.layerStatesArray.find(g=>g.layer===this):a=this.getLayerState();let o=this.getExtent();return ig(a,r.viewState)&&(!o||Qi(o,r.extent))}getAttributions(e){if(!this.isVisible(e))return[];let r,l=this.getSource();if(l&&(r=l.getAttributions()),!r)return[];let a=e instanceof eg?e.getViewStateAndExtent():e,o=r(a);return Array.isArray(o)||(o=[o]),o}render(e,r){let l=this.getRenderer();return l.prepareFrame(e)?(this.rendered=!0,l.renderFrame(e,r)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,r){}renderDeferred(e){let r=this.getRenderer();r&&r.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(Ht.MAP,e)}getMapInternal(){return this.get(Ht.MAP)}setMap(e){this.mapPrecomposeKey_&&(Yr(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(Yr(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=Lr(e,Bs.PRECOMPOSE,function(r){let a=r.frameState.layerStatesArray,o=this.getLayerState(!1);si(!a.some(function(g){return g.layer===o.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),a.push(o)},this),this.mapRenderKey_=Lr(this,li.CHANGE,e.render,e),this.changed())}setSource(e){this.set(Ht.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}};function ig(h,e){if(!h.visible)return!1;let r=e.resolution;if(r<h.minResolution||r>=h.maxResolution)return!1;let l=e.zoom;return l>h.minZoom&&l<=h.maxZoom}var xo=tg;var Yx={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var na=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",ER=na.includes("firefox"),i2=na.includes("safari")&&!na.includes("chrom"),TR=i2&&(na.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(na)),MR=na.includes("webkit")&&!na.includes("edge"),AR=na.includes("macintosh");var ep=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Kx=typeof Image<"u"&&Image.prototype.decode;var PR=function(){let h=!1;try{let e=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return h}();function Wi(h,e,r,l){let a;return r&&r.length?a=r.shift():ep?a=new OffscreenCanvas(h||300,e||300):a=document.createElement("canvas"),h&&(a.width=h),e&&(a.height=e),a.getContext("2d",l)}var rg;function Hh(){return rg||(rg=Wi(1,1)),rg}function Jx(h){let e=h.canvas;e.width=1,e.height=1,h.clearRect(0,0,1,1)}function ng(h){return h&&h.parentNode?h.parentNode.removeChild(h):null}var sg=class extends gr{constructor(e){super();let r=e.element;r&&!e.target&&!r.style.pointerEvents&&(r.style.pointerEvents="auto"),this.element=r||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){ng(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&ng(this.element);for(let r=0,l=this.listenerKeys.length;r<l;++r)Yr(this.listenerKeys[r]);this.listenerKeys.length=0,this.map_=e,e&&((this.target_?this.target_:e.getOverlayContainerStopEvent()).appendChild(this.element),this.render!==ms&&this.listenerKeys.push(Lr(e,Yx.POSTRENDER,this.render,this)),e.render())}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}},ac=sg;var r2=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",bottom:0,right:0,fontSize:".8rem",padding:"0 10px"}),h},Qx=r2;var og=class extends ac{constructor(e={}){let r=Qx();r.className=e.className||"mbt-copyright",super({element:r,...e})}render({frameState:e}){if(!e){this.element.innerHTML="";return}let r=[];e?.layerStatesArray.forEach(a=>{let{layer:o}=a;e&&ig(a,e.viewState)&&o&&o.getSource&&o.getSource()&&o.getSource().getAttributions()&&(r=r.concat(o.getSource().getAttributions()(e)))});let l=Va(r)||[];this.element.innerHTML=l.join(" | ")}},ev=og;var bs={ADD:"add",REMOVE:"remove"};var tv={LENGTH:"length"},lc=class extends mi{constructor(e,r,l){super(e),this.element=r,this.index=l}},ag=class extends gr{constructor(e,r){if(super(),this.on,this.once,this.un,r=r||{},this.unique_=!!r.unique,this.array_=e||[],this.unique_)for(let l=0,a=this.array_.length;l<a;++l)this.assertUnique_(this.array_[l],l);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let r=0,l=e.length;r<l;++r)this.push(e[r]);return this}forEach(e){let r=this.array_;for(let l=0,a=r.length;l<a;++l)e(r[l],l,r)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(tv.LENGTH)}insertAt(e,r){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r),this.array_.splice(e,0,r),this.updateLength_(),this.dispatchEvent(new lc(bs.ADD,r,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);let r=this.getLength();return this.insertAt(r,e),this.getLength()}remove(e){let r=this.array_;for(let l=0,a=r.length;l<a;++l)if(r[l]===e)return this.removeAt(l)}removeAt(e){if(e<0||e>=this.getLength())return;let r=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new lc(bs.REMOVE,r,e)),r}setAt(e,r){let l=this.getLength();if(e>=l){this.insertAt(e,r);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r,e);let a=this.array_[e];this.array_[e]=r,this.dispatchEvent(new lc(bs.REMOVE,a,e)),this.dispatchEvent(new lc(bs.ADD,r,e))}updateLength_(){this.set(tv.LENGTH,this.array_.length)}assertUnique_(e,r){for(let l=0,a=this.array_.length;l<a;++l)if(this.array_[l]===e&&l!==r)throw new Error("Duplicate item added to a unique collection")}},Yh=ag;var lg=class h extends gr{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){let r=e;this.setGeometry(r)}else{let r=e;this.setProperties(r)}}clone(){let e=new h(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());let r=this.getGeometry();r&&e.setGeometry(r.clone());let l=this.getStyle();return l&&e.setStyle(l),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(Yr(this.geometryChangeKey_),this.geometryChangeKey_=null);let e=this.getGeometry();e&&(this.geometryChangeKey_=Lr(e,li.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?n2(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}};function n2(h){if(typeof h=="function")return h;let e;return Array.isArray(h)?e=h:(si(typeof h.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[h]),function(){return e}}var rs=lg;var Tt={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var vo={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var Ka={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"]};Ka.whitepoint={2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}};Ka.max=Ka.whitepoint[2].D65;Ka.rgb=function(h,e){e=e||Ka.whitepoint[2].E;var r=h[0]/e[0],l=h[1]/e[1],a=h[2]/e[2],o,g,v;return o=r*3.240969941904521+l*-1.537383177570093+a*-.498610760293,g=r*-.96924363628087+l*1.87596750150772+a*.041555057407175,v=r*.055630079696993+l*-.20397695888897+a*1.056971514242878,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,g=g>.0031308?1.055*Math.pow(g,1/2.4)-.055:g=g*12.92,v=v>.0031308?1.055*Math.pow(v,1/2.4)-.055:v=v*12.92,o=Math.min(Math.max(0,o),1),g=Math.min(Math.max(0,g),1),v=Math.min(Math.max(0,v),1),[o*255,g*255,v*255]};vo.xyz=function(h,e){var r=h[0]/255,l=h[1]/255,a=h[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,l=l>.04045?Math.pow((l+.055)/1.055,2.4):l/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var o=r*.41239079926595+l*.35758433938387+a*.18048078840183,g=r*.21263900587151+l*.71516867876775+a*.072192315360733,v=r*.019330818715591+l*.11919477979462+a*.95053215224966;return e=e||Ka.whitepoint[2].E,[o*e[0],g*e[1],v*e[2]]};var Tn=Ka;var tp={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(h,e,r){var l,a,o,g,v,w,T,S,k,F,j,J,he;if(o=h[0],g=h[1],v=h[2],o===0)return[0,0,0];var q=.0011070564598794539;return e=e||"D65",r=r||2,k=Tn.whitepoint[r][e][0],F=Tn.whitepoint[r][e][1],j=Tn.whitepoint[r][e][2],J=4*k/(k+15*F+3*j),he=9*F/(k+15*F+3*j),l=g/(13*o)+J||0,a=v/(13*o)+he||0,T=o>8?F*Math.pow((o+16)/116,3):F*o*q,w=T*9*l/(4*a)||0,S=T*(12-3*l-20*a)/(4*a)||0,[w,T,S]}};Tn.luv=function(h,e,r){var l,a,o,g,v,w,T,S,k,F,j,J,he,q=.008856451679035631,Z=903.2962962962961;e=e||"D65",r=r||2,k=Tn.whitepoint[r][e][0],F=Tn.whitepoint[r][e][1],j=Tn.whitepoint[r][e][2],J=4*k/(k+15*F+3*j),he=9*F/(k+15*F+3*j),w=h[0],T=h[1],S=h[2],l=4*w/(w+15*T+3*S)||0,a=9*T/(w+15*T+3*S)||0;var ne=T/F;return o=ne<=q?Z*ne:116*Math.pow(ne,1/3)-16,g=13*o*(l-J),v=13*o*(a-he),[o,g,v]};var iv={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(h){var e=h[0],r=h[1],l=h[2],a,o,g;return g=l/360*2*Math.PI,a=r*Math.cos(g),o=r*Math.sin(g),[e,a,o]},xyz:function(h){return tp.xyz(iv.luv(h))}},rv=iv;tp.lchuv=function(h){var e=h[0],r=h[1],l=h[2],a=Math.sqrt(r*r+l*l),o=Math.atan2(l,r),g=o*360/2/Math.PI;return g<0&&(g+=360),[e,a,g]};Tn.lchuv=function(h){return tp.lchuv(Tn.luv(h))};var cg=fo(sv(),1),av=s2,ov={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function s2(h){var e,r=[],l=1,a;if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(h=String(h).toLowerCase(),cg.default[h])r=cg.default[h].slice(),a="rgb";else if(h==="transparent")l=0,a="rgb",r=[0,0,0];else if(h[0]==="#"){var o=h.slice(1),g=o.length,v=g<=4;l=1,v?(r=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],g===4&&(l=parseInt(o[3]+o[3],16)/255)):(r=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],g===8&&(l=parseInt(o[6]+o[7],16)/255)),r[0]||(r[0]=0),r[1]||(r[1]=0),r[2]||(r[2]=0),a="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(h)){var w=e[1];a=w.replace(/a$/,"");var T=a==="cmyk"?4:a==="gray"?1:3;r=e[2].trim().split(/\s*[,\/]\s*|\s+/),a==="color"&&(a=r.shift()),r=r.map(function(S,k){if(S[S.length-1]==="%")return S=parseFloat(S)/100,k===3?S:a==="rgb"?S*255:a[0]==="h"||a[0]==="l"&&!k?S*100:a==="lab"?S*125:a==="lch"?k<2?S*150:S*360:a[0]==="o"&&!k?S:a==="oklab"?S*.4:a==="oklch"?k<2?S*.4:S*360:S;if(a[k]==="h"||k===2&&a[a.length-1]==="h"){if(ov[S]!==void 0)return ov[S];if(S.endsWith("deg"))return parseFloat(S);if(S.endsWith("turn"))return parseFloat(S)*360;if(S.endsWith("grad"))return parseFloat(S)*360/400;if(S.endsWith("rad"))return parseFloat(S)*180/Math.PI}return S==="none"?0:parseFloat(S)}),l=r.length>T?r.pop():1}else/[0-9](?:\s|\/|,)/.test(h)&&(r=h.match(/([0-9]+)/g).map(function(S){return parseFloat(S)}),a=h.match(/([a-z])/ig)?.join("")?.toLowerCase()||"rgb");return{space:a,values:r,alpha:l}}var ip={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(h){var e=h[0]/360,r=h[1]/100,l=h[2]/100,a,o,g,v,w,T=0;if(r===0)return w=l*255,[w,w,w];for(o=l<.5?l*(1+r):l+r-l*r,a=2*l-o,v=[0,0,0];T<3;)g=e+1/3*-(T-1),g<0?g++:g>1&&g--,w=6*g<1?a+(o-a)*6*g:2*g<1?o:3*g<2?a+(o-a)*(2/3-g)*6:a,v[T++]=w*255;return v}};vo.hsl=function(h){var e=h[0]/255,r=h[1]/255,l=h[2]/255,a=Math.min(e,r,l),o=Math.max(e,r,l),g=o-a,v,w,T;return o===a?v=0:e===o?v=(r-l)/g:r===o?v=2+(l-e)/g:l===o&&(v=4+(e-r)/g),v=Math.min(v*60,360),v<0&&(v+=360),T=(a+o)/2,o===a?w=0:T<=.5?w=g/(o+a):w=g/(2-o-a),[v,w*100,T*100]};function hg(h){Array.isArray(h)&&h.raw&&(h=String.raw(...arguments)),h instanceof Number&&(h=+h);var e,r,l,a=av(h);if(!a.space)return[];let o=a.space[0]==="h"?ip.min:vo.min,g=a.space[0]==="h"?ip.max:vo.max;return e=Array(3),e[0]=Math.min(Math.max(a.values[0],o[0]),g[0]),e[1]=Math.min(Math.max(a.values[1],o[1]),g[1]),e[2]=Math.min(Math.max(a.values[2],o[2]),g[2]),a.space[0]==="h"&&(e=ip.rgb(e)),e.push(Math.min(Math.max(a.alpha,0),1)),e}function lv(h){return typeof h=="string"?h:fg(h)}var o2=1024,Kh={},ug=0;function cv(h){if(h.length===4)return h;let e=h.slice();return e[3]=1,e}function dg(h){let e=Tn.lchuv(vo.xyz(h));return e[3]=h[3],e}function hv(h){let e=Tn.rgb(rv.xyz(h));return e[3]=h[3],e}function rp(h){if(Kh.hasOwnProperty(h))return Kh[h];if(ug>=o2){let r=0;for(let l in Kh)r++&3||(delete Kh[l],--ug)}let e=hg(h);if(e.length!==4)throw new Error('Failed to parse "'+h+'" as color');for(let r of e)if(isNaN(r))throw new Error('Failed to parse "'+h+'" as color');return pg(e),Kh[h]=e,++ug,e}function bo(h){return Array.isArray(h)?h:rp(h)}function pg(h){return h[0]=Ii(h[0]+.5|0,0,255),h[1]=Ii(h[1]+.5|0,0,255),h[2]=Ii(h[2]+.5|0,0,255),h[3]=Ii(h[3],0,1),h}function fg(h){let e=h[0];e!=(e|0)&&(e=e+.5|0);let r=h[1];r!=(r|0)&&(r=r+.5|0);let l=h[2];l!=(l|0)&&(l=l+.5|0);let a=h[3]===void 0?1:Math.round(h[3]*1e3)/1e3;return"rgba("+e+","+r+","+l+","+a+")"}function uv(h){try{return rp(h),!0}catch{return!1}}function a2(h,e){return new Promise((r,l)=>{function a(){g(),r(h)}function o(){g(),l(new Error("Image load error"))}function g(){h.removeEventListener("load",a),h.removeEventListener("error",o)}h.addEventListener("load",a),h.addEventListener("error",o),e&&(h.src=e)})}function dv(h,e){return e&&(h.src=e),h.src&&Kx?new Promise((r,l)=>h.decode().then(()=>r(h)).catch(a=>h.complete&&h.width?r(h):l(a))):a2(h)}var gg=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let r in this.cache_){let l=this.cache_[r];!(e++&3)&&!l.hasListener()&&(delete this.cache_[r],delete this.patternCache_[r],--this.cacheSize_)}}}get(e,r,l){let a=mg(e,r,l);return a in this.cache_?this.cache_[a]:null}getPattern(e,r,l){let a=mg(e,r,l);return a in this.patternCache_?this.patternCache_[a]:null}set(e,r,l,a,o){let g=mg(e,r,l),v=g in this.cache_;this.cache_[g]=a,o&&(a.getImageState()===Tt.IDLE&&a.load(),a.getImageState()===Tt.LOADING?a.ready().then(()=>{this.patternCache_[g]=Hh().createPattern(a.getImage(1),"repeat")}):this.patternCache_[g]=Hh().createPattern(a.getImage(1),"repeat")),v||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function mg(h,e,r){let l=r?bo(r):"null";return e+":"+h+":"+l}var Ns=new gg;var Jh=null,yg=class extends Rd{constructor(e,r,l,a,o){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=l,this.canvas_={},this.color_=o,this.imageState_=a===void 0?Tt.IDLE:a,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=r,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===Tt.LOADED){Jh||(Jh=Wi(1,1,void 0,{willReadFrequently:!0})),Jh.drawImage(this.image_,0,0);try{Jh.getImageData(0,0,1,1),this.tainted_=!1}catch{Jh=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(li.CHANGE)}handleImageError_(){this.imageState_=Tt.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Tt.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],r=this.size_[1],l=Wi(e,r);l.fillRect(0,0,e,r),this.hitDetectionImage_=l.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===Tt.IDLE){this.image_||this.initializeImage_(),this.imageState_=Tt.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&dv(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==Tt.LOADED)return;let r=this.image_,l=document.createElement("canvas");l.width=Math.ceil(r.width*e),l.height=Math.ceil(r.height*e);let a=l.getContext("2d");a.scale(e,e),a.drawImage(r,0,0),a.globalCompositeOperation="multiply",a.fillStyle=lv(this.color_),a.fillRect(0,0,l.width/e,l.height/e),a.globalCompositeOperation="destination-in",a.drawImage(r,0,0),this.canvas_[e]=l}ready(){return this.ready_||(this.ready_=new Promise(e=>{this.imageState_===Tt.LOADED||this.imageState_===Tt.ERROR?e():this.addEventListener(li.CHANGE,function r(){(this.imageState_===Tt.LOADED||this.imageState_===Tt.ERROR)&&(this.removeEventListener(li.CHANGE,r),e())})})),this.ready_}};function cc(h,e,r,l,a,o){let g=e===void 0?void 0:Ns.get(e,r,a);return g||(g=new yg(h,h instanceof HTMLImageElement?h.src||void 0:e,r,l,a),Ns.set(e,r,a,g,o)),o&&g&&!Ns.getPattern(e,r,a)&&Ns.set(e,r,a,g,o),g}var _g=class h{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){let r=cc(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));r.ready().then(()=>{this.patternImage_=null}),r.getImageState()===Tt.IDLE&&r.load(),r.getImageState()===Tt.LOADING&&(this.patternImage_=r)}this.color_=e}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Fr=_g;var xg=class h{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}},nr=xg;function sa(h,e){return Array.isArray(h)?h:(e===void 0?e=[h,h]:(e[0]=h,e[1]=h),e)}var vg=class h{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=sa(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return St()}getImage(e){return St()}getHitDetectionImage(){return St()}getPixelRatio(e){return 1}getImageState(){return St()}getImageSize(){return St()}getOrigin(){return St()}getSize(){return St()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=sa(e)}listenImageChange(e){St()}load(){St()}unlistenImageChange(e){St()}ready(){return Promise.resolve()}},np=vg;function Mn(h){return h?Array.isArray(h)?fg(h):typeof h=="object"&&"src"in h?l2(h):h:null}function l2(h){if(!h.offset||!h.size)return Ns.getPattern(h.src,"anonymous",h.color);let e=h.src+":"+h.offset,r=Ns.getPattern(e,void 0,h.color);if(r)return r;let l=Ns.get(h.src,"anonymous",null);if(l.getImageState()!==Tt.LOADED)return null;let a=Wi(h.size[0],h.size[1]);return a.drawImage(l.getImage(1),h.offset[0],h.offset[1],h.size[0],h.size[1],0,0,h.size[0],h.size[1]),cc(a.canvas,e,void 0,Tt.LOADED,h.color,!0),Ns.getPattern(e,void 0,h.color)}var c2=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`].join(""),"i"),pv=["style","variant","weight","size","lineHeight","family"],bg=function(h){let e=h.match(c2);if(!e)return null;let r={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let l=0,a=pv.length;l<a;++l){let o=e[l+1];o!==void 0&&(r[pv[l]]=o)}return r.families=r.family.split(/,\s?/),r};var op="10px sans-serif",sr="#000",Vs="round",An=[],Pn=0,Gs="round",wo=10,So="#000",aa="center",Ja="middle",Co=[0,0,0,0],Io=1,oa=new gr,hc=null,wg,Sg={},fv=function(){let e="32px ",r=["monospace","serif"],l=r.length,a="wmytzilWMYTZIL@#/&?$%10\uF013",o,g;function v(T,S,k){let F=!0;for(let j=0;j<l;++j){let J=r[j];if(g=sp(T+" "+S+" "+e+J,a),k!=J){let he=sp(T+" "+S+" "+e+k+","+J,a);F=F&&he!=g}}return!!F}function w(){let T=!0,S=oa.getKeys();for(let k=0,F=S.length;k<F;++k){let j=S[k];oa.get(j)<100&&(v.apply(this,j.split(`
577
+ `),ie=E.createShader(E.FRAGMENT_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(ie,le),E.compileShader(ie),!E.getShaderParameter(ie,E.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${E.getShaderInfoLog(ie)}`);E.attachShader(this.program,ie);let pe=E.createShader(E.VERTEX_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(pe,xe),E.compileShader(pe),!E.getShaderParameter(pe,E.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${E.getShaderInfoLog(pe)}`);E.attachShader(this.program,pe),this.attributes={};let we={};this.numAttributes=D.length;for(let be=0;be<this.numAttributes;be++)D[be]&&(E.bindAttribLocation(this.program,be,D[be]),this.attributes[D[be]]=be);if(E.linkProgram(this.program),!E.getProgramParameter(this.program,E.LINK_STATUS))throw new Error(`Program failed to link: ${E.getProgramInfoLog(this.program)}`);E.deleteShader(pe),E.deleteShader(ie);for(let be=0;be<te.length;be++){let Ae=te[be];if(Ae&&!we[Ae]){let De=E.getUniformLocation(this.program,Ae);De&&(we[Ae]=De)}}this.fixedUniforms=f(i,we),this.terrainUniforms=((be,Ae)=>({u_depth:new o.aG(be,Ae.u_depth),u_terrain:new o.aG(be,Ae.u_terrain),u_terrain_dim:new o.aH(be,Ae.u_terrain_dim),u_terrain_matrix:new o.aI(be,Ae.u_terrain_matrix),u_terrain_unpack:new o.aJ(be,Ae.u_terrain_unpack),u_terrain_exaggeration:new o.aH(be,Ae.u_terrain_exaggeration)}))(i,we),this.binderUniforms=d?d.getUniforms(i,we):[]}draw(i,c,d,f,y,C,E,M,P,D,z,G,Y,K,te,X,le,xe){let ie=i.gl;if(this.failedToCreate)return;if(i.program.set(this.program),i.setDepthMode(d),i.setStencilMode(f),i.setColorMode(y),i.setCullFace(C),M){i.activeTexture.set(ie.TEXTURE2),ie.bindTexture(ie.TEXTURE_2D,M.depthTexture),i.activeTexture.set(ie.TEXTURE3),ie.bindTexture(ie.TEXTURE_2D,M.texture);for(let we in this.terrainUniforms)this.terrainUniforms[we].set(M[we])}for(let we in this.fixedUniforms)this.fixedUniforms[we].set(E[we]);te&&te.setUniforms(i,this.binderUniforms,Y,{zoom:K});let pe=0;switch(c){case ie.LINES:pe=2;break;case ie.TRIANGLES:pe=3;break;case ie.LINE_STRIP:pe=1}for(let we of G.get()){let be=we.vaos||(we.vaos={});(be[P]||(be[P]=new sl)).bind(i,this,D,te?te.getPaintVertexBuffers():[],z,we.vertexOffset,X,le,xe),ie.drawElements(c,we.primitiveLength*pe,ie.UNSIGNED_SHORT,we.primitiveOffset*pe*2)}}}function ol(m,i,c){let d=1/_t(c,1,i.transform.tileZoom),f=Math.pow(2,c.tileID.overscaledZ),y=c.tileSize*Math.pow(2,i.transform.tileZoom)/f,C=y*(c.tileID.canonical.x+c.tileID.wrap*f),E=y*c.tileID.canonical.y;return{u_image:0,u_texsize:c.imageAtlasTexture.size,u_scale:[d,m.fromScale,m.toScale],u_fade:m.t,u_pixel_coord_upper:[C>>16,E>>16],u_pixel_coord_lower:[65535&C,65535&E]}}let ga=(m,i,c,d)=>{let f=i.style.light,y=f.properties.get("position"),C=[y.x,y.y,y.z],E=function(){var P=new o.A(9);return o.A!=Float32Array&&(P[1]=0,P[2]=0,P[3]=0,P[5]=0,P[6]=0,P[7]=0),P[0]=1,P[4]=1,P[8]=1,P}();f.properties.get("anchor")==="viewport"&&function(P,D){var z=Math.sin(D),G=Math.cos(D);P[0]=G,P[1]=z,P[2]=0,P[3]=-z,P[4]=G,P[5]=0,P[6]=0,P[7]=0,P[8]=1}(E,-i.transform.angle),function(P,D,z){var G=D[0],Y=D[1],K=D[2];P[0]=G*z[0]+Y*z[3]+K*z[6],P[1]=G*z[1]+Y*z[4]+K*z[7],P[2]=G*z[2]+Y*z[5]+K*z[8]}(C,C,E);let M=f.properties.get("color");return{u_matrix:m,u_lightpos:C,u_lightintensity:f.properties.get("intensity"),u_lightcolor:[M.r,M.g,M.b],u_vertical_gradient:+c,u_opacity:d}},Rp=(m,i,c,d,f,y,C)=>o.e(ga(m,i,c,d),ol(y,i,C),{u_height_factor:-Math.pow(2,f.overscaledZ)/C.tileSize/8}),vu=m=>({u_matrix:m}),al=(m,i,c,d)=>o.e(vu(m),ol(c,i,d)),kp=(m,i)=>({u_matrix:m,u_world:i}),bu=(m,i,c,d,f)=>o.e(al(m,i,c,d),{u_world:f}),Lp=(m,i,c,d)=>{let f=m.transform,y,C;if(d.paint.get("circle-pitch-alignment")==="map"){let E=_t(c,1,f.zoom);y=!0,C=[E,E]}else y=!1,C=f.pixelsToGLUnits;return{u_camera_to_center_distance:f.cameraToCenterDistance,u_scale_with_map:+(d.paint.get("circle-pitch-scale")==="map"),u_matrix:m.translatePosMatrix(i.posMatrix,c,d.paint.get("circle-translate"),d.paint.get("circle-translate-anchor")),u_pitch_with_map:+y,u_device_pixel_ratio:m.pixelRatio,u_extrude_scale:C}},wu=(m,i,c)=>{let d=_t(c,1,i.zoom),f=Math.pow(2,i.zoom-c.tileID.overscaledZ),y=c.tileID.overscaleFactor();return{u_matrix:m,u_camera_to_center_distance:i.cameraToCenterDistance,u_pixels_to_tile_units:d,u_extrude_scale:[i.pixelsToGLUnits[0]/(d*f),i.pixelsToGLUnits[1]/(d*f)],u_overscale_factor:y}},Su=(m,i,c=1)=>({u_matrix:m,u_color:i,u_overlay:0,u_overlay_scale:c}),ll=m=>({u_matrix:m}),Cu=(m,i,c,d)=>({u_matrix:m,u_extrude_scale:_t(i,1,c),u_intensity:d});function Iu(m,i){let c=Math.pow(2,i.canonical.z),d=i.canonical.y;return[new o.Y(0,d/c).toLngLat().lat,new o.Y(0,(d+1)/c).toLngLat().lat]}let cl=(m,i,c,d)=>{let f=m.transform;return{u_matrix:ya(m,i,c,d),u_ratio:1/_t(i,1,f.zoom),u_device_pixel_ratio:m.pixelRatio,u_units_to_pixels:[1/f.pixelsToGLUnits[0],1/f.pixelsToGLUnits[1]]}},Eu=(m,i,c,d,f)=>o.e(cl(m,i,c,f),{u_image:0,u_image_height:d}),Ys=(m,i,c,d,f)=>{let y=m.transform,C=tn(i,y);return{u_matrix:ya(m,i,c,f),u_texsize:i.imageAtlasTexture.size,u_ratio:1/_t(i,1,y.zoom),u_device_pixel_ratio:m.pixelRatio,u_image:0,u_scale:[C,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]]}},hl=(m,i,c,d,f,y)=>{let C=m.lineAtlas,E=tn(i,m.transform),M=c.layout.get("line-cap")==="round",P=C.getDash(d.from,M),D=C.getDash(d.to,M),z=P.width*f.fromScale,G=D.width*f.toScale;return o.e(cl(m,i,c,y),{u_patternscale_a:[E/z,-P.height/2],u_patternscale_b:[E/G,-D.height/2],u_sdfgamma:C.width/(256*Math.min(z,G)*m.pixelRatio)/2,u_image:0,u_tex_y_a:P.y,u_tex_y_b:D.y,u_mix:f.t})};function tn(m,i){return 1/_t(m,1,i.tileZoom)}function ya(m,i,c,d){return m.translatePosMatrix(d?d.posMatrix:i.tileID.posMatrix,i,c.paint.get("line-translate"),c.paint.get("line-translate-anchor"))}let ul=(m,i,c,d,f)=>{return{u_matrix:m,u_tl_parent:i,u_scale_parent:c,u_buffer_scale:1,u_fade_t:d.mix,u_opacity:d.opacity*f.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:f.paint.get("raster-brightness-min"),u_brightness_high:f.paint.get("raster-brightness-max"),u_saturation_factor:(C=f.paint.get("raster-saturation"),C>0?1-1/(1.001-C):-C),u_contrast_factor:(y=f.paint.get("raster-contrast"),y>0?1/(1-y):1+y),u_spin_weights:_a(f.paint.get("raster-hue-rotate"))};var y,C};function _a(m){m*=Math.PI/180;let i=Math.sin(m),c=Math.cos(m);return[(2*c+1)/3,(-Math.sqrt(3)*i-c+1)/3,(Math.sqrt(3)*i-c+1)/3]}let xa=(m,i,c,d,f,y,C,E,M,P)=>{let D=f.transform;return{u_is_size_zoom_constant:+(m==="constant"||m==="source"),u_is_size_feature_constant:+(m==="constant"||m==="camera"),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:D.cameraToCenterDistance,u_pitch:D.pitch/360*2*Math.PI,u_rotate_symbol:+c,u_aspect_ratio:D.width/D.height,u_fade_change:f.options.fadeDuration?f.symbolFadeChange:1,u_matrix:y,u_label_plane_matrix:C,u_coord_matrix:E,u_is_text:+M,u_pitch_with_map:+d,u_texsize:P,u_texture:0}},va=(m,i,c,d,f,y,C,E,M,P,D)=>{let z=f.transform;return o.e(xa(m,i,c,d,f,y,C,E,M,P),{u_gamma_scale:d?Math.cos(z._pitch)*z.cameraToCenterDistance:1,u_device_pixel_ratio:f.pixelRatio,u_is_halo:+D})},ba=(m,i,c,d,f,y,C,E,M,P)=>o.e(va(m,i,c,d,f,y,C,E,!0,M,!0),{u_texsize_icon:P,u_texture_icon:1}),Dp=(m,i,c)=>({u_matrix:m,u_opacity:i,u_color:c}),Fp=(m,i,c,d,f,y)=>o.e(function(C,E,M,P){let D=M.imageManager.getPattern(C.from.toString()),z=M.imageManager.getPattern(C.to.toString()),{width:G,height:Y}=M.imageManager.getPixelSize(),K=Math.pow(2,P.tileID.overscaledZ),te=P.tileSize*Math.pow(2,M.transform.tileZoom)/K,X=te*(P.tileID.canonical.x+P.tileID.wrap*K),le=te*P.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:D.tl,u_pattern_br_a:D.br,u_pattern_tl_b:z.tl,u_pattern_br_b:z.br,u_texsize:[G,Y],u_mix:E.t,u_pattern_size_a:D.displaySize,u_pattern_size_b:z.displaySize,u_scale_a:E.fromScale,u_scale_b:E.toScale,u_tile_units_to_pixels:1/_t(P,1,M.transform.tileZoom),u_pixel_coord_upper:[X>>16,le>>16],u_pixel_coord_lower:[65535&X,65535&le]}}(d,y,c,f),{u_matrix:m,u_opacity:i}),Tu={fillExtrusion:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_lightpos:new o.aK(m,i.u_lightpos),u_lightintensity:new o.aH(m,i.u_lightintensity),u_lightcolor:new o.aK(m,i.u_lightcolor),u_vertical_gradient:new o.aH(m,i.u_vertical_gradient),u_opacity:new o.aH(m,i.u_opacity)}),fillExtrusionPattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_lightpos:new o.aK(m,i.u_lightpos),u_lightintensity:new o.aH(m,i.u_lightintensity),u_lightcolor:new o.aK(m,i.u_lightcolor),u_vertical_gradient:new o.aH(m,i.u_vertical_gradient),u_height_factor:new o.aH(m,i.u_height_factor),u_image:new o.aG(m,i.u_image),u_texsize:new o.aL(m,i.u_texsize),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade),u_opacity:new o.aH(m,i.u_opacity)}),fill:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix)}),fillPattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_image:new o.aG(m,i.u_image),u_texsize:new o.aL(m,i.u_texsize),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade)}),fillOutline:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_world:new o.aL(m,i.u_world)}),fillOutlinePattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_world:new o.aL(m,i.u_world),u_image:new o.aG(m,i.u_image),u_texsize:new o.aL(m,i.u_texsize),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade)}),circle:(m,i)=>({u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_scale_with_map:new o.aG(m,i.u_scale_with_map),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_extrude_scale:new o.aL(m,i.u_extrude_scale),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_matrix:new o.aI(m,i.u_matrix)}),collisionBox:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pixels_to_tile_units:new o.aH(m,i.u_pixels_to_tile_units),u_extrude_scale:new o.aL(m,i.u_extrude_scale),u_overscale_factor:new o.aH(m,i.u_overscale_factor)}),collisionCircle:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_inv_matrix:new o.aI(m,i.u_inv_matrix),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_viewport_size:new o.aL(m,i.u_viewport_size)}),debug:(m,i)=>({u_color:new o.aM(m,i.u_color),u_matrix:new o.aI(m,i.u_matrix),u_overlay:new o.aG(m,i.u_overlay),u_overlay_scale:new o.aH(m,i.u_overlay_scale)}),clippingMask:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix)}),heatmap:(m,i)=>({u_extrude_scale:new o.aH(m,i.u_extrude_scale),u_intensity:new o.aH(m,i.u_intensity),u_matrix:new o.aI(m,i.u_matrix)}),heatmapTexture:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_world:new o.aL(m,i.u_world),u_image:new o.aG(m,i.u_image),u_color_ramp:new o.aG(m,i.u_color_ramp),u_opacity:new o.aH(m,i.u_opacity)}),hillshade:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_image:new o.aG(m,i.u_image),u_latrange:new o.aL(m,i.u_latrange),u_light:new o.aL(m,i.u_light),u_shadow:new o.aM(m,i.u_shadow),u_highlight:new o.aM(m,i.u_highlight),u_accent:new o.aM(m,i.u_accent)}),hillshadePrepare:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_image:new o.aG(m,i.u_image),u_dimension:new o.aL(m,i.u_dimension),u_zoom:new o.aH(m,i.u_zoom),u_unpack:new o.aJ(m,i.u_unpack)}),line:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels)}),lineGradient:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels),u_image:new o.aG(m,i.u_image),u_image_height:new o.aH(m,i.u_image_height)}),linePattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_texsize:new o.aL(m,i.u_texsize),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_image:new o.aG(m,i.u_image),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels),u_scale:new o.aK(m,i.u_scale),u_fade:new o.aH(m,i.u_fade)}),lineSDF:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ratio:new o.aH(m,i.u_ratio),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_units_to_pixels:new o.aL(m,i.u_units_to_pixels),u_patternscale_a:new o.aL(m,i.u_patternscale_a),u_patternscale_b:new o.aL(m,i.u_patternscale_b),u_sdfgamma:new o.aH(m,i.u_sdfgamma),u_image:new o.aG(m,i.u_image),u_tex_y_a:new o.aH(m,i.u_tex_y_a),u_tex_y_b:new o.aH(m,i.u_tex_y_b),u_mix:new o.aH(m,i.u_mix)}),raster:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_tl_parent:new o.aL(m,i.u_tl_parent),u_scale_parent:new o.aH(m,i.u_scale_parent),u_buffer_scale:new o.aH(m,i.u_buffer_scale),u_fade_t:new o.aH(m,i.u_fade_t),u_opacity:new o.aH(m,i.u_opacity),u_image0:new o.aG(m,i.u_image0),u_image1:new o.aG(m,i.u_image1),u_brightness_low:new o.aH(m,i.u_brightness_low),u_brightness_high:new o.aH(m,i.u_brightness_high),u_saturation_factor:new o.aH(m,i.u_saturation_factor),u_contrast_factor:new o.aH(m,i.u_contrast_factor),u_spin_weights:new o.aK(m,i.u_spin_weights)}),symbolIcon:(m,i)=>({u_is_size_zoom_constant:new o.aG(m,i.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(m,i.u_is_size_feature_constant),u_size_t:new o.aH(m,i.u_size_t),u_size:new o.aH(m,i.u_size),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pitch:new o.aH(m,i.u_pitch),u_rotate_symbol:new o.aG(m,i.u_rotate_symbol),u_aspect_ratio:new o.aH(m,i.u_aspect_ratio),u_fade_change:new o.aH(m,i.u_fade_change),u_matrix:new o.aI(m,i.u_matrix),u_label_plane_matrix:new o.aI(m,i.u_label_plane_matrix),u_coord_matrix:new o.aI(m,i.u_coord_matrix),u_is_text:new o.aG(m,i.u_is_text),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_texsize:new o.aL(m,i.u_texsize),u_texture:new o.aG(m,i.u_texture)}),symbolSDF:(m,i)=>({u_is_size_zoom_constant:new o.aG(m,i.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(m,i.u_is_size_feature_constant),u_size_t:new o.aH(m,i.u_size_t),u_size:new o.aH(m,i.u_size),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pitch:new o.aH(m,i.u_pitch),u_rotate_symbol:new o.aG(m,i.u_rotate_symbol),u_aspect_ratio:new o.aH(m,i.u_aspect_ratio),u_fade_change:new o.aH(m,i.u_fade_change),u_matrix:new o.aI(m,i.u_matrix),u_label_plane_matrix:new o.aI(m,i.u_label_plane_matrix),u_coord_matrix:new o.aI(m,i.u_coord_matrix),u_is_text:new o.aG(m,i.u_is_text),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_texsize:new o.aL(m,i.u_texsize),u_texture:new o.aG(m,i.u_texture),u_gamma_scale:new o.aH(m,i.u_gamma_scale),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_is_halo:new o.aG(m,i.u_is_halo)}),symbolTextAndIcon:(m,i)=>({u_is_size_zoom_constant:new o.aG(m,i.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aG(m,i.u_is_size_feature_constant),u_size_t:new o.aH(m,i.u_size_t),u_size:new o.aH(m,i.u_size),u_camera_to_center_distance:new o.aH(m,i.u_camera_to_center_distance),u_pitch:new o.aH(m,i.u_pitch),u_rotate_symbol:new o.aG(m,i.u_rotate_symbol),u_aspect_ratio:new o.aH(m,i.u_aspect_ratio),u_fade_change:new o.aH(m,i.u_fade_change),u_matrix:new o.aI(m,i.u_matrix),u_label_plane_matrix:new o.aI(m,i.u_label_plane_matrix),u_coord_matrix:new o.aI(m,i.u_coord_matrix),u_is_text:new o.aG(m,i.u_is_text),u_pitch_with_map:new o.aG(m,i.u_pitch_with_map),u_texsize:new o.aL(m,i.u_texsize),u_texsize_icon:new o.aL(m,i.u_texsize_icon),u_texture:new o.aG(m,i.u_texture),u_texture_icon:new o.aG(m,i.u_texture_icon),u_gamma_scale:new o.aH(m,i.u_gamma_scale),u_device_pixel_ratio:new o.aH(m,i.u_device_pixel_ratio),u_is_halo:new o.aG(m,i.u_is_halo)}),background:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_opacity:new o.aH(m,i.u_opacity),u_color:new o.aM(m,i.u_color)}),backgroundPattern:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_opacity:new o.aH(m,i.u_opacity),u_image:new o.aG(m,i.u_image),u_pattern_tl_a:new o.aL(m,i.u_pattern_tl_a),u_pattern_br_a:new o.aL(m,i.u_pattern_br_a),u_pattern_tl_b:new o.aL(m,i.u_pattern_tl_b),u_pattern_br_b:new o.aL(m,i.u_pattern_br_b),u_texsize:new o.aL(m,i.u_texsize),u_mix:new o.aH(m,i.u_mix),u_pattern_size_a:new o.aL(m,i.u_pattern_size_a),u_pattern_size_b:new o.aL(m,i.u_pattern_size_b),u_scale_a:new o.aH(m,i.u_scale_a),u_scale_b:new o.aH(m,i.u_scale_b),u_pixel_coord_upper:new o.aL(m,i.u_pixel_coord_upper),u_pixel_coord_lower:new o.aL(m,i.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aH(m,i.u_tile_units_to_pixels)}),terrain:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_texture:new o.aG(m,i.u_texture),u_ele_delta:new o.aH(m,i.u_ele_delta)}),terrainDepth:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_ele_delta:new o.aH(m,i.u_ele_delta)}),terrainCoords:(m,i)=>({u_matrix:new o.aI(m,i.u_matrix),u_texture:new o.aG(m,i.u_texture),u_terrain_coords_id:new o.aH(m,i.u_terrain_coords_id),u_ele_delta:new o.aH(m,i.u_ele_delta)})};class zp{constructor(i,c,d){this.context=i;let f=i.gl;this.buffer=f.createBuffer(),this.dynamicDraw=!!d,this.context.unbindVAO(),i.bindElementBuffer.set(this.buffer),f.bufferData(f.ELEMENT_ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?f.DYNAMIC_DRAW:f.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(i){let c=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),c.bufferSubData(c.ELEMENT_ARRAY_BUFFER,0,i.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let Ks={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class dl{constructor(i,c,d,f){this.length=c.length,this.attributes=d,this.itemSize=c.bytesPerElement,this.dynamicDraw=f,this.context=i;let y=i.gl;this.buffer=y.createBuffer(),i.bindVertexBuffer.set(this.buffer),y.bufferData(y.ARRAY_BUFFER,c.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||delete c.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(i){if(i.length!==this.length)throw new Error(`Length of new data is ${i.length}, which doesn't match current length of ${this.length}`);let c=this.context.gl;this.bind(),c.bufferSubData(c.ARRAY_BUFFER,0,i.arrayBuffer)}enableAttributes(i,c){for(let d=0;d<this.attributes.length;d++){let f=c.attributes[this.attributes[d].name];f!==void 0&&i.enableVertexAttribArray(f)}}setVertexAttribPointers(i,c,d){for(let f=0;f<this.attributes.length;f++){let y=this.attributes[f],C=c.attributes[y.name];C!==void 0&&i.vertexAttribPointer(C,y.components,i[Ks[y.type]],!1,this.itemSize,y.offset+this.itemSize*(d||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let Sr=new WeakMap;function cr(m){var i;if(Sr.has(m))return Sr.get(m);{let c=(i=m.getParameter(m.VERSION))===null||i===void 0?void 0:i.startsWith("WebGL 2.0");return Sr.set(m,c),c}}class jt{constructor(i){this.gl=i.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(i){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class pl extends jt{getDefault(){return o.aO.transparent}set(i){let c=this.current;(i.r!==c.r||i.g!==c.g||i.b!==c.b||i.a!==c.a||this.dirty)&&(this.gl.clearColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class fl extends jt{getDefault(){return 1}set(i){(i!==this.current||this.dirty)&&(this.gl.clearDepth(i),this.current=i,this.dirty=!1)}}class bc extends jt{getDefault(){return 0}set(i){(i!==this.current||this.dirty)&&(this.gl.clearStencil(i),this.current=i,this.dirty=!1)}}class wc extends jt{getDefault(){return[!0,!0,!0,!0]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||i[2]!==c[2]||i[3]!==c[3]||this.dirty)&&(this.gl.colorMask(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class ml extends jt{getDefault(){return!0}set(i){(i!==this.current||this.dirty)&&(this.gl.depthMask(i),this.current=i,this.dirty=!1)}}class Sc extends jt{getDefault(){return 255}set(i){(i!==this.current||this.dirty)&&(this.gl.stencilMask(i),this.current=i,this.dirty=!1)}}class Cc extends jt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(i){let c=this.current;(i.func!==c.func||i.ref!==c.ref||i.mask!==c.mask||this.dirty)&&(this.gl.stencilFunc(i.func,i.ref,i.mask),this.current=i,this.dirty=!1)}}class gl extends jt{getDefault(){let i=this.gl;return[i.KEEP,i.KEEP,i.KEEP]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||i[2]!==c[2]||this.dirty)&&(this.gl.stencilOp(i[0],i[1],i[2]),this.current=i,this.dirty=!1)}}class Mu extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.STENCIL_TEST):c.disable(c.STENCIL_TEST),this.current=i,this.dirty=!1}}class Au extends jt{getDefault(){return[0,1]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||this.dirty)&&(this.gl.depthRange(i[0],i[1]),this.current=i,this.dirty=!1)}}class Lo extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST),this.current=i,this.dirty=!1}}class Op extends jt{getDefault(){return this.gl.LESS}set(i){(i!==this.current||this.dirty)&&(this.gl.depthFunc(i),this.current=i,this.dirty=!1)}}class Bp extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.BLEND):c.disable(c.BLEND),this.current=i,this.dirty=!1}}class Np extends jt{getDefault(){let i=this.gl;return[i.ONE,i.ZERO]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||this.dirty)&&(this.gl.blendFunc(i[0],i[1]),this.current=i,this.dirty=!1)}}class Vp extends jt{getDefault(){return o.aO.transparent}set(i){let c=this.current;(i.r!==c.r||i.g!==c.g||i.b!==c.b||i.a!==c.a||this.dirty)&&(this.gl.blendColor(i.r,i.g,i.b,i.a),this.current=i,this.dirty=!1)}}class Gp extends jt{getDefault(){return this.gl.FUNC_ADD}set(i){(i!==this.current||this.dirty)&&(this.gl.blendEquation(i),this.current=i,this.dirty=!1)}}class jp extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;i?c.enable(c.CULL_FACE):c.disable(c.CULL_FACE),this.current=i,this.dirty=!1}}class Ic extends jt{getDefault(){return this.gl.BACK}set(i){(i!==this.current||this.dirty)&&(this.gl.cullFace(i),this.current=i,this.dirty=!1)}}class yl extends jt{getDefault(){return this.gl.CCW}set(i){(i!==this.current||this.dirty)&&(this.gl.frontFace(i),this.current=i,this.dirty=!1)}}class Ec extends jt{getDefault(){return null}set(i){(i!==this.current||this.dirty)&&(this.gl.useProgram(i),this.current=i,this.dirty=!1)}}class Tc extends jt{getDefault(){return this.gl.TEXTURE0}set(i){(i!==this.current||this.dirty)&&(this.gl.activeTexture(i),this.current=i,this.dirty=!1)}}class Do extends jt{getDefault(){let i=this.gl;return[0,0,i.drawingBufferWidth,i.drawingBufferHeight]}set(i){let c=this.current;(i[0]!==c[0]||i[1]!==c[1]||i[2]!==c[2]||i[3]!==c[3]||this.dirty)&&(this.gl.viewport(i[0],i[1],i[2],i[3]),this.current=i,this.dirty=!1)}}class Pu extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindFramebuffer(c.FRAMEBUFFER,i),this.current=i,this.dirty=!1}}class Ru extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindRenderbuffer(c.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class Mc extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindTexture(c.TEXTURE_2D,i),this.current=i,this.dirty=!1}}class Js extends jt{getDefault(){return null}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.bindBuffer(c.ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class ku extends jt{getDefault(){return null}set(i){let c=this.gl;c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i),this.current=i,this.dirty=!1}}class Fo extends jt{getDefault(){return null}set(i){var c;if(i===this.current&&!this.dirty)return;let d=this.gl;cr(d)?d.bindVertexArray(i):(c=d.getExtension("OES_vertex_array_object"))===null||c===void 0||c.bindVertexArrayOES(i),this.current=i,this.dirty=!1}}class zo extends jt{getDefault(){return 4}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.pixelStorei(c.UNPACK_ALIGNMENT,i),this.current=i,this.dirty=!1}}class Lu extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i),this.current=i,this.dirty=!1}}class Ac extends jt{getDefault(){return!1}set(i){if(i===this.current&&!this.dirty)return;let c=this.gl;c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,i),this.current=i,this.dirty=!1}}class Vt extends jt{constructor(i,c){super(i),this.context=i,this.parent=c}getDefault(){return null}}class _l extends Vt{setDirty(){this.dirty=!0}set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let c=this.gl;c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,i,0),this.current=i,this.dirty=!1}}class Up extends Vt{set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let c=this.gl;c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class Du extends Vt{set(i){if(i===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let c=this.gl;c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,i),this.current=i,this.dirty=!1}}class wa{constructor(i,c,d,f,y){this.context=i,this.width=c,this.height=d;let C=i.gl,E=this.framebuffer=C.createFramebuffer();if(this.colorAttachment=new _l(i,E),f)this.depthAttachment=y?new Du(i,E):new Up(i,E);else if(y)throw new Error("Stencil cannot be set without depth");if(C.checkFramebufferStatus(C.FRAMEBUFFER)!==C.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){let i=this.context.gl,c=this.colorAttachment.get();if(c&&i.deleteTexture(c),this.depthAttachment){let d=this.depthAttachment.get();d&&i.deleteRenderbuffer(d)}i.deleteFramebuffer(this.framebuffer)}}class vi{constructor(i,c,d){this.blendFunction=i,this.blendColor=c,this.mask=d}}vi.Replace=[1,0],vi.disabled=new vi(vi.Replace,o.aO.transparent,[!1,!1,!1,!1]),vi.unblended=new vi(vi.Replace,o.aO.transparent,[!0,!0,!0,!0]),vi.alphaBlended=new vi([1,771],o.aO.transparent,[!0,!0,!0,!0]);class $p{constructor(i){var c,d;if(this.gl=i,this.clearColor=new pl(this),this.clearDepth=new fl(this),this.clearStencil=new bc(this),this.colorMask=new wc(this),this.depthMask=new ml(this),this.stencilMask=new Sc(this),this.stencilFunc=new Cc(this),this.stencilOp=new gl(this),this.stencilTest=new Mu(this),this.depthRange=new Au(this),this.depthTest=new Lo(this),this.depthFunc=new Op(this),this.blend=new Bp(this),this.blendFunc=new Np(this),this.blendColor=new Vp(this),this.blendEquation=new Gp(this),this.cullFace=new jp(this),this.cullFaceSide=new Ic(this),this.frontFace=new yl(this),this.program=new Ec(this),this.activeTexture=new Tc(this),this.viewport=new Do(this),this.bindFramebuffer=new Pu(this),this.bindRenderbuffer=new Ru(this),this.bindTexture=new Mc(this),this.bindVertexBuffer=new Js(this),this.bindElementBuffer=new ku(this),this.bindVertexArray=new Fo(this),this.pixelStoreUnpack=new zo(this),this.pixelStoreUnpackPremultiplyAlpha=new Lu(this),this.pixelStoreUnpackFlipY=new Ac(this),this.extTextureFilterAnisotropic=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=i.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=i.getParameter(i.MAX_TEXTURE_SIZE),cr(i)){this.HALF_FLOAT=i.HALF_FLOAT;let f=i.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(c=i.RGBA16F)!==null&&c!==void 0?c:f?.RGBA16F_EXT,this.RGB16F=(d=i.RGB16F)!==null&&d!==void 0?d:f?.RGB16F_EXT,i.getExtension("EXT_color_buffer_float")}else{i.getExtension("EXT_color_buffer_half_float"),i.getExtension("OES_texture_half_float_linear");let f=i.getExtension("OES_texture_half_float");this.HALF_FLOAT=f?.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(i,c){return new zp(this,i,c)}createVertexBuffer(i,c,d){return new dl(this,i,c,d)}createRenderbuffer(i,c,d){let f=this.gl,y=f.createRenderbuffer();return this.bindRenderbuffer.set(y),f.renderbufferStorage(f.RENDERBUFFER,i,c,d),this.bindRenderbuffer.set(null),y}createFramebuffer(i,c,d,f){return new wa(this,i,c,d,f)}clear({color:i,depth:c,stencil:d}){let f=this.gl,y=0;i&&(y|=f.COLOR_BUFFER_BIT,this.clearColor.set(i),this.colorMask.set([!0,!0,!0,!0])),c!==void 0&&(y|=f.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(c),this.depthMask.set(!0)),d!==void 0&&(y|=f.STENCIL_BUFFER_BIT,this.clearStencil.set(d),this.stencilMask.set(255)),f.clear(y)}setCullFace(i){i.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(i.mode),this.frontFace.set(i.frontFace))}setDepthMode(i){i.func!==this.gl.ALWAYS||i.mask?(this.depthTest.set(!0),this.depthFunc.set(i.func),this.depthMask.set(i.mask),this.depthRange.set(i.range)):this.depthTest.set(!1)}setStencilMode(i){i.test.func!==this.gl.ALWAYS||i.mask?(this.stencilTest.set(!0),this.stencilMask.set(i.mask),this.stencilOp.set([i.fail,i.depthFail,i.pass]),this.stencilFunc.set({func:i.test.func,ref:i.ref,mask:i.test.mask})):this.stencilTest.set(!1)}setColorMode(i){o.aD(i.blendFunction,vi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(i.blendFunction),this.blendColor.set(i.blendColor)),this.colorMask.set(i.mask)}createVertexArray(){var i;return cr(this.gl)?this.gl.createVertexArray():(i=this.gl.getExtension("OES_vertex_array_object"))===null||i===void 0?void 0:i.createVertexArrayOES()}deleteVertexArray(i){var c;return cr(this.gl)?this.gl.deleteVertexArray(i):(c=this.gl.getExtension("OES_vertex_array_object"))===null||c===void 0?void 0:c.deleteVertexArrayOES(i)}unbindVAO(){this.bindVertexArray.set(null)}}class Ot{constructor(i,c,d){this.func=i,this.mask=c,this.range=d}}Ot.ReadOnly=!1,Ot.ReadWrite=!0,Ot.disabled=new Ot(519,Ot.ReadOnly,[0,1]);let Pc=7680;class Jt{constructor(i,c,d,f,y,C){this.test=i,this.ref=c,this.mask=d,this.fail=f,this.depthFail=y,this.pass=C}}Jt.disabled=new Jt({func:519,mask:0},0,0,Pc,Pc,Pc);class Kt{constructor(i,c,d){this.enable=i,this.mode=c,this.frontFace=d}}let Qs;function xl(m,i,c,d,f,y,C){let E=m.context,M=E.gl,P=m.useProgram("collisionBox"),D=[],z=0,G=0;for(let ie=0;ie<d.length;ie++){let pe=d[ie],we=i.getTile(pe),be=we.getBucket(c);if(!be)continue;let Ae=pe.posMatrix;f[0]===0&&f[1]===0||(Ae=m.translatePosMatrix(pe.posMatrix,we,f,y));let De=C?be.textCollisionBox:be.iconCollisionBox,Le=be.collisionCircleArray;if(Le.length>0){let Be=o.F(),et=Ae;o.aP(Be,be.placementInvProjMatrix,m.transform.glCoordMatrix),o.aP(Be,Be,be.placementViewportMatrix),D.push({circleArray:Le,circleOffset:G,transform:et,invTransform:Be,coord:pe}),z+=Le.length/4,G=z}De&&P.draw(E,M.LINES,Ot.disabled,Jt.disabled,m.colorModeForRenderPass(),Kt.disabled,wu(Ae,m.transform,we),m.style.map.terrain&&m.style.map.terrain.getTerrainData(pe),c.id,De.layoutVertexBuffer,De.indexBuffer,De.segments,null,m.transform.zoom,null,null,De.collisionVertexBuffer)}if(!C||!D.length)return;let Y=m.useProgram("collisionCircle"),K=new o.aQ;K.resize(4*z),K._trim();let te=0;for(let ie of D)for(let pe=0;pe<ie.circleArray.length/4;pe++){let we=4*pe,be=ie.circleArray[we+0],Ae=ie.circleArray[we+1],De=ie.circleArray[we+2],Le=ie.circleArray[we+3];K.emplace(te++,be,Ae,De,Le,0),K.emplace(te++,be,Ae,De,Le,1),K.emplace(te++,be,Ae,De,Le,2),K.emplace(te++,be,Ae,De,Le,3)}(!Qs||Qs.length<2*z)&&(Qs=function(ie){let pe=2*ie,we=new o.aS;we.resize(pe),we._trim();for(let be=0;be<pe;be++){let Ae=6*be;we.uint16[Ae+0]=4*be+0,we.uint16[Ae+1]=4*be+1,we.uint16[Ae+2]=4*be+2,we.uint16[Ae+3]=4*be+2,we.uint16[Ae+4]=4*be+3,we.uint16[Ae+5]=4*be+0}return we}(z));let X=E.createIndexBuffer(Qs,!0),le=E.createVertexBuffer(K,o.aR.members,!0);for(let ie of D){let pe={u_matrix:ie.transform,u_inv_matrix:ie.invTransform,u_camera_to_center_distance:(xe=m.transform).cameraToCenterDistance,u_viewport_size:[xe.width,xe.height]};Y.draw(E,M.TRIANGLES,Ot.disabled,Jt.disabled,m.colorModeForRenderPass(),Kt.disabled,pe,m.style.map.terrain&&m.style.map.terrain.getTerrainData(ie.coord),c.id,le,X,o.$.simpleSegment(0,2*ie.circleOffset,ie.circleArray.length,ie.circleArray.length/2),null,m.transform.zoom,null,null,null)}var xe;le.destroy(),X.destroy()}Kt.disabled=new Kt(!1,1029,2305),Kt.backCCW=new Kt(!0,1029,2305);let Rc=o.an(new Float32Array(16));function Fu(m,i,c,d,f,y){let{horizontalAlign:C,verticalAlign:E}=o.at(m);return new o.P((-(C-.5)*i/f+d[0])*y,(-(E-.5)*c/f+d[1])*y)}function vl(m,i,c,d,f,y,C,E,M,P,D){let z=m.text.placedSymbolArray,G=m.text.dynamicLayoutVertexArray,Y=m.icon.dynamicLayoutVertexArray,K={};G.clear();for(let te=0;te<z.length;te++){let X=z.get(te),le=X.hidden||!X.crossTileID||m.allowVerticalPlacement&&!X.placedOrientation?null:d[X.crossTileID];if(le){let xe=new o.P(X.anchorX,X.anchorY),ie=yi(xe,c?C:y,D),pe=Q(f.cameraToCenterDistance,ie.signedDistanceFromCamera),we=o.ai(m.textSizeData,M,X)*pe/o.ao;c&&(we*=m.tilePixelRatio/E);let{width:be,height:Ae,anchor:De,textOffset:Le,textBoxScale:Be}=le,et=Fu(De,be,Ae,Le,Be,we),ht=c?yi(xe.add(et),y,D).point:ie.point.add(i?et.rotate(-f.angle):et),$e=m.allowVerticalPlacement&&X.placedOrientation===o.ah.vertical?Math.PI/2:0;for(let ct=0;ct<X.numGlyphs;ct++)o.aj(G,ht,$e);P&&X.associatedIconIndex>=0&&(K[X.associatedIconIndex]={shiftedAnchor:ht,angle:$e})}else Ce(X.numGlyphs,G)}if(P){Y.clear();let te=m.icon.placedSymbolArray;for(let X=0;X<te.length;X++){let le=te.get(X);if(le.hidden)Ce(le.numGlyphs,Y);else{let xe=K[X];if(xe)for(let ie=0;ie<le.numGlyphs;ie++)o.aj(Y,xe.shiftedAnchor,xe.angle);else Ce(le.numGlyphs,Y)}}m.icon.dynamicLayoutVertexBuffer.updateData(Y)}m.text.dynamicLayoutVertexBuffer.updateData(G)}function bl(m,i,c){return c.iconsInText&&i?"symbolTextAndIcon":m?"symbolSDF":"symbolIcon"}function wl(m,i,c,d,f,y,C,E,M,P,D,z){let G=m.context,Y=G.gl,K=m.transform,te=E==="map",X=M==="map",le=E!=="viewport"&&c.layout.get("symbol-placement")!=="point",xe=te&&!X&&!le,ie=!c.layout.get("symbol-sort-key").isConstant(),pe=!1,we=m.depthModeForSublayer(0,Ot.ReadOnly),be=c._unevaluatedLayout.hasValue("text-variable-anchor")||c._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ae=[];for(let De of d){let Le=i.getTile(De),Be=Le.getBucket(c);if(!Be)continue;let et=f?Be.text:Be.icon;if(!et||!et.segments.get().length||!et.hasVisibleVertices)continue;let ht=et.programConfigurations.get(c.id),$e=f||Be.sdfIcons,ct=f?Be.textSizeData:Be.iconSizeData,nt=X||K.pitch!==0,ei=m.useProgram(bl($e,f,Be),ht),kt=o.ag(ct,K.zoom),It=m.style.map.terrain&&m.style.map.terrain.getTerrainData(De),Lt,wi,Zt,Er,Hi=[0,0],pi=null;if(f)wi=Le.glyphAtlasTexture,Zt=Y.LINEAR,Lt=Le.glyphAtlasTexture.size,Be.iconsInText&&(Hi=Le.imageAtlasTexture.size,pi=Le.imageAtlasTexture,Er=nt||m.options.rotating||m.options.zooming||ct.kind==="composite"||ct.kind==="camera"?Y.LINEAR:Y.NEAREST);else{let ti=c.layout.get("icon-size").constantOr(0)!==1||Be.iconsNeedLinear;wi=Le.imageAtlasTexture,Zt=$e||m.options.rotating||m.options.zooming||ti||nt?Y.LINEAR:Y.NEAREST,Lt=Le.imageAtlasTexture.size}let hr=_t(Le,1,m.transform.zoom),ur=vt(De.posMatrix,X,te,m.transform,hr),_n=On(De.posMatrix,X,te,m.transform,hr),Ps=be&&Be.hasTextData(),jo=c.layout.get("icon-text-fit")!=="none"&&Ps&&Be.hasIconData();if(le){let ti=m.style.map.terrain?(Yi,Oi)=>m.style.map.terrain.getElevation(De,Yi,Oi):null,zi=c.layout.get("text-rotation-alignment")==="map";N(Be,De.posMatrix,m,f,ur,_n,X,P,zi,ti)}let Uo=m.translatePosMatrix(De.posMatrix,Le,y,C),Rs=le||f&&be||jo?Rc:ur,Fi=m.translatePosMatrix(_n,Le,y,C,!0),Si=$e&&c.paint.get(f?"text-halo-width":"icon-halo-width").constantOr(1)!==0,fi;fi=$e?Be.iconsInText?ba(ct.kind,kt,xe,X,m,Uo,Rs,Fi,Lt,Hi):va(ct.kind,kt,xe,X,m,Uo,Rs,Fi,f,Lt,!0):xa(ct.kind,kt,xe,X,m,Uo,Rs,Fi,f,Lt);let Tr={program:ei,buffers:et,uniformValues:fi,atlasTexture:wi,atlasTextureIcon:pi,atlasInterpolation:Zt,atlasInterpolationIcon:Er,isSDF:$e,hasHalo:Si};if(ie&&Be.canOverlap){pe=!0;let ti=et.segments.get();for(let zi of ti)Ae.push({segments:new o.$([zi]),sortKey:zi.sortKey,state:Tr,terrainData:It})}else Ae.push({segments:et.segments,sortKey:0,state:Tr,terrainData:It})}pe&&Ae.sort((De,Le)=>De.sortKey-Le.sortKey);for(let De of Ae){let Le=De.state;if(G.activeTexture.set(Y.TEXTURE0),Le.atlasTexture.bind(Le.atlasInterpolation,Y.CLAMP_TO_EDGE),Le.atlasTextureIcon&&(G.activeTexture.set(Y.TEXTURE1),Le.atlasTextureIcon&&Le.atlasTextureIcon.bind(Le.atlasInterpolationIcon,Y.CLAMP_TO_EDGE)),Le.isSDF){let Be=Le.uniformValues;Le.hasHalo&&(Be.u_is_halo=1,zu(Le.buffers,De.segments,c,m,Le.program,we,D,z,Be,De.terrainData)),Be.u_is_halo=0}zu(Le.buffers,De.segments,c,m,Le.program,we,D,z,Le.uniformValues,De.terrainData)}}function zu(m,i,c,d,f,y,C,E,M,P){let D=d.context;f.draw(D,D.gl.TRIANGLES,y,C,E,Kt.disabled,M,P,c.id,m.layoutVertexBuffer,m.indexBuffer,i,c.paint,d.transform.zoom,m.programConfigurations.get(c.id),m.dynamicLayoutVertexBuffer,m.opacityVertexBuffer)}function Sl(m,i,c,d,f){if(!c||!d||!d.imageAtlas)return;let y=d.imageAtlas.patternPositions,C=y[c.to.toString()],E=y[c.from.toString()];if(!C&&E&&(C=E),!E&&C&&(E=C),!C||!E){let M=f.getPaintProperty(i);C=y[M],E=y[M]}C&&E&&m.setConstantPatternPositions(C,E)}function Ou(m,i,c,d,f,y,C){let E=m.context.gl,M="fill-pattern",P=c.paint.get(M),D=P&&P.constantOr(1),z=c.getCrossfadeParameters(),G,Y,K,te,X;C?(Y=D&&!c.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",G=E.LINES):(Y=D?"fillPattern":"fill",G=E.TRIANGLES);let le=P.constantOr(null);for(let xe of d){let ie=i.getTile(xe);if(D&&!ie.patternsLoaded())continue;let pe=ie.getBucket(c);if(!pe)continue;let we=pe.programConfigurations.get(c.id),be=m.useProgram(Y,we),Ae=m.style.map.terrain&&m.style.map.terrain.getTerrainData(xe);D&&(m.context.activeTexture.set(E.TEXTURE0),ie.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),we.updatePaintBuffers(z)),Sl(we,M,le,ie,c);let De=Ae?xe:null,Le=m.translatePosMatrix(De?De.posMatrix:xe.posMatrix,ie,c.paint.get("fill-translate"),c.paint.get("fill-translate-anchor"));if(C){te=pe.indexBuffer2,X=pe.segments2;let Be=[E.drawingBufferWidth,E.drawingBufferHeight];K=Y==="fillOutlinePattern"&&D?bu(Le,m,z,ie,Be):kp(Le,Be)}else te=pe.indexBuffer,X=pe.segments,K=D?al(Le,m,z,ie):vu(Le);be.draw(m.context,G,f,m.stencilModeForClipping(xe),y,Kt.disabled,K,Ae,c.id,pe.layoutVertexBuffer,te,X,c.paint,m.transform.zoom,we)}}function Cl(m,i,c,d,f,y,C){let E=m.context,M=E.gl,P="fill-extrusion-pattern",D=c.paint.get(P),z=D.constantOr(1),G=c.getCrossfadeParameters(),Y=c.paint.get("fill-extrusion-opacity"),K=D.constantOr(null);for(let te of d){let X=i.getTile(te),le=X.getBucket(c);if(!le)continue;let xe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(te),ie=le.programConfigurations.get(c.id),pe=m.useProgram(z?"fillExtrusionPattern":"fillExtrusion",ie);z&&(m.context.activeTexture.set(M.TEXTURE0),X.imageAtlasTexture.bind(M.LINEAR,M.CLAMP_TO_EDGE),ie.updatePaintBuffers(G)),Sl(ie,P,K,X,c);let we=m.translatePosMatrix(te.posMatrix,X,c.paint.get("fill-extrusion-translate"),c.paint.get("fill-extrusion-translate-anchor")),be=c.paint.get("fill-extrusion-vertical-gradient"),Ae=z?Rp(we,m,be,Y,te,G,X):ga(we,m,be,Y);pe.draw(E,E.gl.TRIANGLES,f,y,C,Kt.backCCW,Ae,xe,c.id,le.layoutVertexBuffer,le.indexBuffer,le.segments,c.paint,m.transform.zoom,ie,m.style.map.terrain&&le.centroidVertexBuffer)}}function Il(m,i,c,d,f,y,C){let E=m.context,M=E.gl,P=c.fbo;if(!P)return;let D=m.useProgram("hillshade"),z=m.style.map.terrain&&m.style.map.terrain.getTerrainData(i);E.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,P.colorAttachment.get()),D.draw(E,M.TRIANGLES,f,y,C,Kt.disabled,((G,Y,K,te)=>{let X=K.paint.get("hillshade-shadow-color"),le=K.paint.get("hillshade-highlight-color"),xe=K.paint.get("hillshade-accent-color"),ie=K.paint.get("hillshade-illumination-direction")*(Math.PI/180);K.paint.get("hillshade-illumination-anchor")==="viewport"&&(ie-=G.transform.angle);let pe=!G.options.moving;return{u_matrix:te?te.posMatrix:G.transform.calculatePosMatrix(Y.tileID.toUnwrapped(),pe),u_image:0,u_latrange:Iu(0,Y.tileID),u_light:[K.paint.get("hillshade-exaggeration"),ie],u_shadow:X,u_highlight:le,u_accent:xe}})(m,c,d,z?i:null),z,d.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments)}function kc(m,i,c,d,f,y){let C=m.context,E=C.gl,M=i.dem;if(M&&M.data){let P=M.dim,D=M.stride,z=M.getPixels();if(C.activeTexture.set(E.TEXTURE1),C.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||m.getTileTexture(D),i.demTexture){let Y=i.demTexture;Y.update(z,{premultiply:!1}),Y.bind(E.NEAREST,E.CLAMP_TO_EDGE)}else i.demTexture=new Ye(C,z,E.RGBA,{premultiply:!1}),i.demTexture.bind(E.NEAREST,E.CLAMP_TO_EDGE);C.activeTexture.set(E.TEXTURE0);let G=i.fbo;if(!G){let Y=new Ye(C,{width:P,height:P,data:null},E.RGBA);Y.bind(E.LINEAR,E.CLAMP_TO_EDGE),G=i.fbo=C.createFramebuffer(P,P,!0,!1),G.colorAttachment.set(Y.texture)}C.bindFramebuffer.set(G.framebuffer),C.viewport.set([0,0,P,P]),m.useProgram("hillshadePrepare").draw(C,E.TRIANGLES,d,f,y,Kt.disabled,((Y,K)=>{let te=K.stride,X=o.F();return o.aN(X,0,o.W,-o.W,0,0,1),o.H(X,X,[0,-o.W,0]),{u_matrix:X,u_image:1,u_dimension:[te,te],u_zoom:Y.overscaledZ,u_unpack:K.getUnpackVector()}})(i.tileID,M),null,c.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments),i.needsHillshadePrepare=!1}}function Bu(m,i,c,d,f,y){let C=d.paint.get("raster-fade-duration");if(!y&&C>0){let E=T.now(),M=(E-m.timeAdded)/C,P=i?(E-i.timeAdded)/C:-1,D=c.getSource(),z=f.coveringZoomLevel({tileSize:D.tileSize,roundZoom:D.roundZoom}),G=!i||Math.abs(i.tileID.overscaledZ-z)>Math.abs(m.tileID.overscaledZ-z),Y=G&&m.refreshedUponExpiration?1:o.ac(G?M:1-P,0,1);return m.refreshedUponExpiration&&M>=1&&(m.refreshedUponExpiration=!1),i?{opacity:1,mix:1-Y}:{opacity:Y,mix:0}}return{opacity:1,mix:0}}let Nu=new o.aO(1,0,0,1),El=new o.aO(0,1,0,1),Lc=new o.aO(0,0,1,1),qp=new o.aO(1,0,1,1),Vu=new o.aO(0,1,1,1);function ui(m,i,c,d){Cr(m,0,i+c/2,m.transform.width,c,d)}function Ts(m,i,c,d){Cr(m,i-c/2,0,c,m.transform.height,d)}function Cr(m,i,c,d,f,y){let C=m.context,E=C.gl;E.enable(E.SCISSOR_TEST),E.scissor(i*m.pixelRatio,c*m.pixelRatio,d*m.pixelRatio,f*m.pixelRatio),C.clear({color:y}),E.disable(E.SCISSOR_TEST)}function Dc(m,i,c){let d=m.context,f=d.gl,y=c.posMatrix,C=m.useProgram("debug"),E=Ot.disabled,M=Jt.disabled,P=m.colorModeForRenderPass(),D="$debug",z=m.style.map.terrain&&m.style.map.terrain.getTerrainData(c);d.activeTexture.set(f.TEXTURE0);let G=i.getTileByID(c.key).latestRawTileData,Y=Math.floor((G&&G.byteLength||0)/1024),K=i.getTile(c).tileSize,te=512/Math.min(K,512)*(c.overscaledZ/m.transform.zoom)*.5,X=c.canonical.toString();c.overscaledZ!==c.canonical.z&&(X+=` => ${c.overscaledZ}`),function(le,xe){le.initDebugOverlayCanvas();let ie=le.debugOverlayCanvas,pe=le.context.gl,we=le.debugOverlayCanvas.getContext("2d");we.clearRect(0,0,ie.width,ie.height),we.shadowColor="white",we.shadowBlur=2,we.lineWidth=1.5,we.strokeStyle="white",we.textBaseline="top",we.font="bold 36px Open Sans, sans-serif",we.fillText(xe,5,5),we.strokeText(xe,5,5),le.debugOverlayTexture.update(ie),le.debugOverlayTexture.bind(pe.LINEAR,pe.CLAMP_TO_EDGE)}(m,`${X} ${Y}kB`),C.draw(d,f.TRIANGLES,E,M,vi.alphaBlended,Kt.disabled,Su(y,o.aO.transparent,te),null,D,m.debugBuffer,m.quadTriangleIndexBuffer,m.debugSegments),C.draw(d,f.LINE_STRIP,E,M,P,Kt.disabled,Su(y,o.aO.red),z,D,m.debugBuffer,m.tileBorderIndexBuffer,m.debugSegments)}function Tl(m,i,c){let d=m.context,f=d.gl,y=m.colorModeForRenderPass(),C=new Ot(f.LEQUAL,Ot.ReadWrite,m.depthRangeFor3D),E=m.useProgram("terrain"),M=i.getTerrainMesh();d.bindFramebuffer.set(null),d.viewport.set([0,0,m.width,m.height]);for(let P of c){let D=m.renderToTexture.getTexture(P),z=i.getTerrainData(P.tileID);d.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,D.texture);let G={u_matrix:m.transform.calculatePosMatrix(P.tileID.toUnwrapped()),u_texture:0,u_ele_delta:i.getMeshFrameDelta(m.transform.zoom)};E.draw(d,f.TRIANGLES,C,Jt.disabled,y,Kt.backCCW,G,z,"terrain",M.vertexBuffer,M.indexBuffer,M.segments)}}class Gu{constructor(i,c){this.context=new $p(i),this.transform=c,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.F(),renderTime:0},this.setup(),this.numSublayers=Li.maxUnderzooming+Li.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Is}resize(i,c,d){if(this.width=Math.floor(i*d),this.height=Math.floor(c*d),this.pixelRatio=d,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let f of this.style._order)this.style._layers[f].resize()}setup(){let i=this.context,c=new o.aV;c.emplaceBack(0,0),c.emplaceBack(o.W,0),c.emplaceBack(0,o.W),c.emplaceBack(o.W,o.W),this.tileExtentBuffer=i.createVertexBuffer(c,nl.members),this.tileExtentSegments=o.$.simpleSegment(0,0,4,2);let d=new o.aV;d.emplaceBack(0,0),d.emplaceBack(o.W,0),d.emplaceBack(0,o.W),d.emplaceBack(o.W,o.W),this.debugBuffer=i.createVertexBuffer(d,nl.members),this.debugSegments=o.$.simpleSegment(0,0,4,5);let f=new o.Z;f.emplaceBack(0,0,0,0),f.emplaceBack(o.W,0,o.W,0),f.emplaceBack(0,o.W,0,o.W),f.emplaceBack(o.W,o.W,o.W,o.W),this.rasterBoundsBuffer=i.createVertexBuffer(f,ci.members),this.rasterBoundsSegments=o.$.simpleSegment(0,0,4,2);let y=new o.aV;y.emplaceBack(0,0),y.emplaceBack(1,0),y.emplaceBack(0,1),y.emplaceBack(1,1),this.viewportBuffer=i.createVertexBuffer(y,nl.members),this.viewportSegments=o.$.simpleSegment(0,0,4,2);let C=new o.aW;C.emplaceBack(0),C.emplaceBack(1),C.emplaceBack(3),C.emplaceBack(2),C.emplaceBack(0),this.tileBorderIndexBuffer=i.createIndexBuffer(C);let E=new o.aX;E.emplaceBack(0,1,2),E.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=i.createIndexBuffer(E);let M=this.context.gl;this.stencilClearMode=new Jt({func:M.ALWAYS,mask:0},0,255,M.ZERO,M.ZERO,M.ZERO)}clearStencil(){let i=this.context,c=i.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let d=o.F();o.aN(d,0,this.width,this.height,0,0,1),o.J(d,d,[c.drawingBufferWidth,c.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(i,c.TRIANGLES,Ot.disabled,this.stencilClearMode,vi.disabled,Kt.disabled,ll(d),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(i,c){if(this.currentStencilSource===i.source||!i.isTileClipped()||!c||!c.length)return;this.currentStencilSource=i.source;let d=this.context,f=d.gl;this.nextStencilID+c.length>256&&this.clearStencil(),d.setColorMode(vi.disabled),d.setDepthMode(Ot.disabled);let y=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let C of c){let E=this._tileClippingMaskIDs[C.key]=this.nextStencilID++,M=this.style.map.terrain&&this.style.map.terrain.getTerrainData(C);y.draw(d,f.TRIANGLES,Ot.disabled,new Jt({func:f.ALWAYS,mask:0},E,255,f.KEEP,f.KEEP,f.REPLACE),vi.disabled,Kt.disabled,ll(C.posMatrix),M,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let i=this.nextStencilID++,c=this.context.gl;return new Jt({func:c.NOTEQUAL,mask:255},i,255,c.KEEP,c.KEEP,c.REPLACE)}stencilModeForClipping(i){let c=this.context.gl;return new Jt({func:c.EQUAL,mask:255},this._tileClippingMaskIDs[i.key],0,c.KEEP,c.KEEP,c.REPLACE)}stencilConfigForOverlap(i){let c=this.context.gl,d=i.sort((C,E)=>E.overscaledZ-C.overscaledZ),f=d[d.length-1].overscaledZ,y=d[0].overscaledZ-f+1;if(y>1){this.currentStencilSource=void 0,this.nextStencilID+y>256&&this.clearStencil();let C={};for(let E=0;E<y;E++)C[E+f]=new Jt({func:c.GEQUAL,mask:255},E+this.nextStencilID,255,c.KEEP,c.KEEP,c.REPLACE);return this.nextStencilID+=y,[C,d]}return[{[f]:Jt.disabled},d]}colorModeForRenderPass(){let i=this.context.gl;return this._showOverdrawInspector?new vi([i.CONSTANT_COLOR,i.ONE],new o.aO(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?vi.unblended:vi.alphaBlended}depthModeForSublayer(i,c,d){if(!this.opaquePassEnabledForLayer())return Ot.disabled;let f=1-((1+this.currentLayer)*this.numSublayers+i)*this.depthEpsilon;return new Ot(d||this.context.gl.LEQUAL,c,[f,f])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(i,c){this.style=i,this.options=c,this.lineAtlas=i.lineAtlas,this.imageManager=i.imageManager,this.glyphManager=i.glyphManager,this.symbolFadeChange=i.placement.symbolFadeChange(T.now()),this.imageManager.beginFrame();let d=this.style._order,f=this.style.sourceCaches,y={},C={},E={};for(let M in f){let P=f[M];P.used&&P.prepare(this.context),y[M]=P.getVisibleCoordinates(),C[M]=y[M].slice().reverse(),E[M]=P.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let M=0;M<d.length;M++)if(this.style._layers[d[M]].is3D()){this.opaquePassCutoff=M;break}if(this.renderToTexture){this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0;let M=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime);(this.terrainFacilitator.dirty||!o.aY(this.terrainFacilitator.matrix,this.transform.projMatrix)||M.length)&&(o.aZ(this.terrainFacilitator.matrix,this.transform.projMatrix),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(P,D){let z=P.context,G=z.gl,Y=vi.unblended,K=new Ot(G.LEQUAL,Ot.ReadWrite,[0,1]),te=D.getTerrainMesh(),X=D.sourceCache.getRenderableTiles(),le=P.useProgram("terrainDepth");z.bindFramebuffer.set(D.getFramebuffer("depth").framebuffer),z.viewport.set([0,0,P.width/devicePixelRatio,P.height/devicePixelRatio]),z.clear({color:o.aO.transparent,depth:1});for(let xe of X){let ie=D.getTerrainData(xe.tileID),pe={u_matrix:P.transform.calculatePosMatrix(xe.tileID.toUnwrapped()),u_ele_delta:D.getMeshFrameDelta(P.transform.zoom)};le.draw(z,G.TRIANGLES,K,Jt.disabled,Y,Kt.backCCW,pe,ie,"terrain",te.vertexBuffer,te.indexBuffer,te.segments)}z.bindFramebuffer.set(null),z.viewport.set([0,0,P.width,P.height])}(this,this.style.map.terrain),function(P,D){let z=P.context,G=z.gl,Y=vi.unblended,K=new Ot(G.LEQUAL,Ot.ReadWrite,[0,1]),te=D.getTerrainMesh(),X=D.getCoordsTexture(),le=D.sourceCache.getRenderableTiles(),xe=P.useProgram("terrainCoords");z.bindFramebuffer.set(D.getFramebuffer("coords").framebuffer),z.viewport.set([0,0,P.width/devicePixelRatio,P.height/devicePixelRatio]),z.clear({color:o.aO.transparent,depth:1}),D.coordsIndex=[];for(let ie of le){let pe=D.getTerrainData(ie.tileID);z.activeTexture.set(G.TEXTURE0),G.bindTexture(G.TEXTURE_2D,X.texture);let we={u_matrix:P.transform.calculatePosMatrix(ie.tileID.toUnwrapped()),u_terrain_coords_id:(255-D.coordsIndex.length)/255,u_texture:0,u_ele_delta:D.getMeshFrameDelta(P.transform.zoom)};xe.draw(z,G.TRIANGLES,K,Jt.disabled,Y,Kt.backCCW,we,pe,"terrain",te.vertexBuffer,te.indexBuffer,te.segments),D.coordsIndex.push(ie.tileID.key)}z.bindFramebuffer.set(null),z.viewport.set([0,0,P.width,P.height])}(this,this.style.map.terrain))}this.renderPass="offscreen";for(let M of d){let P=this.style._layers[M];if(!P.hasOffscreenPass()||P.isHidden(this.transform.zoom))continue;let D=C[P.source];(P.type==="custom"||D.length)&&this.renderLayer(this,f[P.source],P,D)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:c.showOverdrawInspector?o.aO.black:o.aO.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=c.showOverdrawInspector,this.depthRangeFor3D=[0,1-(i._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){let M=this.style._layers[d[this.currentLayer]],P=f[M.source],D=y[M.source];this._renderTileClippingMasks(M,D),this.renderLayer(this,P,M,D)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let M=this.style._layers[d[this.currentLayer]],P=f[M.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(M))continue;let D=(M.type==="symbol"?E:C)[M.source];this._renderTileClippingMasks(M,y[M.source]),this.renderLayer(this,P,M,D)}if(this.options.showTileBoundaries){let M=function(P,D){let z=null,G=Object.values(P._layers).flatMap(X=>X.source&&!X.isHidden(D)?[P.sourceCaches[X.source]]:[]),Y=G.filter(X=>X.getSource().type==="vector"),K=G.filter(X=>X.getSource().type!=="vector"),te=X=>{(!z||z.getSource().maxzoom<X.getSource().maxzoom)&&(z=X)};return Y.forEach(X=>te(X)),z||K.forEach(X=>te(X)),z}(this.style,this.transform.zoom);M&&function(P,D,z){for(let G=0;G<z.length;G++)Dc(P,D,z[G])}(this,M,M.getVisibleCoordinates())}this.options.showPadding&&function(M){let P=M.transform.padding;ui(M,M.transform.height-(P.top||0),3,Nu),ui(M,P.bottom||0,3,El),Ts(M,P.left||0,3,Lc),Ts(M,M.transform.width-(P.right||0),3,qp);let D=M.transform.centerPoint;(function(z,G,Y,K){Cr(z,G-1,Y-10,2,20,K),Cr(z,G-10,Y-1,20,2,K)})(M,D.x,M.transform.height-D.y,Vu)}(this),this.context.setDefault()}renderLayer(i,c,d,f){if(!d.isHidden(this.transform.zoom)&&(d.type==="background"||d.type==="custom"||(f||[]).length))switch(this.id=d.id,d.type){case"symbol":(function(y,C,E,M,P){if(y.renderPass!=="translucent")return;let D=Jt.disabled,z=y.colorModeForRenderPass();(E._unevaluatedLayout.hasValue("text-variable-anchor")||E._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(G,Y,K,te,X,le,xe){let ie=Y.transform,pe=X==="map",we=le==="map";for(let be of G){let Ae=te.getTile(be),De=Ae.getBucket(K);if(!De||!De.text||!De.text.segments.get().length)continue;let Le=o.ag(De.textSizeData,ie.zoom),Be=_t(Ae,1,Y.transform.zoom),et=vt(be.posMatrix,we,pe,Y.transform,Be),ht=K.layout.get("icon-text-fit")!=="none"&&De.hasIconData();if(Le){let $e=Math.pow(2,ie.zoom-Ae.tileID.overscaledZ);vl(De,pe,we,xe,ie,et,be.posMatrix,$e,Le,ht,Y.style.map.terrain?(ct,nt)=>Y.style.map.terrain.getElevation(be,ct,nt):null)}}}(M,y,E,C,E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),P),E.paint.get("icon-opacity").constantOr(1)!==0&&wl(y,C,E,M,!1,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),E.layout.get("icon-rotation-alignment"),E.layout.get("icon-pitch-alignment"),E.layout.get("icon-keep-upright"),D,z),E.paint.get("text-opacity").constantOr(1)!==0&&wl(y,C,E,M,!0,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.layout.get("text-keep-upright"),D,z),C.map.showCollisionBoxes&&(xl(y,C,E,M,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),!0),xl(y,C,E,M,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),!1))})(i,c,d,f,this.style.placement.variableOffsets);break;case"circle":(function(y,C,E,M){if(y.renderPass!=="translucent")return;let P=E.paint.get("circle-opacity"),D=E.paint.get("circle-stroke-width"),z=E.paint.get("circle-stroke-opacity"),G=!E.layout.get("circle-sort-key").isConstant();if(P.constantOr(1)===0&&(D.constantOr(1)===0||z.constantOr(1)===0))return;let Y=y.context,K=Y.gl,te=y.depthModeForSublayer(0,Ot.ReadOnly),X=Jt.disabled,le=y.colorModeForRenderPass(),xe=[];for(let ie=0;ie<M.length;ie++){let pe=M[ie],we=C.getTile(pe),be=we.getBucket(E);if(!be)continue;let Ae=be.programConfigurations.get(E.id),De=y.useProgram("circle",Ae),Le=be.layoutVertexBuffer,Be=be.indexBuffer,et=y.style.map.terrain&&y.style.map.terrain.getTerrainData(pe),ht={programConfiguration:Ae,program:De,layoutVertexBuffer:Le,indexBuffer:Be,uniformValues:Lp(y,pe,we,E),terrainData:et};if(G){let $e=be.segments.get();for(let ct of $e)xe.push({segments:new o.$([ct]),sortKey:ct.sortKey,state:ht})}else xe.push({segments:be.segments,sortKey:0,state:ht})}G&&xe.sort((ie,pe)=>ie.sortKey-pe.sortKey);for(let ie of xe){let{programConfiguration:pe,program:we,layoutVertexBuffer:be,indexBuffer:Ae,uniformValues:De,terrainData:Le}=ie.state;we.draw(Y,K.TRIANGLES,te,X,le,Kt.disabled,De,Le,E.id,be,Ae,ie.segments,E.paint,y.transform.zoom,pe)}})(i,c,d,f);break;case"heatmap":(function(y,C,E,M){if(E.paint.get("heatmap-opacity")!==0)if(y.renderPass==="offscreen"){let P=y.context,D=P.gl,z=Jt.disabled,G=new vi([D.ONE,D.ONE],o.aO.transparent,[!0,!0,!0,!0]);(function(Y,K,te){let X=Y.gl;Y.activeTexture.set(X.TEXTURE1),Y.viewport.set([0,0,K.width/4,K.height/4]);let le=te.heatmapFbo;if(le)X.bindTexture(X.TEXTURE_2D,le.colorAttachment.get()),Y.bindFramebuffer.set(le.framebuffer);else{let xe=X.createTexture();X.bindTexture(X.TEXTURE_2D,xe),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_S,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_WRAP_T,X.CLAMP_TO_EDGE),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MIN_FILTER,X.LINEAR),X.texParameteri(X.TEXTURE_2D,X.TEXTURE_MAG_FILTER,X.LINEAR),le=te.heatmapFbo=Y.createFramebuffer(K.width/4,K.height/4,!1,!1),function(ie,pe,we,be){var Ae,De;let Le=ie.gl,Be=(Ae=ie.HALF_FLOAT)!==null&&Ae!==void 0?Ae:Le.UNSIGNED_BYTE,et=(De=ie.RGBA16F)!==null&&De!==void 0?De:Le.RGBA;Le.texImage2D(Le.TEXTURE_2D,0,et,pe.width/4,pe.height/4,0,Le.RGBA,Be,null),be.colorAttachment.set(we)}(Y,K,xe,le)}})(P,y,E),P.clear({color:o.aO.transparent});for(let Y=0;Y<M.length;Y++){let K=M[Y];if(C.hasRenderableParent(K))continue;let te=C.getTile(K),X=te.getBucket(E);if(!X)continue;let le=X.programConfigurations.get(E.id),xe=y.useProgram("heatmap",le),{zoom:ie}=y.transform;xe.draw(P,D.TRIANGLES,Ot.disabled,z,G,Kt.disabled,Cu(K.posMatrix,te,ie,E.paint.get("heatmap-intensity")),null,E.id,X.layoutVertexBuffer,X.indexBuffer,X.segments,E.paint,y.transform.zoom,le)}P.viewport.set([0,0,y.width,y.height])}else y.renderPass==="translucent"&&(y.context.setColorMode(y.colorModeForRenderPass()),function(P,D){let z=P.context,G=z.gl,Y=D.heatmapFbo;if(!Y)return;z.activeTexture.set(G.TEXTURE0),G.bindTexture(G.TEXTURE_2D,Y.colorAttachment.get()),z.activeTexture.set(G.TEXTURE1);let K=D.colorRampTexture;K||(K=D.colorRampTexture=new Ye(z,D.colorRamp,G.RGBA)),K.bind(G.LINEAR,G.CLAMP_TO_EDGE),P.useProgram("heatmapTexture").draw(z,G.TRIANGLES,Ot.disabled,Jt.disabled,P.colorModeForRenderPass(),Kt.disabled,((te,X,le,xe)=>{let ie=o.F();o.aN(ie,0,te.width,te.height,0,0,1);let pe=te.context.gl;return{u_matrix:ie,u_world:[pe.drawingBufferWidth,pe.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:X.paint.get("heatmap-opacity")}})(P,D),null,D.id,P.viewportBuffer,P.quadTriangleIndexBuffer,P.viewportSegments,D.paint,P.transform.zoom)}(y,E))})(i,c,d,f);break;case"line":(function(y,C,E,M){if(y.renderPass!=="translucent")return;let P=E.paint.get("line-opacity"),D=E.paint.get("line-width");if(P.constantOr(1)===0||D.constantOr(1)===0)return;let z=y.depthModeForSublayer(0,Ot.ReadOnly),G=y.colorModeForRenderPass(),Y=E.paint.get("line-dasharray"),K=E.paint.get("line-pattern"),te=K.constantOr(1),X=E.paint.get("line-gradient"),le=E.getCrossfadeParameters(),xe=te?"linePattern":Y?"lineSDF":X?"lineGradient":"line",ie=y.context,pe=ie.gl,we=!0;for(let be of M){let Ae=C.getTile(be);if(te&&!Ae.patternsLoaded())continue;let De=Ae.getBucket(E);if(!De)continue;let Le=De.programConfigurations.get(E.id),Be=y.context.program.get(),et=y.useProgram(xe,Le),ht=we||et.program!==Be,$e=y.style.map.terrain&&y.style.map.terrain.getTerrainData(be),ct=K.constantOr(null);if(ct&&Ae.imageAtlas){let kt=Ae.imageAtlas,It=kt.patternPositions[ct.to.toString()],Lt=kt.patternPositions[ct.from.toString()];It&&Lt&&Le.setConstantPatternPositions(It,Lt)}let nt=$e?be:null,ei=te?Ys(y,Ae,E,le,nt):Y?hl(y,Ae,E,Y,le,nt):X?Eu(y,Ae,E,De.lineClipsArray.length,nt):cl(y,Ae,E,nt);if(te)ie.activeTexture.set(pe.TEXTURE0),Ae.imageAtlasTexture.bind(pe.LINEAR,pe.CLAMP_TO_EDGE),Le.updatePaintBuffers(le);else if(Y&&(ht||y.lineAtlas.dirty))ie.activeTexture.set(pe.TEXTURE0),y.lineAtlas.bind(ie);else if(X){let kt=De.gradients[E.id],It=kt.texture;if(E.gradientVersion!==kt.version){let Lt=256;if(E.stepInterpolant){let wi=C.getSource().maxzoom,Zt=be.canonical.z===wi?Math.ceil(1<<y.transform.maxZoom-be.canonical.z):1;Lt=o.ac(o.aT(De.maxLineLength/o.W*1024*Zt),256,ie.maxTextureSize)}kt.gradient=o.aU({expression:E.gradientExpression(),evaluationKey:"lineProgress",resolution:Lt,image:kt.gradient||void 0,clips:De.lineClipsArray}),kt.texture?kt.texture.update(kt.gradient):kt.texture=new Ye(ie,kt.gradient,pe.RGBA),kt.version=E.gradientVersion,It=kt.texture}ie.activeTexture.set(pe.TEXTURE0),It.bind(E.stepInterpolant?pe.NEAREST:pe.LINEAR,pe.CLAMP_TO_EDGE)}et.draw(ie,pe.TRIANGLES,z,y.stencilModeForClipping(be),G,Kt.disabled,ei,$e,E.id,De.layoutVertexBuffer,De.indexBuffer,De.segments,E.paint,y.transform.zoom,Le,De.layoutVertexBuffer2),we=!1}})(i,c,d,f);break;case"fill":(function(y,C,E,M){let P=E.paint.get("fill-color"),D=E.paint.get("fill-opacity");if(D.constantOr(1)===0)return;let z=y.colorModeForRenderPass(),G=E.paint.get("fill-pattern"),Y=y.opaquePassEnabledForLayer()&&!G.constantOr(1)&&P.constantOr(o.aO.transparent).a===1&&D.constantOr(0)===1?"opaque":"translucent";if(y.renderPass===Y){let K=y.depthModeForSublayer(1,y.renderPass==="opaque"?Ot.ReadWrite:Ot.ReadOnly);Ou(y,C,E,M,K,z,!1)}if(y.renderPass==="translucent"&&E.paint.get("fill-antialias")){let K=y.depthModeForSublayer(E.getPaintProperty("fill-outline-color")?2:0,Ot.ReadOnly);Ou(y,C,E,M,K,z,!0)}})(i,c,d,f);break;case"fill-extrusion":(function(y,C,E,M){let P=E.paint.get("fill-extrusion-opacity");if(P!==0&&y.renderPass==="translucent"){let D=new Ot(y.context.gl.LEQUAL,Ot.ReadWrite,y.depthRangeFor3D);if(P!==1||E.paint.get("fill-extrusion-pattern").constantOr(1))Cl(y,C,E,M,D,Jt.disabled,vi.disabled),Cl(y,C,E,M,D,y.stencilModeFor3D(),y.colorModeForRenderPass());else{let z=y.colorModeForRenderPass();Cl(y,C,E,M,D,Jt.disabled,z)}}})(i,c,d,f);break;case"hillshade":(function(y,C,E,M){if(y.renderPass!=="offscreen"&&y.renderPass!=="translucent")return;let P=y.context,D=y.depthModeForSublayer(0,Ot.ReadOnly),z=y.colorModeForRenderPass(),[G,Y]=y.renderPass==="translucent"?y.stencilConfigForOverlap(M):[{},M];for(let K of Y){let te=C.getTile(K);te.needsHillshadePrepare!==void 0&&te.needsHillshadePrepare&&y.renderPass==="offscreen"?kc(y,te,E,D,Jt.disabled,z):y.renderPass==="translucent"&&Il(y,K,te,E,D,G[K.overscaledZ],z)}P.viewport.set([0,0,y.width,y.height])})(i,c,d,f);break;case"raster":(function(y,C,E,M){if(y.renderPass!=="translucent"||E.paint.get("raster-opacity")===0||!M.length)return;let P=y.context,D=P.gl,z=C.getSource(),G=y.useProgram("raster"),Y=y.colorModeForRenderPass(),[K,te]=z instanceof Vr?[{},M]:y.stencilConfigForOverlap(M),X=te[te.length-1].overscaledZ,le=!y.options.moving;for(let xe of te){let ie=y.depthModeForSublayer(xe.overscaledZ-X,E.paint.get("raster-opacity")===1?Ot.ReadWrite:Ot.ReadOnly,D.LESS),pe=C.getTile(xe);pe.registerFadeDuration(E.paint.get("raster-fade-duration"));let we=C.findLoadedParent(xe,0),be=Bu(pe,we,C,E,y.transform,y.style.map.terrain),Ae,De,Le=E.paint.get("raster-resampling")==="nearest"?D.NEAREST:D.LINEAR;P.activeTexture.set(D.TEXTURE0),pe.texture.bind(Le,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),P.activeTexture.set(D.TEXTURE1),we?(we.texture.bind(Le,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),Ae=Math.pow(2,we.tileID.overscaledZ-pe.tileID.overscaledZ),De=[pe.tileID.canonical.x*Ae%1,pe.tileID.canonical.y*Ae%1]):pe.texture.bind(Le,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST);let Be=y.style.map.terrain&&y.style.map.terrain.getTerrainData(xe),et=Be?xe:null,ht=et?et.posMatrix:y.transform.calculatePosMatrix(xe.toUnwrapped(),le),$e=ul(ht,De||[0,0],Ae||1,be,E);z instanceof Vr?G.draw(P,D.TRIANGLES,ie,Jt.disabled,Y,Kt.disabled,$e,Be,E.id,z.boundsBuffer,y.quadTriangleIndexBuffer,z.boundsSegments):G.draw(P,D.TRIANGLES,ie,K[xe.overscaledZ],Y,Kt.disabled,$e,Be,E.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments)}})(i,c,d,f);break;case"background":(function(y,C,E,M){let P=E.paint.get("background-color"),D=E.paint.get("background-opacity");if(D===0)return;let z=y.context,G=z.gl,Y=y.transform,K=Y.tileSize,te=E.paint.get("background-pattern");if(y.isPatternMissing(te))return;let X=!te&&P.a===1&&D===1&&y.opaquePassEnabledForLayer()?"opaque":"translucent";if(y.renderPass!==X)return;let le=Jt.disabled,xe=y.depthModeForSublayer(0,X==="opaque"?Ot.ReadWrite:Ot.ReadOnly),ie=y.colorModeForRenderPass(),pe=y.useProgram(te?"backgroundPattern":"background"),we=M||Y.coveringTiles({tileSize:K,terrain:y.style.map.terrain});te&&(z.activeTexture.set(G.TEXTURE0),y.imageManager.bind(y.context));let be=E.getCrossfadeParameters();for(let Ae of we){let De=M?Ae.posMatrix:y.transform.calculatePosMatrix(Ae.toUnwrapped()),Le=te?Fp(De,D,y,te,{tileID:Ae,tileSize:K},be):Dp(De,D,P),Be=y.style.map.terrain&&y.style.map.terrain.getTerrainData(Ae);pe.draw(z,G.TRIANGLES,xe,le,ie,Kt.disabled,Le,Be,E.id,y.tileExtentBuffer,y.quadTriangleIndexBuffer,y.tileExtentSegments)}})(i,0,d,f);break;case"custom":(function(y,C,E){let M=y.context,P=E.implementation;if(y.renderPass==="offscreen"){let D=P.prerender;D&&(y.setCustomLayerDefaults(),M.setColorMode(y.colorModeForRenderPass()),D.call(P,M.gl,y.transform.customLayerMatrix()),M.setDirty(),y.setBaseState())}else if(y.renderPass==="translucent"){y.setCustomLayerDefaults(),M.setColorMode(y.colorModeForRenderPass()),M.setStencilMode(Jt.disabled);let D=P.renderingMode==="3d"?new Ot(y.context.gl.LEQUAL,Ot.ReadWrite,y.depthRangeFor3D):y.depthModeForSublayer(0,Ot.ReadOnly);M.setDepthMode(D),P.render(M.gl,y.transform.customLayerMatrix()),M.setDirty(),y.setBaseState(),M.bindFramebuffer.set(null)}})(i,0,d)}}translatePosMatrix(i,c,d,f,y){if(!d[0]&&!d[1])return i;let C=y?f==="map"?this.transform.angle:0:f==="viewport"?-this.transform.angle:0;if(C){let P=Math.sin(C),D=Math.cos(C);d=[d[0]*D-d[1]*P,d[0]*P+d[1]*D]}let E=[y?d[0]:_t(c,d[0],this.transform.zoom),y?d[1]:_t(c,d[1],this.transform.zoom),0],M=new Float32Array(16);return o.H(M,i,E),M}saveTileTexture(i){let c=this._tileTextures[i.size[0]];c?c.push(i):this._tileTextures[i.size[0]]=[i]}getTileTexture(i){let c=this._tileTextures[i];return c&&c.length>0?c.pop():null}isPatternMissing(i){if(!i)return!1;if(!i.from||!i.to)return!0;let c=this.imageManager.getPattern(i.from.toString()),d=this.imageManager.getPattern(i.to.toString());return!c||!d}useProgram(i,c){this.cache=this.cache||{};let d=i+(c?c.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[d]||(this.cache[d]=new Es(this.context,ma[i],c,Tu[i],this._showOverdrawInspector,this.style.map.terrain)),this.cache[d]}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(){let i=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(i.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Ye(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:i,drawingBufferHeight:c}=this.context.gl;return this.width!==i||this.height!==c}}class Ms{constructor(i,c){this.points=i,this.planes=c}static fromInvProjectionMatrix(i,c,d){let f=Math.pow(2,d),y=[[-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(E=>{let M=1/(E=o.af([],E,i))[3]/c*f;return o.a_(E,E,[M,M,1/E[3],M])}),C=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{let M=function(G,Y){var K=Y[0],te=Y[1],X=Y[2],le=K*K+te*te+X*X;return le>0&&(le=1/Math.sqrt(le)),G[0]=Y[0]*le,G[1]=Y[1]*le,G[2]=Y[2]*le,G}([],function(G,Y,K){var te=Y[0],X=Y[1],le=Y[2],xe=K[0],ie=K[1],pe=K[2];return G[0]=X*pe-le*ie,G[1]=le*xe-te*pe,G[2]=te*ie-X*xe,G}([],Ee([],y[E[0]],y[E[1]]),Ee([],y[E[2]],y[E[1]]))),P=-((D=M)[0]*(z=y[E[1]])[0]+D[1]*z[1]+D[2]*z[2]);var D,z;return M.concat(P)});return new Ms(y,C)}}class As{constructor(i,c){this.min=i,this.max=c,this.center=function(d,f,y){return d[0]=.5*f[0],d[1]=.5*f[1],d[2]=.5*f[2],d}([],function(d,f,y){return d[0]=f[0]+y[0],d[1]=f[1]+y[1],d[2]=f[2]+y[2],d}([],this.min,this.max))}quadrant(i){let c=[i%2==0,i<2],d=fe(this.min),f=fe(this.max);for(let y=0;y<c.length;y++)d[y]=c[y]?this.min[y]:this.center[y],f[y]=c[y]?this.center[y]:this.max[y];return f[2]=this.max[2],new As(d,f)}distanceX(i){return Math.max(Math.min(this.max[0],i[0]),this.min[0])-i[0]}distanceY(i){return Math.max(Math.min(this.max[1],i[1]),this.min[1])-i[1]}intersects(i){let c=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]],d=!0;for(let f=0;f<i.planes.length;f++){let y=i.planes[f],C=0;for(let E=0;E<c.length;E++)o.a$(y,c[E])>=0&&C++;if(C===0)return 0;C!==c.length&&(d=!1)}if(d)return 2;for(let f=0;f<3;f++){let y=Number.MAX_VALUE,C=-Number.MAX_VALUE;for(let E=0;E<i.points.length;E++){let M=i.points[E][f]-this.min[f];y=Math.min(y,M),C=Math.max(C,M)}if(C<0||y>this.max[f]-this.min[f])return 0}return 1}}class Oo{constructor(i=0,c=0,d=0,f=0){if(isNaN(i)||i<0||isNaN(c)||c<0||isNaN(d)||d<0||isNaN(f)||f<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=i,this.bottom=c,this.left=d,this.right=f}interpolate(i,c,d){return c.top!=null&&i.top!=null&&(this.top=o.z.number(i.top,c.top,d)),c.bottom!=null&&i.bottom!=null&&(this.bottom=o.z.number(i.bottom,c.bottom,d)),c.left!=null&&i.left!=null&&(this.left=o.z.number(i.left,c.left,d)),c.right!=null&&i.right!=null&&(this.right=o.z.number(i.right,c.right,d)),this}getCenter(i,c){let d=o.ac((this.left+i-this.right)/2,0,i),f=o.ac((this.top+c-this.bottom)/2,0,c);return new o.P(d,f)}equals(i){return this.top===i.top&&this.bottom===i.bottom&&this.left===i.left&&this.right===i.right}clone(){return new Oo(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class Ml{constructor(i,c,d,f,y){this.tileSize=512,this.maxValidLatitude=85.051129,this._renderWorldCopies=y===void 0||!!y,this._minZoom=i||0,this._maxZoom=c||22,this._minPitch=d??0,this._maxPitch=f??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Oo,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){let i=new Ml(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return i.apply(this),i}apply(i){this.tileSize=i.tileSize,this.latRange=i.latRange,this.width=i.width,this.height=i.height,this._center=i._center,this._elevation=i._elevation,this.minElevationForCurrentTile=i.minElevationForCurrentTile,this.zoom=i.zoom,this.angle=i.angle,this._fov=i._fov,this._pitch=i._pitch,this._unmodified=i._unmodified,this._edgeInsets=i._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(i){this._minZoom!==i&&(this._minZoom=i,this.zoom=Math.max(this.zoom,i))}get maxZoom(){return this._maxZoom}set maxZoom(i){this._maxZoom!==i&&(this._maxZoom=i,this.zoom=Math.min(this.zoom,i))}get minPitch(){return this._minPitch}set minPitch(i){this._minPitch!==i&&(this._minPitch=i,this.pitch=Math.max(this.pitch,i))}get maxPitch(){return this._maxPitch}set maxPitch(i){this._maxPitch!==i&&(this._maxPitch=i,this.pitch=Math.min(this.pitch,i))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(i){i===void 0?i=!0:i===null&&(i=!1),this._renderWorldCopies=i}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(i){let c=-o.b0(i,-180,180)*Math.PI/180;this.angle!==c&&(this._unmodified=!1,this.angle=c,this._calcMatrices(),this.rotationMatrix=function(){var d=new o.A(4);return o.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}(),function(d,f,y){var C=f[0],E=f[1],M=f[2],P=f[3],D=Math.sin(y),z=Math.cos(y);d[0]=C*z+M*D,d[1]=E*z+P*D,d[2]=C*-D+M*z,d[3]=E*-D+P*z}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(i){let c=o.ac(i,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==c&&(this._unmodified=!1,this._pitch=c,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(i){i=Math.max(.01,Math.min(60,i)),this._fov!==i&&(this._unmodified=!1,this._fov=i/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(i){let c=Math.min(Math.max(i,this.minZoom),this.maxZoom);this._zoom!==c&&(this._unmodified=!1,this._zoom=c,this.tileZoom=Math.max(0,Math.floor(c)),this.scale=this.zoomScale(c),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(i){i.lat===this._center.lat&&i.lng===this._center.lng||(this._unmodified=!1,this._center=i,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(i){i!==this._elevation&&(this._elevation=i,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(i){this._edgeInsets.equals(i)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,i,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(i){return this._edgeInsets.equals(i)}interpolatePadding(i,c,d){this._unmodified=!1,this._edgeInsets.interpolate(i,c,d),this._constrain(),this._calcMatrices()}coveringZoomLevel(i){let c=(i.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/i.tileSize));return Math.max(0,c)}getVisibleUnwrappedCoordinates(i){let c=[new o.b1(0,i)];if(this._renderWorldCopies){let d=this.pointCoordinate(new o.P(0,0)),f=this.pointCoordinate(new o.P(this.width,0)),y=this.pointCoordinate(new o.P(this.width,this.height)),C=this.pointCoordinate(new o.P(0,this.height)),E=Math.floor(Math.min(d.x,f.x,y.x,C.x)),M=Math.floor(Math.max(d.x,f.x,y.x,C.x)),P=1;for(let D=E-P;D<=M+P;D++)D!==0&&c.push(new o.b1(D,i))}return c}coveringTiles(i){var c,d;let f=this.coveringZoomLevel(i),y=f;if(i.minzoom!==void 0&&f<i.minzoom)return[];i.maxzoom!==void 0&&f>i.maxzoom&&(f=i.maxzoom);let C=this.pointCoordinate(this.getCameraPoint()),E=o.Y.fromLngLat(this.center),M=Math.pow(2,f),P=[M*C.x,M*C.y,0],D=[M*E.x,M*E.y,0],z=Ms.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,f),G=i.minzoom||0;!i.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(G=f);let Y=i.terrain?2/Math.min(this.tileSize,i.tileSize)*this.tileSize:3,K=ie=>({aabb:new As([ie*M,0,0],[(ie+1)*M,M,0]),zoom:0,x:0,y:0,wrap:ie,fullyVisible:!1}),te=[],X=[],le=f,xe=i.reparseOverscaled?y:f;if(this._renderWorldCopies)for(let ie=1;ie<=3;ie++)te.push(K(-ie)),te.push(K(ie));for(te.push(K(0));te.length>0;){let ie=te.pop(),pe=ie.x,we=ie.y,be=ie.fullyVisible;if(!be){let et=ie.aabb.intersects(z);if(et===0)continue;be=et===2}let Ae=i.terrain?P:D,De=ie.aabb.distanceX(Ae),Le=ie.aabb.distanceY(Ae),Be=Math.max(Math.abs(De),Math.abs(Le));if(ie.zoom===le||Be>Y+(1<<le-ie.zoom)-2&&ie.zoom>=G){let et=le-ie.zoom,ht=P[0]-.5-(pe<<et),$e=P[1]-.5-(we<<et);X.push({tileID:new o.Q(ie.zoom===le?xe:ie.zoom,ie.wrap,ie.zoom,pe,we),distanceSq:Re([D[0]-.5-pe,D[1]-.5-we]),tileDistanceToCamera:Math.sqrt(ht*ht+$e*$e)})}else for(let et=0;et<4;et++){let ht=(pe<<1)+et%2,$e=(we<<1)+(et>>1),ct=ie.zoom+1,nt=ie.aabb.quadrant(et);if(i.terrain){let ei=new o.Q(ct,ie.wrap,ct,ht,$e),kt=i.terrain.getMinMaxElevation(ei),It=(c=kt.minElevation)!==null&&c!==void 0?c:this.elevation,Lt=(d=kt.maxElevation)!==null&&d!==void 0?d:this.elevation;nt=new As([nt.min[0],nt.min[1],It],[nt.max[0],nt.max[1],Lt])}te.push({aabb:nt,zoom:ct,x:ht,y:$e,wrap:ie.wrap,fullyVisible:be})}}return X.sort((ie,pe)=>ie.distanceSq-pe.distanceSq).map(ie=>ie.tileID)}resize(i,c){this.width=i,this.height=c,this.pixelsToGLUnits=[2/i,-2/c],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(i){return Math.pow(2,i)}scaleZoom(i){return Math.log(i)/Math.LN2}project(i){let c=o.ac(i.lat,-this.maxValidLatitude,this.maxValidLatitude);return new o.P(o.N(i.lng)*this.worldSize,o.O(c)*this.worldSize)}unproject(i){return new o.Y(i.x/this.worldSize,i.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(i){let c=this.pointLocation(this.centerPoint,i),d=i.getElevationForLngLatZoom(c,this.tileZoom);if(!(this.elevation-d))return;let f=this.getCameraPosition(),y=o.Y.fromLngLat(f.lngLat,f.altitude),C=o.Y.fromLngLat(c,d),E=y.x-C.x,M=y.y-C.y,P=y.z-C.z,D=Math.sqrt(E*E+M*M+P*P),z=this.scaleZoom(this.cameraToCenterDistance/D/this.tileSize);this._elevation=d,this._center=c,this.zoom=z}setLocationAtPoint(i,c){let d=this.pointCoordinate(c),f=this.pointCoordinate(this.centerPoint),y=this.locationCoordinate(i),C=new o.Y(y.x-(d.x-f.x),y.y-(d.y-f.y));this.center=this.coordinateLocation(C),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(i,c){return c?this.coordinatePoint(this.locationCoordinate(i),c.getElevationForLngLatZoom(i,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(i))}pointLocation(i,c){return this.coordinateLocation(this.pointCoordinate(i,c))}locationCoordinate(i){return o.Y.fromLngLat(i)}coordinateLocation(i){return i&&i.toLngLat()}pointCoordinate(i,c){if(c){let G=c.pointCoordinate(i);if(G!=null)return G}let d=[i.x,i.y,0,1],f=[i.x,i.y,1,1];o.af(d,d,this.pixelMatrixInverse),o.af(f,f,this.pixelMatrixInverse);let y=d[3],C=f[3],E=d[1]/y,M=f[1]/C,P=d[2]/y,D=f[2]/C,z=P===D?0:(0-P)/(D-P);return new o.Y(o.z.number(d[0]/y,f[0]/C,z)/this.worldSize,o.z.number(E,M,z)/this.worldSize)}coordinatePoint(i,c=0,d=this.pixelMatrix){let f=[i.x*this.worldSize,i.y*this.worldSize,c,1];return o.af(f,f,d),new o.P(f[0]/f[3],f[1]/f[3])}getBounds(){let i=Math.max(0,this.height/2-this.getHorizon());return new oi().extend(this.pointLocation(new o.P(0,i))).extend(this.pointLocation(new o.P(this.width,i))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new oi([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(i){i?(this.lngRange=[i.getWest(),i.getEast()],this.latRange=[i.getSouth(),i.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-this.maxValidLatitude,this.maxValidLatitude])}calculatePosMatrix(i,c=!1){let d=i.key,f=c?this._alignedPosMatrixCache:this._posMatrixCache;if(f[d])return f[d];let y=i.canonical,C=this.worldSize/this.zoomScale(y.z),E=y.x+Math.pow(2,y.z)*i.wrap,M=o.an(new Float64Array(16));return o.H(M,M,[E*C,y.y*C,0]),o.J(M,M,[C/o.W,C/o.W,1]),o.K(M,c?this.alignedProjMatrix:this.projMatrix,M),f[d]=new Float32Array(M),f[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let i,c,d,f,y=-90,C=90,E=-180,M=180,P=this.size,D=this._unmodified;if(this.latRange){let Y=this.latRange;y=o.O(Y[1])*this.worldSize,C=o.O(Y[0])*this.worldSize,i=C-y<P.y?P.y/(C-y):0}if(this.lngRange){let Y=this.lngRange;E=o.b0(o.N(Y[0])*this.worldSize,0,this.worldSize),M=o.b0(o.N(Y[1])*this.worldSize,0,this.worldSize),M<E&&(M+=this.worldSize),c=M-E<P.x?P.x/(M-E):0}let z=this.point,G=Math.max(c||0,i||0);if(G)return this.center=this.unproject(new o.P(c?(M+E)/2:z.x,i?(C+y)/2:z.y)),this.zoom+=this.scaleZoom(G),this._unmodified=D,void(this._constraining=!1);if(this.latRange){let Y=z.y,K=P.y/2;Y-K<y&&(f=y+K),Y+K>C&&(f=C-K)}if(this.lngRange){let Y=(E+M)/2,K=o.b0(z.x,Y-this.worldSize/2,Y+this.worldSize/2),te=P.x/2;K-te<E&&(d=E+te),K+te>M&&(d=M-te)}d===void 0&&f===void 0||(this.center=this.unproject(new o.P(d!==void 0?d:z.x,f!==void 0?f:z.y)).wrap()),this._unmodified=D,this._constraining=!1}_calcMatrices(){if(!this.height)return;let i=this.centerOffset,c=this.point.x,d=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=o.b2(1,this.center.lat)*this.worldSize;let f=o.an(new Float64Array(16));o.J(f,f,[this.width/2,-this.height/2,1]),o.H(f,f,[1,-1,0]),this.labelPlaneMatrix=f,f=o.an(new Float64Array(16)),o.J(f,f,[1,-1,1]),o.H(f,f,[-1,-1,0]),o.J(f,f,[2/this.width,2/this.height,1]),this.glCoordMatrix=f;let y=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),C=Math.min(this.elevation,this.minElevationForCurrentTile),E=y-C*this._pixelPerMeter/Math.cos(this._pitch),M=C<0?E:y,P=Math.PI/2+this._pitch,D=this._fov*(.5+i.y/this.height),z=Math.sin(D)*M/Math.sin(o.ac(Math.PI-P-D,.01,Math.PI-.01)),G=this.getHorizon(),Y=2*Math.atan(G/this.cameraToCenterDistance)*(.5+i.y/(2*G)),K=Math.sin(Y)*M/Math.sin(o.ac(Math.PI-P-Y,.01,Math.PI-.01)),te=Math.min(z,K),X=1.01*(Math.cos(Math.PI/2-this._pitch)*te+M),le=this.height/50;f=new Float64Array(16),o.b3(f,this._fov,this.width/this.height,le,X),f[8]=2*-i.x/this.width,f[9]=2*i.y/this.height,o.J(f,f,[1,-1,1]),o.H(f,f,[0,0,-this.cameraToCenterDistance]),o.b4(f,f,this._pitch),o.ad(f,f,this.angle),o.H(f,f,[-c,-d,0]),this.mercatorMatrix=o.J([],f,[this.worldSize,this.worldSize,this.worldSize]),o.J(f,f,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.K(new Float64Array(16),this.labelPlaneMatrix,f),o.H(f,f,[0,0,-this.elevation]),this.projMatrix=f,this.invProjMatrix=o.ar([],f),this.pixelMatrix3D=o.K(new Float64Array(16),this.labelPlaneMatrix,f);let xe=this.width%2/2,ie=this.height%2/2,pe=Math.cos(this.angle),we=Math.sin(this.angle),be=c-Math.round(c)+pe*xe+we*ie,Ae=d-Math.round(d)+pe*ie+we*xe,De=new Float64Array(f);if(o.H(De,De,[be>.5?be-1:be,Ae>.5?Ae-1:Ae,0]),this.alignedProjMatrix=De,f=o.ar(new Float64Array(16),this.pixelMatrix),!f)throw new Error("failed to invert matrix");this.pixelMatrixInverse=f,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let i=this.pointCoordinate(new o.P(0,0)),c=[i.x*this.worldSize,i.y*this.worldSize,0,1];return o.af(c,c,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let i=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,i))}getCameraQueryGeometry(i){let c=this.getCameraPoint();if(i.length===1)return[i[0],c];{let d=c.x,f=c.y,y=c.x,C=c.y;for(let E of i)d=Math.min(d,E.x),f=Math.min(f,E.y),y=Math.max(y,E.x),C=Math.max(C,E.y);return[new o.P(d,f),new o.P(y,f),new o.P(y,C),new o.P(d,C),new o.P(d,f)]}}lngLatToCameraDepth(i,c){let d=this.locationCoordinate(i),f=[d.x*this.worldSize,d.y*this.worldSize,c,1];return o.af(f,f,this.projMatrix),f[2]/f[3]}}function Fc(m,i){let c,d=!1,f=null,y=null,C=()=>{f=null,d&&(m.apply(y,c),f=setTimeout(C,i),d=!1)};return(...E)=>(d=!0,y=this,c=E,f||C(),f)}class zc{constructor(i){this._getCurrentHash=()=>{let c=window.location.hash.replace("#","");if(this._hashName){let d;return c.split("&").map(f=>f.split("=")).forEach(f=>{f[0]===this._hashName&&(d=f)}),(d&&d[1]||"").split("/")}return c.split("/")},this._onHashChange=()=>{let c=this._getCurrentHash();if(c.length>=3&&!c.some(d=>isNaN(d))){let d=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(c[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+c[2],+c[1]],zoom:+c[0],bearing:d,pitch:+(c[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let c=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,c)}catch{}},this._updateHash=Fc(this._updateHashUnthrottled,300),this._hashName=i&&encodeURIComponent(i)}addTo(i){return this._map=i,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(i){let c=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,f=Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10),y=Math.pow(10,f),C=Math.round(c.lng*y)/y,E=Math.round(c.lat*y)/y,M=this._map.getBearing(),P=this._map.getPitch(),D="";if(D+=i?`/${C}/${E}/${d}`:`${d}/${E}/${C}`,(M||P)&&(D+="/"+Math.round(10*M)/10),P&&(D+=`/${Math.round(P)}`),this._hashName){let z=this._hashName,G=!1,Y=window.location.hash.slice(1).split("&").map(K=>{let te=K.split("=")[0];return te===z?(G=!0,`${te}=${D}`):K}).filter(K=>K);return G||Y.push(`${z}=${D}`),`#${Y.join("&")}`}return`#${D}`}}let Sa={linearity:.3,easing:o.b5(0,0,.3,1)},ju=o.e({deceleration:2500,maxSpeed:1400},Sa),eo=o.e({deceleration:20,maxSpeed:1400},Sa),Uu=o.e({deceleration:1e3,maxSpeed:360},Sa),$u=o.e({deceleration:1e3,maxSpeed:90},Sa);class qu{constructor(i){this._map=i,this.clear()}clear(){this._inertiaBuffer=[]}record(i){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:T.now(),settings:i})}_drainInertiaBuffer(){let i=this._inertiaBuffer,c=T.now();for(;i.length>0&&c-i[0].time>160;)i.shift()}_onMoveEnd(i){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let c={zoom:0,bearing:0,pitch:0,pan:new o.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:y}of this._inertiaBuffer)c.zoom+=y.zoomDelta||0,c.bearing+=y.bearingDelta||0,c.pitch+=y.pitchDelta||0,y.panDelta&&c.pan._add(y.panDelta),y.around&&(c.around=y.around),y.pinchAround&&(c.pinchAround=y.pinchAround);let d=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,f={};if(c.pan.mag()){let y=Ia(c.pan.mag(),d,o.e({},ju,i||{}));f.offset=c.pan.mult(y.amount/c.pan.mag()),f.center=this._map.transform.center,Ca(f,y)}if(c.zoom){let y=Ia(c.zoom,d,eo);f.zoom=this._map.transform.zoom+y.amount,Ca(f,y)}if(c.bearing){let y=Ia(c.bearing,d,Uu);f.bearing=this._map.transform.bearing+o.ac(y.amount,-179,179),Ca(f,y)}if(c.pitch){let y=Ia(c.pitch,d,$u);f.pitch=this._map.transform.pitch+y.amount,Ca(f,y)}if(f.zoom||f.bearing){let y=c.pinchAround===void 0?c.around:c.pinchAround;f.around=y?this._map.unproject(y):this._map.getCenter()}return this.clear(),o.e(f,{noMoveStart:!0})}}function Ca(m,i){(!m.duration||m.duration<i.duration)&&(m.duration=i.duration,m.easing=i.easing)}function Ia(m,i,c){let{maxSpeed:d,linearity:f,deceleration:y}=c,C=o.ac(m*f/(i/1e3),-d,d),E=Math.abs(C)/(y*f);return{easing:c.easing,duration:1e3*E,amount:C*(E/2)}}class Ur extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,c,d,f={}){let y=S.mousePos(c.getCanvas(),d),C=c.unproject(y);super(i,o.e({point:y,lngLat:C,originalEvent:d},f)),this._defaultPrevented=!1,this.target=c}}class Bo extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,c,d){let f=i==="touchend"?d.changedTouches:d.touches,y=S.touchPos(c.getCanvasContainer(),f),C=y.map(M=>c.unproject(M)),E=y.reduce((M,P,D,z)=>M.add(P.div(z.length)),new o.P(0,0));super(i,{points:y,point:E,lngLats:C,lngLat:c.unproject(E),originalEvent:d}),this._defaultPrevented=!1}}class to extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(i,c,d){super(i,{originalEvent:d}),this._defaultPrevented=!1}}class Wu{constructor(i,c){this._map=i,this._clickTolerance=c.clickTolerance}reset(){delete this._mousedownPos}wheel(i){return this._firePreventable(new to(i.type,this._map,i))}mousedown(i,c){return this._mousedownPos=c,this._firePreventable(new Ur(i.type,this._map,i))}mouseup(i){this._map.fire(new Ur(i.type,this._map,i))}click(i,c){this._mousedownPos&&this._mousedownPos.dist(c)>=this._clickTolerance||this._map.fire(new Ur(i.type,this._map,i))}dblclick(i){return this._firePreventable(new Ur(i.type,this._map,i))}mouseover(i){this._map.fire(new Ur(i.type,this._map,i))}mouseout(i){this._map.fire(new Ur(i.type,this._map,i))}touchstart(i){return this._firePreventable(new Bo(i.type,this._map,i))}touchmove(i){this._map.fire(new Bo(i.type,this._map,i))}touchend(i){this._map.fire(new Bo(i.type,this._map,i))}touchcancel(i){this._map.fire(new Bo(i.type,this._map,i))}_firePreventable(i){if(this._map.fire(i),i.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bn{constructor(i){this._map=i}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(i){this._map.fire(new Ur(i.type,this._map,i))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ur("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(i){this._delayContextMenu?this._contextMenuEvent=i:this._ignoreContextMenu||this._map.fire(new Ur(i.type,this._map,i)),this._map.listens("contextmenu")&&i.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class $r{constructor(i){this._map=i}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(i){return this.transform.pointLocation(o.P.convert(i),this._map.terrain)}}class Oc{constructor(i,c){this._map=i,this._tr=new $r(i),this._el=i.getCanvasContainer(),this._container=i.getContainer(),this._clickTolerance=c.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(i,c){this.isEnabled()&&i.shiftKey&&i.button===0&&(S.disableDrag(),this._startPos=this._lastPos=c,this._active=!0)}mousemoveWindow(i,c){if(!this._active)return;let d=c;if(this._lastPos.equals(d)||!this._box&&d.dist(this._startPos)<this._clickTolerance)return;let f=this._startPos;this._lastPos=d,this._box||(this._box=S.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",i));let y=Math.min(f.x,d.x),C=Math.max(f.x,d.x),E=Math.min(f.y,d.y),M=Math.max(f.y,d.y);S.setTransform(this._box,`translate(${y}px,${E}px)`),this._box.style.width=C-y+"px",this._box.style.height=M-E+"px"}mouseupWindow(i,c){if(!this._active||i.button!==0)return;let d=this._startPos,f=c;if(this.reset(),S.suppressClick(),d.x!==f.x||d.y!==f.y)return this._map.fire(new o.k("boxzoomend",{originalEvent:i})),{cameraAnimation:y=>y.fitScreenCoordinates(d,f,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",i)}keydown(i){this._active&&i.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",i))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(S.remove(this._box),this._box=null),S.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(i,c){return this._map.fire(new o.k(i,{originalEvent:c}))}}function yn(m,i){if(m.length!==i.length)throw new Error(`The number of touches and points are not equal - touches ${m.length}, points ${i.length}`);let c={};for(let d=0;d<m.length;d++)c[m[d].identifier]=i[d];return c}class Ea{constructor(i){this.reset(),this.numTouches=i.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(i,c,d){(this.centroid||d.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=i.timeStamp),d.length===this.numTouches&&(this.centroid=function(f){let y=new o.P(0,0);for(let C of f)y._add(C);return y.div(f.length)}(c),this.touches=yn(d,c)))}touchmove(i,c,d){if(this.aborted||!this.centroid)return;let f=yn(d,c);for(let y in this.touches){let C=f[y];(!C||C.dist(this.touches[y])>30)&&(this.aborted=!0)}}touchend(i,c,d){if((!this.centroid||i.timeStamp-this.startTime>500)&&(this.aborted=!0),d.length===0){let f=!this.aborted&&this.centroid;if(this.reset(),f)return f}}}class Bc{constructor(i){this.singleTap=new Ea(i),this.numTaps=i.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(i,c,d){this.singleTap.touchstart(i,c,d)}touchmove(i,c,d){this.singleTap.touchmove(i,c,d)}touchend(i,c,d){let f=this.singleTap.touchend(i,c,d);if(f){let y=i.timeStamp-this.lastTime<500,C=!this.lastTap||this.lastTap.dist(f)<30;if(y&&C||this.reset(),this.count++,this.lastTime=i.timeStamp,this.lastTap=f,this.count===this.numTaps)return this.reset(),f}}}class Wp{constructor(i){this._tr=new $r(i),this._zoomIn=new Bc({numTouches:1,numTaps:2}),this._zoomOut=new Bc({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(i,c,d){this._zoomIn.touchstart(i,c,d),this._zoomOut.touchstart(i,c,d)}touchmove(i,c,d){this._zoomIn.touchmove(i,c,d),this._zoomOut.touchmove(i,c,d)}touchend(i,c,d){let f=this._zoomIn.touchend(i,c,d),y=this._zoomOut.touchend(i,c,d),C=this._tr;return f?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:C.zoom+1,around:C.unproject(f)},{originalEvent:i})}):y?(this._active=!0,i.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:C.zoom-1,around:C.unproject(y)},{originalEvent:i})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ta{constructor(i){this._enabled=!!i.enable,this._moveStateManager=i.moveStateManager,this._clickTolerance=i.clickTolerance||1,this._moveFunction=i.move,this._activateOnStart=!!i.activateOnStart,i.assignEvents(this),this.reset()}reset(i){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(i)}_move(...i){let c=this._moveFunction(...i);if(c.bearingDelta||c.pitchDelta||c.around||c.panDelta)return this._active=!0,c}dragStart(i,c){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(i)&&(this._moveStateManager.startMove(i),this._lastPoint=c.length?c[0]:c,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(i,c){if(!this.isEnabled())return;let d=this._lastPoint;if(!d)return;if(i.preventDefault(),!this._moveStateManager.isValidMoveEvent(i))return void this.reset(i);let f=c.length?c[0]:c;return!this._moved&&f.dist(d)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=f,this._move(d,f))}dragEnd(i){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(i)&&(this._moved&&S.suppressClick(),this.reset(i))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let Zu={0:1,2:2};class io{constructor(i){this._correctEvent=i.checkCorrectEvent}startMove(i){let c=S.mouseButton(i);this._eventButton=c}endMove(i){delete this._eventButton}isValidStartEvent(i){return this._correctEvent(i)}isValidMoveEvent(i){return!function(c,d){let f=Zu[d];return c.buttons===void 0||(c.buttons&f)!==f}(i,this._eventButton)}isValidEndEvent(i){return S.mouseButton(i)===this._eventButton}}class as{constructor(){this._firstTouch=void 0}_isOneFingerTouch(i){return i.targetTouches.length===1}_isSameTouchEvent(i){return i.targetTouches[0].identifier===this._firstTouch}startMove(i){this._firstTouch=i.targetTouches[0].identifier}endMove(i){delete this._firstTouch}isValidStartEvent(i){return this._isOneFingerTouch(i)}isValidMoveEvent(i){return this._isOneFingerTouch(i)&&this._isSameTouchEvent(i)}isValidEndEvent(i){return this._isOneFingerTouch(i)&&this._isSameTouchEvent(i)}}let Je=m=>{m.mousedown=m.dragStart,m.mousemoveWindow=m.dragMove,m.mouseup=m.dragEnd,m.contextmenu=function(i){i.preventDefault()}},Nc=({enable:m,clickTolerance:i,bearingDegreesPerPixelMoved:c=.8})=>{let d=new io({checkCorrectEvent:f=>S.mouseButton(f)===0&&f.ctrlKey||S.mouseButton(f)===2});return new Ta({clickTolerance:i,move:(f,y)=>({bearingDelta:(y.x-f.x)*c}),moveStateManager:d,enable:m,assignEvents:Je})},No=({enable:m,clickTolerance:i,pitchDegreesPerPixelMoved:c=-.5})=>{let d=new io({checkCorrectEvent:f=>S.mouseButton(f)===0&&f.ctrlKey||S.mouseButton(f)===2});return new Ta({clickTolerance:i,move:(f,y)=>({pitchDelta:(y.y-f.y)*c}),moveStateManager:d,enable:m,assignEvents:Je})};class Ma{constructor(i,c){this._clickTolerance=i.clickTolerance||1,this._map=c,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(i,c,d){return this._calculateTransform(i,c,d)}touchmove(i,c,d){if(this._active&&!(d.length<this.minTouchs()))return i.preventDefault(),this._calculateTransform(i,c,d)}touchend(i,c,d){this._calculateTransform(i,c,d),this._active&&d.length<this.minTouchs()&&this.reset()}touchcancel(){this.reset()}_calculateTransform(i,c,d){d.length>0&&(this._active=!0);let f=yn(d,c),y=new o.P(0,0),C=new o.P(0,0),E=0;for(let P in f){let D=f[P],z=this._touches[P];z&&(y._add(D),C._add(D.sub(z)),E++,f[P]=D)}if(this._touches=f,E<this.minTouchs()||!C.mag())return;let M=C.div(E);return this._sum._add(M),this._sum.mag()<this._clickTolerance?void 0:{around:y.div(E),panDelta:M}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Al{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(i,c,d){this._firstTwoTouches||d.length<2||(this._firstTwoTouches=[d[0].identifier,d[1].identifier],this._start([c[0],c[1]]))}touchmove(i,c,d){if(!this._firstTwoTouches)return;i.preventDefault();let[f,y]=this._firstTwoTouches,C=Ze(d,c,f),E=Ze(d,c,y);if(!C||!E)return;let M=this._aroundCenter?null:C.add(E).div(2);return this._move([C,E],M,i)}touchend(i,c,d){if(!this._firstTwoTouches)return;let[f,y]=this._firstTwoTouches,C=Ze(d,c,f),E=Ze(d,c,y);C&&E||(this._active&&S.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(i){this._enabled=!0,this._aroundCenter=!!i&&i.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ze(m,i,c){for(let d=0;d<m.length;d++)if(m[d].identifier===c)return i[d]}function Pl(m,i){return Math.log(m/i)/Math.LN2}class Xu extends Al{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(i){this._startDistance=this._distance=i[0].dist(i[1])}_move(i,c){let d=this._distance;if(this._distance=i[0].dist(i[1]),this._active||!(Math.abs(Pl(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Pl(this._distance,d),pinchAround:c}}}function Hu(m,i){return 180*m.angleWith(i)/Math.PI}class Rl extends Al{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(i){this._startVector=this._vector=i[0].sub(i[1]),this._minDiameter=i[0].dist(i[1])}_move(i,c,d){let f=this._vector;if(this._vector=i[0].sub(i[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Hu(this._vector,f),pinchAround:c}}_isBelowThreshold(i){this._minDiameter=Math.min(this._minDiameter,i.mag());let c=25/(Math.PI*this._minDiameter)*360,d=Hu(i,this._startVector);return Math.abs(d)<c}}function kl(m){return Math.abs(m.y)>Math.abs(m.x)}class Vc extends Al{constructor(i){super(),this._currentTouchCount=0,this._map=i}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(i,c,d){super.touchstart(i,c,d),this._currentTouchCount=d.length}_start(i){this._lastPoints=i,kl(i[0].sub(i[1]))&&(this._valid=!1)}_move(i,c,d){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let f=i[0].sub(this._lastPoints[0]),y=i[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(f,y,d.timeStamp),this._valid?(this._lastPoints=i,this._active=!0,{pitchDelta:(f.y+y.y)/2*-.5}):void 0}gestureBeginsVertically(i,c,d){if(this._valid!==void 0)return this._valid;let f=i.mag()>=2,y=c.mag()>=2;if(!f&&!y)return;if(!f||!y)return this._firstMove===void 0&&(this._firstMove=d),d-this._firstMove<100&&void 0;let C=i.y>0==c.y>0;return kl(i)&&kl(c)&&C}}let Zp={panStep:100,bearingStep:15,pitchStep:10};class Yu{constructor(i){this._tr=new $r(i);let c=Zp;this._panStep=c.panStep,this._bearingStep=c.bearingStep,this._pitchStep=c.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(i){if(i.altKey||i.ctrlKey||i.metaKey)return;let c=0,d=0,f=0,y=0,C=0;switch(i.keyCode){case 61:case 107:case 171:case 187:c=1;break;case 189:case 109:case 173:c=-1;break;case 37:i.shiftKey?d=-1:(i.preventDefault(),y=-1);break;case 39:i.shiftKey?d=1:(i.preventDefault(),y=1);break;case 38:i.shiftKey?f=1:(i.preventDefault(),C=-1);break;case 40:i.shiftKey?f=-1:(i.preventDefault(),C=1);break;default:return}return this._rotationDisabled&&(d=0,f=0),{cameraAnimation:E=>{let M=this._tr;E.easeTo({duration:300,easeId:"keyboardHandler",easing:ro,zoom:c?Math.round(M.zoom)+c*(i.shiftKey?2:1):M.zoom,bearing:M.bearing+d*this._bearingStep,pitch:M.pitch+f*this._pitchStep,offset:[-y*this._panStep,-C*this._panStep],center:M.center},{originalEvent:i})}}}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 ro(m){return m*(2-m)}let Qt=4.000244140625;class Aa{constructor(i,c){this._onTimeout=d=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(d)},this._map=i,this._tr=new $r(i),this._triggerRenderFrame=c,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(i){this._defaultZoomRate=i}setWheelZoomRate(i){this._wheelZoomRate=i}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(i){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!i&&i.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(i){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!i[this._map.cooperativeGestures._bypassKey])return;let c=i.deltaMode===WheelEvent.DOM_DELTA_LINE?40*i.deltaY:i.deltaY,d=T.now(),f=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,c!==0&&c%Qt==0?this._type="wheel":c!==0&&Math.abs(c)<4?this._type="trackpad":f>400?(this._type=null,this._lastValue=c,this._timeout=setTimeout(this._onTimeout,40,i)):this._type||(this._type=Math.abs(f*c)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,c+=this._lastValue)),i.shiftKey&&c&&(c/=4),this._type&&(this._lastWheelEvent=i,this._delta-=c,this._active||this._start(i)),i.preventDefault()}_start(i){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);let c=S.mousePos(this._map.getCanvas(),i),d=this._tr;this._around=c.y>d.transform.height/2-d.transform.getHorizon()?o.M.convert(this._aroundCenter?d.center:d.unproject(c)):o.M.convert(d.center),this._aroundPoint=d.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let i=this._tr.transform;if(this._delta!==0){let E=this._type==="wheel"&&Math.abs(this._delta)>Qt?this._wheelZoomRate:this._defaultZoomRate,M=2/(1+Math.exp(-Math.abs(this._delta*E)));this._delta<0&&M!==0&&(M=1/M);let P=typeof this._targetZoom=="number"?i.zoomScale(this._targetZoom):i.scale;this._targetZoom=Math.min(i.maxZoom,Math.max(i.minZoom,i.scaleZoom(P*M))),this._type==="wheel"&&(this._startZoom=i.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let c=typeof this._targetZoom=="number"?this._targetZoom:i.zoom,d=this._startZoom,f=this._easing,y,C=!1;if(this._type==="wheel"&&d&&f){let E=Math.min((T.now()-this._lastWheelEventTime)/200,1),M=f(E);y=o.z.number(d,c,M),E<1?this._frameId||(this._frameId=!0):C=!0}else y=c,C=!0;return this._active=!0,C&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!C,zoomDelta:y-i.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(i){let c=o.b6;if(this._prevEase){let d=this._prevEase,f=(T.now()-d.start)/d.duration,y=d.easing(f+.01)-d.easing(f),C=.27/Math.sqrt(y*y+1e-4)*.01,E=Math.sqrt(.0729-C*C);c=o.b5(C,E,.25,1)}return this._prevEase={start:T.now(),duration:i,easing:c},c}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ll{constructor(i,c){this._clickZoom=i,this._tapZoom=c}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 Ku{constructor(i){this._tr=new $r(i),this.reset()}reset(){this._active=!1}dblclick(i,c){return i.preventDefault(),{cameraAnimation:d=>{d.easeTo({duration:300,zoom:this._tr.zoom+(i.shiftKey?-1:1),around:this._tr.unproject(c)},{originalEvent:i})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ju{constructor(){this._tap=new Bc({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(i,c,d){if(!this._swipePoint)if(this._tapTime){let f=c[0],y=i.timeStamp-this._tapTime<500,C=this._tapPoint.dist(f)<30;y&&C?d.length>0&&(this._swipePoint=f,this._swipeTouch=d[0].identifier):this.reset()}else this._tap.touchstart(i,c,d)}touchmove(i,c,d){if(this._tapTime){if(this._swipePoint){if(d[0].identifier!==this._swipeTouch)return;let f=c[0],y=f.y-this._swipePoint.y;return this._swipePoint=f,i.preventDefault(),this._active=!0,{zoomDelta:y/128}}}else this._tap.touchmove(i,c,d)}touchend(i,c,d){if(this._tapTime)this._swipePoint&&d.length===0&&this.reset();else{let f=this._tap.touchend(i,c,d);f&&(this._tapTime=i.timeStamp,this._tapPoint=f)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Gc{constructor(i,c,d){this._el=i,this._mousePan=c,this._touchPan=d}enable(i){this._inertiaOptions=i||{},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 Qu{constructor(i,c,d){this._pitchWithRotate=i.pitchWithRotate,this._mouseRotate=c,this._mousePitch=d}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 Nn{constructor(i,c,d,f){this._el=i,this._touchZoom=c,this._touchRotate=d,this._tapDragZoom=f,this._rotationDisabled=!1,this._enabled=!0}enable(i){this._touchZoom.enable(i),this._rotationDisabled||this._touchRotate.enable(i),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 Pa{constructor(i,c){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=i,this._options=c,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let i=this._map.getCanvasContainer();i.classList.add("maplibregl-cooperative-gestures"),this._container=S.create("div","maplibregl-cooperative-gesture-screen",i);let c=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(c=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let d=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),f=document.createElement("div");f.className="maplibregl-desktop-message",f.textContent=c,this._container.appendChild(f);let y=document.createElement("div");y.className="maplibregl-mobile-message",y.textContent=d,this._container.appendChild(y),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(S.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._destoryUI()}isEnabled(){return this._enabled}touchmove(i){this._onCooperativeGesture(i.touches.length===1)}wheel(i){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!i[this._bypassKey])}_onCooperativeGesture(i){this._enabled&&i&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let ot=m=>m.zoom||m.drag||m.pitch||m.rotate;class pt extends o.k{}function Vo(m){return m.panDelta&&m.panDelta.mag()||m.zoomDelta||m.bearingDelta||m.pitchDelta}class jc{constructor(i,c){this.handleWindowEvent=f=>{this.handleEvent(f,`${f.type}Window`)},this.handleEvent=(f,y)=>{if(f.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let C=f.type==="renderFrame"?void 0:f,E={needsRenderFrame:!1},M={},P={},D=f.touches,z=D?this._getMapTouches(D):void 0,G=z?S.touchPos(this._map.getCanvas(),z):S.mousePos(this._map.getCanvas(),f);for(let{handlerName:te,handler:X,allowed:le}of this._handlers){if(!X.isEnabled())continue;let xe;this._blockedByActive(P,le,te)?X.reset():X[y||f.type]&&(xe=X[y||f.type](f,G,z),this.mergeHandlerResult(E,M,xe,te,C),xe&&xe.needsRenderFrame&&this._triggerRenderFrame()),(xe||X.isActive())&&(P[te]=X)}let Y={};for(let te in this._previousActiveHandlers)P[te]||(Y[te]=C);this._previousActiveHandlers=P,(Object.keys(Y).length||Vo(E))&&(this._changes.push([E,M,Y]),this._triggerRenderFrame()),(Object.keys(P).length||Vo(E))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:K}=E;K&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],K(this._map))},this._map=i,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new qu(i),this._bearingSnap=c.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(c);let d=this._el;this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[window,"blur",void 0]];for(let[f,y,C]of this._listeners)S.addEventListener(f,y,f===document?this.handleWindowEvent:this.handleEvent,C)}destroy(){for(let[i,c,d]of this._listeners)S.removeEventListener(i,c,i===document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(i){let c=this._map,d=c.getCanvasContainer();this._add("mapEvent",new Wu(c,i));let f=c.boxZoom=new Oc(c,i);this._add("boxZoom",f),i.interactive&&i.boxZoom&&f.enable();let y=c.cooperativeGestures=new Pa(c,i.cooperativeGestures);this._add("cooperativeGestures",y),i.cooperativeGestures&&y.enable();let C=new Wp(c),E=new Ku(c);c.doubleClickZoom=new Ll(E,C),this._add("tapZoom",C),this._add("clickZoom",E),i.interactive&&i.doubleClickZoom&&c.doubleClickZoom.enable();let M=new Ju;this._add("tapDragZoom",M);let P=c.touchPitch=new Vc(c);this._add("touchPitch",P),i.interactive&&i.touchPitch&&c.touchPitch.enable(i.touchPitch);let D=Nc(i),z=No(i);c.dragRotate=new Qu(i,D,z),this._add("mouseRotate",D,["mousePitch"]),this._add("mousePitch",z,["mouseRotate"]),i.interactive&&i.dragRotate&&c.dragRotate.enable();let G=(({enable:xe,clickTolerance:ie})=>{let pe=new io({checkCorrectEvent:we=>S.mouseButton(we)===0&&!we.ctrlKey});return new Ta({clickTolerance:ie,move:(we,be)=>({around:be,panDelta:be.sub(we)}),activateOnStart:!0,moveStateManager:pe,enable:xe,assignEvents:Je})})(i),Y=new Ma(i,c);c.dragPan=new Gc(d,G,Y),this._add("mousePan",G),this._add("touchPan",Y,["touchZoom","touchRotate"]),i.interactive&&i.dragPan&&c.dragPan.enable(i.dragPan);let K=new Rl,te=new Xu;c.touchZoomRotate=new Nn(d,te,K,M),this._add("touchRotate",K,["touchPan","touchZoom"]),this._add("touchZoom",te,["touchPan","touchRotate"]),i.interactive&&i.touchZoomRotate&&c.touchZoomRotate.enable(i.touchZoomRotate);let X=c.scrollZoom=new Aa(c,()=>this._triggerRenderFrame());this._add("scrollZoom",X,["mousePan"]),i.interactive&&i.scrollZoom&&c.scrollZoom.enable(i.scrollZoom);let le=c.keyboard=new Yu(c);this._add("keyboard",le),i.interactive&&i.keyboard&&c.keyboard.enable(),this._add("blockableMapEvent",new Bn(c))}_add(i,c,d){this._handlers.push({handlerName:i,handler:c,allowed:d}),this._handlersById[i]=c}stop(i){if(!this._updatingCamera){for(let{handler:c}of this._handlers)c.reset();this._inertia.clear(),this._fireEvents({},{},i),this._changes=[]}}isActive(){for(let{handler:i}of this._handlers)if(i.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ot(this._eventsInProgress)||this.isZooming()}_blockedByActive(i,c,d){for(let f in i)if(f!==d&&(!c||c.indexOf(f)<0))return!0;return!1}_getMapTouches(i){let c=[];for(let d of i)this._el.contains(d.target)&&c.push(d);return c}mergeHandlerResult(i,c,d,f,y){if(!d)return;o.e(i,d);let C={handlerName:f,originalEvent:d.originalEvent||y};d.zoomDelta!==void 0&&(c.zoom=C),d.panDelta!==void 0&&(c.drag=C),d.pitchDelta!==void 0&&(c.pitch=C),d.bearingDelta!==void 0&&(c.rotate=C)}_applyChanges(){let i={},c={},d={};for(let[f,y,C]of this._changes)f.panDelta&&(i.panDelta=(i.panDelta||new o.P(0,0))._add(f.panDelta)),f.zoomDelta&&(i.zoomDelta=(i.zoomDelta||0)+f.zoomDelta),f.bearingDelta&&(i.bearingDelta=(i.bearingDelta||0)+f.bearingDelta),f.pitchDelta&&(i.pitchDelta=(i.pitchDelta||0)+f.pitchDelta),f.around!==void 0&&(i.around=f.around),f.pinchAround!==void 0&&(i.pinchAround=f.pinchAround),f.noInertia&&(i.noInertia=f.noInertia),o.e(c,y),o.e(d,C);this._updateMapTransform(i,c,d),this._changes=[]}_updateMapTransform(i,c,d){let f=this._map,y=f._getTransformForUpdate(),C=f.terrain;if(!(Vo(i)||C&&this._terrainMovement))return this._fireEvents(c,d,!0);let{panDelta:E,zoomDelta:M,bearingDelta:P,pitchDelta:D,around:z,pinchAround:G}=i;G!==void 0&&(z=G),f._stop(!0),z=z||f.transform.centerPoint;let Y=y.pointLocation(E?z.sub(E):z);P&&(y.bearing+=P),D&&(y.pitch+=D),M&&(y.zoom+=M),C?this._terrainMovement||!c.drag&&!c.zoom?c.drag&&this._terrainMovement?y.center=y.pointLocation(y.centerPoint.sub(E)):y.setLocationAtPoint(Y,z):(this._terrainMovement=!0,this._map._elevationFreeze=!0,y.setLocationAtPoint(Y,z),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,y.recalculateZoom(f.terrain)})):y.setLocationAtPoint(Y,z),f._applyUpdatedTransform(y),this._map._update(),i.noInertia||this._inertia.record(i),this._fireEvents(c,d,!0)}_fireEvents(i,c,d){let f=ot(this._eventsInProgress),y=ot(i),C={};for(let D in i){let{originalEvent:z}=i[D];this._eventsInProgress[D]||(C[`${D}start`]=z),this._eventsInProgress[D]=i[D]}!f&&y&&this._fireEvent("movestart",y.originalEvent);for(let D in C)this._fireEvent(D,C[D]);y&&this._fireEvent("move",y.originalEvent);for(let D in i){let{originalEvent:z}=i[D];this._fireEvent(D,z)}let E={},M;for(let D in this._eventsInProgress){let{handlerName:z,originalEvent:G}=this._eventsInProgress[D];this._handlersById[z].isActive()||(delete this._eventsInProgress[D],M=c[z]||G,E[`${D}end`]=M)}for(let D in E)this._fireEvent(D,E[D]);let P=ot(this._eventsInProgress);if(d&&(f||y)&&!P){this._updatingCamera=!0;let D=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),z=G=>G!==0&&-this._bearingSnap<G&&G<this._bearingSnap;!D||!D.essential&&T.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:M})),z(this._map.getBearing())&&this._map.resetNorth()):(z(D.bearing||this._map.getBearing())&&(D.bearing=0),D.freezeElevation=!0,this._map.easeTo(D,{originalEvent:M})),this._updatingCamera=!1}}_fireEvent(i,c){this._map.fire(new o.k(i,c?{originalEvent:c}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(i=>{delete this._frameId,this.handleEvent(new pt("renderFrame",{timeStamp:i})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Uc extends o.E{constructor(i,c){super(),this._renderFrameCallback=()=>{let d=Math.min((T.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(d)),d<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=i,this._bearingSnap=c.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.M(this.transform.center.lng,this.transform.center.lat)}setCenter(i,c){return this.jumpTo({center:i},c)}panBy(i,c,d){return i=o.P.convert(i).mult(-1),this.panTo(this.transform.center,o.e({offset:i},c),d)}panTo(i,c,d){return this.easeTo(o.e({center:i},c),d)}getZoom(){return this.transform.zoom}setZoom(i,c){return this.jumpTo({zoom:i},c),this}zoomTo(i,c,d){return this.easeTo(o.e({zoom:i},c),d)}zoomIn(i,c){return this.zoomTo(this.getZoom()+1,i,c),this}zoomOut(i,c){return this.zoomTo(this.getZoom()-1,i,c),this}getBearing(){return this.transform.bearing}setBearing(i,c){return this.jumpTo({bearing:i},c),this}getPadding(){return this.transform.padding}setPadding(i,c){return this.jumpTo({padding:i},c),this}rotateTo(i,c,d){return this.easeTo(o.e({bearing:i},c),d)}resetNorth(i,c){return this.rotateTo(0,o.e({duration:1e3},i),c),this}resetNorthPitch(i,c){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},i),c),this}snapToNorth(i,c){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(i,c):this}getPitch(){return this.transform.pitch}setPitch(i,c){return this.jumpTo({pitch:i},c),this}cameraForBounds(i,c){i=oi.convert(i);let d=c&&c.bearing||0;return this._cameraForBoxAndBearing(i.getNorthWest(),i.getSouthEast(),d,c)}_cameraForBoxAndBearing(i,c,d,f){let y={top:0,bottom:0,right:0,left:0};if(typeof(f=o.e({padding:y,offset:[0,0],maxZoom:this.transform.maxZoom},f)).padding=="number"){let et=f.padding;f.padding={top:et,bottom:et,right:et,left:et}}f.padding=o.e(y,f.padding);let C=this.transform,E=C.padding,M=new oi(i,c),P=C.project(M.getNorthWest()),D=C.project(M.getNorthEast()),z=C.project(M.getSouthEast()),G=C.project(M.getSouthWest()),Y=o.b7(-d),K=P.rotate(Y),te=D.rotate(Y),X=z.rotate(Y),le=G.rotate(Y),xe=new o.P(Math.max(K.x,te.x,le.x,X.x),Math.max(K.y,te.y,le.y,X.y)),ie=new o.P(Math.min(K.x,te.x,le.x,X.x),Math.min(K.y,te.y,le.y,X.y)),pe=xe.sub(ie),we=(C.width-(E.left+E.right+f.padding.left+f.padding.right))/pe.x,be=(C.height-(E.top+E.bottom+f.padding.top+f.padding.bottom))/pe.y;if(be<0||we<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let Ae=Math.min(C.scaleZoom(C.scale*Math.min(we,be)),f.maxZoom),De=o.P.convert(f.offset),Le=new o.P((f.padding.left-f.padding.right)/2,(f.padding.top-f.padding.bottom)/2).rotate(o.b7(d)),Be=De.add(Le).mult(C.scale/C.zoomScale(Ae));return{center:C.unproject(P.add(z).div(2).sub(Be)),zoom:Ae,bearing:d}}fitBounds(i,c,d){return this._fitInternal(this.cameraForBounds(i,c),c,d)}fitScreenCoordinates(i,c,d,f,y){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(i)),this.transform.pointLocation(o.P.convert(c)),d,f),f,y)}_fitInternal(i,c,d){return i?(delete(c=o.e(i,c)).padding,c.linear?this.easeTo(c,d):this.flyTo(c,d)):this}jumpTo(i,c){this.stop();let d=this._getTransformForUpdate(),f=!1,y=!1,C=!1;return"zoom"in i&&d.zoom!==+i.zoom&&(f=!0,d.zoom=+i.zoom),i.center!==void 0&&(d.center=o.M.convert(i.center)),"bearing"in i&&d.bearing!==+i.bearing&&(y=!0,d.bearing=+i.bearing),"pitch"in i&&d.pitch!==+i.pitch&&(C=!0,d.pitch=+i.pitch),i.padding==null||d.isPaddingEqual(i.padding)||(d.padding=i.padding),this._applyUpdatedTransform(d),this.fire(new o.k("movestart",c)).fire(new o.k("move",c)),f&&this.fire(new o.k("zoomstart",c)).fire(new o.k("zoom",c)).fire(new o.k("zoomend",c)),y&&this.fire(new o.k("rotatestart",c)).fire(new o.k("rotate",c)).fire(new o.k("rotateend",c)),C&&this.fire(new o.k("pitchstart",c)).fire(new o.k("pitch",c)).fire(new o.k("pitchend",c)),this.fire(new o.k("moveend",c))}calculateCameraOptionsFromTo(i,c,d,f=0){let y=o.Y.fromLngLat(i,c),C=o.Y.fromLngLat(d,f),E=C.x-y.x,M=C.y-y.y,P=C.z-y.z,D=Math.hypot(E,M,P);if(D===0)throw new Error("Can't calculate camera options with same From and To");let z=Math.hypot(E,M),G=this.transform.scaleZoom(this.transform.cameraToCenterDistance/D/this.transform.tileSize),Y=180*Math.atan2(E,-M)/Math.PI,K=180*Math.acos(z/D)/Math.PI;return K=P<0?90-K:90+K,{center:C.toLngLat(),zoom:G,pitch:K,bearing:Y}}easeTo(i,c){this._stop(!1,i.easeId),((i=o.e({offset:[0,0],duration:500,easing:o.b6},i)).animate===!1||!i.essential&&T.prefersReducedMotion)&&(i.duration=0);let d=this._getTransformForUpdate(),f=this.getZoom(),y=this.getBearing(),C=this.getPitch(),E=this.getPadding(),M="zoom"in i?+i.zoom:f,P="bearing"in i?this._normalizeBearing(i.bearing,y):y,D="pitch"in i?+i.pitch:C,z="padding"in i?i.padding:d.padding,G=o.P.convert(i.offset),Y=d.centerPoint.add(G),K=d.pointLocation(Y),te=o.M.convert(i.center||K);this._normalizeCenter(te);let X=d.project(K),le=d.project(te).sub(X),xe=d.zoomScale(M-f),ie,pe;i.around&&(ie=o.M.convert(i.around),pe=d.locationPoint(ie));let we={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||M!==f,this._rotating=this._rotating||y!==P,this._pitching=this._pitching||D!==C,this._padding=!d.isPaddingEqual(z),this._easeId=i.easeId,this._prepareEase(c,i.noMoveStart,we),this.terrain&&this._prepareElevation(te),this._ease(be=>{if(this._zooming&&(d.zoom=o.z.number(f,M,be)),this._rotating&&(d.bearing=o.z.number(y,P,be)),this._pitching&&(d.pitch=o.z.number(C,D,be)),this._padding&&(d.interpolatePadding(E,z,be),Y=d.centerPoint.add(G)),this.terrain&&!i.freezeElevation&&this._updateElevation(be),ie)d.setLocationAtPoint(ie,pe);else{let Ae=d.zoomScale(d.zoom-f),De=M>f?Math.min(2,xe):Math.max(.5,xe),Le=Math.pow(De,1-be),Be=d.unproject(X.add(le.mult(be*Le)).mult(Ae));d.setLocationAtPoint(d.renderWorldCopies?Be.wrap():Be,Y)}this._applyUpdatedTransform(d),this._fireMoveEvents(c)},be=>{this.terrain&&this._finalizeElevation(),this._afterEase(c,be)},i),this}_prepareEase(i,c,d={}){this._moving=!0,c||d.moving||this.fire(new o.k("movestart",i)),this._zooming&&!d.zooming&&this.fire(new o.k("zoomstart",i)),this._rotating&&!d.rotating&&this.fire(new o.k("rotatestart",i)),this._pitching&&!d.pitching&&this.fire(new o.k("pitchstart",i))}_prepareElevation(i){this._elevationCenter=i,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(i){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let c=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(i<1&&c!==this._elevationTarget){let d=this._elevationTarget-this._elevationStart;this._elevationStart+=i*(d-(c-(d*i+this._elevationStart))/(1-i)),this._elevationTarget=c}this.transform.elevation=o.z.number(this._elevationStart,this._elevationTarget,i)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(i){if(!this.transformCameraUpdate)return;let c=i.clone(),{center:d,zoom:f,pitch:y,bearing:C,elevation:E}=this.transformCameraUpdate(c);d&&(c.center=d),f!==void 0&&(c.zoom=f),y!==void 0&&(c.pitch=y),C!==void 0&&(c.bearing=C),E!==void 0&&(c.elevation=E),this.transform.apply(c)}_fireMoveEvents(i){this.fire(new o.k("move",i)),this._zooming&&this.fire(new o.k("zoom",i)),this._rotating&&this.fire(new o.k("rotate",i)),this._pitching&&this.fire(new o.k("pitch",i))}_afterEase(i,c){if(this._easeId&&c&&this._easeId===c)return;delete this._easeId;let d=this._zooming,f=this._rotating,y=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new o.k("zoomend",i)),f&&this.fire(new o.k("rotateend",i)),y&&this.fire(new o.k("pitchend",i)),this.fire(new o.k("moveend",i))}flyTo(i,c){if(!i.essential&&T.prefersReducedMotion){let nt=o.L(i,["center","zoom","bearing","pitch","around"]);return this.jumpTo(nt,c)}this.stop(),i=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b6},i);let d=this._getTransformForUpdate(),f=this.getZoom(),y=this.getBearing(),C=this.getPitch(),E=this.getPadding(),M="zoom"in i?o.ac(+i.zoom,d.minZoom,d.maxZoom):f,P="bearing"in i?this._normalizeBearing(i.bearing,y):y,D="pitch"in i?+i.pitch:C,z="padding"in i?i.padding:d.padding,G=d.zoomScale(M-f),Y=o.P.convert(i.offset),K=d.centerPoint.add(Y),te=d.pointLocation(K),X=o.M.convert(i.center||te);this._normalizeCenter(X);let le=d.project(te),xe=d.project(X).sub(le),ie=i.curve,pe=Math.max(d.width,d.height),we=pe/G,be=xe.mag();if("minZoom"in i){let nt=o.ac(Math.min(i.minZoom,f,M),d.minZoom,d.maxZoom),ei=pe/d.zoomScale(nt-f);ie=Math.sqrt(ei/be*2)}let Ae=ie*ie;function De(nt){let ei=(we*we-pe*pe+(nt?-1:1)*Ae*Ae*be*be)/(2*(nt?we:pe)*Ae*be);return Math.log(Math.sqrt(ei*ei+1)-ei)}function Le(nt){return(Math.exp(nt)-Math.exp(-nt))/2}function Be(nt){return(Math.exp(nt)+Math.exp(-nt))/2}let et=De(!1),ht=function(nt){return Be(et)/Be(et+ie*nt)},$e=function(nt){return pe*((Be(et)*(Le(ei=et+ie*nt)/Be(ei))-Le(et))/Ae)/be;var ei},ct=(De(!0)-et)/ie;if(Math.abs(be)<1e-6||!isFinite(ct)){if(Math.abs(pe-we)<1e-6)return this.easeTo(i,c);let nt=we<pe?-1:1;ct=Math.abs(Math.log(we/pe))/ie,$e=function(){return 0},ht=function(ei){return Math.exp(nt*ie*ei)}}return i.duration="duration"in i?+i.duration:1e3*ct/("screenSpeed"in i?+i.screenSpeed/ie:+i.speed),i.maxDuration&&i.duration>i.maxDuration&&(i.duration=0),this._zooming=!0,this._rotating=y!==P,this._pitching=D!==C,this._padding=!d.isPaddingEqual(z),this._prepareEase(c,!1),this.terrain&&this._prepareElevation(X),this._ease(nt=>{let ei=nt*ct,kt=1/ht(ei);d.zoom=nt===1?M:f+d.scaleZoom(kt),this._rotating&&(d.bearing=o.z.number(y,P,nt)),this._pitching&&(d.pitch=o.z.number(C,D,nt)),this._padding&&(d.interpolatePadding(E,z,nt),K=d.centerPoint.add(Y)),this.terrain&&!i.freezeElevation&&this._updateElevation(nt);let It=nt===1?X:d.unproject(le.add(xe.mult($e(ei))).mult(kt));d.setLocationAtPoint(d.renderWorldCopies?It.wrap():It,K),this._applyUpdatedTransform(d),this._fireMoveEvents(c)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(c)},i),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(i,c){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let d=this._onEaseEnd;delete this._onEaseEnd,d.call(this,c)}if(!i){let d=this.handlers;d&&d.stop(!1)}return this}_ease(i,c,d){d.animate===!1||d.duration===0?(i(1),c()):(this._easeStart=T.now(),this._easeOptions=d,this._onEaseFrame=i,this._onEaseEnd=c,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(i,c){i=o.b0(i,-180,180);let d=Math.abs(i-c);return Math.abs(i-360-c)<d&&(i-=360),Math.abs(i+360-c)<d&&(i+=360),i}_normalizeCenter(i){let c=this.transform;if(!c.renderWorldCopies||c.lngRange)return;let d=i.lng-c.center.lng;i.lng+=d>180?-360:d<-180?360:0}queryTerrainElevation(i){return this.terrain?this.terrain.getElevationForLngLatZoom(o.M.convert(i),this.transform.tileZoom)-this.transform.elevation:null}}let Ir={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class $c{constructor(i=Ir){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=c=>{!c||c.sourceDataType!=="metadata"&&c.sourceDataType!=="visibility"&&c.dataType!=="style"&&c.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=i}getDefaultPosition(){return"bottom-right"}onAdd(i){return this._map=i,this._compact=this.options.compact,this._container=S.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=S.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=S.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(){S.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(i,c){let d=this._map._getUIString(`AttributionControl.${c}`);i.title=d,i.setAttribute("aria-label",d)}_updateAttributions(){if(!this._map.style)return;let i=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?i=i.concat(this.options.customAttribution.map(f=>typeof f!="string"?"":f)):typeof this.options.customAttribution=="string"&&i.push(this.options.customAttribution)),this._map.style.stylesheet){let f=this._map.style.stylesheet;this.styleOwner=f.owner,this.styleId=f.id}let c=this._map.style.sourceCaches;for(let f in c){let y=c[f];if(y.used||y.usedForTerrain){let C=y.getSource();C.attribution&&i.indexOf(C.attribution)<0&&i.push(C.attribution)}}i=i.filter(f=>String(f).trim()),i.sort((f,y)=>f.length-y.length),i=i.filter((f,y)=>{for(let C=y+1;C<i.length;C++)if(i[C].indexOf(f)>=0)return!1;return!0});let d=i.join(" | ");d!==this._attribHTML&&(this._attribHTML=d,i.length?(this._innerContainer.innerHTML=d,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Vn{constructor(i={}){this._updateCompact=()=>{let c=this._container.children;if(c.length){let d=c[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&d.classList.add("maplibregl-compact"):d.classList.remove("maplibregl-compact")}},this.options=i}getDefaultPosition(){return"bottom-left"}onAdd(i){this._map=i,this._compact=this.options&&this.options.compact,this._container=S.create("div","maplibregl-ctrl");let c=S.create("a","maplibregl-ctrl-logo");return c.target="_blank",c.rel="noopener nofollow",c.href="https://maplibre.org/",c.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),c.setAttribute("rel","noopener nofollow"),this._container.appendChild(c),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){S.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Xp{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(i){let c=++this._id;return this._queue.push({callback:i,id:c,cancelled:!1}),c}remove(i){let c=this._currentlyRunning,d=c?this._queue.concat(c):this._queue;for(let f of d)if(f.id===i)return void(f.cancelled=!0)}run(i=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let c=this._currentlyRunning=this._queue;this._queue=[];for(let d of c)if(!d.cancelled&&(d.callback(i),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ra=o.X([{name:"a_pos3d",type:"Int16",components:3}]);class di extends o.E{constructor(i){super(),this.sourceCache=i,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,i.usedForTerrain=!0,i.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(i,c){this.sourceCache.update(i,c),this._renderableTilesKeys=[];let d={};for(let f of i.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:c}))d[f.key]=!0,this._renderableTilesKeys.push(f.key),this._tiles[f.key]||(f.posMatrix=new Float64Array(16),o.aN(f.posMatrix,0,o.W,0,o.W,0,1),this._tiles[f.key]=new br(f,this.tileSize));for(let f in this._tiles)d[f]||delete this._tiles[f]}freeRtt(i){for(let c in this._tiles){let d=this._tiles[c];(!i||d.tileID.equals(i)||d.tileID.isChildOf(i)||i.isChildOf(d.tileID))&&(d.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(i=>this.getTileByID(i))}getTileByID(i){return this._tiles[i]}getTerrainCoords(i){let c={};for(let d of this._renderableTilesKeys){let f=this._tiles[d].tileID;if(f.canonical.equals(i.canonical)){let y=i.clone();y.posMatrix=new Float64Array(16),o.aN(y.posMatrix,0,o.W,0,o.W,0,1),c[d]=y}else if(f.canonical.isChildOf(i.canonical)){let y=i.clone();y.posMatrix=new Float64Array(16);let C=f.canonical.z-i.canonical.z,E=f.canonical.x-(f.canonical.x>>C<<C),M=f.canonical.y-(f.canonical.y>>C<<C),P=o.W>>C;o.aN(y.posMatrix,0,P,0,P,0,1),o.H(y.posMatrix,y.posMatrix,[-E*P,-M*P,0]),c[d]=y}else if(i.canonical.isChildOf(f.canonical)){let y=i.clone();y.posMatrix=new Float64Array(16);let C=i.canonical.z-f.canonical.z,E=i.canonical.x-(i.canonical.x>>C<<C),M=i.canonical.y-(i.canonical.y>>C<<C),P=o.W>>C;o.aN(y.posMatrix,0,o.W,0,o.W,0,1),o.H(y.posMatrix,y.posMatrix,[E*P,M*P,0]),o.J(y.posMatrix,y.posMatrix,[1/2**C,1/2**C,0]),c[d]=y}}return c}getSourceTile(i,c){let d=this.sourceCache._source,f=i.overscaledZ-this.deltaZoom;if(f>d.maxzoom&&(f=d.maxzoom),f<d.minzoom)return null;this._sourceTileCache[i.key]||(this._sourceTileCache[i.key]=i.scaledTo(f).key);let y=this.sourceCache.getTileByID(this._sourceTileCache[i.key]);if((!y||!y.dem)&&c)for(;f>=d.minzoom&&(!y||!y.dem);)y=this.sourceCache.getTileByID(i.scaledTo(f--).key);return y}tilesAfterTime(i=Date.now()){return Object.values(this._tiles).filter(c=>c.timeAdded>=i)}}class bi{constructor(i,c,d){this.painter=i,this.sourceCache=new di(c),this.options=d,this.exaggeration=typeof d.exaggeration=="number"?d.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(i,c,d,f=o.W){var y;if(!(c>=0&&c<f&&d>=0&&d<f))return 0;let C=this.getTerrainData(i),E=(y=C.tile)===null||y===void 0?void 0:y.dem;if(!E)return 0;let M=function(K,te,X){var le=te[0],xe=te[1];return K[0]=X[0]*le+X[4]*xe+X[12],K[1]=X[1]*le+X[5]*xe+X[13],K}([],[c/f*o.W,d/f*o.W],C.u_terrain_matrix),P=[M[0]*E.dim,M[1]*E.dim],D=Math.floor(P[0]),z=Math.floor(P[1]),G=P[0]-D,Y=P[1]-z;return E.get(D,z)*(1-G)*(1-Y)+E.get(D+1,z)*G*(1-Y)+E.get(D,z+1)*(1-G)*Y+E.get(D+1,z+1)*G*Y}getElevationForLngLatZoom(i,c){let{tileID:d,mercatorX:f,mercatorY:y}=this._getOverscaledTileIDFromLngLatZoom(i,c);return this.getElevation(d,f%o.W,y%o.W,o.W)}getElevation(i,c,d,f=o.W){return this.getDEMElevation(i,c,d,f)*this.exaggeration}getTerrainData(i){if(!this._emptyDemTexture){let f=this.painter.context,y=new o.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ye(f,y,f.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ye(f,new o.R({width:1,height:1}),f.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(f.gl.NEAREST,f.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=o.an([])}let c=this.sourceCache.getSourceTile(i,!0);if(c&&c.dem&&(!c.demTexture||c.needsTerrainPrepare)){let f=this.painter.context;c.demTexture=this.painter.getTileTexture(c.dem.stride),c.demTexture?c.demTexture.update(c.dem.getPixels(),{premultiply:!1}):c.demTexture=new Ye(f,c.dem.getPixels(),f.gl.RGBA,{premultiply:!1}),c.demTexture.bind(f.gl.NEAREST,f.gl.CLAMP_TO_EDGE),c.needsTerrainPrepare=!1}let d=c&&c+c.tileID.key+i.key;if(d&&!this._demMatrixCache[d]){let f=this.sourceCache.sourceCache._source.maxzoom,y=i.canonical.z-c.tileID.canonical.z;i.overscaledZ>i.canonical.z&&(i.canonical.z>=f?y=i.canonical.z-f:o.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let C=i.canonical.x-(i.canonical.x>>y<<y),E=i.canonical.y-(i.canonical.y>>y<<y),M=o.b8(new Float64Array(16),[1/(o.W<<y),1/(o.W<<y),0]);o.H(M,M,[C*o.W,E*o.W,0]),this._demMatrixCache[i.key]={matrix:M,coord:i}}return{u_depth:2,u_terrain:3,u_terrain_dim:c&&c.dem&&c.dem.dim||1,u_terrain_matrix:d?this._demMatrixCache[i.key].matrix:this._emptyDemMatrix,u_terrain_unpack:c&&c.dem&&c.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(c&&c.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:c}}getFramebuffer(i){let c=this.painter,d=c.width/devicePixelRatio,f=c.height/devicePixelRatio;return!this._fbo||this._fbo.width===d&&this._fbo.height===f||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ye(c.context,{width:d,height:f,data:null},c.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(c.context.gl.NEAREST,c.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ye(c.context,{width:d,height:f,data:null},c.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(c.context.gl.NEAREST,c.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=c.context.createFramebuffer(d,f,!0,!1),this._fbo.depthAttachment.set(c.context.createRenderbuffer(c.context.gl.DEPTH_COMPONENT16,d,f))),this._fbo.colorAttachment.set(i==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let i=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let c=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let y=0,C=0;y<this._coordsTextureSize;y++)for(let E=0;E<this._coordsTextureSize;E++,C+=4)c[C+0]=255&E,c[C+1]=255&y,c[C+2]=E>>8<<4|y>>8,c[C+3]=0;let d=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(c.buffer)),f=new Ye(i,d,i.gl.RGBA,{premultiply:!1});return f.bind(i.gl.NEAREST,i.gl.CLAMP_TO_EDGE),this._coordsTexture=f,f}pointCoordinate(i){let c=new Uint8Array(4),d=this.painter.context,f=d.gl;d.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),f.readPixels(i.x,this.painter.height/devicePixelRatio-i.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),d.bindFramebuffer.set(null);let y=c[0]+(c[2]>>4<<8),C=c[1]+((15&c[2])<<8),E=this.coordsIndex[255-c[3]],M=E&&this.sourceCache.getTileByID(E);if(!M)return null;let P=this._coordsTextureSize,D=(1<<M.tileID.canonical.z)*P;return new o.Y((M.tileID.canonical.x*P+y)/D+M.tileID.wrap,(M.tileID.canonical.y*P+C)/D,this.getElevation(M.tileID,y,C,P))}depthAtPoint(i){let c=new Uint8Array(4),d=this.painter.context,f=d.gl;return d.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),f.readPixels(i.x,this.painter.height/devicePixelRatio-i.y-1,1,1,f.RGBA,f.UNSIGNED_BYTE,c),d.bindFramebuffer.set(null),(c[0]/16777216+c[1]/65536+c[2]/256+c[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let i=this.painter.context,c=new o.b9,d=new o.aX,f=this.meshSize,y=o.W/f,C=f*f;for(let z=0;z<=f;z++)for(let G=0;G<=f;G++)c.emplaceBack(G*y,z*y,0);for(let z=0;z<C;z+=f+1)for(let G=0;G<f;G++)d.emplaceBack(G+z,f+G+z+1,f+G+z+2),d.emplaceBack(G+z,f+G+z+2,G+z+1);let E=c.length,M=E+2*(f+1);for(let z of[0,1])for(let G=0;G<=f;G++)for(let Y of[0,1])c.emplaceBack(G*y,z*o.W,Y);for(let z=0;z<2*f;z+=2)d.emplaceBack(M+z,M+z+1,M+z+3),d.emplaceBack(M+z,M+z+3,M+z+2),d.emplaceBack(E+z,E+z+3,E+z+1),d.emplaceBack(E+z,E+z+2,E+z+3);let P=c.length,D=P+2*(f+1);for(let z of[0,1])for(let G=0;G<=f;G++)for(let Y of[0,1])c.emplaceBack(z*o.W,G*y,Y);for(let z=0;z<2*f;z+=2)d.emplaceBack(P+z,P+z+1,P+z+3),d.emplaceBack(P+z,P+z+3,P+z+2),d.emplaceBack(D+z,D+z+3,D+z+1),d.emplaceBack(D+z,D+z+2,D+z+3);return this._mesh={indexBuffer:i.createIndexBuffer(d),vertexBuffer:i.createVertexBuffer(c,Ra.members),segments:o.$.simpleSegment(0,0,c.length,d.length)},this._mesh}getMeshFrameDelta(i){return 2*Math.PI*o.ba/Math.pow(2,i)/5}getMinTileElevationForLngLatZoom(i,c){var d;let{tileID:f}=this._getOverscaledTileIDFromLngLatZoom(i,c);return(d=this.getMinMaxElevation(f).minElevation)!==null&&d!==void 0?d:0}getMinMaxElevation(i){let c=this.getTerrainData(i).tile,d={minElevation:null,maxElevation:null};return c&&c.dem&&(d.minElevation=c.dem.min*this.exaggeration,d.maxElevation=c.dem.max*this.exaggeration),d}_getOverscaledTileIDFromLngLatZoom(i,c){let d=o.Y.fromLngLat(i.wrap()),f=(1<<c)*o.W,y=d.x*f,C=d.y*f,E=Math.floor(y/o.W),M=Math.floor(C/o.W);return{tileID:new o.Q(c,0,c,E,M),mercatorX:y,mercatorY:C}}}class ed{constructor(i,c,d){this._context=i,this._size=c,this._tileSize=d,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let i of this._objects)i.texture.destroy(),i.fbo.destroy()}_createObject(i){let c=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),d=new Ye(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return d.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),c.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),c.colorAttachment.set(d.texture),{id:i,fbo:c,texture:d,stamp:-1,inUse:!1}}getObjectForId(i){return this._objects[i]}useObject(i){i.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(c=>i.id!==c),this._recentlyUsed.push(i.id)}stampObject(i){i.stamp=++this._stamp}getOrCreateFreeObject(){for(let c of this._recentlyUsed)if(!this._objects[c].inUse)return this._objects[c];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let i=this._createObject(this._objects.length);return this._objects.push(i),i}freeObject(i){i.inUse=!1}freeAllObjects(){for(let i of this._objects)this.freeObject(i)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(i=>!i.inUse)===!1}}let Kn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Dl{constructor(i,c){this.painter=i,this.terrain=c,this.pool=new ed(i.context,30,c.sourceCache.tileSize*c.qualityFactor)}destruct(){this.pool.destruct()}getTexture(i){return this.pool.getObjectForId(i.rtt[this._stacks.length-1].id).texture}prepareForRender(i,c){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=i._order.filter(d=>!i._layers[d].isHidden(c)),this._coordsDescendingInv={};for(let d in i.sourceCaches){this._coordsDescendingInv[d]={};let f=i.sourceCaches[d].getVisibleCoordinates();for(let y of f){let C=this.terrain.sourceCache.getTerrainCoords(y);for(let E in C)this._coordsDescendingInv[d][E]||(this._coordsDescendingInv[d][E]=[]),this._coordsDescendingInv[d][E].push(C[E])}}this._coordsDescendingInvStr={};for(let d of i._order){let f=i._layers[d],y=f.source;if(Kn[f.type]&&!this._coordsDescendingInvStr[y]){this._coordsDescendingInvStr[y]={};for(let C in this._coordsDescendingInv[y])this._coordsDescendingInvStr[y][C]=this._coordsDescendingInv[y][C].map(E=>E.key).sort().join()}}for(let d of this._renderableTiles)for(let f in this._coordsDescendingInvStr){let y=this._coordsDescendingInvStr[f][d.tileID.key];y&&y!==d.rttCoords[f]&&(d.rtt=[])}}renderLayer(i){if(i.isHidden(this.painter.transform.zoom))return!1;let c=i.type,d=this.painter,f=this._renderableLayerIds[this._renderableLayerIds.length-1]===i.id;if(Kn[c]&&(this._prevType&&Kn[this._prevType]||this._stacks.push([]),this._prevType=c,this._stacks[this._stacks.length-1].push(i.id),!f))return!0;if(Kn[this._prevType]||Kn[c]&&f){this._prevType=c;let y=this._stacks.length-1,C=this._stacks[y]||[];for(let E of this._renderableTiles){if(this.pool.isFull()&&(Tl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(E),E.rtt[y]){let P=this.pool.getObjectForId(E.rtt[y].id);if(P.stamp===E.rtt[y].stamp){this.pool.useObject(P);continue}}let M=this.pool.getOrCreateFreeObject();this.pool.useObject(M),this.pool.stampObject(M),E.rtt[y]={id:M.id,stamp:M.stamp},d.context.bindFramebuffer.set(M.fbo.framebuffer),d.context.clear({color:o.aO.transparent,stencil:0}),d.currentStencilSource=void 0;for(let P=0;P<C.length;P++){let D=d.style._layers[C[P]],z=D.source?this._coordsDescendingInv[D.source][E.tileID.key]:[E.tileID];d.context.viewport.set([0,0,M.fbo.width,M.fbo.height]),d._renderTileClippingMasks(D,z),d.renderLayer(d,d.style.sourceCaches[D.source],D,z),D.source&&(E.rttCoords[D.source]=this._coordsDescendingInvStr[D.source][E.tileID.key])}}return Tl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Kn[c]}return!1}}let qc={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Wc=g,Zc={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:Ir,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:o.a.MAX_TILE_CACHE_ZOOM_LEVELS,localIdeographFontFamily:"sans-serif",transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,validateStyle:!0,maxCanvasSize:[4096,4096]},Go=m=>{m.touchstart=m.dragStart,m.touchmoveWindow=m.dragMove,m.touchend=m.dragEnd},Xc={showCompass:!0,showZoom:!0,visualizePitch:!1};class Hc{constructor(i,c,d=!1){this.mousedown=C=>{this.startMouse(o.e({},C,{ctrlKey:!0,preventDefault:()=>C.preventDefault()}),S.mousePos(this.element,C)),S.addEventListener(window,"mousemove",this.mousemove),S.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=C=>{this.moveMouse(C,S.mousePos(this.element,C))},this.mouseup=C=>{this.mouseRotate.dragEnd(C),this.mousePitch&&this.mousePitch.dragEnd(C),this.offTemp()},this.touchstart=C=>{C.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=S.touchPos(this.element,C.targetTouches)[0],this.startTouch(C,this._startPos),S.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),S.addEventListener(window,"touchend",this.touchend))},this.touchmove=C=>{C.targetTouches.length!==1?this.reset():(this._lastPos=S.touchPos(this.element,C.targetTouches)[0],this.moveTouch(C,this._lastPos))},this.touchend=C=>{C.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{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;let f=i.dragRotate._mouseRotate.getClickTolerance(),y=i.dragRotate._mousePitch.getClickTolerance();this.element=c,this.mouseRotate=Nc({clickTolerance:f,enable:!0}),this.touchRotate=(({enable:C,clickTolerance:E,bearingDegreesPerPixelMoved:M=.8})=>{let P=new as;return new Ta({clickTolerance:E,move:(D,z)=>({bearingDelta:(z.x-D.x)*M}),moveStateManager:P,enable:C,assignEvents:Go})})({clickTolerance:f,enable:!0}),this.map=i,d&&(this.mousePitch=No({clickTolerance:y,enable:!0}),this.touchPitch=(({enable:C,clickTolerance:E,pitchDegreesPerPixelMoved:M=-.5})=>{let P=new as;return new Ta({clickTolerance:E,move:(D,z)=>({pitchDelta:(z.y-D.y)*M}),moveStateManager:P,enable:C,assignEvents:Go})})({clickTolerance:y,enable:!0})),S.addEventListener(c,"mousedown",this.mousedown),S.addEventListener(c,"touchstart",this.touchstart,{passive:!1}),S.addEventListener(c,"touchcancel",this.reset)}startMouse(i,c){this.mouseRotate.dragStart(i,c),this.mousePitch&&this.mousePitch.dragStart(i,c),S.disableDrag()}startTouch(i,c){this.touchRotate.dragStart(i,c),this.touchPitch&&this.touchPitch.dragStart(i,c),S.disableDrag()}moveMouse(i,c){let d=this.map,{bearingDelta:f}=this.mouseRotate.dragMove(i,c)||{};if(f&&d.setBearing(d.getBearing()+f),this.mousePitch){let{pitchDelta:y}=this.mousePitch.dragMove(i,c)||{};y&&d.setPitch(d.getPitch()+y)}}moveTouch(i,c){let d=this.map,{bearingDelta:f}=this.touchRotate.dragMove(i,c)||{};if(f&&d.setBearing(d.getBearing()+f),this.touchPitch){let{pitchDelta:y}=this.touchPitch.dragMove(i,c)||{};y&&d.setPitch(d.getPitch()+y)}}off(){let i=this.element;S.removeEventListener(i,"mousedown",this.mousedown),S.removeEventListener(i,"touchstart",this.touchstart,{passive:!1}),S.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),S.removeEventListener(window,"touchend",this.touchend),S.removeEventListener(i,"touchcancel",this.reset),this.offTemp()}offTemp(){S.enableDrag(),S.removeEventListener(window,"mousemove",this.mousemove),S.removeEventListener(window,"mouseup",this.mouseup),S.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),S.removeEventListener(window,"touchend",this.touchend)}}let ls;function Fl(m,i,c){let d=new o.M(m.lng,m.lat);if(m=new o.M(m.lng,m.lat),i){let f=new o.M(m.lng-360,m.lat),y=new o.M(m.lng+360,m.lat),C=c.locationPoint(m).distSqr(i);c.locationPoint(f).distSqr(i)<C?m=f:c.locationPoint(y).distSqr(i)<C&&(m=y)}for(;Math.abs(m.lng-c.center.lng)>180;){let f=c.locationPoint(m);if(f.x>=0&&f.y>=0&&f.x<=c.width&&f.y<=c.height)break;m.lng>c.center.lng?m.lng-=360:m.lng+=360}return m.lng!==d.lng&&c.locationPoint(m).y>c.height/2-c.getHorizon()?m:d}let ka={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 zl(m,i,c){let d=m.classList;for(let f in ka)d.remove(`maplibregl-${c}-anchor-${f}`);d.add(`maplibregl-${c}-anchor-${i}`)}class La extends o.E{constructor(i){if(super(),this._onKeyPress=c=>{let d=c.code,f=c.charCode||c.keyCode;d!=="Space"&&d!=="Enter"&&f!==32&&f!==13||this.togglePopup()},this._onMapClick=c=>{let d=c.originalEvent.target,f=this._element;this._popup&&(d===f||f.contains(d))&&this.togglePopup()},this._update=c=>{if(!this._map)return;let d=this._map.loaded()&&!this._map.isMoving();(c?.type==="terrain"||c?.type==="render"&&!d)&&this._map.once("render",this._update),this._map.transform.renderWorldCopies&&(this._lngLat=Fl(this._lngLat,this._flatPos,this._map.transform)),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 f="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?f=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(f=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let y="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?y="rotateX(0deg)":this._pitchAlignment==="map"&&(y=`rotateX(${this._map.getPitch()}deg)`),c&&c.type!=="moveend"||(this._pos=this._pos.round()),S.setTransform(this._element,`${ka[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${y} ${f}`),T.frameAsync(new AbortController).then(()=>{this._updateOpacity(c&&c.type==="moveend")}).catch(()=>{})},this._onMove=c=>{if(!this._isDragging){let d=this._clickTolerance||this._map._clickTolerance;this._isDragging=c.point.dist(this._pointerdownPos)>=d}this._isDragging&&(this._pos=c.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 o.k("dragstart"))),this.fire(new o.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 o.k("dragend")),this._state="inactive"},this._addDragHandler=c=>{this._element.contains(c.originalEvent.target)&&(c.preventDefault(),this._positionDelta=c.point.sub(this._pos).add(this._offset),this._pointerdownPos=c.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=i&&i.anchor||"center",this._color=i&&i.color||"#3FB1CE",this._scale=i&&i.scale||1,this._draggable=i&&i.draggable||!1,this._clickTolerance=i&&i.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=i&&i.rotation||0,this._rotationAlignment=i&&i.rotationAlignment||"auto",this._pitchAlignment=i&&i.pitchAlignment&&i.pitchAlignment!=="auto"?i.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(i?.opacity,i?.opacityWhenCovered),i&&i.element)this._element=i.element,this._offset=o.P.convert(i&&i.offset||[0,0]);else{this._defaultMarker=!0,this._element=S.create("div"),this._element.setAttribute("aria-label","Map marker");let c=S.createNS("http://www.w3.org/2000/svg","svg"),d=41,f=27;c.setAttributeNS(null,"display","block"),c.setAttributeNS(null,"height",`${d}px`),c.setAttributeNS(null,"width",`${f}px`),c.setAttributeNS(null,"viewBox",`0 0 ${f} ${d}`);let y=S.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"stroke","none"),y.setAttributeNS(null,"stroke-width","1"),y.setAttributeNS(null,"fill","none"),y.setAttributeNS(null,"fill-rule","evenodd");let C=S.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"fill-rule","nonzero");let E=S.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(3.0, 29.0)"),E.setAttributeNS(null,"fill","#000000");let M=[{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(let le of M){let xe=S.createNS("http://www.w3.org/2000/svg","ellipse");xe.setAttributeNS(null,"opacity","0.04"),xe.setAttributeNS(null,"cx","10.5"),xe.setAttributeNS(null,"cy","5.80029008"),xe.setAttributeNS(null,"rx",le.rx),xe.setAttributeNS(null,"ry",le.ry),E.appendChild(xe)}let P=S.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"fill",this._color);let D=S.createNS("http://www.w3.org/2000/svg","path");D.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"),P.appendChild(D);let z=S.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"opacity","0.25"),z.setAttributeNS(null,"fill","#000000");let G=S.createNS("http://www.w3.org/2000/svg","path");G.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"),z.appendChild(G);let Y=S.createNS("http://www.w3.org/2000/svg","g");Y.setAttributeNS(null,"transform","translate(6.0, 7.0)"),Y.setAttributeNS(null,"fill","#FFFFFF");let K=S.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"transform","translate(8.0, 8.0)");let te=S.createNS("http://www.w3.org/2000/svg","circle");te.setAttributeNS(null,"fill","#000000"),te.setAttributeNS(null,"opacity","0.25"),te.setAttributeNS(null,"cx","5.5"),te.setAttributeNS(null,"cy","5.5"),te.setAttributeNS(null,"r","5.4999962");let X=S.createNS("http://www.w3.org/2000/svg","circle");X.setAttributeNS(null,"fill","#FFFFFF"),X.setAttributeNS(null,"cx","5.5"),X.setAttributeNS(null,"cy","5.5"),X.setAttributeNS(null,"r","5.4999962"),K.appendChild(te),K.appendChild(X),C.appendChild(E),C.appendChild(P),C.appendChild(z),C.appendChild(Y),C.appendChild(K),c.appendChild(C),c.setAttributeNS(null,"height",d*this._scale+"px"),c.setAttributeNS(null,"width",f*this._scale+"px"),this._element.appendChild(c),this._offset=o.P.convert(i&&i.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",c=>{c.preventDefault()}),this._element.addEventListener("mousedown",c=>{c.preventDefault()}),zl(this._element,this._anchor,"marker"),i&&i.className)for(let c of i.className.split(" "))this._element.classList.add(c);this._popup=null}addTo(i){return this.remove(),this._map=i,i.getCanvasContainer().appendChild(this._element),i.on("move",this._update),i.on("moveend",this._update),i.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("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),S.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(i){return this._lngLat=o.M.convert(i),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(i){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),i){if(!("offset"in i.options)){let f=Math.abs(13.5)/Math.SQRT2;i.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[f,-1*(38.1-13.5+f)],"bottom-right":[-f,-1*(38.1-13.5+f)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=i,this._lngLat&&this._popup.setLngLat(this._lngLat),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){let i=this._popup;return i?(i.isOpen()?i.remove():i.addTo(this._map),this):this}_updateOpacity(i=!1){var c;if(!(!((c=this._map)===null||c===void 0)&&c.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(i)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let d=this._map,f=d.terrain.depthAtPoint(this._pos),y=d.terrain.getElevationForLngLatZoom(this._lngLat,d.transform.tileZoom);if(d.transform.lngLatToCameraDepth(this._lngLat,y)-f<.006)return void(this._element.style.opacity=this._opacity);let C=-this._offset.y/d.transform._pixelPerMeter,E=Math.sin(d.getPitch()*Math.PI/180)*C,M=d.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),P=d.transform.lngLatToCameraDepth(this._lngLat,y+E);this._element.style.opacity=P-M>.006?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(i){return this._offset=o.P.convert(i),this._update(),this}addClassName(i){this._element.classList.add(i)}removeClassName(i){this._element.classList.remove(i)}toggleClassName(i){return this._element.classList.toggle(i)}setDraggable(i){return this._draggable=!!i,this._map&&(i?(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(i){return this._rotation=i||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(i){return this._rotationAlignment=i||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(i){return this._pitchAlignment=i&&i!=="auto"?i:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(i,c){return i===void 0&&c===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),i!==void 0&&(this._opacity=i),c!==void 0&&(this._opacityWhenCovered=c),this._map&&this._updateOpacity(!0),this}}let Yc={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},no=0,so=!1,Kc={maxWidth:100,unit:"metric"};function Da(m,i,c){let d=c&&c.maxWidth||100,f=m._container.clientHeight/2,y=m.unproject([0,f]),C=m.unproject([d,f]),E=y.distanceTo(C);if(c&&c.unit==="imperial"){let M=3.2808*E;M>5280?oo(i,d,M/5280,m._getUIString("ScaleControl.Miles")):oo(i,d,M,m._getUIString("ScaleControl.Feet"))}else c&&c.unit==="nautical"?oo(i,d,E/1852,m._getUIString("ScaleControl.NauticalMiles")):E>=1e3?oo(i,d,E/1e3,m._getUIString("ScaleControl.Kilometers")):oo(i,d,E,m._getUIString("ScaleControl.Meters"))}function oo(m,i,c,d){let f=function(y){let C=Math.pow(10,`${Math.floor(y)}`.length-1),E=y/C;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:E>=1?1:function(M){let P=Math.pow(10,Math.ceil(-Math.log(M)/Math.LN10));return Math.round(M*P)/P}(E),C*E}(c);m.style.width=i*(f/c)+"px",m.innerHTML=`${f}&nbsp;${d}`}let Jc={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Qc=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Ol(m){if(m){if(typeof m=="number"){let i=Math.round(Math.abs(m)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,m),"top-left":new o.P(i,i),"top-right":new o.P(-i,i),bottom:new o.P(0,-m),"bottom-left":new o.P(i,-i),"bottom-right":new o.P(-i,-i),left:new o.P(m,0),right:new o.P(-m,0)}}if(m instanceof o.P||Array.isArray(m)){let i=o.P.convert(m);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:o.P.convert(m.center||[0,0]),top:o.P.convert(m.top||[0,0]),"top-left":o.P.convert(m["top-left"]||[0,0]),"top-right":o.P.convert(m["top-right"]||[0,0]),bottom:o.P.convert(m.bottom||[0,0]),"bottom-left":o.P.convert(m["bottom-left"]||[0,0]),"bottom-right":o.P.convert(m["bottom-right"]||[0,0]),left:o.P.convert(m.left||[0,0]),right:o.P.convert(m.right||[0,0])}}return Ol(new o.P(0,0))}let eh=g;a.AJAXError=o.bd,a.Evented=o.E,a.LngLat=o.M,a.MercatorCoordinate=o.Y,a.Point=o.P,a.addProtocol=o.be,a.config=o.a,a.removeProtocol=o.bf,a.AttributionControl=$c,a.BoxZoomHandler=Oc,a.CanvasSource=pn,a.CooperativeGesturesHandler=Pa,a.DoubleClickZoomHandler=Ll,a.DragPanHandler=Gc,a.DragRotateHandler=Qu,a.EdgeInsets=Oo,a.FullscreenControl=class extends o.E{constructor(m={}){super(),this._onFullscreenChange=()=>{(window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement)===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,m&&m.container&&(m.container instanceof HTMLElement?this._container=m.container:o.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(m){return this._map=m,this._container||(this._container=this._map.getContainer()),this._controlContainer=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){S.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let m=this._fullscreenButton=S.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);S.create("span","maplibregl-ctrl-icon",m).setAttribute("aria-hidden","true"),m.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let m=this._getTitle();this._fullscreenButton.setAttribute("aria-label",m),this._fullscreenButton.title=m}_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 o.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new o.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()}},a.GeoJSONSource=Et,a.GeolocateControl=class extends o.E{constructor(m){super(),this._onSuccess=i=>{if(this._map){if(this._isOutOfMapMaxBounds(i))return this._setErrorState(),this.fire(new o.k("outofmaxbounds",i)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=i,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(i),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(i),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new o.k("geolocate",i)),this._finish()}},this._updateCamera=i=>{let c=new o.M(i.coords.longitude,i.coords.latitude),d=i.coords.accuracy,f=this._map.getBearing(),y=o.e({bearing:f},this.options.fitBoundsOptions),C=oi.fromLngLat(c,d);this._map.fitBounds(C,y,{geolocateSource:!0})},this._updateMarker=i=>{if(i){let c=new o.M(i.coords.longitude,i.coords.latitude);this._accuracyCircleMarker.setLngLat(c).addTo(this._map),this._userLocationDotMarker.setLngLat(c).addTo(this._map),this._accuracy=i.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=i=>{if(this._map){if(this.options.trackUserLocation)if(i.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;let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(i.code===3&&so)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.k("error",i)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=i=>{if(this._map){if(this._container.addEventListener("contextmenu",c=>c.preventDefault()),this._geolocateButton=S.create("button","maplibregl-ctrl-geolocate",this._container),S.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",i===!1){o.w("Geolocation support is not available so the GeolocateControl will be disabled.");let c=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}else{let c=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=c,this._geolocateButton.setAttribute("aria-label",c)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=S.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new La({element:this._dotElement}),this._circleElement=S.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new La({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",c=>{c.geolocateSource||this._watchState!=="ACTIVE_LOCK"||c.originalEvent&&c.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 o.k("trackuserlocationend")))})}},this.options=o.e({},Yc,m)}onAdd(m){return this._map=m,this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(i=!1){return o._(this,void 0,void 0,function*(){if(ls!==void 0&&!i)return ls;if(window.navigator.permissions===void 0)return ls=!!window.navigator.geolocation,ls;try{ls=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{ls=!!window.navigator.geolocation}return ls})}().then(i=>this._setupUI(i)),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(),S.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,no=0,so=!1}_isOutOfMapMaxBounds(m){let i=this._map.getMaxBounds(),c=m.coords;return i&&(c.longitude<i.getWest()||c.longitude>i.getEast()||c.latitude<i.getSouth()||c.latitude>i.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(){let m=this._map.getBounds(),i=m.getSouthEast(),c=m.getNorthEast(),d=i.distanceTo(c),f=Math.ceil(this._accuracy/(d/this._map._container.clientHeight)*2);this._circleElement.style.width=`${f}px`,this._circleElement.style.height=`${f}px`}trigger(){if(!this._setup)return o.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 o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":no--,so=!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 o.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 o.k("trackuserlocationstart"));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 m;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),no++,no>1?(m={maximumAge:6e5,timeout:0},so=!0):(m=this.options.positionOptions,so=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,m)}}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)}},a.Hash=zc,a.ImageSource=Vr,a.KeyboardHandler=Yu,a.LngLatBounds=oi,a.LogoControl=Vn,a.Map=class extends Uc{constructor(m){if(o.bb.mark(o.bc.create),(m=o.e({},Zc,m)).minZoom!=null&&m.maxZoom!=null&&m.minZoom>m.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(m.minPitch!=null&&m.maxPitch!=null&&m.minPitch>m.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(m.minPitch!=null&&m.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(m.maxPitch!=null&&m.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Ml(m.minZoom,m.maxZoom,m.minPitch,m.maxPitch,m.renderWorldCopies),{bearingSnap:m.bearingSnap}),this._contextLost=i=>{i.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:i}))},this._contextRestored=i=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:i}))},this._onMapScroll=i=>{if(i.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=m.interactive,this._maxTileCacheSize=m.maxTileCacheSize,this._maxTileCacheZoomLevels=m.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=m.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=m.preserveDrawingBuffer,this._antialias=m.antialias,this._trackResize=m.trackResize,this._bearingSnap=m.bearingSnap,this._refreshExpiredTiles=m.refreshExpiredTiles,this._fadeDuration=m.fadeDuration,this._crossSourceCollisions=m.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=m.collectResourceTiming,this._renderTaskQueue=new Xp,this._controls=[],this._mapId=o.a3(),this._locale=o.e({},qc,m.locale),this._clickTolerance=m.clickTolerance,this._overridePixelRatio=m.pixelRatio,this._maxCanvasSize=m.maxCanvasSize,this.transformCameraUpdate=m.transformCameraUpdate,this._imageQueueHandle=Z.addThrottleControl(()=>this.isMoving()),this._requestManager=new me(m.transformRequest),typeof m.container=="string"){if(this._container=document.getElementById(m.container),!this._container)throw new Error(`Container '${m.container}' not found.`)}else{if(!(m.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=m.container}if(m.maxBounds&&this.setMaxBounds(m.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let i=!1,c=Fc(d=>{this._trackResize&&!this._removed&&this.resize(d)._update()},50);this._resizeObserver=new ResizeObserver(d=>{i?c(d):i=!0}),this._resizeObserver.observe(this._container)}this.handlers=new jc(this,m),this._hash=m.hash&&new zc(typeof m.hash=="string"&&m.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:m.center,zoom:m.zoom,bearing:m.bearing,pitch:m.pitch}),m.bounds&&(this.resize(),this.fitBounds(m.bounds,o.e({},m.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=m.localIdeographFontFamily,this._validateStyle=m.validateStyle,m.style&&this.setStyle(m.style,{localIdeographFontFamily:m.localIdeographFontFamily}),m.attributionControl&&this.addControl(new $c(typeof m.attributionControl=="boolean"?void 0:m.attributionControl)),m.maplibreLogo&&this.addControl(new Vn,m.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",i=>{this._update(i.dataType==="style"),this.fire(new o.k(`${i.dataType}data`,i))}),this.on("dataloading",i=>{this.fire(new o.k(`${i.dataType}dataloading`,i))}),this.on("dataabort",i=>{this.fire(new o.k("sourcedataabort",i))})}_getMapId(){return this._mapId}addControl(m,i){if(i===void 0&&(i=m.getDefaultPosition?m.getDefaultPosition():"top-right"),!m||!m.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let c=m.onAdd(this);this._controls.push(m);let d=this._controlPositions[i];return i.indexOf("bottom")!==-1?d.insertBefore(c,d.firstChild):d.appendChild(c),this}removeControl(m){if(!m||!m.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(m);return i>-1&&this._controls.splice(i,1),m.onRemove(this),this}hasControl(m){return this._controls.indexOf(m)>-1}calculateCameraOptionsFromTo(m,i,c,d){return d==null&&this.terrain&&(d=this.terrain.getElevationForLngLatZoom(c,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(m,i,c,d)}resize(m){var i;let c=this._containerDimensions(),d=c[0],f=c[1],y=this._getClampedPixelRatio(d,f);if(this._resizeCanvas(d,f,y),this.painter.resize(d,f,y),this.painter.overLimit()){let E=this.painter.context.gl;this._maxCanvasSize=[E.drawingBufferWidth,E.drawingBufferHeight];let M=this._getClampedPixelRatio(d,f);this._resizeCanvas(d,f,M),this.painter.resize(d,f,M)}this.transform.resize(d,f),(i=this._requestedCameraState)===null||i===void 0||i.resize(d,f);let C=!this._moving;return C&&(this.stop(),this.fire(new o.k("movestart",m)).fire(new o.k("move",m))),this.fire(new o.k("resize",m)),C&&this.fire(new o.k("moveend",m)),this}_getClampedPixelRatio(m,i){let{0:c,1:d}=this._maxCanvasSize,f=this.getPixelRatio(),y=m*f,C=i*f;return Math.min(y>c?c/y:1,C>d?d/C:1)*f}getPixelRatio(){var m;return(m=this._overridePixelRatio)!==null&&m!==void 0?m:devicePixelRatio}setPixelRatio(m){this._overridePixelRatio=m,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(m){return this.transform.setMaxBounds(oi.convert(m)),this._update()}setMinZoom(m){if((m=m??-2)>=-2&&m<=this.transform.maxZoom)return this.transform.minZoom=m,this._update(),this.getZoom()<m&&this.setZoom(m),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(m){if((m=m??22)>=this.transform.minZoom)return this.transform.maxZoom=m,this._update(),this.getZoom()>m&&this.setZoom(m),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(m){if((m=m??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(m>=0&&m<=this.transform.maxPitch)return this.transform.minPitch=m,this._update(),this.getPitch()<m&&this.setPitch(m),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(m){if((m=m??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(m>=this.transform.minPitch)return this.transform.maxPitch=m,this._update(),this.getPitch()>m&&this.setPitch(m),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(m){return this.transform.renderWorldCopies=m,this._update()}project(m){return this.transform.locationPoint(o.M.convert(m),this.style&&this.terrain)}unproject(m){return this.transform.pointLocation(o.P.convert(m),this.terrain)}isMoving(){var m;return this._moving||((m=this.handlers)===null||m===void 0?void 0:m.isMoving())}isZooming(){var m;return this._zooming||((m=this.handlers)===null||m===void 0?void 0:m.isZooming())}isRotating(){var m;return this._rotating||((m=this.handlers)===null||m===void 0?void 0:m.isRotating())}_createDelegatedListener(m,i,c){if(m==="mouseenter"||m==="mouseover"){let d=!1;return{layer:i,listener:c,delegates:{mousemove:y=>{let C=this.getLayer(i)?this.queryRenderedFeatures(y.point,{layers:[i]}):[];C.length?d||(d=!0,c.call(this,new Ur(m,this,y.originalEvent,{features:C}))):d=!1},mouseout:()=>{d=!1}}}}if(m==="mouseleave"||m==="mouseout"){let d=!1;return{layer:i,listener:c,delegates:{mousemove:C=>{(this.getLayer(i)?this.queryRenderedFeatures(C.point,{layers:[i]}):[]).length?d=!0:d&&(d=!1,c.call(this,new Ur(m,this,C.originalEvent)))},mouseout:C=>{d&&(d=!1,c.call(this,new Ur(m,this,C.originalEvent)))}}}}{let d=f=>{let y=this.getLayer(i)?this.queryRenderedFeatures(f.point,{layers:[i]}):[];y.length&&(f.features=y,c.call(this,f),delete f.features)};return{layer:i,listener:c,delegates:{[m]:d}}}}on(m,i,c){if(c===void 0)return super.on(m,i);let d=this._createDelegatedListener(m,i,c);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[m]=this._delegatedListeners[m]||[],this._delegatedListeners[m].push(d);for(let f in d.delegates)this.on(f,d.delegates[f]);return this}once(m,i,c){if(c===void 0)return super.once(m,i);let d=this._createDelegatedListener(m,i,c);for(let f in d.delegates)this.once(f,d.delegates[f]);return this}off(m,i,c){return c===void 0?super.off(m,i):(this._delegatedListeners&&this._delegatedListeners[m]&&(d=>{let f=this._delegatedListeners[m];for(let y=0;y<f.length;y++){let C=f[y];if(C.layer===i&&C.listener===c){for(let E in C.delegates)this.off(E,C.delegates[E]);return f.splice(y,1),this}}})(),this)}queryRenderedFeatures(m,i){if(!this.style)return[];let c,d=m instanceof o.P||Array.isArray(m),f=d?m:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(d?{}:m)||{},f instanceof o.P||typeof f[0]=="number")c=[o.P.convert(f)];else{let y=o.P.convert(f[0]),C=o.P.convert(f[1]);c=[y,new o.P(C.x,y.y),C,new o.P(y.x,C.y),y]}return this.style.queryRenderedFeatures(c,i,this.transform)}querySourceFeatures(m,i){return this.style.querySourceFeatures(m,i)}setStyle(m,i){return(i=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff!==!1&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&m?(this._diffStyle(m,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(m,i))}setTransformRequest(m){return this._requestManager.setTransformRequest(m),this}_getUIString(m){let i=this._locale[m];if(i==null)throw new Error(`Missing UI string '${m}'`);return i}_updateStyle(m,i){if(i.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(m,i));let c=this.style&&i.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!m)),m?(this.style=new en(this,i||{}),this.style.setEventedParent(this,{style:this.style}),typeof m=="string"?this.style.loadURL(m,i,c):this.style.loadJSON(m,i,c),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new en(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(m,i){if(typeof m=="string"){let c=this._requestManager.transformRequest(m,ne.Style);o.h(c,new AbortController).then(d=>{this._updateDiff(d.data,i)}).catch(d=>{d&&this.fire(new o.j(d))})}else typeof m=="object"&&this._updateDiff(m,i)}_updateDiff(m,i){try{this.style.setState(m,i)&&this._update(!0)}catch(c){o.w(`Unable to perform style diff: ${c.message||c.error||c}. Rebuilding the style from scratch.`),this._updateStyle(m,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(m,i){return this._lazyInitEmptyStyle(),this.style.addSource(m,i),this._update(!0)}isSourceLoaded(m){let i=this.style&&this.style.sourceCaches[m];if(i!==void 0)return i.loaded();this.fire(new o.j(new Error(`There is no source with ID '${m}'`)))}setTerrain(m){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),m){let i=this.style.sourceCaches[m.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${m.source}`);this.terrain===null&&i.reload();for(let c in this.style._layers){let d=this.style._layers[c];d.type==="hillshade"&&d.source===m.source&&o.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 bi(this.painter,i,m),this.painter.renderToTexture=new Dl(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=c=>{c.dataType==="style"?this.terrain.sourceCache.freeRtt():c.dataType==="source"&&c.tile&&(c.sourceId!==m.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(c.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 o.k("terrain",{terrain:m})),this}getTerrain(){var m,i;return(i=(m=this.terrain)===null||m===void 0?void 0:m.options)!==null&&i!==void 0?i:null}areTilesLoaded(){let m=this.style&&this.style.sourceCaches;for(let i in m){let c=m[i]._tiles;for(let d in c){let f=c[d];if(f.state!=="loaded"&&f.state!=="errored")return!1}}return!0}removeSource(m){return this.style.removeSource(m),this._update(!0)}getSource(m){return this.style.getSource(m)}addImage(m,i,c={}){let{pixelRatio:d=1,sdf:f=!1,stretchX:y,stretchY:C,content:E}=c;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||o.b(i))){if(i.width===void 0||i.height===void 0)return this.fire(new o.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`")));{let{width:M,height:P,data:D}=i,z=i;return this.style.addImage(m,{data:new o.R({width:M,height:P},new Uint8Array(D)),pixelRatio:d,stretchX:y,stretchY:C,content:E,sdf:f,version:0,userImage:z}),z.onAdd&&z.onAdd(this,m),this}}{let{width:M,height:P,data:D}=T.getImageData(i);this.style.addImage(m,{data:new o.R({width:M,height:P},D),pixelRatio:d,stretchX:y,stretchY:C,content:E,sdf:f,version:0})}}updateImage(m,i){let c=this.style.getImage(m);if(!c)return this.fire(new o.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let d=i instanceof HTMLImageElement||o.b(i)?T.getImageData(i):i,{width:f,height:y,data:C}=d;if(f===void 0||y===void 0)return this.fire(new o.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(f!==c.data.width||y!==c.data.height)return this.fire(new o.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let E=!(i instanceof HTMLImageElement||o.b(i));return c.data.replace(C,E),this.style.updateImage(m,c),this}getImage(m){return this.style.getImage(m)}hasImage(m){return m?!!this.style.getImage(m):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(m){this.style.removeImage(m)}loadImage(m){return Z.getImage(this._requestManager.transformRequest(m,ne.Image),new AbortController)}listImages(){return this.style.listImages()}addLayer(m,i){return this._lazyInitEmptyStyle(),this.style.addLayer(m,i),this._update(!0)}moveLayer(m,i){return this.style.moveLayer(m,i),this._update(!0)}removeLayer(m){return this.style.removeLayer(m),this._update(!0)}getLayer(m){return this.style.getLayer(m)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(m,i,c){return this.style.setLayerZoomRange(m,i,c),this._update(!0)}setFilter(m,i,c={}){return this.style.setFilter(m,i,c),this._update(!0)}getFilter(m){return this.style.getFilter(m)}setPaintProperty(m,i,c,d={}){return this.style.setPaintProperty(m,i,c,d),this._update(!0)}getPaintProperty(m,i){return this.style.getPaintProperty(m,i)}setLayoutProperty(m,i,c,d={}){return this.style.setLayoutProperty(m,i,c,d),this._update(!0)}getLayoutProperty(m,i){return this.style.getLayoutProperty(m,i)}setGlyphs(m,i={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(m,i),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(m,i,c={}){return this._lazyInitEmptyStyle(),this.style.addSprite(m,i,c,d=>{d||this._update(!0)}),this}removeSprite(m){return this._lazyInitEmptyStyle(),this.style.removeSprite(m),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(m,i={}){return this._lazyInitEmptyStyle(),this.style.setSprite(m,i,c=>{c||this._update(!0)}),this}setLight(m,i={}){return this._lazyInitEmptyStyle(),this.style.setLight(m,i),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(m,i){return this.style.setFeatureState(m,i),this._update()}removeFeatureState(m,i){return this.style.removeFeatureState(m,i),this._update()}getFeatureState(m){return this.style.getFeatureState(m)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let m=0,i=0;return this._container&&(m=this._container.clientWidth||400,i=this._container.clientHeight||300),[m,i]}_setupContainer(){let m=this._container;m.classList.add("maplibregl-map");let i=this._canvasContainer=S.create("div","maplibregl-canvas-container",m);this._interactive&&i.classList.add("maplibregl-interactive"),this._canvas=S.create("canvas","maplibregl-canvas",i),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label","Map"),this._canvas.setAttribute("role","region");let c=this._containerDimensions(),d=this._getClampedPixelRatio(c[0],c[1]);this._resizeCanvas(c[0],c[1],d);let f=this._controlContainer=S.create("div","maplibregl-control-container",m),y=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(C=>{y[C]=S.create("div",`maplibregl-ctrl-${C} `,f)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(m,i,c){this._canvas.width=Math.floor(c*m),this._canvas.height=Math.floor(c*i),this._canvas.style.width=`${m}px`,this._canvas.style.height=`${i}px`}_setupPainter(){let m={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},i=null;this._canvas.addEventListener("webglcontextcreationerror",d=>{i={requestedAttributes:m},d&&(i.statusMessage=d.statusMessage,i.type=d.type)},{once:!0});let c=this._canvas.getContext("webgl2",m)||this._canvas.getContext("webgl",m);if(!c){let d="Failed to initialize WebGL";throw i?(i.message=d,new Error(JSON.stringify(i))):new Error(d)}this.painter=new Gu(c,this.transform),k.testSupport(c)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(m){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||m,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(m){return this._update(),this._renderTaskQueue.add(m)}_cancelRenderFrame(m){this._renderTaskQueue.remove(m)}_render(m){let i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(m),this._removed)return;let c=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let f=this.transform.zoom,y=T.now();this.style.zoomHistory.update(f,y);let C=new o.a8(f,{now:y,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),E=C.crossFadingFactor();E===1&&E===this._crossFadingFactor||(c=!0,this._crossFadingFactor=E),this.style.update(C)}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,i,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:i,showPadding:this.showPadding}),this.fire(new o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bb.mark(o.bc.load),this.fire(new o.k("load"))),this.style&&(this.style.hasTransitions()||c)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new o.k("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,o.bb.mark(o.bc.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var m;this._hash&&this._hash.remove();for(let c of this._controls)c.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),Z.removeThrottleControl(this._imageQueueHandle),(m=this._resizeObserver)===null||m===void 0||m.disconnect();let i=this.painter.context.gl.getExtension("WEBGL_lose_context");i&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),S.remove(this._canvasContainer),S.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),o.bb.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,T.frameAsync(this._frameRequest).then(m=>{o.bb.frame(m),this._frameRequest=null,this._render(m)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(m){this._showTileBoundaries!==m&&(this._showTileBoundaries=m,this._update())}get showPadding(){return!!this._showPadding}set showPadding(m){this._showPadding!==m&&(this._showPadding=m,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(m){this._showCollisionBoxes!==m&&(this._showCollisionBoxes=m,m?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(m){this._showOverdrawInspector!==m&&(this._showOverdrawInspector=m,this._update())}get repaint(){return!!this._repaint}set repaint(m){this._repaint!==m&&(this._repaint=m,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(m){this._vertices=m,this._update()}get version(){return Wc}getCameraTargetElevation(){return this.transform.elevation}},a.MapMouseEvent=Ur,a.MapTouchEvent=Bo,a.MapWheelEvent=to,a.Marker=La,a.NavigationControl=class{constructor(m){this._updateZoomButtons=()=>{let i=this._map.getZoom(),c=i===this._map.getMaxZoom(),d=i===this._map.getMinZoom();this._zoomInButton.disabled=c,this._zoomOutButton.disabled=d,this._zoomInButton.setAttribute("aria-disabled",c.toString()),this._zoomOutButton.setAttribute("aria-disabled",d.toString())},this._rotateCompassArrow=()=>{let i=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=i},this._setButtonTitle=(i,c)=>{let d=this._map._getUIString(`NavigationControl.${c}`);i.title=d,i.setAttribute("aria-label",d)},this.options=o.e({},Xc,m),this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",i=>i.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",i=>this._map.zoomIn({},{originalEvent:i})),S.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",i=>this._map.zoomOut({},{originalEvent:i})),S.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",i=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:i}):this._map.resetNorth({},{originalEvent:i})}),this._compassIcon=S.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(m){return this._map=m,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 Hc(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){S.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(m,i){let c=S.create("button",m,this._container);return c.type="button",c.addEventListener("click",i),c}},a.Popup=class extends o.E{constructor(m){super(),this.remove=()=>(this._content&&S.remove(this._content),this._container&&(S.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 o.k("close")),this),this._onMouseUp=i=>{this._update(i.point)},this._onMouseMove=i=>{this._update(i.point)},this._onDrag=i=>{this._update(i.point)},this._update=i=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=S.create("div","maplibregl-popup",this._map.getContainer()),this._tip=S.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let C of this.options.className.split(" "))this._container.classList.add(C);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._map.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Fl(this._lngLat,this._flatPos,this._map.transform)),this._trackPointer&&!i)return;let c=this._flatPos=this._pos=this._trackPointer&&i?i:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&i?i:this._map.transform.locationPoint(this._lngLat));let d=this.options.anchor,f=Ol(this.options.offset);if(!d){let C=this._container.offsetWidth,E=this._container.offsetHeight,M;M=c.y+f.bottom.y<E?["top"]:c.y>this._map.transform.height-E?["bottom"]:[],c.x<C/2?M.push("left"):c.x>this._map.transform.width-C/2&&M.push("right"),d=M.length===0?"bottom":M.join("-")}let y=c.add(f[d]).round();S.setTransform(this._container,`${ka[d]} translate(${y.x}px,${y.y}px)`),zl(this._container,d,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(Jc),m)}addTo(m){return this._map&&this.remove(),this._map=m,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 o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(m){return this._lngLat=o.M.convert(m),this._pos=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._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(m){return this.setDOMContent(document.createTextNode(m))}setHTML(m){let i=document.createDocumentFragment(),c=document.createElement("body"),d;for(c.innerHTML=m;d=c.firstChild,d;)i.appendChild(d);return this.setDOMContent(i)}getMaxWidth(){var m;return(m=this._container)===null||m===void 0?void 0:m.style.maxWidth}setMaxWidth(m){return this.options.maxWidth=m,this._update(),this}setDOMContent(m){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=S.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(m),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(m){this._container&&this._container.classList.add(m)}removeClassName(m){this._container&&this._container.classList.remove(m)}setOffset(m){return this.options.offset=m,this._update(),this}toggleClassName(m){if(this._container)return this._container.classList.toggle(m)}_createCloseButton(){this.options.closeButton&&(this._closeButton=S.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let m=this._container.querySelector(Qc);m&&m.focus()}},a.RasterDEMTileSource=Ti,a.RasterTileSource=tr,a.ScaleControl=class{constructor(m){this._onMove=()=>{Da(this._map,this._container,this.options)},this.setUnit=i=>{this.options.unit=i,Da(this._map,this._container,this.options)},this.options=o.e({},Kc,m)}getDefaultPosition(){return"bottom-left"}onAdd(m){return this._map=m,this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-scale",m.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){S.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},a.ScrollZoomHandler=Aa,a.Style=en,a.TerrainControl=class{constructor(m){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=m}onAdd(m){return this._map=m,this._container=S.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=S.create("button","maplibregl-ctrl-terrain",this._container),S.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(){S.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},a.TwoFingersTouchPitchHandler=Vc,a.TwoFingersTouchRotateHandler=Rl,a.TwoFingersTouchZoomHandler=Xu,a.TwoFingersTouchZoomRotateHandler=Nn,a.VectorTileSource=Ie,a.VideoSource=Fn,a.addSourceType=(m,i)=>o._(void 0,void 0,void 0,function*(){if(fn(m))throw new Error(`A source type called "${m}" already exists.`);((c,d)=>{os[c]=d})(m,i)}),a.clearPrewarmedResources=function(){let m=Ue;m&&(m.isPreloaded()&&m.numActive()===1?(m.release(Ft),Ue=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()"))},a.getMaxParallelImageRequests=function(){return o.a.MAX_PARALLEL_IMAGE_REQUESTS},a.getRTLTextPluginStatus=function(){return Oe().getRTLTextPluginStatus()},a.getVersion=function(){return eh},a.getWorkerCount=function(){return Bt.workerCount},a.getWorkerUrl=function(){return o.a.WORKER_URL},a.importScriptInWorkers=function(m){return ar().broadcast("importScript",m)},a.prewarm=function(){xi().acquire(Ft)},a.setMaxParallelImageRequests=function(m){o.a.MAX_PARALLEL_IMAGE_REQUESTS=m},a.setRTLTextPlugin=function(m,i){return Oe().setRTLTextPlugin(m,i)},a.setWorkerCount=function(m){Bt.workerCount=m},a.setWorkerUrl=function(m){o.a.WORKER_URL=m}});var l=h;return l})});var vp=vh((g3,Pb)=>{var DC="Expected a function",Mb=NaN,FC="[object Symbol]",zC=/^\s+|\s+$/g,OC=/^[-+]0x[0-9a-f]+$/i,BC=/^0b[01]+$/i,NC=/^0o[0-7]+$/i,VC=parseInt,GC=typeof global=="object"&&global&&global.Object===Object&&global,jC=typeof self=="object"&&self&&self.Object===Object&&self,UC=GC||jC||Function("return this")(),$C=Object.prototype,qC=$C.toString,WC=Math.max,ZC=Math.min,Fy=function(){return UC.Date.now()};function XC(h,e,r){var l,a,o,g,v,w,T=0,S=!1,k=!1,F=!0;if(typeof h!="function")throw new TypeError(DC);e=Ab(e)||0,zy(r)&&(S=!!r.leading,k="maxWait"in r,o=k?WC(Ab(r.maxWait)||0,e):o,F="trailing"in r?!!r.trailing:F);function j(ve){var Ee=l,Re=a;return l=a=void 0,T=ve,g=h.apply(Re,Ee),g}function J(ve){return T=ve,v=setTimeout(Z,e),S?j(ve):g}function he(ve){var Ee=ve-w,Re=ve-T,Pe=e-Ee;return k?ZC(Pe,o-Re):Pe}function q(ve){var Ee=ve-w,Re=ve-T;return w===void 0||Ee>=e||Ee<0||k&&Re>=o}function Z(){var ve=Fy();if(q(ve))return ne(ve);v=setTimeout(Z,he(ve))}function ne(ve){return v=void 0,F&&l?j(ve):(l=a=void 0,g)}function me(){v!==void 0&&clearTimeout(v),T=0,l=w=a=v=void 0}function _e(){return v===void 0?g:ne(Fy())}function fe(){var ve=Fy(),Ee=q(ve);if(l=arguments,a=this,w=ve,Ee){if(v===void 0)return J(w);if(k)return v=setTimeout(Z,e),j(w)}return v===void 0&&(v=setTimeout(Z,e)),g}return fe.cancel=me,fe.flush=_e,fe}function zy(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function HC(h){return!!h&&typeof h=="object"}function YC(h){return typeof h=="symbol"||HC(h)&&qC.call(h)==FC}function Ab(h){if(typeof h=="number")return h;if(YC(h))return Mb;if(zy(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=zy(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(zC,"");var r=BC.test(h);return r||NC.test(h)?VC(h.slice(2),r?2:8):OC.test(h)?Mb:+h}Pb.exports=XC});var Vb=vh((lB,Nb)=>{var Bb="Expected a function",zb=NaN,QC="[object Symbol]",eI=/^\s+|\s+$/g,tI=/^[-+]0x[0-9a-f]+$/i,iI=/^0b[01]+$/i,rI=/^0o[0-7]+$/i,nI=parseInt,sI=typeof global=="object"&&global&&global.Object===Object&&global,oI=typeof self=="object"&&self&&self.Object===Object&&self,aI=sI||oI||Function("return this")(),lI=Object.prototype,cI=lI.toString,hI=Math.max,uI=Math.min,Gy=function(){return aI.Date.now()};function dI(h,e,r){var l,a,o,g,v,w,T=0,S=!1,k=!1,F=!0;if(typeof h!="function")throw new TypeError(Bb);e=Ob(e)||0,bp(r)&&(S=!!r.leading,k="maxWait"in r,o=k?hI(Ob(r.maxWait)||0,e):o,F="trailing"in r?!!r.trailing:F);function j(ve){var Ee=l,Re=a;return l=a=void 0,T=ve,g=h.apply(Re,Ee),g}function J(ve){return T=ve,v=setTimeout(Z,e),S?j(ve):g}function he(ve){var Ee=ve-w,Re=ve-T,Pe=e-Ee;return k?uI(Pe,o-Re):Pe}function q(ve){var Ee=ve-w,Re=ve-T;return w===void 0||Ee>=e||Ee<0||k&&Re>=o}function Z(){var ve=Gy();if(q(ve))return ne(ve);v=setTimeout(Z,he(ve))}function ne(ve){return v=void 0,F&&l?j(ve):(l=a=void 0,g)}function me(){v!==void 0&&clearTimeout(v),T=0,l=w=a=v=void 0}function _e(){return v===void 0?g:ne(Gy())}function fe(){var ve=Gy(),Ee=q(ve);if(l=arguments,a=this,w=ve,Ee){if(v===void 0)return J(w);if(k)return v=setTimeout(Z,e),j(w)}return v===void 0&&(v=setTimeout(Z,e)),g}return fe.cancel=me,fe.flush=_e,fe}function pI(h,e,r){var l=!0,a=!0;if(typeof h!="function")throw new TypeError(Bb);return bp(r)&&(l="leading"in r?!!r.leading:l,a="trailing"in r?!!r.trailing:a),dI(h,e,{leading:l,maxWait:e,trailing:a})}function bp(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function fI(h){return!!h&&typeof h=="object"}function mI(h){return typeof h=="symbol"||fI(h)&&cI.call(h)==QC}function Ob(h){if(typeof h=="number")return h;if(mI(h))return zb;if(bp(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=bp(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(eI,"");var r=iI.test(h);return r||rI.test(h)?nI(h.slice(2),r?2:8):tI.test(h)?zb:+h}Nb.exports=pI});var Cp={};Of(Cp,{CopyrightControl:()=>ev,MaplibreLayer:()=>fu,MaplibreStyleLayer:()=>Fb,RealtimeAPI:()=>Ch,RealtimeLayer:()=>$b,RealtimeModes:()=>Ki,RoutingAPI:()=>bh,RoutingControl:()=>Sb,StopFinderControl:()=>Eb,StopsAPI:()=>wh,VECTOR_TILE_FEATURE_PROPERTY:()=>ra,compareDepartures:()=>Zh,createCanvas:()=>xs,createRealtimeFilters:()=>Uf,debounceDeparturesMessages:()=>Lm,debounceWebsocketMessages:()=>Sh,fullTrajectoryDelayStyle:()=>Gb,fullTrajectoryStyle:()=>Sp,getCircleCanvas:()=>Gm,getDelayBgCanvas:()=>Nm,getDelayTextCanvas:()=>Vm,getFeatureInfoAtCoordinate:()=>qb,getHoursAndMinutes:()=>O0,getLayersAsFlatArray:()=>ja,getMapGlCopyrights:()=>Ga,getTextCanvas:()=>jm,getUTCDateString:()=>F0,getUTCTimeString:()=>z0,getUrlWithParams:()=>Na,getVehiclePosition:()=>qh,pad:()=>Ed,realtimeConfig:()=>oc,realtimeDefaultStyle:()=>Ya,realtimeDelayStyle:()=>Um,realtimeSimpleStyle:()=>$m,removeDuplicate:()=>Va,renderTrajectories:()=>Wh,routingStyle:()=>Ub,sortAndFilterDepartures:()=>Xh,sortByDelay:()=>$f});var aS=(h,e)=>{let r=new URL(h);return Object.entries(e||{}).forEach(([a,o])=>{o!=null&&r.searchParams.set(a,o)}),r},Na=aS;var Bf=class{constructor(e){this.url=e.url,this.apiKey=e.apiKey}async fetch(e,r,l){if(!this.url)throw new Error(`No url defined for request to ${this.url}/${e}`);if(!this.url&&!this.apiKey&&!/key=/.test(this.url))throw new Error(`No apiKey defined for request to ${this.url}`);let a=r||{},o=Na(`${this.url}${e||""}`,{key:this.apiKey,...a}),v=await(await fetch(o.toString(),l)).json();if(v.error)throw new Error(v.error);return v}},Id=Bf;var Nf=class extends Id{constructor(e={}){super({url:"https://api.geops.io/routing/v1/",...e})}route(e,r){return this.fetch("",e,r)}},bh=Nf;var Vf=class extends Id{constructor(e={}){super({url:"https://api.geops.io/stops/v1/",...e})}search(e,r){return this.fetch("",e,r)}},wh=Vf;var Gf=class h{constructor(){this.defineProperties()}defineProperties(){Object.defineProperties(this,{closed:{get:()=>!this.websocket||this.websocket.readyState===this.websocket.CLOSED},closing:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CLOSING)},connecting:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CONNECTING)},open:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.OPEN)},messagesOnOpen:{value:[],writable:!0},subscriptions:{value:[],writable:!0},subscribed:{value:{},writable:!0}})}static getRequestString(e,r={}){let l=`${e} ${r.channel}`;return l+=r.args?` ${r.args}`:"",l+=r.id?` ${r.id}`:"",l.trim()}connect(e,r=()=>{}){if(!e){this.websocket?.close();return}if(this.websocket){if(this.websocket.url===e&&(this.open||this.connecting))return;this.websocket.url!==e&&(this.open||this.connecting)&&this.websocket.close()}this.websocket=new WebSocket(e),this.open?(r(),this.subscribePreviousSubscriptions()):this.websocket.addEventListener("open",()=>{r(),this.subscribePreviousSubscriptions()})}close(){this.websocket&&(this.open||this.connecting)&&(this.websocket.onclose=()=>{},this.websocket.close(),this.messagesOnOpen=[])}send(e){if(!this.websocket||this.closed||this.closing)return;let r=()=>{this.websocket?.send(e)};this.open?this.messagesOnOpen.includes(e)||r():this.messagesOnOpen.includes(e)||(this.messagesOnOpen.push(e),this.websocket.addEventListener("open",()=>{this.messagesOnOpen=[],r()}),this.websocket.addEventListener("close",()=>{this.messagesOnOpen=[]}))}addEvents(e,r){this.websocket&&(this.websocket.addEventListener("message",e),r&&(this.websocket.addEventListener("error",r),this.websocket.addEventListener("close",r)))}removeEvents(e,r){this.websocket&&(this.websocket.removeEventListener("message",e),r&&(this.websocket.removeEventListener("error",r),this.websocket.removeEventListener("close",r)))}listen(e,r,l){this.unlisten(e,r);let a=o=>{let g;try{g=JSON.parse(o.data)}catch(T){console.error("WebSocket: unable to parse JSON data",T,o.data);return}let v=e.channel;v+=e.args?` ${e.args}`:"";let w;g.source==="buffer"?w=g.content:w=[g],w.forEach(T=>{T?.source===v&&(!e.id||e.id===g.client_reference)&&r(T)})};return this.addEvents(a,l),{onMessageCb:a,onErrorCb:l}}unlisten(e,r){[...this.subscriptions||[],...this.requests||[]].filter(l=>l.params.channel===e.channel&&(!r||l.cb===r)).forEach(({onMessageCb:l,onErrorCb:a})=>{this.removeEvents(l,a)})}get(e,r,l){let a=h.getRequestString("GET",e);this.send(a);let o=S=>(...k)=>{S(...k);let F=this.requests.findIndex(he=>a===he.requestString&&r===he.cb),{onMessageCb:j,onErrorCb:J}=this.requests[F];this.removeEvents(j,J),this.requests.splice(F,1)},{onMessageCb:g,onErrorCb:v}=this.listen(e,o(r),l&&o(l));this.requests||(this.requests=[]);let w=this.requests.findIndex(S=>a===S.requestString&&r===S.cb),T={params:e,requestString:a,cb:r,errorCb:l,onMessageCb:g,onErrorCb:v};w>-1?this.requests[w]=T:this.requests.push(T)}subscribe(e,r,l,a=!1){let{onMessageCb:o,onErrorCb:g}=this.listen(e,r,l),v=h.getRequestString("",e),w=this.subscriptions.findIndex(S=>e.channel===S.params.channel&&r===S.cb),T={params:e,cb:r,errorCb:l,onMessageCb:o,onErrorCb:g,quiet:a};w>-1?this.subscriptions[w]=T:this.subscriptions.push(T),this.subscribed[v]||(T.quiet||(this.send(`GET ${v}`),this.send(`SUB ${v}`)),this.subscribed[v]=!0)}unsubscribe(e,r){let l=this.subscriptions.filter(a=>a.params.channel===e&&(!r||a.cb===r));l.forEach(({onMessageCb:a,onErrorCb:o})=>{this.removeEvents(a,o)}),this.subscriptions=this.subscriptions.filter(a=>a.params.channel!==e||r&&a.cb!==r),e&&this.subscribed[e]&&!this.subscriptions.find(a=>a.params.channel===e)&&l.find(a=>!a.quiet)&&(this.send(`DEL ${e}`),this.subscribed[e]=!1)}subscribePreviousSubscriptions(){Object.keys(this.subscribed).forEach(e=>{this.subscribed[e]=!1}),[...this.subscriptions].forEach(e=>{this.subscribe(e.params,e.cb,e.errorCb,e.quiet)})}},L0=Gf;var lS=(h,e,r=100)=>{let l={},a={},o=[];return g=>{let{source:v,content:w}=g;l[v]&&window.clearTimeout(l[v]),e?a[e(w)]=w:o.push(w),l[v]=window.setTimeout(()=>{let T=e?Object.values(a):o;h(T)},r)}},Sh=lS;var cS=(h,e)=>h===e.SCHEMATIC?"_schematic":"",fs=cS;var Ki={RAW:"raw",TOPOGRAPHIC:"topographic",SCHEMATIC:"schematic"},jf=class{constructor(e={}){this.version="2";this.defineProperties(e),this.onOpen=this.onOpen.bind(this)}defineProperties(e={}){let r=e||{};typeof e=="string"&&(r={url:e});let{apiKey:l,version:a}=r,{url:o,bbox:g,buffer:v=[100,100]}=r,w=new L0;o||(o="wss://api.geops.io/tracker-ws/v1/"),l&&(o=`${o}?key=${l}`),Object.defineProperties(this,{url:{get:()=>o,set:T=>{o!==T&&(o=T,(this.wsApi.open||this.wsApi.connecting)&&this.open())}},bbox:{get:()=>g,set:T=>{JSON.stringify(T)!==JSON.stringify(g)&&(g=T,this.wsApi&&g&&this.wsApi.send(`BBOX ${g.join(" ")}`))}},buffer:{get:()=>v,set:T=>{JSON.stringify(T)!==JSON.stringify(v)&&(v=T,this.wsApi&&this.wsApi.send(`BUFFER ${v.join(" ")}`))}},version:{value:a,writable:!0},wsApi:{value:w,writable:!0},pingIntervalMs:{value:e.pingIntervalMs||1e4,writable:!0},reconnectTimeoutMs:{value:e.pingIntervalMs||100,writable:!0}})}open(){this.wsApi.connect(this.url,this.onOpen),this.wsApi.websocket&&(this.wsApi.websocket.onclose=()=>{this.onClose()})}close(){this.wsApi.close()}reset(){this.wsApi.send("RESET")}onOpen(){this.bbox&&this.wsApi.send(`BBOX ${this.bbox.join(" ")}`),this.buffer&&this.wsApi.send(`BUFFER ${this.buffer.join(" ")}`),this.pingIntervalMs&&(window.clearInterval(this.pingInterval),this.pingInterval=window.setInterval(()=>{this.wsApi.send("PING")},this.pingIntervalMs))}onClose(){window.clearTimeout(this.pingInterval),window.clearTimeout(this.reconnectTimeout),this.reconnectTimeoutMs&&(this.reconnectTimeout=window.setTimeout(()=>this.open(),this.reconnectTimeoutMs))}get(e){let r=e;return typeof e=="string"&&(r={channel:e}),new Promise((l,a)=>{this.wsApi.get(r,l,a)})}subscribe(e,r,l=()=>{},a=!1){!e||!r||this.wsApi.subscribe({channel:e},r,l,a)}unsubscribe(e,r="",l){let a=fs(Ki.SCHEMATIC,Ki),o=fs(Ki.TOPOGRAPHIC,Ki);this.wsApi.unsubscribe(`${e}${a}${r||""}`,l),this.wsApi.unsubscribe(`${e}${o}${r||""}`,l)}subscribeDepartures(e,r,l=()=>{},a=!1){this.subscribe(`timetable_${e}`,r,l,a)}unsubscribeDepartures(e,r){this.unsubscribe(`timetable_${e}`,"",r)}subscribeDisruptions(e,r,l=()=>{},a=!1){this.subscribe(`${e}_newsticker`,r,l,a)}unsubscribeDisruptions(e,r){this.unsubscribe(`${e}_newsticker`,"",r)}getStation(e,r){let l={channel:`station${fs(r,Ki)}`,args:e};return this.get(l)}getStations(e,r=100){return new Promise(l=>{this.get(`station${fs(e,Ki)}`).then(Sh(l,void 0,r))})}subscribeStations(e,r,l=()=>{},a=!1){this.subscribe(`station${fs(e,Ki)}`,r,l,a)}unsubscribeStations(e){this.unsubscribe("station","",e)}subscribeExtraGeoms(e,r=()=>{},l=!1){this.subscribe("extra_geoms",e,r,l)}unsubscribeExtraGeoms(e){this.unsubscribe("extra_geoms","",e)}getTrajectory(e,r){return this.get(`partial_trajectory${fs(r,Ki)}_${e}`)}subscribeTrajectory(e,r,l=()=>{},a=!1){this.unsubscribeTrajectory(r);let o="";this.version==="1"&&(o=fs(e,Ki)),this.subscribe(`trajectory${o}`,r,l,a)}unsubscribeTrajectory(e){this.unsubscribe("trajectory","",e)}subscribeDeletedVehicles(e,r,l=()=>{},a=!1){this.unsubscribeDeletedVehicles(r);let o="";this.version==="1"&&(o=fs(e,Ki)),this.subscribe(`deleted_vehicles${o}`,r,l,a)}unsubscribeDeletedVehicles(e){this.unsubscribe("deleted_vehicles","",e)}getFullTrajectory(e,r,l){let a="";this.version==="1"&&(a=fs(r,Ki));let o=[`full_trajectory${a}`];return e&&o.push(e),(!r||r===Ki.TOPOGRAPHIC)&&l&&o.push(`gen${l}`),this.get(o.join("_"))}subscribeFullTrajectory(e,r,l,a=()=>{},o=!1){let g="";this.version==="1"&&(g=fs(r,Ki)),this.subscribe(`full_trajectory${g}_${e}`,l,a,o)}unsubscribeFullTrajectory(e,r){this.unsubscribe("full_trajectory",`_${e}`,r)}getStopSequence(e){return this.get(`stopsequence_${e}`)}subscribeStopSequence(e,r,l=()=>{},a=!1){this.subscribe(`stopsequence_${e}`,r,l,a)}unsubscribeStopSequence(e,r){this.unsubscribe("stopsequence",`_${e}`,r)}subscribeHealthCheck(e,r=()=>{},l=!1){this.subscribe("healthcheck",e,r,l)}unsubscribeHealthCheck(e){this.unsubscribe("healthcheck","",e)}},Ch=jf;var hS=h=>{let e=h.filter(o=>o!=null&&o.trim&&o.trim()),r=e.map(o=>o.toLowerCase());return[...new Set(r)].map(o=>e.find(g=>g.toLowerCase()===o))},Va=hS;var uS=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,l=[];return Object.values(r).forEach(a=>{if(a.used){let o=a.getSource(),g=o.attribution||o.options&&o.options.attribution;g&&(l=l.concat(g.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),Va(l)},Ga=uS;var dS=(h,e,r,l)=>{let a=[];if(!h&&!e&&!r&&!l)return null;if(l){let o=typeof l=="string"?[l]:l,g=v=>{let w=v.properties.name||v.properties.line&&v.properties.line.name||"";return w?o.some(T=>new RegExp(T,"i").test(w)):!1};a.push(g)}if(h){let g=(typeof h=="string"?h.split(","):h).map(w=>w.replace(/\s+/g,"").toUpperCase()),v=w=>{let{line:T,name:S}=w.properties,k=(S||T&&T.name||"").toUpperCase();return k?g.includes(k):!1};a.push(v)}if(e){let g=(typeof e=="string"?e.split(","):e).map(w=>parseInt(w,10)),v=w=>{let T=w.properties.route_identifier||w.properties.routeIdentifier||"",S=parseInt(T.split(".")[0],10);return g.includes(S)};a.push(v)}if(r){let o=typeof r=="string"?[r]:r,g=v=>o.some(w=>{let T=v.properties.operator||v.properties.tenant||"";return new RegExp(w,"i").test(T)});a.push(g)}return a.length?o=>{for(let g=0;g<a.length;g+=1)if(!a[g](o))return!1;return!0}:null},Uf=dS;var D0=h=>{let e=h;Array.isArray(e)||(e=[h]);let r=[];return e.forEach(l=>{r.push(l);let a=l.children||l.get("children")||{};r=r.concat(D0(a||[]))}),r},ja=D0;var F0=(h=new Date)=>{let e=(h.getUTCMonth()+1).toString();e=e.length===1?`0${e}`:e;let r=h.getUTCDate().toString();return r=r.length===1?`0${r}`:r,[h.getUTCFullYear(),e,r].join("")},z0=h=>[h.getUTCHours(),h.getUTCMinutes(),`${h.getUTCSeconds()}.${h.getUTCMilliseconds()}`].join(":"),Ed=h=>h<10?`0${h}`:`${h}`,O0=h=>{if(!h||h<=0)return"";let e=new Date(h);return`${Ed(e.getHours())}:${Ed(e.getMinutes())}`};var pS=(h,e)=>{let r=h.properties,l=e.properties;return r.delay===null&&l.delay!==null?1:l.delay===null&&r.delay!==null?-1:r.cancelled&&!l.cancelled?l.delay<18e4?-1:1:l.cancelled&&!r.cancelled?r.delay<18e4?1:-1:l.delay-r.delay},$f=pS;function si(h,e){if(!h)throw new Error(e)}var EE=new Array(6);function mr(){return[1,0,0,1,0,0]}function fS(h,e,r,l,a,o,g){return h[0]=e,h[1]=r,h[2]=l,h[3]=a,h[4]=o,h[5]=g,h}function N0(h,e){return h[0]=e[0],h[1]=e[1],h[2]=e[2],h[3]=e[3],h[4]=e[4],h[5]=e[5],h}function rr(h,e){let r=e[0],l=e[1];return e[0]=h[0]*r+h[2]*l+h[4],e[1]=h[1]*r+h[3]*l+h[5],e}function V0(h,e,r){return fS(h,e,0,0,r,0,0)}function an(h,e,r,l,a,o,g,v){let w=Math.sin(o),T=Math.cos(o);return h[0]=l*T,h[1]=a*w,h[2]=-l*w,h[3]=a*T,h[4]=g*l*T-v*l*w+e,h[5]=g*a*w+v*a*T+r,h}function G0(h,e,r,l,a,o,g){return qf(an(mr(),h,e,r,l,a,o,g))}function j0(h,e){let r=mS(e);si(r!==0,"Transformation matrix cannot be inverted");let l=e[0],a=e[1],o=e[2],g=e[3],v=e[4],w=e[5];return h[0]=g/r,h[1]=-a/r,h[2]=-o/r,h[3]=l/r,h[4]=(o*w-g*v)/r,h[5]=-(l*w-a*v)/r,h}function mS(h){return h[0]*h[3]-h[1]*h[2]}var B0=[1e6,1e6,1e6,1e6,2,2];function qf(h){return"matrix("+h.map((r,l)=>Math.round(r*B0[l])/B0[l]).join(", ")+")"}var Wf=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var mi=Wf;var Td={PROPERTYCHANGE:"propertychange"};var Zf=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},U0=Zf;function $0(h,e,r){let l,a;r=r||Ds;let o=0,g=h.length,v=!1;for(;o<g;)l=o+(g-o>>1),a=+r(h[l],e),a<0?o=l+1:(g=l,v=!a);return v?o:~o}function Ds(h,e){return h>e?1:h<e?-1:0}function Md(h,e,r){if(h[0]<=e)return 0;let l=h.length;if(e<=h[l-1])return l-1;if(typeof r=="function"){for(let a=1;a<l;++a){let o=h[a];if(o===e)return a;if(o<e)return r(e,h[a-1],o)>0?a-1:a}return l-1}if(r>0){for(let a=1;a<l;++a)if(h[a]<e)return a-1;return l-1}if(r<0){for(let a=1;a<l;++a)if(h[a]<=e)return a;return l-1}for(let a=1;a<l;++a){if(h[a]==e)return a;if(h[a]<e)return h[a-1]-e<e-h[a]?a-1:a}return l-1}function q0(h,e,r){for(;e<r;){let l=h[e];h[e]=h[r],h[r]=l,++e,--r}}function kr(h,e){let r=Array.isArray(e)?e:[e],l=r.length;for(let a=0;a<l;a++)h[h.length]=r[a]}function vn(h,e){let r=h.length;if(r!==e.length)return!1;for(let l=0;l<r;l++)if(h[l]!==e[l])return!1;return!0}function Ad(){return!0}function ms(){}function Pd(h){let e=!1,r,l,a;return function(){let o=Array.prototype.slice.call(arguments);return(!e||this!==a||!vn(o,l))&&(e=!0,a=this,l=o,r=h.apply(this,arguments)),r}}function Yl(h){for(let e in h)delete h[e]}function qn(h){let e;for(e in h)return!1;return!e}var Xf=class extends U0{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,r){if(!e||!r)return;let l=this.listeners_||(this.listeners_={}),a=l[e]||(l[e]=[]);a.includes(r)||a.push(r)}dispatchEvent(e){let r=typeof e=="string",l=r?e:e.type,a=this.listeners_&&this.listeners_[l];if(!a)return;let o=r?new mi(e):e;o.target||(o.target=this.eventTarget_||this);let g=this.dispatching_||(this.dispatching_={}),v=this.pendingRemovals_||(this.pendingRemovals_={});l in g||(g[l]=0,v[l]=0),++g[l];let w;for(let T=0,S=a.length;T<S;++T)if("handleEvent"in a[T]?w=a[T].handleEvent(o):w=a[T].call(this,o),w===!1||o.propagationStopped){w=!1;break}if(--g[l]===0){let T=v[l];for(delete v[l];T--;)this.removeEventListener(l,ms);delete g[l]}return w}disposeInternal(){this.listeners_&&Yl(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,r){if(!this.listeners_)return;let l=this.listeners_[e];if(!l)return;let a=l.indexOf(r);a!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(l[a]=ms,++this.pendingRemovals_[e]):(l.splice(a,1),l.length===0&&delete this.listeners_[e]))}},Rd=Xf;var li={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function Lr(h,e,r,l,a){if(l&&l!==h&&(r=r.bind(l)),a){let g=r;r=function(){h.removeEventListener(e,r),g.apply(this,arguments)}}let o={target:h,type:e,listener:r};return h.addEventListener(e,r),o}function Hf(h,e,r,l){return Lr(h,e,r,l,!0)}function Yr(h){h&&h.target&&(h.target.removeEventListener(h.type,h.listener),Yl(h))}var Kl=class extends Rd{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(li.CHANGE)}getRevision(){return this.revision_}onInternal(e,r){if(Array.isArray(e)){let l=e.length,a=new Array(l);for(let o=0;o<l;++o)a[o]=Lr(this,e[o],r);return a}return Lr(this,e,r)}onceInternal(e,r){let l;if(Array.isArray(e)){let a=e.length;l=new Array(a);for(let o=0;o<a;++o)l[o]=Hf(this,e[o],r)}else l=Hf(this,e,r);return r.ol_key=l,l}unInternal(e,r){let l=r.ol_key;if(l)Ih(l);else if(Array.isArray(e))for(let a=0,o=e.length;a<o;++a)this.removeEventListener(e[a],r);else this.removeEventListener(e,r)}};Kl.prototype.on;Kl.prototype.once;Kl.prototype.un;function Ih(h){if(Array.isArray(h))for(let e=0,r=h.length;e<r;++e)Yr(h[e]);else Yr(h)}var kd=Kl;function St(){throw new Error("Unimplemented abstract method.")}var gS=0;function Gt(h){return h.ol_uid||(h.ol_uid=String(++gS))}var Ld=class extends mi{constructor(e,r,l){super(e),this.key=r,this.oldValue=l}},Yf=class extends kd{constructor(e){super(),this.on,this.once,this.un,Gt(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let r;return this.values_&&this.values_.hasOwnProperty(e)&&(r=this.values_[e]),r}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,r){let l;l=`change:${e}`,this.hasListener(l)&&this.dispatchEvent(new Ld(l,e,r)),l=Td.PROPERTYCHANGE,this.hasListener(l)&&this.dispatchEvent(new Ld(l,e,r))}addChangeListener(e,r){this.addEventListener(`change:${e}`,r)}removeChangeListener(e,r){this.removeEventListener(`change:${e}`,r)}set(e,r,l){let a=this.values_||(this.values_={});if(l)a[e]=r;else{let o=a[e];a[e]=r,o!==r&&this.notify(e,o)}}setProperties(e,r){for(let l in e)this.set(l,e[l],r)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,r){if(this.values_&&e in this.values_){let l=this.values_[e];delete this.values_[e],qn(this.values_)&&(this.values_=null),r||this.notify(e,l)}}},gr=Yf;var Ji={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function Fs(h){let e=Sn();for(let r=0,l=h.length;r<l;++r)Kf(e,h[r]);return e}function yS(h,e,r){let l=Math.min.apply(null,h),a=Math.min.apply(null,e),o=Math.max.apply(null,h),g=Math.max.apply(null,e);return yo(l,a,o,g,r)}function bn(h,e,r){return r?(r[0]=h[0]-e,r[1]=h[1]-e,r[2]=h[2]+e,r[3]=h[3]+e,r):[h[0]-e,h[1]-e,h[2]+e,h[3]+e]}function W0(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h.slice()}function wn(h,e,r){let l,a;return e<h[0]?l=h[0]-e:h[2]<e?l=e-h[2]:l=0,r<h[1]?a=h[1]-r:h[3]<r?a=r-h[3]:a=0,l*l+a*a}function mo(h,e){return Eh(h,e[0],e[1])}function go(h,e){return h[0]<=e[0]&&e[2]<=h[2]&&h[1]<=e[1]&&e[3]<=h[3]}function Eh(h,e,r){return h[0]<=e&&e<=h[2]&&h[1]<=r&&r<=h[3]}function Dd(h,e){let r=h[0],l=h[1],a=h[2],o=h[3],g=e[0],v=e[1],w=Ji.UNKNOWN;return g<r?w=w|Ji.LEFT:g>a&&(w=w|Ji.RIGHT),v<l?w=w|Ji.BELOW:v>o&&(w=w|Ji.ABOVE),w===Ji.UNKNOWN&&(w=Ji.INTERSECTING),w}function Sn(){return[1/0,1/0,-1/0,-1/0]}function yo(h,e,r,l,a){return a?(a[0]=h,a[1]=e,a[2]=r,a[3]=l,a):[h,e,r,l]}function Jl(h){return yo(1/0,1/0,-1/0,-1/0,h)}function Yo(h,e){let r=h[0],l=h[1];return yo(r,l,r,l,e)}function Ql(h,e,r,l,a){let o=Jl(a);return Jf(o,h,e,r,l)}function Fd(h,e){return h[0]==e[0]&&h[2]==e[2]&&h[1]==e[1]&&h[3]==e[3]}function Z0(h,e){return e[0]<h[0]&&(h[0]=e[0]),e[2]>h[2]&&(h[2]=e[2]),e[1]<h[1]&&(h[1]=e[1]),e[3]>h[3]&&(h[3]=e[3]),h}function Kf(h,e){e[0]<h[0]&&(h[0]=e[0]),e[0]>h[2]&&(h[2]=e[0]),e[1]<h[1]&&(h[1]=e[1]),e[1]>h[3]&&(h[3]=e[1])}function Jf(h,e,r,l,a){for(;r<l;r+=a)_S(h,e[r],e[r+1]);return h}function _S(h,e,r){h[0]=Math.min(h[0],e),h[1]=Math.min(h[1],r),h[2]=Math.max(h[2],e),h[3]=Math.max(h[3],r)}function X0(h,e){let r;return r=e(Qf(h)),r||(r=e(em(h)),r)||(r=e(im(h)),r)||(r=e(tm(h)),r)?r:!1}function Qf(h){return[h[0],h[1]]}function em(h){return[h[2],h[1]]}function es(h){return[(h[0]+h[2])/2,(h[1]+h[3])/2]}function H0(h,e,r,l,a){let[o,g,v,w,T,S,k,F]=xS(h,e,r,l);return yo(Math.min(o,v,T,k),Math.min(g,w,S,F),Math.max(o,v,T,k),Math.max(g,w,S,F),a)}function xS(h,e,r,l){let a=e*l[0]/2,o=e*l[1]/2,g=Math.cos(r),v=Math.sin(r),w=a*g,T=a*v,S=o*g,k=o*v,F=h[0],j=h[1];return[F-w+k,j-T-S,F-w-k,j-T+S,F+w-k,j+T+S,F+w+k,j+T-S,F-w+k,j-T-S]}function ln(h){return h[3]-h[1]}function tm(h){return[h[0],h[3]]}function im(h){return[h[2],h[3]]}function $i(h){return h[2]-h[0]}function Qi(h,e){return h[0]<=e[2]&&h[2]>=e[0]&&h[1]<=e[3]&&h[3]>=e[1]}function Th(h){return h[2]<h[0]||h[3]<h[1]}function Y0(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h}function K0(h,e,r){let l=!1,a=Dd(h,e),o=Dd(h,r);if(a===Ji.INTERSECTING||o===Ji.INTERSECTING)l=!0;else{let g=h[0],v=h[1],w=h[2],T=h[3],S=e[0],k=e[1],F=r[0],j=r[1],J=(j-k)/(F-S),he,q;o&Ji.ABOVE&&!(a&Ji.ABOVE)&&(he=F-(j-T)/J,l=he>=g&&he<=w),!l&&o&Ji.RIGHT&&!(a&Ji.RIGHT)&&(q=j-(F-w)*J,l=q>=v&&q<=T),!l&&o&Ji.BELOW&&!(a&Ji.BELOW)&&(he=F-(j-v)/J,l=he>=g&&he<=w),!l&&o&Ji.LEFT&&!(a&Ji.LEFT)&&(q=j-(F-g)*J,l=q>=v&&q<=T)}return l}function J0(h,e,r,l){if(Th(h))return Jl(r);let a=[];if(l>1){let v=h[2]-h[0],w=h[3]-h[1];for(let T=0;T<l;++T)a.push(h[0]+v*T/l,h[1],h[2],h[1]+w*T/l,h[2]-v*T/l,h[3],h[0],h[3]-w*T/l)}else a=[h[0],h[1],h[2],h[1],h[2],h[3],h[0],h[3]];e(a,a,2);let o=[],g=[];for(let v=0,w=a.length;v<w;v+=2)o.push(a[v]),g.push(a[v+1]);return yS(o,g,r)}function rm(h,e){let r=e.getExtent(),l=es(h);if(e.canWrapX()&&(l[0]<r[0]||l[0]>=r[2])){let a=$i(r),g=Math.floor((l[0]-r[0])/a)*a;h[0]-=g,h[2]-=g}return h}function Q0(h,e){if(e.canWrapX()){let r=e.getExtent();if(!isFinite(h[0])||!isFinite(h[2]))return[[r[0],h[1],r[2],h[3]]];rm(h,e);let l=$i(r);if($i(h)>l)return[[r[0],h[1],r[2],h[3]]];if(h[0]<r[0])return[[h[0]+l,h[1],r[2],h[3]],[r[0],h[1],h[2],h[3]]];if(h[2]>r[2])return[[h[0],h[1],r[2],h[3]],[r[0],h[1],h[2]-l,h[3]]]}return[h]}var Mh={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var nm=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Mh[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},zd=nm;var Ah=6378137,ec=Math.PI*Ah,vS=[-ec,-ec,ec,ec],bS=[-180,-85,180,85],Od=Ah*Math.log(Math.tan(Math.PI/2)),Ko=class extends zd{constructor(e){super({code:e,units:"m",extent:vS,global:!0,worldExtent:bS,getPointResolution:function(r,l){return r/Math.cosh(l[1]/Ah)}})}},sm=[new Ko("EPSG:3857"),new Ko("EPSG:102100"),new Ko("EPSG:102113"),new Ko("EPSG:900913"),new Ko("http://www.opengis.net/def/crs/EPSG/0/3857"),new Ko("http://www.opengis.net/gml/srs/epsg.xml#3857")];function ex(h,e,r){let l=h.length;r=r>1?r:2,e===void 0&&(r>2?e=h.slice():e=new Array(l));for(let a=0;a<l;a+=r){e[a]=ec*h[a]/180;let o=Ah*Math.log(Math.tan(Math.PI*(+h[a+1]+90)/360));o>Od?o=Od:o<-Od&&(o=-Od),e[a+1]=o}return e}function tx(h,e,r){let l=h.length;r=r>1?r:2,e===void 0&&(r>2?e=h.slice():e=new Array(l));for(let a=0;a<l;a+=r)e[a]=180*h[a]/ec,e[a+1]=360*Math.atan(Math.exp(h[a+1]/Ah))/Math.PI-90;return e}var wS=6378137,ix=[-180,-90,180,90],SS=Math.PI*wS/180,_o=class extends zd{constructor(e,r){super({code:e,units:"degrees",extent:ix,axisOrientation:r,global:!0,metersPerUnit:SS,worldExtent:ix})}},om=[new _o("CRS:84"),new _o("EPSG:4326","neu"),new _o("urn:ogc:def:crs:OGC:1.3:CRS84"),new _o("urn:ogc:def:crs:OGC:2:84"),new _o("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new _o("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new _o("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var am={};function rx(h){return am[h]||am[h.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function nx(h,e){am[h]=e}var tc={};function Ph(h,e,r){let l=h.getCode(),a=e.getCode();l in tc||(tc[l]={}),tc[l][a]=r}function sx(h,e){let r;return h in tc&&e in tc[h]&&(r=tc[h][e]),r}function Ii(h,e,r){return Math.min(Math.max(h,e),r)}function ox(h,e,r,l,a,o){let g=a-r,v=o-l;if(g!==0||v!==0){let w=((h-r)*g+(e-l)*v)/(g*g+v*v);w>1?(r=a,l=o):w>0&&(r+=g*w,l+=v*w)}return gs(h,e,r,l)}function gs(h,e,r,l){let a=r-h,o=l-e;return a*a+o*o}function ax(h){return h*180/Math.PI}function lx(h){return h*Math.PI/180}function Ua(h,e){let r=h%e;return r*e<0?r+e:r}function Dr(h,e,r){return h+r*(e-h)}function cx(h,e){let r=Math.pow(10,e);return Math.round(h*r)/r}function hx(h,e){return h[0]+=+e[0],h[1]+=+e[1],h}function lm(h,e){let r=h[0],l=h[1],a=e[0],o=e[1],g=a[0],v=a[1],w=o[0],T=o[1],S=w-g,k=T-v,F=S===0&&k===0?0:(S*(r-g)+k*(l-v))/(S*S+k*k||0),j,J;return F<=0?(j=g,J=v):F>=1?(j=w,J=T):(j=g+F*S,J=v+F*k),[j,J]}function cn(h,e){let r=!0;for(let l=h.length-1;l>=0;--l)if(h[l]!=e[l]){r=!1;break}return r}function ux(h,e){let r=Math.cos(e),l=Math.sin(e),a=h[0]*r-h[1]*l,o=h[1]*r+h[0]*l;return h[0]=a,h[1]=o,h}function ic(h,e){let r=h[0]-e[0],l=h[1]-e[1];return r*r+l*l}function cm(h,e){return Math.sqrt(ic(h,e))}function dx(h,e){return ic(h,lm(h,e))}function px(h,e){if(e.canWrapX()){let r=$i(e.getExtent()),l=fx(h,e,r);l&&(h[0]-=l*r)}return h}function fx(h,e,r){let l=e.getExtent(),a=0;return e.canWrapX()&&(h[0]<l[0]||h[0]>l[2])&&(r=r||$i(l),a=Math.floor((h[0]-l[0])/r)),a}var mx={info:1,warn:2,error:3,none:4},CS=mx.info;function gx(...h){CS>mx.warn||console.warn(...h)}var hm=!0;function um(h){hm=!(h===void 0?!0:h)}function dm(h,e){if(e!==void 0){for(let r=0,l=h.length;r<l;++r)e[r]=h[r];e=e}else e=h.slice();return e}function IS(h,e){if(e!==void 0&&h!==e){for(let r=0,l=h.length;r<l;++r)e[r]=h[r];h=e}return h}function ES(h){nx(h.getCode(),h),Ph(h,h,dm)}function TS(h){h.forEach(ES)}function qi(h){return typeof h=="string"?rx(h):h||null}function yx(h){TS(h),h.forEach(function(e){h.forEach(function(r){e!==r&&Ph(e,r,dm)})})}function MS(h,e,r,l){h.forEach(function(a){e.forEach(function(o){Ph(a,o,r),Ph(o,a,l)})})}function Bd(h,e){return h?typeof h=="string"?qi(h):h:qi(e)}function yr(h,e){return um(),Nd(h,"EPSG:4326",e!==void 0?e:"EPSG:3857")}function $a(h,e){let r=Nd(h,e!==void 0?e:"EPSG:3857","EPSG:4326"),l=r[0];return(l<-180||l>180)&&(r[0]=Ua(l+180,360)-180),r}function _x(h,e){if(h===e)return!0;let r=h.getUnits()===e.getUnits();return(h.getCode()===e.getCode()||rc(h,e)===dm)&&r}function rc(h,e){let r=h.getCode(),l=e.getCode(),a=sx(r,l);return a||(a=IS),a}function qa(h,e){let r=qi(h),l=qi(e);return rc(r,l)}function Nd(h,e,r){return qa(e,r)(h,void 0,h.length)}function Rh(h,e,r,l){let a=qa(e,r);return J0(h,a,void 0,l)}var ys=null;function Wn(){return ys}function Wa(h,e){return ys?Nd(h,e,ys):h}function er(h,e){return ys?Nd(h,ys,e):(hm&&!cn(h,[0,0])&&h[0]>=-180&&h[0]<=180&&h[1]>=-90&&h[1]<=90&&(hm=!1,gx("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),h)}function zs(h,e){return ys?Rh(h,e,ys):h}function Os(h,e){return ys?Rh(h,ys,e):h}function xx(h,e){if(!ys)return h;let r=qi(e).getMetersPerUnit(),l=ys.getMetersPerUnit();return r&&l?h*r/l:h}function AS(){yx(sm),yx(om),MS(om,sm,ex,tx)}AS();function Cn(h,e,r,l,a,o){o=o||[];let g=0;for(let v=e;v<r;v+=l){let w=h[v],T=h[v+1];o[g++]=a[0]*w+a[2]*T+a[4],o[g++]=a[1]*w+a[3]*T+a[5]}return o&&o.length!=g&&(o.length=g),o}function Vd(h,e,r,l,a,o,g){g=g||[];let v=Math.cos(a),w=Math.sin(a),T=o[0],S=o[1],k=0;for(let F=e;F<r;F+=l){let j=h[F]-T,J=h[F+1]-S;g[k++]=T+j*v-J*w,g[k++]=S+j*w+J*v;for(let he=F+2;he<F+l;++he)g[k++]=h[he]}return g&&g.length!=k&&(g.length=k),g}function vx(h,e,r,l,a,o,g,v){v=v||[];let w=g[0],T=g[1],S=0;for(let k=e;k<r;k+=l){let F=h[k]-w,j=h[k+1]-T;v[S++]=w+a*F,v[S++]=T+o*j;for(let J=k+2;J<k+l;++J)v[S++]=h[J]}return v&&v.length!=S&&(v.length=S),v}function bx(h,e,r,l,a,o,g){g=g||[];let v=0;for(let w=e;w<r;w+=l){g[v++]=h[w]+a,g[v++]=h[w+1]+o;for(let T=w+2;T<w+l;++T)g[v++]=h[T]}return g&&g.length!=v&&(g.length=v),g}var wx=mr(),pm=class extends gr{constructor(){super(),this.extent_=Sn(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=Pd((e,r,l)=>{if(!l)return this.getSimplifiedGeometry(r);let a=this.clone();return a.applyTransform(l),a.getSimplifiedGeometry(r)})}simplifyTransformed(e,r){return this.simplifyTransformedInternal(this.getRevision(),e,r)}clone(){return St()}closestPointXY(e,r,l,a){return St()}containsXY(e,r){let l=this.getClosestPoint([e,r]);return l[0]===e&&l[1]===r}getClosestPoint(e,r){return r=r||[NaN,NaN],this.closestPointXY(e[0],e[1],r,1/0),r}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return St()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let r=this.computeExtent(this.extent_);(isNaN(r[0])||isNaN(r[1]))&&Jl(r),this.extentRevision_=this.getRevision()}return Y0(this.extent_,e)}rotate(e,r){St()}scale(e,r,l){St()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return St()}getType(){return St()}applyTransform(e){St()}intersectsExtent(e){return St()}translate(e,r){St()}transform(e,r){let l=qi(e),a=l.getUnits()=="tile-pixels"?function(o,g,v){let w=l.getExtent(),T=l.getWorldExtent(),S=ln(T)/ln(w);return an(wx,T[0],T[3],S,-S,0,0,0),Cn(o,0,o.length,v,wx,g),qa(l,r)(o,g,v)}:qa(l,r);return this.applyTransform(a),this}},Gd=pm;var fm=class extends Gd{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return Ql(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return St()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=this.getSimplifiedGeometryInternal(e);return r.getFlatCoordinates().length<this.flatCoordinates.length?r:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,r){this.stride=Sx(e),this.layout=e,this.flatCoordinates=r}setCoordinates(e,r){St()}setLayout(e,r,l){let a;if(e)a=Sx(e);else{for(let o=0;o<l;++o){if(r.length===0){this.layout="XY",this.stride=2;return}r=r[0]}a=r.length,e=Jo(a)}this.layout=e,this.stride=a}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.stride),this.changed())}rotate(e,r){let l=this.getFlatCoordinates();if(l){let a=this.getStride();Vd(l,0,l.length,a,e,r,l),this.changed()}}scale(e,r,l){r===void 0&&(r=e),l||(l=es(this.getExtent()));let a=this.getFlatCoordinates();if(a){let o=this.getStride();vx(a,0,a.length,o,e,r,l,a),this.changed()}}translate(e,r){let l=this.getFlatCoordinates();if(l){let a=this.getStride();bx(l,0,l.length,a,e,r,l),this.changed()}}};function Jo(h){let e;return h==2?e="XY":h==3?e="XYZ":h==4&&(e="XYZM"),e}function Sx(h){let e;return h=="XY"?e=2:h=="XYZ"||h=="XYM"?e=3:h=="XYZM"&&(e=4),e}function Cx(h,e,r){let l=h.getFlatCoordinates();if(!l)return null;let a=h.getStride();return Cn(l,0,l.length,a,e,r)}var In=fm;function Ix(h,e,r,l){for(let a=0,o=r.length;a<o;++a)h[e++]=r[a];return e}function Za(h,e,r,l){for(let a=0,o=r.length;a<o;++a){let g=r[a];for(let v=0;v<l;++v)h[e++]=g[v]}return e}function Qo(h,e,r,l,a){a=a||[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=Za(h,e,r[g],l);a[o++]=w,e=w}return a.length=o,a}function jd(h,e,r,l,a){a=a||[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=Qo(h,e,r[g],l,a[o]);w.length===0&&(w[0]=e),a[o++]=w,e=w[w.length-1]}return a.length=o,a}var gm=class h extends Gd{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(Yr),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let r=0,l=e.length;r<l;++r)this.changeEventsKeys_.push(Lr(e[r],li.CHANGE,this.changed,this))}clone(){let e=new h(mm(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,r,l,a){if(a<wn(this.getExtent(),e,r))return a;let o=this.geometries_;for(let g=0,v=o.length;g<v;++g)a=o[g].closestPointXY(e,r,l,a);return a}containsXY(e,r){let l=this.geometries_;for(let a=0,o=l.length;a<o;++a)if(l[a].containsXY(e,r))return!0;return!1}computeExtent(e){Jl(e);let r=this.geometries_;for(let l=0,a=r.length;l<a;++l)Z0(e,r[l].getExtent());return e}getGeometries(){return mm(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[],r=this.geometries_;for(let l=0,a=r.length;l<a;++l)r[l].getType()===this.getType()?e=e.concat(r[l].getGeometriesArrayRecursive()):e.push(r[l]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=[],l=this.geometries_,a=!1;for(let o=0,g=l.length;o<g;++o){let v=l[o],w=v.getSimplifiedGeometry(e);r.push(w),w!==v&&(a=!0)}return a?new h(r):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){let r=this.geometries_;for(let l=0,a=r.length;l<a;++l)if(r[l].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,r){let l=this.geometries_;for(let a=0,o=l.length;a<o;++a)l[a].rotate(e,r);this.changed()}scale(e,r,l){l||(l=es(this.getExtent()));let a=this.geometries_;for(let o=0,g=a.length;o<g;++o)a[o].scale(e,r,l);this.changed()}setGeometries(e){this.setGeometriesArray(mm(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){let r=this.geometries_;for(let l=0,a=r.length;l<a;++l)r[l].applyTransform(e);this.changed()}translate(e,r){let l=this.geometries_;for(let a=0,o=l.length;a<o;++a)l[a].translate(e,r);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function mm(h){return h.map(e=>e.clone())}var ym=gm;function Ex(h,e,r,l,a,o,g){let v=h[e],w=h[e+1],T=h[r]-v,S=h[r+1]-w,k;if(T===0&&S===0)k=e;else{let F=((a-v)*T+(o-w)*S)/(T*T+S*S);if(F>1)k=r;else if(F>0){for(let j=0;j<l;++j)g[j]=Dr(h[e+j],h[r+j],F);g.length=l;return}else k=e}for(let F=0;F<l;++F)g[F]=h[k+F];g.length=l}function kh(h,e,r,l,a){let o=h[e],g=h[e+1];for(e+=l;e<r;e+=l){let v=h[e],w=h[e+1],T=gs(o,g,v,w);T>a&&(a=T),o=v,g=w}return a}function Lh(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];a=kh(h,e,v,l,a),e=v}return a}function Tx(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];a=Lh(h,e,v,l,a),e=v[v.length-1]}return a}function Dh(h,e,r,l,a,o,g,v,w,T,S){if(e==r)return T;let k,F;if(a===0){if(F=gs(g,v,h[e],h[e+1]),F<T){for(k=0;k<l;++k)w[k]=h[e+k];return w.length=l,F}return T}S=S||[NaN,NaN];let j=e+l;for(;j<r;)if(Ex(h,j-l,j,l,g,v,S),F=gs(g,v,S[0],S[1]),F<T){for(T=F,k=0;k<l;++k)w[k]=S[k];w.length=l,j+=l}else j+=l*Math.max((Math.sqrt(F)-Math.sqrt(T))/a|0,1);if(o&&(Ex(h,r-l,e,l,g,v,S),F=gs(g,v,S[0],S[1]),F<T)){for(T=F,k=0;k<l;++k)w[k]=S[k];w.length=l}return T}function Fh(h,e,r,l,a,o,g,v,w,T,S){S=S||[NaN,NaN];for(let k=0,F=r.length;k<F;++k){let j=r[k];T=Dh(h,e,j,l,a,o,g,v,w,T,S),e=j}return T}function Mx(h,e,r,l,a,o,g,v,w,T,S){S=S||[NaN,NaN];for(let k=0,F=r.length;k<F;++k){let j=r[k];T=Fh(h,e,j,l,a,o,g,v,w,T,S),e=j[j.length-1]}return T}function Xa(h,e,r,l,a,o,g){let v=(r-e)/l;if(v<3){for(;e<r;e+=l)o[g++]=h[e],o[g++]=h[e+1];return g}let w=new Array(v);w[0]=1,w[v-1]=1;let T=[e,r-l],S=0;for(;T.length>0;){let k=T.pop(),F=T.pop(),j=0,J=h[F],he=h[F+1],q=h[k],Z=h[k+1];for(let ne=F+l;ne<k;ne+=l){let me=h[ne],_e=h[ne+1],fe=ox(me,_e,J,he,q,Z);fe>j&&(S=ne,j=fe)}j>a&&(w[(S-e)/l]=1,F+l<S&&T.push(F,S),S+l<k&&T.push(S,k))}for(let k=0;k<v;++k)w[k]&&(o[g++]=h[e+k*l],o[g++]=h[e+k*l+1]);return g}function Ud(h,e,r,l,a,o,g,v){for(let w=0,T=r.length;w<T;++w){let S=r[w];g=Xa(h,e,S,l,a,o,g),v.push(g),e=S}return g}function ea(h,e){return e*Math.round(h/e)}function PS(h,e,r,l,a,o,g){if(e==r)return g;let v=ea(h[e],a),w=ea(h[e+1],a);e+=l,o[g++]=v,o[g++]=w;let T,S;do if(T=ea(h[e],a),S=ea(h[e+1],a),e+=l,e==r)return o[g++]=T,o[g++]=S,g;while(T==v&&S==w);for(;e<r;){let k=ea(h[e],a),F=ea(h[e+1],a);if(e+=l,k==T&&F==S)continue;let j=T-v,J=S-w,he=k-v,q=F-w;if(j*q==J*he&&(j<0&&he<j||j==he||j>0&&he>j)&&(J<0&&q<J||J==q||J>0&&q>J)){T=k,S=F;continue}o[g++]=T,o[g++]=S,v=T,w=S,T=k,S=F}return o[g++]=T,o[g++]=S,g}function zh(h,e,r,l,a,o,g,v){for(let w=0,T=r.length;w<T;++w){let S=r[w];g=PS(h,e,S,l,a,o,g),v.push(g),e=S}return g}function Ax(h,e,r,l,a,o,g,v){for(let w=0,T=r.length;w<T;++w){let S=r[w],k=[];g=zh(h,e,S,l,a,o,g,k),v.push(k),e=S[S.length-1]}return g}function ts(h,e,r,l,a){a=a!==void 0?a:[];let o=0;for(let g=e;g<r;g+=l)a[o++]=h.slice(g,g+l);return a.length=o,a}function ta(h,e,r,l,a){a=a!==void 0?a:[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=r[g];a[o++]=ts(h,e,w,l,a[o]),e=w}return a.length=o,a}function Oh(h,e,r,l,a){a=a!==void 0?a:[];let o=0;for(let g=0,v=r.length;g<v;++g){let w=r[g];a[o++]=w.length===1&&w[0]===e?[]:ta(h,e,w,l,a[o]),e=w[w.length-1]}return a.length=o,a}function _m(h,e,r,l){let a=0,o=h[r-l],g=h[r-l+1];for(;e<r;e+=l){let v=h[e],w=h[e+1];a+=g*v-o*w,o=v,g=w}return a/2}function xm(h,e,r,l){let a=0;for(let o=0,g=r.length;o<g;++o){let v=r[o];a+=_m(h,e,v,l),e=v}return a}function Px(h,e,r,l){let a=0;for(let o=0,g=r.length;o<g;++o){let v=r[o];a+=xm(h,e,v,l),e=v[v.length-1]}return a}var vm=class h extends In{constructor(e,r){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}clone(){return new h(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Dh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,r,l,a))}getArea(){return _m(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return ts(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){let r=[];return r.length=Xa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Za(this.flatCoordinates,0,e,this.stride),this.changed()}},bm=vm;function $d(h,e,r,l,a){let o;for(e+=l;e<r;e+=l)if(o=a(h.slice(e-l,e),h.slice(e,e+l)),o)return o;return!1}function Ha(h,e,r,l,a,o,g){let v,w,T=(r-e)/l;if(T===1)v=e;else if(T===2)v=e,w=a;else if(T!==0){let S=h[e],k=h[e+1],F=0,j=[0];for(let q=e+l;q<r;q+=l){let Z=h[q],ne=h[q+1];F+=Math.sqrt((Z-S)*(Z-S)+(ne-k)*(ne-k)),j.push(F),S=Z,k=ne}let J=a*F,he=$0(j,J);he<0?(w=(J-j[-he-2])/(j[-he-1]-j[-he-2]),v=e+(-he-2)*l):v=e+he*l}g=g>1?g:2,o=o||new Array(g);for(let S=0;S<g;++S)o[S]=v===void 0?NaN:w===void 0?h[v+S]:Dr(h[v+S],h[v+l+S],w);return o}function qd(h,e,r,l,a,o){if(r==e)return null;let g;if(a<h[e+l-1])return o?(g=h.slice(e,e+l),g[l-1]=a,g):null;if(h[r-1]<a)return o?(g=h.slice(r-l,r),g[l-1]=a,g):null;if(a==h[e+l-1])return h.slice(e,e+l);let v=e/l,w=r/l;for(;v<w;){let F=v+w>>1;a<h[(F+1)*l-1]?w=F:v=F+1}let T=h[v*l-1];if(a==T)return h.slice((v-1)*l,(v-1)*l+l);let S=h[(v+1)*l-1],k=(a-T)/(S-T);g=[];for(let F=0;F<l-1;++F)g.push(Dr(h[(v-1)*l+F],h[v*l+F],k));return g.push(a),g}function Rx(h,e,r,l,a,o,g){if(g)return qd(h,e,r[r.length-1],l,a,o);let v;if(a<h[l-1])return o?(v=h.slice(0,l),v[l-1]=a,v):null;if(h[h.length-1]<a)return o?(v=h.slice(h.length-l),v[l-1]=a,v):null;for(let w=0,T=r.length;w<T;++w){let S=r[w];if(e!=S){if(a<h[e+l-1])return null;if(a<=h[S-1])return qd(h,e,S,l,a,!1);e=S}}return null}function kx(h,e,r,l,a){return!X0(a,function(g){return!ia(h,e,r,l,g[0],g[1])})}function ia(h,e,r,l,a,o){let g=0,v=h[r-l],w=h[r-l+1];for(;e<r;e+=l){let T=h[e],S=h[e+1];w<=o?S>o&&(T-v)*(o-w)-(a-v)*(S-w)>0&&g++:S<=o&&(T-v)*(o-w)-(a-v)*(S-w)<0&&g--,v=T,w=S}return g!==0}function Bh(h,e,r,l,a,o){if(r.length===0||!ia(h,e,r[0],l,a,o))return!1;for(let g=1,v=r.length;g<v;++g)if(ia(h,r[g-1],r[g],l,a,o))return!1;return!0}function Lx(h,e,r,l,a,o){if(r.length===0)return!1;for(let g=0,v=r.length;g<v;++g){let w=r[g];if(Bh(h,e,w,l,a,o))return!0;e=w[w.length-1]}return!1}function Nh(h,e,r,l,a){let o=Jf(Sn(),h,e,r,l);return Qi(a,o)?go(a,o)||o[0]>=a[0]&&o[2]<=a[2]||o[1]>=a[1]&&o[3]<=a[3]?!0:$d(h,e,r,l,function(g,v){return K0(a,g,v)}):!1}function Dx(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){if(Nh(h,e,r[o],l,a))return!0;e=r[o]}return!1}function RS(h,e,r,l,a){return!!(Nh(h,e,r,l,a)||ia(h,e,r,l,a[0],a[1])||ia(h,e,r,l,a[0],a[3])||ia(h,e,r,l,a[2],a[1])||ia(h,e,r,l,a[2],a[3]))}function wm(h,e,r,l,a){if(!RS(h,e,r[0],l,a))return!1;if(r.length===1)return!0;for(let o=1,g=r.length;o<g;++o)if(kx(h,r[o-1],r[o],l,a)&&!Nh(h,r[o-1],r[o],l,a))return!1;return!0}function Fx(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];if(wm(h,e,v,l,a))return!0;e=v[v.length-1]}return!1}function Wd(h,e,r,l){let a=h[e],o=h[e+1],g=0;for(let v=e+l;v<r;v+=l){let w=h[v],T=h[v+1];g+=Math.sqrt((w-a)*(w-a)+(T-o)*(T-o)),a=w,o=T}return g}var Sm=class h extends In{constructor(e,r){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendCoordinate(e){kr(this.flatCoordinates,e),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(kh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Dh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,r,l,a))}forEachSegment(e){return $d(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,r){return this.layout!="XYM"&&this.layout!="XYZM"?null:(r=r!==void 0?r:!1,qd(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r))}getCoordinates(){return ts(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,r){return Ha(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,this.stride)}getLength(){return Wd(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){let r=[];return r.length=Xa(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LineString"}intersectsExtent(e){return Nh(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Za(this.flatCoordinates,0,e,this.stride),this.changed()}},_s=Sm;var Cm=class h extends In{constructor(e,r,l){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,r);else if(r!==void 0&&l)this.setFlatCoordinates(r,e),this.ends_=l;else{let a=e,o=[],g=[];for(let w=0,T=a.length;w<T;++w){let S=a[w];kr(o,S.getFlatCoordinates()),g.push(o.length)}let v=a.length===0?this.getLayout():a[0].getLayout();this.setFlatCoordinates(v,o),this.ends_=g}}appendLineString(e){kr(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Lh(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Fh(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,r,l,a))}getCoordinateAtM(e,r,l){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(r=r!==void 0?r:!1,l=l!==void 0?l:!1,Rx(this.flatCoordinates,0,this.ends_,this.stride,e,r,l))}getCoordinates(){return ta(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new _s(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){let e=this.flatCoordinates,r=this.ends_,l=this.layout,a=[],o=0;for(let g=0,v=r.length;g<v;++g){let w=r[g],T=new _s(e.slice(o,w),l);a.push(T),o=w}return a}getFlatMidpoints(){let e=[],r=this.flatCoordinates,l=0,a=this.ends_,o=this.stride;for(let g=0,v=a.length;g<v;++g){let w=a[g],T=Ha(r,l,w,o,.5);kr(e,T),l=w}return e}getSimplifiedGeometryInternal(e){let r=[],l=[];return r.length=Ud(this.flatCoordinates,0,this.ends_,this.stride,e,r,0,l),new h(r,"XY",l)}getType(){return"MultiLineString"}intersectsExtent(e){return Dx(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let l=Qo(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=l.length===0?0:l[l.length-1],this.changed()}},Im=Cm;var Em=class h extends In{constructor(e,r){super(),this.setCoordinates(e,r)}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,l,a){let o=this.flatCoordinates,g=gs(e,r,o[0],o[1]);if(g<a){let v=this.stride;for(let w=0;w<v;++w)l[w]=o[w];return l.length=v,g}return a}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return Yo(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return Eh(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,r){this.setLayout(r,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Ix(this.flatCoordinates,0,e,this.stride),this.changed()}},_r=Em;var Tm=class h extends In{constructor(e,r){super(),r&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendPoint(e){kr(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,l,a){if(a<wn(this.getExtent(),e,r))return a;let o=this.flatCoordinates,g=this.stride;for(let v=0,w=o.length;v<w;v+=g){let T=gs(e,r,o[v],o[v+1]);if(T<a){a=T;for(let S=0;S<g;++S)l[S]=o[v+S];l.length=g}}return a}getCoordinates(){return ts(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){let r=this.flatCoordinates.length/this.stride;return e<0||r<=e?null:new _r(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){let e=this.flatCoordinates,r=this.layout,l=this.stride,a=[];for(let o=0,g=e.length;o<g;o+=l){let v=new _r(e.slice(o,o+l),r);a.push(v)}return a}getType(){return"MultiPoint"}intersectsExtent(e){let r=this.flatCoordinates,l=this.stride;for(let a=0,o=r.length;a<o;a+=l){let g=r[a],v=r[a+1];if(Eh(e,g,v))return!0}return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=Za(this.flatCoordinates,0,e,this.stride),this.changed()}},Vh=Tm;function Gh(h,e,r,l,a,o,g){let v,w,T,S,k,F,j,J=a[o+1],he=[];for(let ne=0,me=r.length;ne<me;++ne){let _e=r[ne];for(S=h[_e-l],F=h[_e-l+1],v=e;v<_e;v+=l)k=h[v],j=h[v+1],(J<=F&&j<=J||F<=J&&J<=j)&&(T=(J-F)/(j-F)*(k-S)+S,he.push(T)),S=k,F=j}let q=NaN,Z=-1/0;for(he.sort(Ds),S=he[0],v=1,w=he.length;v<w;++v){k=he[v];let ne=Math.abs(k-S);ne>Z&&(T=(S+k)/2,Bh(h,e,r,l,T,J)&&(q=T,Z=ne)),S=k}return isNaN(q)&&(q=a[o]),g?(g.push(q,J,Z),g):[q,J,Z]}function Zd(h,e,r,l,a){let o=[];for(let g=0,v=r.length;g<v;++g){let w=r[g];o=Gh(h,e,w,l,a,2*g,o),e=w[w.length-1]}return o}function zx(h,e,r,l){for(;e<r-l;){for(let a=0;a<l;++a){let o=h[e+a];h[e+a]=h[r-l+a],h[r-l+a]=o}e+=l,r-=l}}function Mm(h,e,r,l){let a=0,o=h[r-l],g=h[r-l+1];for(;e<r;e+=l){let v=h[e],w=h[e+1];a+=(v-o)*(w+g),o=v,g=w}return a===0?void 0:a>0}function jh(h,e,r,l,a){a=a!==void 0?a:!1;for(let o=0,g=r.length;o<g;++o){let v=r[o],w=Mm(h,e,v,l);if(o===0){if(a&&w||!a&&!w)return!1}else if(a&&!w||!a&&w)return!1;e=v}return!0}function Xd(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o){let v=r[o];if(!jh(h,e,v,l,a))return!1;v.length&&(e=v[v.length-1])}return!0}function nc(h,e,r,l,a){a=a!==void 0?a:!1;for(let o=0,g=r.length;o<g;++o){let v=r[o],w=Mm(h,e,v,l);(o===0?a&&w||!a&&!w:a&&!w||!a&&w)&&zx(h,e,v,l),e=v}return e}function Uh(h,e,r,l,a){for(let o=0,g=r.length;o<g;++o)e=nc(h,e,r[o],l,a);return e}function Ox(h,e){let r=[],l=0,a=0,o;for(let g=0,v=e.length;g<v;++g){let w=e[g],T=Mm(h,l,w,2);if(o===void 0&&(o=T),T===o)r.push(e.slice(a,g+1));else{if(r.length===0)continue;r[r.length-1].push(e[a])}a=g+1,l=w}return r}var $h=class h extends In{constructor(e,r,l){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,r!==void 0&&l?(this.setFlatCoordinates(r,e),this.ends_=l):this.setCoordinates(e,r)}appendLinearRing(e){this.flatCoordinates?kr(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Lh(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Fh(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,r,l,a))}containsXY(e,r){return Bh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,r)}getArea(){return xm(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),nc(r,0,this.ends_,this.stride,e)):r=this.flatCoordinates,ta(r,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let e=es(this.getExtent());this.flatInteriorPoint_=Gh(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new _r(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new bm(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){let e=this.layout,r=this.flatCoordinates,l=this.ends_,a=[],o=0;for(let g=0,v=l.length;g<v;++g){let w=l[g],T=new bm(r.slice(o,w),e);a.push(T),o=w}return a}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;jh(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=nc(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],l=[];return r.length=zh(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),r,0,l),new h(r,"XY",l)}getType(){return"Polygon"}intersectsExtent(e){return wm(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let l=Qo(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=l.length===0?0:l[l.length-1],this.changed()}},sc=$h;function Am(h){if(Th(h))throw new Error("Cannot create polygon from empty extent");let e=h[0],r=h[1],l=h[2],a=h[3],o=[e,r,e,a,l,a,l,r,e,r];return new $h(o,"XY",[o.length])}function Pm(h,e,r){e=e||32;let l=h.getStride(),a=h.getLayout(),o=h.getCenter(),g=l*(e+1),v=new Array(g);for(let S=0;S<g;S+=l){v[S]=0,v[S+1]=0;for(let k=2;k<l;k++)v[S+k]=o[k]}let w=[v.length],T=new $h(v,a,w);return kS(T,o,h.getRadius(),r),T}function kS(h,e,r,l){let a=h.getFlatCoordinates(),o=h.getStride(),g=a.length/o-1,v=l||0;for(let w=0;w<=g;++w){let T=w*o,S=v+Ua(w,g)*2*Math.PI/g;a[T]=e[0]+r*Math.cos(S),a[T+1]=e[1]+r*Math.sin(S)}h.changed()}function Hd(h,e,r,l){let a=[],o=Sn();for(let g=0,v=r.length;g<v;++g){let w=r[g];o=Ql(h,e,w[0],l),a.push((o[0]+o[2])/2,(o[1]+o[3])/2),e=w[w.length-1]}return a}var Rm=class h extends In{constructor(e,r,l){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!l&&!Array.isArray(e[0])){let a=e,o=[],g=[];for(let v=0,w=a.length;v<w;++v){let T=a[v],S=o.length,k=T.getEnds();for(let F=0,j=k.length;F<j;++F)k[F]+=S;kr(o,T.getFlatCoordinates()),g.push(k)}r=a.length===0?this.getLayout():a[0].getLayout(),e=o,l=g}r!==void 0&&l?(this.setFlatCoordinates(r,e),this.endss_=l):this.setCoordinates(e,r)}appendPolygon(e){let r;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),r=e.getEnds().slice(),this.endss_.push();else{let l=this.flatCoordinates.length;kr(this.flatCoordinates,e.getFlatCoordinates()),r=e.getEnds().slice();for(let a=0,o=r.length;a<o;++a)r[a]+=l}this.endss_.push(r),this.changed()}clone(){let e=this.endss_.length,r=new Array(e);for(let a=0;a<e;++a)r[a]=this.endss_[a].slice();let l=new h(this.flatCoordinates.slice(),this.layout,r);return l.applyProperties(this),l}closestPointXY(e,r,l,a){return a<wn(this.getExtent(),e,r)?a:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Tx(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Mx(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,r,l,a))}containsXY(e,r){return Lx(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,r)}getArea(){return Px(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),Uh(r,0,this.endss_,this.stride,e)):r=this.flatCoordinates,Oh(r,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let e=Hd(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Zd(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new Vh(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;Xd(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Uh(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],l=[];return r.length=Ax(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),r,0,l),new h(r,"XY",l)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let r;if(e===0)r=0;else{let o=this.endss_[e-1];r=o[o.length-1]}let l=this.endss_[e].slice(),a=l[l.length-1];if(r!==0)for(let o=0,g=l.length;o<g;++o)l[o]-=r;return new sc(this.flatCoordinates.slice(r,a),this.layout,l)}getPolygons(){let e=this.layout,r=this.flatCoordinates,l=this.endss_,a=[],o=0;for(let g=0,v=l.length;g<v;++g){let w=l[g].slice(),T=w[w.length-1];if(o!==0)for(let k=0,F=w.length;k<F;++k)w[k]-=o;let S=new sc(r.slice(o,T),e,w);a.push(S),o=T}return a}getType(){return"MultiPolygon"}intersectsExtent(e){return Fx(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,3),this.flatCoordinates||(this.flatCoordinates=[]);let l=jd(this.flatCoordinates,0,e,this.stride,this.endss_);if(l.length===0)this.flatCoordinates.length=0;else{let a=l[l.length-1];this.flatCoordinates.length=a.length===0?0:a[a.length-1]}this.changed()}},km=Rm;var LS=(h,e,r)=>{let{time_intervals:l,olGeometry:a,coordinate:o}=e.properties,{coordinates:g}=e.geometry,{type:v}=e.geometry,w=a,T,S;if(a&&(v=w.getType()),r&&o)T=o;else if(v==="Point")T=g;else if(v==="LineString"){w||(w=new _s(g));let k=l||[[]],F=k[0],j=k[k.length-1];if(h<F[0])[,,S]=F,T=w.getFirstCoordinate();else if(h>j[0])[,,S]=j,T=w.getLastCoordinate();else for(let J=0;J<k.length-1;J+=1){let[he,q]=k[J],[Z,ne]=k[J+1];if(he<=h&&h<=Z){let _e=Math.min((h-he)/(Z-he),1)*(ne-q)+q;T=w.getCoordinateAt(_e),[,,S]=k[J];break}}}else console.error("This geometry type is not supported. Only Point or LineString are. Current geometry: ",w);return{coord:T,rotation:S}},qh=LS;var DS=(h,e,r,l,a)=>{if(!h)return{renderedTrajectories:[]};let{time:o=Date.now(),size:g=[],center:v,resolution:w,rotation:T=0,pixelRatio:S=1}=l;if(!w||!v)return{renderedTrajectories:[]};let{noInterpolate:k=!1,hoverVehicleId:F,selectedVehicleId:j,filter:J,getScreenPixel:he=(Pe,Ye)=>(Ye.zoom||0)<12?Pe.map(je=>Math.floor(je)):Pe}=a,q=h.getContext("2d");q?.clearRect(0,0,h.width,h.height);let[Z,ne]=g;Z&&ne&&(h.width!==Z||h.height!==ne)&&([h.width,h.height]=[Z*S,ne*S]);let me=an(mr(),g[0]/2,g[1]/2,1/w,-1/w,-T,-v[0],-v[1]);h.style&&(h.style.width=`${h.width/S}px`,h.style.height=`${h.height/S}px`);let _e,fe,ve,Ee,Re=[];for(let Pe=e.length-1;Pe>=0;Pe-=1){let Ye=e[Pe];if(J&&!J(Ye))continue;let{train_id:je,timeOffset:Ke}=Ye.properties,{coord:xt,rotation:At}=qh(o-(Ke||0),Ye,k);if(e[Pe].properties.coordinate=xt,e[Pe].properties.rotation=At,!xt)continue;let rt=rr(me,[...xt]);if(!rt||(rt=rt.map(yt=>yt*S),rt[0]<0||rt[0]>h.width||rt[1]<0||rt[1]>h.height))continue;let tt=r(Ye,l,a);if(tt){if(F!==je&&j!==je){let[yt,ut]=he([rt[0]-tt.width/2,rt[1]-tt.height/2],l);q?.drawImage(tt,yt,ut)}F&&F===je&&(_e=tt,fe=rt),j&&j===je&&(ve=tt,Ee=rt),Re.push(Ye)}}return ve&&Ee&&q?.drawImage(ve,Math.floor(Ee[0]-ve.width/2),Math.floor(Ee[1]-ve.height/2)),_e&&fe&&q?.drawImage(_e,Math.floor(fe[0]-_e.width/2),Math.floor(fe[1]-_e.height/2)),{renderedTrajectories:Re}},Wh=DS;var FS=(h,e,r=!1)=>{let l=["HIDDEN","LEAVING","BOARDING"],a=h.has_fzo&&l.indexOf(h.state)>-1,o=e.has_fzo&&l.indexOf(e.state)>-1;if(a||o){if(a!==o)return a?-1:1;if(h.state!==e.state)return l.indexOf(h.state)-l.indexOf(e.state)}let g=null,v=null,w=Date.now();return r?(g=new Date(h.min_arrival_time||h.time).getTime()-w,v=new Date(e.min_arrival_time||e.time).getTime()-w):(g=new Date(h.time).getTime()-w,v=new Date(e.time).getTime()-w),g-v},Zh=FS;var zS=(h,e=!1,r=30)=>{let l=Object.keys(h).map(k=>h[k]);l.sort((k,F)=>Zh(k,F,e));let a=new Date;a.setMinutes(a.getMinutes()+r);let o=a.getTime(),g=new Date;g.setMinutes(g.getMinutes()-r);let v=g.getTime(),w=[],T=[],S=null;for(let k=l.length-1;k>=0;k-=1){let F={...l[k]},j=new Date(F.time).getTime();j>v&&j<o&&(F.state==="BOARDING"&&(T.includes(F.platform)?F.state="HIDDEN":T.push(F.platform)),S&&F.to[0]===S.to[0]&&Math.abs(j-S.time)<1e3&&F.line.name===S.line.name&&(F.state="HIDDEN"),/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(F.state)&&(F.cancelled=!0),S=F,S.time=j,w.unshift(F))}return w},Xh=zS;var OS=(h,e=!1,r=30,l=100)=>{let a={},o={};return g=>{let{source:v,content:w}=g;a[v]&&window.clearTimeout(a[v]),w&&(o[w.call_id]=w,a[v]=window.setTimeout(()=>{let T=Xh(o,e||!1,r);h(T)},l))}},Lm=OS;var BS=(h,e)=>{let r=null;return typeof window>"u"?null:(typeof document<"u"&&document?.createElement?(r=document.createElement("canvas"),r.width=h,r.height=e):OffscreenCanvas?r=new OffscreenCanvas(h,e):console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"),r)},xs=BS;var oc={};Of(oc,{MOTS_ALL:()=>GS,MOTS_ONLY_RAIL:()=>vs,MOTS_WITHOUT_CABLE:()=>Yd,MOTS_WITH_CABLE:()=>VS,bgColors:()=>Nx,getBgColor:()=>US,getDelayColor:()=>WS,getDelayText:()=>ZS,getRadius:()=>jS,getTextColor:()=>$S,getTextSize:()=>qS,getTypeIndex:()=>Kd,textColors:()=>Vx,types:()=>Bx});var NS=[[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15]],vs=["rail"],VS=["cablecar","gondola","funicular","coach"],Yd=["tram","subway","rail","bus"],GS=["tram","subway","rail","bus","ferry","cablecar","gondola","funicular","coach"],Bx=[/^Tram/i,/^Subway( \/ Metro \/ S-Bahn)?/i,/^Train/i,/^Bus/i,/^Ferry/i,/^Cable ?Car/i,/^Gondola/i,/^Funicular/i,/^(Long distance bus|coach)/i,/^Rail/i],Nx=["#ffb400","#ff5400","#ff8080","#ea0000","#3000ff","#ffb400","#41a27b","#00d237","#b5b5b5","#ff8080"],Vx=["#000000","#ffffff","#000000","#ffffff","#ffffff","#000000","#ffffff","#000000","#000000","#000000"],Kd=h=>typeof h=="string"?Bx.findIndex(e=>e.test(h)):h,jS=(h,e)=>{try{let r=Kd(h||0);return NS[r][e]}catch{return 1}},US=h=>{try{let e=Kd(h);return Nx[e]}catch{return"#ffffff"}},$S=h=>{try{let e=Kd(h);return Vx[e]}catch{return"#ffffff"}},qS=(h,e,r,l,a)=>{if(!h)return 0;h.font=a(l,r);let o=h.measureText(r),g=25,v=0;for(;o.width>e-6&&v<g;)l-=.5,h.font=a(l,r),o=h.measureText(r),v+=1;return l},WS=(h,e,r)=>e?r?"#ff0000":"#a0a0a0":h===null?"#a0a0a0":h>=36e5?"#ed004c":h>=5e5?"#e80000":h>=3e5?"#ff4a00":h>=18e4?"#f7bf00":"#00a00c",ZS=(h,e)=>e?String.fromCodePoint(215):h>=36e5?`+${Math.round(h/36e5)}h`:h>=6e4?`+${Math.round(h/6e4)}m`:h>=1e3?`+${Math.round(h/1e3)}s`:h>0?`+${h}ms`:"";var ra="vectorTileFeature";var Dm={},Nm=(h,e,r)=>{let l=`${h}, ${e}, ${r}`;if(!Dm[l]){let a=xs(h*2,h*2);if(a){let o=a.getContext("2d");if(!o)return null;o.beginPath(),o.arc(h,h,e,0,2*Math.PI,!1),o.fillStyle=r,o.filter="blur(1px)",o.fill(),Dm[l]=a}}return Dm[l]},Fm={},Vm=(h,e,r,l,a="#000",o=1)=>{let g=`${h}, ${r}, ${l}, ${a}, ${o}`;if(!Fm[g]){let v=xs(Math.ceil(h.length*e),Math.ceil(e+8*o));if(v){let w=v.getContext("2d");if(!w)return null;w.font=r,w.textAlign="left",w.textBaseline="middle",w.font=r,w.fillStyle=l,w.strokeStyle=a,w.lineWidth=1.5*o,w.strokeText(h,0,e),w.fillText(h,0,e),Fm[g]=v}}return Fm[g]},zm={},Gm=(h,e,r,l,a,o)=>{let g=`${h}, ${e}, ${r}, ${l}, ${a}, ${o}`;if(!zm[g]){let v=xs(h*2,h*2);if(v){let w=v.getContext("2d");if(!w)return null;w.fillStyle=r,l&&(w.lineWidth=1*o,w.strokeStyle="#000000"),w.beginPath(),w.arc(h,h,e,0,2*Math.PI,!1),w.fill(),a&&w.setLineDash([5,3]),l&&w.stroke(),zm[g]=v}}return zm[g]},Om={},jm=(h,e,r,l,a,o,g,v)=>{let w=`${h}, ${e}, ${r}, ${l},${a}, ${o}, ${g}`;if(!Om[w]){let T=xs(e*2,e*2);if(T){let S=T.getContext("2d");if(!S)return null;o&&(S.save(),S.textBaseline="middle",S.textAlign="center",S.font=v(r+2,h),S.strokeStyle=a,S.strokeText(h,e,e),S.restore()),S.textBaseline="middle",S.textAlign="center",S.fillStyle=l,S.font=v(r,h),S.strokeStyle=a,S.strokeText(h,e,e),S.fillText(h,e,e),Om[w]=T}}return Om[w]},Bm={},XS=(h,e,r)=>{let{hoverVehicleId:l,selectedVehicleId:a,useDelayStyle:o,delayOutlineColor:g="#000",delayDisplay:v=3e5,getRadius:w=()=>0,getBgColor:T=()=>"#000",getDelayColor:S=()=>"#000",getDelayText:k=()=>null,getDelayFont:F=Bt=>`bold ${Bt}px arial, sans-serif`,getText:j=Bt=>Bt,getTextFont:J=Bt=>`bold ${Bt}px arial, sans-serif`,getTextColor:he=()=>"#000",getTextSize:q=()=>14,getMaxRadiusForText:Z=()=>10,getMaxRadiusForStrokeAndDelay:ne=()=>7}=r,{zoom:me,pixelRatio:_e=1}=e,{type:fe}=h.properties,{train_id:ve,line:Ee,delay:Re,state:Pe,operator_provides_realtime_journey:Ye}=h.properties,{name:je,text_color:Ke,color:xt}=Ee||{};je=j(je);let At=Pe==="JOURNEY_CANCELLED";fe||(fe="Rail"),je||(je="I"),Ke||(Ke="#000000"),xt&&xt[0]!=="#"&&(xt=`#${xt}`),Ke[0]!=="#"&&(Ke=`#${Ke}`);let rt=Math.min(Math.floor(me||1),16),tt=!!(l&&l===ve),yt=!!(a&&a===ve),ut=w(fe,rt)*_e,Mt=ut>=ne()*_e;(tt||yt)&&(ut=Mt?ut+5*_e:14*_e);let mt=ut>Z()*_e,Ft=`${ut}${tt||yt}`;if(o?(Ft+=`${Ye}${Re}`,Mt&&(Ft+=`${At}`)):(Ft+=`${xt||fe}`,Mt&&(Ft+=`${At}${Re}`)),mt&&(Ft+=`${je}${Ke}`),!Bm[Ft]){if(ut===0)return null;let Bt=1*_e,Ei=ut+2*_e,Ue=ut*2,ki=Ei*2+Bt*2,xi=ki/2,Nr=null;Mt&&Re!==null&&(Nr=Nm(xi,Ei,S(Re,At)));let ar=null,Ln=0;if(Mt&&(tt||(Re||0)>=v||At)){Ln=Math.max(At?19:14,Math.min(At?19:17,ut*1.2))*_e;let Ti=k(Re,At);Ti&&(ar=Vm(Ti,Ln,F(Ln,Ti),S(Re,At,!0),g,_e))}let lr;o?lr=S(Re,At):lr=xt||T(fe);let oi=Gm(xi,ut,lr,Mt||tt||yt,!!Mt&&!!o&&Re===null&&Ye==="yes",_e),Dn=ki+(ar?.width||0)*2,tr=xs(Dn,ki);if(tr){let Ti=tr.getContext("2d");if(!Ti)return null;let Et=ar?.width||0;Nr&&Ti.drawImage(Nr,Et,0),oi&&Ti.drawImage(oi,Et,0);let ci=null;if(mt){let Vr=Math.max(ut,10),Fn=q(Ti,Ue,je,Vr,J),pn=o?"#000000":Ke||he(fe);ci=jm(je,xi,Fn,pn,lr,!!o&&Re===null&&Ye==="yes",_e,J)}ci&&Ti.drawImage(ci,Et,0),ar&&Ti.drawImage(ar,Et+Math.ceil(xi+Ei)+Bt,Math.ceil(xi-Ln)),Bm[Ft]=tr}}return Bm[Ft]},Ya=XS;var HS=(h,e,r)=>Ya(h,e,{...r,useDelayStyle:!0}),Um=HS;var Jd,YS=()=>{if(!Jd){Jd=xs(15,15);let h=Jd?.getContext("2d");h&&(h.arc(8,8,5,0,2*Math.PI,!1),h.fillStyle="#8ED6FF",h.fill(),h.lineWidth=3,h.strokeStyle="black",h.stroke(),h.lineWidth=3)}return Jd},$m=YS;var Ht={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var qm=class extends gr{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;let r=Object.assign({},e);typeof e.properties=="object"&&(delete r.properties,Object.assign(r,e.properties)),r[Ht.OPACITY]=e.opacity!==void 0?e.opacity:1,si(typeof r[Ht.OPACITY]=="number","Layer opacity must be a number"),r[Ht.VISIBLE]=e.visible!==void 0?e.visible:!0,r[Ht.Z_INDEX]=e.zIndex,r[Ht.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,r[Ht.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,r[Ht.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,r[Ht.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=r.className!==void 0?r.className:"ol-layer",delete r.className,this.setProperties(r),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){let r=this.state_||{layer:this,managed:e===void 0?!0:e},l=this.getZIndex();return r.opacity=Ii(Math.round(this.getOpacity()*100)/100,0,1),r.visible=this.getVisible(),r.extent=this.getExtent(),r.zIndex=l===void 0&&!r.managed?1/0:l,r.maxResolution=this.getMaxResolution(),r.minResolution=Math.max(this.getMinResolution(),0),r.minZoom=this.getMinZoom(),r.maxZoom=this.getMaxZoom(),this.state_=r,r}getLayersArray(e){return St()}getLayerStatesArray(e){return St()}getExtent(){return this.get(Ht.EXTENT)}getMaxResolution(){return this.get(Ht.MAX_RESOLUTION)}getMinResolution(){return this.get(Ht.MIN_RESOLUTION)}getMinZoom(){return this.get(Ht.MIN_ZOOM)}getMaxZoom(){return this.get(Ht.MAX_ZOOM)}getOpacity(){return this.get(Ht.OPACITY)}getSourceState(){return St()}getVisible(){return this.get(Ht.VISIBLE)}getZIndex(){return this.get(Ht.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(Ht.EXTENT,e)}setMaxResolution(e){this.set(Ht.MAX_RESOLUTION,e)}setMinResolution(e){this.set(Ht.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(Ht.MAX_ZOOM,e)}setMinZoom(e){this.set(Ht.MIN_ZOOM,e)}setOpacity(e){si(typeof e=="number","Layer opacity must be a number"),this.set(Ht.OPACITY,e)}setVisible(e){this.set(Ht.VISIBLE,e)}setZIndex(e){this.set(Ht.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},Gx=qm;var Bs={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var En={ANIMATING:0,INTERACTING:1};var is={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Wm(h,e,r){return function(l,a,o,g,v){if(!l)return;if(!a&&!e)return l;let w=e?0:o[0]*a,T=e?0:o[1]*a,S=v?v[0]:0,k=v?v[1]:0,F=h[0]+w/2+S,j=h[2]-w/2+S,J=h[1]+T/2+k,he=h[3]-T/2+k;F>j&&(F=(j+F)/2,j=F),J>he&&(J=(he+J)/2,he=J);let q=Ii(l[0],F,j),Z=Ii(l[1],J,he);if(g&&r&&a){let ne=30*a;q+=-ne*Math.log(1+Math.max(0,F-l[0])/ne)+ne*Math.log(1+Math.max(0,l[0]-j)/ne),Z+=-ne*Math.log(1+Math.max(0,J-l[1])/ne)+ne*Math.log(1+Math.max(0,l[1]-he)/ne)}return[q,Z]}}function jx(h){return h}function Zm(h,e,r,l){let a=$i(e)/r[0],o=ln(e)/r[1];return l?Math.min(h,Math.max(a,o)):Math.min(h,Math.min(a,o))}function Xm(h,e,r){let l=Math.min(h,e),a=50;return l*=Math.log(1+a*Math.max(0,h/e-1))/a+1,r&&(l=Math.max(l,r),l/=Math.log(1+a*Math.max(0,r/h-1))/a+1),Ii(l,r/2,e*2)}function Ux(h,e,r,l){return e=e!==void 0?e:!0,function(a,o,g,v){if(a!==void 0){let w=h[0],T=h[h.length-1],S=r?Zm(w,r,g,l):w;if(v)return e?Xm(a,S,T):Ii(a,T,S);let k=Math.min(S,a),F=Math.floor(Md(h,k,o));return h[F]>S&&F<h.length-1?h[F+1]:h[F]}}}function $x(h,e,r,l,a,o){return l=l!==void 0?l:!0,r=r!==void 0?r:0,function(g,v,w,T){if(g!==void 0){let S=a?Zm(e,a,w,o):e;if(T)return l?Xm(g,S,r):Ii(g,r,S);let k=1e-9,F=Math.ceil(Math.log(e/S)/Math.log(h)-k),j=-v*(.5-k)+.5,J=Math.min(S,g),he=Math.floor(Math.log(e/J)/Math.log(h)+j),q=Math.max(F,he),Z=e/Math.pow(h,q);return Ii(Z,r,S)}}}function Hm(h,e,r,l,a){return r=r!==void 0?r:!0,function(o,g,v,w){if(o!==void 0){let T=l?Zm(h,l,v,a):h;return!r||!w?Ii(o,e,T):Xm(o,T,e)}}}function qx(h){if(h!==void 0)return 0}function Ym(h){if(h!==void 0)return h}function Wx(h){let e=2*Math.PI/h;return function(r,l){if(l)return r;if(r!==void 0)return r=Math.floor(r/e+.5)*e,r}}function Zx(h){let e=h===void 0?lx(5):h;return function(r,l){return l||r===void 0?r:Math.abs(r)<=e?0:r}}function KS(h){return Math.pow(h,3)}function Xx(h){return 1-KS(1-h)}function Hx(h){return 3*h*h-2*h*h*h}var Km=0,Qm=class extends gr{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=Bd(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&um(),e.center&&(e.center=er(e.center,this.projection_)),e.extent&&(e.extent=Os(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){let r=Object.assign({},e);for(let v in is)delete r[v];this.setProperties(r,!0);let l=QS(e);this.maxResolution_=l.maxResolution,this.minResolution_=l.minResolution,this.zoomFactor_=l.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=l.minZoom;let a=JS(e),o=l.constraint,g=e2(e);this.constraints_={center:a,resolution:o,rotation:g},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let r=this.padding_;this.padding_=e;let l=this.getCenterInternal();if(l){let a=e||[0,0,0,0];r=r||[0,0,0,0];let o=this.getResolution(),g=o/2*(a[3]-r[3]+r[1]-a[1]),v=o/2*(a[0]-r[0]+r[2]-a[2]);this.setCenterInternal([l[0]+g,l[1]-v])}}getUpdatedOptions_(e){let r=this.getProperties();return r.resolution!==void 0?r.resolution=this.getResolution():r.zoom=this.getZoom(),r.center=this.getCenterInternal(),r.rotation=this.getRotation(),Object.assign({},r,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let r=new Array(arguments.length);for(let l=0;l<r.length;++l){let a=arguments[l];a.center&&(a=Object.assign({},a),a.center=er(a.center,this.getProjection())),a.anchor&&(a=Object.assign({},a),a.anchor=er(a.anchor,this.getProjection())),r[l]=a}this.animateInternal.apply(this,r)}animateInternal(e){let r=arguments.length,l;r>1&&typeof arguments[r-1]=="function"&&(l=arguments[r-1],--r);let a=0;for(;a<r&&!this.isDef();++a){let S=arguments[a];S.center&&this.setCenterInternal(S.center),S.zoom!==void 0?this.setZoom(S.zoom):S.resolution&&this.setResolution(S.resolution),S.rotation!==void 0&&this.setRotation(S.rotation)}if(a===r){l&&Qd(l,!0);return}let o=Date.now(),g=this.targetCenter_.slice(),v=this.targetResolution_,w=this.targetRotation_,T=[];for(;a<r;++a){let S=arguments[a],k={start:o,complete:!1,anchor:S.anchor,duration:S.duration!==void 0?S.duration:1e3,easing:S.easing||Hx,callback:l};if(S.center&&(k.sourceCenter=g,k.targetCenter=S.center.slice(),g=k.targetCenter),S.zoom!==void 0?(k.sourceResolution=v,k.targetResolution=this.getResolutionForZoom(S.zoom),v=k.targetResolution):S.resolution&&(k.sourceResolution=v,k.targetResolution=S.resolution,v=k.targetResolution),S.rotation!==void 0){k.sourceRotation=w;let F=Ua(S.rotation-w+Math.PI,2*Math.PI)-Math.PI;k.targetRotation=w+F,w=k.targetRotation}t2(k)?k.complete=!0:o+=k.duration,T.push(k)}this.animations_.push(T),this.setHint(En.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[En.ANIMATING]>0}getInteracting(){return this.hints_[En.INTERACTING]>0}cancelAnimations(){this.setHint(En.ANIMATING,-this.hints_[En.ANIMATING]);let e;for(let r=0,l=this.animations_.length;r<l;++r){let a=this.animations_[r];if(a[0].callback&&Qd(a[0].callback,!1),!e)for(let o=0,g=a.length;o<g;++o){let v=a[o];if(!v.complete){e=v.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let e=Date.now(),r=!1;for(let l=this.animations_.length-1;l>=0;--l){let a=this.animations_[l],o=!0;for(let g=0,v=a.length;g<v;++g){let w=a[g];if(w.complete)continue;let T=e-w.start,S=w.duration>0?T/w.duration:1;S>=1?(w.complete=!0,S=1):o=!1;let k=w.easing(S);if(w.sourceCenter){let F=w.sourceCenter[0],j=w.sourceCenter[1],J=w.targetCenter[0],he=w.targetCenter[1];this.nextCenter_=w.targetCenter;let q=F+k*(J-F),Z=j+k*(he-j);this.targetCenter_=[q,Z]}if(w.sourceResolution&&w.targetResolution){let F=k===1?w.targetResolution:w.sourceResolution+k*(w.targetResolution-w.sourceResolution);if(w.anchor){let j=this.getViewportSize_(this.getRotation()),J=this.constraints_.resolution(F,0,j,!0);this.targetCenter_=this.calculateCenterZoom(J,w.anchor)}this.nextResolution_=w.targetResolution,this.targetResolution_=F,this.applyTargetState_(!0)}if(w.sourceRotation!==void 0&&w.targetRotation!==void 0){let F=k===1?Ua(w.targetRotation+Math.PI,2*Math.PI)-Math.PI:w.sourceRotation+k*(w.targetRotation-w.sourceRotation);if(w.anchor){let j=this.constraints_.rotation(F,!0);this.targetCenter_=this.calculateCenterRotate(j,w.anchor)}this.nextRotation_=w.targetRotation,this.targetRotation_=F}if(this.applyTargetState_(!0),r=!0,!w.complete)break}if(o){this.animations_[l]=null,this.setHint(En.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let g=a[0].callback;g&&Qd(g,!0)}}this.animations_=this.animations_.filter(Boolean),r&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,r){let l,a=this.getCenterInternal();return a!==void 0&&(l=[a[0]-r[0],a[1]-r[1]],ux(l,e-this.getRotation()),hx(l,r)),l}calculateCenterZoom(e,r){let l,a=this.getCenterInternal(),o=this.getResolution();if(a!==void 0&&o!==void 0){let g=r[0]-e*(r[0]-a[0])/o,v=r[1]-e*(r[1]-a[1])/o;l=[g,v]}return l}getViewportSize_(e){let r=this.viewportSize_;if(e){let l=r[0],a=r[1];return[Math.abs(l*Math.cos(e))+Math.abs(a*Math.sin(e)),Math.abs(l*Math.sin(e))+Math.abs(a*Math.cos(e))]}return r}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&Wa(e,this.getProjection())}getCenterInternal(){return this.get(is.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){let r=this.calculateExtentInternal(e);return zs(r,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();let r=this.getCenterInternal();si(r,"The view center is not defined");let l=this.getResolution();si(l!==void 0,"The view resolution is not defined");let a=this.getRotation();return si(a!==void 0,"The view rotation is not defined"),H0(r,l,a,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(is.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,r){return this.getResolutionForExtentInternal(Os(e,this.getProjection()),r)}getResolutionForExtentInternal(e,r){r=r||this.getViewportSizeMinusPadding_();let l=$i(e)/r[0],a=ln(e)/r[1];return Math.max(l,a)}getResolutionForValueFunction(e){e=e||2;let r=this.getConstrainedResolution(this.maxResolution_),l=this.minResolution_,a=Math.log(r/l)/Math.log(e);return function(o){return r/Math.pow(e,o*a)}}getRotation(){return this.get(is.ROTATION)}getValueForResolutionFunction(e){let r=Math.log(e||2),l=this.getConstrainedResolution(this.maxResolution_),a=this.minResolution_,o=Math.log(l/a)/r;return function(g){return Math.log(l/g)/r/o}}getViewportSizeMinusPadding_(e){let r=this.getViewportSize_(e),l=this.padding_;return l&&(r=[r[0]-l[1]-l[3],r[1]-l[0]-l[2]]),r}getState(){let e=this.getProjection(),r=this.getResolution(),l=this.getRotation(),a=this.getCenterInternal(),o=this.padding_;if(o){let g=this.getViewportSizeMinusPadding_();a=Jm(a,this.getViewportSize_(),[g[0]/2+o[3],g[1]/2+o[0]],r,l)}return{center:a.slice(0),projection:e!==void 0?e:null,resolution:r,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:l,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,r=this.getResolution();return r!==void 0&&(e=this.getZoomForResolution(r)),e}getZoomForResolution(e){let r=this.minZoom_||0,l,a;if(this.resolutions_){let o=Md(this.resolutions_,e,1);r=o,l=this.resolutions_[o],o==this.resolutions_.length-1?a=2:a=l/this.resolutions_[o+1]}else l=this.maxResolution_,a=this.zoomFactor_;return r+Math.log(l/e)/Math.log(a)}getResolutionForZoom(e){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;let r=Ii(Math.floor(e),0,this.resolutions_.length-2),l=this.resolutions_[r]/this.resolutions_[r+1];return this.resolutions_[r]/Math.pow(l,Ii(e-r,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,r){let l;if(si(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){si(!Th(e),"Cannot fit empty extent provided as `geometry`");let a=Os(e,this.getProjection());l=Am(a)}else if(e.getType()==="Circle"){let a=Os(e.getExtent(),this.getProjection());l=Am(a),l.rotate(this.getRotation(),es(a))}else{let a=Wn();a?l=e.clone().transform(a,this.getProjection()):l=e}this.fitInternal(l,r)}rotatedExtentForGeometry(e){let r=this.getRotation(),l=Math.cos(r),a=Math.sin(-r),o=e.getFlatCoordinates(),g=e.getStride(),v=1/0,w=1/0,T=-1/0,S=-1/0;for(let k=0,F=o.length;k<F;k+=g){let j=o[k]*l-o[k+1]*a,J=o[k]*a+o[k+1]*l;v=Math.min(v,j),w=Math.min(w,J),T=Math.max(T,j),S=Math.max(S,J)}return[v,w,T,S]}fitInternal(e,r){r=r||{};let l=r.size;l||(l=this.getViewportSizeMinusPadding_());let a=r.padding!==void 0?r.padding:[0,0,0,0],o=r.nearest!==void 0?r.nearest:!1,g;r.minResolution!==void 0?g=r.minResolution:r.maxZoom!==void 0?g=this.getResolutionForZoom(r.maxZoom):g=0;let v=this.rotatedExtentForGeometry(e),w=this.getResolutionForExtentInternal(v,[l[0]-a[1]-a[3],l[1]-a[0]-a[2]]);w=isNaN(w)?g:Math.max(w,g),w=this.getConstrainedResolution(w,o?0:1);let T=this.getRotation(),S=Math.sin(T),k=Math.cos(T),F=es(v);F[0]+=(a[1]-a[3])/2*w,F[1]+=(a[0]-a[2])/2*w;let j=F[0]*k-F[1]*S,J=F[1]*k+F[0]*S,he=this.getConstrainedCenter([j,J],w),q=r.callback?r.callback:ms;r.duration!==void 0?this.animateInternal({resolution:w,center:he,duration:r.duration,easing:r.easing},q):(this.targetResolution_=w,this.targetCenter_=he,this.applyTargetState_(!1,!0),Qd(q,!0))}centerOn(e,r,l){this.centerOnInternal(er(e,this.getProjection()),r,l)}centerOnInternal(e,r,l){this.setCenterInternal(Jm(e,r,l,this.getResolution(),this.getRotation()))}calculateCenterShift(e,r,l,a){let o,g=this.padding_;if(g&&e){let v=this.getViewportSizeMinusPadding_(-l),w=Jm(e,a,[v[0]/2+g[3],v[1]/2+g[0]],r,l);o=[e[0]-w[0],e[1]-w[1]]}return o}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){let r=Wa(this.targetCenter_,this.getProjection());this.setCenter([r[0]+e[0],r[1]+e[1]])}adjustCenterInternal(e){let r=this.targetCenter_;this.setCenterInternal([r[0]+e[0],r[1]+e[1]])}adjustResolution(e,r){r=r&&er(r,this.getProjection()),this.adjustResolutionInternal(e,r)}adjustResolutionInternal(e,r){let l=this.getAnimating()||this.getInteracting(),a=this.getViewportSize_(this.getRotation()),o=this.constraints_.resolution(this.targetResolution_*e,0,a,l);r&&(this.targetCenter_=this.calculateCenterZoom(o,r)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,r){this.adjustResolution(Math.pow(this.zoomFactor_,-e),r)}adjustRotation(e,r){r&&(r=er(r,this.getProjection())),this.adjustRotationInternal(e,r)}adjustRotationInternal(e,r){let l=this.getAnimating()||this.getInteracting(),a=this.constraints_.rotation(this.targetRotation_+e,l);r&&(this.targetCenter_=this.calculateCenterRotate(a,r)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&er(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,r){return this.hints_[e]+=r,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,r){let l=this.getAnimating()||this.getInteracting()||r,a=this.constraints_.rotation(this.targetRotation_,l),o=this.getViewportSize_(a),g=this.constraints_.resolution(this.targetResolution_,0,o,l),v=this.constraints_.center(this.targetCenter_,g,o,l,this.calculateCenterShift(this.targetCenter_,g,a,o));this.get(is.ROTATION)!==a&&this.set(is.ROTATION,a),this.get(is.RESOLUTION)!==g&&(this.set(is.RESOLUTION,g),this.set("zoom",this.getZoom(),!0)),(!v||!this.get(is.CENTER)||!cn(this.get(is.CENTER),v))&&this.set(is.CENTER,v),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,r,l){e=e!==void 0?e:200;let a=r||0,o=this.constraints_.rotation(this.targetRotation_),g=this.getViewportSize_(o),v=this.constraints_.resolution(this.targetResolution_,a,g),w=this.constraints_.center(this.targetCenter_,v,g,!1,this.calculateCenterShift(this.targetCenter_,v,o,g));if(e===0&&!this.cancelAnchor_){this.targetResolution_=v,this.targetRotation_=o,this.targetCenter_=w,this.applyTargetState_();return}l=l||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==v||this.getRotation()!==o||!this.getCenterInternal()||!cn(this.getCenterInternal(),w))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:o,center:w,resolution:v,duration:e,easing:Xx,anchor:l}))}beginInteraction(){this.resolveConstraints(0),this.setHint(En.INTERACTING,1)}endInteraction(e,r,l){l=l&&er(l,this.getProjection()),this.endInteractionInternal(e,r,l)}endInteractionInternal(e,r,l){this.getInteracting()&&(this.setHint(En.INTERACTING,-1),this.resolveConstraints(e,r,l))}getConstrainedCenter(e,r){let l=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,r||this.getResolution(),l)}getConstrainedZoom(e,r){let l=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(l,r))}getConstrainedResolution(e,r){r=r||0;let l=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,r,l)}};function Qd(h,e){setTimeout(function(){h(e)},0)}function JS(h){if(h.extent!==void 0){let r=h.smoothExtentConstraint!==void 0?h.smoothExtentConstraint:!0;return Wm(h.extent,h.constrainOnlyCenter,r)}let e=Bd(h.projection,"EPSG:3857");if(h.multiWorld!==!0&&e.isGlobal()){let r=e.getExtent().slice();return r[0]=-1/0,r[2]=1/0,Wm(r,!1,!1)}return jx}function QS(h){let e,r,l,g=h.minZoom!==void 0?h.minZoom:Km,v=h.maxZoom!==void 0?h.maxZoom:28,w=h.zoomFactor!==void 0?h.zoomFactor:2,T=h.multiWorld!==void 0?h.multiWorld:!1,S=h.smoothResolutionConstraint!==void 0?h.smoothResolutionConstraint:!0,k=h.showFullExtent!==void 0?h.showFullExtent:!1,F=Bd(h.projection,"EPSG:3857"),j=F.getExtent(),J=h.constrainOnlyCenter,he=h.extent;if(!T&&!he&&F.isGlobal()&&(J=!1,he=j),h.resolutions!==void 0){let q=h.resolutions;r=q[g],l=q[v]!==void 0?q[v]:q[q.length-1],h.constrainResolution?e=Ux(q,S,!J&&he,k):e=Hm(r,l,S,!J&&he,k)}else{let Z=(j?Math.max($i(j),ln(j)):360*Mh.degrees/F.getMetersPerUnit())/256/Math.pow(2,Km),ne=Z/Math.pow(2,28-Km);r=h.maxResolution,r!==void 0?g=0:r=Z/Math.pow(w,g),l=h.minResolution,l===void 0&&(h.maxZoom!==void 0?h.maxResolution!==void 0?l=r/Math.pow(w,v):l=Z/Math.pow(w,v):l=ne),v=g+Math.floor(Math.log(r/l)/Math.log(w)),l=r/Math.pow(w,v-g),h.constrainResolution?e=$x(w,r,l,S,!J&&he,k):e=Hm(r,l,S,!J&&he,k)}return{constraint:e,maxResolution:r,minResolution:l,minZoom:g,zoomFactor:w}}function e2(h){if(h.enableRotation!==void 0?h.enableRotation:!0){let r=h.constrainRotation;return r===void 0||r===!0?Zx():r===!1?Ym:typeof r=="number"?Wx(r):Ym}return qx}function t2(h){return!(h.sourceCenter&&h.targetCenter&&!cn(h.sourceCenter,h.targetCenter)||h.sourceResolution!==h.targetResolution||h.sourceRotation!==h.targetRotation)}function Jm(h,e,r,l,a){let o=Math.cos(-a),g=Math.sin(-a),v=h[0]*o-h[1]*g,w=h[1]*o+h[0]*g;v+=(e[0]/2-r[0])*l,w+=(r[1]-e[1]/2)*l,g=-g;let T=v*o-w*g,S=w*o+v*g;return[T,S]}var eg=Qm;var tg=class extends Gx{constructor(e){let r=Object.assign({},e);delete r.source,super(r),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(Ht.SOURCE,this.handleSourcePropertyChange_);let l=e.source?e.source:null;this.setSource(l)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(Ht.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(Yr(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let e=this.getSource();e&&(this.sourceChangeKey_=Lr(e,li.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let r,l=this.getMapInternal();!e&&l&&(e=l.getView()),e instanceof eg?r={viewState:e.getState(),extent:e.calculateExtent()}:r=e,!r.layerStatesArray&&l&&(r.layerStatesArray=l.getLayerGroup().getLayerStatesArray());let a;r.layerStatesArray?a=r.layerStatesArray.find(g=>g.layer===this):a=this.getLayerState();let o=this.getExtent();return ig(a,r.viewState)&&(!o||Qi(o,r.extent))}getAttributions(e){if(!this.isVisible(e))return[];let r,l=this.getSource();if(l&&(r=l.getAttributions()),!r)return[];let a=e instanceof eg?e.getViewStateAndExtent():e,o=r(a);return Array.isArray(o)||(o=[o]),o}render(e,r){let l=this.getRenderer();return l.prepareFrame(e)?(this.rendered=!0,l.renderFrame(e,r)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,r){}renderDeferred(e){let r=this.getRenderer();r&&r.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(Ht.MAP,e)}getMapInternal(){return this.get(Ht.MAP)}setMap(e){this.mapPrecomposeKey_&&(Yr(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(Yr(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=Lr(e,Bs.PRECOMPOSE,function(r){let a=r.frameState.layerStatesArray,o=this.getLayerState(!1);si(!a.some(function(g){return g.layer===o.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),a.push(o)},this),this.mapRenderKey_=Lr(this,li.CHANGE,e.render,e),this.changed())}setSource(e){this.set(Ht.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}};function ig(h,e){if(!h.visible)return!1;let r=e.resolution;if(r<h.minResolution||r>=h.maxResolution)return!1;let l=e.zoom;return l>h.minZoom&&l<=h.maxZoom}var xo=tg;var Yx={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var na=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",ER=na.includes("firefox"),i2=na.includes("safari")&&!na.includes("chrom"),TR=i2&&(na.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(na)),MR=na.includes("webkit")&&!na.includes("edge"),AR=na.includes("macintosh");var ep=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Kx=typeof Image<"u"&&Image.prototype.decode;var PR=function(){let h=!1;try{let e=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return h}();function Wi(h,e,r,l){let a;return r&&r.length?a=r.shift():ep?a=new OffscreenCanvas(h||300,e||300):a=document.createElement("canvas"),h&&(a.width=h),e&&(a.height=e),a.getContext("2d",l)}var rg;function Hh(){return rg||(rg=Wi(1,1)),rg}function Jx(h){let e=h.canvas;e.width=1,e.height=1,h.clearRect(0,0,1,1)}function ng(h){return h&&h.parentNode?h.parentNode.removeChild(h):null}var sg=class extends gr{constructor(e){super();let r=e.element;r&&!e.target&&!r.style.pointerEvents&&(r.style.pointerEvents="auto"),this.element=r||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){ng(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&ng(this.element);for(let r=0,l=this.listenerKeys.length;r<l;++r)Yr(this.listenerKeys[r]);this.listenerKeys.length=0,this.map_=e,e&&((this.target_?this.target_:e.getOverlayContainerStopEvent()).appendChild(this.element),this.render!==ms&&this.listenerKeys.push(Lr(e,Yx.POSTRENDER,this.render,this)),e.render())}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}},ac=sg;var r2=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",bottom:0,right:0,fontSize:".8rem",padding:"0 10px"}),h},Qx=r2;var og=class extends ac{constructor(e={}){let r=Qx();r.className=e.className||"mbt-copyright",super({element:r,...e})}render({frameState:e}){if(!e){this.element.innerHTML="";return}let r=[];e?.layerStatesArray.forEach(a=>{let{layer:o}=a;e&&ig(a,e.viewState)&&o&&o.getSource&&o.getSource()&&o.getSource().getAttributions()&&(r=r.concat(o.getSource().getAttributions()(e)))});let l=Va(r)||[];this.element.innerHTML=l.join(" | ")}},ev=og;var bs={ADD:"add",REMOVE:"remove"};var tv={LENGTH:"length"},lc=class extends mi{constructor(e,r,l){super(e),this.element=r,this.index=l}},ag=class extends gr{constructor(e,r){if(super(),this.on,this.once,this.un,r=r||{},this.unique_=!!r.unique,this.array_=e||[],this.unique_)for(let l=0,a=this.array_.length;l<a;++l)this.assertUnique_(this.array_[l],l);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let r=0,l=e.length;r<l;++r)this.push(e[r]);return this}forEach(e){let r=this.array_;for(let l=0,a=r.length;l<a;++l)e(r[l],l,r)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(tv.LENGTH)}insertAt(e,r){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r),this.array_.splice(e,0,r),this.updateLength_(),this.dispatchEvent(new lc(bs.ADD,r,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);let r=this.getLength();return this.insertAt(r,e),this.getLength()}remove(e){let r=this.array_;for(let l=0,a=r.length;l<a;++l)if(r[l]===e)return this.removeAt(l)}removeAt(e){if(e<0||e>=this.getLength())return;let r=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new lc(bs.REMOVE,r,e)),r}setAt(e,r){let l=this.getLength();if(e>=l){this.insertAt(e,r);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r,e);let a=this.array_[e];this.array_[e]=r,this.dispatchEvent(new lc(bs.REMOVE,a,e)),this.dispatchEvent(new lc(bs.ADD,r,e))}updateLength_(){this.set(tv.LENGTH,this.array_.length)}assertUnique_(e,r){for(let l=0,a=this.array_.length;l<a;++l)if(this.array_[l]===e&&l!==r)throw new Error("Duplicate item added to a unique collection")}},Yh=ag;var lg=class h extends gr{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){let r=e;this.setGeometry(r)}else{let r=e;this.setProperties(r)}}clone(){let e=new h(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());let r=this.getGeometry();r&&e.setGeometry(r.clone());let l=this.getStyle();return l&&e.setStyle(l),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(Yr(this.geometryChangeKey_),this.geometryChangeKey_=null);let e=this.getGeometry();e&&(this.geometryChangeKey_=Lr(e,li.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?n2(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}};function n2(h){if(typeof h=="function")return h;let e;return Array.isArray(h)?e=h:(si(typeof h.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[h]),function(){return e}}var rs=lg;var Tt={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var vo={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var Ka={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"]};Ka.whitepoint={2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}};Ka.max=Ka.whitepoint[2].D65;Ka.rgb=function(h,e){e=e||Ka.whitepoint[2].E;var r=h[0]/e[0],l=h[1]/e[1],a=h[2]/e[2],o,g,v;return o=r*3.240969941904521+l*-1.537383177570093+a*-.498610760293,g=r*-.96924363628087+l*1.87596750150772+a*.041555057407175,v=r*.055630079696993+l*-.20397695888897+a*1.056971514242878,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o=o*12.92,g=g>.0031308?1.055*Math.pow(g,1/2.4)-.055:g=g*12.92,v=v>.0031308?1.055*Math.pow(v,1/2.4)-.055:v=v*12.92,o=Math.min(Math.max(0,o),1),g=Math.min(Math.max(0,g),1),v=Math.min(Math.max(0,v),1),[o*255,g*255,v*255]};vo.xyz=function(h,e){var r=h[0]/255,l=h[1]/255,a=h[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,l=l>.04045?Math.pow((l+.055)/1.055,2.4):l/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92;var o=r*.41239079926595+l*.35758433938387+a*.18048078840183,g=r*.21263900587151+l*.71516867876775+a*.072192315360733,v=r*.019330818715591+l*.11919477979462+a*.95053215224966;return e=e||Ka.whitepoint[2].E,[o*e[0],g*e[1],v*e[2]]};var Tn=Ka;var tp={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(h,e,r){var l,a,o,g,v,w,T,S,k,F,j,J,he;if(o=h[0],g=h[1],v=h[2],o===0)return[0,0,0];var q=.0011070564598794539;return e=e||"D65",r=r||2,k=Tn.whitepoint[r][e][0],F=Tn.whitepoint[r][e][1],j=Tn.whitepoint[r][e][2],J=4*k/(k+15*F+3*j),he=9*F/(k+15*F+3*j),l=g/(13*o)+J||0,a=v/(13*o)+he||0,T=o>8?F*Math.pow((o+16)/116,3):F*o*q,w=T*9*l/(4*a)||0,S=T*(12-3*l-20*a)/(4*a)||0,[w,T,S]}};Tn.luv=function(h,e,r){var l,a,o,g,v,w,T,S,k,F,j,J,he,q=.008856451679035631,Z=903.2962962962961;e=e||"D65",r=r||2,k=Tn.whitepoint[r][e][0],F=Tn.whitepoint[r][e][1],j=Tn.whitepoint[r][e][2],J=4*k/(k+15*F+3*j),he=9*F/(k+15*F+3*j),w=h[0],T=h[1],S=h[2],l=4*w/(w+15*T+3*S)||0,a=9*T/(w+15*T+3*S)||0;var ne=T/F;return o=ne<=q?Z*ne:116*Math.pow(ne,1/3)-16,g=13*o*(l-J),v=13*o*(a-he),[o,g,v]};var iv={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(h){var e=h[0],r=h[1],l=h[2],a,o,g;return g=l/360*2*Math.PI,a=r*Math.cos(g),o=r*Math.sin(g),[e,a,o]},xyz:function(h){return tp.xyz(iv.luv(h))}},rv=iv;tp.lchuv=function(h){var e=h[0],r=h[1],l=h[2],a=Math.sqrt(r*r+l*l),o=Math.atan2(l,r),g=o*360/2/Math.PI;return g<0&&(g+=360),[e,a,g]};Tn.lchuv=function(h){return tp.lchuv(Tn.luv(h))};var cg=fo(sv(),1),av=s2,ov={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function s2(h){var e,r=[],l=1,a;if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(h=String(h).toLowerCase(),cg.default[h])r=cg.default[h].slice(),a="rgb";else if(h==="transparent")l=0,a="rgb",r=[0,0,0];else if(h[0]==="#"){var o=h.slice(1),g=o.length,v=g<=4;l=1,v?(r=[parseInt(o[0]+o[0],16),parseInt(o[1]+o[1],16),parseInt(o[2]+o[2],16)],g===4&&(l=parseInt(o[3]+o[3],16)/255)):(r=[parseInt(o[0]+o[1],16),parseInt(o[2]+o[3],16),parseInt(o[4]+o[5],16)],g===8&&(l=parseInt(o[6]+o[7],16)/255)),r[0]||(r[0]=0),r[1]||(r[1]=0),r[2]||(r[2]=0),a="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(h)){var w=e[1];a=w.replace(/a$/,"");var T=a==="cmyk"?4:a==="gray"?1:3;r=e[2].trim().split(/\s*[,\/]\s*|\s+/),a==="color"&&(a=r.shift()),r=r.map(function(S,k){if(S[S.length-1]==="%")return S=parseFloat(S)/100,k===3?S:a==="rgb"?S*255:a[0]==="h"||a[0]==="l"&&!k?S*100:a==="lab"?S*125:a==="lch"?k<2?S*150:S*360:a[0]==="o"&&!k?S:a==="oklab"?S*.4:a==="oklch"?k<2?S*.4:S*360:S;if(a[k]==="h"||k===2&&a[a.length-1]==="h"){if(ov[S]!==void 0)return ov[S];if(S.endsWith("deg"))return parseFloat(S);if(S.endsWith("turn"))return parseFloat(S)*360;if(S.endsWith("grad"))return parseFloat(S)*360/400;if(S.endsWith("rad"))return parseFloat(S)*180/Math.PI}return S==="none"?0:parseFloat(S)}),l=r.length>T?r.pop():1}else/[0-9](?:\s|\/|,)/.test(h)&&(r=h.match(/([0-9]+)/g).map(function(S){return parseFloat(S)}),a=h.match(/([a-z])/ig)?.join("")?.toLowerCase()||"rgb");return{space:a,values:r,alpha:l}}var ip={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(h){var e=h[0]/360,r=h[1]/100,l=h[2]/100,a,o,g,v,w,T=0;if(r===0)return w=l*255,[w,w,w];for(o=l<.5?l*(1+r):l+r-l*r,a=2*l-o,v=[0,0,0];T<3;)g=e+1/3*-(T-1),g<0?g++:g>1&&g--,w=6*g<1?a+(o-a)*6*g:2*g<1?o:3*g<2?a+(o-a)*(2/3-g)*6:a,v[T++]=w*255;return v}};vo.hsl=function(h){var e=h[0]/255,r=h[1]/255,l=h[2]/255,a=Math.min(e,r,l),o=Math.max(e,r,l),g=o-a,v,w,T;return o===a?v=0:e===o?v=(r-l)/g:r===o?v=2+(l-e)/g:l===o&&(v=4+(e-r)/g),v=Math.min(v*60,360),v<0&&(v+=360),T=(a+o)/2,o===a?w=0:T<=.5?w=g/(o+a):w=g/(2-o-a),[v,w*100,T*100]};function hg(h){Array.isArray(h)&&h.raw&&(h=String.raw(...arguments)),h instanceof Number&&(h=+h);var e,r,l,a=av(h);if(!a.space)return[];let o=a.space[0]==="h"?ip.min:vo.min,g=a.space[0]==="h"?ip.max:vo.max;return e=Array(3),e[0]=Math.min(Math.max(a.values[0],o[0]),g[0]),e[1]=Math.min(Math.max(a.values[1],o[1]),g[1]),e[2]=Math.min(Math.max(a.values[2],o[2]),g[2]),a.space[0]==="h"&&(e=ip.rgb(e)),e.push(Math.min(Math.max(a.alpha,0),1)),e}function lv(h){return typeof h=="string"?h:fg(h)}var o2=1024,Kh={},ug=0;function cv(h){if(h.length===4)return h;let e=h.slice();return e[3]=1,e}function dg(h){let e=Tn.lchuv(vo.xyz(h));return e[3]=h[3],e}function hv(h){let e=Tn.rgb(rv.xyz(h));return e[3]=h[3],e}function rp(h){if(Kh.hasOwnProperty(h))return Kh[h];if(ug>=o2){let r=0;for(let l in Kh)r++&3||(delete Kh[l],--ug)}let e=hg(h);if(e.length!==4)throw new Error('Failed to parse "'+h+'" as color');for(let r of e)if(isNaN(r))throw new Error('Failed to parse "'+h+'" as color');return pg(e),Kh[h]=e,++ug,e}function bo(h){return Array.isArray(h)?h:rp(h)}function pg(h){return h[0]=Ii(h[0]+.5|0,0,255),h[1]=Ii(h[1]+.5|0,0,255),h[2]=Ii(h[2]+.5|0,0,255),h[3]=Ii(h[3],0,1),h}function fg(h){let e=h[0];e!=(e|0)&&(e=e+.5|0);let r=h[1];r!=(r|0)&&(r=r+.5|0);let l=h[2];l!=(l|0)&&(l=l+.5|0);let a=h[3]===void 0?1:Math.round(h[3]*1e3)/1e3;return"rgba("+e+","+r+","+l+","+a+")"}function uv(h){try{return rp(h),!0}catch{return!1}}function a2(h,e){return new Promise((r,l)=>{function a(){g(),r(h)}function o(){g(),l(new Error("Image load error"))}function g(){h.removeEventListener("load",a),h.removeEventListener("error",o)}h.addEventListener("load",a),h.addEventListener("error",o),e&&(h.src=e)})}function dv(h,e){return e&&(h.src=e),h.src&&Kx?new Promise((r,l)=>h.decode().then(()=>r(h)).catch(a=>h.complete&&h.width?r(h):l(a))):a2(h)}var gg=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let r in this.cache_){let l=this.cache_[r];!(e++&3)&&!l.hasListener()&&(delete this.cache_[r],delete this.patternCache_[r],--this.cacheSize_)}}}get(e,r,l){let a=mg(e,r,l);return a in this.cache_?this.cache_[a]:null}getPattern(e,r,l){let a=mg(e,r,l);return a in this.patternCache_?this.patternCache_[a]:null}set(e,r,l,a,o){let g=mg(e,r,l),v=g in this.cache_;this.cache_[g]=a,o&&(a.getImageState()===Tt.IDLE&&a.load(),a.getImageState()===Tt.LOADING?a.ready().then(()=>{this.patternCache_[g]=Hh().createPattern(a.getImage(1),"repeat")}):this.patternCache_[g]=Hh().createPattern(a.getImage(1),"repeat")),v||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function mg(h,e,r){let l=r?bo(r):"null";return e+":"+h+":"+l}var Ns=new gg;var Jh=null,yg=class extends Rd{constructor(e,r,l,a,o){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=l,this.canvas_={},this.color_=o,this.imageState_=a===void 0?Tt.IDLE:a,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=r,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===Tt.LOADED){Jh||(Jh=Wi(1,1,void 0,{willReadFrequently:!0})),Jh.drawImage(this.image_,0,0);try{Jh.getImageData(0,0,1,1),this.tainted_=!1}catch{Jh=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(li.CHANGE)}handleImageError_(){this.imageState_=Tt.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=Tt.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],r=this.size_[1],l=Wi(e,r);l.fillRect(0,0,e,r),this.hitDetectionImage_=l.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===Tt.IDLE){this.image_||this.initializeImage_(),this.imageState_=Tt.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&dv(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==Tt.LOADED)return;let r=this.image_,l=document.createElement("canvas");l.width=Math.ceil(r.width*e),l.height=Math.ceil(r.height*e);let a=l.getContext("2d");a.scale(e,e),a.drawImage(r,0,0),a.globalCompositeOperation="multiply",a.fillStyle=lv(this.color_),a.fillRect(0,0,l.width/e,l.height/e),a.globalCompositeOperation="destination-in",a.drawImage(r,0,0),this.canvas_[e]=l}ready(){return this.ready_||(this.ready_=new Promise(e=>{this.imageState_===Tt.LOADED||this.imageState_===Tt.ERROR?e():this.addEventListener(li.CHANGE,function r(){(this.imageState_===Tt.LOADED||this.imageState_===Tt.ERROR)&&(this.removeEventListener(li.CHANGE,r),e())})})),this.ready_}};function cc(h,e,r,l,a,o){let g=e===void 0?void 0:Ns.get(e,r,a);return g||(g=new yg(h,h instanceof HTMLImageElement?h.src||void 0:e,r,l,a),Ns.set(e,r,a,g,o)),o&&g&&!Ns.getPattern(e,r,a)&&Ns.set(e,r,a,g,o),g}var _g=class h{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){let r=cc(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));r.ready().then(()=>{this.patternImage_=null}),r.getImageState()===Tt.IDLE&&r.load(),r.getImageState()===Tt.LOADING&&(this.patternImage_=r)}this.color_=e}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Fr=_g;var xg=class h{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}},nr=xg;function sa(h,e){return Array.isArray(h)?h:(e===void 0?e=[h,h]:(e[0]=h,e[1]=h),e)}var vg=class h{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=sa(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return St()}getImage(e){return St()}getHitDetectionImage(){return St()}getPixelRatio(e){return 1}getImageState(){return St()}getImageSize(){return St()}getOrigin(){return St()}getSize(){return St()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=sa(e)}listenImageChange(e){St()}load(){St()}unlistenImageChange(e){St()}ready(){return Promise.resolve()}},np=vg;function Mn(h){return h?Array.isArray(h)?fg(h):typeof h=="object"&&"src"in h?l2(h):h:null}function l2(h){if(!h.offset||!h.size)return Ns.getPattern(h.src,"anonymous",h.color);let e=h.src+":"+h.offset,r=Ns.getPattern(e,void 0,h.color);if(r)return r;let l=Ns.get(h.src,"anonymous",null);if(l.getImageState()!==Tt.LOADED)return null;let a=Wi(h.size[0],h.size[1]);return a.drawImage(l.getImage(1),h.offset[0],h.offset[1],h.size[0],h.size[1],0,0,h.size[0],h.size[1]),cc(a.canvas,e,void 0,Tt.LOADED,h.color,!0),Ns.getPattern(e,void 0,h.color)}var c2=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`].join(""),"i"),pv=["style","variant","weight","size","lineHeight","family"],bg=function(h){let e=h.match(c2);if(!e)return null;let r={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let l=0,a=pv.length;l<a;++l){let o=e[l+1];o!==void 0&&(r[pv[l]]=o)}return r.families=r.family.split(/,\s?/),r};var op="10px sans-serif",sr="#000",Vs="round",An=[],Pn=0,Gs="round",wo=10,So="#000",aa="center",Ja="middle",Co=[0,0,0,0],Io=1,oa=new gr,hc=null,wg,Sg={},fv=function(){let e="32px ",r=["monospace","serif"],l=r.length,a="wmytzilWMYTZIL@#/&?$%10\uF013",o,g;function v(T,S,k){let F=!0;for(let j=0;j<l;++j){let J=r[j];if(g=sp(T+" "+S+" "+e+J,a),k!=J){let he=sp(T+" "+S+" "+e+k+","+J,a);F=F&&he!=g}}return!!F}function w(){let T=!0,S=oa.getKeys();for(let k=0,F=S.length;k<F;++k){let j=S[k];oa.get(j)<100&&(v.apply(this,j.split(`
578
578
  `))?(Yl(Sg),hc=null,wg=void 0,oa.set(j,100)):(oa.set(j,oa.get(j)+1,!0),T=!1))}T&&(clearInterval(o),o=void 0)}return function(T){let S=bg(T);if(!S)return;let k=S.families;for(let F=0,j=k.length;F<j;++F){let J=k[F],he=S.style+`
579
579
  `+S.weight+`
580
580
  `+J;oa.get(he)===void 0&&(oa.set(he,100,!0),v(S.style,S.weight,J)||(oa.set(he,0,!0),o===void 0&&(o=setInterval(w,32))))}}}(),h2=function(){let h;return function(e){let r=Sg[e];if(r==null){if(ep){let l=bg(e),a=mv(e,"\u017Dg");r=(isNaN(Number(l.lineHeight))?1.2:Number(l.lineHeight))*(a.actualBoundingBoxAscent+a.actualBoundingBoxDescent)}else h||(h=document.createElement("div"),h.innerHTML="M",h.style.minHeight="0",h.style.maxHeight="none",h.style.height="auto",h.style.padding="0",h.style.border="none",h.style.position="absolute",h.style.display="block",h.style.left="-99999px"),h.style.font=e,document.body.appendChild(h),r=h.offsetHeight,document.body.removeChild(h);Sg[e]=r}return r}}();function mv(h,e){return hc||(hc=Wi(1,1)),h!=wg&&(hc.font=h,wg=hc.font),hc.measureText(e)}function sp(h,e){return mv(h,e).width}function Cg(h,e,r){if(e in r)return r[e];let l=e.split(`
@@ -582,7 +582,7 @@ uniform ${D} ${z} u_${G};
582
582
  `||T===S){o=Math.max(o,g),a.push(g),g=0,v+=w;continue}let F=e[T+1]||h.font,j=sp(F,k);r.push(j),g+=j;let J=h2(F);l.push(J),w=Math.max(w,J)}return{width:o,height:v,widths:r,heights:l,lineWidths:a}}function yv(h,e,r,l,a,o,g,v,w,T,S){h.save(),r!==1&&(h.globalAlpha===void 0?h.globalAlpha=k=>k.globalAlpha*=r:h.globalAlpha*=r),e&&h.transform.apply(h,e),l.contextInstructions?(h.translate(w,T),h.scale(S[0],S[1]),u2(l,h)):S[0]<0||S[1]<0?(h.translate(w,T),h.scale(S[0],S[1]),h.drawImage(l,a,o,g,v,0,0,g,v)):h.drawImage(l,a,o,g,v,w,T,g*S[0],v*S[1]),h.restore()}function u2(h,e){let r=h.contextInstructions;for(let l=0,a=r.length;l<a;l+=2)Array.isArray(r[l+1])?e[r[l]].apply(e,r[l+1]):e[r[l]]=r[l+1]}var Ig=class h extends np{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,rotation:e.rotation!==void 0?e.rotation:0,scale:e.scale!==void 0?e.scale:1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode}),this.canvases_,this.hitDetectionCanvas_=null,this.fill_=e.fill!==void 0?e.fill:null,this.origin_=[0,0],this.points_=e.points,this.radius_=e.radius,this.radius2_=e.radius2,this.angle_=e.angle!==void 0?e.angle:0,this.stroke_=e.stroke!==void 0?e.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?Tt.LOADING:Tt.LOADED,this.imageState_===Tt.LOADING&&this.ready().then(()=>this.imageState_=Tt.LOADED),this.render()}clone(){let e=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}getAnchor(){let e=this.size_,r=this.getDisplacement(),l=this.getScaleArray();return[e[0]/2-r[0]/l[0],e[1]/2+r[1]/l[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){let r=this.canvases_[e];if(!r){let l=this.renderOptions_,a=Wi(l.size*e,l.size*e);this.draw_(l,a,e),r=a.canvas,this.canvases_[e]=r}return r}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius_}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,r,l){if(r===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return r;let a=this.radius_,o=this.radius2_===void 0?a:this.radius2_;if(a<o){let ve=a;a=o,o=ve}let g=this.radius2_===void 0?this.points_:this.points_*2,v=2*Math.PI/g,w=o*Math.sin(v),T=Math.sqrt(o*o-w*w),S=a-T,k=Math.sqrt(w*w+S*S),F=k/w;if(e==="miter"&&F<=l)return F*r;let j=r/2/F,J=r/2*(S/k),q=Math.sqrt((a+j)*(a+j)+J*J)-a;if(this.radius2_===void 0||e==="bevel")return q*2;let Z=a*Math.sin(v),ne=Math.sqrt(a*a-Z*Z),me=o-ne,fe=Math.sqrt(Z*Z+me*me)/Z;if(fe<=l){let ve=fe*r/2-o-a;return 2*Math.max(q,ve)}return q*2}createRenderOptions(){let e=Vs,r=Gs,l=0,a=null,o=0,g,v=0;this.stroke_&&(g=Mn(this.stroke_.getColor()??So),v=this.stroke_.getWidth()??Io,a=this.stroke_.getLineDash(),o=this.stroke_.getLineDashOffset()??0,r=this.stroke_.getLineJoin()??Gs,e=this.stroke_.getLineCap()??Vs,l=this.stroke_.getMiterLimit()??wo);let w=this.calculateLineJoinSize_(r,v,l),T=Math.max(this.radius_,this.radius2_||0),S=Math.ceil(2*T+w);return{strokeStyle:g,strokeWidth:v,size:S,lineCap:e,lineDash:a,lineDashOffset:o,lineJoin:r,miterLimit:l}}render(){this.renderOptions_=this.createRenderOptions();let e=this.renderOptions_.size;this.canvases_={},this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,r,l){if(r.scale(l,l),r.translate(e.size/2,e.size/2),this.createPath_(r),this.fill_){let a=this.fill_.getColor();a===null&&(a=sr),r.fillStyle=Mn(a),r.fill()}e.strokeStyle&&(r.strokeStyle=e.strokeStyle,r.lineWidth=e.strokeWidth,e.lineDash&&(r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset),r.lineCap=e.lineCap,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit,r.stroke())}createHitDetectionCanvas_(e){let r;if(this.fill_){let l=this.fill_.getColor(),a=0;typeof l=="string"&&(l=bo(l)),l===null?a=1:Array.isArray(l)&&(a=l.length===4?l[3]:1),a===0&&(r=Wi(e.size,e.size),this.drawHitDetectionCanvas_(e,r))}return r?r.canvas:this.getImage(1)}createPath_(e){let r=this.points_,l=this.radius_;if(r===1/0)e.arc(0,0,l,0,2*Math.PI);else{let a=this.radius2_===void 0?l:this.radius2_;this.radius2_!==void 0&&(r*=2);let o=this.angle_-Math.PI/2,g=2*Math.PI/r;for(let v=0;v<r;v++){let w=o+v*g,T=v%2===0?l:a;e.lineTo(T*Math.cos(w),T*Math.sin(w))}e.closePath()}}drawHitDetectionCanvas_(e,r){r.translate(e.size/2,e.size/2),this.createPath_(r),r.fillStyle=sr,r.fill(),e.strokeStyle&&(r.strokeStyle=e.strokeStyle,r.lineWidth=e.strokeWidth,e.lineDash&&(r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset),r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit,r.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},ap=Ig;var Eg=class h extends ap{constructor(e){e=e||{radius:5},super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:e.scale!==void 0?e.scale:1,rotation:e.rotation!==void 0?e.rotation:0,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode})}clone(){let e=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}setRadius(e){this.radius_=e,this.render()}},Rn=Eg;var la=class h{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=_v,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new h({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(r){return r.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=_v,this.geometry_=e}setZIndex(e){this.zIndex_=e}};function xv(h){let e;if(typeof h=="function")e=h;else{let r;Array.isArray(h)?r=h:(si(typeof h.getZIndex=="function","Expected an `Style` or an array of `Style`"),r=[h]),e=function(){return r}}return e}var Tg=null;function vv(h,e){if(!Tg){let r=new Fr({color:"rgba(255,255,255,0.4)"}),l=new nr({color:"#3399CC",width:1.25});Tg=[new la({image:new Rn({fill:r,stroke:l,radius:5}),fill:r,stroke:l})]}return Tg}function bv(){let h={},e=[255,255,255,1],r=[0,153,255,1],l=3;return h.Polygon=[new la({fill:new Fr({color:[255,255,255,.5]})})],h.MultiPolygon=h.Polygon,h.LineString=[new la({stroke:new nr({color:e,width:l+2})}),new la({stroke:new nr({color:r,width:l})})],h.MultiLineString=h.LineString,h.Circle=h.Polygon.concat(h.LineString),h.Point=[new la({image:new Rn({radius:l*2,fill:new Fr({color:r}),stroke:new nr({color:e,width:l/2})}),zIndex:1/0})],h.MultiPoint=h.Point,h.GeometryCollection=h.Polygon.concat(h.LineString,h.Point),h}function _v(h){return h.getGeometry()}var zr=la;var d2="#333",Mg=class h{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.scale_=e.scale,this.scaleArray_=sa(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new Fr({color:d2}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=sa(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}},wv=Mg;var Fv=fo(Rg(),1);function Sv(h,e,r,l){return r!==void 0&&l!==void 0?[r/h,l/e]:r!==void 0?r/h:l!==void 0?l/e:1}var kg=class h extends np{constructor(e){e=e||{};let r=e.opacity!==void 0?e.opacity:1,l=e.rotation!==void 0?e.rotation:0,a=e.scale!==void 0?e.scale:1,o=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:r,rotation:l,scale:a,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:o,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;let g=e.img!==void 0?e.img:null,v=e.src;si(!(v!==void 0&&g),"`image` and `src` cannot be provided at the same time"),(v===void 0||v.length===0)&&g&&(v=g.src||Gt(g)),si(v!==void 0&&v.length>0,"A defined and non-empty `src` or `image` must be provided"),si(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let w;if(e.src!==void 0?w=Tt.IDLE:g!==void 0&&(g instanceof HTMLImageElement?g.complete?w=g.src?Tt.LOADED:Tt.IDLE:w=Tt.LOADING:w=Tt.LOADED),this.color_=e.color!==void 0?bo(e.color):null,this.iconImage_=cc(g,v,this.crossOrigin_,w,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,e.width!==void 0||e.height!==void 0){let T,S;if(e.size)[T,S]=e.size;else{let k=this.getImage(1);if(k.width&&k.height)T=k.width,S=k.height;else if(k instanceof HTMLImageElement){this.initialOptions_=e;let F=()=>{if(this.unlistenImageChange(F),!this.initialOptions_)return;let j=this.iconImage_.getSize();this.setScale(Sv(j[0],j[1],e.width,e.height))};this.listenImageChange(F);return}}T!==void 0&&this.setScale(Sv(T,S,e.width,e.height))}}clone(){let e,r,l;return this.initialOptions_?(r=this.initialOptions_.width,l=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new h({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:r,height:l,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;let a=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!a)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=a[0]),this.anchorYUnits_=="fraction"&&(e[1]*=a[1])}if(this.anchorOrigin_!="top-left"){if(!a)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+a[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+a[1])}this.normalizedAnchor_=e}let r=this.getDisplacement(),l=this.getScaleArray();return[e[0]-r[0]/l[0],e[1]+r[1]/l[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){let r=this.getSize(),l=this.iconImage_.getSize();if(!r||!l)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=l[0]-r[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=l[1]-r[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==Tt.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){let e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==Tt.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(li.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(li.CHANGE,e)}ready(){return this.iconImage_.ready()}},Qh=kg;var uc=0,dc=0,Ri=1<<uc++,ft=1<<uc++,ns=1<<uc++,xr=1<<uc++,js=1<<uc++,Kr=Math.pow(2,uc)-1,Iv={[Ri]:"boolean",[ft]:"number",[ns]:"string",[xr]:"color",[js]:"number[]"},p2=Object.keys(Iv).map(Number).sort(Ds);function Or(h){let e=[];for(let r of p2)f2(h,r)&&e.push(Iv[r]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function f2(h,e){return(h&e)===e}function Ss(h,e){return!!(h&e)}function lp(h,e){return h===e}var ws=class{constructor(e,r){this.type=e,this.value=r}},Lg=class{constructor(e,r,...l){this.type=e,this.operator=r,this.args=l}};function Dg(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,style:{}}}function m2(h){switch(h){case"string":return ns;case"color":return xr;case"number":return ft;case"boolean":return Ri;case"number[]":return js;default:throw new Error(`Unrecognized type hint: ${h}`)}}function Yt(h,e,r){switch(typeof h){case"boolean":return new ws(Ri,h);case"number":return new ws(ft,h);case"string":{let a=ns;return uv(h)&&(a|=xr),lp(a&r,dc)||(a&=r),new ws(a,h)}default:}if(!Array.isArray(h))throw new Error("Expression must be an array or a primitive value");if(h.length===0)throw new Error("Empty expression");if(typeof h[0]=="string")return T2(h,e,r);for(let a of h)if(typeof a!="number")throw new Error("Expected an array of numbers");let l=js;return(h.length===3||h.length===4)&&(l|=xr),r&&(l&=r),new ws(l,h)}var Fe={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette"},g2={[Fe.Get]:Rt(([h,e])=>e!==void 0?m2(e.value):Kr,Nt(1,2),y2),[Fe.Var]:Rt(([h])=>h.type,Nt(1,1),_2),[Fe.Id]:Rt(ft|ns,eu,x2),[Fe.Concat]:Rt(ns,Nt(2,1/0),qt(Kr)),[Fe.GeometryType]:Rt(ns,eu,v2),[Fe.Resolution]:Rt(ft,eu),[Fe.Zoom]:Rt(ft,eu),[Fe.Time]:Rt(ft,eu),[Fe.Any]:Rt(Ri,Nt(2,1/0),qt(Ri)),[Fe.All]:Rt(Ri,Nt(2,1/0),qt(Ri)),[Fe.Not]:Rt(Ri,Nt(1,1),qt(Ri)),[Fe.Equal]:Rt(Ri,Nt(2,2),qt(Kr),ca),[Fe.NotEqual]:Rt(Ri,Nt(2,2),qt(Kr),ca),[Fe.GreaterThan]:Rt(Ri,Nt(2,2),qt(Kr),ca),[Fe.GreaterThanOrEqualTo]:Rt(Ri,Nt(2,2),qt(Kr),ca),[Fe.LessThan]:Rt(Ri,Nt(2,2),qt(Kr),ca),[Fe.LessThanOrEqualTo]:Rt(Ri,Nt(2,2),qt(Kr),ca),[Fe.Multiply]:Rt(h=>{let e=ft|xr;for(let r=0;r<h.length;r++)e&=h[r].type;return e},Nt(2,1/0),qt(ft|xr),ca),[Fe.Coalesce]:Rt(h=>{let e=Kr;for(let r=1;r<h.length;r+=2)e&=h[r].type;return e&=h[h.length-1].type,e},Nt(2,1/0),qt(Kr),ca),[Fe.Divide]:Rt(ft,Nt(2,2),qt(ft)),[Fe.Add]:Rt(ft,Nt(2,1/0),qt(ft)),[Fe.Subtract]:Rt(ft,Nt(2,2),qt(ft)),[Fe.Clamp]:Rt(ft,Nt(3,3),qt(ft)),[Fe.Mod]:Rt(ft,Nt(2,2),qt(ft)),[Fe.Pow]:Rt(ft,Nt(2,2),qt(ft)),[Fe.Abs]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Floor]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Ceil]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Round]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Sin]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Cos]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Atan]:Rt(ft,Nt(1,2),qt(ft)),[Fe.Sqrt]:Rt(ft,Nt(1,1),qt(ft)),[Fe.Match]:Rt(h=>{let e=Kr;for(let r=2;r<h.length;r+=2)e&=h[r].type;return e&=h[h.length-1].type,e},Nt(4,1/0),Cv,w2),[Fe.Between]:Rt(Ri,Nt(3,3),qt(ft)),[Fe.Interpolate]:Rt(h=>{let e=xr|ft;for(let r=3;r<h.length;r+=2)e&=h[r].type;return e},Nt(6,1/0),Cv,S2),[Fe.Case]:Rt(h=>{let e=Kr;for(let r=1;r<h.length;r+=2)e&=h[r].type;return e&=h[h.length-1].type,e},Nt(3,1/0),b2,C2),[Fe.In]:Rt(Ri,Nt(2,2),I2),[Fe.Number]:Rt(ft,Nt(1,1/0),qt(Kr)),[Fe.String]:Rt(ns,Nt(1,1/0),qt(Kr)),[Fe.Array]:Rt(h=>h.length===3||h.length===4?js|xr:js,Nt(1,1/0),qt(ft)),[Fe.Color]:Rt(xr,Nt(1,4),qt(ft)),[Fe.Band]:Rt(ft,Nt(1,3),qt(ft)),[Fe.Palette]:Rt(xr,Nt(2,2),E2)};function y2(h,e){let r=Yt(h[1],e);if(!(r instanceof ws))throw new Error("Expected a literal argument for get operation");if(typeof r.value!="string")throw new Error("Expected a string argument for get operation");if(e.properties.add(r.value),h.length===3){let l=Yt(h[2],e);return[r,l]}return[r]}function _2(h,e,r,l){let a=h[1];if(typeof a!="string")throw new Error("Expected a string argument for var operation");if(e.variables.add(a),!("variables"in e.style)||e.style.variables[a]===void 0)return[new ws(Kr,a)];let o=e.style.variables[a],g=Yt(o,e);if(g.value=a,l&&!Ss(l,g.type))throw new Error(`The variable ${a} has type ${Or(g.type)} but the following type was expected: ${Or(l)}`);return[g]}function x2(h,e){e.featureId=!0}function v2(h,e){e.geometryType=!0}function eu(h,e){let r=h[0];if(h.length!==1)throw new Error(`Expected no arguments for ${r} operation`);return[]}function Nt(h,e){return function(r,l){let a=r[0],o=r.length-1;if(h===e){if(o!==h){let g=h===1?"":"s";throw new Error(`Expected ${h} argument${g} for ${a}, got ${o}`)}}else if(o<h||o>e){let g=e===1/0?`${h} or more`:`${h} to ${e}`;throw new Error(`Expected ${g} arguments for ${a}, got ${o}`)}}}function qt(h){return function(e,r){let l=e[0],a=e.length-1,o=new Array(a);for(let g=0;g<a;++g){let v=Yt(e[g+1],r);if(!Ss(h,v.type)){let w=Or(h),T=Or(v.type);throw new Error(`Unexpected type for argument ${g} of ${l} operation, got ${w} but expected ${T}`)}v.type&=h,o[g]=v}return o}}function ca(h,e,r){let l=h[0],a=h.length-1,o=Kr;for(let v=0;v<r.length;++v)o&=r[v].type;if(o===dc)throw new Error(`No common type could be found for arguments of ${l} operation`);let g=new Array(a);for(let v=0;v<a;++v)g[v]=Yt(h[v+1],e,o);return g}function b2(h,e){let r=h[0],l=h.length-1;if(l%2===0)throw new Error(`An odd amount of arguments was expected for operation ${r}, got ${JSON.stringify(l)} instead`)}function Cv(h,e){let r=h[0],l=h.length-1;if(l%2===1)throw new Error(`An even amount of arguments was expected for operation ${r}, got ${JSON.stringify(l)} instead`)}function w2(h,e,r,l){let a=h.length-1,g=Yt(h[1],e).type,v=Yt(h[h.length-1],e),w=l!==void 0?l&v.type:v.type,T=new Array(a-2);for(let k=0;k<a-2;k+=2){let F=Yt(h[k+2],e),j=Yt(h[k+3],e);g&=F.type,w&=j.type,T[k]=F,T[k+1]=j}let S=ns|ft|Ri;if(!Ss(S,g))throw new Error(`Expected an input of type ${Or(S)} for the interpolate operation, got ${Or(g)} instead`);if(lp(w,dc))throw new Error("Could not find a common output type for the following match operation: "+JSON.stringify(h));for(let k=0;k<a-2;k+=2){let F=Yt(h[k+2],e,g),j=Yt(h[k+3],e,w);T[k]=F,T[k+1]=j}return[Yt(h[1],e,g),...T,Yt(h[h.length-1],e,w)]}function S2(h,e,r,l){let a=h[1],o;switch(a[0]){case"linear":o=1;break;case"exponential":if(o=a[1],typeof o!="number")throw new Error(`Expected a number base for exponential interpolation, got ${JSON.stringify(o)} instead`);break;default:o=null}if(!o)throw new Error(`Invalid interpolation type: ${JSON.stringify(a)}`);o=Yt(o,e);let g=Yt(h[2],e);if(!Ss(ft,g.type))throw new Error(`Expected an input of type number for the interpolate operation, got ${Or(g.type)} instead`);g=Yt(h[2],e,ft);let v=new Array(h.length-3);for(let w=0;w<v.length;w+=2){let T=Yt(h[w+3],e);if(!Ss(ft,T.type))throw new Error(`Expected all stop input values in the interpolate operation to be of type number, got ${Or(T.type)} at position ${w+2} instead`);let S=Yt(h[w+4],e);if(!Ss(ft|xr,S.type))throw new Error(`Expected all stop output values in the interpolate operation to be a number or color, got ${Or(S.type)} at position ${w+3} instead`);T=Yt(h[w+3],e,ft),S=Yt(h[w+4],e,ft|xr),v[w]=T,v[w+1]=S}return[o,g,...v]}function C2(h,e,r,l){let a=Yt(h[h.length-1],e),o=l!==void 0?l&a.type:a.type,g=new Array(h.length-1);for(let v=0;v<g.length-1;v+=2){let w=Yt(h[v+1],e),T=Yt(h[v+2],e);if(!Ss(Ri,w.type))throw new Error(`Expected all conditions in the case operation to be of type boolean, got ${Or(w.type)} at position ${v} instead`);o&=T.type,g[v]=w,g[v+1]=T}if(lp(o,dc))throw new Error("Could not find a common output type for the following case operation: "+JSON.stringify(h));for(let v=0;v<g.length-1;v+=2)g[v+1]=Yt(h[v+2],e,o);return g[g.length-1]=Yt(h[h.length-1],e,o),g}function I2(h,e){let r=h[2];if(!Array.isArray(r))throw new Error('The "in" operator was provided a literal value which was not an array as second argument.');if(typeof r[0]=="string"){if(r[0]!=="literal")throw new Error('For the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions.');if(!Array.isArray(r[1]))throw new Error('The "in" operator was provided a literal value which was not an array as second argument.');r=r[1]}let l=ns|ft,a=new Array(r.length);for(let g=0;g<a.length;g++){let v=Yt(r[g],e);l&=v.type,a[g]=v}if(lp(l,dc))throw new Error("Could not find a common type for the following in operation: "+JSON.stringify(h));return[Yt(h[1],e,l),...a]}function E2(h,e){let r=Yt(h[1],e,ft);if(r.type!==ft)throw new Error(`The first argument of palette must be an number, got ${Or(r.type)} instead`);let l=h[2];if(!Array.isArray(l))throw new Error("The second argument of palette must be an array");let a=new Array(l.length);for(let o=0;o<a.length;o++){let g=Yt(l[o],e,xr);if(!(g instanceof ws))throw new Error(`The palette color at index ${o} must be a literal value`);if(!Ss(g.type,xr))throw new Error(`The palette color at index ${o} should be of type color, got ${Or(g.type)} instead`);a[o]=g}return[r,...a]}function Rt(h,...e){return function(r,l,a){let o=r[0],g=[];for(let w=0;w<e.length;w++)g=e[w](r,l,g,a)||g;let v=typeof h=="function"?h(g):h;if(a!==void 0){if(!Ss(v,a))throw new Error(`The following expression was expected to return ${Or(a)}, but returns ${Or(v)} instead: ${JSON.stringify(r)}`);v&=a}if(v===dc)throw new Error(`No matching type was found for the following expression: ${JSON.stringify(r)}`);return new Lg(v,o,...g)}}function T2(h,e,r){let l=h[0],a=g2[l];if(!a)throw new Error(`Unknown operator: ${l}`);return a(h,e,r)}function Fg(h){if(!h)return"";let e=h.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Fg(h.getGeometries()[0]);default:return""}}function zg(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function $s(h,e,r){let l=Yt(h,r);if(!Ss(e,l.type)){let a=Or(e),o=Or(l.type);throw new Error(`Expected expression to be of type ${a}, got ${o}`)}return Us(l,r)}function Us(h,e){if(h instanceof ws){if(h.type===xr&&typeof h.value=="string"){let l=rp(h.value);return function(){return l}}return function(){return h.value}}let r=h.operator;switch(r){case Fe.Number:case Fe.String:case Fe.Coalesce:return M2(h,e);case Fe.Get:case Fe.Var:return A2(h,e);case Fe.Id:return l=>l.featureId;case Fe.GeometryType:return l=>l.geometryType;case Fe.Concat:{let l=h.args.map(a=>Us(a,e));return a=>"".concat(...l.map(o=>o(a).toString()))}case Fe.Resolution:return l=>l.resolution;case Fe.Any:case Fe.All:case Fe.Not:return R2(h,e);case Fe.Equal:case Fe.NotEqual:case Fe.LessThan:case Fe.LessThanOrEqualTo:case Fe.GreaterThan:case Fe.GreaterThanOrEqualTo:return P2(h,e);case Fe.Multiply:case Fe.Divide:case Fe.Add:case Fe.Subtract:case Fe.Clamp:case Fe.Mod:case Fe.Pow:case Fe.Abs:case Fe.Floor:case Fe.Ceil:case Fe.Round:case Fe.Sin:case Fe.Cos:case Fe.Atan:case Fe.Sqrt:return k2(h,e);case Fe.Case:return L2(h,e);case Fe.Match:return D2(h,e);case Fe.Interpolate:return F2(h,e);default:throw new Error(`Unsupported operator ${r}`)}}function M2(h,e){let r=h.operator,l=h.args.length,a=new Array(l);for(let o=0;o<l;++o)a[o]=Us(h.args[o],e);switch(r){case Fe.Coalesce:return o=>{for(let g=0;g<l;++g){let v=a[g](o);if(typeof v<"u"&&v!==null)return v}throw new Error("Expected one of the values to be non-null")};case Fe.Number:case Fe.String:return o=>{for(let g=0;g<l;++g){let v=a[g](o);if(typeof v===r)return v}throw new Error(`Expected one of the values to be a ${r}`)};default:throw new Error(`Unsupported assertion operator ${r}`)}}function A2(h,e){let l=h.args[0].value;switch(h.operator){case Fe.Get:return a=>a.properties[l];case Fe.Var:return a=>a.variables[l];default:throw new Error(`Unsupported accessor operator ${h.operator}`)}}function P2(h,e){let r=h.operator,l=Us(h.args[0],e),a=Us(h.args[1],e);switch(r){case Fe.Equal:return o=>l(o)===a(o);case Fe.NotEqual:return o=>l(o)!==a(o);case Fe.LessThan:return o=>l(o)<a(o);case Fe.LessThanOrEqualTo:return o=>l(o)<=a(o);case Fe.GreaterThan:return o=>l(o)>a(o);case Fe.GreaterThanOrEqualTo:return o=>l(o)>=a(o);default:throw new Error(`Unsupported comparison operator ${r}`)}}function R2(h,e){let r=h.operator,l=h.args.length,a=new Array(l);for(let o=0;o<l;++o)a[o]=Us(h.args[o],e);switch(r){case Fe.Any:return o=>{for(let g=0;g<l;++g)if(a[g](o))return!0;return!1};case Fe.All:return o=>{for(let g=0;g<l;++g)if(!a[g](o))return!1;return!0};case Fe.Not:return o=>!a[0](o);default:throw new Error(`Unsupported logical operator ${r}`)}}function k2(h,e){let r=h.operator,l=h.args.length,a=new Array(l);for(let o=0;o<l;++o)a[o]=Us(h.args[o],e);switch(r){case Fe.Multiply:return o=>{let g=1;for(let v=0;v<l;++v)g*=a[v](o);return g};case Fe.Divide:return o=>a[0](o)/a[1](o);case Fe.Add:return o=>{let g=0;for(let v=0;v<l;++v)g+=a[v](o);return g};case Fe.Subtract:return o=>a[0](o)-a[1](o);case Fe.Clamp:return o=>{let g=a[0](o),v=a[1](o);if(g<v)return v;let w=a[2](o);return g>w?w:g};case Fe.Mod:return o=>a[0](o)%a[1](o);case Fe.Pow:return o=>Math.pow(a[0](o),a[1](o));case Fe.Abs:return o=>Math.abs(a[0](o));case Fe.Floor:return o=>Math.floor(a[0](o));case Fe.Ceil:return o=>Math.ceil(a[0](o));case Fe.Round:return o=>Math.round(a[0](o));case Fe.Sin:return o=>Math.sin(a[0](o));case Fe.Cos:return o=>Math.cos(a[0](o));case Fe.Atan:return l===2?o=>Math.atan2(a[0](o),a[1](o)):o=>Math.atan(a[0](o));case Fe.Sqrt:return o=>Math.sqrt(a[0](o));default:throw new Error(`Unsupported numeric operator ${r}`)}}function L2(h,e){let r=h.args.length,l=new Array(r);for(let a=0;a<r;++a)l[a]=Us(h.args[a],e);return a=>{for(let o=0;o<r-1;o+=2)if(l[o](a))return l[o+1](a);return l[r-1](a)}}function D2(h,e){let r=h.args.length,l=new Array(r);for(let a=0;a<r;++a)l[a]=Us(h.args[a],e);return a=>{let o=l[0](a);for(let g=1;g<r;g+=2)if(o===l[g](a))return l[g+1](a);return l[r-1](a)}}function F2(h,e){let r=h.args.length,l=new Array(r);for(let a=0;a<r;++a)l[a]=Us(h.args[a],e);return a=>{let o=l[0](a),g=l[1](a),v,w;for(let T=2;T<r;T+=2){let S=l[T](a),k=l[T+1](a),F=Array.isArray(k);if(F&&(k=cv(k)),S>=g)return T===2?k:F?z2(o,g,v,w,S,k):tu(o,g,v,w,S,k);v=S,w=k}return w}}function tu(h,e,r,l,a,o){let g=a-r;if(g===0)return l;let v=e-r,w=h===1?v/g:(Math.pow(h,v)-1)/(Math.pow(h,g)-1);return l+w*(o-l)}function z2(h,e,r,l,a,o){if(a-r===0)return l;let v=dg(l),w=dg(o),T=w[2]-v[2];T>180?T-=360:T<-180&&(T+=360);let S=[tu(h,e,r,v[0],a,w[0]),tu(h,e,r,v[1],a,w[1]),v[2]+tu(h,e,r,0,a,T),tu(h,e,r,l[3],a,o[3])];return pg(hv(S))}function O2(h){return!0}function Av(h){let e=Dg(),r=B2(h,e),l=zg();return function(a,o){if(l.properties=a.getPropertiesInternal(),l.resolution=o,e.featureId){let g=a.getId();g!==void 0?l.featureId=g:l.featureId=null}return e.geometryType&&(l.geometryType=Fg(a.getGeometry())),r(l)}}function Ng(h){let e=Dg(),r=h.length,l=new Array(r);for(let g=0;g<r;++g)l[g]=Og(h[g],e);let a=zg(),o=new Array(r);return function(g,v){if(a.properties=g.getPropertiesInternal(),a.resolution=v,e.featureId){let T=g.getId();T!==void 0?a.featureId=T:a.featureId=null}let w=0;for(let T=0;T<r;++T){let S=l[T](a);S&&(o[w]=S,w+=1)}return o.length=w,o}}function B2(h,e){let r=h.length,l=new Array(r);for(let a=0;a<r;++a){let o=h[a],g="filter"in o?$s(o.filter,Ri,e):O2,v;if(Array.isArray(o.style)){let w=o.style.length;v=new Array(w);for(let T=0;T<w;++T)v[T]=Og(o.style[T],e)}else v=[Og(o.style,e)];l[a]={filter:g,styles:v}}return function(a){let o=[],g=!1;for(let v=0;v<r;++v){let w=l[v].filter;if(w(a)&&!(h[v].else&&g)){g=!0;for(let T of l[v].styles){let S=T(a);S&&o.push(S)}}}return o}}function Og(h,e){let r=iu(h,"",e),l=ru(h,"",e),a=N2(h,e),o=V2(h,e),g=kn(h,"z-index",e);if(!r&&!l&&!a&&!o&&!qn(h))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(h));let v=new zr;return function(w){let T=!0;if(r){let S=r(w);S&&(T=!1),v.setFill(S)}if(l){let S=l(w);S&&(T=!1),v.setStroke(S)}if(a){let S=a(w);S&&(T=!1),v.setText(S)}if(o){let S=o(w);S&&(T=!1),v.setImage(S)}return g&&v.setZIndex(g(w)),T?null:v}}function iu(h,e,r){let l;if(e+"fill-pattern-src"in h?l=$2(h,e+"fill-",r):l=Vg(h,e+"fill-color",r),!l)return null;let a=new Fr;return function(o){let g=l(o);return g==="none"?null:(a.setColor(g),a)}}function ru(h,e,r){let l=kn(h,e+"stroke-width",r),a=Vg(h,e+"stroke-color",r);if(!l&&!a)return null;let o=Eo(h,e+"stroke-line-cap",r),g=Eo(h,e+"stroke-line-join",r),v=Pv(h,e+"stroke-line-dash",r),w=kn(h,e+"stroke-line-dash-offset",r),T=kn(h,e+"stroke-miter-limit",r),S=new nr;return function(k){if(a){let F=a(k);if(F==="none")return null;S.setColor(F)}if(l&&S.setWidth(l(k)),o){let F=o(k);if(F!=="butt"&&F!=="round"&&F!=="square")throw new Error("Expected butt, round, or square line cap");S.setLineCap(F)}if(g){let F=g(k);if(F!=="bevel"&&F!=="round"&&F!=="miter")throw new Error("Expected bevel, round, or miter line join");S.setLineJoin(F)}return v&&S.setLineDash(v(k)),w&&S.setLineDashOffset(w(k)),T&&S.setMiterLimit(T(k)),S}}function N2(h,e){let r="text-",l=Eo(h,r+"value",e);if(!l)return null;let a=iu(h,r,e),o=iu(h,r+"background-",e),g=ru(h,r,e),v=ru(h,r+"background-",e),w=Eo(h,r+"font",e),T=kn(h,r+"max-angle",e),S=kn(h,r+"offset-x",e),k=kn(h,r+"offset-y",e),F=nu(h,r+"overflow",e),j=Eo(h,r+"placement",e),J=kn(h,r+"repeat",e),he=up(h,r+"scale",e),q=nu(h,r+"rotate-with-view",e),Z=kn(h,r+"rotation",e),ne=Eo(h,r+"align",e),me=Eo(h,r+"justify",e),_e=Eo(h,r+"baseline",e),fe=Pv(h,r+"padding",e),ve=dp(h,r+"declutter-mode"),Ee=new wv({declutterMode:ve});return function(Re){if(Ee.setText(l(Re)),a&&Ee.setFill(a(Re)),o&&Ee.setBackgroundFill(o(Re)),g&&Ee.setStroke(g(Re)),v&&Ee.setBackgroundStroke(v(Re)),w&&Ee.setFont(w(Re)),T&&Ee.setMaxAngle(T(Re)),S&&Ee.setOffsetX(S(Re)),k&&Ee.setOffsetY(k(Re)),F&&Ee.setOverflow(F(Re)),j){let Pe=j(Re);if(Pe!=="point"&&Pe!=="line")throw new Error("Expected point or line for text-placement");Ee.setPlacement(Pe)}if(J&&Ee.setRepeat(J(Re)),he&&Ee.setScale(he(Re)),q&&Ee.setRotateWithView(q(Re)),Z&&Ee.setRotation(Z(Re)),ne){let Pe=ne(Re);if(Pe!=="left"&&Pe!=="center"&&Pe!=="right"&&Pe!=="end"&&Pe!=="start")throw new Error("Expected left, right, center, start, or end for text-align");Ee.setTextAlign(Pe)}if(me){let Pe=me(Re);if(Pe!=="left"&&Pe!=="right"&&Pe!=="center")throw new Error("Expected left, right, or center for text-justify");Ee.setJustify(Pe)}if(_e){let Pe=_e(Re);if(Pe!=="bottom"&&Pe!=="top"&&Pe!=="middle"&&Pe!=="alphabetic"&&Pe!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");Ee.setTextBaseline(Pe)}return fe&&Ee.setPadding(fe(Re)),Ee}}function V2(h,e){return"icon-src"in h?G2(h,e):"shape-points"in h?j2(h,e):"circle-radius"in h?U2(h,e):null}function G2(h,e){let r="icon-",l=r+"src",a=Rv(h[l],l),o=cp(h,r+"anchor",e),g=up(h,r+"scale",e),v=kn(h,r+"opacity",e),w=cp(h,r+"displacement",e),T=kn(h,r+"rotation",e),S=nu(h,r+"rotate-with-view",e),k=Tv(h,r+"anchor-origin"),F=Mv(h,r+"anchor-x-units"),j=Mv(h,r+"anchor-y-units"),J=X2(h,r+"color"),he=W2(h,r+"cross-origin"),q=Z2(h,r+"offset"),Z=Tv(h,r+"offset-origin"),ne=hp(h,r+"width"),me=hp(h,r+"height"),_e=q2(h,r+"size"),fe=dp(h,r+"declutter-mode"),ve=new Qh({src:a,anchorOrigin:k,anchorXUnits:F,anchorYUnits:j,color:J,crossOrigin:he,offset:q,offsetOrigin:Z,height:me,width:ne,size:_e,declutterMode:fe});return function(Ee){return v&&ve.setOpacity(v(Ee)),w&&ve.setDisplacement(w(Ee)),T&&ve.setRotation(T(Ee)),S&&ve.setRotateWithView(S(Ee)),g&&ve.setScale(g(Ee)),o&&ve.setAnchor(o(Ee)),ve}}function j2(h,e){let r="shape-",l=r+"points",a=r+"radius",o=Bg(h[l],l),g=Bg(h[a],a),v=iu(h,r,e),w=ru(h,r,e),T=up(h,r+"scale",e),S=cp(h,r+"displacement",e),k=kn(h,r+"rotation",e),F=nu(h,r+"rotate-with-view",e),j=hp(h,r+"radius2"),J=hp(h,r+"angle"),he=dp(h,r+"declutter-mode"),q=new ap({points:o,radius:g,radius2:j,angle:J,declutterMode:he});return function(Z){return v&&q.setFill(v(Z)),w&&q.setStroke(w(Z)),S&&q.setDisplacement(S(Z)),k&&q.setRotation(k(Z)),F&&q.setRotateWithView(F(Z)),T&&q.setScale(T(Z)),q}}function U2(h,e){let r="circle-",l=iu(h,r,e),a=ru(h,r,e),o=kn(h,r+"radius",e),g=up(h,r+"scale",e),v=cp(h,r+"displacement",e),w=kn(h,r+"rotation",e),T=nu(h,r+"rotate-with-view",e),S=dp(h,r+"declutter-mode"),k=new Rn({radius:5,declutterMode:S});return function(F){return o&&k.setRadius(o(F)),l&&k.setFill(l(F)),a&&k.setStroke(a(F)),v&&k.setDisplacement(v(F)),w&&k.setRotation(w(F)),T&&k.setRotateWithView(T(F)),g&&k.setScale(g(F)),k}}function kn(h,e,r){if(!(e in h))return;let l=$s(h[e],ft,r);return function(a){return Bg(l(a),e)}}function Eo(h,e,r){if(!(e in h))return null;let l=$s(h[e],ns,r);return function(a){return Rv(l(a),e)}}function $2(h,e,r){let l=Eo(h,e+"pattern-src",r),a=Ev(h,e+"pattern-offset",r),o=Ev(h,e+"pattern-size",r),g=Vg(h,e+"color",r);return function(v){return{src:l(v),offset:a&&a(v),size:o&&o(v),color:g&&g(v)}}}function nu(h,e,r){if(!(e in h))return null;let l=$s(h[e],Ri,r);return function(a){let o=l(a);if(typeof o!="boolean")throw new Error(`Expected a boolean for ${e}`);return o}}function Vg(h,e,r){if(!(e in h))return null;let l=$s(h[e],xr|ns,r);return function(a){return kv(l(a),e)}}function Pv(h,e,r){if(!(e in h))return null;let l=$s(h[e],js,r);return function(a){return su(l(a),e)}}function cp(h,e,r){if(!(e in h))return null;let l=$s(h[e],js,r);return function(a){let o=su(l(a),e);if(o.length!==2)throw new Error(`Expected two numbers for ${e}`);return o}}function Ev(h,e,r){if(!(e in h))return null;let l=$s(h[e],js,r);return function(a){return Lv(l(a),e)}}function up(h,e,r){if(!(e in h))return null;let l=$s(h[e],js|ft,r);return function(a){return H2(l(a),e)}}function hp(h,e){let r=h[e];if(r!==void 0){if(typeof r!="number")throw new Error(`Expected a number for ${e}`);return r}}function q2(h,e){let r=h[e];if(r!==void 0){if(typeof r=="number")return sa(r);if(!Array.isArray(r))throw new Error(`Expected a number or size array for ${e}`);if(r.length!==2||typeof r[0]!="number"||typeof r[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return r}}function W2(h,e){let r=h[e];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);return r}}function Tv(h,e){let r=h[e];if(r!==void 0){if(r!=="bottom-left"&&r!=="bottom-right"&&r!=="top-left"&&r!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return r}}function Mv(h,e){let r=h[e];if(r!==void 0){if(r!=="pixels"&&r!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return r}}function Z2(h,e){let r=h[e];if(r!==void 0)return su(r,e)}function dp(h,e){let r=h[e];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);if(r!=="declutter"&&r!=="obstacle"&&r!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return r}}function X2(h,e){let r=h[e];if(r!==void 0)return kv(r,e)}function su(h,e){if(!Array.isArray(h))throw new Error(`Expected an array for ${e}`);let r=h.length;for(let l=0;l<r;++l)if(typeof h[l]!="number")throw new Error(`Expected an array of numbers for ${e}`);return h}function Rv(h,e){if(typeof h!="string")throw new Error(`Expected a string for ${e}`);return h}function Bg(h,e){if(typeof h!="number")throw new Error(`Expected a number for ${e}`);return h}function kv(h,e){if(typeof h=="string")return h;let r=su(h,e),l=r.length;if(l<3||l>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return r}function Lv(h,e){let r=su(h,e);if(r.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return r}function H2(h,e){return typeof h=="number"?h:Lv(h,e)}var Dv={RENDER_ORDER:"renderOrder"},Gg=class extends xo{constructor(e){e=e||{};let r=Object.assign({},e);delete r.style,delete r.renderBuffer,delete r.updateWhileAnimating,delete r.updateWhileInteracting,super(r),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Dv.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,r){let l=this.getDeclutter();l in e.declutter||(e.declutter[l]=new Fv.default(9)),this.getRenderer().renderDeclutter(e,r)}setRenderOrder(e){this.set(Dv.RENDER_ORDER,e)}setStyle(e){this.style_=Y2(e),this.styleFunction_=e===null?void 0:xv(this.style_),this.changed()}};function Y2(h){if(h===void 0)return vv;if(!h)return null;if(typeof h=="function"||h instanceof zr)return h;if(!Array.isArray(h))return Ng([h]);if(h.length===0)return[];let e=h.length,r=h[0];if(r instanceof zr){let a=new Array(e);for(let o=0;o<e;++o){let g=h[o];if(!(g instanceof zr))throw new Error("Expected a list of style instances");a[o]=g}return a}if("style"in r){let a=new Array(e);for(let o=0;o<e;++o){let g=h[o];if(!("style"in g))throw new Error("Expected a list of rules with a style property");a[o]=g}return Av(a)}return Ng(h)}var zv=Gg;var ou={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},au=[ou.FILL],qs=[ou.STROKE],To=[ou.BEGIN_PATH],jg=[ou.CLOSE_PATH],gt=ou;var Ug=class{drawCustom(e,r,l,a,o){}drawGeometry(e){}setStyle(e){}drawCircle(e,r,l){}drawFeature(e,r,l){}drawGeometryCollection(e,r,l){}drawLineString(e,r,l){}drawMultiLineString(e,r,l){}drawMultiPoint(e,r,l){}drawMultiPolygon(e,r,l){}drawPoint(e,r,l){}drawPolygon(e,r,l){}drawText(e,r,l){}setFillStrokeStyle(e,r){}setImageStyle(e,r){}setTextStyle(e,r){}},pp=Ug;var $g=class extends pp{constructor(e,r,l,a){super(),this.tolerance=e,this.maxExtent=r,this.pixelRatio=a,this.maxLineWidth=0,this.resolution=l,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){let r=this.pixelRatio;return r==1?e:e.map(function(l){return l*r})}appendFlatPointCoordinates(e,r){let l=this.getBufferedMaxExtent(),a=this.tmpCoordinate_,o=this.coordinates,g=o.length;for(let v=0,w=e.length;v<w;v+=r)a[0]=e[v],a[1]=e[v+1],mo(l,a)&&(o[g++]=a[0],o[g++]=a[1]);return g}appendFlatLineCoordinates(e,r,l,a,o,g){let v=this.coordinates,w=v.length,T=this.getBufferedMaxExtent();g&&(r+=a);let S=e[r],k=e[r+1],F=this.tmpCoordinate_,j=!0,J,he,q;for(J=r+a;J<l;J+=a)F[0]=e[J],F[1]=e[J+1],q=Dd(T,F),q!==he?(j&&(v[w++]=S,v[w++]=k,j=!1),v[w++]=F[0],v[w++]=F[1]):q===Ji.INTERSECTING?(v[w++]=F[0],v[w++]=F[1],j=!1):j=!0,S=F[0],k=F[1],he=q;return(o&&j||J===r+a)&&(v[w++]=S,v[w++]=k),w}drawCustomCoordinates_(e,r,l,a,o){for(let g=0,v=l.length;g<v;++g){let w=l[g],T=this.appendFlatLineCoordinates(e,r,w,a,!1,!1);o.push(T),r=w}return r}drawCustom(e,r,l,a,o){this.beginGeometry(e,r,o);let g=e.getType(),v=e.getStride(),w=this.coordinates.length,T,S,k,F,j;switch(g){case"MultiPolygon":T=e.getOrientedFlatCoordinates(),F=[];let J=e.getEndss();j=0;for(let he=0,q=J.length;he<q;++he){let Z=[];j=this.drawCustomCoordinates_(T,j,J[he],v,Z),F.push(Z)}this.instructions.push([gt.CUSTOM,w,F,e,l,Oh,o]),this.hitDetectionInstructions.push([gt.CUSTOM,w,F,e,a||l,Oh,o]);break;case"Polygon":case"MultiLineString":k=[],T=g=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),j=this.drawCustomCoordinates_(T,0,e.getEnds(),v,k),this.instructions.push([gt.CUSTOM,w,k,e,l,ta,o]),this.hitDetectionInstructions.push([gt.CUSTOM,w,k,e,a||l,ta,o]);break;case"LineString":case"Circle":T=e.getFlatCoordinates(),S=this.appendFlatLineCoordinates(T,0,T.length,v,!1,!1),this.instructions.push([gt.CUSTOM,w,S,e,l,ts,o]),this.hitDetectionInstructions.push([gt.CUSTOM,w,S,e,a||l,ts,o]);break;case"MultiPoint":T=e.getFlatCoordinates(),S=this.appendFlatPointCoordinates(T,v),S>w&&(this.instructions.push([gt.CUSTOM,w,S,e,l,ts,o]),this.hitDetectionInstructions.push([gt.CUSTOM,w,S,e,a||l,ts,o]));break;case"Point":T=e.getFlatCoordinates(),this.coordinates.push(T[0],T[1]),S=this.coordinates.length,this.instructions.push([gt.CUSTOM,w,S,e,l,void 0,o]),this.hitDetectionInstructions.push([gt.CUSTOM,w,S,e,a||l,void 0,o]);break;default:}this.endGeometry(r)}beginGeometry(e,r,l){this.beginGeometryInstruction1_=[gt.BEGIN_GEOMETRY,r,0,e,l],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[gt.BEGIN_GEOMETRY,r,0,e,l],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let e=this.hitDetectionInstructions;e.reverse();let r,l=e.length,a,o,g=-1;for(r=0;r<l;++r)a=e[r],o=a[0],o==gt.END_GEOMETRY?g=r:o==gt.BEGIN_GEOMETRY&&(a[2]=r,q0(this.hitDetectionInstructions,g,r),g=-1)}setFillStrokeStyle(e,r){let l=this.state;if(e){let a=e.getColor();l.fillPatternScale=a&&typeof a=="object"&&"src"in a?this.pixelRatio:1,l.fillStyle=Mn(a||sr)}else l.fillStyle=void 0;if(r){let a=r.getColor();l.strokeStyle=Mn(a||So);let o=r.getLineCap();l.lineCap=o!==void 0?o:Vs;let g=r.getLineDash();l.lineDash=g?g.slice():An;let v=r.getLineDashOffset();l.lineDashOffset=v||Pn;let w=r.getLineJoin();l.lineJoin=w!==void 0?w:Gs;let T=r.getWidth();l.lineWidth=T!==void 0?T:Io;let S=r.getMiterLimit();l.miterLimit=S!==void 0?S:wo,l.lineWidth>this.maxLineWidth&&(this.maxLineWidth=l.lineWidth,this.bufferedMaxExtent_=null)}else l.strokeStyle=void 0,l.lineCap=void 0,l.lineDash=null,l.lineDashOffset=void 0,l.lineJoin=void 0,l.lineWidth=void 0,l.miterLimit=void 0}createFill(e){let r=e.fillStyle,l=[gt.SET_FILL_STYLE,r];return typeof r!="string"&&l.push(e.fillPatternScale),l}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[gt.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,this.applyPixelRatio(e.lineDash),e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,r){let l=e.fillStyle;(typeof l!="string"||e.currentFillStyle!=l)&&(l!==void 0&&this.instructions.push(r.call(this,e)),e.currentFillStyle=l)}updateStrokeStyle(e,r){let l=e.strokeStyle,a=e.lineCap,o=e.lineDash,g=e.lineDashOffset,v=e.lineJoin,w=e.lineWidth,T=e.miterLimit;(e.currentStrokeStyle!=l||e.currentLineCap!=a||o!=e.currentLineDash&&!vn(e.currentLineDash,o)||e.currentLineDashOffset!=g||e.currentLineJoin!=v||e.currentLineWidth!=w||e.currentMiterLimit!=T)&&(l!==void 0&&r.call(this,e),e.currentStrokeStyle=l,e.currentLineCap=a,e.currentLineDash=o,e.currentLineDashOffset=g,e.currentLineJoin=v,e.currentLineWidth=w,e.currentMiterLimit=T)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let r=[gt.END_GEOMETRY,e];this.instructions.push(r),this.hitDetectionInstructions.push(r)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=W0(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;bn(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Ws=$g;var qg=class extends Ws{constructor(e,r,l,a){super(e,r,l,a),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,r,l){if(!this.image_||this.maxExtent&&!mo(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,r,l);let a=e.getFlatCoordinates(),o=e.getStride(),g=this.coordinates.length,v=this.appendFlatPointCoordinates(a,o);this.instructions.push([gt.DRAW_IMAGE,g,v,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([gt.DRAW_IMAGE,g,v,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}drawMultiPoint(e,r,l){if(!this.image_)return;this.beginGeometry(e,r,l);let a=e.getFlatCoordinates(),o=[];for(let w=0,T=a.length;w<T;w+=e.getStride())(!this.maxExtent||mo(this.maxExtent,a.slice(w,w+2)))&&o.push(a[w],a[w+1]);let g=this.coordinates.length,v=this.appendFlatPointCoordinates(o,2);this.instructions.push([gt.DRAW_IMAGE,g,v,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([gt.DRAW_IMAGE,g,v,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,r){let l=e.getAnchor(),a=e.getSize(),o=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=l[0],this.anchorY_=l[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=a[1],this.opacity_=e.getOpacity(),this.originX_=o[0],this.originY_=o[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=a[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=r}},Ov=qg;var Wg=class extends Ws{constructor(e,r,l,a){super(e,r,l,a)}drawFlatCoordinates_(e,r,l,a){let o=this.coordinates.length,g=this.appendFlatLineCoordinates(e,r,l,a,!1,!1),v=[gt.MOVE_TO_LINE_TO,o,g];return this.instructions.push(v),this.hitDetectionInstructions.push(v),l}drawLineString(e,r,l){let a=this.state,o=a.strokeStyle,g=a.lineWidth;if(o===void 0||g===void 0)return;this.updateStrokeStyle(a,this.applyStroke),this.beginGeometry(e,r,l),this.hitDetectionInstructions.push([gt.SET_STROKE_STYLE,a.strokeStyle,a.lineWidth,a.lineCap,a.lineJoin,a.miterLimit,An,Pn],To);let v=e.getFlatCoordinates(),w=e.getStride();this.drawFlatCoordinates_(v,0,v.length,w),this.hitDetectionInstructions.push(qs),this.endGeometry(r)}drawMultiLineString(e,r,l){let a=this.state,o=a.strokeStyle,g=a.lineWidth;if(o===void 0||g===void 0)return;this.updateStrokeStyle(a,this.applyStroke),this.beginGeometry(e,r,l),this.hitDetectionInstructions.push([gt.SET_STROKE_STYLE,a.strokeStyle,a.lineWidth,a.lineCap,a.lineJoin,a.miterLimit,An,Pn],To);let v=e.getEnds(),w=e.getFlatCoordinates(),T=e.getStride(),S=0;for(let k=0,F=v.length;k<F;++k)S=this.drawFlatCoordinates_(w,S,v[k],T);this.hitDetectionInstructions.push(qs),this.endGeometry(r)}finish(){let e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(qs),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(qs),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(To)}},Bv=Wg;var Zg=class extends Ws{constructor(e,r,l,a){super(e,r,l,a)}drawFlatCoordinatess_(e,r,l,a){let o=this.state,g=o.fillStyle!==void 0,v=o.strokeStyle!==void 0,w=l.length;this.instructions.push(To),this.hitDetectionInstructions.push(To);for(let T=0;T<w;++T){let S=l[T],k=this.coordinates.length,F=this.appendFlatLineCoordinates(e,r,S,a,!0,!v),j=[gt.MOVE_TO_LINE_TO,k,F];this.instructions.push(j),this.hitDetectionInstructions.push(j),v&&(this.instructions.push(jg),this.hitDetectionInstructions.push(jg)),r=S}return g&&(this.instructions.push(au),this.hitDetectionInstructions.push(au)),v&&(this.instructions.push(qs),this.hitDetectionInstructions.push(qs)),r}drawCircle(e,r,l){let a=this.state,o=a.fillStyle,g=a.strokeStyle;if(o===void 0&&g===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,l),a.fillStyle!==void 0&&this.hitDetectionInstructions.push([gt.SET_FILL_STYLE,sr]),a.strokeStyle!==void 0&&this.hitDetectionInstructions.push([gt.SET_STROKE_STYLE,a.strokeStyle,a.lineWidth,a.lineCap,a.lineJoin,a.miterLimit,An,Pn]);let v=e.getFlatCoordinates(),w=e.getStride(),T=this.coordinates.length;this.appendFlatLineCoordinates(v,0,v.length,w,!1,!1);let S=[gt.CIRCLE,T];this.instructions.push(To,S),this.hitDetectionInstructions.push(To,S),a.fillStyle!==void 0&&(this.instructions.push(au),this.hitDetectionInstructions.push(au)),a.strokeStyle!==void 0&&(this.instructions.push(qs),this.hitDetectionInstructions.push(qs)),this.endGeometry(r)}drawPolygon(e,r,l){let a=this.state,o=a.fillStyle,g=a.strokeStyle;if(o===void 0&&g===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,l),a.fillStyle!==void 0&&this.hitDetectionInstructions.push([gt.SET_FILL_STYLE,sr]),a.strokeStyle!==void 0&&this.hitDetectionInstructions.push([gt.SET_STROKE_STYLE,a.strokeStyle,a.lineWidth,a.lineCap,a.lineJoin,a.miterLimit,An,Pn]);let v=e.getEnds(),w=e.getOrientedFlatCoordinates(),T=e.getStride();this.drawFlatCoordinatess_(w,0,v,T),this.endGeometry(r)}drawMultiPolygon(e,r,l){let a=this.state,o=a.fillStyle,g=a.strokeStyle;if(o===void 0&&g===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,l),a.fillStyle!==void 0&&this.hitDetectionInstructions.push([gt.SET_FILL_STYLE,sr]),a.strokeStyle!==void 0&&this.hitDetectionInstructions.push([gt.SET_STROKE_STYLE,a.strokeStyle,a.lineWidth,a.lineCap,a.lineJoin,a.miterLimit,An,Pn]);let v=e.getEndss(),w=e.getOrientedFlatCoordinates(),T=e.getStride(),S=0;for(let k=0,F=v.length;k<F;++k)S=this.drawFlatCoordinatess_(w,S,v[k],T);this.endGeometry(r)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let e=this.tolerance;if(e!==0){let r=this.coordinates;for(let l=0,a=r.length;l<a;++l)r[l]=ea(r[l],e)}return super.finish()}setFillStrokeStyles_(){let e=this.state;e.fillStyle!==void 0&&this.updateFillStyle(e,this.createFill),e.strokeStyle!==void 0&&this.updateStrokeStyle(e,this.applyStroke)}},Xg=Zg;function Nv(h,e,r,l,a){let o=[],g=r,v=0,w=e.slice(r,2);for(;v<h&&g+a<l;){let[T,S]=w.slice(-2),k=e[g+a],F=e[g+a+1],j=Math.sqrt((k-T)*(k-T)+(F-S)*(F-S));if(v+=j,v>=h){let J=(h-v+j)/j,he=Dr(T,k,J),q=Dr(S,F,J);w.push(he,q),o.push(w),w=[he,q],v==h&&(g+=a),v=0}else if(v<h)w.push(e[g+a],e[g+a+1]),g+=a;else{let J=j-v,he=Dr(T,k,J/j),q=Dr(S,F,J/j);w.push(he,q),o.push(w),w=[he,q],v=0,g+=a}}return v>0&&o.push(w),o}function Vv(h,e,r,l,a){let o=r,g=r,v=0,w=0,T=r,S,k,F,j,J,he,q,Z,ne,me;for(k=r;k<l;k+=a){let _e=e[k],fe=e[k+1];J!==void 0&&(ne=_e-J,me=fe-he,j=Math.sqrt(ne*ne+me*me),q!==void 0&&(w+=F,S=Math.acos((q*ne+Z*me)/(F*j)),S>h&&(w>v&&(v=w,o=T,g=k),w=0,T=k-a)),F=j,q=ne,Z=me),J=_e,he=fe}return w+=j,w>v?[T,k]:[o,g]}var lu={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Hg=class extends Ws{constructor(e,r,l,a){super(e,r,l,a),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[sr]={fillStyle:sr},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,r,l){let a=this.textFillState_,o=this.textStrokeState_,g=this.textState_;if(this.text_===""||!g||!a&&!o)return;let v=this.coordinates,w=v.length,T=e.getType(),S=null,k=e.getStride();if(g.placement==="line"&&(T=="LineString"||T=="MultiLineString"||T=="Polygon"||T=="MultiPolygon")){if(!Qi(this.maxExtent,e.getExtent()))return;let F;if(S=e.getFlatCoordinates(),T=="LineString")F=[S.length];else if(T=="MultiLineString")F=e.getEnds();else if(T=="Polygon")F=e.getEnds().slice(0,1);else if(T=="MultiPolygon"){let q=e.getEndss();F=[];for(let Z=0,ne=q.length;Z<ne;++Z)F.push(q[Z][0])}this.beginGeometry(e,r,l);let j=g.repeat,J=j?void 0:g.textAlign,he=0;for(let q=0,Z=F.length;q<Z;++q){let ne;j?ne=Nv(j*this.resolution,S,he,F[q],k):ne=[S.slice(he,F[q])];for(let me=0,_e=ne.length;me<_e;++me){let fe=ne[me],ve=0,Ee=fe.length;if(J==null){let Pe=Vv(g.maxAngle,fe,0,fe.length,2);ve=Pe[0],Ee=Pe[1]}for(let Pe=ve;Pe<Ee;Pe+=k)v.push(fe[Pe],fe[Pe+1]);let Re=v.length;he=F[q],this.drawChars_(w,Re),w=Re}}this.endGeometry(r)}else{let F=g.overflow?null:[];switch(T){case"Point":case"MultiPoint":S=e.getFlatCoordinates();break;case"LineString":S=e.getFlatMidpoint();break;case"Circle":S=e.getCenter();break;case"MultiLineString":S=e.getFlatMidpoints(),k=2;break;case"Polygon":S=e.getFlatInteriorPoint(),g.overflow||F.push(S[2]/this.resolution),k=3;break;case"MultiPolygon":let ne=e.getFlatInteriorPoints();S=[];for(let me=0,_e=ne.length;me<_e;me+=3)g.overflow||F.push(ne[me+2]/this.resolution),S.push(ne[me],ne[me+1]);if(S.length===0)return;k=2;break;default:}let j=this.appendFlatPointCoordinates(S,k);if(j===w)return;if(F&&(j-w)/2!==S.length/k){let ne=w/2;F=F.filter((me,_e)=>{let fe=v[(ne+_e)*2]===S[_e*k]&&v[(ne+_e)*2+1]===S[_e*k+1];return fe||--ne,fe})}this.saveTextStates_(),(g.backgroundFill||g.backgroundStroke)&&(this.setFillStrokeStyle(g.backgroundFill,g.backgroundStroke),g.backgroundFill&&this.updateFillStyle(this.state,this.createFill),g.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,r,l);let J=g.padding;if(J!=Co&&(g.scale[0]<0||g.scale[1]<0)){let ne=g.padding[0],me=g.padding[1],_e=g.padding[2],fe=g.padding[3];g.scale[0]<0&&(me=-me,fe=-fe),g.scale[1]<0&&(ne=-ne,_e=-_e),J=[ne,me,_e,fe]}let he=this.pixelRatio;this.instructions.push([gt.DRAW_IMAGE,w,j,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,J==Co?Co:J.map(function(ne){return ne*he}),!!g.backgroundFill,!!g.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,F]);let q=1/he,Z=this.state.fillStyle;g.backgroundFill&&(this.state.fillStyle=sr,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([gt.DRAW_IMAGE,w,j,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[q,q],NaN,this.declutterMode_,this.declutterImageWithText_,J,!!g.backgroundFill,!!g.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?sr:this.fillKey_,this.textOffsetX_,this.textOffsetY_,F]),g.backgroundFill&&(this.state.fillStyle=Z,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(r)}}saveTextStates_(){let e=this.textStrokeState_,r=this.textState_,l=this.textFillState_,a=this.strokeKey_;e&&(a in this.strokeStates||(this.strokeStates[a]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));let o=this.textKey_;o in this.textStates||(this.textStates[o]={font:r.font,textAlign:r.textAlign||aa,justify:r.justify,textBaseline:r.textBaseline||Ja,scale:r.scale});let g=this.fillKey_;l&&(g in this.fillStates||(this.fillStates[g]={fillStyle:l.fillStyle}))}drawChars_(e,r){let l=this.textStrokeState_,a=this.textState_,o=this.strokeKey_,g=this.textKey_,v=this.fillKey_;this.saveTextStates_();let w=this.pixelRatio,T=lu[a.textBaseline],S=this.textOffsetY_*w,k=this.text_,F=l?l.lineWidth*Math.abs(a.scale[0])/2:0;this.instructions.push([gt.DRAW_CHARS,e,r,T,a.overflow,v,a.maxAngle,w,S,o,F*w,k,g,1,this.declutterMode_]),this.hitDetectionInstructions.push([gt.DRAW_CHARS,e,r,T,a.overflow,v&&sr,a.maxAngle,w,S,o,F*w,k,g,1/w,this.declutterMode_])}setTextStyle(e,r){let l,a,o;if(!e)this.text_="";else{let g=e.getFill();g?(a=this.textFillState_,a||(a={},this.textFillState_=a),a.fillStyle=Mn(g.getColor()||sr)):(a=null,this.textFillState_=a);let v=e.getStroke();if(!v)o=null,this.textStrokeState_=o;else{o=this.textStrokeState_,o||(o={},this.textStrokeState_=o);let J=v.getLineDash(),he=v.getLineDashOffset(),q=v.getWidth(),Z=v.getMiterLimit();o.lineCap=v.getLineCap()||Vs,o.lineDash=J?J.slice():An,o.lineDashOffset=he===void 0?Pn:he,o.lineJoin=v.getLineJoin()||Gs,o.lineWidth=q===void 0?Io:q,o.miterLimit=Z===void 0?wo:Z,o.strokeStyle=Mn(v.getColor()||So)}l=this.textState_;let w=e.getFont()||op;fv(w);let T=e.getScaleArray();l.overflow=e.getOverflow(),l.font=w,l.maxAngle=e.getMaxAngle(),l.placement=e.getPlacement(),l.textAlign=e.getTextAlign(),l.repeat=e.getRepeat(),l.justify=e.getJustify(),l.textBaseline=e.getTextBaseline()||Ja,l.backgroundFill=e.getBackgroundFill(),l.backgroundStroke=e.getBackgroundStroke(),l.padding=e.getPadding()||Co,l.scale=T===void 0?[1,1]:T;let S=e.getOffsetX(),k=e.getOffsetY(),F=e.getRotateWithView(),j=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=S===void 0?0:S,this.textOffsetY_=k===void 0?0:k,this.textRotateWithView_=F===void 0?!1:F,this.textRotation_=j===void 0?0:j,this.strokeKey_=o?(typeof o.strokeStyle=="string"?o.strokeStyle:Gt(o.strokeStyle))+o.lineCap+o.lineDashOffset+"|"+o.lineWidth+o.lineJoin+o.miterLimit+"["+o.lineDash.join()+"]":"",this.textKey_=l.font+l.scale+(l.textAlign||"?")+(l.repeat||"?")+(l.justify||"?")+(l.textBaseline||"?"),this.fillKey_=a&&a.fillStyle?typeof a.fillStyle=="string"?a.fillStyle:"|"+Gt(a.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=r}},Gv=Hg;var K2={Circle:Xg,Default:Ws,Image:Ov,LineString:Bv,Polygon:Xg,Text:Gv},Yg=class{constructor(e,r,l,a){this.tolerance_=e,this.maxExtent_=r,this.pixelRatio_=a,this.resolution_=l,this.buildersByZIndex_={}}finish(){let e={};for(let r in this.buildersByZIndex_){e[r]=e[r]||{};let l=this.buildersByZIndex_[r];for(let a in l){let o=l[a].finish();e[r][a]=o}}return e}getBuilder(e,r){let l=e!==void 0?e.toString():"0",a=this.buildersByZIndex_[l];a===void 0&&(a={},this.buildersByZIndex_[l]=a);let o=a[r];if(o===void 0){let g=K2[r];o=new g(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),a[r]=o}return o}},jv=Yg;var Kg=class extends kd{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.declutterExecutorGroup=null}getFeatures(e){return St()}getData(e){return null}prepareFrame(e){return St()}renderFrame(e,r){return St()}loadedTileCallback(e,r,l){e[r]||(e[r]={}),e[r][l.tileCoord.toString()]=l}createLoadedTileFinder(e,r,l){return(a,o)=>{let g=this.loadedTileCallback.bind(this,l,a);return e.forEachLoadedTile(r,a,o,g)}}forEachFeatureAtCoordinate(e,r,l,a,o){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let r=e.target;(r.getState()===Tt.LOADED||r.getState()===Tt.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let r=e.getState();return r!=Tt.LOADED&&r!=Tt.ERROR&&e.addEventListener(li.CHANGE,this.boundHandleImageChange_),r==Tt.IDLE&&(e.load(),r=e.getState()),r==Tt.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},pc=Kg;var Jg=class extends mi{constructor(e,r,l,a){super(e),this.inversePixelTransform=r,this.frameState=l,this.context=a}},Uv=Jg;var Qg=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(CanvasRenderingContext2D.prototype,{get:(e,r)=>{if(typeof Hh()[r]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r),this.pushMethodArgs_},set:(e,r,l)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r,l),!0)})}pushMethodArgs_=(...e)=>(this.instructions_[this.zIndex+this.offset_].push(e),this);getContext(){return this.context_}draw(e){this.instructions_.forEach(r=>{for(let l=0,a=r.length;l<a;l+=2){let o=r[l],g=r[l+1];if(typeof e[o]=="function")e[o](...g);else{if(typeof g=="function"){e[o]=g(e);continue}e[o]=g}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},fp=Qg;var ty=[],fc=null;function J2(){fc=Wi(1,1,void 0,{willReadFrequently:!0})}var ey=class extends pc{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=mr(),this.pixelTransform=mr(),this.inversePixelTransform=mr(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.pixelContext_=null,this.frameState=null}getImageData(e,r,l){fc||J2(),fc.clearRect(0,0,1,1);let a;try{fc.drawImage(e,r,l,1,1,0,0,1,1),a=fc.getImageData(0,0,1,1).data}catch{return fc=null,null}return a}getBackground(e){let l=this.getLayer().getBackground();return typeof l=="function"&&(l=l(e.viewState.resolution)),l||void 0}useContainer(e,r,l){let a=this.getLayer().getClassName(),o,g;if(e&&e.className===a&&(!l||e&&e.style.backgroundColor&&vn(bo(e.style.backgroundColor),bo(l)))){let v=e.firstElementChild;v instanceof HTMLCanvasElement&&(g=v.getContext("2d"))}if(g&&g.canvas.style.transform===r?(this.container=e,this.context=g,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){o=document.createElement("div"),o.className=a;let v=o.style;v.position="absolute",v.width="100%",v.height="100%",g=Wi();let w=g.canvas;o.appendChild(w),v=w.style,v.position="absolute",v.left="0",v.transformOrigin="top left",this.container=o,this.context=g}!this.containerReused&&l&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=l)}clipUnrotated(e,r,l){let a=tm(l),o=im(l),g=em(l),v=Qf(l);rr(r.coordinateToPixelTransform,a),rr(r.coordinateToPixelTransform,o),rr(r.coordinateToPixelTransform,g),rr(r.coordinateToPixelTransform,v);let w=this.inversePixelTransform;rr(w,a),rr(w,o),rr(w,g),rr(w,v),e.save(),e.beginPath(),e.moveTo(Math.round(a[0]),Math.round(a[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(g[0]),Math.round(g[1])),e.lineTo(Math.round(v[0]),Math.round(v[1])),e.clip()}dispatchRenderEvent_(e,r,l){let a=this.getLayer();if(a.hasListener(e)){let o=new Uv(e,this.inversePixelTransform,l,r);a.dispatchEvent(o)}}preRender(e,r){this.frameState=r,!r.declutter&&this.dispatchRenderEvent_(Bs.PRERENDER,e,r)}postRender(e,r){r.declutter||this.dispatchRenderEvent_(Bs.POSTRENDER,e,r)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new fp),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Bs.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Bs.POSTRENDER,this.context,e))}getRenderTransform(e,r,l,a,o,g,v){let w=o/2,T=g/2,S=a/r,k=-S,F=-e[0]+v,j=-e[1];return an(this.tempTransform,w,T,S,k,-l,F,j)}disposeInternal(){delete this.frameState,super.disposeInternal()}},mp=ey;function $v(h,e,r,l,a,o,g,v,w,T,S,k){let F=h[e],j=h[e+1],J=0,he=0,q=0,Z=0;function ne(){J=F,he=j,e+=l,F=h[e],j=h[e+1],Z+=q,q=Math.sqrt((F-J)*(F-J)+(j-he)*(j-he))}do ne();while(e<r-l&&Z+q<o);let me=q===0?0:(o-Z)/q,_e=Dr(J,F,me),fe=Dr(he,j,me),ve=e-l,Ee=Z,Re=o+v*w(T,a,S);for(;e<r-l&&Z+q<Re;)ne();me=q===0?0:(Re-Z)/q;let Pe=Dr(J,F,me),Ye=Dr(he,j,me),je;if(k){let tt=[_e,fe,Pe,Ye];Vd(tt,0,4,2,k,tt,tt),je=tt[0]>tt[2]}else je=_e>Pe;let Ke=Math.PI,xt=[],At=ve+l===e;e=ve,q=0,Z=Ee,F=h[e],j=h[e+1];let rt;if(At){ne(),rt=Math.atan2(j-he,F-J),je&&(rt+=rt>0?-Ke:Ke);let tt=(Pe+_e)/2,yt=(Ye+fe)/2;return xt[0]=[tt,yt,(Re-o)/2,rt,a],xt}a=a.replace(/\n/g," ");for(let tt=0,yt=a.length;tt<yt;){ne();let ut=Math.atan2(j-he,F-J);if(je&&(ut+=ut>0?-Ke:Ke),rt!==void 0){let Ue=ut-rt;if(Ue+=Ue>Ke?-2*Ke:Ue<-Ke?2*Ke:0,Math.abs(Ue)>g)return null}rt=ut;let Mt=tt,mt=0;for(;tt<yt;++tt){let Ue=je?yt-tt-1:tt,ki=v*w(T,a[Ue],S);if(e+l<r&&Z+q<o+mt+ki/2)break;mt+=ki}if(tt===Mt)continue;let Ft=je?a.substring(yt-Mt,yt-tt):a.substring(Mt,tt);me=q===0?0:(o+mt/2-Z)/q;let Bt=Dr(J,F,me),Ei=Dr(he,j,me);xt.push([Bt,Ei,mt/2,ut,Ft]),o+=mt}return xt}var mc=Sn(),ha=[],Mo=[],Ao=[],ua=[];function qv(h){return h[3].declutterBox}var Wv=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function iy(h,e){return e==="start"?e=Wv.test(h)?"right":"left":e==="end"&&(e=Wv.test(h)?"left":"right"),lu[e]}function Q2(h,e,r){return r>0&&h.push(`
583
583
  `,""),h.push(e,""),h}var ry=class{constructor(e,r,l,a,o){this.overlaps=l,this.pixelRatio=r,this.resolution=e,this.alignAndScaleFill_,this.instructions=a.instructions,this.coordinates=a.coordinates,this.coordinateCache_={},this.renderedTransform_=mr(),this.hitDetectionInstructions=a.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=a.fillStates||{},this.strokeStates=a.strokeStates||{},this.textStates=a.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=o?new fp:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,r,l,a){let o=e+r+l+a;if(this.labels_[o])return this.labels_[o];let g=a?this.strokeStates[a]:null,v=l?this.fillStates[l]:null,w=this.textStates[r],T=this.pixelRatio,S=[w.scale[0]*T,w.scale[1]*T],k=Array.isArray(e),F=w.justify?lu[w.justify]:iy(Array.isArray(e)?e[0]:e,w.textAlign||aa),j=a&&g.lineWidth?g.lineWidth:0,J=k?e:e.split(`
584
584
  `).reduce(Q2,[]),{width:he,height:q,widths:Z,heights:ne,lineWidths:me}=gv(w,J),_e=he+j,fe=[],ve=(_e+2)*S[0],Ee=(q+j)*S[1],Re={width:ve<0?Math.floor(ve):Math.ceil(ve),height:Ee<0?Math.floor(Ee):Math.ceil(Ee),contextInstructions:fe};(S[0]!=1||S[1]!=1)&&fe.push("scale",S),a&&(fe.push("strokeStyle",g.strokeStyle),fe.push("lineWidth",j),fe.push("lineCap",g.lineCap),fe.push("lineJoin",g.lineJoin),fe.push("miterLimit",g.miterLimit),fe.push("setLineDash",[g.lineDash]),fe.push("lineDashOffset",g.lineDashOffset)),l&&fe.push("fillStyle",v.fillStyle),fe.push("textBaseline","middle"),fe.push("textAlign","center");let Pe=.5-F,Ye=F*_e+Pe*j,je=[],Ke=[],xt=0,At=0,rt=0,tt=0,yt;for(let ut=0,Mt=J.length;ut<Mt;ut+=2){let mt=J[ut];if(mt===`
585
- `){At+=xt,xt=0,Ye=F*_e+Pe*j,++tt;continue}let Ft=J[ut+1]||w.font;Ft!==yt&&(a&&je.push("font",Ft),l&&Ke.push("font",Ft),yt=Ft),xt=Math.max(xt,ne[rt]);let Bt=[mt,Ye+Pe*Z[rt]+F*(Z[rt]-me[tt]),.5*(j+xt)+At];Ye+=Z[rt],a&&je.push("strokeText",Bt),l&&Ke.push("fillText",Bt),++rt}return Array.prototype.push.apply(fe,je),Array.prototype.push.apply(fe,Ke),this.labels_[o]=Re,Re}replayTextBackground_(e,r,l,a,o,g,v){e.beginPath(),e.moveTo.apply(e,r),e.lineTo.apply(e,l),e.lineTo.apply(e,a),e.lineTo.apply(e,o),e.lineTo.apply(e,r),g&&(this.alignAndScaleFill_=g[2],this.fill_(e)),v&&(this.setStrokeStyle_(e,v),e.stroke())}calculateImageOrLabelDimensions_(e,r,l,a,o,g,v,w,T,S,k,F,j,J,he,q){v*=F[0],w*=F[1];let Z=l-v,ne=a-w,me=o+T>e?e-T:o,_e=g+S>r?r-S:g,fe=J[3]+me*F[0]+J[1],ve=J[0]+_e*F[1]+J[2],Ee=Z-J[3],Re=ne-J[0];(he||k!==0)&&(ha[0]=Ee,ua[0]=Ee,ha[1]=Re,Mo[1]=Re,Mo[0]=Ee+fe,Ao[0]=Mo[0],Ao[1]=Re+ve,ua[1]=Ao[1]);let Pe;return k!==0?(Pe=an(mr(),l,a,1,1,k,-l,-a),rr(Pe,ha),rr(Pe,Mo),rr(Pe,Ao),rr(Pe,ua),yo(Math.min(ha[0],Mo[0],Ao[0],ua[0]),Math.min(ha[1],Mo[1],Ao[1],ua[1]),Math.max(ha[0],Mo[0],Ao[0],ua[0]),Math.max(ha[1],Mo[1],Ao[1],ua[1]),mc)):yo(Math.min(Ee,Ee+fe),Math.min(Re,Re+ve),Math.max(Ee,Ee+fe),Math.max(Re,Re+ve),mc),j&&(Z=Math.round(Z),ne=Math.round(ne)),{drawImageX:Z,drawImageY:ne,drawImageW:me,drawImageH:_e,originX:T,originY:S,declutterBox:{minX:mc[0],minY:mc[1],maxX:mc[2],maxY:mc[3],value:q},canvasTransform:Pe,scale:F}}replayImageOrLabel_(e,r,l,a,o,g,v){let w=!!(g||v),T=a.declutterBox,S=v?v[2]*a.scale[0]/2:0;return T.minX-S<=r[0]&&T.maxX+S>=0&&T.minY-S<=r[1]&&T.maxY+S>=0&&(w&&this.replayTextBackground_(e,ha,Mo,Ao,ua,g,v),yv(e,a.canvasTransform,o,l,a.originX,a.originY,a.drawImageW,a.drawImageH,a.drawImageX,a.drawImageY,a.scale)),!0}fill_(e){let r=this.alignAndScaleFill_;if(r){let l=rr(this.renderedTransform_,[0,0]),a=512*this.pixelRatio;e.save(),e.translate(l[0]%a,l[1]%a),r!==1&&e.scale(r,r),e.rotate(this.viewRotation_)}e.fill(),r&&e.restore()}setStrokeStyle_(e,r){e.strokeStyle=r[1],e.lineWidth=r[2],e.lineCap=r[3],e.lineJoin=r[4],e.miterLimit=r[5],e.lineDashOffset=r[7],e.setLineDash(r[6])}drawLabelWithPointPlacement_(e,r,l,a){let o=this.textStates[r],g=this.createLabel(e,r,a,l),v=this.strokeStates[l],w=this.pixelRatio,T=iy(Array.isArray(e)?e[0]:e,o.textAlign||aa),S=lu[o.textBaseline||Ja],k=v&&v.lineWidth?v.lineWidth:0,F=g.width/w-2*o.scale[0],j=T*F+2*(.5-T)*k,J=S*g.height/w+2*(.5-S)*k;return{label:g,anchorX:j,anchorY:J}}execute_(e,r,l,a,o,g,v,w){let T=this.zIndexContext_,S;this.pixelCoordinates_&&vn(l,this.renderedTransform_)?S=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),S=Cn(this.coordinates,0,this.coordinates.length,2,l,this.pixelCoordinates_),N0(this.renderedTransform_,l));let k=0,F=a.length,j=0,J,he,q,Z,ne,me,_e,fe,ve,Ee,Re,Pe,Ye,je=0,Ke=0,xt=null,At=null,rt=this.coordinateCache_,tt=this.viewRotation_,yt=Math.round(Math.atan2(-l[1],l[0])*1e12)/1e12,ut={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:tt},Mt=this.instructions!=a||this.overlaps?0:200,mt,Ft,Bt,Ei;for(;k<F;){let Ue=a[k];switch(Ue[0]){case gt.BEGIN_GEOMETRY:mt=Ue[1],Ei=Ue[3],mt.getGeometry()?v!==void 0&&!Qi(v,Ei.getExtent())?k=Ue[2]+1:++k:k=Ue[2],T&&(T.zIndex=Ue[4]);break;case gt.BEGIN_PATH:je>Mt&&(this.fill_(e),je=0),Ke>Mt&&(e.stroke(),Ke=0),!je&&!Ke&&(e.beginPath(),ne=NaN,me=NaN),++k;break;case gt.CIRCLE:j=Ue[1];let xi=S[j],Nr=S[j+1],ar=S[j+2],Ln=S[j+3],lr=ar-xi,un=Ln-Nr,dn=Math.sqrt(lr*lr+un*un);e.moveTo(xi+dn,Nr),e.arc(xi,Nr,dn,0,2*Math.PI,!0),++k;break;case gt.CLOSE_PATH:e.closePath(),++k;break;case gt.CUSTOM:j=Ue[1],J=Ue[2];let oi=Ue[3],Dn=Ue[4],Ie=Ue[5];ut.geometry=oi,ut.feature=mt,k in rt||(rt[k]=[]);let tr=rt[k];Ie?Ie(S,j,J,2,tr):(tr[0]=S[j],tr[1]=S[j+1],tr.length=2),T&&(T.zIndex=Ue[6]),Dn(tr,ut),++k;break;case gt.DRAW_IMAGE:j=Ue[1],J=Ue[2],ve=Ue[3],he=Ue[4],q=Ue[5];let Ti=Ue[6],Et=Ue[7],ci=Ue[8],Vr=Ue[9],Fn=Ue[10],pn=Ue[11],os=Ue[12],fn=Ue[13];Z=Ue[14]||"declutter";let Xn=Ue[15];if(!ve&&Ue.length>=20){Ee=Ue[19],Re=Ue[20],Pe=Ue[21],Ye=Ue[22];let ae=this.drawLabelWithPointPlacement_(Ee,Re,Pe,Ye);ve=ae.label,Ue[3]=ve;let de=Ue[23];he=(ae.anchorX-de)*this.pixelRatio,Ue[4]=he;let se=Ue[24];q=(ae.anchorY-se)*this.pixelRatio,Ue[5]=q,Ti=ve.height,Ue[6]=Ti,fn=ve.width,Ue[13]=fn}let zn;Ue.length>25&&(zn=Ue[25]);let Oe,br,Zi;Ue.length>17?(Oe=Ue[16],br=Ue[17],Zi=Ue[18]):(Oe=Co,br=!1,Zi=!1),Fn&&yt?pn+=tt:!Fn&&!yt&&(pn-=tt);let Hs=0;for(;j<J;j+=2){if(zn&&zn[Hs++]<fn/this.pixelRatio)continue;let ae=this.calculateImageOrLabelDimensions_(ve.width,ve.height,S[j],S[j+1],fn,Ti,he,q,ci,Vr,pn,os,o,Oe,br||Zi,mt),de=[e,r,ve,ae,Et,br?xt:null,Zi?At:null];if(w){let se,ge,Te;if(Xn){let qe=J-j;if(!Xn[qe]){Xn[qe]={args:de,declutterMode:Z};continue}let Qe=Xn[qe];se=Qe.args,ge=Qe.declutterMode,delete Xn[qe],Te=qv(se)}let Se,Ce;if(se&&(ge!=="declutter"||!w.collides(Te))&&(Se=!0),(Z!=="declutter"||!w.collides(ae.declutterBox))&&(Ce=!0),ge==="declutter"&&Z==="declutter"){let qe=Se&&Ce;Se=qe,Ce=qe}Se&&(ge!=="none"&&w.insert(Te),this.replayImageOrLabel_.apply(this,se)),Ce&&(Z!=="none"&&w.insert(ae.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++k;break;case gt.DRAW_CHARS:let Li=Ue[1],Ne=Ue[2],bt=Ue[3],wt=Ue[4];Ye=Ue[5];let gi=Ue[6],Jr=Ue[7],vt=Ue[8];Pe=Ue[9];let On=Ue[10];Ee=Ue[11],Re=Ue[12];let yi=[Ue[13],Ue[13]];Z=Ue[14]||"declutter";let Q=this.textStates[Re],O=Q.font,N=[Q.scale[0]*Jr,Q.scale[1]*Jr],$;O in this.widths_?$=this.widths_[O]:($={},this.widths_[O]=$);let H=Wd(S,Li,Ne,2),ce=Math.abs(N[0])*Cg(O,Ee,$);if(wt||ce<=H){let ae=this.textStates[Re].textAlign,de=(H-ce)*iy(Ee,ae),se=$v(S,Li,Ne,2,Ee,de,gi,Math.abs(N[0]),Cg,O,$,yt?0:this.viewRotation_);e:if(se){let ge=[],Te,Se,Ce,qe,Qe;if(Pe)for(Te=0,Se=se.length;Te<Se;++Te){Qe=se[Te],Ce=Qe[4],qe=this.createLabel(Ce,Re,"",Pe),he=Qe[2]+(N[0]<0?-On:On),q=bt*qe.height+(.5-bt)*2*On*N[1]/N[0]-vt;let dt=this.calculateImageOrLabelDimensions_(qe.width,qe.height,Qe[0],Qe[1],qe.width,qe.height,he,q,0,0,Qe[3],yi,!1,Co,!1,mt);if(w&&Z==="declutter"&&w.collides(dt.declutterBox))break e;ge.push([e,r,qe,dt,1,null,null])}if(Ye)for(Te=0,Se=se.length;Te<Se;++Te){Qe=se[Te],Ce=Qe[4],qe=this.createLabel(Ce,Re,Ye,""),he=Qe[2],q=bt*qe.height-vt;let dt=this.calculateImageOrLabelDimensions_(qe.width,qe.height,Qe[0],Qe[1],qe.width,qe.height,he,q,0,0,Qe[3],yi,!1,Co,!1,mt);if(w&&Z==="declutter"&&w.collides(dt.declutterBox))break e;ge.push([e,r,qe,dt,1,null,null])}w&&Z!=="none"&&w.load(ge.map(qv));for(let dt=0,_t=ge.length;dt<_t;++dt)this.replayImageOrLabel_.apply(this,ge[dt])}}++k;break;case gt.END_GEOMETRY:if(g!==void 0){mt=Ue[1];let ae=g(mt,Ei);if(ae)return ae}++k;break;case gt.FILL:Mt?je++:this.fill_(e),++k;break;case gt.MOVE_TO_LINE_TO:for(j=Ue[1],J=Ue[2],Ft=S[j],Bt=S[j+1],_e=Ft+.5|0,fe=Bt+.5|0,(_e!==ne||fe!==me)&&(e.moveTo(Ft,Bt),ne=_e,me=fe),j+=2;j<J;j+=2)Ft=S[j],Bt=S[j+1],_e=Ft+.5|0,fe=Bt+.5|0,(j==J-2||_e!==ne||fe!==me)&&(e.lineTo(Ft,Bt),ne=_e,me=fe);++k;break;case gt.SET_FILL_STYLE:xt=Ue,this.alignAndScaleFill_=Ue[2],je&&(this.fill_(e),je=0,Ke&&(e.stroke(),Ke=0)),e.fillStyle=Ue[1],++k;break;case gt.SET_STROKE_STYLE:At=Ue,Ke&&(e.stroke(),Ke=0),this.setStrokeStyle_(e,Ue),++k;break;case gt.STROKE:Mt?Ke++:e.stroke(),++k;break;default:++k;break}}je&&this.fill_(e),Ke&&e.stroke()}execute(e,r,l,a,o,g){this.viewRotation_=a,this.execute_(e,r,l,this.instructions,o,void 0,void 0,g)}executeHitDetection(e,r,l,a,o){return this.viewRotation_=l,this.execute_(e,[e.canvas.width,e.canvas.height],r,this.hitDetectionInstructions,!0,a,o)}},Zv=ry;var gc=["Polygon","Circle","LineString","Image","Text","Default"],oy=["Image","Text"],Xv=gc.filter(h=>!oy.includes(h)),sy=class{constructor(e,r,l,a,o,g,v){this.maxExtent_=e,this.overlaps_=a,this.pixelRatio_=l,this.resolution_=r,this.renderBuffer_=g,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=mr(),this.renderedContext_=null,this.deferredZIndexContexts_=[],this.createExecutors_(o,v)}clip(e,r){let l=this.getClipCoords(r);e.beginPath(),e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3]),e.lineTo(l[4],l[5]),e.lineTo(l[6],l[7]),e.clip()}createExecutors_(e,r){for(let l in e){let a=this.executorsByZIndex_[l];a===void 0&&(a={},this.executorsByZIndex_[l]=a);let o=e[l];for(let g in o){let v=o[g];a[g]=new Zv(this.resolution_,this.pixelRatio_,this.overlaps_,v,r)}}}hasExecutors(e){for(let r in this.executorsByZIndex_){let l=this.executorsByZIndex_[r];for(let a=0,o=e.length;a<o;++a)if(e[a]in l)return!0}return!1}forEachFeatureAtCoordinate(e,r,l,a,o,g){a=Math.round(a);let v=a*2+1,w=an(this.hitDetectionTransform_,a+.5,a+.5,1/r,-1/r,-l,-e[0],-e[1]),T=!this.hitDetectionContext_;T&&(this.hitDetectionContext_=Wi(v,v,void 0,{willReadFrequently:!0}));let S=this.hitDetectionContext_;S.canvas.width!==v||S.canvas.height!==v?(S.canvas.width=v,S.canvas.height=v):T||S.clearRect(0,0,v,v);let k;this.renderBuffer_!==void 0&&(k=Sn(),Kf(k,e),bn(k,r*(this.renderBuffer_+a),k));let F=eC(a),j;function J(fe,ve){let Ee=S.getImageData(0,0,v,v).data;for(let Re=0,Pe=F.length;Re<Pe;Re++)if(Ee[F[Re]]>0){if(!g||j!=="Image"&&j!=="Text"||g.includes(fe)){let Ye=(F[Re]-3)/4,je=a-Ye%v,Ke=a-(Ye/v|0),xt=o(fe,ve,je*je+Ke*Ke);if(xt)return xt}S.clearRect(0,0,v,v);break}}let he=Object.keys(this.executorsByZIndex_).map(Number);he.sort(Ds);let q,Z,ne,me,_e;for(q=he.length-1;q>=0;--q){let fe=he[q].toString();for(ne=this.executorsByZIndex_[fe],Z=gc.length-1;Z>=0;--Z)if(j=gc[Z],me=ne[j],me!==void 0&&(_e=me.executeHitDetection(S,w,l,J,k),_e))return _e}}getClipCoords(e){let r=this.maxExtent_;if(!r)return null;let l=r[0],a=r[1],o=r[2],g=r[3],v=[l,a,l,g,o,g,o,a];return Cn(v,0,8,2,e,v),v}isEmpty(){return qn(this.executorsByZIndex_)}execute(e,r,l,a,o,g,v){let w=Object.keys(this.executorsByZIndex_).map(Number);w.sort(Ds),g=g||gc;let T,S,k,F,j,J;for(v&&w.reverse(),T=0,S=w.length;T<S;++T){let he=w[T].toString();for(j=this.executorsByZIndex_[he],k=0,F=g.length;k<F;++k){let q=g[k];if(J=j[q],J!==void 0){let Z=v===null?void 0:J.getZIndexContext(),ne=Z?Z.getContext():e,me=this.maxExtent_&&q!=="Image"&&q!=="Text";if(me&&(ne.save(),this.clip(ne,l)),J.execute(ne,r,l,a,o,v),me&&ne.restore(),Z){Z.offset();let _e=w[T];this.deferredZIndexContexts_[_e]||(this.deferredZIndexContexts_[_e]=[]),this.deferredZIndexContexts_[_e].push(Z)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){this.deferredZIndexContexts_.forEach(e=>{e.forEach(r=>{r.draw(this.renderedContext_),r.clear()})})}},ny={};function eC(h){if(ny[h]!==void 0)return ny[h];let e=h*2+1,r=h*h,l=new Array(r+1);for(let o=0;o<=h;++o)for(let g=0;g<=h;++g){let v=o*o+g*g;if(v>r)break;let w=l[v];w||(w=[],l[v]=w),w.push(((h+o)*e+(h+g))*4+3),o>0&&w.push(((h-o)*e+(h+g))*4+3),g>0&&(w.push(((h+o)*e+(h-g))*4+3),o>0&&w.push(((h-o)*e+(h-g))*4+3))}let a=[];for(let o=0,g=l.length;o<g;++o)l[o]&&a.push(...l[o]);return ny[h]=a,a}var Hv=sy;var ay=class extends pp{constructor(e,r,l,a,o,g,v){super(),this.context_=e,this.pixelRatio_=r,this.extent_=l,this.transform_=a,this.transformRotation_=a?cx(Math.atan2(a[1],a[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=g,this.userTransform_=v,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=mr()}drawImages_(e,r,l,a){if(!this.image_)return;let o=Cn(e,r,l,a,this.transform_,this.pixelCoordinates_),g=this.context_,v=this.tmpLocalTransform_,w=g.globalAlpha;this.imageOpacity_!=1&&(g.globalAlpha=w*this.imageOpacity_);let T=this.imageRotation_;this.transformRotation_===0&&(T-=this.viewRotation_),this.imageRotateWithView_&&(T+=this.viewRotation_);for(let S=0,k=o.length;S<k;S+=2){let F=o[S]-this.imageAnchorX_,j=o[S+1]-this.imageAnchorY_;if(T!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let J=F+this.imageAnchorX_,he=j+this.imageAnchorY_;an(v,J,he,1,1,T,-J,-he),g.save(),g.transform.apply(g,v),g.translate(J,he),g.scale(this.imageScale_[0],this.imageScale_[1]),g.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),g.restore()}else g.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,F,j,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(g.globalAlpha=w)}drawText_(e,r,l,a){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=Cn(e,r,l,a,this.transform_,this.pixelCoordinates_),g=this.context_,v=this.textRotation_;for(this.transformRotation_===0&&(v-=this.viewRotation_),this.textRotateWithView_&&(v+=this.viewRotation_);r<l;r+=a){let w=o[r]+this.textOffsetX_,T=o[r+1]+this.textOffsetY_;v!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(g.save(),g.translate(w-this.textOffsetX_,T-this.textOffsetY_),g.rotate(v),g.translate(this.textOffsetX_,this.textOffsetY_),g.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&g.strokeText(this.text_,0,0),this.textFillState_&&g.fillText(this.text_,0,0),g.restore()):(this.textStrokeState_&&g.strokeText(this.text_,w,T),this.textFillState_&&g.fillText(this.text_,w,T))}}moveToLineTo_(e,r,l,a,o){let g=this.context_,v=Cn(e,r,l,a,this.transform_,this.pixelCoordinates_);g.moveTo(v[0],v[1]);let w=v.length;o&&(w-=2);for(let T=2;T<w;T+=2)g.lineTo(v[T],v[T+1]);return o&&g.closePath(),l}drawRings_(e,r,l,a){for(let o=0,g=l.length;o<g;++o)r=this.moveToLineTo_(e,r,l[o],a,!0);return r}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=Cx(e,this.transform_,this.pixelCoordinates_),l=r[2]-r[0],a=r[3]-r[1],o=Math.sqrt(l*l+a*a),g=this.context_;g.beginPath(),g.arc(r[0],r[1],o,0,2*Math.PI),this.fillState_&&g.fill(),this.strokeState_&&g.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,r){let l=r.getGeometryFunction()(e);l&&(this.setStyle(r),this.drawGeometry(l))}drawGeometryCollection(e){let r=e.getGeometriesArray();for(let l=0,a=r.length;l<a;++l)this.drawGeometry(r[l])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(l,0,l.length,e.getStride(),!1),r.stroke()}if(this.text_!==""){let r=e.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getExtent();if(Qi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let l=this.context_,a=e.getFlatCoordinates(),o=0,g=e.getEnds(),v=e.getStride();l.beginPath();for(let w=0,T=g.length;w<T;++w)o=this.moveToLineTo_(a,o,g[w],v,!1);l.stroke()}if(this.text_!==""){let l=e.getFlatMidpoints();this.drawText_(l,0,l.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getOrientedFlatCoordinates(),a=0,o=e.getEndss(),g=e.getStride();r.beginPath();for(let v=0,w=o.length;v<w;++v){let T=o[v];a=this.drawRings_(l,a,T,g)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(e){let r=this.context_,l=this.contextFillState_;l?l.fillStyle!=e.fillStyle&&(l.fillStyle=e.fillStyle,r.fillStyle=e.fillStyle):(r.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let r=this.context_,l=this.contextStrokeState_;l?(l.lineCap!=e.lineCap&&(l.lineCap=e.lineCap,r.lineCap=e.lineCap),vn(l.lineDash,e.lineDash)||r.setLineDash(l.lineDash=e.lineDash),l.lineDashOffset!=e.lineDashOffset&&(l.lineDashOffset=e.lineDashOffset,r.lineDashOffset=e.lineDashOffset),l.lineJoin!=e.lineJoin&&(l.lineJoin=e.lineJoin,r.lineJoin=e.lineJoin),l.lineWidth!=e.lineWidth&&(l.lineWidth=e.lineWidth,r.lineWidth=e.lineWidth),l.miterLimit!=e.miterLimit&&(l.miterLimit=e.miterLimit,r.miterLimit=e.miterLimit),l.strokeStyle!=e.strokeStyle&&(l.strokeStyle=e.strokeStyle,r.strokeStyle=e.strokeStyle)):(r.lineCap=e.lineCap,r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset,r.lineJoin=e.lineJoin,r.lineWidth=e.lineWidth,r.miterLimit=e.miterLimit,r.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let r=this.context_,l=this.contextTextState_,a=e.textAlign?e.textAlign:aa;l?(l.font!=e.font&&(l.font=e.font,r.font=e.font),l.textAlign!=a&&(l.textAlign=a,r.textAlign=a),l.textBaseline!=e.textBaseline&&(l.textBaseline=e.textBaseline,r.textBaseline=e.textBaseline)):(r.font=e.font,r.textAlign=a,r.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:a,textBaseline:e.textBaseline})}setFillStrokeStyle(e,r){if(!e)this.fillState_=null;else{let l=e.getColor();this.fillState_={fillStyle:Mn(l||sr)}}if(!r)this.strokeState_=null;else{let l=r.getColor(),a=r.getLineCap(),o=r.getLineDash(),g=r.getLineDashOffset(),v=r.getLineJoin(),w=r.getWidth(),T=r.getMiterLimit(),S=o||An;this.strokeState_={lineCap:a!==void 0?a:Vs,lineDash:this.pixelRatio_===1?S:S.map(k=>k*this.pixelRatio_),lineDashOffset:(g||Pn)*this.pixelRatio_,lineJoin:v!==void 0?v:Gs,lineWidth:(w!==void 0?w:Io)*this.pixelRatio_,miterLimit:T!==void 0?T:wo,strokeStyle:Mn(l||So)}}}setImageStyle(e){let r;if(!e||!(r=e.getSize())){this.image_=null;return}let l=e.getPixelRatio(this.pixelRatio_),a=e.getAnchor(),o=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=a[0]*l,this.imageAnchorY_=a[1]*l,this.imageHeight_=r[1]*l,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let g=e.getScaleArray();this.imageScale_=[g[0]*this.pixelRatio_/l,g[1]*this.pixelRatio_/l],this.imageWidth_=r[0]*l}setTextStyle(e){if(!e)this.text_="";else{let r=e.getFill();if(!r)this.textFillState_=null;else{let j=r.getColor();this.textFillState_={fillStyle:Mn(j||sr)}}let l=e.getStroke();if(!l)this.textStrokeState_=null;else{let j=l.getColor(),J=l.getLineCap(),he=l.getLineDash(),q=l.getLineDashOffset(),Z=l.getLineJoin(),ne=l.getWidth(),me=l.getMiterLimit();this.textStrokeState_={lineCap:J!==void 0?J:Vs,lineDash:he||An,lineDashOffset:q||Pn,lineJoin:Z!==void 0?Z:Gs,lineWidth:ne!==void 0?ne:Io,miterLimit:me!==void 0?me:wo,strokeStyle:Mn(j||So)}}let a=e.getFont(),o=e.getOffsetX(),g=e.getOffsetY(),v=e.getRotateWithView(),w=e.getRotation(),T=e.getScaleArray(),S=e.getText(),k=e.getTextAlign(),F=e.getTextBaseline();this.textState_={font:a!==void 0?a:op,textAlign:k!==void 0?k:aa,textBaseline:F!==void 0?F:Ja},this.text_=S!==void 0?Array.isArray(S)?S.reduce((j,J,he)=>j+=he%2?" ":J,""):S:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=g!==void 0?this.pixelRatio_*g:0,this.textRotateWithView_=v!==void 0?v:!1,this.textRotation_=w!==void 0?w:0,this.textScale_=[this.pixelRatio_*T[0],this.pixelRatio_*T[1]]}}},Yv=ay;var Cs=.5;function Kv(h,e,r,l,a,o,g,v,w){let T=w?zs(a,w):a,S=h[0]*Cs,k=h[1]*Cs,F=Wi(S,k);F.imageSmoothingEnabled=!1;let j=F.canvas,J=new Yv(F,Cs,a,null,g,v,w?rc(Wn(),w):null),he=r.length,q=Math.floor((256*256*256-1)/he),Z={};for(let me=1;me<=he;++me){let _e=r[me-1],fe=_e.getStyleFunction()||l;if(!fe)continue;let ve=fe(_e,o);if(!ve)continue;Array.isArray(ve)||(ve=[ve]);let Re=(me*q).toString(16).padStart(7,"#00000");for(let Pe=0,Ye=ve.length;Pe<Ye;++Pe){let je=ve[Pe],Ke=je.getGeometryFunction()(_e);if(!Ke||!Qi(T,Ke.getExtent()))continue;let xt=je.clone(),At=xt.getFill();At&&At.setColor(Re);let rt=xt.getStroke();rt&&(rt.setColor(Re),rt.setLineDash(null)),xt.setText(void 0);let tt=je.getImage();if(tt){let mt=tt.getImageSize();if(!mt)continue;let Ft=Wi(mt[0],mt[1],void 0,{alpha:!1}),Bt=Ft.canvas;Ft.fillStyle=Re,Ft.fillRect(0,0,Bt.width,Bt.height),xt.setImage(new Qh({img:Bt,anchor:tt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:tt.getOrigin(),opacity:1,size:tt.getSize(),scale:tt.getScale(),rotation:tt.getRotation(),rotateWithView:tt.getRotateWithView()}))}let yt=xt.getZIndex()||0,ut=Z[yt];ut||(ut={},Z[yt]=ut,ut.Polygon=[],ut.Circle=[],ut.LineString=[],ut.Point=[]);let Mt=Ke.getType();if(Mt==="GeometryCollection"){let mt=Ke.getGeometriesArrayRecursive();for(let Ft=0,Bt=mt.length;Ft<Bt;++Ft){let Ei=mt[Ft];ut[Ei.getType().replace("Multi","")].push(Ei,xt)}}else ut[Mt.replace("Multi","")].push(Ke,xt)}}let ne=Object.keys(Z).map(Number).sort(Ds);for(let me=0,_e=ne.length;me<_e;++me){let fe=Z[ne[me]];for(let ve in fe){let Ee=fe[ve];for(let Re=0,Pe=Ee.length;Re<Pe;Re+=2){J.setStyle(Ee[Re+1]);for(let Ye=0,je=e.length;Ye<je;++Ye)J.setTransform(e[Ye]),J.drawGeometry(Ee[Re])}}}return F.getImageData(0,0,j.width,j.height)}function Jv(h,e,r){let l=[];if(r){let a=Math.floor(Math.round(h[0])*Cs),o=Math.floor(Math.round(h[1])*Cs),g=(Ii(a,0,r.width-1)+Ii(o,0,r.height-1)*r.width)*4,v=r.data[g],w=r.data[g+1],S=r.data[g+2]+256*(w+256*v),k=Math.floor((256*256*256-1)/e.length);S&&S%k===0&&l.push(e[S/k-1])}return l}var tC=.5,Qv={Point:lC,LineString:sC,Polygon:hC,MultiPoint:cC,MultiLineString:oC,MultiPolygon:aC,GeometryCollection:nC,Circle:iC};function eb(h,e){return parseInt(Gt(h),10)-parseInt(Gt(e),10)}function ly(h,e){let r=cy(h,e);return r*r}function cy(h,e){return tC*h/e}function iC(h,e,r,l){let a=r.getFill(),o=r.getStroke();if(a||o){let v=h.getBuilder(r.getZIndex(),"Circle");v.setFillStrokeStyle(a,o),v.drawCircle(e,l)}let g=r.getText();if(g&&g.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(g),v.drawText(e,l)}}function hy(h,e,r,l,a,o,g,v){let w=[],T=r.getImage();if(T){let F=!0,j=T.getImageState();j==Tt.LOADED||j==Tt.ERROR?F=!1:j==Tt.IDLE&&T.load(),F&&w.push(T.ready())}let S=r.getFill();S&&S.loading()&&w.push(S.ready());let k=w.length>0;return k&&Promise.all(w).then(()=>a(null)),rC(h,e,r,l,o,g,v),k}function rC(h,e,r,l,a,o,g){let v=r.getGeometryFunction()(e);if(!v)return;let w=v.simplifyTransformed(l,a);if(r.getRenderer())tb(h,w,r,e,g);else{let S=Qv[w.getType()];S(h,w,r,e,g,o)}}function tb(h,e,r,l,a){if(e.getType()=="GeometryCollection"){let g=e.getGeometries();for(let v=0,w=g.length;v<w;++v)tb(h,g[v],r,l,a);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(e,l,r.getRenderer(),r.getHitDetectionRenderer(),a)}function nC(h,e,r,l,a,o){let g=e.getGeometriesArray(),v,w;for(v=0,w=g.length;v<w;++v){let T=Qv[g[v].getType()];T(h,g[v],r,l,a,o)}}function sC(h,e,r,l,a){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawLineString(e,l,a)}let g=r.getText();if(g&&g.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(g),v.drawText(e,l,a)}}function oC(h,e,r,l,a){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawMultiLineString(e,l,a)}let g=r.getText();if(g&&g.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(g),v.drawText(e,l,a)}}function aC(h,e,r,l,a){let o=r.getFill(),g=r.getStroke();if(g||o){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,g),w.drawMultiPolygon(e,l,a)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,a)}}function lC(h,e,r,l,a,o){let g=r.getImage(),v=r.getText(),w=v&&v.getText(),T=o&&g&&w?{}:void 0;if(g){if(g.getImageState()!=Tt.LOADED)return;let S=h.getBuilder(r.getZIndex(),"Image");S.setImageStyle(g,T),S.drawPoint(e,l,a)}if(w){let S=h.getBuilder(r.getZIndex(),"Text");S.setTextStyle(v,T),S.drawText(e,l,a)}}function cC(h,e,r,l,a,o){let g=r.getImage(),v=g&&g.getOpacity()!==0,w=r.getText(),T=w&&w.getText(),S=o&&v&&T?{}:void 0;if(v){if(g.getImageState()!=Tt.LOADED)return;let k=h.getBuilder(r.getZIndex(),"Image");k.setImageStyle(g,S),k.drawMultiPoint(e,l,a)}if(T){let k=h.getBuilder(r.getZIndex(),"Text");k.setTextStyle(w,S),k.drawText(e,l,a)}}function hC(h,e,r,l,a){let o=r.getFill(),g=r.getStroke();if(o||g){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,g),w.drawPolygon(e,l,a)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,a)}}var uy=class extends mp{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Sn(),this.wrappedRenderedExtent_=Sn(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.compositionContext_=null,this.opacity_=1}renderWorlds(e,r,l){let a=r.extent,o=r.viewState,g=o.center,v=o.resolution,w=o.projection,T=o.rotation,S=w.getExtent(),k=this.getLayer().getSource(),F=this.getLayer().getDeclutter(),j=r.pixelRatio,J=r.viewHints,he=!(J[En.ANIMATING]||J[En.INTERACTING]),q=this.compositionContext_,Z=Math.round(r.size[0]*j),ne=Math.round(r.size[1]*j),me=k.getWrapX()&&w.canWrapX(),_e=me?$i(S):null,fe=me?Math.ceil((a[2]-S[2])/_e)+1:1,ve=me?Math.floor((a[0]-S[0])/_e):0;do{let Ee=this.getRenderTransform(g,v,T,j,Z,ne,ve*_e);e.execute(q,[q.canvas.width,q.canvas.height],Ee,T,he,l===void 0?gc:l?oy:Xv,l?F&&r.declutter[F]:void 0)}while(++ve<fe)}setupCompositionContext_(){if(this.opacity_!==1){let e=Wi(this.context.canvas.width,this.context.canvas.height,ty);this.compositionContext_=e}else this.compositionContext_=this.context}releaseCompositionContext_(){if(this.opacity_!==1){let e=this.context.globalAlpha;this.context.globalAlpha=this.opacity_,this.context.drawImage(this.compositionContext_.canvas,0,0),this.context.globalAlpha=e,Jx(this.compositionContext_),ty.push(this.compositionContext_.canvas),this.compositionContext_=null}}renderDeclutter(e){this.getLayer().getDeclutter()&&(this.setupCompositionContext_(),this.renderWorlds(this.replayGroup_,e,!0),this.releaseCompositionContext_())}renderDeferredInternal(e){this.replayGroup_.renderDeferred()}renderFrame(e,r){let l=e.pixelRatio,a=e.layerStatesArray[e.layerIndex];V0(this.pixelTransform,1/l,1/l),j0(this.inversePixelTransform,this.pixelTransform);let o=qf(this.pixelTransform);this.useContainer(r,o,this.getBackground(e));let g=this.context,v=g.canvas,w=this.replayGroup_,T=w&&!w.isEmpty();if(!T&&!(this.getLayer().hasListener(Bs.PRERENDER)||this.getLayer().hasListener(Bs.POSTRENDER)))return null;let S=Math.round(e.size[0]*l),k=Math.round(e.size[1]*l);v.width!=S||v.height!=k?(v.width=S,v.height=k,v.style.transform!==o&&(v.style.transform=o)):this.containerReused||g.clearRect(0,0,S,k),this.preRender(g,e);let F=e.viewState,j=F.projection;this.opacity_=a.opacity,this.setupCompositionContext_();let J=!1;if(T&&a.extent&&this.clipping){let he=Os(a.extent,j);T=Qi(he,e.extent),J=T&&!go(he,e.extent),J&&this.clipUnrotated(this.compositionContext_,e,he)}return T&&this.renderWorlds(w,e,this.getLayer().getDeclutter()?!1:void 0),J&&this.compositionContext_.restore(),this.releaseCompositionContext_(),this.postRender(g,e),this.renderedRotation_!==F.rotation&&(this.renderedRotation_=F.rotation,this.hitDetectionImageData_=null),this.container}getFeatures(e){return new Promise(r=>{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let l=[this.context.canvas.width,this.context.canvas.height];rr(this.pixelTransform,l);let a=this.renderedCenter_,o=this.renderedResolution_,g=this.renderedRotation_,v=this.renderedProjection_,w=this.wrappedRenderedExtent_,T=this.getLayer(),S=[],k=l[0]*Cs,F=l[1]*Cs;S.push(this.getRenderTransform(a,o,g,Cs,k,F,0).slice());let j=T.getSource(),J=v.getExtent();if(j.getWrapX()&&v.canWrapX()&&!go(J,w)){let q=w[0],Z=$i(J),ne=0,me;for(;q<J[0];)--ne,me=Z*ne,S.push(this.getRenderTransform(a,o,g,Cs,k,F,me).slice()),q+=Z;for(ne=0,q=w[2];q>J[2];)++ne,me=Z*ne,S.push(this.getRenderTransform(a,o,g,Cs,k,F,me).slice()),q-=Z}let he=Wn();this.hitDetectionImageData_=Kv(l,S,this.renderedFeatures_,T.getStyleFunction(),w,o,g,ly(o,this.renderedPixelRatio_),he?v:null)}r(Jv(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,r,l,a,o){if(!this.replayGroup_)return;let g=r.viewState.resolution,v=r.viewState.rotation,w=this.getLayer(),T={},S=function(J,he,q){let Z=Gt(J),ne=T[Z];if(ne){if(ne!==!0&&q<ne.distanceSq){if(q===0)return T[Z]=!0,o.splice(o.lastIndexOf(ne),1),a(J,w,he);ne.geometry=he,ne.distanceSq=q}}else{if(q===0)return T[Z]=!0,a(J,w,he);o.push(T[Z]={feature:J,layer:w,geometry:he,distanceSq:q,callback:a})}},k,F=[this.replayGroup_],j=this.getLayer().getDeclutter();return F.some(J=>k=J.forEachFeatureAtCoordinate(e,g,v,l,S,j&&r.declutter[j]?r.declutter[j].all().map(he=>he.value):null)),k}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let r=this.getLayer(),l=r.getSource();if(!l)return!1;let a=e.viewHints[En.ANIMATING],o=e.viewHints[En.INTERACTING],g=r.getUpdateWhileAnimating(),v=r.getUpdateWhileInteracting();if(this.ready&&!g&&a||!v&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let w=e.extent,T=e.viewState,S=T.projection,k=T.resolution,F=e.pixelRatio,j=r.getRevision(),J=r.getRenderBuffer(),he=r.getRenderOrder();he===void 0&&(he=eb);let q=T.center.slice(),Z=bn(w,J*k),ne=Z.slice(),me=[Z.slice()],_e=S.getExtent();if(l.getWrapX()&&S.canWrapX()&&!go(_e,e.extent)){let rt=$i(_e),tt=Math.max($i(Z)/2,rt);Z[0]=_e[0]-tt,Z[2]=_e[2]+tt,px(q,S);let yt=rm(me[0],S);yt[0]<_e[0]&&yt[2]<_e[2]?me.push([yt[0]+rt,yt[1],yt[2]+rt,yt[3]]):yt[0]>_e[0]&&yt[2]>_e[2]&&me.push([yt[0]-rt,yt[1],yt[2]-rt,yt[3]])}if(this.ready&&this.renderedResolution_==k&&this.renderedRevision_==j&&this.renderedRenderOrder_==he&&go(this.wrappedRenderedExtent_,Z))return vn(this.renderedExtent_,ne)||(this.hitDetectionImageData_=null,this.renderedExtent_=ne),this.renderedCenter_=q,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let fe=new jv(cy(k,F),Z,k,F),ve=Wn(),Ee;if(ve){for(let rt=0,tt=me.length;rt<tt;++rt){let yt=me[rt],ut=zs(yt,S);l.loadFeatures(ut,xx(k,S),ve)}Ee=rc(ve,S)}else for(let rt=0,tt=me.length;rt<tt;++rt)l.loadFeatures(me[rt],k,S);let Re=ly(k,F),Pe=!0,Ye=(rt,tt)=>{let yt,ut=rt.getStyleFunction()||r.getStyleFunction();if(ut&&(yt=ut(rt,k)),yt){let Mt=this.renderFeature(rt,Re,yt,fe,Ee,this.getLayer().getDeclutter(),tt);Pe=Pe&&!Mt}},je=zs(Z,S),Ke=l.getFeaturesInExtent(je);he&&Ke.sort(he);for(let rt=0,tt=Ke.length;rt<tt;++rt)Ye(Ke[rt],rt);this.renderedFeatures_=Ke,this.ready=Pe;let xt=fe.finish(),At=new Hv(Z,k,F,l.getOverlaps(),xt,r.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=k,this.renderedRevision_=j,this.renderedRenderOrder_=he,this.renderedExtent_=ne,this.wrappedRenderedExtent_=Z,this.renderedCenter_=q,this.renderedProjection_=S,this.renderedPixelRatio_=F,this.replayGroup_=At,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,r,l,a,o,g,v){if(!l)return!1;let w=!1;if(Array.isArray(l))for(let T=0,S=l.length;T<S;++T)w=hy(a,e,l[T],r,this.boundHandleStyleImageChange_,o,g,v)||w;else w=hy(a,e,l,r,this.boundHandleStyleImageChange_,o,g,v);return w}},ib=uy;var dy=class extends zv{constructor(e){super(e)}createRenderer(){return new ib(this)}},Qa=dy;var rb=fo(Rg(),1);var py=class{constructor(e){this.rbush_=new rb.default(e),this.items_={}}insert(e,r){let l={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:r};this.rbush_.insert(l),this.items_[Gt(r)]=l}load(e,r){let l=new Array(r.length);for(let a=0,o=r.length;a<o;a++){let g=e[a],v=r[a],w={minX:g[0],minY:g[1],maxX:g[2],maxY:g[3],value:v};l[a]=w,this.items_[Gt(v)]=w}this.rbush_.load(l)}remove(e){let r=Gt(e),l=this.items_[r];return delete this.items_[r],this.rbush_.remove(l)!==null}update(e,r){let l=this.items_[Gt(r)],a=[l.minX,l.minY,l.maxX,l.maxY];Fd(a,e)||(this.remove(r),this.insert(e,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(e){let r={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(r).map(function(a){return a.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,r){return this.forEach_(this.getInExtent(e),r)}forEach_(e,r){let l;for(let a=0,o=e.length;a<o;a++)if(l=r(e[a]),l)return l;return l}isEmpty(){return qn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let r=this.rbush_.toJSON();return yo(r.minX,r.minY,r.maxX,r.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let r in e.items_)this.items_[r]=e.items_[r]}},cu=py;var nb=mr(),hu=class h{constructor(e,r,l,a,o,g){this.styleFunction,this.extent_,this.id_=g,this.type_=e,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=l||null,this.properties_=o,this.squaredTolerance_,this.stride_=a,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Yo(this.flatCoordinates_):Ql(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=es(this.getExtent());this.flatInteriorPoints_=Gh(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=Ox(this.flatCoordinates_,this.ends_),r=Hd(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Zd(this.flatCoordinates_,0,e,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Ha(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,r=0,l=this.ends_;for(let a=0,o=l.length;a<o;++a){let g=l[a],v=Ha(e,r,g,2,.5);kr(this.flatMidpoints_,v),r=g}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=qi(e);let r=e.getExtent(),l=e.getWorldExtent();if(r&&l){let a=ln(l)/ln(r);an(nb,l[0],l[3],a,-a,0,0,0),Cn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,nb,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Pd((e,r)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let l=this.simplifiedGeometry_.getFlatCoordinates(),a;switch(this.type_){case"LineString":l.length=Xa(l,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,l,0),a=[l.length];break;case"MultiLineString":a=[],l.length=Ud(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,l,0,a);break;case"Polygon":a=[],l.length=zh(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),l,0,a);break;default:}return a&&(this.simplifiedGeometry_=new h(this.type_,l,a,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};hu.prototype.getFlatCoordinates=hu.prototype.getOrientedFlatCoordinates;var ss=hu;var fy=class extends gr{constructor(e){super(),this.projection=qi(e.projection),this.attributions_=sb(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?e.attributionsCollapsible:!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(l,a){r.viewResolver=l,r.viewRejector=a})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=sb(e),this.changed()}setState(e){this.state_=e,this.changed()}};function sb(h){return h?Array.isArray(h)?function(e){return h}:typeof h=="function"?h:function(e){return[h]}:null}var Po=fy;var hn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function ob(h,e){return[[-1/0,-1/0,1/0,1/0]]}var uC=!1;function dC(h,e,r,l,a,o,g){let v=new XMLHttpRequest;v.open("GET",typeof h=="function"?h(r,l,a):h,!0),e.getType()=="arraybuffer"&&(v.responseType="arraybuffer"),v.withCredentials=uC,v.onload=function(w){if(!v.status||v.status>=200&&v.status<300){let T=e.getType(),S;T=="json"?S=JSON.parse(v.responseText):T=="text"?S=v.responseText:T=="xml"?(S=v.responseXML,S||(S=new DOMParser().parseFromString(v.responseText,"application/xml"))):T=="arraybuffer"&&(S=v.response),S?o(e.readFeatures(S,{extent:r,featureProjection:a}),e.readProjection(S)):g()}else g()},v.onerror=g,v.send()}function my(h,e){return function(r,l,a,o,g){let v=this;dC(h,e,r,l,a,function(w,T){v.addFeatures(w),o!==void 0&&o(w)},g||ms)}}var Zs=class extends mi{constructor(e,r,l){super(e),this.feature=r,this.features=l}},gy=class extends Po{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=ms,this.format_=e.format,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(si(this.format_,"`format` must be set when `url` is set"),this.loader_=my(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:ob;let r=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=r?new cu:null,this.loadedExtentsRtree_=new cu,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let l,a;Array.isArray(e.features)?a=e.features:e.features&&(l=e.features,a=l.getArray()),!r&&l===void 0&&(l=new Yh(a)),a!==void 0&&this.addFeaturesInternal(a),l!==void 0&&this.bindFeaturesCollection_(l)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let r=Gt(e);if(!this.addToIndex_(r,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(r,e);let l=e.getGeometry();if(l){let a=l.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(a,e)}else this.nullGeometryFeatures_[r]=e;this.dispatchEvent(new Zs(hn.ADDFEATURE,e))}setupChangeEvents_(e,r){r instanceof ss||(this.featureChangeKeys_[e]=[Lr(r,li.CHANGE,this.handleFeatureChange_,this),Lr(r,Td.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,r){let l=!0;if(r.getId()!==void 0){let a=String(r.getId());if(!(a in this.idIndex_))this.idIndex_[a]=r;else if(r instanceof ss){let o=this.idIndex_[a];o instanceof ss?Array.isArray(o)?o.push(r):this.idIndex_[a]=[o,r]:l=!1}else l=!1}return l&&(si(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=r),l}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let r=[],l=[],a=[];for(let o=0,g=e.length;o<g;o++){let v=e[o],w=Gt(v);this.addToIndex_(w,v)&&l.push(v)}for(let o=0,g=l.length;o<g;o++){let v=l[o],w=Gt(v);this.setupChangeEvents_(w,v);let T=v.getGeometry();if(T){let S=T.getExtent();r.push(S),a.push(v)}else this.nullGeometryFeatures_[w]=v}if(this.featuresRtree_&&this.featuresRtree_.load(r,a),this.hasListener(hn.ADDFEATURE))for(let o=0,g=l.length;o<g;o++)this.dispatchEvent(new Zs(hn.ADDFEATURE,l[o]))}bindFeaturesCollection_(e){let r=!1;this.addEventListener(hn.ADDFEATURE,function(l){r||(r=!0,e.push(l.feature),r=!1)}),this.addEventListener(hn.REMOVEFEATURE,function(l){r||(r=!0,e.remove(l.feature),r=!1)}),e.addEventListener(bs.ADD,l=>{r||(r=!0,this.addFeature(l.element),r=!1)}),e.addEventListener(bs.REMOVE,l=>{r||(r=!0,this.removeFeature(l.element),r=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let l in this.featureChangeKeys_)this.featureChangeKeys_[l].forEach(Yr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){let l=a=>{this.removeFeatureInternal(a)};this.featuresRtree_.forEach(l);for(let a in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[a])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Zs(hn.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,r){let l=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(l,function(a){let o=a.getGeometry();if(o instanceof ss||o.intersectsCoordinate(e))return r(a)})}forEachFeatureInExtent(e,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(e,r){return this.forEachFeatureInExtent(e,function(l){let a=l.getGeometry();if(a instanceof ss||a.intersectsExtent(e)){let o=r(l);if(o)return o}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),qn(this.nullGeometryFeatures_)||kr(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let r=[];return this.forEachFeatureAtCoordinateDirect(e,function(l){r.push(l)}),r}getFeaturesInExtent(e,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let a=Q0(e,r);return[].concat(...a.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,r){let l=e[0],a=e[1],o=null,g=[NaN,NaN],v=1/0,w=[-1/0,-1/0,1/0,1/0];return r=r||Ad,this.featuresRtree_.forEachInExtent(w,function(T){if(r(T)){let S=T.getGeometry(),k=v;if(v=S instanceof ss?0:S.closestPointXY(l,a,g,v),v<k){o=T;let F=Math.sqrt(v);w[0]=l-F,w[1]=a-F,w[2]=l+F,w[3]=a+F}}}),o}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let r=this.idIndex_[e.toString()];return r!==void 0?r:null}getFeatureByUid(e){let r=this.uidIndex_[e];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let r=e.target,l=Gt(r),a=r.getGeometry();if(!a)l in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[l]=r);else{let g=a.getExtent();l in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[l],this.featuresRtree_&&this.featuresRtree_.insert(g,r)):this.featuresRtree_&&this.featuresRtree_.update(g,r)}let o=r.getId();if(o!==void 0){let g=o.toString();this.idIndex_[g]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[g]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[l]=r;this.changed(),this.dispatchEvent(new Zs(hn.CHANGEFEATURE,r))}hasFeature(e){let r=e.getId();return r!==void 0?r in this.idIndex_:Gt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&qn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,r,l){let a=this.loadedExtentsRtree_,o=this.strategy_(e,r,l);for(let g=0,v=o.length;g<v;++g){let w=o[g];a.forEachInExtent(w,function(S){return go(S.extent,w)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Zs(hn.FEATURESLOADSTART)),this.loader_.call(this,w,r,l,S=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(hn.FEATURESLOADEND,void 0,S))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(hn.FEATURESLOADERROR))}),a.insert(w,{extent:w.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let r=this.loadedExtentsRtree_,l;r.forEachInExtent(e,function(a){if(Fd(a.extent,e))return l=a,!0}),l&&r.remove(l)}removeFeature(e){if(!e)return;let r=Gt(e);r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let r=Gt(e),l=this.featureChangeKeys_[r];if(!l)return;l.forEach(Yr),delete this.featureChangeKeys_[r];let a=e.getId();return a!==void 0&&delete this.idIndex_[a.toString()],delete this.uidIndex_[r],this.dispatchEvent(new Zs(hn.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let r=!1;for(let l in this.idIndex_){let a=this.idIndex_[l];if(e instanceof ss&&Array.isArray(a)&&a.includes(e))a.splice(a.indexOf(e),1);else if(this.idIndex_[l]===e){delete this.idIndex_[l],r=!0;break}}return r}setLoader(e){this.loader_=e}setUrl(e){si(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(my(e,this.format_))}},el=gy;var Zn={SINGLECLICK:"singleclick",CLICK:li.CLICK,DBLCLICK:li.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var yy={ACTIVE:"active"};var _y=class extends gr{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(yy.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(yy.ACTIVE,e)}setMap(e){this.map_=e}};var ab=_y;var xy=class extends ab{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==Zn.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==Zn.POINTERUP){let l=this.handleUpEvent(e);this.handlingDownUpSequence=l&&this.targetPointers.length>0}}else if(e.type==Zn.POINTERDOWN){let l=this.handleDownEvent(e);this.handlingDownUpSequence=l,r=this.stopDown(l)}else e.type==Zn.POINTERMOVE&&this.handleMoveEvent(e);return!r}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var lb=xy;var cb=function(h){let e=h.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var hb=Ad,ub=function(h){return h.type==Zn.CLICK};var db=function(h){return h.type==Zn.SINGLECLICK};var pb=function(h){let e=h.originalEvent;return si(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var fb=0,uu=1,mb=[0,0,0,0],yc=[],vy={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},du=class extends mi{constructor(e,r,l){super(e),this.features=r,this.mapBrowserEvent=l}},by=class extends lb{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:pb,this.defaultDeleteCondition_=function(l){return cb(l)&&db(l)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:hb,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new cu,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Qa({source:new el({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:fC(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(e.features?r=e.features:e.source&&(this.source_=e.source,r=new Yh(this.source_.getFeatures()),this.source_.addEventListener(hn.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(hn.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(bs.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(bs.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let r=e.getGeometry();if(r){let a=this.SEGMENT_WRITERS_[r.getType()];a&&a(e,r)}let l=this.getMap();l&&l.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,l),e.addEventListener(li.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Yh;let l=this.featuresBeingModified_.getArray();for(let a=0,o=r.length;a<o;++a){let g=r[a];for(let v=0,w=g.length;v<w;++v){let T=g[v].feature;T&&!l.includes(T)&&this.featuresBeingModified_.push(T)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new du(vy.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(li.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let r=this.rBush_,l=[];r.forEach(function(a){e===a.feature&&l.push(a)});for(let a=l.length-1;a>=0;--a){let o=l[a];for(let g=this.dragSegments_.length-1;g>=0;--g)this.dragSegments_[g][0]===o&&this.dragSegments_.splice(g,1);r.remove(o)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let r=e.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,r){let l=r.getCoordinates(),a={feature:e,geometry:r,segment:[l,l]};this.rBush_.insert(r.getExtent(),a)}writeMultiPointGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a],v={feature:e,geometry:r,depth:[a],index:a,segment:[g,g]};this.rBush_.insert(r.getExtent(),v)}}writeLineStringGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length-1;a<o;++a){let g=l.slice(a,a+2),v={feature:e,geometry:r,index:a,segment:g};this.rBush_.insert(Fs(g),v)}}writeMultiLineStringGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a];for(let v=0,w=g.length-1;v<w;++v){let T=g.slice(v,v+2),S={feature:e,geometry:r,depth:[a],index:v,segment:T};this.rBush_.insert(Fs(T),S)}}}writePolygonGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a];for(let v=0,w=g.length-1;v<w;++v){let T=g.slice(v,v+2),S={feature:e,geometry:r,depth:[a],index:v,segment:T};this.rBush_.insert(Fs(T),S)}}}writeMultiPolygonGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a];for(let v=0,w=g.length;v<w;++v){let T=g[v];for(let S=0,k=T.length-1;S<k;++S){let F=T.slice(S,S+2),j={feature:e,geometry:r,depth:[v,a],index:S,segment:F};this.rBush_.insert(Fs(F),j)}}}}writeCircleGeometry_(e,r){let l=r.getCenter(),a={feature:e,geometry:r,index:fb,segment:[l,l]},o={feature:e,geometry:r,index:uu,segment:[l,l]},g=[a,o];a.featureSegments=g,o.featureSegments=g,this.rBush_.insert(Yo(l),a);let v=r,w=Wn();if(w&&this.getMap()){let T=this.getMap().getView().getProjection();v=v.clone().transform(w,T),v=Pm(v).transform(T,w)}this.rBush_.insert(v.getExtent(),o)}writeGeometryCollectionGeometry_(e,r){let l=r.getGeometriesArray();for(let a=0;a<l.length;++a){let o=l[a],g=this.SEGMENT_WRITERS_[o.getType()];g(e,o)}}createOrUpdateVertexFeature_(e,r,l){let a=this.vertexFeature_;return a?a.getGeometry().setCoordinates(e):(a=new rs(new _r(e)),this.vertexFeature_=a,this.overlay_.getSource().addFeature(a)),a.set("features",r),a.set("geometries",l),a}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let r;return!e.map.getView().getInteracting()&&e.type==Zn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=Zn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),e.type==Zn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!r}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let r=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],l=[],a=[];for(let o=0,g=this.dragSegments_.length;o<g;++o){let v=this.dragSegments_[o],w=v[0],T=w.feature;l.includes(T)||l.push(T);let S=w.geometry;a.includes(S)||a.push(S);let k=w.depth,F,j=w.segment,J=v[1];for(;r.length<S.getStride();)r.push(j[J][r.length]);switch(S.getType()){case"Point":F=r,j[0]=r,j[1]=r;break;case"MultiPoint":F=S.getCoordinates(),F[w.index]=r,j[0]=r,j[1]=r;break;case"LineString":F=S.getCoordinates(),F[w.index+J]=r,j[J]=r;break;case"MultiLineString":F=S.getCoordinates(),F[k[0]][w.index+J]=r,j[J]=r;break;case"Polygon":F=S.getCoordinates(),F[k[0]][w.index+J]=r,j[J]=r;break;case"MultiPolygon":F=S.getCoordinates(),F[k[1]][k[0]][w.index+J]=r,j[J]=r;break;case"Circle":if(j[0]=r,j[1]=r,w.index===fb)this.changingFeature_=!0,S.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let he=e.map.getView().getProjection(),q=cm(er(S.getCenter(),he),er(r,he)),Z=Wn();if(Z){let ne=S.clone().transform(Z,he);ne.setRadius(q),q=ne.transform(he,Z).getRadius()}S.setRadius(q),this.changingFeature_=!1}break;default:}F&&this.setGeometryCoordinates_(S,F)}this.createOrUpdateVertexFeature_(r,l,a)}handleDownEvent(e){if(!this.condition_(e))return!1;let r=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,r),this.dragSegments_.length=0,this.featuresBeingModified_=null;let l=this.vertexFeature_;if(l){let a=e.map.getView().getProjection(),o=[],g=l.getGeometry().getCoordinates(),v=Fs([g]),w=this.rBush_.getInExtent(v),T={};w.sort(pC);for(let S=0,k=w.length;S<k;++S){let F=w[S],j=F.segment,J=Gt(F.geometry),he=F.depth;if(he&&(J+="-"+he.join("-")),T[J]||(T[J]=new Array(2)),F.geometry.getType()==="Circle"&&F.index===uu){let q=yb(r,F,a);cn(q,g)&&!T[J][0]&&(this.dragSegments_.push([F,0]),T[J][0]=F);continue}if(cn(j[0],g)&&!T[J][0]){this.dragSegments_.push([F,0]),T[J][0]=F;continue}if(cn(j[1],g)&&!T[J][1]){if(T[J][0]&&T[J][0].index===0){let q=F.geometry.getCoordinates();switch(F.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":q=q[he[1]];case"Polygon":if(F.index!==q[he[0]].length-2)continue;break;default:}}this.dragSegments_.push([F,1]),T[J][1]=F;continue}Gt(j)in this.vertexSegments_&&!T[J][0]&&!T[J][1]&&this.insertVertexCondition_(e)&&o.push(F)}o.length&&this.willModifyFeatures_(e,[o]);for(let S=o.length-1;S>=0;--S)this.insertVertex_(o[S],g)}return!!this.vertexFeature_}handleUpEvent(e){for(let r=this.dragSegments_.length-1;r>=0;--r){let l=this.dragSegments_[r][0],a=l.geometry;if(a.getType()==="Circle"){let o=a.getCenter(),g=l.featureSegments[0],v=l.featureSegments[1];g.segment[0]=o,g.segment[1]=o,v.segment[0]=o,v.segment[1]=o,this.rBush_.update(Yo(o),g);let w=a,T=Wn();if(T){let S=e.map.getView().getProjection();w=w.clone().transform(T,S),w=Pm(w).transform(S,T)}this.rBush_.update(w.getExtent(),v)}else this.rBush_.update(Fs(l.segment),l)}return this.featuresBeingModified_&&(this.dispatchEvent(new du(vy.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,r,l){let a=l||r.getCoordinateFromPixel(e),o=r.getView().getProjection(),g=function(T,S){return gb(a,T,o)-gb(a,S,o)},v,w;if(this.hitDetection_){let T=typeof this.hitDetection_=="object"?S=>S===this.hitDetection_:void 0;r.forEachFeatureAtPixel(e,(S,k,F)=>{F&&F.getType()==="Point"&&(F=new _r(Wa(F.getCoordinates(),o)));let j=F||S.getGeometry();if(S instanceof rs&&this.features_.getArray().includes(S)){w=j;let J=S.getGeometry().getFlatCoordinates().slice(0,2);v=[{feature:S,geometry:w,segment:[J,J]}]}return!0},{layerFilter:T})}if(!v){let T=Os(Yo(a,mb),o),S=r.getView().getResolution()*this.pixelTolerance_,k=zs(bn(T,S,mb),o);v=this.rBush_.getInExtent(k)}if(v&&v.length>0){let T=v.sort(g)[0],S=T.segment,k=yb(a,T,o),F=r.getPixelFromCoordinate(k),j=cm(e,F);if(w||j<=this.pixelTolerance_){let J={};if(J[Gt(S)]=!0,this.snapToPointer_||(this.delta_[0]=k[0]-a[0],this.delta_[1]=k[1]-a[1]),T.geometry.getType()==="Circle"&&T.index===uu)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(k,[T.feature],[T.geometry]);else{let he=r.getPixelFromCoordinate(S[0]),q=r.getPixelFromCoordinate(S[1]),Z=ic(F,he),ne=ic(F,q);j=Math.sqrt(Math.min(Z,ne)),this.snappedToVertex_=j<=this.pixelTolerance_,this.snappedToVertex_&&(k=Z>ne?S[1]:S[0]),this.createOrUpdateVertexFeature_(k,[T.feature],[T.geometry]);let me={};me[Gt(T.geometry)]=!0;for(let _e=1,fe=v.length;_e<fe;++_e){let ve=v[_e].segment;if(cn(S[0],ve[0])&&cn(S[1],ve[1])||cn(S[0],ve[1])&&cn(S[1],ve[0])){let Ee=Gt(v[_e].geometry);Ee in me||(me[Ee]=!0,J[Gt(ve)]=!0)}else break}}this.vertexSegments_=J;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,r){let l=e.segment,a=e.feature,o=e.geometry,g=e.depth,v=e.index,w;for(;r.length<o.getStride();)r.push(0);switch(o.getType()){case"MultiLineString":w=o.getCoordinates(),w[g[0]].splice(v+1,0,r);break;case"Polygon":w=o.getCoordinates(),w[g[0]].splice(v+1,0,r);break;case"MultiPolygon":w=o.getCoordinates(),w[g[1]][g[0]].splice(v+1,0,r);break;case"LineString":w=o.getCoordinates(),w.splice(v+1,0,r);break;default:return}this.setGeometryCoordinates_(o,w);let T=this.rBush_;T.remove(e),this.updateSegmentIndices_(o,v,g,1);let S={segment:[l[0],r],feature:a,geometry:o,depth:g,index:v};T.insert(Fs(S.segment),S),this.dragSegments_.push([S,1]);let k={segment:[r,l[1]],feature:a,geometry:o,depth:g,index:v+1};T.insert(Fs(k.segment),k),this.dragSegments_.push([k,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=Zn.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let r=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new du(vy.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,r}return!1}removeVertex_(){let e=this.dragSegments_,r={},l=!1,a,o,g,v,w,T,S,k,F,j,J;for(w=e.length-1;w>=0;--w)g=e[w],j=g[0],J=Gt(j.feature),j.depth&&(J+="-"+j.depth.join("-")),J in r||(r[J]={}),g[1]===0?(r[J].right=j,r[J].index=j.index):g[1]==1&&(r[J].left=j,r[J].index=j.index+1);for(J in r){switch(F=r[J].right,S=r[J].left,T=r[J].index,k=T-1,S!==void 0?j=S:j=F,k<0&&(k=0),v=j.geometry,o=v.getCoordinates(),a=o,l=!1,v.getType()){case"MultiLineString":o[j.depth[0]].length>2&&(o[j.depth[0]].splice(T,1),l=!0);break;case"LineString":o.length>2&&(o.splice(T,1),l=!0);break;case"MultiPolygon":a=a[j.depth[1]];case"Polygon":a=a[j.depth[0]],a.length>4&&(T==a.length-1&&(T=0),a.splice(T,1),l=!0,T===0&&(a.pop(),a.push(a[0]),k=a.length-1));break;default:}if(l){this.setGeometryCoordinates_(v,o);let he=[];if(S!==void 0&&(this.rBush_.remove(S),he.push(S.segment[0])),F!==void 0&&(this.rBush_.remove(F),he.push(F.segment[1])),S!==void 0&&F!==void 0){let q={depth:j.depth,feature:j.feature,geometry:j.geometry,index:k,segment:he};this.rBush_.insert(Fs(q.segment),q)}this.updateSegmentIndices_(v,T,j.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return l}setGeometryCoordinates_(e,r){this.changingFeature_=!0,e.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(e,r,l,a){this.rBush_.forEachInExtent(e.getExtent(),function(o){o.geometry===e&&(l===void 0||o.depth===void 0||vn(o.depth,l))&&o.index>r&&(o.index+=a)})}};function pC(h,e){return h.index-e.index}function gb(h,e,r){let l=e.geometry;if(l.getType()==="Circle"){let o=l;if(e.index===uu){let g=Wn();g&&(o=o.clone().transform(g,r));let v=ic(o.getCenter(),er(h,r)),w=Math.sqrt(v)-o.getRadius();return w*w}}let a=er(h,r);return yc[0]=er(e.segment[0],r),yc[1]=er(e.segment[1],r),dx(a,yc)}function yb(h,e,r){let l=e.geometry;if(l.getType()==="Circle"&&e.index===uu){let o=l,g=Wn();return g&&(o=o.clone().transform(g,r)),Wa(o.getClosestPoint(er(h,r)),r)}let a=er(h,r);return yc[0]=er(e.segment[0],r),yc[1]=er(e.segment[1],r),Wa(lm(a,yc),r)}function fC(){let h=bv();return function(e,r){return h.Point}}var wy=by;var Sy=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=rs,this.supportedMediaTypes=null}getReadOptions(e,r){if(r){let l=r.dataProjection?qi(r.dataProjection):this.readProjection(e);r.extent&&l&&l.getUnits()==="tile-pixels"&&(l=qi(l),l.setWorldExtent(r.extent)),r={dataProjection:l,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return St()}readFeature(e,r){return St()}readFeatures(e,r){return St()}readGeometry(e,r){return St()}readProjection(e){return St()}writeFeature(e,r){return St()}writeFeatures(e,r){return St()}writeGeometry(e,r){return St()}},_b=Sy;function gp(h,e,r){let l=r?qi(r.featureProjection):null,a=r?qi(r.dataProjection):null,o=h;if(l&&a&&!_x(l,a)){e&&(o=h.clone());let g=e?l:a,v=e?a:l;g.getUnits()==="tile-pixels"?o.transform(g,v):o.applyTransform(qa(g,v))}if(e&&r&&r.decimals!==void 0){let g=Math.pow(10,r.decimals),v=function(w){for(let T=0,S=w.length;T<S;++T)w[T]=Math.round(w[T]*g)/g;return w};o===h&&(o=h.clone()),o.applyTransform(v)}return o}var mC={Point:_r,LineString:_s,Polygon:sc,MultiPoint:Vh,MultiLineString:Im,MultiPolygon:km};function gC(h,e,r){return Array.isArray(e[0])?(Xd(h,0,e,r)||(h=h.slice(),Uh(h,0,e,r)),h):(jh(h,0,e,r)||(h=h.slice(),nc(h,0,e,r)),h)}function Cy(h,e){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(o=>Cy({...h,geometry:o})).flat();let l=r.type==="MultiPolygon"?"Polygon":r.type;if(l==="GeometryCollection"||l==="Circle")throw new Error("Unsupported geometry type: "+l);let a=r.layout.length;return gp(new ss(l,l==="Polygon"?gC(r.flatCoordinates,r.ends,a):r.flatCoordinates,r.ends?.flat(),a,h.properties||{},h.id).enableSimplifyTransformed(),!1,e)}function yp(h,e){if(!h)return null;if(Array.isArray(h)){let l=h.map(a=>yp(a,e));return new ym(l)}let r=mC[h.type];return gp(new r(h.flatCoordinates,h.layout,h.ends),!1,e)}var Iy=class extends _b{constructor(){super()}getType(){return"json"}readFeature(e,r){return this.readFeatureFromObject(_p(e),this.getReadOptions(e,r))}readFeatures(e,r){return this.readFeaturesFromObject(_p(e),this.getReadOptions(e,r))}readFeatureFromObject(e,r){return St()}readFeaturesFromObject(e,r){return St()}readGeometry(e,r){return this.readGeometryFromObject(_p(e),this.getReadOptions(e,r))}readGeometryFromObject(e,r){return St()}readProjection(e){return this.readProjectionFromObject(_p(e))}readProjectionFromObject(e){return St()}writeFeature(e,r){return JSON.stringify(this.writeFeatureObject(e,r))}writeFeatureObject(e,r){return St()}writeFeatures(e,r){return JSON.stringify(this.writeFeaturesObject(e,r))}writeFeaturesObject(e,r){return St()}writeGeometry(e,r){return JSON.stringify(this.writeGeometryObject(e,r))}writeGeometryObject(e,r){return St()}};function _p(h){if(typeof h=="string"){let e=JSON.parse(h);return e||null}return h!==null?h:null}var xb=Iy;var Ey=class extends xb{constructor(e){e=e||{},super(),this.dataProjection=qi(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=qi(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,r){let l=null;e.type==="Feature"?l=e:l={type:"Feature",geometry:e,properties:null};let a=My(l.geometry,r);if(this.featureClass===ss)return Cy({geometry:a,id:l.id,properties:l.properties},r);let o=new rs;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&l.geometry_name&&o.setGeometryName(l.geometry_name),o.setGeometry(yp(a,r)),"id"in l&&o.setId(l.id),l.properties&&o.setProperties(l.properties,!0),o}readFeaturesFromObject(e,r){let l=e,a=null;if(l.type==="FeatureCollection"){let o=e;a=[];let g=o.features;for(let v=0,w=g.length;v<w;++v){let T=this.readFeatureFromObject(g[v],r);T&&a.push(T)}}else a=[this.readFeatureFromObject(e,r)];return a.flat()}readGeometryFromObject(e,r){return yC(e,r)}readProjectionFromObject(e){let r=e.crs,l;if(r)if(r.type=="name")l=qi(r.properties.name);else if(r.type==="EPSG")l=qi("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else l=this.dataProjection;return l}writeFeatureObject(e,r){r=this.adaptOptions(r);let l={type:"Feature",geometry:null,properties:null},a=e.getId();if(a!==void 0&&(l.id=a),!e.hasProperties())return l;let o=e.getProperties(),g=e.getGeometry();return g&&(l.geometry=Ty(g,r),delete o[e.getGeometryName()]),qn(o)||(l.properties=o),l}writeFeaturesObject(e,r){r=this.adaptOptions(r);let l=[];for(let a=0,o=e.length;a<o;++a)l.push(this.writeFeatureObject(e[a],r));return{type:"FeatureCollection",features:l}}writeGeometryObject(e,r){return Ty(e,this.adaptOptions(r))}};function My(h,e){if(!h)return null;let r;switch(h.type){case"Point":{r=xC(h);break}case"LineString":{r=vC(h);break}case"Polygon":{r=CC(h);break}case"MultiPoint":{r=wC(h);break}case"MultiLineString":{r=bC(h);break}case"MultiPolygon":{r=SC(h);break}case"GeometryCollection":{r=_C(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function yC(h,e){let r=My(h,e);return yp(r,e)}function _C(h,e){return h.geometries.map(function(l){return My(l,e)})}function xC(h){let e=h.coordinates;return{type:"Point",flatCoordinates:e,layout:Jo(e.length)}}function vC(h){let e=h.coordinates,r=e.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:Jo(e[0]?.length||2)}}function bC(h){let e=h.coordinates,r=e[0]?.[0]?.length||2,l=[],a=Qo(l,0,e,r);return{type:"MultiLineString",flatCoordinates:l,ends:a,layout:Jo(r)}}function wC(h){let e=h.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Jo(e[0]?.length||2)}}function SC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.[0].length||2,a=jd(r,0,e,l);return{type:"MultiPolygon",flatCoordinates:r,ends:a,layout:Jo(l)}}function CC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.length,a=Qo(r,0,e,l);return{type:"Polygon",flatCoordinates:r,ends:a,layout:Jo(l)}}function Ty(h,e){h=gp(h,!0,e);let r=h.getType(),l;switch(r){case"Point":{l=PC(h,e);break}case"LineString":{l=EC(h,e);break}case"Polygon":{l=RC(h,e);break}case"MultiPoint":{l=MC(h,e);break}case"MultiLineString":{l=TC(h,e);break}case"MultiPolygon":{l=AC(h,e);break}case"GeometryCollection":{l=IC(h,e);break}case"Circle":{l={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return l}function IC(h,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(l){return Ty(l,e)})}}function EC(h,e){return{type:"LineString",coordinates:h.getCoordinates()}}function TC(h,e){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function MC(h,e){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function AC(h,e){let r;return e&&(r=e.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function PC(h,e){return{type:"Point",coordinates:h.getCoordinates()}}function RC(h,e){let r;return e&&(r=e.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var vr=Ey;var kC=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,vb=/^([\d.]+),([\d.]+)$/,bb=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,xp="stop-fetch",wb=h=>{let e=[];return h.forEach(r=>{let l=r.getGeometry()?.getCoordinates();l?.length&&e.push(...l)}),e},Ay=class h extends ac{constructor(r={}){super(r);this.viaPoints=[];this.graphs=[];this.useRawViaPoints=!1;this.snapToClosestStation=!1;this.cacheStationData={};this.abortControllers={};this.segments=[];this.format=new vr({featureProjection:"EPSG:3857"});this.initialRouteDrag={};this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.routingApiParams=r.routingApiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new bh({...r}),this.routingLayer=r.routingLayer||new Qa({source:new el,style:r.style}),this.onRouteError=r.onRouteError||(l=>{this.dispatchEvent(new mi("change:route")),this.reset(),console.error(l)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",l=>{l.key==="active"&&this.onActiveChange(),l.key==="mot"&&this.viaPoints&&this.drawRoute()})}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}static getGraphsResolutions(r,l){let a=l.getView();return r.map(([,o,g])=>[a.getResolutionForZoom(o),a.getResolutionForZoom(g||o+1)])}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}addViaPoint(r,l=-1,a=0){this.viaPoints.splice(l===-1?this.viaPoints.length:l,a,r),this.drawRoute(),this.dispatchEvent(new mi("change:route"))}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new mi("change:route"))}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new mi("change:route"))}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new mi("change:route"))}abortRequests(){this.graphs.forEach(r=>{let l=r[0];this.abortControllers[l]&&this.abortControllers[l].abort(),this.abortControllers[l]=new AbortController}),this.abortControllers[xp]?.abort(),this.abortControllers[xp]=new AbortController,this.loading=!1}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(!0),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[xp]);let r=this.viaPoints.map(l=>{if(Array.isArray(l)){let a=this.getMap()?.getView().getProjection(),[o,g]=$a(l,a);return this.snapToClosestStation?[`@${g}`,o]:[g,o]}return this.useRawViaPoints?l:`!${l}`});return this.loading=!0,this.viaPoints.forEach((l,a)=>this.drawViaPoint(l,a,this.abortControllers[xp])),Promise.all(this.graphs.map(([l],a)=>{let{signal:o}=this.abortControllers[l];return this.api?this.api.route({graph:l,via:`${r.join("|")}`,mot:this.mot,"resolve-hops":!1,elevation:!1,"coord-radius":100,"coord-punish":1e3,...this.routingApiParams||{}},{signal:o}).then(g=>{if(this.segments=this.format.readFeatures(g),this.mot==="foot"){let T=this.segments.reduce((S,k)=>{let F=k.get("trg");return S.find(j=>j[0]===F[0]&&j[1]===F[1])?S:[...S,F]},[]);this.segments=T.map(S=>{let k=this.segments.filter(j=>{let J=j.get("trg");return J[0]===S[0]&&J[1]===S[1]}),F=wb(k);return new rs({geometry:new _s(F)})})}let v=wb(this.segments),w=new rs({geometry:new _s(v)});w.set("graph",l),w.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[a]?.length>=2&&(w.set("minResolution",this.graphsResolutions[a][0]),w.set("maxResolution",this.graphsResolutions[a][1])),this.routingLayer?.getSource()?.addFeature(w),this.loading=!1}).catch(g=>{/AbortError/.test(g.message)||(this.segments=[],this.dispatchEvent(new mi("error")),this.onRouteError(g,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,l,a){let o=new rs;if(o.set("viaPointIdx",l),Array.isArray(r))return o.setGeometry(new _r(r)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||bb.test(r)){let S,k;return this.useRawViaPoints?[,S,,k]=bb.exec(r)||[]:[S,k]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${S}?key=${this.stopsApiKey}`,{signal:a.signal}).then(F=>F.json()).then(F=>{let{coordinates:j}=F.features[0].geometry;return this.cacheStationData[r]=yr(j),o.set("viaPointTrack",k),o.setGeometry(new _r(yr(j))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(F=>{/AbortError/.test(F.message)||(this.dispatchEvent(new mi("error")),this.onRouteError(F,this),this.loading=!1)})}if(this.useRawViaPoints&&vb.test(r)){let[S,k]=vb.exec(r)||[];if(k&&S){let F=parseFloat(k),j=parseFloat(S),J=yr([F,j],this.getMap()?.getView().getProjection());return o.setGeometry(new _r(J)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,g,,v,w,,T]=kC.exec(r)||[];if(w&&v){let S=yr([parseFloat(w),parseFloat(v)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",T),o.setGeometry(new _r(S)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}return g?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${g}&limit=1`,{signal:a.signal}).then(S=>S.json()).then(S=>{let{coordinates:k}=S.features[0].geometry;return this.cacheStationData[r]=yr(k),o.set("viaPointTrack",T),o.setGeometry(new _r(yr(k))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(S=>(this.dispatchEvent(new mi("error")),this.onRouteError(S,this),this.loading=!1,null)):Promise.resolve(null)}onMapClick(r){let a=r.target.getFeaturesAtPixel(r.pixel,{layerFilter:o=>o===this.routingLayer,hitTolerance:5}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(a){this.removeViaPoint(a.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyStart(r){let l=-1,a=r.features.getArray().find(g=>g.getGeometry()?.getType()==="LineString");if(a&&a.getGeometry()&&r.mapBrowserEvent.coordinate){let g=bn(new _r(a.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);l=this.segments.findIndex(v=>v.getGeometry()?.intersectsExtent(g))}let o=(r.features.getArray().filter(g=>g.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={viaPoint:o,oldRoute:a&&a.clone(),segmentIndex:l}}onModifyEnd(r){let l=r.mapBrowserEvent.coordinate,{oldRoute:a,viaPoint:o,segmentIndex:g}=this.initialRouteDrag||{};return o?this.addViaPoint(l,o.get("viaPointIdx"),1):a?g===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(l,(g||0)+1):this.addViaPoint(l,0,1)}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new wy({source:this.routingLayer?.getSource()||void 0,pixelTolerance:6,deleteCondition:r=>{let a=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return ub(r)&&a?(this.removeViaPoint(a.get("index")),!0):!1}}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}removeListeners(){this.onMapClickKey&&Ih(this.onMapClickKey)}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}activate(){let r=this.getMap();r&&(this.format=new vr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}render(){}},Sb=Ay;var Py=class{constructor(e){let{apiParams:r,apiKey:l,url:a,placeholder:o}=e||{};this.apiParams={limit:20,...r||{}},this.placeholder=o||"Search for a stop...";let g={apiKey:l};a&&(g.url=a),this.api=new wh(g),this.abortController=new AbortController,this.createElement(e),this.options=e}render(e){let r=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(l=>{let a=document.createElement("div");a.innerHTML=l?.properties?.name,a.onclick=o=>{this.options?.onSuggestionClick?.(l,o)},Object.assign(a.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(a)}))}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),e.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",overflowY:"auto",cursor:"pointer"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{display:"none",position:"absolute",right:"0",padding:"0 10px",fontSize:"200%",cursor:"pointer"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}search(e,r){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(l=>{this.render(l)}).catch(()=>{this.render()})}},Cb=Py;var LC=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},Ib=LC;var Ry=class extends ac{constructor(e){let r=Ib();r.className=e?.className||"mbt-stop-finder";let l={element:r,...e||{}};super(l),this.controller=new Cb({onSuggestionClick:this.onSuggestionClick.bind(this),...l})}onSuggestionClick(e){let r=yr(e.geometry.coordinates);this.getMap()?.getView().setCenter(r)}},Eb=Ry;var Db=fo(Dy());var kb=fo(vp());function KC(h){return class extends h{constructor(r){super(r);this.options={};this.olListenersKeys=[];r.properties&&(console.warn("Deprecated. Don't use properties options. Pass the values directly in options object."),this.setProperties(r.properties)),this.olListenersKeys?.push(this.on("propertychange",l=>{l.key==="children"&&this.onChildrenChange(l.oldValue)}),this.on("change:visible",()=>{this.onVisibleChange()}),this.on("change:visible:group",l=>{this.group===l.target.group&&this!==l.target&&this.visible?this.visible=!1:this.children&&this.children.forEach(a=>a.dispatchEvent(l))})),this.options=r,this.children=r.children||[]}get children(){return this.get("children")||[]}set children(r){this.set("children",r||[])}get copyrights(){return console.warn("Deprecated. Use the source object to get the attributions"),this.get("copyrights")}set copyrights(r){console.warn("Deprecated. Use the source object to set the attributions");let l=r&&!Array.isArray(r)?[r]:r;this.set("copyrights",l||[])}get disabled(){return this.get("disabled")}set disabled(r){this.set("disabled",r)}get group(){return this.get("group")}get hitTolerance(){return console.warn("Deprecated. Pass the pixelTolerance when you request the features."),this.get("hitTolerance")||5}get key(){return this.get("key")||this.get("name")||Gt(this)}get map(){return this.getMapInternal()}get name(){return this.get("name")}get olLayer(){return console.warn("Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."),this}set olLayer(r){console.log("Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return this.get("parent")}set parent(r){this.set("parent",r)}get visible(){return this.getVisible()}set visible(r){this.setVisible(r)}setMapInternal(r){super.setMapInternal(r),r?this.attachToMap(r):this.detachFromMap()}onChildrenChange(r){(r||[]).forEach(l=>{l.set("parent",void 0)}),(this.children||[]).forEach(l=>{l.set("parent",this)})}onVisibleChange(){let r=this.get("parent"),l=this.get("children")||[];if(this.getVisible()){let a=this.get("group");if(r&&r.setVisible(!0),l&&!l.some(o=>o.getVisible())&&l.forEach(o=>{o.setVisible(!0)}),r&&a){let o=r;for(;o.get("parent");)o=o.get("parent");let g=new mi("change:visible:group");g.target=this,o.dispatchEvent(g)}}else l.forEach(a=>{a.setVisible(!1)}),r?.getVisible()&&!r?.get("children").find(a=>a.getVisible())&&r.setVisible(!1)}attachToMap(r){(super.attachToMap||(()=>{}))(r),(this.get("children")||[]).forEach(l=>{r.addLayer(l)})}detachFromMap(){(this.get("children")||[]).forEach(r=>{this.map.removeLayer(r)}),(super.detachFromMap||(()=>{}))(map)}flat(){return ja(this)}}}var Rb=KC;function JC(h){return class extends Rb(h){constructor(e={}){super(e)}}}var _c=JC;var Oy=class extends _c(xo){get apiKey(){return this.get("apiKey")}set apiKey(e){this.set("apiKey",e)}get apiKeyName(){return this.get("apiKeyName")}set apiKeyName(e){this.set("apiKeyName",e)}get style(){return this.get("style")}set style(e){this.set("style",e)}get url(){return this.get("url")}set url(e){this.set("url",e)}get queryRenderedFeaturesOptions(){return this.get("queryRenderedFeaturesOptions")}set queryRenderedFeaturesOptions(e){this.set("queryRenderedFeaturesOptions",e)}constructor(e){super({source:new Po({attributions:()=>this.mbMap&&Ga(this.mbMap)||[]}),apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...e||{},mapOptions:{interactive:!1,trackResize:!1,attributionControl:!1,...e?.mapOptions||{}},queryRenderedFeaturesOptions:{...e?.queryRenderedFeaturesOptions||{}}})}attachToMap(e){super.attachToMap(e),this.loadMbMap();let r=(0,kb.default)(this.updateMbMap.bind(this),150);this.olListenersKeys.push(this.on("propertychange",l=>{/(apiKey|apiKeyName|url|style|)/.test(l.key)&&r()}))}detachFromMap(){this.mbMap&&(this.mbMap.triggerRepaint=()=>{},this.mbMap.remove(),this.mbMap=void 0),this.loaded=!1,super.detachFromMap()}loadMbMap(){if(this.loaded=!1,this.olListenersKeys.push(this.map?.on("change:target",this.loadMbMap.bind(this))),!this.map?.getTargetElement())return;if(!this.visible){this.olListenersKeys.push(this.once("change:visible",this.loadMbMap.bind(this)));return}let e=document.createElement("div");e.style.position="absolute",e.style.width="100%",e.style.height="100%",this.mbMap=this.createMap({style:this.getStyle()||{version:"8",sources:{},layers:[]},container:e,...this.options?.mapOptions||{}}),this.mbMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mbMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new mi("load"))})}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:Na(`${this.url}/styles/${this.style}/style.json`,{[this.apiKeyName]:this.apiKey}).toString()}createMap(e){throw new Error("createMap must be implemented in child class")}updateMbMap(){this.mbMap?.setStyle(this.getStyle(),{diff:!1})}},Lb=Oy;var By={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},pu=class extends pc{getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),a=l.getMapInternal(),{mbMap:o}=l,g=a?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(By[g]||(By[g]=new vr({featureProjection:g})),o?.isStyleLoaded()){let w=e&&o.project($a(e));if(w?.x&&w?.y){let T=[w.x,w.y];if(r){let[S,k]=T;T=[[S-r,k-r],[S+r,k+r]]}v=o.queryRenderedFeatures(T,l.queryRenderedFeaturesOptions||{}).map(S=>{let k=By[g].readFeature(S);return k&&k.set(ra,S),k})}}return v}prepareFrame(){return!0}renderFrame(e){let r=this.getLayer(),{map:l,mbMap:a}=r;if(!r||!l||!a)return null;let o=a.getCanvas(),{viewState:g}=e,v=r.getOpacity()||1;return o.style.opacity=`${v}`,a.jumpTo({center:$a(g.center),zoom:g.zoom-1,bearing:ax(-g.rotation)}),o.isConnected?(o.width!==e.size[0]||o.height!==e.size[1])&&a.resize():l.render(),a.redraw(),a.getContainer()}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,a){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(g=>{a(g,this.layer_,g.getGeometry())}),o?.[0]}};var fu=class h extends Lb{get maplibreMap(){return this.mbMap}constructor(e){super({...e})}createRenderer(){return new pu(this)}createMap(e){return new Db.Map(e)}clone(e){return new h({...this.options||{},...e||{}})}};var Ny={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},mu=class extends pc{getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),a=l.getMapInternal(),{maplibreMap:o}=l.maplibreLayer,g=a?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(Ny[g]||(Ny[g]=new vr({featureProjection:g})),o?.isStyleLoaded()){let w=e&&o.project($a(e));if(w?.x&&w?.y){let T=[w.x,w.y];if(r){let[k,F]=T;T=[[k-r,F-r],[k+r,F+r]]}let S=l.layers||[];l.layersFilter&&(S=o.getStyle().layers.filter(l.layersFilter)),l.queryRenderedLayersFilter&&(S=o.getStyle().layers.filter(l.queryRenderedLayersFilter)),v=o.queryRenderedFeatures(T,{layers:S.map(k=>k.id),validate:!1}).map(k=>{let F=Ny[g].readFeature(k);return F&&F.set(ra,k),F})}}return v}prepareFrame(){return!0}renderFrame(){return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,a){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(g=>{a(g,this.layer_,g.getGeometry())}),o?.[0]}};var Vy=class h extends _c(xo){constructor(r){super({source:new Po({}),...r||{}});this.highlightedFeatures=[];this.selectedFeatures=[];this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=l=>!!this.layers.find(a=>l.id===a.id))}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return console.warn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return console.warn("Deprecated. Use layers instead."),this.layers[0]}set styleLayer(r){console.warn("Deprecated. Use layers instead."),this.layers=[r]}get styleLayers(){return console.warn("Deprecated. Use layers instead."),this.layers}set styleLayers(r){console.warn("Deprecated. Use layers instead."),this.layers=r}createRenderer(){return new mu(this)}attachToMap(r){if(this.maplibreLayer&&!this.maplibreLayer.map&&r.addLayer(this.maplibreLayer),super.attachToMap(r),!this.map||!this.maplibreLayer)return;let{maplibreMap:l}=this.maplibreLayer;if(!l){this.olListenersKeys.push(this.map.on("change:target",()=>{this.attachToMap(r)}));return}l.loaded()?this.onLoad():l.once("load",this.onLoad),this.olListenersKeys.push(this.on("change:visible",a=>{this.applyLayoutVisibility(a)}),this.maplibreLayer.on("load",this.onLoad),this.on("propertychange",a=>{/(sources|layers|layersFilter|maplibreLayer|beforeId|)/.test(a.key)&&(this.detachFromMap(),this.attachToMap(r))}))}detachFromMap(){this.maplibreLayer?.maplibreMap&&(this.maplibreLayer.maplibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}addSources(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.sources))return;let{maplibreMap:r}=this.maplibreLayer;r&&this.sources.forEach(l=>{let{id:a}=l;r.getSource(a)||r.addSource(a,l)})}removeSources(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.layers))return;let{maplibreMap:r}=this.maplibreLayer;r&&this.sources.forEach(l=>{let{id:a}=l;r.getSource(a)&&r.removeSource(a)})}addLayers(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.layers))return;let{maplibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(l=>{let{id:a,source:o}=l;(!o||o&&r.getSource(o))&&a&&!r.getLayer(a)&&r.addLayer(l,this.beforeId)}),this.applyLayoutVisibility())}removeLayers(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.layers))return;let{maplibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(l=>{let{id:a}=l;a&&r.getLayer(a)&&r.removeLayer(a)})}onLoad(){if(!this.maplibreLayer?.maplibreMap)return;this.addSources(),this.addLayers();let{maplibreMap:r}=this.maplibreLayer,l=r.getStyle();if(l?.layers&&this.layersFilter){let a=l.layers.filter(this.layersFilter);this.disabled=!a.length}}getFeatureInfoAtCoordinate(r){if(!this.maplibreLayer?.maplibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{maplibreMap:l}=this.maplibreLayer;if(!l.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let a=this.layers||[];return this.layersFilter&&(a=l.getStyle().layers.filter(this.layersFilter)),this.queryRenderedLayersFilter&&(a=l.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({features:[],layer:this,coordinate:r})}setHoverState(r,l){if(!this.maplibreLayer?.maplibreMap||!r.length)return;let{maplibreMap:a}=this.maplibreLayer;r.forEach(o=>{let{source:g,sourceLayer:v}=o.get(ra)||{};if(!g&&!v||!o.getId()){o.getId()||console.warn("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",o.getId(),o.getProperties());return}a.setFeatureState({id:o.getId(),source:g,sourceLayer:v},{hover:l})})}select(r=[]){this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}highlight(r=[]){let l=this.highlightedFeatures?.filter(a=>!(this.selectedFeatures||[]).map(o=>o.getId()).includes(a.getId()))||[];this.setHoverState(l,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}applyLayoutVisibility(r){if(!this.maplibreLayer?.maplibreMap?.getStyle()||!this.layersFilter)return;let{maplibreMap:l}=this.maplibreLayer,a=l.getStyle(),o=this.getVisible()?"visible":"none",g=a.layers||[];for(let v=0;v<g.length;v+=1){let w=g[v];if(this.layersFilter(w)){let{id:T}=w;l.getLayer(T)&&(l.setLayoutProperty(T,"visibility",o),(this.getMinZoom()||this.getMaxZoom())&&l.setLayerZoomRange(T,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}clone(r){return new h({...this.options,...r})}},Fb=Vy;var $y=fo(vp());var jy=fo(vp()),Uy=fo(Vb());function gI(h){return class extends h{constructor(r){super({hitTolerance:10,...r}),this.defineProperties(r),this.debug=r.debug||!1,this.mode=r.mode||Ki.TOPOGRAPHIC,this.api=r.api||new Ch(r),this.tenant=r.tenant||"",this.minZoomInterpolation=r.minZoomInterpolation||8,this.format=new vr,this.onStart=r.onStart,this.onStop=r.onStop,this.motsByZoom=r.motsByZoom||[vs,vs,vs,vs,vs,vs,vs,vs,vs,Yd,Yd],this.getMotsByZoom=l=>r.getMotsByZoom?r.getMotsByZoom(l,this.motsByZoom):this.motsByZoom[l],this.generalizationLevelByZoom=r.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=l=>r.getGeneralizationLevelByZoom?r.getGeneralizationLevelByZoom(l,this.generalizationLevelByZoom):this.generalizationLevelByZoom[l],this.renderTimeIntervalByZoom=r.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=l=>r.getRenderTimeIntervalByZoom?r.getRenderTimeIntervalByZoom(l,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[l],this.isUpdateBboxOnMoveEnd=r.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,Uy.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,jy.default)(this.renderTrajectoriesInternal,50,{leading:!0,trailing:!0,maxWait:5e3}),this.renderTrajectoriesInternal=this.renderTrajectoriesInternal.bind(this),this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}defineProperties(r){(super.defineProperties||(()=>{}))(r);let{style:l,speed:a,pixelRatio:o,hoverVehicleId:g,selectedVehicleId:v,filter:w,sort:T,time:S,live:k,canvas:F,styleOptions:j,mode:J,bboxParameters:he}=r,q=F,Z=a||1,ne=S||new Date,me=J||Ki.TOPOGRAPHIC,_e=l||Ya;Object.defineProperties(this,{isTrackerLayer:{value:!0},canvas:{get:()=>(q||(q=document.createElement("canvas")),q),set:fe=>{q=fe}},mode:{get:()=>me,set:fe=>{fe!==me&&(me=fe,this.api?.wsApi?.open&&(this.stop(),this.start()))}},style:{get:()=>_e,set:fe=>{_e=fe,this.renderTrajectories()}},styleOptions:{value:{...oc,...j||{}}},speed:{get:()=>Z,set:fe=>{Z=fe,this.start()}},bboxParameters:{value:he,writable:!0},filter:{value:w,writable:!0},sort:{value:T,writable:!0},live:{value:k===!1?k:!0,writable:!0},time:{get:()=>ne,set:fe=>{ne=fe&&fe.getTime?fe:new Date(fe),this.renderTrajectories()}},trajectories:{value:{},writable:!0},hoverVehicleId:{value:g,writable:!0},selectedVehicleId:{value:v,writable:!0},pixelRatio:{value:o||(typeof window<"u"?window.devicePixelRatio:1),writable:!0},useRequestAnimationFrame:{value:r.useRequestAnimationFrame||!1,writable:!0},useThrottle:{value:r.useThrottle!==!1,writable:!0},useDebounce:{value:r.useDebounce||!1,writable:!0}})}attachToMap(r){super.attachToMap(r),document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),Ih(this.visibilityRef),this.canvas){let r=this.canvas.getContext("2d");r&&r.clearRect(0,0,this.canvas.width,this.canvas.height),super.detachFromMap()}}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}renderTrajectoriesInternal(r,l=!1){if(!this.map||!this.trajectories)return!1;let a=this.live?Date.now():this.time?.getTime(),o=Object.values(this.trajectories);return this.sort&&o.sort(this.sort),!this.canvas||!this.style||(this.renderState=Wh(this.canvas,o,this.style,{...r,pixelRatio:this.pixelRatio||1,time:a},{filter:this.filter,noInterpolate:(r.zoom||0)<this.minZoomInterpolation?!0:l,hoverVehicleId:this.hoverVehicleId,selectedVehicleId:this.selectedVehicleId,...this.styleOptions})),!0}renderTrajectories(r,l){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),r&&(!l&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,l)}):!l&&this.useDebounce?this.debounceRenderTrajectories(r,l):!l&&this.useThrottle?this.throttleRenderTrajectories(r,l):this.renderTrajectoriesInternal(r,l))}setBbox(r,l){if(this.trajectories&&r&&l){let k=Object.keys(this.trajectories);for(let F=k.length-1;F>=0;F-=1)this.purgeTrajectory(this.trajectories[k[F]],r,l)}let a=Math.floor(l);if(!r||Number.isNaN(a))return;let[o,g,v,w]=r,T=[Math.floor(o),Math.floor(g),Math.ceil(v),Math.ceil(w),a],S=this.getGeneralizationLevelByZoom(a);this.generalizationLevel&&T.push(`gen=${S}`),this.mots=this.getMotsByZoom(a),this.mots&&T.push(`mots=${this.mots}`),this.tenant&&T.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&T.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([k,F])=>{T.push(`${k}=${F}`)}),this.api.bbox=T}getRefreshTimeInMs(r=0){let l=r!==void 0?Math.round(r):-1,a=this.getRenderTimeIntervalByZoom(l)||25,o=Math.max(25,a/(this.speed||1)),g=Math.min(o,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,Uy.default)(this.renderTrajectoriesInternal,g,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,jy.default)(this.renderTrajectoriesInternal,g,{leading:!0,trailing:!0,maxWait:5e3})),this.api?.buffer){let[,v]=this.api.buffer;this.api.buffer=[g,v]}return o}getVehicle(r){return this.trajectories&&Object.values(this.trajectories).filter(r)||[]}getFeatureInfoAtCoordinate(r,l){let{resolution:a,nb:o}=l,g=bn([...r,...r],this.hitTolerance*a),v=Object.values(this.trajectories||{});this.sort&&(v=v.sort(this.sort));let w=[];for(let T=0;T<v.length&&(v[T].properties.coordinate&&mo(g,v[T].properties.coordinate)&&w.push(v[T]),w.length!==o);T+=1);return Promise.resolve({layer:this,features:w,coordinate:r})}getTrajectoryInfos(r){let l=[this.api.getStopSequence(r),this.api.getFullTrajectory(r,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0)))];return Promise.all(l).then(([a,o])=>({stopSequence:a,fullTrajectory:o}))}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([r,l])=>{let a=l?.properties?.time_intervals;this.time&&a.length&&a[a.length-1][0]<this.time&&this.removeTrajectory(r)})}purgeTrajectory(r,l,a){let{type:o,bounds:g}=r.properties;return this.isUpdateBboxOnMoveEnd&&!Qi(l,g)||this.mots&&!this.mots.includes(o)?(this.removeTrajectory(r),!0):!1}addTrajectory(r){this.trajectories||(this.trajectories={}),this.trajectories[r.properties.train_id]=r,this.renderTrajectories()}removeTrajectory(r){let l;typeof r!="string"?l=r?.properties?.train_id:l=r,this.trajectories&&delete this.trajectories[l]}onZoomEnd(){this.startUpdateTime()}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(this.visible===!1)return;this.start()}}onTrajectoryMessage(r){if(!r.content)return;let l=r.content,{geometry:a,properties:{train_id:o,time_since_update:g,raw_coordinates:v}}=l;g<0||this.purgeTrajectory(l)||(this.debug&&this.mode===Ki.TOPOGRAPHIC&&v?l.properties.olGeometry=this.format.readGeometry({type:"Point",coordinates:yr(v,this.map.getView().getProjection())}):l.properties.olGeometry=this.format.readGeometry(a),l.properties.timeOffset=Date.now()-r.timestamp,this.addTrajectory(l))}onDeleteTrajectoryMessage(r){r.content&&this.removeTrajectory(r.content)}highlightVehicle(r){this.hoverVehicleId!==r&&(this.hoverVehicleId=r,this.renderTrajectories(!0))}selectVehicle(r){this.selectedVehicleId!==r&&(this.selectedVehicleId=r,this.renderTrajectories(!0))}}}var wp=gI;var yI=new zr({zIndex:2,image:new Rn({radius:5,fill:new Fr({color:"#000000"})}),stroke:new nr({color:"#000000",width:6})}),_I=(h,e,r)=>{let l="#ffffff",a=h.get("type"),o=h.get("stroke");return o&&o[0]!=="#"&&(o=`#${o}`),l=o||r?.getBgColor(a),l=/#ffffff/i.test(l)?"#ff0000":l,[yI,new zr({zIndex:3,image:new Rn({radius:4,fill:new Fr({color:l})}),stroke:new nr({color:l,width:4})})]},Sp=_I;var xI=new zr({zIndex:2,image:new Rn({radius:5,fill:new Fr({color:"#000000"})}),stroke:new nr({color:"#000000",width:6})}),vI=new zr({zIndex:3,image:new Rn({radius:4,fill:new Fr({color:"#a0a0a0"})}),stroke:new nr({color:"#a0a0a0",width:4})}),bI=()=>[xI,vI],Gb=bI;var jb=new Rn({radius:6,fill:new Fr({color:[255,0,0,1]}),stroke:new nr({color:[0,0,0,1],width:1})}),wI=new zr({stroke:new nr({color:[0,0,0,1],width:5})}),SI=new zr({image:jb,stroke:new nr({color:[255,0,0,1],width:3})}),CI=new zr({image:jb,stroke:new nr({color:[255,0,0,1],width:3,lineDash:[1,10]})}),II=(h,e)=>{let r=h.get("minResolution"),l=h.get("maxResolution"),a=e<=r&&e>l;return r&&l&&!a?[]:h.get("mot")!=="foot"?[wI,SI]:[CI]},Ub=II;var EI=new vr,gu=class extends mp{prepareFrame(){return!0}renderFrame(e){let{canvas:r,renderedViewState:l}=this.getLayer();if(this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),l){let{center:a,resolution:o,rotation:g}=e.viewState,{center:v,resolution:w,rotation:T}=l;if(w/o>=3)r?.getContext("2d")?.clearRect(0,0,r?.width,r?.height);else{let S=this.getLayer().getMapInternal()?.getPixelFromCoordinate(v),k=this.getLayer().getMapInternal().getPixelFromCoordinate(a);this.container.style.transform=G0(S[0]-k[0],S[1]-k[1],w/o,w/o,g-T,0,0)}}return this.container}getData(e){let r;try{let{pixelRatio:l}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(l||1),e[1]*(l||1),1,1).data||null,r}catch(l){console.error("error getting data",l)}return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,a){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(g=>{a(g,this.layer_,g.getGeometry())}),o?.[0]}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),o=l.getMapInternal().getView().getResolution(),g=10,v=bn([...e,...e],r*o),w=[],T=Object.values(l.trajectories||{});l.sort&&(T=T.sort(this.sort));let S=[];for(let k=0;k<T.length;k+=1){let F=T[k];if(F.properties.coordinate&&mo(v,F.properties.coordinate)&&S.push(T[k]),S.length===g)break}return w=S.map(k=>EI.readFeature(k)),w}};var TI=new vr,qy=class h extends wp(_c(xo)){constructor(r){super({source:new Po({}),...r});this.allowRenderWhenAnimating=!1;this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new Qa({updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0,source:new el({features:[]}),style:(l,a)=>(r.fullTrajectoryStyle||Sp)(l,a,this.styleOptions)}),this.renderState={center:[0,0],zoom:void 0,rotation:0},this.onZoomEndDebounced=(0,$y.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,$y.default)(this.onMoveEnd,100)}createRenderer(){return new gu(this)}attachToMap(r){if(super.attachToMap(r),this.map){this.visible&&this.start();let l=this.map.getLayers().getArray().indexOf(this);this.map.getLayers().insertAt(l,this.vectorLayer),this.olListenersKeys.push(...this.map.on(["moveend","change:target"],a=>{let o=(a.map||a.target).getView();if(o.getAnimating()||o.getInteracting())return;let g=o.getZoom();this.currentZoom!==g&&this.onZoomEndDebounced(a),this.currentZoom=g,this.onMoveEndDebounced(a)}),this.on("change:visible",a=>{a.target.visible?this.start():this.stop()}),this.on("propertychange",a=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(a.key)&&this.vectorLayer.set(a.key,a.target.get(a.key))}))}}detachFromMap(){this.map?.removeLayer(this.vectorLayer),super.detachFromMap()}renderTrajectories(r){if(!this.map)return;let l=this.map.getView();l.getCenter()&&super.renderTrajectories({size:this.map.getSize(),center:l.getCenter(),extent:l.calculateExtent(),resolution:l.getResolution(),rotation:l.getRotation(),zoom:l.getZoom(),pixelRatio:this.pixelRatio},r)}renderTrajectoriesInternal(r,l){if(!this.map)return!1;let a=!1;return a=(this.allowRenderWhenAnimating?!1:this.map.getView().getAnimating()||this.map.getView().getInteracting())?!1:super.renderTrajectoriesInternal(r,l),a&&(this.renderedViewState={...r},this.getRenderer().container&&(this.getRenderer().container.style.transform="")),a}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getView().getZoom())}onMoveEnd(r){!this.isUpdateBboxOnMoveEnd||!this.visible||this.setBbox()}onZoomEnd(){super.onZoomEnd(),!(!this.isUpdateBboxOnMoveEnd||!this.visible)&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}highlight(r){this.highlightVehicle(r?.get("train_id"))}select(r){this.selectVehicle(r?.get("train_id")),this.highlightTrajectory(r?.get("train_id"))}purgeTrajectory(r,l,a){let o=this.map.getView().getCenter();return!l&&!o?!1:super.purgeTrajectory(r,l||this.map.getView().calculateExtent(),a||this.map.getView().getZoom())}setBbox(r,l){super.setBbox(r||this.map.getView().calculateExtent(),l||this.map.getView().getZoom())}highlightTrajectory(r){return r?this.api.getFullTrajectory(r,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0))).then(l=>{let a=l.content;if(!a?.features?.length)return[];let o=TI.readFeatures(a);return this.vectorLayer.getSource().clear(!0),o.length&&this.vectorLayer.getSource().addFeatures(o),o}).catch(()=>(this.vectorLayer.getSource().clear(!0),[])):(this.vectorLayer.getSource().clear(!0),Promise.resolve([]))}clone(r){return new h({...this.options,...r})}},$b=qy;var MI=new vr,AI=(h,e,r)=>{let l,{coordinate:a,resolution:o,projection:g,params:v}=e;return h&&o&&g&&(l=h.getFeatureInfoUrl(a,o,g,{info_format:"application/json",query_layers:h.getParams().layers,...v})),fetch(l,{signal:r.signal}).then(w=>w.json()).then(w=>MI.readFeatures(w)).catch(()=>[])},yu={},PI=async(h,e,r=5)=>{Object.values(yu).forEach(o=>{o?.abort()}),yu={};let a=ja(e).map(o=>{let g=o.getMapInternal(),v=g?.getView()?.getProjection()?.getCode(),w={features:[],layer:o,coordinate:h};if(!v)return Promise.resolve(w);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(h);let T=o?.getSource();if(T?.getFeatureInfoUrl){let F=Gt(void 0);yu[F]?.abort(),yu[F]=new AbortController;let j=g?.getView()?.getResolution();return AI(T,{coordinate:h,resolution:j,projection:v,params:{info_format:"application/json",query_layers:T.getParams().layers}},yu[F]).then(J=>({features:J,layer:o,coordinate:h})).catch(()=>({features:[],layer:o,coordinate:h}))}let S=g?.getPixelFromCoordinate(h);if(!S)return Promise.resolve(w);let k=g?.getFeaturesAtPixel(S,{layerFilter:F=>F===o,hitTolerance:o.get("hitTolerance")||r||5});return Promise.resolve({features:k,layer:o,coordinate:h})});return Promise.all(a)},qb=PI;var Ap={};Of(Ap,{CopyrightControl:()=>Wb,Layer:()=>Ep,RealtimeAPI:()=>Ch,RealtimeLayer:()=>c1,RealtimeModes:()=>Ki,RoutingAPI:()=>bh,StopsAPI:()=>wh,VECTOR_TILE_FEATURE_PROPERTY:()=>ra,compareDepartures:()=>Zh,createCanvas:()=>xs,createRealtimeFilters:()=>Uf,debounceDeparturesMessages:()=>Lm,debounceWebsocketMessages:()=>Sh,getCircleCanvas:()=>Gm,getDelayBgCanvas:()=>Nm,getDelayTextCanvas:()=>Vm,getHoursAndMinutes:()=>O0,getLayersAsFlatArray:()=>ja,getMapGlCopyrights:()=>Ga,getMercatorResolution:()=>l1,getSourceCoordinates:()=>Mp,getTextCanvas:()=>jm,getUTCDateString:()=>F0,getUTCTimeString:()=>z0,getUrlWithParams:()=>Na,getVehiclePosition:()=>qh,pad:()=>Ed,realtimeConfig:()=>oc,realtimeDefaultStyle:()=>Ya,realtimeDelayStyle:()=>Um,realtimeSimpleStyle:()=>$m,removeDuplicate:()=>Va,renderTrajectories:()=>Wh,sortAndFilterDepartures:()=>Xh,sortByDelay:()=>$f});var RI=" | ",Wy=class{constructor(e={}){this.options=e}onAdd(e){return this.map=e,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}getDefaultPosition(){return"bottom-right"}render(){if(this.map&&this.container){let e=this.options?.separator||RI,r=this.options?.customAttribution||Ga(this.map),l=(Array.isArray(r)?r:[r]).join(e);this.container.innerHTML!==l&&(this.content=l,this.container.innerHTML=this.content)}}},Wb=Wy;var Ip,kI=new Uint8Array(16);function Zy(){if(!Ip&&(Ip=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ip))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ip(kI)}var Br=[];for(let h=0;h<256;++h)Br.push((h+256).toString(16).slice(1));function Zb(h,e=0){return Br[h[e+0]]+Br[h[e+1]]+Br[h[e+2]]+Br[h[e+3]]+"-"+Br[h[e+4]]+Br[h[e+5]]+"-"+Br[h[e+6]]+Br[h[e+7]]+"-"+Br[h[e+8]]+Br[h[e+9]]+"-"+Br[h[e+10]]+Br[h[e+11]]+Br[h[e+12]]+Br[h[e+13]]+Br[h[e+14]]+Br[h[e+15]]}var LI=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Xy={randomUUID:LI};function DI(h,e,r){if(Xy.randomUUID&&!e&&!h)return Xy.randomUUID();h=h||{};let l=h.random||(h.rng||Zy)();if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,e){r=r||0;for(let a=0;a<16;++a)e[r+a]=l[a];return e}return Zb(l)}var Hy=DI;var Xb=fo(Dy()),Yy=class extends Xb.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||Hy(),this.type="custom"}onAdd(r,l){this.map=r}onRemove(r,l){this.map=void 0}render(r){}},Ep=Yy;var or=63710088e-1,Hb={centimeters:or*100,centimetres:or*100,degrees:or/111325,feet:or*3.28084,inches:or*39.37,kilometers:or/1e3,kilometres:or/1e3,meters:or,metres:or,miles:or/1609.344,millimeters:or*1e3,millimetres:or*1e3,nauticalmiles:or/1852,radians:1,yards:or*1.0936},I4={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/or,yards:1.0936133};function Yb(h,e,r){r===void 0&&(r={});var l={type:"Feature"};return(r.id===0||r.id)&&(l.id=r.id),r.bbox&&(l.bbox=r.bbox),l.properties=e||{},l.geometry=h,l}function da(h,e,r){if(r===void 0&&(r={}),!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ky(h[0])||!Ky(h[1]))throw new Error("coordinates must contain numbers");var l={type:"Point",coordinates:h};return Yb(l,e,r)}function FI(h,e){e===void 0&&(e="kilometers");var r=Hb[e];if(!r)throw new Error(e+" units is invalid");return h*r}function zI(h,e){e===void 0&&(e="kilometers");var r=Hb[e];if(!r)throw new Error(e+" units is invalid");return h/r}function Kb(h){var e=h%(2*Math.PI);return e*180/Math.PI}function tl(h){var e=h%360;return e*Math.PI/180}function Tp(h,e,r){if(e===void 0&&(e="kilometers"),r===void 0&&(r="kilometers"),!(h>=0))throw new Error("length must be a positive number");return FI(zI(h,e),r)}function Ky(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function Jy(h){return!!h&&h.constructor===Object}function _u(h,e,r){if(h!==null)for(var l,a,o,g,v,w,T,S=0,k=0,F,j=h.type,J=j==="FeatureCollection",he=j==="Feature",q=J?h.features.length:1,Z=0;Z<q;Z++){T=J?h.features[Z].geometry:he?h.geometry:h,F=T?T.type==="GeometryCollection":!1,v=F?T.geometries.length:1;for(var ne=0;ne<v;ne++){var me=0,_e=0;if(g=F?T.geometries[ne]:T,g!==null){w=g.coordinates;var fe=g.type;switch(S=r&&(fe==="Polygon"||fe==="MultiPolygon")?1:0,fe){case null:break;case"Point":if(e(w,k,Z,me,_e)===!1)return!1;k++,me++;break;case"LineString":case"MultiPoint":for(l=0;l<w.length;l++){if(e(w[l],k,Z,me,_e)===!1)return!1;k++,fe==="MultiPoint"&&me++}fe==="LineString"&&me++;break;case"Polygon":case"MultiLineString":for(l=0;l<w.length;l++){for(a=0;a<w[l].length-S;a++){if(e(w[l][a],k,Z,me,_e)===!1)return!1;k++}fe==="MultiLineString"&&me++,fe==="Polygon"&&_e++}fe==="Polygon"&&me++;break;case"MultiPolygon":for(l=0;l<w.length;l++){for(_e=0,a=0;a<w[l].length;a++){for(o=0;o<w[l][a].length-S;o++){if(e(w[l][a][o],k,Z,me,_e)===!1)return!1;k++}_e++}me++}break;case"GeometryCollection":for(l=0;l<g.geometries.length;l++)if(_u(g.geometries[l],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function OI(h,e){e===void 0&&(e={});var r=0,l=0,a=0;return _u(h,function(o){r+=o[0],l+=o[1],a++},!0),da([r/a,l/a],e.properties)}var Jb=OI;function Xs(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return h.geometry.coordinates;if(h.type==="Point")return h.coordinates}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return h;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Qb(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function BI(h,e,r){r===void 0&&(r={});var l;r.final?l=e1(Xs(e),Xs(h)):l=e1(Xs(h),Xs(e));var a=l>180?-(360-l):l;return a}function e1(h,e){var r=tl(h[1]),l=tl(e[1]),a=tl(e[0]-h[0]);a>Math.PI&&(a-=2*Math.PI),a<-Math.PI&&(a+=2*Math.PI);var o=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),g=Math.atan2(a,o);return(Kb(g)+360)%360}var t1=BI;function NI(h,e,r){r===void 0&&(r={});var l=Xs(h),a=Xs(e);a[0]+=a[0]-l[0]>180?-360:l[0]-a[0]>180?360:0;var o=VI(l,a),g=Tp(o,"meters",r.units);return g}function VI(h,e,r){r=r===void 0?or:Number(r);var l=r,a=h[1]*Math.PI/180,o=e[1]*Math.PI/180,g=o-a,v=Math.abs(e[0]-h[0])*Math.PI/180;v>Math.PI&&(v-=2*Math.PI);var w=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),T=Math.abs(w)>1e-11?g/w:Math.cos(a),S=Math.sqrt(g*g+T*T*v*v),k=S*l;return k}var i1=NI;function GI(h,e,r,l){l===void 0&&(l={});var a=e<0,o=Tp(Math.abs(e),l.units,"meters");a&&(o=-Math.abs(o));var g=Xs(h),v=jI(g,o,r);return v[0]+=v[0]-g[0]>180?-360:g[0]-v[0]>180?360:0,da(v,l.properties)}function jI(h,e,r,l){l=l===void 0?or:Number(l);var a=e/l,o=h[0]*Math.PI/180,g=tl(h[1]),v=tl(r),w=a*Math.cos(v),T=g+w;Math.abs(T)>Math.PI/2&&(T=T>0?Math.PI-T:-Math.PI-T);var S=Math.log(Math.tan(T/2+Math.PI/4)/Math.tan(g/2+Math.PI/4)),k=Math.abs(S)>1e-11?w/S:Math.cos(g),F=a*Math.sin(v)/k,j=o+F;return[(j*180/Math.PI+540)%360-180,T*180/Math.PI]}var r1=GI;function UI(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return n1(h);case"FeatureCollection":return $I(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Qy(h);default:throw new Error("unknown GeoJSON type")}}function n1(h){var e={type:"Feature"};return Object.keys(h).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:e[r]=h[r]}}),e.properties=s1(h.properties),e.geometry=Qy(h.geometry),e}function s1(h){var e={};return h&&Object.keys(h).forEach(function(r){var l=h[r];typeof l=="object"?l===null?e[r]=null:Array.isArray(l)?e[r]=l.map(function(a){return a}):e[r]=s1(l):e[r]=l}),e}function $I(h){var e={type:"FeatureCollection"};return Object.keys(h).forEach(function(r){switch(r){case"type":case"features":return;default:e[r]=h[r]}}),e.features=h.features.map(function(r){return n1(r)}),e}function Qy(h){var e={type:h.type};return h.bbox&&(e.bbox=h.bbox),h.type==="GeometryCollection"?(e.geometries=h.geometries.map(function(r){return Qy(r)}),e):(e.coordinates=o1(h.coordinates),e)}function o1(h){var e=h;return typeof e[0]!="object"?e.slice():e.map(function(r){return o1(r)})}var a1=UI;function qI(h,e,r){if(r=r||{},!Jy(r))throw new Error("options is invalid");var l=r.pivot,a=r.mutate;if(!h)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");return e===0||(l||(l=Jb(h)),(a===!1||a===void 0)&&(h=a1(h)),_u(h,function(o){var g=t1(l,o),v=g+e,w=i1(l,o),T=Qb(r1(l,w,v));o[0]=T[0],o[1]=T[1]})),h}var e_=qI;var WI=(h,e=1)=>{let{width:r,height:l}=h.getCanvas(),a=h.unproject({x:0,y:0}),o=h.unproject({x:0,y:l/e}),g=h.unproject({x:r/e,y:l/e}),v=h.unproject({x:r/e,y:0});return[[a.lng,a.lat],[v.lng,v.lat],[g.lng,g.lat],[o.lng,o.lat]]},Mp=WI;var ZI=h=>{let e=h.getBounds().toArray(),r=yr(e[0]),l=yr(e[1]),a=[...r,...l],{width:o,height:g}=h.getCanvas(),v=$i(a)/o,w=ln(a)/g;return Math.max(v,w)},l1=ZI;var XI=h=>Rh(h.toArray().flat(),"EPSG:4326","EPSG:3857"),t_=XI;var i_=class extends wp(Ep){constructor(e={}){let r=document.createElement("canvas");super({canvas:r,...e}),this.source={id:this.id,type:"canvas",canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],animate:!0,attribution:e.attribution?.join(", "),loaded:!0},this.layer={id:`${this.id}-raster`,type:"raster",source:this.id,layout:{visibility:"visible"},paint:{"raster-opacity":1,"raster-fade-duration":0,"raster-resampling":"nearest"}},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}onAdd(e,r){super.onAdd(e,r),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onRemove(e,r){e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.id)&&e.removeSource(this.id),super.onRemove(e,r)}onLoad(){this.map.getSource(this.id)||this.map.addSource(this.id,this.source),this.map.getLayer(this.layer.id)||this.map.addLayer(this.layer,this.id),this.start()}start(){super.start(),this.map.on("move",this.onMove),this.map.on("moveend",this.onMoveEnd),this.map.on("zoomend",this.onZoomEnd)}stop(){super.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}renderTrajectories(e=!1){if(!this.map)return;this.pixelRatio||(this.pixelRatio=1);let{width:r,height:l}=this.map.getCanvas(),a=this.map.getCenter(),o=this.map.unproject({x:0,y:l/this.pixelRatio}),g=this.map.unproject({x:r/this.pixelRatio,y:0}),v=e_(da([o.lng,o.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,w=e_(da([g.lng,g.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,T=[...yr(v),...yr(w)],S=$i(T)/(r/this.pixelRatio),k=ln(T)/(l/this.pixelRatio),F=Math.max(S,k),j={size:[r/this.pixelRatio,l/this.pixelRatio],center:yr([a.lng,a.lat]),extent:T,resolution:F,zoom:this.map.getZoom()-1,rotation:-(this.map.getBearing()*Math.PI)/180,pixelRatio:this.pixelRatio};super.renderTrajectories(j,e)}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getZoom())}purgeTrajectory(e,r,l){return super.purgeTrajectory(e,r||t_(this.map.getBounds()),l||Math.floor(this.map.getZoom()-1))}setBbox(e,r){super.setBbox(e||t_(this.map.getBounds()),r||this.map.getZoom()-1)}renderTrajectoriesInternal(e,r=!1){let l=super.renderTrajectoriesInternal(e,r);if(l&&this.map.style){let a=Mp(this.map,this.pixelRatio),o=this.map.getSource(this.id);o&&o.setCoordinates(a)}return l}onMove(){this.renderTrajectories()}onMoveEnd(){this.renderTrajectories(),this.isUpdateBboxOnMoveEnd&&this.setBbox()}},c1=i_;var r_={ol:Cp,maplibre:Ap};typeof window<"u"&&(window.mbt=r_);var P6=r_;})();
585
+ `){At+=xt,xt=0,Ye=F*_e+Pe*j,++tt;continue}let Ft=J[ut+1]||w.font;Ft!==yt&&(a&&je.push("font",Ft),l&&Ke.push("font",Ft),yt=Ft),xt=Math.max(xt,ne[rt]);let Bt=[mt,Ye+Pe*Z[rt]+F*(Z[rt]-me[tt]),.5*(j+xt)+At];Ye+=Z[rt],a&&je.push("strokeText",Bt),l&&Ke.push("fillText",Bt),++rt}return Array.prototype.push.apply(fe,je),Array.prototype.push.apply(fe,Ke),this.labels_[o]=Re,Re}replayTextBackground_(e,r,l,a,o,g,v){e.beginPath(),e.moveTo.apply(e,r),e.lineTo.apply(e,l),e.lineTo.apply(e,a),e.lineTo.apply(e,o),e.lineTo.apply(e,r),g&&(this.alignAndScaleFill_=g[2],this.fill_(e)),v&&(this.setStrokeStyle_(e,v),e.stroke())}calculateImageOrLabelDimensions_(e,r,l,a,o,g,v,w,T,S,k,F,j,J,he,q){v*=F[0],w*=F[1];let Z=l-v,ne=a-w,me=o+T>e?e-T:o,_e=g+S>r?r-S:g,fe=J[3]+me*F[0]+J[1],ve=J[0]+_e*F[1]+J[2],Ee=Z-J[3],Re=ne-J[0];(he||k!==0)&&(ha[0]=Ee,ua[0]=Ee,ha[1]=Re,Mo[1]=Re,Mo[0]=Ee+fe,Ao[0]=Mo[0],Ao[1]=Re+ve,ua[1]=Ao[1]);let Pe;return k!==0?(Pe=an(mr(),l,a,1,1,k,-l,-a),rr(Pe,ha),rr(Pe,Mo),rr(Pe,Ao),rr(Pe,ua),yo(Math.min(ha[0],Mo[0],Ao[0],ua[0]),Math.min(ha[1],Mo[1],Ao[1],ua[1]),Math.max(ha[0],Mo[0],Ao[0],ua[0]),Math.max(ha[1],Mo[1],Ao[1],ua[1]),mc)):yo(Math.min(Ee,Ee+fe),Math.min(Re,Re+ve),Math.max(Ee,Ee+fe),Math.max(Re,Re+ve),mc),j&&(Z=Math.round(Z),ne=Math.round(ne)),{drawImageX:Z,drawImageY:ne,drawImageW:me,drawImageH:_e,originX:T,originY:S,declutterBox:{minX:mc[0],minY:mc[1],maxX:mc[2],maxY:mc[3],value:q},canvasTransform:Pe,scale:F}}replayImageOrLabel_(e,r,l,a,o,g,v){let w=!!(g||v),T=a.declutterBox,S=v?v[2]*a.scale[0]/2:0;return T.minX-S<=r[0]&&T.maxX+S>=0&&T.minY-S<=r[1]&&T.maxY+S>=0&&(w&&this.replayTextBackground_(e,ha,Mo,Ao,ua,g,v),yv(e,a.canvasTransform,o,l,a.originX,a.originY,a.drawImageW,a.drawImageH,a.drawImageX,a.drawImageY,a.scale)),!0}fill_(e){let r=this.alignAndScaleFill_;if(r){let l=rr(this.renderedTransform_,[0,0]),a=512*this.pixelRatio;e.save(),e.translate(l[0]%a,l[1]%a),r!==1&&e.scale(r,r),e.rotate(this.viewRotation_)}e.fill(),r&&e.restore()}setStrokeStyle_(e,r){e.strokeStyle=r[1],e.lineWidth=r[2],e.lineCap=r[3],e.lineJoin=r[4],e.miterLimit=r[5],e.lineDashOffset=r[7],e.setLineDash(r[6])}drawLabelWithPointPlacement_(e,r,l,a){let o=this.textStates[r],g=this.createLabel(e,r,a,l),v=this.strokeStates[l],w=this.pixelRatio,T=iy(Array.isArray(e)?e[0]:e,o.textAlign||aa),S=lu[o.textBaseline||Ja],k=v&&v.lineWidth?v.lineWidth:0,F=g.width/w-2*o.scale[0],j=T*F+2*(.5-T)*k,J=S*g.height/w+2*(.5-S)*k;return{label:g,anchorX:j,anchorY:J}}execute_(e,r,l,a,o,g,v,w){let T=this.zIndexContext_,S;this.pixelCoordinates_&&vn(l,this.renderedTransform_)?S=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),S=Cn(this.coordinates,0,this.coordinates.length,2,l,this.pixelCoordinates_),N0(this.renderedTransform_,l));let k=0,F=a.length,j=0,J,he,q,Z,ne,me,_e,fe,ve,Ee,Re,Pe,Ye,je=0,Ke=0,xt=null,At=null,rt=this.coordinateCache_,tt=this.viewRotation_,yt=Math.round(Math.atan2(-l[1],l[0])*1e12)/1e12,ut={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:tt},Mt=this.instructions!=a||this.overlaps?0:200,mt,Ft,Bt,Ei;for(;k<F;){let Ue=a[k];switch(Ue[0]){case gt.BEGIN_GEOMETRY:mt=Ue[1],Ei=Ue[3],mt.getGeometry()?v!==void 0&&!Qi(v,Ei.getExtent())?k=Ue[2]+1:++k:k=Ue[2],T&&(T.zIndex=Ue[4]);break;case gt.BEGIN_PATH:je>Mt&&(this.fill_(e),je=0),Ke>Mt&&(e.stroke(),Ke=0),!je&&!Ke&&(e.beginPath(),ne=NaN,me=NaN),++k;break;case gt.CIRCLE:j=Ue[1];let xi=S[j],Nr=S[j+1],ar=S[j+2],Ln=S[j+3],lr=ar-xi,un=Ln-Nr,dn=Math.sqrt(lr*lr+un*un);e.moveTo(xi+dn,Nr),e.arc(xi,Nr,dn,0,2*Math.PI,!0),++k;break;case gt.CLOSE_PATH:e.closePath(),++k;break;case gt.CUSTOM:j=Ue[1],J=Ue[2];let oi=Ue[3],Dn=Ue[4],Ie=Ue[5];ut.geometry=oi,ut.feature=mt,k in rt||(rt[k]=[]);let tr=rt[k];Ie?Ie(S,j,J,2,tr):(tr[0]=S[j],tr[1]=S[j+1],tr.length=2),T&&(T.zIndex=Ue[6]),Dn(tr,ut),++k;break;case gt.DRAW_IMAGE:j=Ue[1],J=Ue[2],ve=Ue[3],he=Ue[4],q=Ue[5];let Ti=Ue[6],Et=Ue[7],ci=Ue[8],Vr=Ue[9],Fn=Ue[10],pn=Ue[11],os=Ue[12],fn=Ue[13];Z=Ue[14]||"declutter";let Xn=Ue[15];if(!ve&&Ue.length>=20){Ee=Ue[19],Re=Ue[20],Pe=Ue[21],Ye=Ue[22];let ae=this.drawLabelWithPointPlacement_(Ee,Re,Pe,Ye);ve=ae.label,Ue[3]=ve;let de=Ue[23];he=(ae.anchorX-de)*this.pixelRatio,Ue[4]=he;let se=Ue[24];q=(ae.anchorY-se)*this.pixelRatio,Ue[5]=q,Ti=ve.height,Ue[6]=Ti,fn=ve.width,Ue[13]=fn}let zn;Ue.length>25&&(zn=Ue[25]);let Oe,br,Zi;Ue.length>17?(Oe=Ue[16],br=Ue[17],Zi=Ue[18]):(Oe=Co,br=!1,Zi=!1),Fn&&yt?pn+=tt:!Fn&&!yt&&(pn-=tt);let Hs=0;for(;j<J;j+=2){if(zn&&zn[Hs++]<fn/this.pixelRatio)continue;let ae=this.calculateImageOrLabelDimensions_(ve.width,ve.height,S[j],S[j+1],fn,Ti,he,q,ci,Vr,pn,os,o,Oe,br||Zi,mt),de=[e,r,ve,ae,Et,br?xt:null,Zi?At:null];if(w){let se,ge,Te;if(Xn){let qe=J-j;if(!Xn[qe]){Xn[qe]={args:de,declutterMode:Z};continue}let Qe=Xn[qe];se=Qe.args,ge=Qe.declutterMode,delete Xn[qe],Te=qv(se)}let Se,Ce;if(se&&(ge!=="declutter"||!w.collides(Te))&&(Se=!0),(Z!=="declutter"||!w.collides(ae.declutterBox))&&(Ce=!0),ge==="declutter"&&Z==="declutter"){let qe=Se&&Ce;Se=qe,Ce=qe}Se&&(ge!=="none"&&w.insert(Te),this.replayImageOrLabel_.apply(this,se)),Ce&&(Z!=="none"&&w.insert(ae.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++k;break;case gt.DRAW_CHARS:let Li=Ue[1],Ne=Ue[2],bt=Ue[3],wt=Ue[4];Ye=Ue[5];let gi=Ue[6],Jr=Ue[7],vt=Ue[8];Pe=Ue[9];let On=Ue[10];Ee=Ue[11],Re=Ue[12];let yi=[Ue[13],Ue[13]];Z=Ue[14]||"declutter";let Q=this.textStates[Re],O=Q.font,N=[Q.scale[0]*Jr,Q.scale[1]*Jr],$;O in this.widths_?$=this.widths_[O]:($={},this.widths_[O]=$);let H=Wd(S,Li,Ne,2),ce=Math.abs(N[0])*Cg(O,Ee,$);if(wt||ce<=H){let ae=this.textStates[Re].textAlign,de=(H-ce)*iy(Ee,ae),se=$v(S,Li,Ne,2,Ee,de,gi,Math.abs(N[0]),Cg,O,$,yt?0:this.viewRotation_);e:if(se){let ge=[],Te,Se,Ce,qe,Qe;if(Pe)for(Te=0,Se=se.length;Te<Se;++Te){Qe=se[Te],Ce=Qe[4],qe=this.createLabel(Ce,Re,"",Pe),he=Qe[2]+(N[0]<0?-On:On),q=bt*qe.height+(.5-bt)*2*On*N[1]/N[0]-vt;let dt=this.calculateImageOrLabelDimensions_(qe.width,qe.height,Qe[0],Qe[1],qe.width,qe.height,he,q,0,0,Qe[3],yi,!1,Co,!1,mt);if(w&&Z==="declutter"&&w.collides(dt.declutterBox))break e;ge.push([e,r,qe,dt,1,null,null])}if(Ye)for(Te=0,Se=se.length;Te<Se;++Te){Qe=se[Te],Ce=Qe[4],qe=this.createLabel(Ce,Re,Ye,""),he=Qe[2],q=bt*qe.height-vt;let dt=this.calculateImageOrLabelDimensions_(qe.width,qe.height,Qe[0],Qe[1],qe.width,qe.height,he,q,0,0,Qe[3],yi,!1,Co,!1,mt);if(w&&Z==="declutter"&&w.collides(dt.declutterBox))break e;ge.push([e,r,qe,dt,1,null,null])}w&&Z!=="none"&&w.load(ge.map(qv));for(let dt=0,_t=ge.length;dt<_t;++dt)this.replayImageOrLabel_.apply(this,ge[dt])}}++k;break;case gt.END_GEOMETRY:if(g!==void 0){mt=Ue[1];let ae=g(mt,Ei);if(ae)return ae}++k;break;case gt.FILL:Mt?je++:this.fill_(e),++k;break;case gt.MOVE_TO_LINE_TO:for(j=Ue[1],J=Ue[2],Ft=S[j],Bt=S[j+1],_e=Ft+.5|0,fe=Bt+.5|0,(_e!==ne||fe!==me)&&(e.moveTo(Ft,Bt),ne=_e,me=fe),j+=2;j<J;j+=2)Ft=S[j],Bt=S[j+1],_e=Ft+.5|0,fe=Bt+.5|0,(j==J-2||_e!==ne||fe!==me)&&(e.lineTo(Ft,Bt),ne=_e,me=fe);++k;break;case gt.SET_FILL_STYLE:xt=Ue,this.alignAndScaleFill_=Ue[2],je&&(this.fill_(e),je=0,Ke&&(e.stroke(),Ke=0)),e.fillStyle=Ue[1],++k;break;case gt.SET_STROKE_STYLE:At=Ue,Ke&&(e.stroke(),Ke=0),this.setStrokeStyle_(e,Ue),++k;break;case gt.STROKE:Mt?Ke++:e.stroke(),++k;break;default:++k;break}}je&&this.fill_(e),Ke&&e.stroke()}execute(e,r,l,a,o,g){this.viewRotation_=a,this.execute_(e,r,l,this.instructions,o,void 0,void 0,g)}executeHitDetection(e,r,l,a,o){return this.viewRotation_=l,this.execute_(e,[e.canvas.width,e.canvas.height],r,this.hitDetectionInstructions,!0,a,o)}},Zv=ry;var gc=["Polygon","Circle","LineString","Image","Text","Default"],oy=["Image","Text"],Xv=gc.filter(h=>!oy.includes(h)),sy=class{constructor(e,r,l,a,o,g,v){this.maxExtent_=e,this.overlaps_=a,this.pixelRatio_=l,this.resolution_=r,this.renderBuffer_=g,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=mr(),this.renderedContext_=null,this.deferredZIndexContexts_=[],this.createExecutors_(o,v)}clip(e,r){let l=this.getClipCoords(r);e.beginPath(),e.moveTo(l[0],l[1]),e.lineTo(l[2],l[3]),e.lineTo(l[4],l[5]),e.lineTo(l[6],l[7]),e.clip()}createExecutors_(e,r){for(let l in e){let a=this.executorsByZIndex_[l];a===void 0&&(a={},this.executorsByZIndex_[l]=a);let o=e[l];for(let g in o){let v=o[g];a[g]=new Zv(this.resolution_,this.pixelRatio_,this.overlaps_,v,r)}}}hasExecutors(e){for(let r in this.executorsByZIndex_){let l=this.executorsByZIndex_[r];for(let a=0,o=e.length;a<o;++a)if(e[a]in l)return!0}return!1}forEachFeatureAtCoordinate(e,r,l,a,o,g){a=Math.round(a);let v=a*2+1,w=an(this.hitDetectionTransform_,a+.5,a+.5,1/r,-1/r,-l,-e[0],-e[1]),T=!this.hitDetectionContext_;T&&(this.hitDetectionContext_=Wi(v,v,void 0,{willReadFrequently:!0}));let S=this.hitDetectionContext_;S.canvas.width!==v||S.canvas.height!==v?(S.canvas.width=v,S.canvas.height=v):T||S.clearRect(0,0,v,v);let k;this.renderBuffer_!==void 0&&(k=Sn(),Kf(k,e),bn(k,r*(this.renderBuffer_+a),k));let F=eC(a),j;function J(fe,ve){let Ee=S.getImageData(0,0,v,v).data;for(let Re=0,Pe=F.length;Re<Pe;Re++)if(Ee[F[Re]]>0){if(!g||j!=="Image"&&j!=="Text"||g.includes(fe)){let Ye=(F[Re]-3)/4,je=a-Ye%v,Ke=a-(Ye/v|0),xt=o(fe,ve,je*je+Ke*Ke);if(xt)return xt}S.clearRect(0,0,v,v);break}}let he=Object.keys(this.executorsByZIndex_).map(Number);he.sort(Ds);let q,Z,ne,me,_e;for(q=he.length-1;q>=0;--q){let fe=he[q].toString();for(ne=this.executorsByZIndex_[fe],Z=gc.length-1;Z>=0;--Z)if(j=gc[Z],me=ne[j],me!==void 0&&(_e=me.executeHitDetection(S,w,l,J,k),_e))return _e}}getClipCoords(e){let r=this.maxExtent_;if(!r)return null;let l=r[0],a=r[1],o=r[2],g=r[3],v=[l,a,l,g,o,g,o,a];return Cn(v,0,8,2,e,v),v}isEmpty(){return qn(this.executorsByZIndex_)}execute(e,r,l,a,o,g,v){let w=Object.keys(this.executorsByZIndex_).map(Number);w.sort(Ds),g=g||gc;let T,S,k,F,j,J;for(v&&w.reverse(),T=0,S=w.length;T<S;++T){let he=w[T].toString();for(j=this.executorsByZIndex_[he],k=0,F=g.length;k<F;++k){let q=g[k];if(J=j[q],J!==void 0){let Z=v===null?void 0:J.getZIndexContext(),ne=Z?Z.getContext():e,me=this.maxExtent_&&q!=="Image"&&q!=="Text";if(me&&(ne.save(),this.clip(ne,l)),J.execute(ne,r,l,a,o,v),me&&ne.restore(),Z){Z.offset();let _e=w[T];this.deferredZIndexContexts_[_e]||(this.deferredZIndexContexts_[_e]=[]),this.deferredZIndexContexts_[_e].push(Z)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){this.deferredZIndexContexts_.forEach(e=>{e.forEach(r=>{r.draw(this.renderedContext_),r.clear()})})}},ny={};function eC(h){if(ny[h]!==void 0)return ny[h];let e=h*2+1,r=h*h,l=new Array(r+1);for(let o=0;o<=h;++o)for(let g=0;g<=h;++g){let v=o*o+g*g;if(v>r)break;let w=l[v];w||(w=[],l[v]=w),w.push(((h+o)*e+(h+g))*4+3),o>0&&w.push(((h-o)*e+(h+g))*4+3),g>0&&(w.push(((h+o)*e+(h-g))*4+3),o>0&&w.push(((h-o)*e+(h-g))*4+3))}let a=[];for(let o=0,g=l.length;o<g;++o)l[o]&&a.push(...l[o]);return ny[h]=a,a}var Hv=sy;var ay=class extends pp{constructor(e,r,l,a,o,g,v){super(),this.context_=e,this.pixelRatio_=r,this.extent_=l,this.transform_=a,this.transformRotation_=a?cx(Math.atan2(a[1],a[0]),10):0,this.viewRotation_=o,this.squaredTolerance_=g,this.userTransform_=v,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=mr()}drawImages_(e,r,l,a){if(!this.image_)return;let o=Cn(e,r,l,a,this.transform_,this.pixelCoordinates_),g=this.context_,v=this.tmpLocalTransform_,w=g.globalAlpha;this.imageOpacity_!=1&&(g.globalAlpha=w*this.imageOpacity_);let T=this.imageRotation_;this.transformRotation_===0&&(T-=this.viewRotation_),this.imageRotateWithView_&&(T+=this.viewRotation_);for(let S=0,k=o.length;S<k;S+=2){let F=o[S]-this.imageAnchorX_,j=o[S+1]-this.imageAnchorY_;if(T!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let J=F+this.imageAnchorX_,he=j+this.imageAnchorY_;an(v,J,he,1,1,T,-J,-he),g.save(),g.transform.apply(g,v),g.translate(J,he),g.scale(this.imageScale_[0],this.imageScale_[1]),g.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),g.restore()}else g.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,F,j,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(g.globalAlpha=w)}drawText_(e,r,l,a){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let o=Cn(e,r,l,a,this.transform_,this.pixelCoordinates_),g=this.context_,v=this.textRotation_;for(this.transformRotation_===0&&(v-=this.viewRotation_),this.textRotateWithView_&&(v+=this.viewRotation_);r<l;r+=a){let w=o[r]+this.textOffsetX_,T=o[r+1]+this.textOffsetY_;v!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(g.save(),g.translate(w-this.textOffsetX_,T-this.textOffsetY_),g.rotate(v),g.translate(this.textOffsetX_,this.textOffsetY_),g.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&g.strokeText(this.text_,0,0),this.textFillState_&&g.fillText(this.text_,0,0),g.restore()):(this.textStrokeState_&&g.strokeText(this.text_,w,T),this.textFillState_&&g.fillText(this.text_,w,T))}}moveToLineTo_(e,r,l,a,o){let g=this.context_,v=Cn(e,r,l,a,this.transform_,this.pixelCoordinates_);g.moveTo(v[0],v[1]);let w=v.length;o&&(w-=2);for(let T=2;T<w;T+=2)g.lineTo(v[T],v[T+1]);return o&&g.closePath(),l}drawRings_(e,r,l,a){for(let o=0,g=l.length;o<g;++o)r=this.moveToLineTo_(e,r,l[o],a,!0);return r}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=Cx(e,this.transform_,this.pixelCoordinates_),l=r[2]-r[0],a=r[3]-r[1],o=Math.sqrt(l*l+a*a),g=this.context_;g.beginPath(),g.arc(r[0],r[1],o,0,2*Math.PI),this.fillState_&&g.fill(),this.strokeState_&&g.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,r){let l=r.getGeometryFunction()(e);l&&(this.setStyle(r),this.drawGeometry(l))}drawGeometryCollection(e){let r=e.getGeometriesArray();for(let l=0,a=r.length;l<a;++l)this.drawGeometry(r[l])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),l=e.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(l,0,l.length,e.getStride(),!1),r.stroke()}if(this.text_!==""){let r=e.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getExtent();if(Qi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let l=this.context_,a=e.getFlatCoordinates(),o=0,g=e.getEnds(),v=e.getStride();l.beginPath();for(let w=0,T=g.length;w<T;++w)o=this.moveToLineTo_(a,o,g[w],v,!1);l.stroke()}if(this.text_!==""){let l=e.getFlatMidpoints();this.drawText_(l,0,l.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=e.getOrientedFlatCoordinates(),a=0,o=e.getEndss(),g=e.getStride();r.beginPath();for(let v=0,w=o.length;v<w;++v){let T=o[v];a=this.drawRings_(l,a,T,g)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(e){let r=this.context_,l=this.contextFillState_;l?l.fillStyle!=e.fillStyle&&(l.fillStyle=e.fillStyle,r.fillStyle=e.fillStyle):(r.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let r=this.context_,l=this.contextStrokeState_;l?(l.lineCap!=e.lineCap&&(l.lineCap=e.lineCap,r.lineCap=e.lineCap),vn(l.lineDash,e.lineDash)||r.setLineDash(l.lineDash=e.lineDash),l.lineDashOffset!=e.lineDashOffset&&(l.lineDashOffset=e.lineDashOffset,r.lineDashOffset=e.lineDashOffset),l.lineJoin!=e.lineJoin&&(l.lineJoin=e.lineJoin,r.lineJoin=e.lineJoin),l.lineWidth!=e.lineWidth&&(l.lineWidth=e.lineWidth,r.lineWidth=e.lineWidth),l.miterLimit!=e.miterLimit&&(l.miterLimit=e.miterLimit,r.miterLimit=e.miterLimit),l.strokeStyle!=e.strokeStyle&&(l.strokeStyle=e.strokeStyle,r.strokeStyle=e.strokeStyle)):(r.lineCap=e.lineCap,r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset,r.lineJoin=e.lineJoin,r.lineWidth=e.lineWidth,r.miterLimit=e.miterLimit,r.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let r=this.context_,l=this.contextTextState_,a=e.textAlign?e.textAlign:aa;l?(l.font!=e.font&&(l.font=e.font,r.font=e.font),l.textAlign!=a&&(l.textAlign=a,r.textAlign=a),l.textBaseline!=e.textBaseline&&(l.textBaseline=e.textBaseline,r.textBaseline=e.textBaseline)):(r.font=e.font,r.textAlign=a,r.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:a,textBaseline:e.textBaseline})}setFillStrokeStyle(e,r){if(!e)this.fillState_=null;else{let l=e.getColor();this.fillState_={fillStyle:Mn(l||sr)}}if(!r)this.strokeState_=null;else{let l=r.getColor(),a=r.getLineCap(),o=r.getLineDash(),g=r.getLineDashOffset(),v=r.getLineJoin(),w=r.getWidth(),T=r.getMiterLimit(),S=o||An;this.strokeState_={lineCap:a!==void 0?a:Vs,lineDash:this.pixelRatio_===1?S:S.map(k=>k*this.pixelRatio_),lineDashOffset:(g||Pn)*this.pixelRatio_,lineJoin:v!==void 0?v:Gs,lineWidth:(w!==void 0?w:Io)*this.pixelRatio_,miterLimit:T!==void 0?T:wo,strokeStyle:Mn(l||So)}}}setImageStyle(e){let r;if(!e||!(r=e.getSize())){this.image_=null;return}let l=e.getPixelRatio(this.pixelRatio_),a=e.getAnchor(),o=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=a[0]*l,this.imageAnchorY_=a[1]*l,this.imageHeight_=r[1]*l,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=o[0],this.imageOriginY_=o[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let g=e.getScaleArray();this.imageScale_=[g[0]*this.pixelRatio_/l,g[1]*this.pixelRatio_/l],this.imageWidth_=r[0]*l}setTextStyle(e){if(!e)this.text_="";else{let r=e.getFill();if(!r)this.textFillState_=null;else{let j=r.getColor();this.textFillState_={fillStyle:Mn(j||sr)}}let l=e.getStroke();if(!l)this.textStrokeState_=null;else{let j=l.getColor(),J=l.getLineCap(),he=l.getLineDash(),q=l.getLineDashOffset(),Z=l.getLineJoin(),ne=l.getWidth(),me=l.getMiterLimit();this.textStrokeState_={lineCap:J!==void 0?J:Vs,lineDash:he||An,lineDashOffset:q||Pn,lineJoin:Z!==void 0?Z:Gs,lineWidth:ne!==void 0?ne:Io,miterLimit:me!==void 0?me:wo,strokeStyle:Mn(j||So)}}let a=e.getFont(),o=e.getOffsetX(),g=e.getOffsetY(),v=e.getRotateWithView(),w=e.getRotation(),T=e.getScaleArray(),S=e.getText(),k=e.getTextAlign(),F=e.getTextBaseline();this.textState_={font:a!==void 0?a:op,textAlign:k!==void 0?k:aa,textBaseline:F!==void 0?F:Ja},this.text_=S!==void 0?Array.isArray(S)?S.reduce((j,J,he)=>j+=he%2?" ":J,""):S:"",this.textOffsetX_=o!==void 0?this.pixelRatio_*o:0,this.textOffsetY_=g!==void 0?this.pixelRatio_*g:0,this.textRotateWithView_=v!==void 0?v:!1,this.textRotation_=w!==void 0?w:0,this.textScale_=[this.pixelRatio_*T[0],this.pixelRatio_*T[1]]}}},Yv=ay;var Cs=.5;function Kv(h,e,r,l,a,o,g,v,w){let T=w?zs(a,w):a,S=h[0]*Cs,k=h[1]*Cs,F=Wi(S,k);F.imageSmoothingEnabled=!1;let j=F.canvas,J=new Yv(F,Cs,a,null,g,v,w?rc(Wn(),w):null),he=r.length,q=Math.floor((256*256*256-1)/he),Z={};for(let me=1;me<=he;++me){let _e=r[me-1],fe=_e.getStyleFunction()||l;if(!fe)continue;let ve=fe(_e,o);if(!ve)continue;Array.isArray(ve)||(ve=[ve]);let Re=(me*q).toString(16).padStart(7,"#00000");for(let Pe=0,Ye=ve.length;Pe<Ye;++Pe){let je=ve[Pe],Ke=je.getGeometryFunction()(_e);if(!Ke||!Qi(T,Ke.getExtent()))continue;let xt=je.clone(),At=xt.getFill();At&&At.setColor(Re);let rt=xt.getStroke();rt&&(rt.setColor(Re),rt.setLineDash(null)),xt.setText(void 0);let tt=je.getImage();if(tt){let mt=tt.getImageSize();if(!mt)continue;let Ft=Wi(mt[0],mt[1],void 0,{alpha:!1}),Bt=Ft.canvas;Ft.fillStyle=Re,Ft.fillRect(0,0,Bt.width,Bt.height),xt.setImage(new Qh({img:Bt,anchor:tt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:tt.getOrigin(),opacity:1,size:tt.getSize(),scale:tt.getScale(),rotation:tt.getRotation(),rotateWithView:tt.getRotateWithView()}))}let yt=xt.getZIndex()||0,ut=Z[yt];ut||(ut={},Z[yt]=ut,ut.Polygon=[],ut.Circle=[],ut.LineString=[],ut.Point=[]);let Mt=Ke.getType();if(Mt==="GeometryCollection"){let mt=Ke.getGeometriesArrayRecursive();for(let Ft=0,Bt=mt.length;Ft<Bt;++Ft){let Ei=mt[Ft];ut[Ei.getType().replace("Multi","")].push(Ei,xt)}}else ut[Mt.replace("Multi","")].push(Ke,xt)}}let ne=Object.keys(Z).map(Number).sort(Ds);for(let me=0,_e=ne.length;me<_e;++me){let fe=Z[ne[me]];for(let ve in fe){let Ee=fe[ve];for(let Re=0,Pe=Ee.length;Re<Pe;Re+=2){J.setStyle(Ee[Re+1]);for(let Ye=0,je=e.length;Ye<je;++Ye)J.setTransform(e[Ye]),J.drawGeometry(Ee[Re])}}}return F.getImageData(0,0,j.width,j.height)}function Jv(h,e,r){let l=[];if(r){let a=Math.floor(Math.round(h[0])*Cs),o=Math.floor(Math.round(h[1])*Cs),g=(Ii(a,0,r.width-1)+Ii(o,0,r.height-1)*r.width)*4,v=r.data[g],w=r.data[g+1],S=r.data[g+2]+256*(w+256*v),k=Math.floor((256*256*256-1)/e.length);S&&S%k===0&&l.push(e[S/k-1])}return l}var tC=.5,Qv={Point:lC,LineString:sC,Polygon:hC,MultiPoint:cC,MultiLineString:oC,MultiPolygon:aC,GeometryCollection:nC,Circle:iC};function eb(h,e){return parseInt(Gt(h),10)-parseInt(Gt(e),10)}function ly(h,e){let r=cy(h,e);return r*r}function cy(h,e){return tC*h/e}function iC(h,e,r,l){let a=r.getFill(),o=r.getStroke();if(a||o){let v=h.getBuilder(r.getZIndex(),"Circle");v.setFillStrokeStyle(a,o),v.drawCircle(e,l)}let g=r.getText();if(g&&g.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(g),v.drawText(e,l)}}function hy(h,e,r,l,a,o,g,v){let w=[],T=r.getImage();if(T){let F=!0,j=T.getImageState();j==Tt.LOADED||j==Tt.ERROR?F=!1:j==Tt.IDLE&&T.load(),F&&w.push(T.ready())}let S=r.getFill();S&&S.loading()&&w.push(S.ready());let k=w.length>0;return k&&Promise.all(w).then(()=>a(null)),rC(h,e,r,l,o,g,v),k}function rC(h,e,r,l,a,o,g){let v=r.getGeometryFunction()(e);if(!v)return;let w=v.simplifyTransformed(l,a);if(r.getRenderer())tb(h,w,r,e,g);else{let S=Qv[w.getType()];S(h,w,r,e,g,o)}}function tb(h,e,r,l,a){if(e.getType()=="GeometryCollection"){let g=e.getGeometries();for(let v=0,w=g.length;v<w;++v)tb(h,g[v],r,l,a);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(e,l,r.getRenderer(),r.getHitDetectionRenderer(),a)}function nC(h,e,r,l,a,o){let g=e.getGeometriesArray(),v,w;for(v=0,w=g.length;v<w;++v){let T=Qv[g[v].getType()];T(h,g[v],r,l,a,o)}}function sC(h,e,r,l,a){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawLineString(e,l,a)}let g=r.getText();if(g&&g.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(g),v.drawText(e,l,a)}}function oC(h,e,r,l,a){let o=r.getStroke();if(o){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,o),v.drawMultiLineString(e,l,a)}let g=r.getText();if(g&&g.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(g),v.drawText(e,l,a)}}function aC(h,e,r,l,a){let o=r.getFill(),g=r.getStroke();if(g||o){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,g),w.drawMultiPolygon(e,l,a)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,a)}}function lC(h,e,r,l,a,o){let g=r.getImage(),v=r.getText(),w=v&&v.getText(),T=o&&g&&w?{}:void 0;if(g){if(g.getImageState()!=Tt.LOADED)return;let S=h.getBuilder(r.getZIndex(),"Image");S.setImageStyle(g,T),S.drawPoint(e,l,a)}if(w){let S=h.getBuilder(r.getZIndex(),"Text");S.setTextStyle(v,T),S.drawText(e,l,a)}}function cC(h,e,r,l,a,o){let g=r.getImage(),v=g&&g.getOpacity()!==0,w=r.getText(),T=w&&w.getText(),S=o&&v&&T?{}:void 0;if(v){if(g.getImageState()!=Tt.LOADED)return;let k=h.getBuilder(r.getZIndex(),"Image");k.setImageStyle(g,S),k.drawMultiPoint(e,l,a)}if(T){let k=h.getBuilder(r.getZIndex(),"Text");k.setTextStyle(w,S),k.drawText(e,l,a)}}function hC(h,e,r,l,a){let o=r.getFill(),g=r.getStroke();if(o||g){let w=h.getBuilder(r.getZIndex(),"Polygon");w.setFillStrokeStyle(o,g),w.drawPolygon(e,l,a)}let v=r.getText();if(v&&v.getText()){let w=h.getBuilder(r.getZIndex(),"Text");w.setTextStyle(v),w.drawText(e,l,a)}}var uy=class extends mp{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=Sn(),this.wrappedRenderedExtent_=Sn(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.compositionContext_=null,this.opacity_=1}renderWorlds(e,r,l){let a=r.extent,o=r.viewState,g=o.center,v=o.resolution,w=o.projection,T=o.rotation,S=w.getExtent(),k=this.getLayer().getSource(),F=this.getLayer().getDeclutter(),j=r.pixelRatio,J=r.viewHints,he=!(J[En.ANIMATING]||J[En.INTERACTING]),q=this.compositionContext_,Z=Math.round(r.size[0]*j),ne=Math.round(r.size[1]*j),me=k.getWrapX()&&w.canWrapX(),_e=me?$i(S):null,fe=me?Math.ceil((a[2]-S[2])/_e)+1:1,ve=me?Math.floor((a[0]-S[0])/_e):0;do{let Ee=this.getRenderTransform(g,v,T,j,Z,ne,ve*_e);e.execute(q,[q.canvas.width,q.canvas.height],Ee,T,he,l===void 0?gc:l?oy:Xv,l?F&&r.declutter[F]:void 0)}while(++ve<fe)}setupCompositionContext_(){if(this.opacity_!==1){let e=Wi(this.context.canvas.width,this.context.canvas.height,ty);this.compositionContext_=e}else this.compositionContext_=this.context}releaseCompositionContext_(){if(this.opacity_!==1){let e=this.context.globalAlpha;this.context.globalAlpha=this.opacity_,this.context.drawImage(this.compositionContext_.canvas,0,0),this.context.globalAlpha=e,Jx(this.compositionContext_),ty.push(this.compositionContext_.canvas),this.compositionContext_=null}}renderDeclutter(e){this.getLayer().getDeclutter()&&(this.setupCompositionContext_(),this.renderWorlds(this.replayGroup_,e,!0),this.releaseCompositionContext_())}renderDeferredInternal(e){this.replayGroup_.renderDeferred()}renderFrame(e,r){let l=e.pixelRatio,a=e.layerStatesArray[e.layerIndex];V0(this.pixelTransform,1/l,1/l),j0(this.inversePixelTransform,this.pixelTransform);let o=qf(this.pixelTransform);this.useContainer(r,o,this.getBackground(e));let g=this.context,v=g.canvas,w=this.replayGroup_,T=w&&!w.isEmpty();if(!T&&!(this.getLayer().hasListener(Bs.PRERENDER)||this.getLayer().hasListener(Bs.POSTRENDER)))return null;let S=Math.round(e.size[0]*l),k=Math.round(e.size[1]*l);v.width!=S||v.height!=k?(v.width=S,v.height=k,v.style.transform!==o&&(v.style.transform=o)):this.containerReused||g.clearRect(0,0,S,k),this.preRender(g,e);let F=e.viewState,j=F.projection;this.opacity_=a.opacity,this.setupCompositionContext_();let J=!1;if(T&&a.extent&&this.clipping){let he=Os(a.extent,j);T=Qi(he,e.extent),J=T&&!go(he,e.extent),J&&this.clipUnrotated(this.compositionContext_,e,he)}return T&&this.renderWorlds(w,e,this.getLayer().getDeclutter()?!1:void 0),J&&this.compositionContext_.restore(),this.releaseCompositionContext_(),this.postRender(g,e),this.renderedRotation_!==F.rotation&&(this.renderedRotation_=F.rotation,this.hitDetectionImageData_=null),this.container}getFeatures(e){return new Promise(r=>{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let l=[this.context.canvas.width,this.context.canvas.height];rr(this.pixelTransform,l);let a=this.renderedCenter_,o=this.renderedResolution_,g=this.renderedRotation_,v=this.renderedProjection_,w=this.wrappedRenderedExtent_,T=this.getLayer(),S=[],k=l[0]*Cs,F=l[1]*Cs;S.push(this.getRenderTransform(a,o,g,Cs,k,F,0).slice());let j=T.getSource(),J=v.getExtent();if(j.getWrapX()&&v.canWrapX()&&!go(J,w)){let q=w[0],Z=$i(J),ne=0,me;for(;q<J[0];)--ne,me=Z*ne,S.push(this.getRenderTransform(a,o,g,Cs,k,F,me).slice()),q+=Z;for(ne=0,q=w[2];q>J[2];)++ne,me=Z*ne,S.push(this.getRenderTransform(a,o,g,Cs,k,F,me).slice()),q-=Z}let he=Wn();this.hitDetectionImageData_=Kv(l,S,this.renderedFeatures_,T.getStyleFunction(),w,o,g,ly(o,this.renderedPixelRatio_),he?v:null)}r(Jv(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,r,l,a,o){if(!this.replayGroup_)return;let g=r.viewState.resolution,v=r.viewState.rotation,w=this.getLayer(),T={},S=function(J,he,q){let Z=Gt(J),ne=T[Z];if(ne){if(ne!==!0&&q<ne.distanceSq){if(q===0)return T[Z]=!0,o.splice(o.lastIndexOf(ne),1),a(J,w,he);ne.geometry=he,ne.distanceSq=q}}else{if(q===0)return T[Z]=!0,a(J,w,he);o.push(T[Z]={feature:J,layer:w,geometry:he,distanceSq:q,callback:a})}},k,F=[this.replayGroup_],j=this.getLayer().getDeclutter();return F.some(J=>k=J.forEachFeatureAtCoordinate(e,g,v,l,S,j&&r.declutter[j]?r.declutter[j].all().map(he=>he.value):null)),k}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let r=this.getLayer(),l=r.getSource();if(!l)return!1;let a=e.viewHints[En.ANIMATING],o=e.viewHints[En.INTERACTING],g=r.getUpdateWhileAnimating(),v=r.getUpdateWhileInteracting();if(this.ready&&!g&&a||!v&&o)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let w=e.extent,T=e.viewState,S=T.projection,k=T.resolution,F=e.pixelRatio,j=r.getRevision(),J=r.getRenderBuffer(),he=r.getRenderOrder();he===void 0&&(he=eb);let q=T.center.slice(),Z=bn(w,J*k),ne=Z.slice(),me=[Z.slice()],_e=S.getExtent();if(l.getWrapX()&&S.canWrapX()&&!go(_e,e.extent)){let rt=$i(_e),tt=Math.max($i(Z)/2,rt);Z[0]=_e[0]-tt,Z[2]=_e[2]+tt,px(q,S);let yt=rm(me[0],S);yt[0]<_e[0]&&yt[2]<_e[2]?me.push([yt[0]+rt,yt[1],yt[2]+rt,yt[3]]):yt[0]>_e[0]&&yt[2]>_e[2]&&me.push([yt[0]-rt,yt[1],yt[2]-rt,yt[3]])}if(this.ready&&this.renderedResolution_==k&&this.renderedRevision_==j&&this.renderedRenderOrder_==he&&go(this.wrappedRenderedExtent_,Z))return vn(this.renderedExtent_,ne)||(this.hitDetectionImageData_=null,this.renderedExtent_=ne),this.renderedCenter_=q,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let fe=new jv(cy(k,F),Z,k,F),ve=Wn(),Ee;if(ve){for(let rt=0,tt=me.length;rt<tt;++rt){let yt=me[rt],ut=zs(yt,S);l.loadFeatures(ut,xx(k,S),ve)}Ee=rc(ve,S)}else for(let rt=0,tt=me.length;rt<tt;++rt)l.loadFeatures(me[rt],k,S);let Re=ly(k,F),Pe=!0,Ye=(rt,tt)=>{let yt,ut=rt.getStyleFunction()||r.getStyleFunction();if(ut&&(yt=ut(rt,k)),yt){let Mt=this.renderFeature(rt,Re,yt,fe,Ee,this.getLayer().getDeclutter(),tt);Pe=Pe&&!Mt}},je=zs(Z,S),Ke=l.getFeaturesInExtent(je);he&&Ke.sort(he);for(let rt=0,tt=Ke.length;rt<tt;++rt)Ye(Ke[rt],rt);this.renderedFeatures_=Ke,this.ready=Pe;let xt=fe.finish(),At=new Hv(Z,k,F,l.getOverlaps(),xt,r.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=k,this.renderedRevision_=j,this.renderedRenderOrder_=he,this.renderedExtent_=ne,this.wrappedRenderedExtent_=Z,this.renderedCenter_=q,this.renderedProjection_=S,this.renderedPixelRatio_=F,this.replayGroup_=At,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,r,l,a,o,g,v){if(!l)return!1;let w=!1;if(Array.isArray(l))for(let T=0,S=l.length;T<S;++T)w=hy(a,e,l[T],r,this.boundHandleStyleImageChange_,o,g,v)||w;else w=hy(a,e,l,r,this.boundHandleStyleImageChange_,o,g,v);return w}},ib=uy;var dy=class extends zv{constructor(e){super(e)}createRenderer(){return new ib(this)}},Qa=dy;var rb=fo(Rg(),1);var py=class{constructor(e){this.rbush_=new rb.default(e),this.items_={}}insert(e,r){let l={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:r};this.rbush_.insert(l),this.items_[Gt(r)]=l}load(e,r){let l=new Array(r.length);for(let a=0,o=r.length;a<o;a++){let g=e[a],v=r[a],w={minX:g[0],minY:g[1],maxX:g[2],maxY:g[3],value:v};l[a]=w,this.items_[Gt(v)]=w}this.rbush_.load(l)}remove(e){let r=Gt(e),l=this.items_[r];return delete this.items_[r],this.rbush_.remove(l)!==null}update(e,r){let l=this.items_[Gt(r)],a=[l.minX,l.minY,l.maxX,l.maxY];Fd(a,e)||(this.remove(r),this.insert(e,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(e){let r={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(r).map(function(a){return a.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,r){return this.forEach_(this.getInExtent(e),r)}forEach_(e,r){let l;for(let a=0,o=e.length;a<o;a++)if(l=r(e[a]),l)return l;return l}isEmpty(){return qn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let r=this.rbush_.toJSON();return yo(r.minX,r.minY,r.maxX,r.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let r in e.items_)this.items_[r]=e.items_[r]}},cu=py;var nb=mr(),hu=class h{constructor(e,r,l,a,o,g){this.styleFunction,this.extent_,this.id_=g,this.type_=e,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=l||null,this.properties_=o,this.squaredTolerance_,this.stride_=a,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?Yo(this.flatCoordinates_):Ql(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=es(this.getExtent());this.flatInteriorPoints_=Gh(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=Ox(this.flatCoordinates_,this.ends_),r=Hd(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Zd(this.flatCoordinates_,0,e,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=Ha(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,r=0,l=this.ends_;for(let a=0,o=l.length;a<o;++a){let g=l[a],v=Ha(e,r,g,2,.5);kr(this.flatMidpoints_,v),r=g}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=qi(e);let r=e.getExtent(),l=e.getWorldExtent();if(r&&l){let a=ln(l)/ln(r);an(nb,l[0],l[3],a,-a,0,0,0),Cn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,nb,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Pd((e,r)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let l=this.simplifiedGeometry_.getFlatCoordinates(),a;switch(this.type_){case"LineString":l.length=Xa(l,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,l,0),a=[l.length];break;case"MultiLineString":a=[],l.length=Ud(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,l,0,a);break;case"Polygon":a=[],l.length=zh(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),l,0,a);break;default:}return a&&(this.simplifiedGeometry_=new h(this.type_,l,a,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};hu.prototype.getFlatCoordinates=hu.prototype.getOrientedFlatCoordinates;var ss=hu;var fy=class extends gr{constructor(e){super(),this.projection=qi(e.projection),this.attributions_=sb(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?e.attributionsCollapsible:!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(l,a){r.viewResolver=l,r.viewRejector=a})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=sb(e),this.changed()}setState(e){this.state_=e,this.changed()}};function sb(h){return h?Array.isArray(h)?function(e){return h}:typeof h=="function"?h:function(e){return[h]}:null}var Po=fy;var hn={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function ob(h,e){return[[-1/0,-1/0,1/0,1/0]]}var uC=!1;function dC(h,e,r,l,a,o,g){let v=new XMLHttpRequest;v.open("GET",typeof h=="function"?h(r,l,a):h,!0),e.getType()=="arraybuffer"&&(v.responseType="arraybuffer"),v.withCredentials=uC,v.onload=function(w){if(!v.status||v.status>=200&&v.status<300){let T=e.getType(),S;T=="json"?S=JSON.parse(v.responseText):T=="text"?S=v.responseText:T=="xml"?(S=v.responseXML,S||(S=new DOMParser().parseFromString(v.responseText,"application/xml"))):T=="arraybuffer"&&(S=v.response),S?o(e.readFeatures(S,{extent:r,featureProjection:a}),e.readProjection(S)):g()}else g()},v.onerror=g,v.send()}function my(h,e){return function(r,l,a,o,g){let v=this;dC(h,e,r,l,a,function(w,T){v.addFeatures(w),o!==void 0&&o(w)},g||ms)}}var Zs=class extends mi{constructor(e,r,l){super(e),this.feature=r,this.features=l}},gy=class extends Po{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=ms,this.format_=e.format,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(si(this.format_,"`format` must be set when `url` is set"),this.loader_=my(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:ob;let r=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=r?new cu:null,this.loadedExtentsRtree_=new cu,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let l,a;Array.isArray(e.features)?a=e.features:e.features&&(l=e.features,a=l.getArray()),!r&&l===void 0&&(l=new Yh(a)),a!==void 0&&this.addFeaturesInternal(a),l!==void 0&&this.bindFeaturesCollection_(l)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let r=Gt(e);if(!this.addToIndex_(r,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(r,e);let l=e.getGeometry();if(l){let a=l.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(a,e)}else this.nullGeometryFeatures_[r]=e;this.dispatchEvent(new Zs(hn.ADDFEATURE,e))}setupChangeEvents_(e,r){r instanceof ss||(this.featureChangeKeys_[e]=[Lr(r,li.CHANGE,this.handleFeatureChange_,this),Lr(r,Td.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,r){let l=!0;if(r.getId()!==void 0){let a=String(r.getId());if(!(a in this.idIndex_))this.idIndex_[a]=r;else if(r instanceof ss){let o=this.idIndex_[a];o instanceof ss?Array.isArray(o)?o.push(r):this.idIndex_[a]=[o,r]:l=!1}else l=!1}return l&&(si(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=r),l}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let r=[],l=[],a=[];for(let o=0,g=e.length;o<g;o++){let v=e[o],w=Gt(v);this.addToIndex_(w,v)&&l.push(v)}for(let o=0,g=l.length;o<g;o++){let v=l[o],w=Gt(v);this.setupChangeEvents_(w,v);let T=v.getGeometry();if(T){let S=T.getExtent();r.push(S),a.push(v)}else this.nullGeometryFeatures_[w]=v}if(this.featuresRtree_&&this.featuresRtree_.load(r,a),this.hasListener(hn.ADDFEATURE))for(let o=0,g=l.length;o<g;o++)this.dispatchEvent(new Zs(hn.ADDFEATURE,l[o]))}bindFeaturesCollection_(e){let r=!1;this.addEventListener(hn.ADDFEATURE,function(l){r||(r=!0,e.push(l.feature),r=!1)}),this.addEventListener(hn.REMOVEFEATURE,function(l){r||(r=!0,e.remove(l.feature),r=!1)}),e.addEventListener(bs.ADD,l=>{r||(r=!0,this.addFeature(l.element),r=!1)}),e.addEventListener(bs.REMOVE,l=>{r||(r=!0,this.removeFeature(l.element),r=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let l in this.featureChangeKeys_)this.featureChangeKeys_[l].forEach(Yr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){let l=a=>{this.removeFeatureInternal(a)};this.featuresRtree_.forEach(l);for(let a in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[a])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Zs(hn.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,r){let l=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(l,function(a){let o=a.getGeometry();if(o instanceof ss||o.intersectsCoordinate(e))return r(a)})}forEachFeatureInExtent(e,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(e,r){return this.forEachFeatureInExtent(e,function(l){let a=l.getGeometry();if(a instanceof ss||a.intersectsExtent(e)){let o=r(l);if(o)return o}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),qn(this.nullGeometryFeatures_)||kr(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let r=[];return this.forEachFeatureAtCoordinateDirect(e,function(l){r.push(l)}),r}getFeaturesInExtent(e,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let a=Q0(e,r);return[].concat(...a.map(o=>this.featuresRtree_.getInExtent(o)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,r){let l=e[0],a=e[1],o=null,g=[NaN,NaN],v=1/0,w=[-1/0,-1/0,1/0,1/0];return r=r||Ad,this.featuresRtree_.forEachInExtent(w,function(T){if(r(T)){let S=T.getGeometry(),k=v;if(v=S instanceof ss?0:S.closestPointXY(l,a,g,v),v<k){o=T;let F=Math.sqrt(v);w[0]=l-F,w[1]=a-F,w[2]=l+F,w[3]=a+F}}}),o}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let r=this.idIndex_[e.toString()];return r!==void 0?r:null}getFeatureByUid(e){let r=this.uidIndex_[e];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let r=e.target,l=Gt(r),a=r.getGeometry();if(!a)l in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[l]=r);else{let g=a.getExtent();l in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[l],this.featuresRtree_&&this.featuresRtree_.insert(g,r)):this.featuresRtree_&&this.featuresRtree_.update(g,r)}let o=r.getId();if(o!==void 0){let g=o.toString();this.idIndex_[g]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[g]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[l]=r;this.changed(),this.dispatchEvent(new Zs(hn.CHANGEFEATURE,r))}hasFeature(e){let r=e.getId();return r!==void 0?r in this.idIndex_:Gt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&qn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,r,l){let a=this.loadedExtentsRtree_,o=this.strategy_(e,r,l);for(let g=0,v=o.length;g<v;++g){let w=o[g];a.forEachInExtent(w,function(S){return go(S.extent,w)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Zs(hn.FEATURESLOADSTART)),this.loader_.call(this,w,r,l,S=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(hn.FEATURESLOADEND,void 0,S))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Zs(hn.FEATURESLOADERROR))}),a.insert(w,{extent:w.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let r=this.loadedExtentsRtree_,l;r.forEachInExtent(e,function(a){if(Fd(a.extent,e))return l=a,!0}),l&&r.remove(l)}removeFeature(e){if(!e)return;let r=Gt(e);r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let r=Gt(e),l=this.featureChangeKeys_[r];if(!l)return;l.forEach(Yr),delete this.featureChangeKeys_[r];let a=e.getId();return a!==void 0&&delete this.idIndex_[a.toString()],delete this.uidIndex_[r],this.dispatchEvent(new Zs(hn.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let r=!1;for(let l in this.idIndex_){let a=this.idIndex_[l];if(e instanceof ss&&Array.isArray(a)&&a.includes(e))a.splice(a.indexOf(e),1);else if(this.idIndex_[l]===e){delete this.idIndex_[l],r=!0;break}}return r}setLoader(e){this.loader_=e}setUrl(e){si(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(my(e,this.format_))}},el=gy;var Zn={SINGLECLICK:"singleclick",CLICK:li.CLICK,DBLCLICK:li.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var yy={ACTIVE:"active"};var _y=class extends gr{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(yy.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(yy.ACTIVE,e)}setMap(e){this.map_=e}};var ab=_y;var xy=class extends ab{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==Zn.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==Zn.POINTERUP){let l=this.handleUpEvent(e);this.handlingDownUpSequence=l&&this.targetPointers.length>0}}else if(e.type==Zn.POINTERDOWN){let l=this.handleDownEvent(e);this.handlingDownUpSequence=l,r=this.stopDown(l)}else e.type==Zn.POINTERMOVE&&this.handleMoveEvent(e);return!r}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var lb=xy;var cb=function(h){let e=h.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var hb=Ad,ub=function(h){return h.type==Zn.CLICK};var db=function(h){return h.type==Zn.SINGLECLICK};var pb=function(h){let e=h.originalEvent;return si(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var fb=0,uu=1,mb=[0,0,0,0],yc=[],vy={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},du=class extends mi{constructor(e,r,l){super(e),this.features=r,this.mapBrowserEvent=l}},by=class extends lb{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:pb,this.defaultDeleteCondition_=function(l){return cb(l)&&db(l)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:hb,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new cu,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Qa({source:new el({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:fC(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(e.features?r=e.features:e.source&&(this.source_=e.source,r=new Yh(this.source_.getFeatures()),this.source_.addEventListener(hn.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(hn.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(bs.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(bs.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let r=e.getGeometry();if(r){let a=this.SEGMENT_WRITERS_[r.getType()];a&&a(e,r)}let l=this.getMap();l&&l.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(this.lastPixel_,l),e.addEventListener(li.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Yh;let l=this.featuresBeingModified_.getArray();for(let a=0,o=r.length;a<o;++a){let g=r[a];for(let v=0,w=g.length;v<w;++v){let T=g[v].feature;T&&!l.includes(T)&&this.featuresBeingModified_.push(T)}}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new du(vy.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(li.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let r=this.rBush_,l=[];r.forEach(function(a){e===a.feature&&l.push(a)});for(let a=l.length-1;a>=0;--a){let o=l[a];for(let g=this.dragSegments_.length-1;g>=0;--g)this.dragSegments_[g][0]===o&&this.dragSegments_.splice(g,1);r.remove(o)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let r=e.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,r){let l=r.getCoordinates(),a={feature:e,geometry:r,segment:[l,l]};this.rBush_.insert(r.getExtent(),a)}writeMultiPointGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a],v={feature:e,geometry:r,depth:[a],index:a,segment:[g,g]};this.rBush_.insert(r.getExtent(),v)}}writeLineStringGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length-1;a<o;++a){let g=l.slice(a,a+2),v={feature:e,geometry:r,index:a,segment:g};this.rBush_.insert(Fs(g),v)}}writeMultiLineStringGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a];for(let v=0,w=g.length-1;v<w;++v){let T=g.slice(v,v+2),S={feature:e,geometry:r,depth:[a],index:v,segment:T};this.rBush_.insert(Fs(T),S)}}}writePolygonGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a];for(let v=0,w=g.length-1;v<w;++v){let T=g.slice(v,v+2),S={feature:e,geometry:r,depth:[a],index:v,segment:T};this.rBush_.insert(Fs(T),S)}}}writeMultiPolygonGeometry_(e,r){let l=r.getCoordinates();for(let a=0,o=l.length;a<o;++a){let g=l[a];for(let v=0,w=g.length;v<w;++v){let T=g[v];for(let S=0,k=T.length-1;S<k;++S){let F=T.slice(S,S+2),j={feature:e,geometry:r,depth:[v,a],index:S,segment:F};this.rBush_.insert(Fs(F),j)}}}}writeCircleGeometry_(e,r){let l=r.getCenter(),a={feature:e,geometry:r,index:fb,segment:[l,l]},o={feature:e,geometry:r,index:uu,segment:[l,l]},g=[a,o];a.featureSegments=g,o.featureSegments=g,this.rBush_.insert(Yo(l),a);let v=r,w=Wn();if(w&&this.getMap()){let T=this.getMap().getView().getProjection();v=v.clone().transform(w,T),v=Pm(v).transform(T,w)}this.rBush_.insert(v.getExtent(),o)}writeGeometryCollectionGeometry_(e,r){let l=r.getGeometriesArray();for(let a=0;a<l.length;++a){let o=l[a],g=this.SEGMENT_WRITERS_[o.getType()];g(e,o)}}createOrUpdateVertexFeature_(e,r,l){let a=this.vertexFeature_;return a?a.getGeometry().setCoordinates(e):(a=new rs(new _r(e)),this.vertexFeature_=a,this.overlay_.getSource().addFeature(a)),a.set("features",r),a.set("geometries",l),a}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let r;return!e.map.getView().getInteracting()&&e.type==Zn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=Zn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),e.type==Zn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!r}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_);let r=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],l=[],a=[];for(let o=0,g=this.dragSegments_.length;o<g;++o){let v=this.dragSegments_[o],w=v[0],T=w.feature;l.includes(T)||l.push(T);let S=w.geometry;a.includes(S)||a.push(S);let k=w.depth,F,j=w.segment,J=v[1];for(;r.length<S.getStride();)r.push(j[J][r.length]);switch(S.getType()){case"Point":F=r,j[0]=r,j[1]=r;break;case"MultiPoint":F=S.getCoordinates(),F[w.index]=r,j[0]=r,j[1]=r;break;case"LineString":F=S.getCoordinates(),F[w.index+J]=r,j[J]=r;break;case"MultiLineString":F=S.getCoordinates(),F[k[0]][w.index+J]=r,j[J]=r;break;case"Polygon":F=S.getCoordinates(),F[k[0]][w.index+J]=r,j[J]=r;break;case"MultiPolygon":F=S.getCoordinates(),F[k[1]][k[0]][w.index+J]=r,j[J]=r;break;case"Circle":if(j[0]=r,j[1]=r,w.index===fb)this.changingFeature_=!0,S.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let he=e.map.getView().getProjection(),q=cm(er(S.getCenter(),he),er(r,he)),Z=Wn();if(Z){let ne=S.clone().transform(Z,he);ne.setRadius(q),q=ne.transform(he,Z).getRadius()}S.setRadius(q),this.changingFeature_=!1}break;default:}F&&this.setGeometryCoordinates_(S,F)}this.createOrUpdateVertexFeature_(r,l,a)}handleDownEvent(e){if(!this.condition_(e))return!1;let r=e.coordinate;this.handlePointerAtPixel_(e.pixel,e.map,r),this.dragSegments_.length=0,this.featuresBeingModified_=null;let l=this.vertexFeature_;if(l){let a=e.map.getView().getProjection(),o=[],g=l.getGeometry().getCoordinates(),v=Fs([g]),w=this.rBush_.getInExtent(v),T={};w.sort(pC);for(let S=0,k=w.length;S<k;++S){let F=w[S],j=F.segment,J=Gt(F.geometry),he=F.depth;if(he&&(J+="-"+he.join("-")),T[J]||(T[J]=new Array(2)),F.geometry.getType()==="Circle"&&F.index===uu){let q=yb(r,F,a);cn(q,g)&&!T[J][0]&&(this.dragSegments_.push([F,0]),T[J][0]=F);continue}if(cn(j[0],g)&&!T[J][0]){this.dragSegments_.push([F,0]),T[J][0]=F;continue}if(cn(j[1],g)&&!T[J][1]){if(T[J][0]&&T[J][0].index===0){let q=F.geometry.getCoordinates();switch(F.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":q=q[he[1]];case"Polygon":if(F.index!==q[he[0]].length-2)continue;break;default:}}this.dragSegments_.push([F,1]),T[J][1]=F;continue}Gt(j)in this.vertexSegments_&&!T[J][0]&&!T[J][1]&&this.insertVertexCondition_(e)&&o.push(F)}o.length&&this.willModifyFeatures_(e,[o]);for(let S=o.length-1;S>=0;--S)this.insertVertex_(o[S],g)}return!!this.vertexFeature_}handleUpEvent(e){for(let r=this.dragSegments_.length-1;r>=0;--r){let l=this.dragSegments_[r][0],a=l.geometry;if(a.getType()==="Circle"){let o=a.getCenter(),g=l.featureSegments[0],v=l.featureSegments[1];g.segment[0]=o,g.segment[1]=o,v.segment[0]=o,v.segment[1]=o,this.rBush_.update(Yo(o),g);let w=a,T=Wn();if(T){let S=e.map.getView().getProjection();w=w.clone().transform(T,S),w=Pm(w).transform(S,T)}this.rBush_.update(w.getExtent(),v)}else this.rBush_.update(Fs(l.segment),l)}return this.featuresBeingModified_&&(this.dispatchEvent(new du(vy.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.pixel,e.map,e.coordinate)}handlePointerAtPixel_(e,r,l){let a=l||r.getCoordinateFromPixel(e),o=r.getView().getProjection(),g=function(T,S){return gb(a,T,o)-gb(a,S,o)},v,w;if(this.hitDetection_){let T=typeof this.hitDetection_=="object"?S=>S===this.hitDetection_:void 0;r.forEachFeatureAtPixel(e,(S,k,F)=>{F&&F.getType()==="Point"&&(F=new _r(Wa(F.getCoordinates(),o)));let j=F||S.getGeometry();if(S instanceof rs&&this.features_.getArray().includes(S)){w=j;let J=S.getGeometry().getFlatCoordinates().slice(0,2);v=[{feature:S,geometry:w,segment:[J,J]}]}return!0},{layerFilter:T})}if(!v){let T=Os(Yo(a,mb),o),S=r.getView().getResolution()*this.pixelTolerance_,k=zs(bn(T,S,mb),o);v=this.rBush_.getInExtent(k)}if(v&&v.length>0){let T=v.sort(g)[0],S=T.segment,k=yb(a,T,o),F=r.getPixelFromCoordinate(k),j=cm(e,F);if(w||j<=this.pixelTolerance_){let J={};if(J[Gt(S)]=!0,this.snapToPointer_||(this.delta_[0]=k[0]-a[0],this.delta_[1]=k[1]-a[1]),T.geometry.getType()==="Circle"&&T.index===uu)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(k,[T.feature],[T.geometry]);else{let he=r.getPixelFromCoordinate(S[0]),q=r.getPixelFromCoordinate(S[1]),Z=ic(F,he),ne=ic(F,q);j=Math.sqrt(Math.min(Z,ne)),this.snappedToVertex_=j<=this.pixelTolerance_,this.snappedToVertex_&&(k=Z>ne?S[1]:S[0]),this.createOrUpdateVertexFeature_(k,[T.feature],[T.geometry]);let me={};me[Gt(T.geometry)]=!0;for(let _e=1,fe=v.length;_e<fe;++_e){let ve=v[_e].segment;if(cn(S[0],ve[0])&&cn(S[1],ve[1])||cn(S[0],ve[1])&&cn(S[1],ve[0])){let Ee=Gt(v[_e].geometry);Ee in me||(me[Ee]=!0,J[Gt(ve)]=!0)}else break}}this.vertexSegments_=J;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,r){let l=e.segment,a=e.feature,o=e.geometry,g=e.depth,v=e.index,w;for(;r.length<o.getStride();)r.push(0);switch(o.getType()){case"MultiLineString":w=o.getCoordinates(),w[g[0]].splice(v+1,0,r);break;case"Polygon":w=o.getCoordinates(),w[g[0]].splice(v+1,0,r);break;case"MultiPolygon":w=o.getCoordinates(),w[g[1]][g[0]].splice(v+1,0,r);break;case"LineString":w=o.getCoordinates(),w.splice(v+1,0,r);break;default:return}this.setGeometryCoordinates_(o,w);let T=this.rBush_;T.remove(e),this.updateSegmentIndices_(o,v,g,1);let S={segment:[l[0],r],feature:a,geometry:o,depth:g,index:v};T.insert(Fs(S.segment),S),this.dragSegments_.push([S,1]);let k={segment:[r,l[1]],feature:a,geometry:o,depth:g,index:v+1};T.insert(Fs(k.segment),k),this.dragSegments_.push([k,0]),this.ignoreNextSingleClick_=!0}removePoint(){if(this.lastPointerEvent_&&this.lastPointerEvent_.type!=Zn.POINTERDRAG){let e=this.lastPointerEvent_;this.willModifyFeatures_(e,this.dragSegments_);let r=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new du(vy.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null,r}return!1}removeVertex_(){let e=this.dragSegments_,r={},l=!1,a,o,g,v,w,T,S,k,F,j,J;for(w=e.length-1;w>=0;--w)g=e[w],j=g[0],J=Gt(j.feature),j.depth&&(J+="-"+j.depth.join("-")),J in r||(r[J]={}),g[1]===0?(r[J].right=j,r[J].index=j.index):g[1]==1&&(r[J].left=j,r[J].index=j.index+1);for(J in r){switch(F=r[J].right,S=r[J].left,T=r[J].index,k=T-1,S!==void 0?j=S:j=F,k<0&&(k=0),v=j.geometry,o=v.getCoordinates(),a=o,l=!1,v.getType()){case"MultiLineString":o[j.depth[0]].length>2&&(o[j.depth[0]].splice(T,1),l=!0);break;case"LineString":o.length>2&&(o.splice(T,1),l=!0);break;case"MultiPolygon":a=a[j.depth[1]];case"Polygon":a=a[j.depth[0]],a.length>4&&(T==a.length-1&&(T=0),a.splice(T,1),l=!0,T===0&&(a.pop(),a.push(a[0]),k=a.length-1));break;default:}if(l){this.setGeometryCoordinates_(v,o);let he=[];if(S!==void 0&&(this.rBush_.remove(S),he.push(S.segment[0])),F!==void 0&&(this.rBush_.remove(F),he.push(F.segment[1])),S!==void 0&&F!==void 0){let q={depth:j.depth,feature:j.feature,geometry:j.geometry,index:k,segment:he};this.rBush_.insert(Fs(q.segment),q)}this.updateSegmentIndices_(v,T,j.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return l}setGeometryCoordinates_(e,r){this.changingFeature_=!0,e.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(e,r,l,a){this.rBush_.forEachInExtent(e.getExtent(),function(o){o.geometry===e&&(l===void 0||o.depth===void 0||vn(o.depth,l))&&o.index>r&&(o.index+=a)})}};function pC(h,e){return h.index-e.index}function gb(h,e,r){let l=e.geometry;if(l.getType()==="Circle"){let o=l;if(e.index===uu){let g=Wn();g&&(o=o.clone().transform(g,r));let v=ic(o.getCenter(),er(h,r)),w=Math.sqrt(v)-o.getRadius();return w*w}}let a=er(h,r);return yc[0]=er(e.segment[0],r),yc[1]=er(e.segment[1],r),dx(a,yc)}function yb(h,e,r){let l=e.geometry;if(l.getType()==="Circle"&&e.index===uu){let o=l,g=Wn();return g&&(o=o.clone().transform(g,r)),Wa(o.getClosestPoint(er(h,r)),r)}let a=er(h,r);return yc[0]=er(e.segment[0],r),yc[1]=er(e.segment[1],r),Wa(lm(a,yc),r)}function fC(){let h=bv();return function(e,r){return h.Point}}var wy=by;var Sy=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=rs,this.supportedMediaTypes=null}getReadOptions(e,r){if(r){let l=r.dataProjection?qi(r.dataProjection):this.readProjection(e);r.extent&&l&&l.getUnits()==="tile-pixels"&&(l=qi(l),l.setWorldExtent(r.extent)),r={dataProjection:l,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return St()}readFeature(e,r){return St()}readFeatures(e,r){return St()}readGeometry(e,r){return St()}readProjection(e){return St()}writeFeature(e,r){return St()}writeFeatures(e,r){return St()}writeGeometry(e,r){return St()}},_b=Sy;function gp(h,e,r){let l=r?qi(r.featureProjection):null,a=r?qi(r.dataProjection):null,o=h;if(l&&a&&!_x(l,a)){e&&(o=h.clone());let g=e?l:a,v=e?a:l;g.getUnits()==="tile-pixels"?o.transform(g,v):o.applyTransform(qa(g,v))}if(e&&r&&r.decimals!==void 0){let g=Math.pow(10,r.decimals),v=function(w){for(let T=0,S=w.length;T<S;++T)w[T]=Math.round(w[T]*g)/g;return w};o===h&&(o=h.clone()),o.applyTransform(v)}return o}var mC={Point:_r,LineString:_s,Polygon:sc,MultiPoint:Vh,MultiLineString:Im,MultiPolygon:km};function gC(h,e,r){return Array.isArray(e[0])?(Xd(h,0,e,r)||(h=h.slice(),Uh(h,0,e,r)),h):(jh(h,0,e,r)||(h=h.slice(),nc(h,0,e,r)),h)}function Cy(h,e){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(o=>Cy({...h,geometry:o})).flat();let l=r.type==="MultiPolygon"?"Polygon":r.type;if(l==="GeometryCollection"||l==="Circle")throw new Error("Unsupported geometry type: "+l);let a=r.layout.length;return gp(new ss(l,l==="Polygon"?gC(r.flatCoordinates,r.ends,a):r.flatCoordinates,r.ends?.flat(),a,h.properties||{},h.id).enableSimplifyTransformed(),!1,e)}function yp(h,e){if(!h)return null;if(Array.isArray(h)){let l=h.map(a=>yp(a,e));return new ym(l)}let r=mC[h.type];return gp(new r(h.flatCoordinates,h.layout,h.ends),!1,e)}var Iy=class extends _b{constructor(){super()}getType(){return"json"}readFeature(e,r){return this.readFeatureFromObject(_p(e),this.getReadOptions(e,r))}readFeatures(e,r){return this.readFeaturesFromObject(_p(e),this.getReadOptions(e,r))}readFeatureFromObject(e,r){return St()}readFeaturesFromObject(e,r){return St()}readGeometry(e,r){return this.readGeometryFromObject(_p(e),this.getReadOptions(e,r))}readGeometryFromObject(e,r){return St()}readProjection(e){return this.readProjectionFromObject(_p(e))}readProjectionFromObject(e){return St()}writeFeature(e,r){return JSON.stringify(this.writeFeatureObject(e,r))}writeFeatureObject(e,r){return St()}writeFeatures(e,r){return JSON.stringify(this.writeFeaturesObject(e,r))}writeFeaturesObject(e,r){return St()}writeGeometry(e,r){return JSON.stringify(this.writeGeometryObject(e,r))}writeGeometryObject(e,r){return St()}};function _p(h){if(typeof h=="string"){let e=JSON.parse(h);return e||null}return h!==null?h:null}var xb=Iy;var Ey=class extends xb{constructor(e){e=e||{},super(),this.dataProjection=qi(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=qi(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,r){let l=null;e.type==="Feature"?l=e:l={type:"Feature",geometry:e,properties:null};let a=My(l.geometry,r);if(this.featureClass===ss)return Cy({geometry:a,id:l.id,properties:l.properties},r);let o=new rs;return this.geometryName_?o.setGeometryName(this.geometryName_):this.extractGeometryName_&&l.geometry_name&&o.setGeometryName(l.geometry_name),o.setGeometry(yp(a,r)),"id"in l&&o.setId(l.id),l.properties&&o.setProperties(l.properties,!0),o}readFeaturesFromObject(e,r){let l=e,a=null;if(l.type==="FeatureCollection"){let o=e;a=[];let g=o.features;for(let v=0,w=g.length;v<w;++v){let T=this.readFeatureFromObject(g[v],r);T&&a.push(T)}}else a=[this.readFeatureFromObject(e,r)];return a.flat()}readGeometryFromObject(e,r){return yC(e,r)}readProjectionFromObject(e){let r=e.crs,l;if(r)if(r.type=="name")l=qi(r.properties.name);else if(r.type==="EPSG")l=qi("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else l=this.dataProjection;return l}writeFeatureObject(e,r){r=this.adaptOptions(r);let l={type:"Feature",geometry:null,properties:null},a=e.getId();if(a!==void 0&&(l.id=a),!e.hasProperties())return l;let o=e.getProperties(),g=e.getGeometry();return g&&(l.geometry=Ty(g,r),delete o[e.getGeometryName()]),qn(o)||(l.properties=o),l}writeFeaturesObject(e,r){r=this.adaptOptions(r);let l=[];for(let a=0,o=e.length;a<o;++a)l.push(this.writeFeatureObject(e[a],r));return{type:"FeatureCollection",features:l}}writeGeometryObject(e,r){return Ty(e,this.adaptOptions(r))}};function My(h,e){if(!h)return null;let r;switch(h.type){case"Point":{r=xC(h);break}case"LineString":{r=vC(h);break}case"Polygon":{r=CC(h);break}case"MultiPoint":{r=wC(h);break}case"MultiLineString":{r=bC(h);break}case"MultiPolygon":{r=SC(h);break}case"GeometryCollection":{r=_C(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function yC(h,e){let r=My(h,e);return yp(r,e)}function _C(h,e){return h.geometries.map(function(l){return My(l,e)})}function xC(h){let e=h.coordinates;return{type:"Point",flatCoordinates:e,layout:Jo(e.length)}}function vC(h){let e=h.coordinates,r=e.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:Jo(e[0]?.length||2)}}function bC(h){let e=h.coordinates,r=e[0]?.[0]?.length||2,l=[],a=Qo(l,0,e,r);return{type:"MultiLineString",flatCoordinates:l,ends:a,layout:Jo(r)}}function wC(h){let e=h.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:Jo(e[0]?.length||2)}}function SC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.[0].length||2,a=jd(r,0,e,l);return{type:"MultiPolygon",flatCoordinates:r,ends:a,layout:Jo(l)}}function CC(h){let e=h.coordinates,r=[],l=e[0]?.[0]?.length,a=Qo(r,0,e,l);return{type:"Polygon",flatCoordinates:r,ends:a,layout:Jo(l)}}function Ty(h,e){h=gp(h,!0,e);let r=h.getType(),l;switch(r){case"Point":{l=PC(h,e);break}case"LineString":{l=EC(h,e);break}case"Polygon":{l=RC(h,e);break}case"MultiPoint":{l=MC(h,e);break}case"MultiLineString":{l=TC(h,e);break}case"MultiPolygon":{l=AC(h,e);break}case"GeometryCollection":{l=IC(h,e);break}case"Circle":{l={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return l}function IC(h,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(l){return Ty(l,e)})}}function EC(h,e){return{type:"LineString",coordinates:h.getCoordinates()}}function TC(h,e){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function MC(h,e){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function AC(h,e){let r;return e&&(r=e.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function PC(h,e){return{type:"Point",coordinates:h.getCoordinates()}}function RC(h,e){let r;return e&&(r=e.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var vr=Ey;var kC=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,vb=/^([\d.]+),([\d.]+)$/,bb=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,xp="stop-fetch",wb=h=>{let e=[];return h.forEach(r=>{let l=r.getGeometry()?.getCoordinates();l?.length&&e.push(...l)}),e},Ay=class h extends ac{constructor(r={}){super(r);this.viaPoints=[];this.graphs=[];this.useRawViaPoints=!1;this.snapToClosestStation=!1;this.cacheStationData={};this.abortControllers={};this.segments=[];this.format=new vr({featureProjection:"EPSG:3857"});this.initialRouteDrag={};this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.routingApiParams=r.routingApiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new bh({...r}),this.routingLayer=r.routingLayer||new Qa({source:new el,style:r.style}),this.onRouteError=r.onRouteError||(l=>{this.dispatchEvent(new mi("change:route")),this.reset(),console.error(l)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",l=>{l.key==="active"&&this.onActiveChange(),l.key==="mot"&&this.viaPoints&&this.drawRoute()})}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}static getGraphsResolutions(r,l){let a=l.getView();return r.map(([,o,g])=>[a.getResolutionForZoom(o),a.getResolutionForZoom(g||o+1)])}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}addViaPoint(r,l=-1,a=0){this.viaPoints.splice(l===-1?this.viaPoints.length:l,a,r),this.drawRoute(),this.dispatchEvent(new mi("change:route"))}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new mi("change:route"))}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new mi("change:route"))}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new mi("change:route"))}abortRequests(){this.graphs.forEach(r=>{let l=r[0];this.abortControllers[l]&&this.abortControllers[l].abort(),this.abortControllers[l]=new AbortController}),this.abortControllers[xp]?.abort(),this.abortControllers[xp]=new AbortController,this.loading=!1}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(!0),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[xp]);let r=this.viaPoints.map(l=>{if(Array.isArray(l)){let a=this.getMap()?.getView().getProjection(),[o,g]=$a(l,a);return this.snapToClosestStation?[`@${g}`,o]:[g,o]}return this.useRawViaPoints?l:`!${l}`});return this.loading=!0,this.viaPoints.forEach((l,a)=>this.drawViaPoint(l,a,this.abortControllers[xp])),Promise.all(this.graphs.map(([l],a)=>{let{signal:o}=this.abortControllers[l];return this.api?this.api.route({graph:l,via:`${r.join("|")}`,mot:this.mot,"resolve-hops":!1,elevation:!1,"coord-radius":100,"coord-punish":1e3,...this.routingApiParams||{}},{signal:o}).then(g=>{if(this.segments=this.format.readFeatures(g),this.mot==="foot"){let T=this.segments.reduce((S,k)=>{let F=k.get("trg");return S.find(j=>j[0]===F[0]&&j[1]===F[1])?S:[...S,F]},[]);this.segments=T.map(S=>{let k=this.segments.filter(j=>{let J=j.get("trg");return J[0]===S[0]&&J[1]===S[1]}),F=wb(k);return new rs({geometry:new _s(F)})})}let v=wb(this.segments),w=new rs({geometry:new _s(v)});w.set("graph",l),w.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[a]?.length>=2&&(w.set("minResolution",this.graphsResolutions[a][0]),w.set("maxResolution",this.graphsResolutions[a][1])),this.routingLayer?.getSource()?.addFeature(w),this.loading=!1}).catch(g=>{/AbortError/.test(g.message)||(this.segments=[],this.dispatchEvent(new mi("error")),this.onRouteError(g,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,l,a){let o=new rs;if(o.set("viaPointIdx",l),Array.isArray(r))return o.setGeometry(new _r(r)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o);if(!this.useRawViaPoints||bb.test(r)){let S,k;return this.useRawViaPoints?[,S,,k]=bb.exec(r)||[]:[S,k]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${S}?key=${this.stopsApiKey}`,{signal:a.signal}).then(F=>F.json()).then(F=>{let{coordinates:j}=F.features[0].geometry;return this.cacheStationData[r]=yr(j),o.set("viaPointTrack",k),o.setGeometry(new _r(yr(j))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(F=>{/AbortError/.test(F.message)||(this.dispatchEvent(new mi("error")),this.onRouteError(F,this),this.loading=!1)})}if(this.useRawViaPoints&&vb.test(r)){let[S,k]=vb.exec(r)||[];if(k&&S){let F=parseFloat(k),j=parseFloat(S),J=yr([F,j],this.getMap()?.getView().getProjection());return o.setGeometry(new _r(J)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}}let[,g,,v,w,,T]=kC.exec(r)||[];if(w&&v){let S=yr([parseFloat(w),parseFloat(v)],this.getMap()?.getView().getProjection());return o.set("viaPointTrack",T),o.setGeometry(new _r(S)),this.routingLayer?.getSource()?.addFeature(o),Promise.resolve(o)}return g?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${g}&limit=1`,{signal:a.signal}).then(S=>S.json()).then(S=>{let{coordinates:k}=S.features[0].geometry;return this.cacheStationData[r]=yr(k),o.set("viaPointTrack",T),o.setGeometry(new _r(yr(k))),this.routingLayer?.getSource()?.addFeature(o),o}).catch(S=>(this.dispatchEvent(new mi("error")),this.onRouteError(S,this),this.loading=!1,null)):Promise.resolve(null)}onMapClick(r){let a=r.target.getFeaturesAtPixel(r.pixel,{layerFilter:o=>o===this.routingLayer,hitTolerance:5}).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("viaPointIdx")!==void 0);if(a){this.removeViaPoint(a.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyStart(r){let l=-1,a=r.features.getArray().find(g=>g.getGeometry()?.getType()==="LineString");if(a&&a.getGeometry()&&r.mapBrowserEvent.coordinate){let g=bn(new _r(a.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);l=this.segments.findIndex(v=>v.getGeometry()?.intersectsExtent(g))}let o=(r.features.getArray().filter(g=>g.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={viaPoint:o,oldRoute:a&&a.clone(),segmentIndex:l}}onModifyEnd(r){let l=r.mapBrowserEvent.coordinate,{oldRoute:a,viaPoint:o,segmentIndex:g}=this.initialRouteDrag||{};return o?this.addViaPoint(l,o.get("viaPointIdx"),1):a?g===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(l,(g||0)+1):this.addViaPoint(l,0,1)}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new wy({source:this.routingLayer?.getSource()||void 0,pixelTolerance:6,deleteCondition:r=>{let a=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})).find(o=>o.getGeometry()?.getType()==="Point"&&o.get("index"));return ub(r)&&a?(this.removeViaPoint(a.get("index")),!0):!1}}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}removeListeners(){this.onMapClickKey&&Ih(this.onMapClickKey)}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}activate(){let r=this.getMap();r&&(this.format=new vr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}render(){}},Sb=Ay;var Py=class{constructor(e){let{apiParams:r,apiKey:l,url:a,placeholder:o}=e||{};this.apiParams={limit:20,...r||{}},this.placeholder=o||"Search for a stop...";let g={apiKey:l};a&&(g.url=a),this.api=new wh(g),this.abortController=new AbortController,this.createElement(e),this.options=e}render(e){let r=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(l=>{let a=document.createElement("div");a.innerHTML=l?.properties?.name,a.onclick=o=>{this.options?.onSuggestionClick?.(l,o)},Object.assign(a.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(a)}))}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),e.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",overflowY:"auto",cursor:"pointer"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{display:"none",position:"absolute",right:"0",padding:"0 10px",fontSize:"200%",cursor:"pointer"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}search(e,r){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(l=>{this.render(l)}).catch(()=>{this.render()})}},Cb=Py;var LC=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},Ib=LC;var Ry=class extends ac{constructor(e){let r=Ib();r.className=e?.className||"mbt-stop-finder";let l={element:r,...e||{}};super(l),this.controller=new Cb({onSuggestionClick:this.onSuggestionClick.bind(this),...l})}onSuggestionClick(e){let r=yr(e.geometry.coordinates);this.getMap()?.getView().setCenter(r)}},Eb=Ry;var Db=fo(Dy());var kb=fo(vp());function KC(h){return class extends h{constructor(r){super(r);this.options={};this.olListenersKeys=[];r.properties&&(console.warn("Deprecated. Don't use properties options. Pass the values directly in options object."),this.setProperties(r.properties)),this.olListenersKeys?.push(this.on("propertychange",l=>{l.key==="children"&&this.onChildrenChange(l.oldValue)}),this.on("change:visible",()=>{this.onVisibleChange()}),this.on("change:visible:group",l=>{this.group===l.target.group&&this!==l.target&&this.visible?this.visible=!1:this.children&&this.children.forEach(a=>a.dispatchEvent(l))})),this.options=r,this.children=r.children||[]}get children(){return this.get("children")||[]}set children(r){this.set("children",r||[])}get copyrights(){return console.warn("Deprecated. Use the source object to get the attributions"),this.get("copyrights")}set copyrights(r){console.warn("Deprecated. Use the source object to set the attributions");let l=r&&!Array.isArray(r)?[r]:r;this.set("copyrights",l||[])}get disabled(){return this.get("disabled")}set disabled(r){this.set("disabled",r)}get group(){return this.get("group")}get hitTolerance(){return console.warn("Deprecated. Pass the pixelTolerance when you request the features."),this.get("hitTolerance")||5}get key(){return this.get("key")||this.get("name")||Gt(this)}get map(){return this.getMapInternal()}get name(){return this.get("name")}get olLayer(){return console.warn("Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."),this}set olLayer(r){console.log("Deprecated property: mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect.")}get parent(){return this.get("parent")}set parent(r){this.set("parent",r)}get visible(){return this.getVisible()}set visible(r){this.setVisible(r)}setMapInternal(r){super.setMapInternal(r),r?this.attachToMap(r):this.detachFromMap()}onChildrenChange(r){(r||[]).forEach(l=>{l.set("parent",void 0)}),(this.children||[]).forEach(l=>{l.set("parent",this)})}onVisibleChange(){let r=this.get("parent"),l=this.get("children")||[];if(this.getVisible()){let a=this.get("group");if(r&&r.setVisible(!0),l&&!l.some(o=>o.getVisible())&&l.forEach(o=>{o.setVisible(!0)}),r&&a){let o=r;for(;o.get("parent");)o=o.get("parent");let g=new mi("change:visible:group");g.target=this,o.dispatchEvent(g)}}else l.forEach(a=>{a.setVisible(!1)}),r?.getVisible()&&!r?.get("children").find(a=>a.getVisible())&&r.setVisible(!1)}attachToMap(r){(super.attachToMap||(()=>{}))(r),(this.get("children")||[]).forEach(l=>{r.addLayer(l)})}detachFromMap(){(this.get("children")||[]).forEach(r=>{this.map.removeLayer(r)}),(super.detachFromMap||(()=>{}))(map)}flat(){return ja(this)}}}var Rb=KC;function JC(h){return class extends Rb(h){constructor(e={}){super(e)}}}var _c=JC;var Oy=class extends _c(xo){get apiKey(){return this.get("apiKey")}set apiKey(e){this.set("apiKey",e)}get apiKeyName(){return this.get("apiKeyName")}set apiKeyName(e){this.set("apiKeyName",e)}get style(){return this.get("style")}set style(e){this.set("style",e)}get url(){return this.get("url")}set url(e){this.set("url",e)}get queryRenderedFeaturesOptions(){return this.get("queryRenderedFeaturesOptions")}set queryRenderedFeaturesOptions(e){this.set("queryRenderedFeaturesOptions",e)}constructor(e){super({source:new Po({attributions:()=>this.mbMap&&Ga(this.mbMap)||[]}),apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...e||{},mapOptions:{interactive:!1,trackResize:!1,attributionControl:!1,...e?.mapOptions||{}},queryRenderedFeaturesOptions:{...e?.queryRenderedFeaturesOptions||{}}})}attachToMap(e){super.attachToMap(e),this.loadMbMap();let r=(0,kb.default)(this.updateMbMap.bind(this),150);this.olListenersKeys.push(this.on("propertychange",l=>{/(apiKey|apiKeyName|url|style|)/.test(l.key)&&r()}))}detachFromMap(){this.mbMap&&(this.mbMap.triggerRepaint=()=>{},this.mbMap.remove(),this.mbMap=void 0),this.loaded=!1,super.detachFromMap()}loadMbMap(){if(this.loaded=!1,this.olListenersKeys.push(this.map?.on("change:target",this.loadMbMap.bind(this))),!this.map?.getTargetElement())return;if(!this.visible){this.olListenersKeys.push(this.once("change:visible",this.loadMbMap.bind(this)));return}let e=document.createElement("div");e.style.position="absolute",e.style.width="100%",e.style.height="100%",this.mbMap=this.createMap({style:this.getStyle(),container:e,...this.options?.mapOptions||{}}),this.mbMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mbMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new mi("load"))})}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:Na(`${this.url}/styles/${this.style}/style.json`,{[this.apiKeyName]:this.apiKey}).toString()}createMap(e){throw new Error("createMap must be implemented in child class")}updateMbMap(){this.mbMap?.setStyle(this.getStyle(),{diff:!1})}},Lb=Oy;var By={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},pu=class extends pc{getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),a=l.getMapInternal(),{mbMap:o}=l,g=a?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(By[g]||(By[g]=new vr({featureProjection:g})),o?.isStyleLoaded()){let w=e&&o.project($a(e));if(w?.x&&w?.y){let T=[w.x,w.y];if(r){let[S,k]=T;T=[[S-r,k-r],[S+r,k+r]]}v=o.queryRenderedFeatures(T,l.queryRenderedFeaturesOptions||{}).map(S=>{let k=By[g].readFeature(S);return k&&k.set(ra,S),k})}}return v}prepareFrame(){return!0}renderFrame(e){let r=this.getLayer(),{map:l,mbMap:a}=r;if(!r||!l||!a)return null;let o=a.getCanvas(),{viewState:g}=e,v=r.getOpacity()||1;return o.style.opacity=`${v}`,a.jumpTo({center:$a(g.center),zoom:g.zoom-1,bearing:ax(-g.rotation)}),o.isConnected?(o.width!==e.size[0]||o.height!==e.size[1])&&a.resize():l.render(),a.redraw(),a.getContainer()}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,a){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(g=>{a(g,this.layer_,g.getGeometry())}),o?.[0]}};var fu=class h extends Lb{get maplibreMap(){return this.mbMap}constructor(e){super({...e})}createRenderer(){return new pu(this)}createMap(e){return new Db.Map(e)}clone(e){return new h({...this.options||{},...e||{}})}};var Ny={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},mu=class extends pc{getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),a=l.getMapInternal(),{maplibreMap:o}=l.maplibreLayer,g=a?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(Ny[g]||(Ny[g]=new vr({featureProjection:g})),o?.isStyleLoaded()){let w=e&&o.project($a(e));if(w?.x&&w?.y){let T=[w.x,w.y];if(r){let[k,F]=T;T=[[k-r,F-r],[k+r,F+r]]}let S=l.layers||[];l.layersFilter&&(S=o.getStyle().layers.filter(l.layersFilter)),l.queryRenderedLayersFilter&&(S=o.getStyle().layers.filter(l.queryRenderedLayersFilter)),v=o.queryRenderedFeatures(T,{layers:S.map(k=>k.id),validate:!1}).map(k=>{let F=Ny[g].readFeature(k);return F&&F.set(ra,k),F})}}return v}prepareFrame(){return!0}renderFrame(){return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,a){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(g=>{a(g,this.layer_,g.getGeometry())}),o?.[0]}};var Vy=class h extends _c(xo){constructor(r){super({source:new Po({}),...r||{}});this.highlightedFeatures=[];this.selectedFeatures=[];this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=l=>!!this.layers.find(a=>l.id===a.id))}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return console.warn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return console.warn("Deprecated. Use layers instead."),this.layers[0]}set styleLayer(r){console.warn("Deprecated. Use layers instead."),this.layers=[r]}get styleLayers(){return console.warn("Deprecated. Use layers instead."),this.layers}set styleLayers(r){console.warn("Deprecated. Use layers instead."),this.layers=r}createRenderer(){return new mu(this)}attachToMap(r){if(this.maplibreLayer&&!this.maplibreLayer.map&&r.addLayer(this.maplibreLayer),super.attachToMap(r),!this.map||!this.maplibreLayer)return;let{maplibreMap:l}=this.maplibreLayer;if(!l){this.olListenersKeys.push(this.map.on("change:target",()=>{this.attachToMap(r)}));return}l.loaded()?this.onLoad():l.once("load",this.onLoad),this.olListenersKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",a=>{this.applyLayoutVisibility(a)}),this.on("propertychange",a=>{/(sources|layers|layersFilter|maplibreLayer|beforeId|)/.test(a.key)&&(this.detachFromMap(),this.attachToMap(r))}))}detachFromMap(){this.maplibreLayer?.maplibreMap&&(this.maplibreLayer.maplibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources()),super.detachFromMap()}addSources(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.sources))return;let{maplibreMap:r}=this.maplibreLayer;r&&this.sources.forEach(l=>{let{id:a}=l;r.getSource(a)||r.addSource(a,l)})}removeSources(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.layers))return;let{maplibreMap:r}=this.maplibreLayer;r&&this.sources.forEach(l=>{let{id:a}=l;r.getSource(a)&&r.removeSource(a)})}addLayers(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.layers))return;let{maplibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(l=>{let{id:a,source:o}=l;(!o||o&&r.getSource(o))&&a&&!r.getLayer(a)&&r.addLayer(l,this.beforeId)}),this.applyLayoutVisibility())}removeLayers(){if(!this.maplibreLayer?.maplibreMap||!Array.isArray(this.layers))return;let{maplibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(l=>{let{id:a}=l;a&&r.getLayer(a)&&r.removeLayer(a)})}onLoad(){if(!this.maplibreLayer?.maplibreMap)return;this.addSources(),this.addLayers();let{maplibreMap:r}=this.maplibreLayer,l=r.getStyle();if(l?.layers&&this.layersFilter){let a=l.layers.filter(this.layersFilter);this.disabled=!a.length}}getFeatureInfoAtCoordinate(r){if(!this.maplibreLayer?.maplibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{maplibreMap:l}=this.maplibreLayer;if(!l.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let a=this.layers||[];return this.layersFilter&&(a=l.getStyle().layers.filter(this.layersFilter)),this.queryRenderedLayersFilter&&(a=l.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({features:[],layer:this,coordinate:r})}setHoverState(r,l){if(!this.maplibreLayer?.maplibreMap||!r.length)return;let{maplibreMap:a}=this.maplibreLayer;r.forEach(o=>{let{source:g,sourceLayer:v}=o.get(ra)||{};if(!g&&!v||!o.getId()){o.getId()||console.warn("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",o.getId(),o.getProperties());return}a.setFeatureState({id:o.getId(),source:g,sourceLayer:v},{hover:l})})}select(r=[]){this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}highlight(r=[]){let l=this.highlightedFeatures?.filter(a=>!(this.selectedFeatures||[]).map(o=>o.getId()).includes(a.getId()))||[];this.setHoverState(l,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}applyLayoutVisibility(r){if(!this.maplibreLayer?.maplibreMap?.getStyle()||!this.layersFilter)return;let{maplibreMap:l}=this.maplibreLayer,a=l.getStyle(),o=this.getVisible()?"visible":"none",g=a.layers||[];for(let v=0;v<g.length;v+=1){let w=g[v];if(this.layersFilter(w)){let{id:T}=w;l.getLayer(T)&&(l.setLayoutProperty(T,"visibility",o),(this.getMinZoom()||this.getMaxZoom())&&l.setLayerZoomRange(T,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}clone(r){return new h({...this.options,...r})}},Fb=Vy;var $y=fo(vp());var jy=fo(vp()),Uy=fo(Vb());function gI(h){return class extends h{constructor(r){super({hitTolerance:10,...r}),this.defineProperties(r),this.debug=r.debug||!1,this.mode=r.mode||Ki.TOPOGRAPHIC,this.api=r.api||new Ch(r),this.tenant=r.tenant||"",this.minZoomInterpolation=r.minZoomInterpolation||8,this.format=new vr,this.onStart=r.onStart,this.onStop=r.onStop,this.motsByZoom=r.motsByZoom||[vs,vs,vs,vs,vs,vs,vs,vs,vs,Yd,Yd],this.getMotsByZoom=l=>r.getMotsByZoom?r.getMotsByZoom(l,this.motsByZoom):this.motsByZoom[l],this.generalizationLevelByZoom=r.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=l=>r.getGeneralizationLevelByZoom?r.getGeneralizationLevelByZoom(l,this.generalizationLevelByZoom):this.generalizationLevelByZoom[l],this.renderTimeIntervalByZoom=r.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=l=>r.getRenderTimeIntervalByZoom?r.getRenderTimeIntervalByZoom(l,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[l],this.isUpdateBboxOnMoveEnd=r.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,Uy.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,jy.default)(this.renderTrajectoriesInternal,50,{leading:!0,trailing:!0,maxWait:5e3}),this.renderTrajectoriesInternal=this.renderTrajectoriesInternal.bind(this),this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}defineProperties(r){(super.defineProperties||(()=>{}))(r);let{style:l,speed:a,pixelRatio:o,hoverVehicleId:g,selectedVehicleId:v,filter:w,sort:T,time:S,live:k,canvas:F,styleOptions:j,mode:J,bboxParameters:he}=r,q=F,Z=a||1,ne=S||new Date,me=J||Ki.TOPOGRAPHIC,_e=l||Ya;Object.defineProperties(this,{isTrackerLayer:{value:!0},canvas:{get:()=>(q||(q=document.createElement("canvas")),q),set:fe=>{q=fe}},mode:{get:()=>me,set:fe=>{fe!==me&&(me=fe,this.api?.wsApi?.open&&(this.stop(),this.start()))}},style:{get:()=>_e,set:fe=>{_e=fe,this.renderTrajectories()}},styleOptions:{value:{...oc,...j||{}}},speed:{get:()=>Z,set:fe=>{Z=fe,this.start()}},bboxParameters:{value:he,writable:!0},filter:{value:w,writable:!0},sort:{value:T,writable:!0},live:{value:k===!1?k:!0,writable:!0},time:{get:()=>ne,set:fe=>{ne=fe&&fe.getTime?fe:new Date(fe),this.renderTrajectories()}},trajectories:{value:{},writable:!0},hoverVehicleId:{value:g,writable:!0},selectedVehicleId:{value:v,writable:!0},pixelRatio:{value:o||(typeof window<"u"?window.devicePixelRatio:1),writable:!0},useRequestAnimationFrame:{value:r.useRequestAnimationFrame||!1,writable:!0},useThrottle:{value:r.useThrottle!==!1,writable:!0},useDebounce:{value:r.useDebounce||!1,writable:!0}})}attachToMap(r){super.attachToMap(r),document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),Ih(this.visibilityRef),this.canvas){let r=this.canvas.getContext("2d");r&&r.clearRect(0,0,this.canvas.width,this.canvas.height),super.detachFromMap()}}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}renderTrajectoriesInternal(r,l=!1){if(!this.map||!this.trajectories)return!1;let a=this.live?Date.now():this.time?.getTime(),o=Object.values(this.trajectories);return this.sort&&o.sort(this.sort),!this.canvas||!this.style||(this.renderState=Wh(this.canvas,o,this.style,{...r,pixelRatio:this.pixelRatio||1,time:a},{filter:this.filter,noInterpolate:(r.zoom||0)<this.minZoomInterpolation?!0:l,hoverVehicleId:this.hoverVehicleId,selectedVehicleId:this.selectedVehicleId,...this.styleOptions})),!0}renderTrajectories(r,l){this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),r&&(!l&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,l)}):!l&&this.useDebounce?this.debounceRenderTrajectories(r,l):!l&&this.useThrottle?this.throttleRenderTrajectories(r,l):this.renderTrajectoriesInternal(r,l))}setBbox(r,l){if(this.trajectories&&r&&l){let k=Object.keys(this.trajectories);for(let F=k.length-1;F>=0;F-=1)this.purgeTrajectory(this.trajectories[k[F]],r,l)}let a=Math.floor(l);if(!r||Number.isNaN(a))return;let[o,g,v,w]=r,T=[Math.floor(o),Math.floor(g),Math.ceil(v),Math.ceil(w),a],S=this.getGeneralizationLevelByZoom(a);this.generalizationLevel&&T.push(`gen=${S}`),this.mots=this.getMotsByZoom(a),this.mots&&T.push(`mots=${this.mots}`),this.tenant&&T.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&T.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([k,F])=>{T.push(`${k}=${F}`)}),this.api.bbox=T}getRefreshTimeInMs(r=0){let l=r!==void 0?Math.round(r):-1,a=this.getRenderTimeIntervalByZoom(l)||25,o=Math.max(25,a/(this.speed||1)),g=Math.min(o,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,Uy.default)(this.renderTrajectoriesInternal,g,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,jy.default)(this.renderTrajectoriesInternal,g,{leading:!0,trailing:!0,maxWait:5e3})),this.api?.buffer){let[,v]=this.api.buffer;this.api.buffer=[g,v]}return o}getVehicle(r){return this.trajectories&&Object.values(this.trajectories).filter(r)||[]}getFeatureInfoAtCoordinate(r,l){let{resolution:a,nb:o}=l,g=bn([...r,...r],this.hitTolerance*a),v=Object.values(this.trajectories||{});this.sort&&(v=v.sort(this.sort));let w=[];for(let T=0;T<v.length&&(v[T].properties.coordinate&&mo(g,v[T].properties.coordinate)&&w.push(v[T]),w.length!==o);T+=1);return Promise.resolve({layer:this,features:w,coordinate:r})}getTrajectoryInfos(r){let l=[this.api.getStopSequence(r),this.api.getFullTrajectory(r,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0)))];return Promise.all(l).then(([a,o])=>({stopSequence:a,fullTrajectory:o}))}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([r,l])=>{let a=l?.properties?.time_intervals;this.time&&a.length&&a[a.length-1][0]<this.time&&this.removeTrajectory(r)})}purgeTrajectory(r,l,a){let{type:o,bounds:g}=r.properties;return this.isUpdateBboxOnMoveEnd&&!Qi(l,g)||this.mots&&!this.mots.includes(o)?(this.removeTrajectory(r),!0):!1}addTrajectory(r){this.trajectories||(this.trajectories={}),this.trajectories[r.properties.train_id]=r,this.renderTrajectories()}removeTrajectory(r){let l;typeof r!="string"?l=r?.properties?.train_id:l=r,this.trajectories&&delete this.trajectories[l]}onZoomEnd(){this.startUpdateTime()}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(this.visible===!1)return;this.start()}}onTrajectoryMessage(r){if(!r.content)return;let l=r.content,{geometry:a,properties:{train_id:o,time_since_update:g,raw_coordinates:v}}=l;g<0||this.purgeTrajectory(l)||(this.debug&&this.mode===Ki.TOPOGRAPHIC&&v?l.properties.olGeometry=this.format.readGeometry({type:"Point",coordinates:yr(v,this.map.getView().getProjection())}):l.properties.olGeometry=this.format.readGeometry(a),l.properties.timeOffset=Date.now()-r.timestamp,this.addTrajectory(l))}onDeleteTrajectoryMessage(r){r.content&&this.removeTrajectory(r.content)}highlightVehicle(r){this.hoverVehicleId!==r&&(this.hoverVehicleId=r,this.renderTrajectories(!0))}selectVehicle(r){this.selectedVehicleId!==r&&(this.selectedVehicleId=r,this.renderTrajectories(!0))}}}var wp=gI;var yI=new zr({zIndex:2,image:new Rn({radius:5,fill:new Fr({color:"#000000"})}),stroke:new nr({color:"#000000",width:6})}),_I=(h,e,r)=>{let l="#ffffff",a=h.get("type"),o=h.get("stroke");return o&&o[0]!=="#"&&(o=`#${o}`),l=o||r?.getBgColor(a),l=/#ffffff/i.test(l)?"#ff0000":l,[yI,new zr({zIndex:3,image:new Rn({radius:4,fill:new Fr({color:l})}),stroke:new nr({color:l,width:4})})]},Sp=_I;var xI=new zr({zIndex:2,image:new Rn({radius:5,fill:new Fr({color:"#000000"})}),stroke:new nr({color:"#000000",width:6})}),vI=new zr({zIndex:3,image:new Rn({radius:4,fill:new Fr({color:"#a0a0a0"})}),stroke:new nr({color:"#a0a0a0",width:4})}),bI=()=>[xI,vI],Gb=bI;var jb=new Rn({radius:6,fill:new Fr({color:[255,0,0,1]}),stroke:new nr({color:[0,0,0,1],width:1})}),wI=new zr({stroke:new nr({color:[0,0,0,1],width:5})}),SI=new zr({image:jb,stroke:new nr({color:[255,0,0,1],width:3})}),CI=new zr({image:jb,stroke:new nr({color:[255,0,0,1],width:3,lineDash:[1,10]})}),II=(h,e)=>{let r=h.get("minResolution"),l=h.get("maxResolution"),a=e<=r&&e>l;return r&&l&&!a?[]:h.get("mot")!=="foot"?[wI,SI]:[CI]},Ub=II;var EI=new vr,gu=class extends mp{prepareFrame(){return!0}renderFrame(e){let{canvas:r,renderedViewState:l}=this.getLayer();if(this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),l){let{center:a,resolution:o,rotation:g}=e.viewState,{center:v,resolution:w,rotation:T}=l;if(w/o>=3)r?.getContext("2d")?.clearRect(0,0,r?.width,r?.height);else{let S=this.getLayer().getMapInternal()?.getPixelFromCoordinate(v),k=this.getLayer().getMapInternal().getPixelFromCoordinate(a);this.container.style.transform=G0(S[0]-k[0],S[1]-k[1],w/o,w/o,g-T,0,0)}}return this.container}getData(e){let r;try{let{pixelRatio:l}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(l||1),e[1]*(l||1),1,1).data||null,r}catch(l){console.error("error getting data",l)}return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,l,a){let o=this.getFeaturesAtCoordinate(e,l);return o.forEach(g=>{a(g,this.layer_,g.getGeometry())}),o?.[0]}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let l=this.getLayer(),o=l.getMapInternal().getView().getResolution(),g=10,v=bn([...e,...e],r*o),w=[],T=Object.values(l.trajectories||{});l.sort&&(T=T.sort(this.sort));let S=[];for(let k=0;k<T.length;k+=1){let F=T[k];if(F.properties.coordinate&&mo(v,F.properties.coordinate)&&S.push(T[k]),S.length===g)break}return w=S.map(k=>EI.readFeature(k)),w}};var TI=new vr,qy=class h extends wp(_c(xo)){constructor(r){super({source:new Po({}),...r});this.allowRenderWhenAnimating=!1;this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new Qa({updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0,source:new el({features:[]}),style:(l,a)=>(r.fullTrajectoryStyle||Sp)(l,a,this.styleOptions)}),this.renderState={center:[0,0],zoom:void 0,rotation:0},this.onZoomEndDebounced=(0,$y.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,$y.default)(this.onMoveEnd,100)}createRenderer(){return new gu(this)}attachToMap(r){if(super.attachToMap(r),this.map){this.visible&&this.start();let l=this.map.getLayers().getArray().indexOf(this);this.map.getLayers().insertAt(l,this.vectorLayer),this.olListenersKeys.push(...this.map.on(["moveend","change:target"],a=>{let o=(a.map||a.target).getView();if(o.getAnimating()||o.getInteracting())return;let g=o.getZoom();this.currentZoom!==g&&this.onZoomEndDebounced(a),this.currentZoom=g,this.onMoveEndDebounced(a)}),this.on("change:visible",a=>{a.target.visible?this.start():this.stop()}),this.on("propertychange",a=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(a.key)&&this.vectorLayer.set(a.key,a.target.get(a.key))}))}}detachFromMap(){this.map?.removeLayer(this.vectorLayer),super.detachFromMap()}renderTrajectories(r){if(!this.map)return;let l=this.map.getView();l.getCenter()&&super.renderTrajectories({size:this.map.getSize(),center:l.getCenter(),extent:l.calculateExtent(),resolution:l.getResolution(),rotation:l.getRotation(),zoom:l.getZoom(),pixelRatio:this.pixelRatio},r)}renderTrajectoriesInternal(r,l){if(!this.map)return!1;let a=!1;return a=(this.allowRenderWhenAnimating?!1:this.map.getView().getAnimating()||this.map.getView().getInteracting())?!1:super.renderTrajectoriesInternal(r,l),a&&(this.renderedViewState={...r},this.getRenderer().container&&(this.getRenderer().container.style.transform="")),a}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getView().getZoom())}onMoveEnd(r){!this.isUpdateBboxOnMoveEnd||!this.visible||this.setBbox()}onZoomEnd(){super.onZoomEnd(),!(!this.isUpdateBboxOnMoveEnd||!this.visible)&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}highlight(r){this.highlightVehicle(r?.get("train_id"))}select(r){this.selectVehicle(r?.get("train_id")),this.highlightTrajectory(r?.get("train_id"))}purgeTrajectory(r,l,a){let o=this.map.getView().getCenter();return!l&&!o?!1:super.purgeTrajectory(r,l||this.map.getView().calculateExtent(),a||this.map.getView().getZoom())}setBbox(r,l){super.setBbox(r||this.map.getView().calculateExtent(),l||this.map.getView().getZoom())}highlightTrajectory(r){return r?this.api.getFullTrajectory(r,this.mode,this.getGeneralizationLevelByZoom(Math.floor(this.map?.getView()?.getZoom()||0))).then(l=>{let a=l.content;if(!a?.features?.length)return[];let o=TI.readFeatures(a);return this.vectorLayer.getSource().clear(!0),o.length&&this.vectorLayer.getSource().addFeatures(o),o}).catch(()=>(this.vectorLayer.getSource().clear(!0),[])):(this.vectorLayer.getSource().clear(!0),Promise.resolve([]))}clone(r){return new h({...this.options,...r})}},$b=qy;var MI=new vr,AI=(h,e,r)=>{let l,{coordinate:a,resolution:o,projection:g,params:v}=e;return h&&o&&g&&(l=h.getFeatureInfoUrl(a,o,g,{info_format:"application/json",query_layers:h.getParams().layers,...v})),fetch(l,{signal:r.signal}).then(w=>w.json()).then(w=>MI.readFeatures(w)).catch(()=>[])},yu={},PI=async(h,e,r=5)=>{Object.values(yu).forEach(o=>{o?.abort()}),yu={};let a=ja(e).map(o=>{let g=o.getMapInternal(),v=g?.getView()?.getProjection()?.getCode(),w={features:[],layer:o,coordinate:h};if(!v)return Promise.resolve(w);if(o.getFeatureInfoAtCoordinate)return o.getFeatureInfoAtCoordinate(h);let T=o?.getSource();if(T?.getFeatureInfoUrl){let F=Gt(void 0);yu[F]?.abort(),yu[F]=new AbortController;let j=g?.getView()?.getResolution();return AI(T,{coordinate:h,resolution:j,projection:v,params:{info_format:"application/json",query_layers:T.getParams().layers}},yu[F]).then(J=>({features:J,layer:o,coordinate:h})).catch(()=>({features:[],layer:o,coordinate:h}))}let S=g?.getPixelFromCoordinate(h);if(!S)return Promise.resolve(w);let k=g?.getFeaturesAtPixel(S,{layerFilter:F=>F===o,hitTolerance:o.get("hitTolerance")||r||5});return Promise.resolve({features:k,layer:o,coordinate:h})});return Promise.all(a)},qb=PI;var Ap={};Of(Ap,{CopyrightControl:()=>Wb,Layer:()=>Ep,RealtimeAPI:()=>Ch,RealtimeLayer:()=>c1,RealtimeModes:()=>Ki,RoutingAPI:()=>bh,StopsAPI:()=>wh,VECTOR_TILE_FEATURE_PROPERTY:()=>ra,compareDepartures:()=>Zh,createCanvas:()=>xs,createRealtimeFilters:()=>Uf,debounceDeparturesMessages:()=>Lm,debounceWebsocketMessages:()=>Sh,getCircleCanvas:()=>Gm,getDelayBgCanvas:()=>Nm,getDelayTextCanvas:()=>Vm,getHoursAndMinutes:()=>O0,getLayersAsFlatArray:()=>ja,getMapGlCopyrights:()=>Ga,getMercatorResolution:()=>l1,getSourceCoordinates:()=>Mp,getTextCanvas:()=>jm,getUTCDateString:()=>F0,getUTCTimeString:()=>z0,getUrlWithParams:()=>Na,getVehiclePosition:()=>qh,pad:()=>Ed,realtimeConfig:()=>oc,realtimeDefaultStyle:()=>Ya,realtimeDelayStyle:()=>Um,realtimeSimpleStyle:()=>$m,removeDuplicate:()=>Va,renderTrajectories:()=>Wh,sortAndFilterDepartures:()=>Xh,sortByDelay:()=>$f});var RI=" | ",Wy=class{constructor(e={}){this.options=e}onAdd(e){return this.map=e,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}getDefaultPosition(){return"bottom-right"}render(){if(this.map&&this.container){let e=this.options?.separator||RI,r=this.options?.customAttribution||Ga(this.map),l=(Array.isArray(r)?r:[r]).join(e);this.container.innerHTML!==l&&(this.content=l,this.container.innerHTML=this.content)}}},Wb=Wy;var Ip,kI=new Uint8Array(16);function Zy(){if(!Ip&&(Ip=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ip))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ip(kI)}var Br=[];for(let h=0;h<256;++h)Br.push((h+256).toString(16).slice(1));function Zb(h,e=0){return Br[h[e+0]]+Br[h[e+1]]+Br[h[e+2]]+Br[h[e+3]]+"-"+Br[h[e+4]]+Br[h[e+5]]+"-"+Br[h[e+6]]+Br[h[e+7]]+"-"+Br[h[e+8]]+Br[h[e+9]]+"-"+Br[h[e+10]]+Br[h[e+11]]+Br[h[e+12]]+Br[h[e+13]]+Br[h[e+14]]+Br[h[e+15]]}var LI=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Xy={randomUUID:LI};function DI(h,e,r){if(Xy.randomUUID&&!e&&!h)return Xy.randomUUID();h=h||{};let l=h.random||(h.rng||Zy)();if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,e){r=r||0;for(let a=0;a<16;++a)e[r+a]=l[a];return e}return Zb(l)}var Hy=DI;var Xb=fo(Dy()),Yy=class extends Xb.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||Hy(),this.type="custom"}onAdd(r,l){this.map=r}onRemove(r,l){this.map=void 0}render(r){}},Ep=Yy;var or=63710088e-1,Hb={centimeters:or*100,centimetres:or*100,degrees:or/111325,feet:or*3.28084,inches:or*39.37,kilometers:or/1e3,kilometres:or/1e3,meters:or,metres:or,miles:or/1609.344,millimeters:or*1e3,millimetres:or*1e3,nauticalmiles:or/1852,radians:1,yards:or*1.0936},I4={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/or,yards:1.0936133};function Yb(h,e,r){r===void 0&&(r={});var l={type:"Feature"};return(r.id===0||r.id)&&(l.id=r.id),r.bbox&&(l.bbox=r.bbox),l.properties=e||{},l.geometry=h,l}function da(h,e,r){if(r===void 0&&(r={}),!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ky(h[0])||!Ky(h[1]))throw new Error("coordinates must contain numbers");var l={type:"Point",coordinates:h};return Yb(l,e,r)}function FI(h,e){e===void 0&&(e="kilometers");var r=Hb[e];if(!r)throw new Error(e+" units is invalid");return h*r}function zI(h,e){e===void 0&&(e="kilometers");var r=Hb[e];if(!r)throw new Error(e+" units is invalid");return h/r}function Kb(h){var e=h%(2*Math.PI);return e*180/Math.PI}function tl(h){var e=h%360;return e*Math.PI/180}function Tp(h,e,r){if(e===void 0&&(e="kilometers"),r===void 0&&(r="kilometers"),!(h>=0))throw new Error("length must be a positive number");return FI(zI(h,e),r)}function Ky(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function Jy(h){return!!h&&h.constructor===Object}function _u(h,e,r){if(h!==null)for(var l,a,o,g,v,w,T,S=0,k=0,F,j=h.type,J=j==="FeatureCollection",he=j==="Feature",q=J?h.features.length:1,Z=0;Z<q;Z++){T=J?h.features[Z].geometry:he?h.geometry:h,F=T?T.type==="GeometryCollection":!1,v=F?T.geometries.length:1;for(var ne=0;ne<v;ne++){var me=0,_e=0;if(g=F?T.geometries[ne]:T,g!==null){w=g.coordinates;var fe=g.type;switch(S=r&&(fe==="Polygon"||fe==="MultiPolygon")?1:0,fe){case null:break;case"Point":if(e(w,k,Z,me,_e)===!1)return!1;k++,me++;break;case"LineString":case"MultiPoint":for(l=0;l<w.length;l++){if(e(w[l],k,Z,me,_e)===!1)return!1;k++,fe==="MultiPoint"&&me++}fe==="LineString"&&me++;break;case"Polygon":case"MultiLineString":for(l=0;l<w.length;l++){for(a=0;a<w[l].length-S;a++){if(e(w[l][a],k,Z,me,_e)===!1)return!1;k++}fe==="MultiLineString"&&me++,fe==="Polygon"&&_e++}fe==="Polygon"&&me++;break;case"MultiPolygon":for(l=0;l<w.length;l++){for(_e=0,a=0;a<w[l].length;a++){for(o=0;o<w[l][a].length-S;o++){if(e(w[l][a][o],k,Z,me,_e)===!1)return!1;k++}_e++}me++}break;case"GeometryCollection":for(l=0;l<g.geometries.length;l++)if(_u(g.geometries[l],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function OI(h,e){e===void 0&&(e={});var r=0,l=0,a=0;return _u(h,function(o){r+=o[0],l+=o[1],a++},!0),da([r/a,l/a],e.properties)}var Jb=OI;function Xs(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return h.geometry.coordinates;if(h.type==="Point")return h.coordinates}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return h;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Qb(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function BI(h,e,r){r===void 0&&(r={});var l;r.final?l=e1(Xs(e),Xs(h)):l=e1(Xs(h),Xs(e));var a=l>180?-(360-l):l;return a}function e1(h,e){var r=tl(h[1]),l=tl(e[1]),a=tl(e[0]-h[0]);a>Math.PI&&(a-=2*Math.PI),a<-Math.PI&&(a+=2*Math.PI);var o=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),g=Math.atan2(a,o);return(Kb(g)+360)%360}var t1=BI;function NI(h,e,r){r===void 0&&(r={});var l=Xs(h),a=Xs(e);a[0]+=a[0]-l[0]>180?-360:l[0]-a[0]>180?360:0;var o=VI(l,a),g=Tp(o,"meters",r.units);return g}function VI(h,e,r){r=r===void 0?or:Number(r);var l=r,a=h[1]*Math.PI/180,o=e[1]*Math.PI/180,g=o-a,v=Math.abs(e[0]-h[0])*Math.PI/180;v>Math.PI&&(v-=2*Math.PI);var w=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(a/2+Math.PI/4)),T=Math.abs(w)>1e-11?g/w:Math.cos(a),S=Math.sqrt(g*g+T*T*v*v),k=S*l;return k}var i1=NI;function GI(h,e,r,l){l===void 0&&(l={});var a=e<0,o=Tp(Math.abs(e),l.units,"meters");a&&(o=-Math.abs(o));var g=Xs(h),v=jI(g,o,r);return v[0]+=v[0]-g[0]>180?-360:g[0]-v[0]>180?360:0,da(v,l.properties)}function jI(h,e,r,l){l=l===void 0?or:Number(l);var a=e/l,o=h[0]*Math.PI/180,g=tl(h[1]),v=tl(r),w=a*Math.cos(v),T=g+w;Math.abs(T)>Math.PI/2&&(T=T>0?Math.PI-T:-Math.PI-T);var S=Math.log(Math.tan(T/2+Math.PI/4)/Math.tan(g/2+Math.PI/4)),k=Math.abs(S)>1e-11?w/S:Math.cos(g),F=a*Math.sin(v)/k,j=o+F;return[(j*180/Math.PI+540)%360-180,T*180/Math.PI]}var r1=GI;function UI(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return n1(h);case"FeatureCollection":return $I(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Qy(h);default:throw new Error("unknown GeoJSON type")}}function n1(h){var e={type:"Feature"};return Object.keys(h).forEach(function(r){switch(r){case"type":case"properties":case"geometry":return;default:e[r]=h[r]}}),e.properties=s1(h.properties),e.geometry=Qy(h.geometry),e}function s1(h){var e={};return h&&Object.keys(h).forEach(function(r){var l=h[r];typeof l=="object"?l===null?e[r]=null:Array.isArray(l)?e[r]=l.map(function(a){return a}):e[r]=s1(l):e[r]=l}),e}function $I(h){var e={type:"FeatureCollection"};return Object.keys(h).forEach(function(r){switch(r){case"type":case"features":return;default:e[r]=h[r]}}),e.features=h.features.map(function(r){return n1(r)}),e}function Qy(h){var e={type:h.type};return h.bbox&&(e.bbox=h.bbox),h.type==="GeometryCollection"?(e.geometries=h.geometries.map(function(r){return Qy(r)}),e):(e.coordinates=o1(h.coordinates),e)}function o1(h){var e=h;return typeof e[0]!="object"?e.slice():e.map(function(r){return o1(r)})}var a1=UI;function qI(h,e,r){if(r=r||{},!Jy(r))throw new Error("options is invalid");var l=r.pivot,a=r.mutate;if(!h)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");return e===0||(l||(l=Jb(h)),(a===!1||a===void 0)&&(h=a1(h)),_u(h,function(o){var g=t1(l,o),v=g+e,w=i1(l,o),T=Qb(r1(l,w,v));o[0]=T[0],o[1]=T[1]})),h}var e_=qI;var WI=(h,e=1)=>{let{width:r,height:l}=h.getCanvas(),a=h.unproject({x:0,y:0}),o=h.unproject({x:0,y:l/e}),g=h.unproject({x:r/e,y:l/e}),v=h.unproject({x:r/e,y:0});return[[a.lng,a.lat],[v.lng,v.lat],[g.lng,g.lat],[o.lng,o.lat]]},Mp=WI;var ZI=h=>{let e=h.getBounds().toArray(),r=yr(e[0]),l=yr(e[1]),a=[...r,...l],{width:o,height:g}=h.getCanvas(),v=$i(a)/o,w=ln(a)/g;return Math.max(v,w)},l1=ZI;var XI=h=>Rh(h.toArray().flat(),"EPSG:4326","EPSG:3857"),t_=XI;var i_=class extends wp(Ep){constructor(e={}){let r=document.createElement("canvas");super({canvas:r,...e}),this.source={id:this.id,type:"canvas",canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],animate:!0,attribution:e.attribution?.join(", "),loaded:!0},this.layer={id:`${this.id}-raster`,type:"raster",source:this.id,layout:{visibility:"visible"},paint:{"raster-opacity":1,"raster-fade-duration":0,"raster-resampling":"nearest"}},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}onAdd(e,r){super.onAdd(e,r),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onRemove(e,r){e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.id)&&e.removeSource(this.id),super.onRemove(e,r)}onLoad(){this.map.getSource(this.id)||this.map.addSource(this.id,this.source),this.map.getLayer(this.layer.id)||this.map.addLayer(this.layer,this.id),this.start()}start(){super.start(),this.map.on("move",this.onMove),this.map.on("moveend",this.onMoveEnd),this.map.on("zoomend",this.onZoomEnd)}stop(){super.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}renderTrajectories(e=!1){if(!this.map)return;this.pixelRatio||(this.pixelRatio=1);let{width:r,height:l}=this.map.getCanvas(),a=this.map.getCenter(),o=this.map.unproject({x:0,y:l/this.pixelRatio}),g=this.map.unproject({x:r/this.pixelRatio,y:0}),v=e_(da([o.lng,o.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,w=e_(da([g.lng,g.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,T=[...yr(v),...yr(w)],S=$i(T)/(r/this.pixelRatio),k=ln(T)/(l/this.pixelRatio),F=Math.max(S,k),j={size:[r/this.pixelRatio,l/this.pixelRatio],center:yr([a.lng,a.lat]),extent:T,resolution:F,zoom:this.map.getZoom()-1,rotation:-(this.map.getBearing()*Math.PI)/180,pixelRatio:this.pixelRatio};super.renderTrajectories(j,e)}getRefreshTimeInMs(){return super.getRefreshTimeInMs(this.map.getZoom())}purgeTrajectory(e,r,l){return super.purgeTrajectory(e,r||t_(this.map.getBounds()),l||Math.floor(this.map.getZoom()-1))}setBbox(e,r){super.setBbox(e||t_(this.map.getBounds()),r||this.map.getZoom()-1)}renderTrajectoriesInternal(e,r=!1){let l=super.renderTrajectoriesInternal(e,r);if(l&&this.map.style){let a=Mp(this.map,this.pixelRatio),o=this.map.getSource(this.id);o&&o.setCoordinates(a)}return l}onMove(){this.renderTrajectories()}onMoveEnd(){this.renderTrajectories(),this.isUpdateBboxOnMoveEnd&&this.setBbox()}},c1=i_;var r_={ol:Cp,maplibre:Ap};typeof window<"u"&&(window.mbt=r_);var P6=r_;})();
586
586
  /*! Bundled license information:
587
587
 
588
588
  maplibre-gl/dist/maplibre-gl.js: