@openremote/or-map 1.10.0 → 1.11.0-snapshot.20251031091914

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.
@@ -48,7 +48,7 @@ uniform ${i} ${n} u_${r};
48
48
  #else
49
49
  ${i} ${n} ${r} = u_${r};
50
50
  #endif
51
- `}),staticAttributes:n,staticUniforms:o}}class t4{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,n,r,a,o,s,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==n.length;for(let t=0;!c&&t<n.length;t++)this.boundPaintVertexBuffers[t]!==n[t]&&(c=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==r||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,n,r,a,o,s,l):(t.bindVertexArray.set(this.vao),o&&o.bind(),r&&r.dynamicDraw&&r.bind(),s&&s.bind(),l&&l.bind())}freshBind(t,e,i,n,r,a,o,s){let l=t.numAttributes,c=this.context,d=c.gl;for(let l of(this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=n,this.boundVertexOffset=r,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,e.enableAttributes(d,t),i))l.enableAttributes(d,t);for(let n of(a&&a.enableAttributes(d,t),o&&o.enableAttributes(d,t),s&&s.enableAttributes(d,t),e.bind(),e.setVertexAttribPointers(d,t,r),i))n.bind(),n.setVertexAttribPointers(d,t,r);a&&(a.bind(),a.setVertexAttribPointers(d,t,r)),n&&n.bind(),o&&(o.bind(),o.setVertexAttribPointers(d,t,r)),s&&(s.bind(),s.setVertexAttribPointers(d,t,r)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}function t6(t){let e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;let n=t[i].split(" ");e.push(n.pop())}return e}class t7{constructor(t,i,n,r,a,o){let s=t.gl;this.program=s.createProgram();let l=t6(i.staticAttributes),c=n?n.getBinderAttributes():[],d=l.concat(c),u=t5.prelude.staticUniforms?t6(t5.prelude.staticUniforms):[],h=i.staticUniforms?t6(i.staticUniforms):[],p=n?n.getBinderUniforms():[],m=u.concat(h).concat(p),f=[];for(let t of m)0>f.indexOf(t)&&f.push(t);let g=n?n.defines():[];a&&g.push("#define OVERDRAW_INSPECTOR;"),o&&g.push("#define TERRAIN3D;");let _=g.concat(t5.prelude.fragmentSource,i.fragmentSource).join("\n"),b=g.concat(t5.prelude.vertexSource,i.vertexSource).join("\n"),y=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);if(s.shaderSource(y,_),s.compileShader(y),!s.getShaderParameter(y,s.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${s.getShaderInfoLog(y)}`);s.attachShader(this.program,y);let v=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);if(s.shaderSource(v,b),s.compileShader(v),!s.getShaderParameter(v,s.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${s.getShaderInfoLog(v)}`);s.attachShader(this.program,v),this.attributes={};let x={};this.numAttributes=d.length;for(let t=0;t<this.numAttributes;t++)d[t]&&(s.bindAttribLocation(this.program,t,d[t]),this.attributes[d[t]]=t);if(s.linkProgram(this.program),!s.getProgramParameter(this.program,s.LINK_STATUS))throw Error(`Program failed to link: ${s.getProgramInfoLog(this.program)}`);s.deleteShader(v),s.deleteShader(y);for(let t=0;t<f.length;t++){let e=f[t];if(e&&!x[e]){let t=s.getUniformLocation(this.program,e);t&&(x[e]=t)}}this.fixedUniforms=r(t,x),this.terrainUniforms=((t,i)=>({u_depth:new e.aG(t,i.u_depth),u_terrain:new e.aG(t,i.u_terrain),u_terrain_dim:new e.aH(t,i.u_terrain_dim),u_terrain_matrix:new e.aI(t,i.u_terrain_matrix),u_terrain_unpack:new e.aJ(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.aH(t,i.u_terrain_exaggeration)}))(t,x),this.binderUniforms=n?n.getUniforms(t,x):[]}draw(t,e,i,n,r,a,o,s,l,c,d,u,h,p,m,f,g,_){let b=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(n),t.setColorMode(r),t.setCullFace(a),s)for(let e in t.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,s.depthTexture),t.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,s.texture),this.terrainUniforms)this.terrainUniforms[e].set(s[e]);for(let t in this.fixedUniforms)this.fixedUniforms[t].set(o[t]);m&&m.setUniforms(t,this.binderUniforms,h,{zoom:p});let y=0;switch(e){case b.LINES:y=2;break;case b.TRIANGLES:y=3;break;case b.LINE_STRIP:y=1}for(let i of u.get()){let n=i.vaos||(i.vaos={});(n[l]||(n[l]=new t4)).bind(t,this,c,m?m.getPaintVertexBuffers():[],d,i.vertexOffset,f,g,_),b.drawElements(e,i.primitiveLength*y,b.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function t8(t,e,i){let n=1/tM(i,1,e.transform.tileZoom),r=Math.pow(2,i.tileID.overscaledZ),a=i.tileSize*Math.pow(2,e.transform.tileZoom)/r,o=a*(i.tileID.canonical.x+i.tileID.wrap*r),s=a*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[n,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}let t9=(t,i,n,r)=>{var a,o,s,l,c,d,u;let h=i.style.light,p=h.properties.get("position"),m=[p.x,p.y,p.z],f=(a=new e.A(9),e.A!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a);"viewport"===h.properties.get("anchor")&&(s=Math.sin(o=-i.transform.angle),l=Math.cos(o),f[0]=l,f[1]=s,f[2]=0,f[3]=-s,f[4]=l,f[5]=0,f[6]=0,f[7]=0,f[8]=1),c=m[0],d=m[1],u=m[2],m[0]=c*f[0]+d*f[3]+u*f[6],m[1]=c*f[1]+d*f[4]+u*f[7],m[2]=c*f[2]+d*f[5]+u*f[8];let g=h.properties.get("color");return{u_matrix:t,u_lightpos:m,u_lightintensity:h.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+n,u_opacity:r}},et=(t,i,n,r,a,o,s)=>e.e(t9(t,i,n,r),t8(o,i,s),{u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8}),ee=t=>({u_matrix:t}),ei=(t,i,n,r)=>e.e(ee(t),t8(n,i,r)),en=(t,e)=>({u_matrix:t,u_world:e}),er=(t,i,n,r,a)=>e.e(ei(t,i,n,r),{u_world:a}),ea=(t,e,i,n)=>{let r,a,o=t.transform;if("map"===n.paint.get("circle-pitch-alignment")){let t=tM(i,1,o.zoom);r=!0,a=[t,t]}else r=!1,a=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+r,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},eo=(t,e,i)=>{let n=tM(i,1,e.zoom),r=Math.pow(2,e.zoom-i.tileID.overscaledZ),a=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:n,u_extrude_scale:[e.pixelsToGLUnits[0]/(n*r),e.pixelsToGLUnits[1]/(n*r)],u_overscale_factor:a}},es=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),el=t=>({u_matrix:t}),ec=(t,e,i,n)=>({u_matrix:t,u_extrude_scale:tM(e,1,i),u_intensity:n}),ed=(t,e,i,n)=>{let r=t.transform;return{u_matrix:ef(t,e,i,n),u_ratio:1/tM(e,1,r.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/r.pixelsToGLUnits[0],1/r.pixelsToGLUnits[1]]}},eu=(t,i,n,r,a)=>e.e(ed(t,i,n,a),{u_image:0,u_image_height:r}),eh=(t,e,i,n,r)=>{let a=t.transform,o=em(e,a);return{u_matrix:ef(t,e,i,r),u_texsize:e.imageAtlasTexture.size,u_ratio:1/tM(e,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[o,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},ep=(t,i,n,r,a,o)=>{let s=t.lineAtlas,l=em(i,t.transform),c="round"===n.layout.get("line-cap"),d=s.getDash(r.from,c),u=s.getDash(r.to,c),h=d.width*a.fromScale,p=u.width*a.toScale;return e.e(ed(t,i,n,o),{u_patternscale_a:[l/h,-d.height/2],u_patternscale_b:[l/p,-u.height/2],u_sdfgamma:s.width/(256*Math.min(h,p)*t.pixelRatio)/2,u_image:0,u_tex_y_a:d.y,u_tex_y_b:u.y,u_mix:a.t})};function em(t,e){return 1/tM(t,1,e.tileZoom)}function ef(t,e,i,n){return t.translatePosMatrix(n?n.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}let eg=(t,e,i,n,r)=>{var a,o;return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(o=r.paint.get("raster-saturation"))>0?1-1/(1.001-o):-o,u_contrast_factor:(a=r.paint.get("raster-contrast"))>0?1/(1-a):1+a,u_spin_weights:function(t){let e=Math.sin(t*=Math.PI/180),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}(r.paint.get("raster-hue-rotate"))}},e_=(t,e,i,n,r,a,o,s,l,c)=>{let d=r.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:d.width/d.height,u_fade_change:r.options.fadeDuration?r.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+n,u_texsize:c,u_texture:0}},eb=(t,i,n,r,a,o,s,l,c,d,u)=>{let h=a.transform;return e.e(e_(t,i,n,r,a,o,s,l,c,d),{u_gamma_scale:r?Math.cos(h._pitch)*h.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:+u})},ey=(t,i,n,r,a,o,s,l,c,d)=>e.e(eb(t,i,n,r,a,o,s,l,!0,c,!0),{u_texsize_icon:d,u_texture_icon:1}),ev=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),ex=(t,i,n,r,a,o)=>e.e(function(t,e,i,n){let r=i.imageManager.getPattern(t.from.toString()),a=i.imageManager.getPattern(t.to.toString()),{width:o,height:s}=i.imageManager.getPixelSize(),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,i.transform.tileZoom)/l,d=c*(n.tileID.canonical.x+n.tileID.wrap*l),u=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:r.tl,u_pattern_br_a:r.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[o,s],u_mix:e.t,u_pattern_size_a:r.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/tM(n,1,i.transform.tileZoom),u_pixel_coord_upper:[d>>16,u>>16],u_pixel_coord_lower:[65535&d,65535&u]}}(r,o,n,a),{u_matrix:t,u_opacity:i}),ew={fillExtrusion:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_lightpos:new e.aK(t,i.u_lightpos),u_lightintensity:new e.aH(t,i.u_lightintensity),u_lightcolor:new e.aK(t,i.u_lightcolor),u_vertical_gradient:new e.aH(t,i.u_vertical_gradient),u_opacity:new e.aH(t,i.u_opacity)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_lightpos:new e.aK(t,i.u_lightpos),u_lightintensity:new e.aH(t,i.u_lightintensity),u_lightcolor:new e.aK(t,i.u_lightcolor),u_vertical_gradient:new e.aH(t,i.u_vertical_gradient),u_height_factor:new e.aH(t,i.u_height_factor),u_image:new e.aG(t,i.u_image),u_texsize:new e.aL(t,i.u_texsize),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade),u_opacity:new e.aH(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_image:new e.aG(t,i.u_image),u_texsize:new e.aL(t,i.u_texsize),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_world:new e.aL(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_world:new e.aL(t,i.u_world),u_image:new e.aG(t,i.u_image),u_texsize:new e.aL(t,i.u_texsize),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_scale_with_map:new e.aG(t,i.u_scale_with_map),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_extrude_scale:new e.aL(t,i.u_extrude_scale),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_matrix:new e.aI(t,i.u_matrix)}),collisionBox:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pixels_to_tile_units:new e.aH(t,i.u_pixels_to_tile_units),u_extrude_scale:new e.aL(t,i.u_extrude_scale),u_overscale_factor:new e.aH(t,i.u_overscale_factor)}),collisionCircle:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_inv_matrix:new e.aI(t,i.u_inv_matrix),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_viewport_size:new e.aL(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.aM(t,i.u_color),u_matrix:new e.aI(t,i.u_matrix),u_overlay:new e.aG(t,i.u_overlay),u_overlay_scale:new e.aH(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.aH(t,i.u_extrude_scale),u_intensity:new e.aH(t,i.u_intensity),u_matrix:new e.aI(t,i.u_matrix)}),heatmapTexture:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_world:new e.aL(t,i.u_world),u_image:new e.aG(t,i.u_image),u_color_ramp:new e.aG(t,i.u_color_ramp),u_opacity:new e.aH(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_image:new e.aG(t,i.u_image),u_latrange:new e.aL(t,i.u_latrange),u_light:new e.aL(t,i.u_light),u_shadow:new e.aM(t,i.u_shadow),u_highlight:new e.aM(t,i.u_highlight),u_accent:new e.aM(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_image:new e.aG(t,i.u_image),u_dimension:new e.aL(t,i.u_dimension),u_zoom:new e.aH(t,i.u_zoom),u_unpack:new e.aJ(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels),u_image:new e.aG(t,i.u_image),u_image_height:new e.aH(t,i.u_image_height)}),linePattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_texsize:new e.aL(t,i.u_texsize),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_image:new e.aG(t,i.u_image),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade)}),lineSDF:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels),u_patternscale_a:new e.aL(t,i.u_patternscale_a),u_patternscale_b:new e.aL(t,i.u_patternscale_b),u_sdfgamma:new e.aH(t,i.u_sdfgamma),u_image:new e.aG(t,i.u_image),u_tex_y_a:new e.aH(t,i.u_tex_y_a),u_tex_y_b:new e.aH(t,i.u_tex_y_b),u_mix:new e.aH(t,i.u_mix)}),raster:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_tl_parent:new e.aL(t,i.u_tl_parent),u_scale_parent:new e.aH(t,i.u_scale_parent),u_buffer_scale:new e.aH(t,i.u_buffer_scale),u_fade_t:new e.aH(t,i.u_fade_t),u_opacity:new e.aH(t,i.u_opacity),u_image0:new e.aG(t,i.u_image0),u_image1:new e.aG(t,i.u_image1),u_brightness_low:new e.aH(t,i.u_brightness_low),u_brightness_high:new e.aH(t,i.u_brightness_high),u_saturation_factor:new e.aH(t,i.u_saturation_factor),u_contrast_factor:new e.aH(t,i.u_contrast_factor),u_spin_weights:new e.aK(t,i.u_spin_weights)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.aG(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aG(t,i.u_is_size_feature_constant),u_size_t:new e.aH(t,i.u_size_t),u_size:new e.aH(t,i.u_size),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pitch:new e.aH(t,i.u_pitch),u_rotate_symbol:new e.aG(t,i.u_rotate_symbol),u_aspect_ratio:new e.aH(t,i.u_aspect_ratio),u_fade_change:new e.aH(t,i.u_fade_change),u_matrix:new e.aI(t,i.u_matrix),u_label_plane_matrix:new e.aI(t,i.u_label_plane_matrix),u_coord_matrix:new e.aI(t,i.u_coord_matrix),u_is_text:new e.aG(t,i.u_is_text),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_texsize:new e.aL(t,i.u_texsize),u_texture:new e.aG(t,i.u_texture)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.aG(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aG(t,i.u_is_size_feature_constant),u_size_t:new e.aH(t,i.u_size_t),u_size:new e.aH(t,i.u_size),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pitch:new e.aH(t,i.u_pitch),u_rotate_symbol:new e.aG(t,i.u_rotate_symbol),u_aspect_ratio:new e.aH(t,i.u_aspect_ratio),u_fade_change:new e.aH(t,i.u_fade_change),u_matrix:new e.aI(t,i.u_matrix),u_label_plane_matrix:new e.aI(t,i.u_label_plane_matrix),u_coord_matrix:new e.aI(t,i.u_coord_matrix),u_is_text:new e.aG(t,i.u_is_text),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_texsize:new e.aL(t,i.u_texsize),u_texture:new e.aG(t,i.u_texture),u_gamma_scale:new e.aH(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_is_halo:new e.aG(t,i.u_is_halo)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.aG(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aG(t,i.u_is_size_feature_constant),u_size_t:new e.aH(t,i.u_size_t),u_size:new e.aH(t,i.u_size),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pitch:new e.aH(t,i.u_pitch),u_rotate_symbol:new e.aG(t,i.u_rotate_symbol),u_aspect_ratio:new e.aH(t,i.u_aspect_ratio),u_fade_change:new e.aH(t,i.u_fade_change),u_matrix:new e.aI(t,i.u_matrix),u_label_plane_matrix:new e.aI(t,i.u_label_plane_matrix),u_coord_matrix:new e.aI(t,i.u_coord_matrix),u_is_text:new e.aG(t,i.u_is_text),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_texsize:new e.aL(t,i.u_texsize),u_texsize_icon:new e.aL(t,i.u_texsize_icon),u_texture:new e.aG(t,i.u_texture),u_texture_icon:new e.aG(t,i.u_texture_icon),u_gamma_scale:new e.aH(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_is_halo:new e.aG(t,i.u_is_halo)}),background:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_opacity:new e.aH(t,i.u_opacity),u_color:new e.aM(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_opacity:new e.aH(t,i.u_opacity),u_image:new e.aG(t,i.u_image),u_pattern_tl_a:new e.aL(t,i.u_pattern_tl_a),u_pattern_br_a:new e.aL(t,i.u_pattern_br_a),u_pattern_tl_b:new e.aL(t,i.u_pattern_tl_b),u_pattern_br_b:new e.aL(t,i.u_pattern_br_b),u_texsize:new e.aL(t,i.u_texsize),u_mix:new e.aH(t,i.u_mix),u_pattern_size_a:new e.aL(t,i.u_pattern_size_a),u_pattern_size_b:new e.aL(t,i.u_pattern_size_b),u_scale_a:new e.aH(t,i.u_scale_a),u_scale_b:new e.aH(t,i.u_scale_b),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.aH(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_texture:new e.aG(t,i.u_texture),u_ele_delta:new e.aH(t,i.u_ele_delta)}),terrainDepth:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ele_delta:new e.aH(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_texture:new e.aG(t,i.u_texture),u_terrain_coords_id:new e.aH(t,i.u_terrain_coords_id),u_ele_delta:new e.aH(t,i.u_ele_delta)})};class ek{constructor(t,e,i){this.context=t;let n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let e=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let eE={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class eC{constructor(t,e,i,n){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;let r=t.gl;this.buffer=r.createBuffer(),t.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){let n=e.attributes[this.attributes[i].name];void 0!==n&&t.enableVertexAttribArray(n)}}setVertexAttribPointers(t,e,i){for(let n=0;n<this.attributes.length;n++){let r=this.attributes[n],a=e.attributes[r.name];void 0!==a&&t.vertexAttribPointer(a,r.components,t[eE[r.type]],!1,this.itemSize,r.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let eA=new WeakMap;function eT(t){var e;if(eA.has(t))return eA.get(t);{let i=null==(e=t.getParameter(t.VERSION))?void 0:e.startsWith("WebGL 2.0");return eA.set(t,i),i}}class eI{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class eS extends eI{getDefault(){return e.aO.transparent}set(t){let e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class ez extends eI{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class eL extends eI{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class eM extends eI{getDefault(){return[!0,!0,!0,!0]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class eR extends eI{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class eP extends eI{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class eD extends eI{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class eO extends eI{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class eB extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class eF extends eI{getDefault(){return[0,1]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class eN extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class eV extends eI{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class eU extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class e$ extends eI{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class eH extends eI{getDefault(){return e.aO.transparent}set(t){let e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class eq extends eI{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ej extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class eG extends eI{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class eX extends eI{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class eZ extends eI{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class eW extends eI{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class eY extends eI{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class eK extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class eJ extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class eQ extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class e0 extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class e1 extends eI{getDefault(){return null}set(t){let e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class e2 extends eI{getDefault(){return null}set(t){var e;if(t===this.current&&!this.dirty)return;let i=this.gl;eT(i)?i.bindVertexArray(t):null==(e=i.getExtension("OES_vertex_array_object"))||e.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class e5 extends eI{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class e3 extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class e4 extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class e6 extends eI{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class e7 extends e6{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class e8 extends e6{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class e9 extends e6{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class it{constructor(t,e,i,n,r){this.context=t,this.width=e,this.height=i;let a=t.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new e7(t,o),n)this.depthAttachment=r?new e9(t,o):new e8(t,o);else if(r)throw Error("Stencil cannot be set without depth");if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error("Framebuffer is not complete")}destroy(){let t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){let e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class ie{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}ie.Replace=[1,0],ie.disabled=new ie(ie.Replace,e.aO.transparent,[!1,!1,!1,!1]),ie.unblended=new ie(ie.Replace,e.aO.transparent,[!0,!0,!0,!0]),ie.alphaBlended=new ie([1,771],e.aO.transparent,[!0,!0,!0,!0]);class ii{constructor(t){var e,i;if(this.gl=t,this.clearColor=new eS(this),this.clearDepth=new ez(this),this.clearStencil=new eL(this),this.colorMask=new eM(this),this.depthMask=new eR(this),this.stencilMask=new eP(this),this.stencilFunc=new eD(this),this.stencilOp=new eO(this),this.stencilTest=new eB(this),this.depthRange=new eF(this),this.depthTest=new eN(this),this.depthFunc=new eV(this),this.blend=new eU(this),this.blendFunc=new e$(this),this.blendColor=new eH(this),this.blendEquation=new eq(this),this.cullFace=new ej(this),this.cullFaceSide=new eG(this),this.frontFace=new eX(this),this.program=new eZ(this),this.activeTexture=new eW(this),this.viewport=new eY(this),this.bindFramebuffer=new eK(this),this.bindRenderbuffer=new eJ(this),this.bindTexture=new eQ(this),this.bindVertexBuffer=new e0(this),this.bindElementBuffer=new e1(this),this.bindVertexArray=new e2(this),this.pixelStoreUnpack=new e5(this),this.pixelStoreUnpackPremultiplyAlpha=new e3(this),this.pixelStoreUnpackFlipY=new e4(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),eT(t)){this.HALF_FLOAT=t.HALF_FLOAT;let n=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!=(e=t.RGBA16F)?e:null==n?void 0:n.RGBA16F_EXT,this.RGB16F=null!=(i=t.RGB16F)?i:null==n?void 0:n.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");let e=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==e?void 0:e.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(t,e){return new ek(this,t,e)}createVertexBuffer(t,e,i){return new eC(this,t,e,i)}createRenderbuffer(t,e,i){let n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),r}createFramebuffer(t,e,i,n){return new it(this,t,e,i,n)}clear({color:t,depth:e,stencil:i}){let n=this.gl,r=0;t&&(r|=n.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(r|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(r|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(r)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){e.aD(t.blendFunction,ie.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return eT(this.gl)?this.gl.createVertexArray():null==(t=this.gl.getExtension("OES_vertex_array_object"))?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var e;return eT(this.gl)?this.gl.deleteVertexArray(t):null==(e=this.gl.getExtension("OES_vertex_array_object"))?void 0:e.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class ir{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}ir.ReadOnly=!1,ir.ReadWrite=!0,ir.disabled=new ir(519,ir.ReadOnly,[0,1]);class ia{constructor(t,e,i,n,r,a){this.test=t,this.ref=e,this.mask=i,this.fail=n,this.depthFail=r,this.pass=a}}ia.disabled=new ia({func:519,mask:0},0,0,7680,7680,7680);class io{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}function is(t,i,n,r,a,o,l){var c;let d=t.context,u=d.gl,h=t.useProgram("collisionBox"),p=[],m=0,f=0;for(let s=0;s<r.length;s++){let c=r[s],g=i.getTile(c),_=g.getBucket(n);if(!_)continue;let b=c.posMatrix;0===a[0]&&0===a[1]||(b=t.translatePosMatrix(c.posMatrix,g,a,o));let y=l?_.textCollisionBox:_.iconCollisionBox,v=_.collisionCircleArray;if(v.length>0){let i=e.F(),n=b;e.aP(i,_.placementInvProjMatrix,t.transform.glCoordMatrix),e.aP(i,i,_.placementViewportMatrix),p.push({circleArray:v,circleOffset:f,transform:n,invTransform:i,coord:c}),m+=v.length/4,f=m}y&&h.draw(d,u.LINES,ir.disabled,ia.disabled,t.colorModeForRenderPass(),io.disabled,eo(b,t.transform,g),t.style.map.terrain&&t.style.map.terrain.getTerrainData(c),n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,null,y.collisionVertexBuffer)}if(!l||!p.length)return;let g=t.useProgram("collisionCircle"),_=new e.aQ;_.resize(4*m),_._trim();let b=0;for(let t of p)for(let e=0;e<t.circleArray.length/4;e++){let i=4*e,n=t.circleArray[i+0],r=t.circleArray[i+1],a=t.circleArray[i+2],o=t.circleArray[i+3];_.emplace(b++,n,r,a,o,0),_.emplace(b++,n,r,a,o,1),_.emplace(b++,n,r,a,o,2),_.emplace(b++,n,r,a,o,3)}(!s||s.length<2*m)&&(s=function(t){let i=2*t,n=new e.aS;n.resize(i),n._trim();for(let t=0;t<i;t++){let e=6*t;n.uint16[e+0]=4*t+0,n.uint16[e+1]=4*t+1,n.uint16[e+2]=4*t+2,n.uint16[e+3]=4*t+2,n.uint16[e+4]=4*t+3,n.uint16[e+5]=4*t+0}return n}(m));let y=d.createIndexBuffer(s,!0),v=d.createVertexBuffer(_,e.aR.members,!0);for(let i of p){let r={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(c=t.transform).cameraToCenterDistance,u_viewport_size:[c.width,c.height]};g.draw(d,u.TRIANGLES,ir.disabled,ia.disabled,t.colorModeForRenderPass(),io.disabled,r,t.style.map.terrain&&t.style.map.terrain.getTerrainData(i.coord),n.id,v,y,e.$.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}v.destroy(),y.destroy()}io.disabled=new io(!1,1029,2305),io.backCCW=new io(!0,1029,2305);let il=e.an(new Float32Array(16));function ic(t,i,n,r,a,o,s,l,c,d,u,h){let p=t.context,m=p.gl,f=t.transform,g="map"===l,_="map"===c,b="viewport"!==l&&"point"!==n.layout.get("symbol-placement"),y=g&&!_&&!b,v=!n.layout.get("symbol-sort-key").isConstant(),x=!1,w=t.depthModeForSublayer(0,ir.ReadOnly),k=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[];for(let l of r){let r=i.getTile(l),c=r.getBucket(n);if(!c)continue;let u=a?c.text:c.icon;if(!u||!u.segments.get().length||!u.hasVisibleVertices)continue;let h=u.programConfigurations.get(n.id),p=a||c.sdfIcons,w=a?c.textSizeData:c.iconSizeData,C=_||0!==f.pitch,A=t.useProgram(c.iconsInText&&a?"symbolTextAndIcon":p?"symbolSDF":"symbolIcon",h),T=e.ag(w,f.zoom),I=t.style.map.terrain&&t.style.map.terrain.getTerrainData(l),S,z,M,R,P=[0,0],D=null;if(a)z=r.glyphAtlasTexture,M=m.LINEAR,S=r.glyphAtlasTexture.size,c.iconsInText&&(P=r.imageAtlasTexture.size,D=r.imageAtlasTexture,R=C||t.options.rotating||t.options.zooming||"composite"===w.kind||"camera"===w.kind?m.LINEAR:m.NEAREST);else{let e=1!==n.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;z=r.imageAtlasTexture,M=p||t.options.rotating||t.options.zooming||e||C?m.LINEAR:m.NEAREST,S=r.imageAtlasTexture.size}let O=tM(r,1,t.transform.zoom),B=t_(l.posMatrix,_,g,t.transform,O),F=tb(l.posMatrix,_,g,t.transform,O),N=k&&c.hasTextData(),V="none"!==n.layout.get("icon-text-fit")&&N&&c.hasIconData();if(b){let i=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(l,e,i):null,r="map"===n.layout.get("text-rotation-alignment");!function(t,i,n,r,a,o,s,l,c,d){let u=r?t.textSizeData:t.iconSizeData,h=e.ag(u,n.transform.zoom),p=[256/n.width*2+1,256/n.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let f=t.lineVertexArray,g=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,_=n.transform.width/n.transform.height,b=!1;for(let r=0;r<g.length;r++){let y,v=g.get(r);if(v.hidden||v.writingMode===e.ah.vertical&&!b||(b=!1,d?(y=[v.anchorX,v.anchorY,d(v.anchorX,v.anchorY),1],e.af(y,y,i)):tz(y=[v.anchorX,v.anchorY,0,1],y,i),!function(t,e){let i=t[0]/t[3],n=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&n>=-e[1]&&n<=e[1]}(y,p))){tS(v.numGlyphs,m);continue}let x=tv(n.transform.cameraToCenterDistance,y[3]),w=e.ai(u,h,v),k=s?w/x:w*x,E=new e.P(v.anchorX,v.anchorY),C=ty(E,a,d).point,A={projections:{},offsets:{}},T=tk(v,k,!1,l,i,a,o,t.glyphOffsetArray,f,m,C,E,A,_,c,d);b=T.useVertical,(T.notEnoughRoom||b||T.needsFlipping&&tk(v,k,!0,l,i,a,o,t.glyphOffsetArray,f,m,C,E,A,_,c,d).notEnoughRoom)&&tS(v.numGlyphs,m)}r?t.text.dynamicLayoutVertexBuffer.updateData(m):t.icon.dynamicLayoutVertexBuffer.updateData(m)}(c,l.posMatrix,t,a,B,F,_,d,r,i)}let U=t.translatePosMatrix(l.posMatrix,r,o,s),$=b||a&&k||V?il:B,H=t.translatePosMatrix(F,r,o,s,!0),q=p&&0!==n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1),j={program:A,buffers:u,uniformValues:p?c.iconsInText?ey(w.kind,T,y,_,t,U,$,H,S,P):eb(w.kind,T,y,_,t,U,$,H,a,S,!0):e_(w.kind,T,y,_,t,U,$,H,a,S),atlasTexture:z,atlasTextureIcon:D,atlasInterpolation:M,atlasInterpolationIcon:R,isSDF:p,hasHalo:q};if(v&&c.canOverlap)for(let t of(x=!0,u.segments.get()))E.push({segments:new e.$([t]),sortKey:t.sortKey,state:j,terrainData:I});else E.push({segments:u.segments,sortKey:0,state:j,terrainData:I})}for(let e of(x&&E.sort((t,e)=>t.sortKey-e.sortKey),E)){let i=e.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){let r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,id(i.buffers,e.segments,n,t,i.program,w,u,h,r,e.terrainData)),r.u_is_halo=0}id(i.buffers,e.segments,n,t,i.program,w,u,h,i.uniformValues,e.terrainData)}}function id(t,e,i,n,r,a,o,s,l,c){let d=n.context;r.draw(d,d.gl.TRIANGLES,a,o,s,io.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,n.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function iu(t,e,i,n,r){if(!i||!n||!n.imageAtlas)return;let a=n.imageAtlas.patternPositions,o=a[i.to.toString()],s=a[i.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let t=r.getPaintProperty(e);o=a[t],s=a[t]}o&&s&&t.setConstantPatternPositions(o,s)}function ih(t,e,i,n,r,a,o){let s,l,c,d,u,h=t.context.gl,p="fill-pattern",m=i.paint.get(p),f=m&&m.constantOr(1),g=i.getCrossfadeParameters();o?(l=f&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",s=h.LINES):(l=f?"fillPattern":"fill",s=h.TRIANGLES);let _=m.constantOr(null);for(let m of n){let n=e.getTile(m);if(f&&!n.patternsLoaded())continue;let b=n.getBucket(i);if(!b)continue;let y=b.programConfigurations.get(i.id),v=t.useProgram(l,y),x=t.style.map.terrain&&t.style.map.terrain.getTerrainData(m);f&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),y.updatePaintBuffers(g)),iu(y,p,_,n,i);let w=x?m:null,k=t.translatePosMatrix(w?w.posMatrix:m.posMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(o){d=b.indexBuffer2,u=b.segments2;let e=[h.drawingBufferWidth,h.drawingBufferHeight];c="fillOutlinePattern"===l&&f?er(k,t,g,n,e):en(k,e)}else d=b.indexBuffer,u=b.segments,c=f?ei(k,t,g,n):ee(k);v.draw(t.context,s,r,t.stencilModeForClipping(m),a,io.disabled,c,x,i.id,b.layoutVertexBuffer,d,u,i.paint,t.transform.zoom,y)}}function ip(t,e,i,n,r,a,o){let s=t.context,l=s.gl,c="fill-extrusion-pattern",d=i.paint.get(c),u=d.constantOr(1),h=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity"),m=d.constantOr(null);for(let d of n){let n=e.getTile(d),f=n.getBucket(i);if(!f)continue;let g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(d),_=f.programConfigurations.get(i.id),b=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",_);u&&(t.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),_.updatePaintBuffers(h)),iu(_,c,m,n,i);let y=t.translatePosMatrix(d.posMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),x=u?et(y,t,v,p,d,h,n):t9(y,t,v,p);b.draw(s,s.gl.TRIANGLES,r,a,o,io.backCCW,x,g,i.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,i.paint,t.transform.zoom,_,t.style.map.terrain&&f.centroidVertexBuffer)}}let im=new e.aO(1,0,0,1),ig=new e.aO(0,1,0,1),i_=new e.aO(0,0,1,1),ib=new e.aO(1,0,1,1),iy=new e.aO(0,1,1,1);function iv(t,e,i,n){iw(t,0,e+i/2,t.transform.width,i,n)}function ix(t,e,i,n){iw(t,e-i/2,0,i,t.transform.height,n)}function iw(t,e,i,n,r,a){let o=t.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(e*t.pixelRatio,i*t.pixelRatio,n*t.pixelRatio,r*t.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function ik(t,e,i){let n=t.context,r=n.gl,a=t.colorModeForRenderPass(),o=new ir(r.LEQUAL,ir.ReadWrite,t.depthRangeFor3D),s=t.useProgram("terrain"),l=e.getTerrainMesh();for(let c of(n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]),i)){let i=t.renderToTexture.getTexture(c),d=e.getTerrainData(c.tileID);n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,i.texture);let u={u_matrix:t.transform.calculatePosMatrix(c.tileID.toUnwrapped()),u_texture:0,u_ele_delta:e.getMeshFrameDelta(t.transform.zoom)};s.draw(n,r.TRIANGLES,o,ia.disabled,a,io.backCCW,u,d,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}class iE{constructor(t,i){this.context=new ii(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=tu.maxUnderzooming+tu.maxOverzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new tK}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,i=new e.aV;i.emplaceBack(0,0),i.emplaceBack(e.W,0),i.emplaceBack(0,e.W),i.emplaceBack(e.W,e.W),this.tileExtentBuffer=t.createVertexBuffer(i,t1.members),this.tileExtentSegments=e.$.simpleSegment(0,0,4,2);let n=new e.aV;n.emplaceBack(0,0),n.emplaceBack(e.W,0),n.emplaceBack(0,e.W),n.emplaceBack(e.W,e.W),this.debugBuffer=t.createVertexBuffer(n,t1.members),this.debugSegments=e.$.simpleSegment(0,0,4,5);let r=new e.Z;r.emplaceBack(0,0,0,0),r.emplaceBack(e.W,0,e.W,0),r.emplaceBack(0,e.W,0,e.W),r.emplaceBack(e.W,e.W,e.W,e.W),this.rasterBoundsBuffer=t.createVertexBuffer(r,J.members),this.rasterBoundsSegments=e.$.simpleSegment(0,0,4,2);let a=new e.aV;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(a,t1.members),this.viewportSegments=e.$.simpleSegment(0,0,4,2);let o=new e.aW;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let s=new e.aX;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);let l=this.context.gl;this.stencilClearMode=new ia({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)}clearStencil(){let t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let n=e.F();e.aN(n,0,this.width,this.height,0,0,1),e.J(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,i.TRIANGLES,ir.disabled,this.stencilClearMode,ie.disabled,io.disabled,el(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;let i=this.context,n=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(ie.disabled),i.setDepthMode(ir.disabled);let r=this.useProgram("clippingMask");for(let t of(this._tileClippingMaskIDs={},e)){let e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,a=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);r.draw(i,n.TRIANGLES,ir.disabled,new ia({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),ie.disabled,io.disabled,el(t.posMatrix),a,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,e=this.context.gl;return new ia({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){let e=this.context.gl;return new ia({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){let e=this.context.gl,i=t.sort((t,e)=>e.overscaledZ-t.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();let t={};for(let i=0;i<r;i++)t[i+n]=new ia({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=r,[t,i]}return[{[n]:ia.disabled},i]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let i=1/8;return new ie([t.CONSTANT_COLOR,t.ONE],new e.aO(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ie.unblended:ie.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return ir.disabled;let n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ir(i||this.context.gl.LEQUAL,e,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(u.now()),this.imageManager.beginFrame();let n=this.style._order,r=this.style.sourceCaches,a={},o={},s={};for(let t in r){let e=r[t];e.used&&e.prepare(this.context),a[t]=e.getVisibleCoordinates(),o[t]=a[t].slice().reverse(),s[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<n.length;t++)if(this.style._layers[n[t]].is3D()){this.opaquePassCutoff=t;break}for(let t of(this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen",n)){let e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let i=o[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,r[e.source],e,i)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?e.aO.black:e.aO.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){let t=this.style._layers[n[this.currentLayer]],e=r[t.source],i=a[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){let t=this.style._layers[n[this.currentLayer]],e=r[t.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(t))continue;let i=("symbol"===t.type?s:o)[t.source];this._renderTileClippingMasks(t,a[t.source]),this.renderLayer(this,e,t,i)}if(this.options.showTileBoundaries){let t=function(t,e){let i=null,n=Object.values(t._layers).flatMap(i=>i.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[]),r=n.filter(t=>"vector"===t.getSource().type),a=n.filter(t=>"vector"!==t.getSource().type),o=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};return r.forEach(t=>o(t)),i||a.forEach(t=>o(t)),i}(this.style,this.transform.zoom);t&&function(t,i,n){for(let r=0;r<n.length;r++)!function(t,i,n){let r=t.context,a=r.gl,o=n.posMatrix,s=t.useProgram("debug"),l=ir.disabled,c=ia.disabled,d=t.colorModeForRenderPass(),u="$debug",h=t.style.map.terrain&&t.style.map.terrain.getTerrainData(n);r.activeTexture.set(a.TEXTURE0);let p=i.getTileByID(n.key).latestRawTileData,m=Math.floor((p&&p.byteLength||0)/1024),f=512/Math.min(i.getTile(n).tileSize,512)*(n.overscaledZ/t.transform.zoom)*.5,g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();let i=t.debugOverlayCanvas,n=t.context.gl,r=t.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(e,5,5),r.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,`${g} ${m}kB`),s.draw(r,a.TRIANGLES,l,c,ie.alphaBlended,io.disabled,es(o,e.aO.transparent,f),null,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(r,a.LINE_STRIP,l,c,d,io.disabled,es(o,e.aO.red),h,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}(t,i,n[r])}(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){var e,i;let n=t.transform.padding;iv(t,t.transform.height-(n.top||0),3,im),iv(t,n.bottom||0,3,ig),ix(t,n.left||0,3,i_),ix(t,t.transform.width-(n.right||0),3,ib);let r=t.transform.centerPoint;e=r.x,i=t.transform.height-r.y,iw(t,e-1,i-10,2,20,iy),iw(t,e-10,i-1,20,2,iy)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;let i=this.terrainFacilitator.matrix,n=this.transform.projMatrix,r=this.terrainFacilitator.dirty;r||(r=t?!e.aY(i,n):!e.aZ(i,n)),r||(r=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),r&&(e.a_(i,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){let n=t.context,r=n.gl,a=ie.unblended,o=new ir(r.LEQUAL,ir.ReadWrite,[0,1]),s=i.getTerrainMesh(),l=i.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");for(let d of(n.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aO.transparent,depth:1}),l)){let e=i.getTerrainData(d.tileID),l={u_matrix:t.transform.calculatePosMatrix(d.tileID.toUnwrapped()),u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};c.draw(n,r.TRIANGLES,o,ia.disabled,a,io.backCCW,l,e,"terrain",s.vertexBuffer,s.indexBuffer,s.segments)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain),function(t,i){let n=t.context,r=n.gl,a=ie.unblended,o=new ir(r.LEQUAL,ir.ReadWrite,[0,1]),s=i.getTerrainMesh(),l=i.getCoordsTexture(),c=i.sourceCache.getRenderableTiles(),d=t.useProgram("terrainCoords");for(let u of(n.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aO.transparent,depth:1}),i.coordsIndex=[],c)){let e=i.getTerrainData(u.tileID);n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,l.texture);let c={u_matrix:t.transform.calculatePosMatrix(u.tileID.toUnwrapped()),u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};d.draw(n,r.TRIANGLES,o,ia.disabled,a,io.backCCW,c,e,"terrain",s.vertexBuffer,s.indexBuffer,s.segments),i.coordsIndex.push(u.tileID.key)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain))}renderLayer(t,i,n,r){if(!n.isHidden(this.transform.zoom)&&("background"===n.type||"custom"===n.type||(r||[]).length))switch(this.id=n.id,n.type){case"symbol":!function(t,i,n,r,a){if("translucent"!==t.renderPass)return;let o=ia.disabled,s=t.colorModeForRenderPass();(n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,n,r,a,o,s){let l=i.transform,c="map"===a,d="map"===o;for(let a of t){let t=r.getTile(a),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;let u=e.ag(o.textSizeData,l.zoom),h=tM(t,1,i.transform.zoom),p=t_(a.posMatrix,d,c,i.transform,h),m="none"!==n.layout.get("icon-text-fit")&&o.hasIconData();if(u){let n=Math.pow(2,l.zoom-t.tileID.overscaledZ);!function(t,i,n,r,a,o,s,l,c,d,u){let h=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,f={};p.clear();for(let m=0;m<h.length;m++){let g=h.get(m),_=g.hidden||!g.crossTileID||t.allowVerticalPlacement&&!g.placedOrientation?null:r[g.crossTileID];if(_){let r=new e.P(g.anchorX,g.anchorY),h=ty(r,n?s:o,u),m=tv(a.cameraToCenterDistance,h.signedDistanceFromCamera),b=e.ai(t.textSizeData,c,g)*m/e.ao;n&&(b*=t.tilePixelRatio/l);let{width:y,height:v,anchor:x,textOffset:w,textBoxScale:k}=_,E=function(t,i,n,r,a,o){let{horizontalAlign:s,verticalAlign:l}=e.at(t);return new e.P((-(s-.5)*i/a+r[0])*o,(-(l-.5)*n/a+r[1])*o)}(x,y,v,w,k,b),C=n?ty(r.add(E),o,u).point:h.point.add(i?E.rotate(-a.angle):E),A=t.allowVerticalPlacement&&g.placedOrientation===e.ah.vertical?Math.PI/2:0;for(let t=0;t<g.numGlyphs;t++)e.aj(p,C,A);d&&g.associatedIconIndex>=0&&(f[g.associatedIconIndex]={shiftedAnchor:C,angle:A})}else tS(g.numGlyphs,p)}if(d){m.clear();let i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){let n=i.get(t);if(n.hidden)tS(n.numGlyphs,m);else{let i=f[t];if(i)for(let t=0;t<n.numGlyphs;t++)e.aj(m,i.shiftedAnchor,i.angle);else tS(n.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(p)}(o,c,d,s,l,p,a.posMatrix,n,u,m,i.style.map.terrain?(t,e)=>i.style.map.terrain.getElevation(a,t,e):null)}}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),a),0!==n.paint.get("icon-opacity").constantOr(1)&&ic(t,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),o,s),0!==n.paint.get("text-opacity").constantOr(1)&&ic(t,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),o,s),i.map.showCollisionBoxes&&(is(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),is(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))}(t,i,n,r,this.style.placement.variableOffsets);break;case"circle":!function(t,i,n,r){if("translucent"!==t.renderPass)return;let a=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),s=n.paint.get("circle-stroke-opacity"),l=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;let c=t.context,d=c.gl,u=t.depthModeForSublayer(0,ir.ReadOnly),h=ia.disabled,p=t.colorModeForRenderPass(),m=[];for(let a=0;a<r.length;a++){let o=r[a],s=i.getTile(o),c=s.getBucket(n);if(!c)continue;let d=c.programConfigurations.get(n.id),u=t.useProgram("circle",d),h=c.layoutVertexBuffer,p=c.indexBuffer,f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(o),g={programConfiguration:d,program:u,layoutVertexBuffer:h,indexBuffer:p,uniformValues:ea(t,o,s,n),terrainData:f};if(l)for(let t of c.segments.get())m.push({segments:new e.$([t]),sortKey:t.sortKey,state:g});else m.push({segments:c.segments,sortKey:0,state:g})}for(let e of(l&&m.sort((t,e)=>t.sortKey-e.sortKey),m)){let{programConfiguration:i,program:r,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:l}=e.state;r.draw(c,d.TRIANGLES,u,h,p,io.disabled,s,l,n.id,a,o,e.segments,n.paint,t.transform.zoom,i)}}(t,i,n,r);break;case"heatmap":!function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){let a=t.context,o=a.gl,s=ia.disabled,l=new ie([o.ONE,o.ONE],e.aO.transparent,[!0,!0,!0,!0]);!function(t,e,i){let n=t.gl;t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let r=i.heatmapFbo;if(r)n.bindTexture(n.TEXTURE_2D,r.colorAttachment.get()),t.bindFramebuffer.set(r.framebuffer);else{let a=n.createTexture();n.bindTexture(n.TEXTURE_2D,a),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),r=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1,!1),function(t,e,i,n){var r,a;let o=t.gl,s=null!=(r=t.HALF_FLOAT)?r:o.UNSIGNED_BYTE,l=null!=(a=t.RGBA16F)?a:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,e.width/4,e.height/4,0,o.RGBA,s,null),n.colorAttachment.set(i)}(t,e,a,r)}}(a,t,n),a.clear({color:e.aO.transparent});for(let e=0;e<r.length;e++){let c=r[e];if(i.hasRenderableParent(c))continue;let d=i.getTile(c),u=d.getBucket(n);if(!u)continue;let h=u.programConfigurations.get(n.id),p=t.useProgram("heatmap",h),{zoom:m}=t.transform;p.draw(a,o.TRIANGLES,ir.disabled,s,l,io.disabled,ec(c.posMatrix,d,m,n.paint.get("heatmap-intensity")),null,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,t.transform.zoom,h)}a.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){let n=t.context,r=n.gl,a=i.heatmapFbo;if(!a)return;n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),n.activeTexture.set(r.TEXTURE1);let o=i.colorRampTexture;o||(o=i.colorRampTexture=new S(n,i.colorRamp,r.RGBA)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(n,r.TRIANGLES,ir.disabled,ia.disabled,t.colorModeForRenderPass(),io.disabled,((t,i,n,r)=>{let a=e.F();e.aN(a,0,t.width,t.height,0,0,1);let o=t.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(t,i),null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))}(t,i,n,r);break;case"line":!function(t,i,n,r){if("translucent"!==t.renderPass)return;let a=n.paint.get("line-opacity"),o=n.paint.get("line-width");if(0===a.constantOr(1)||0===o.constantOr(1))return;let s=t.depthModeForSublayer(0,ir.ReadOnly),l=t.colorModeForRenderPass(),c=n.paint.get("line-dasharray"),d=n.paint.get("line-pattern"),u=d.constantOr(1),h=n.paint.get("line-gradient"),p=n.getCrossfadeParameters(),m=u?"linePattern":c?"lineSDF":h?"lineGradient":"line",f=t.context,g=f.gl,_=!0;for(let a of r){let r=i.getTile(a);if(u&&!r.patternsLoaded())continue;let o=r.getBucket(n);if(!o)continue;let b=o.programConfigurations.get(n.id),y=t.context.program.get(),v=t.useProgram(m,b),x=_||v.program!==y,w=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a),k=d.constantOr(null);if(k&&r.imageAtlas){let t=r.imageAtlas,e=t.patternPositions[k.to.toString()],i=t.patternPositions[k.from.toString()];e&&i&&b.setConstantPatternPositions(e,i)}let E=w?a:null,C=u?eh(t,r,n,p,E):c?ep(t,r,n,c,p,E):h?eu(t,r,n,o.lineClipsArray.length,E):ed(t,r,n,E);if(u)f.activeTexture.set(g.TEXTURE0),r.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),b.updatePaintBuffers(p);else if(c&&(x||t.lineAtlas.dirty))f.activeTexture.set(g.TEXTURE0),t.lineAtlas.bind(f);else if(h){let r=o.gradients[n.id],s=r.texture;if(n.gradientVersion!==r.version){let l=256;if(n.stepInterpolant){let n=i.getSource().maxzoom,r=a.canonical.z===n?Math.ceil(1<<t.transform.maxZoom-a.canonical.z):1;l=e.ac(e.aT(o.maxLineLength/e.W*1024*r),256,f.maxTextureSize)}r.gradient=e.aU({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:r.gradient||void 0,clips:o.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new S(f,r.gradient,g.RGBA),r.version=n.gradientVersion,s=r.texture}f.activeTexture.set(g.TEXTURE0),s.bind(n.stepInterpolant?g.NEAREST:g.LINEAR,g.CLAMP_TO_EDGE)}v.draw(f,g.TRIANGLES,s,t.stencilModeForClipping(a),l,io.disabled,C,w,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,n.paint,t.transform.zoom,b,o.layoutVertexBuffer2),_=!1}}(t,i,n,r);break;case"fill":!function(t,i,n,r){let a=n.paint.get("fill-color"),o=n.paint.get("fill-opacity");if(0===o.constantOr(1))return;let s=t.colorModeForRenderPass(),l=n.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===a.constantOr(e.aO.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(t.renderPass===c){let e=t.depthModeForSublayer(1,"opaque"===t.renderPass?ir.ReadWrite:ir.ReadOnly);ih(t,i,n,r,e,s,!1)}if("translucent"===t.renderPass&&n.paint.get("fill-antialias")){let e=t.depthModeForSublayer(2*!!n.getPaintProperty("fill-outline-color"),ir.ReadOnly);ih(t,i,n,r,e,s,!0)}}(t,i,n,r);break;case"fill-extrusion":let a=n.paint.get("fill-extrusion-opacity");if(0!==a&&"translucent"===t.renderPass){let e=new ir(t.context.gl.LEQUAL,ir.ReadWrite,t.depthRangeFor3D);if(1!==a||n.paint.get("fill-extrusion-pattern").constantOr(1))ip(t,i,n,r,e,ia.disabled,ie.disabled),ip(t,i,n,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass());else{let a=t.colorModeForRenderPass();ip(t,i,n,r,e,ia.disabled,a)}}break;case"hillshade":!function(t,i,n,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;let a=t.context,o=t.depthModeForSublayer(0,ir.ReadOnly),s=t.colorModeForRenderPass(),[l,c]="translucent"===t.renderPass?t.stencilConfigForOverlap(r):[{},r];for(let r of c){let a=i.getTile(r);void 0!==a.needsHillshadePrepare&&a.needsHillshadePrepare&&"offscreen"===t.renderPass?function(t,i,n,r,a,o){let s=t.context,l=s.gl,c=i.dem;if(c&&c.data){let d=c.dim,u=c.stride,h=c.getPixels();if(s.activeTexture.set(l.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(u),i.demTexture){let t=i.demTexture;t.update(h,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new S(s,h,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);s.activeTexture.set(l.TEXTURE0);let p=i.fbo;if(!p){let t=new S(s,{width:d,height:d,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),(p=i.fbo=s.createFramebuffer(d,d,!0,!1)).colorAttachment.set(t.texture)}s.bindFramebuffer.set(p.framebuffer),s.viewport.set([0,0,d,d]),t.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,r,a,o,io.disabled,((t,i)=>{let n=i.stride,r=e.F();return e.aN(r,0,e.W,-e.W,0,0,1),e.H(r,r,[0,-e.W,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,c),null,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}}(t,a,n,o,ia.disabled,s):"translucent"===t.renderPass&&function(t,i,n,r,a,o,s){let l=t.context,c=l.gl,d=n.fbo;if(!d)return;let u=t.useProgram("hillshade"),h=t.style.map.terrain&&t.style.map.terrain.getTerrainData(i);l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,d.colorAttachment.get()),u.draw(l,c.TRIANGLES,a,o,s,io.disabled,((t,i,n,r)=>{let a=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),s=n.paint.get("hillshade-accent-color"),l=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(l-=t.transform.angle);let c=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(i.tileID.toUnwrapped(),c),u_image:0,u_latrange:function(t,i){let n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new e.Y(0,r/n).toLngLat().lat,new e.Y(0,(r+1)/n).toLngLat().lat]}(0,i.tileID),u_light:[n.paint.get("hillshade-exaggeration"),l],u_shadow:a,u_highlight:o,u_accent:s}})(t,n,r,h?i:null),h,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}(t,r,a,n,o,l[r.overscaledZ],s)}a.viewport.set([0,0,t.width,t.height])}(t,i,n,r);break;case"raster":!function(t,i,n,r){if("translucent"!==t.renderPass||0===n.paint.get("raster-opacity")||!r.length)return;let a=t.context,o=a.gl,s=i.getSource(),l=t.useProgram("raster"),c=t.colorModeForRenderPass(),[d,h]=s instanceof Q?[{},r]:t.stencilConfigForOverlap(r),p=h[h.length-1].overscaledZ,m=!t.options.moving;for(let r of h){let h,f,g=t.depthModeForSublayer(r.overscaledZ-p,1===n.paint.get("raster-opacity")?ir.ReadWrite:ir.ReadOnly,o.LESS),_=i.getTile(r);_.registerFadeDuration(n.paint.get("raster-fade-duration"));let b=i.findLoadedParent(r,0),y=function(t,i,n,r,a,o){let s=r.paint.get("raster-fade-duration");if(!o&&s>0){let r=u.now(),o=(r-t.timeAdded)/s,l=i?(r-i.timeAdded)/s:-1,c=n.getSource(),d=a.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-d)>Math.abs(t.tileID.overscaledZ-d),p=h&&t.refreshedUponExpiration?1:e.ac(h?o:1-l,0,1);return t.refreshedUponExpiration&&o>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}(_,b,i,n,t.transform,t.style.map.terrain),v="nearest"===n.paint.get("raster-resampling")?o.NEAREST:o.LINEAR;a.activeTexture.set(o.TEXTURE0),_.texture.bind(v,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),a.activeTexture.set(o.TEXTURE1),b?(b.texture.bind(v,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),h=Math.pow(2,b.tileID.overscaledZ-_.tileID.overscaledZ),f=[_.tileID.canonical.x*h%1,_.tileID.canonical.y*h%1]):_.texture.bind(v,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST);let x=t.style.map.terrain&&t.style.map.terrain.getTerrainData(r),w=x?r:null,k=eg(w?w.posMatrix:t.transform.calculatePosMatrix(r.toUnwrapped(),m),f||[0,0],h||1,y,n);s instanceof Q?l.draw(a,o.TRIANGLES,g,ia.disabled,c,io.disabled,k,x,n.id,s.boundsBuffer,t.quadTriangleIndexBuffer,s.boundsSegments):l.draw(a,o.TRIANGLES,g,d[r.overscaledZ],c,io.disabled,k,x,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}}(t,i,n,r);break;case"background":!function(t,e,i,n){let r=i.paint.get("background-color"),a=i.paint.get("background-opacity");if(0===a)return;let o=t.context,s=o.gl,l=t.transform,c=l.tileSize,d=i.paint.get("background-pattern");if(t.isPatternMissing(d))return;let u=!d&&1===r.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;let h=ia.disabled,p=t.depthModeForSublayer(0,"opaque"===u?ir.ReadWrite:ir.ReadOnly),m=t.colorModeForRenderPass(),f=t.useProgram(d?"backgroundPattern":"background"),g=n||l.coveringTiles({tileSize:c,terrain:t.style.map.terrain});d&&(o.activeTexture.set(s.TEXTURE0),t.imageManager.bind(t.context));let _=i.getCrossfadeParameters();for(let e of g){let l=n?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),u=d?ex(l,a,t,d,{tileID:e,tileSize:c},_):ev(l,a,r),g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);f.draw(o,s.TRIANGLES,p,h,m,io.disabled,u,g,i.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}}(t,0,n,r);break;case"custom":let o=t.context,s=n.implementation;if("offscreen"===t.renderPass){let e=s.prerender;e&&(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),e.call(s,o.gl,t.transform.customLayerMatrix()),o.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(ia.disabled);let e="3d"===s.renderingMode?new ir(t.context.gl.LEQUAL,ir.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,ir.ReadOnly);o.setDepthMode(e),s.render(o.gl,t.transform.customLayerMatrix()),o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}}translatePosMatrix(t,i,n,r,a){if(!n[0]&&!n[1])return t;let o=a?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){let t=Math.sin(o),e=Math.cos(o);n=[n[0]*e-n[1]*t,n[0]*t+n[1]*e]}let s=[a?n[0]:tM(i,n[0],this.transform.zoom),a?n[1]:tM(i,n[1],this.transform.zoom),0],l=new Float32Array(16);return e.H(l,t,s),l}saveTileTexture(t){let e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};let i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new t7(this.context,t5[t],e,ew[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new S(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class iC{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,i,n){let r=Math.pow(2,n),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(n=>{let a=1/(n=e.af([],n,t))[3]/i*r;return e.a$(n,n,[a,a,1/n[3],a])}),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(t=>{var e,i,n,r,o,s,l,c,d,u,h,p,m,f,g,_;let b=(h=[],m=(i=[],n=A([],a[t[0]],a[t[1]]),r=A([],a[t[2]],a[t[1]]),o=n[0],s=n[1],l=n[2],c=r[0],d=r[1],u=r[2],i[0]=s*u-l*d,i[1]=l*c-o*u,i[2]=o*d-s*c,p=i)[0],(_=m*m+(f=p[1])*f+(g=p[2])*g)>0&&(_=1/Math.sqrt(_)),h[0]=p[0]*_,h[1]=p[1]*_,h[2]=p[2]*_,h),y=-(b[0]*(e=a[t[1]])[0]+b[1]*e[1]+b[2]*e[2]);return b.concat(y)});return new iC(a,o)}}class iA{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max))}quadrant(t){let e=[t%2==0,t<2],i=x(this.min),n=x(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],n[t]=e[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new iA(i,n)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){let i=[[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]],n=!0;for(let r=0;r<t.planes.length;r++){let a=t.planes[r],o=0;for(let t=0;t<i.length;t++)e.b0(a,i[t])>=0&&o++;if(0===o)return 0;o!==i.length&&(n=!1)}if(n)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;r<t.points.length;r++){let a=t.points[r][e]-this.min[e];i=Math.min(i,a),n=Math.max(n,a)}if(n<0||i>this.max[e]-this.min[e])return 0}return 1}}class iT{constructor(t=0,e=0,i=0,n=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(n)||n<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.z.number(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.z.number(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.z.number(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.z.number(t.right,i.right,n)),this}getCenter(t,i){let n=e.ac((this.left+t-this.right)/2,0,t),r=e.ac((this.top+i-this.bottom)/2,0,i);return new e.P(n,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new iT(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class iI{constructor(t,i,n,r,a){this.tileSize=512,this._renderWorldCopies=void 0===a||!!a,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setMaxBounds(),this.width=0,this.height=0,this._center=new e.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new iT,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){let t=new iI(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){var i,n,r,a,o,s,l,c,d,u;let h=-e.b1(t,-180,180)*Math.PI/180;this.angle!==h&&(this._unmodified=!1,this.angle=h,this._calcMatrices(),this.rotationMatrix=(i=new e.A(4),e.A!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),n=this.rotationMatrix,r=this.rotationMatrix,a=this.angle,o=r[0],s=r[1],l=r[2],c=r[3],d=Math.sin(a),u=Math.cos(a),n[0]=o*u+l*d,n[1]=s*u+c*d,n[2]=-(o*d)+l*u,n[3]=-(s*d)+c*u)}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let i=e.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){let e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){return Math.max(0,(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize)))}getVisibleUnwrappedCoordinates(t){let i=[new e.b2(0,t)];if(this._renderWorldCopies){let n=this.pointCoordinate(new e.P(0,0)),r=this.pointCoordinate(new e.P(this.width,0)),a=this.pointCoordinate(new e.P(this.width,this.height)),o=this.pointCoordinate(new e.P(0,this.height)),s=Math.floor(Math.min(n.x,r.x,a.x,o.x)),l=Math.floor(Math.max(n.x,r.x,a.x,o.x));for(let n=s-1;n<=l+1;n++)0!==n&&i.push(new e.b2(n,t))}return i}coveringTiles(t){var i,n;let r=this.coveringZoomLevel(t),a=r;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);let o=this.pointCoordinate(this.getCameraPoint()),s=e.Y.fromLngLat(this.center),l=Math.pow(2,r),c=[l*o.x,l*o.y,0],d=[l*s.x,l*s.y,0],u=iC.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r),h=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(h=r);let p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,m=t=>({aabb:new iA([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),f=[],g=[],_=r,b=t.reparseOverscaled?a:r;if(this._renderWorldCopies)for(let t=1;t<=3;t++)f.push(m(-t)),f.push(m(t));for(f.push(m(0));f.length>0;){let r=f.pop(),a=r.x,o=r.y,s=r.fullyVisible;if(!s){let t=r.aabb.intersects(u);if(0===t)continue;s=2===t}let l=t.terrain?c:d,m=Math.max(Math.abs(r.aabb.distanceX(l)),Math.abs(r.aabb.distanceY(l)));if(r.zoom===_||m>p+(1<<_-r.zoom)-2&&r.zoom>=h){let t=_-r.zoom,i=c[0]-.5-(a<<t),n=c[1]-.5-(o<<t);g.push({tileID:new e.Q(r.zoom===_?b:r.zoom,r.wrap,r.zoom,a,o),distanceSq:T([d[0]-.5-a,d[1]-.5-o]),tileDistanceToCamera:Math.sqrt(i*i+n*n)})}else for(let l=0;l<4;l++){let c=(a<<1)+l%2,d=(o<<1)+(l>>1),u=r.zoom+1,h=r.aabb.quadrant(l);if(t.terrain){let a=new e.Q(u,r.wrap,u,c,d),o=t.terrain.getMinMaxElevation(a),s=null!=(i=o.minElevation)?i:this.elevation,l=null!=(n=o.maxElevation)?n:this.elevation;h=new iA([h.min[0],h.min[1],s],[h.max[0],h.max[1],l])}f.push({aabb:h,zoom:u,x:c,y:d,wrap:r.wrap,fullyVisible:s})}}return g.sort((t,e)=>t.distanceSq-e.distanceSq).map(t=>t.tileID)}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){let i=e.ac(t.lat,-85.051129,85.051129);return new e.P(e.N(t.lng)*this.worldSize,e.O(i)*this.worldSize)}unproject(t){return new e.Y(t.x/this.worldSize,t.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(t){let i=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,r=this.pointLocation(this.centerPoint,t),a=t.getElevationForLngLatZoom(r,this.tileZoom);if(!(this.elevation-a))return;let o=Math.cos(this._pitch)*this.cameraToCenterDistance/(n+i-a)/e.b3(1,r.lat),s=this.scaleZoom(o/this.tileSize);this._elevation=a,this._center=r,this.zoom=s}setLocationAtPoint(t,i){let n=this.pointCoordinate(i),r=this.pointCoordinate(this.centerPoint),a=this.locationCoordinate(t),o=new e.Y(a.x-(n.x-r.x),a.y-(n.y-r.y));this.center=this.coordinateLocation(o),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return e.Y.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,i){if(i){let e=i.pointCoordinate(t);if(null!=e)return e}let n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];e.af(n,n,this.pixelMatrixInverse),e.af(r,r,this.pixelMatrixInverse);let a=n[3],o=r[3],s=n[1]/a,l=r[1]/o,c=n[2]/a,d=r[2]/o,u=c===d?0:(0-c)/(d-c);return new e.Y(e.z.number(n[0]/a,r[0]/o,u)/this.worldSize,e.z.number(s,l,u)/this.worldSize)}coordinatePoint(t,i=0,n=this.pixelMatrix){let r=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.af(r,r,n),new e.P(r[0]/r[3],r[1]/r[3])}getBounds(){let t=Math.max(0,this.height/2-this.getHorizon());return(new G).extend(this.pointLocation(new e.P(0,t))).extend(this.pointLocation(new e.P(this.width,t))).extend(this.pointLocation(new e.P(this.width,this.height))).extend(this.pointLocation(new e.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new G([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(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,85.051129])}calculatePosMatrix(t,i=!1){let n=t.key,r=i?this._alignedPosMatrixCache:this._posMatrixCache;if(r[n])return r[n];let a=t.canonical,o=this.worldSize/this.zoomScale(a.z),s=a.x+Math.pow(2,a.z)*t.wrap,l=e.an(new Float64Array(16));return e.H(l,l,[s*o,a.y*o,0]),e.J(l,l,[o/e.W,o/e.W,1]),e.K(l,i?this.alignedProjMatrix:this.projMatrix,l),r[n]=new Float32Array(l),r[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,i){let n,r;i=e.ac(+i,this.minZoom,this.maxZoom);let a={center:new e.M(t.lng,t.lat),zoom:i},o=this.lngRange;this._renderWorldCopies||null!==o||(o=[-(180-1e-10),180-1e-10]);let s=this.tileSize*this.zoomScale(a.zoom),l=0,c=s,d=0,u=s,h=0,p=0,{x:m,y:f}=this.size;if(this.latRange){let t=this.latRange;l=e.O(t[1])*s,(c=e.O(t[0])*s)-l<f&&(h=f/(c-l))}o&&(d=e.b1(e.N(o[0])*s,0,s),(u=e.b1(e.N(o[1])*s,0,s))<d&&(u+=s),u-d<m&&(p=m/(u-d)));let{x:g,y:_}=this.project.call({worldSize:s},t),b=Math.max(p||0,h||0);if(b){let t=new e.P(p?(u+d)/2:g,h?(c+l)/2:_);return a.center=this.unproject.call({worldSize:s},t).wrap(),a.zoom+=this.scaleZoom(b),a}if(this.latRange){let t=f/2;_-t<l&&(r=l+t),_+t>c&&(r=c-t)}if(o){let t=(d+u)/2,i=g;this._renderWorldCopies&&(i=e.b1(g,t-s/2,t+s/2));let r=m/2;i-r<d&&(n=d+r),i+r>u&&(n=u-r)}if(void 0!==n||void 0!==r){let t=new e.P(null!=n?n:g,null!=r?r:_);a.center=this.unproject.call({worldSize:s},t).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:e,zoom:i}=this.getConstrained(this.center,this.zoom);this.center=e,this.zoom=i,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;let t=this.centerOffset,i=this.point.x,n=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=e.b3(1,this.center.lat)*this.worldSize;let r=e.an(new Float64Array(16));e.J(r,r,[this.width/2,-this.height/2,1]),e.H(r,r,[1,-1,0]),this.labelPlaneMatrix=r,r=e.an(new Float64Array(16)),e.J(r,r,[1,-1,1]),e.H(r,r,[-1,-1,0]),e.J(r,r,[2/this.width,2/this.height,1]),this.glCoordMatrix=r;let a=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),o=Math.min(this.elevation,this.minElevationForCurrentTile),s=a-o*this._pixelPerMeter/Math.cos(this._pitch),l=o<0?s:a,c=Math.PI/2+this._pitch,d=this._fov*(.5+t.y/this.height),u=Math.sin(d)*l/Math.sin(e.ac(Math.PI-c-d,.01,Math.PI-.01)),h=this.getHorizon(),p=2*Math.atan(h/this.cameraToCenterDistance)*(.5+t.y/(2*h)),m=Math.min(u,Math.sin(p)*l/Math.sin(e.ac(Math.PI-c-p,.01,Math.PI-.01))),f=1.01*(Math.cos(Math.PI/2-this._pitch)*m+l),g=this.height/50;r=new Float64Array(16),e.b4(r,this._fov,this.width/this.height,g,f),r[8]=-(2*t.x)/this.width,r[9]=2*t.y/this.height,e.J(r,r,[1,-1,1]),e.H(r,r,[0,0,-this.cameraToCenterDistance]),e.b5(r,r,this._pitch),e.ad(r,r,this.angle),e.H(r,r,[-i,-n,0]),this.mercatorMatrix=e.J([],r,[this.worldSize,this.worldSize,this.worldSize]),e.J(r,r,[1,1,this._pixelPerMeter]),this.pixelMatrix=e.K(new Float64Array(16),this.labelPlaneMatrix,r),e.H(r,r,[0,0,-this.elevation]),this.projMatrix=r,this.invProjMatrix=e.ar([],r),this.pixelMatrix3D=e.K(new Float64Array(16),this.labelPlaneMatrix,r);let _=this.width%2/2,b=this.height%2/2,y=Math.cos(this.angle),v=Math.sin(this.angle),x=i-Math.round(i)+y*_+v*b,w=n-Math.round(n)+y*b+v*_,k=new Float64Array(r);if(e.H(k,k,[x>.5?x-1:x,w>.5?w-1:w,0]),this.alignedProjMatrix=k,!(r=e.ar(new Float64Array(16),this.pixelMatrix)))throw Error("failed to invert matrix");this.pixelMatrixInverse=r,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let t=this.pointCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.af(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}getCameraQueryGeometry(t){let i=this.getCameraPoint();if(1===t.length)return[t[0],i];{let n=i.x,r=i.y,a=i.x,o=i.y;for(let e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),a=Math.max(a,e.x),o=Math.max(o,e.y);return[new e.P(n,r),new e.P(a,r),new e.P(a,o),new e.P(n,o),new e.P(n,r)]}}lngLatToCameraDepth(t,i){let n=this.locationCoordinate(t),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return e.af(r,r,this.projMatrix),r[2]/r[3]}}function iS(t,e){let i,n=!1,r=null,a=null,o=()=>{r=null,n&&(t.apply(a,i),r=setTimeout(o,e),n=!1)};return(...t)=>(n=!0,a=this,i=t,r||o(),r)}class iz{constructor(t){this._getCurrentHash=()=>{let t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(t=>t.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(t.length>=3&&!t.some(t=>isNaN(t))){let e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}},this._updateHash=iS(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){let e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.pow(10,Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10)),r=Math.round(e.lng*n)/n,a=Math.round(e.lat*n)/n,o=this._map.getBearing(),s=this._map.getPitch(),l="";if(l+=t?`/${r}/${a}/${i}`:`${i}/${a}/${r}`,(o||s)&&(l+="/"+Math.round(10*o)/10),s&&(l+=`/${Math.round(s)}`),this._hashName){let t=this._hashName,e=!1,i=window.location.hash.slice(1).split("&").map(i=>{let n=i.split("=")[0];return n===t?(e=!0,`${n}=${l}`):i}).filter(t=>t);return e||i.push(`${t}=${l}`),`#${i.join("&")}`}return`#${l}`}}let iL={linearity:.3,easing:e.b6(0,0,.3,1)},iM=e.e({deceleration:2500,maxSpeed:1400},iL),iR=e.e({deceleration:20,maxSpeed:1400},iL),iP=e.e({deceleration:1e3,maxSpeed:360},iL),iD=e.e({deceleration:1e3,maxSpeed:90},iL);class iO{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:u.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,e=u.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);let n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){let a=iF(i.pan.mag(),n,e.e({},iM,t||{}));r.offset=i.pan.mult(a.amount/i.pan.mag()),r.center=this._map.transform.center,iB(r,a)}if(i.zoom){let t=iF(i.zoom,n,iR);r.zoom=this._map.transform.zoom+t.amount,iB(r,t)}if(i.bearing){let t=iF(i.bearing,n,iP);r.bearing=this._map.transform.bearing+e.ac(t.amount,-179,179),iB(r,t)}if(i.pitch){let t=iF(i.pitch,n,iD);r.pitch=this._map.transform.pitch+t.amount,iB(r,t)}if(r.zoom||r.bearing){let t=void 0===i.pinchAround?i.around:i.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(r,{noMoveStart:!0})}}function iB(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function iF(t,i,n){let{maxSpeed:r,linearity:a,deceleration:o}=n,s=e.ac(t*a/(i/1e3),-r,r),l=Math.abs(s)/(o*a);return{easing:n.easing,duration:1e3*l,amount:l/2*s}}class iN extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n,r={}){let a=h.mousePos(i.getCanvas(),n);super(t,e.e({point:a,lngLat:i.unproject(a),originalEvent:n},r)),this._defaultPrevented=!1,this.target=i}}class iV extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n){let r="touchend"===t?n.changedTouches:n.touches,a=h.touchPos(i.getCanvasContainer(),r),o=a.map(t=>i.unproject(t)),s=a.reduce((t,e,i,n)=>t.add(e.div(n.length)),new e.P(0,0));super(t,{points:a,point:s,lngLats:o,lngLat:i.unproject(s),originalEvent:n}),this._defaultPrevented=!1}}class iU extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class i${constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new iU(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new iN(t.type,this._map,t))}mouseup(t){this._map.fire(new iN(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new iN(t.type,this._map,t))}dblclick(t){return this._firePreventable(new iN(t.type,this._map,t))}mouseover(t){this._map.fire(new iN(t.type,this._map,t))}mouseout(t){this._map.fire(new iN(t.type,this._map,t))}touchstart(t){return this._firePreventable(new iV(t.type,this._map,t))}touchmove(t){this._map.fire(new iV(t.type,this._map,t))}touchend(t){this._map.fire(new iV(t.type,this._map,t))}touchcancel(t){this._map.fire(new iV(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iH{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new iN(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new iN("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new iN(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iq{constructor(t){this._map=t}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(t){return this.transform.pointLocation(e.P.convert(t),this._map.terrain)}}class ij{constructor(t,e){this._map=t,this._tr=new iq(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(h.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active||this._lastPos.equals(e)||!this._box&&e.dist(this._startPos)<this._clickTolerance)return;let i=this._startPos;this._lastPos=e,this._box||(this._box=h.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let n=Math.min(i.x,e.x),r=Math.max(i.x,e.x),a=Math.min(i.y,e.y),o=Math.max(i.y,e.y);h.setTransform(this._box,`translate(${n}px,${a}px)`),this._box.style.width=r-n+"px",this._box.style.height=o-a+"px"}mouseupWindow(t,i){if(!this._active||0!==t.button)return;let n=this._startPos;if(this.reset(),h.suppressClick(),n.x!==i.x||n.y!==i.y)return this._map.fire(new e.k("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(n,i,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.k(t,{originalEvent:i}))}}function iG(t,e){if(t.length!==e.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);let i={};for(let n=0;n<t.length;n++)i[t[n].identifier]=e[n];return i}class iX{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){let i=new e.P(0,0);for(let e of t)i._add(e);return i.div(t.length)}(i),this.touches=iG(n,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;let n=iG(i,e);for(let t in this.touches){let e=n[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class iZ{constructor(t){this.singleTap=new iX(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){let n=this.singleTap.touchend(t,e,i);if(n){let e=t.timeStamp-this.lastTime<500,i=!this.lastTap||30>this.lastTap.dist(n);if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class iW{constructor(t){this._tr=new iq(t),this._zoomIn=new iZ({numTouches:1,numTaps:2}),this._zoomOut=new iZ({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){let n=this._zoomIn.touchend(t,e,i),r=this._zoomOut.touchend(t,e,i),a=this._tr;return n?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(n)},{originalEvent:t})}):r?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(r)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class iY{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){let e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let n=e.length?e[0]:e;return!this._moved&&n.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=n,this._move(i,n))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&h.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let iK={0:1,2:2};class iJ{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){let e=h.mouseButton(t);this._eventButton=e}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){let i=iK[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return h.mouseButton(t)===this._eventButton}}class iQ{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}let i0=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=function(t){t.preventDefault()}},i1=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>new iY({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:new iJ({checkCorrectEvent:t=>0===h.mouseButton(t)&&t.ctrlKey||2===h.mouseButton(t)}),enable:t,assignEvents:i0}),i2=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>new iY({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new iJ({checkCorrectEvent:t=>0===h.mouseButton(t)&&t.ctrlKey||2===h.mouseButton(t)}),enable:t,assignEvents:i0});class i5{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this.minTouchs()))return t.preventDefault(),this._calculateTransform(t,e,i)}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this.minTouchs()&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,n){n.length>0&&(this._active=!0);let r=iG(n,i),a=new e.P(0,0),o=new e.P(0,0),s=0;for(let t in r){let e=r[t],i=this._touches[t];i&&(a._add(e),o._add(e.sub(i)),s++,r[t]=e)}if(this._touches=r,s<this.minTouchs()||!o.mag())return;let l=o.div(s);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class i3{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();let[n,r]=this._firstTwoTouches,a=i4(i,e,n),o=i4(i,e,r);if(!a||!o)return;let s=this._aroundCenter?null:a.add(o).div(2);return this._move([a,o],s,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;let[n,r]=this._firstTwoTouches,a=i4(i,e,n),o=i4(i,e,r);a&&o||(this._active&&h.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function i4(t,e,i){for(let n=0;n<t.length;n++)if(t[n].identifier===i)return e[n]}function i6(t,e){return Math.log(t/e)/Math.LN2}class i7 extends i3{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){let i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(.1>Math.abs(i6(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:i6(this._distance,i),pinchAround:e}}}function i8(t,e){return 180*t.angleWith(e)/Math.PI}class i9 extends i3{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e,i){let n=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:i8(this._vector,n),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let e=25/(Math.PI*this._minDiameter)*360;return Math.abs(i8(t,this._startVector))<e}}function nt(t){return Math.abs(t.y)>Math.abs(t.x)}class ne extends i3{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,nt(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let n=t[0].sub(this._lastPoints[0]),r=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:-((n.y+r.y)/2*.5)}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;let n=t.mag()>=2,r=e.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;let a=t.y>0==e.y>0;return nt(t)&&nt(e)&&a}}let ni=100,nn=15,nr=10;class na{constructor(t){this._tr=new iq(t),this._panStep=ni,this._bearingStep=nn,this._pitchStep=nr,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,n=0,r=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),r=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),r=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:no,zoom:e?Math.round(s.zoom)+e*(t.shiftKey?2:1):s.zoom,bearing:s.bearing+i*this._bearingStep,pitch:s.pitch+n*this._pitchStep,offset:[-r*this._panStep,-a*this._panStep],center:s.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function no(t){return t*(2-t)}class ns{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new iq(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!t[this._map.cooperativeGestures._bypassKey])return;let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,i=u.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%4.000244140625==0?this._type="wheel":0!==e&&4>Math.abs(e)?this._type="trackpad":n>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=200>Math.abs(n*e)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){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 i=h.mousePos(this._map.getCanvas(),t),n=this._tr;this._around=i.y>n.transform.height/2-n.transform.getHorizon()?e.M.convert(this._aroundCenter?n.center:n.unproject(i)):e.M.convert(n.center),this._aroundPoint=n.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let t=this._tr.transform;if(0!==this._delta){let e="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);let n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,n=this._startZoom,r=this._easing,a,o=!1;if("wheel"===this._type&&n&&r){let t=Math.min((u.now()-this._lastWheelEventTime)/200,1),s=r(t);a=e.z.number(n,i,s),t<1?this._frameId||(this._frameId=!0):o=!0}else a=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!o,zoomDelta:a-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.b7;if(this._prevEase){let t=this._prevEase,n=(u.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),a=.27/Math.sqrt(r*r+1e-4)*.01,o=Math.sqrt(.0729-a*a);i=e.b6(a,o,.25,1)}return this._prevEase={start:u.now(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class nl{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class nc{constructor(t){this._tr=new iq(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nd{constructor(){this._tap=new iZ({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(t,e,i){if(!this._swipePoint)if(this._tapTime){let n=e[0],r=t.timeStamp-this._tapTime<500,a=30>this._tapPoint.dist(n);r&&a?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let n=e[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,t.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{let n=this._tap.touchend(t,e,i);n&&(this._tapTime=t.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nu{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}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 nh{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class np{constructor(t,e,i,n){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}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 nm{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=e,this._container.appendChild(n);let r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(h.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(t){this._onCooperativeGesture(1===t.touches.length)}wheel(t){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!t[this._bypassKey])}_onCooperativeGesture(t){this._enabled&&t&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let nf=t=>t.zoom||t.drag||t.pitch||t.rotate;class ng extends e.k{}function n_(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class nb{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;let i="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},r={},a={},o=t.touches,s=o?this._getMapTouches(o):void 0,l=s?h.touchPos(this._map.getCanvas(),s):h.mousePos(this._map.getCanvas(),t);for(let{handlerName:o,handler:c,allowed:d}of this._handlers){let u;c.isEnabled()&&(this._blockedByActive(a,d,o)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,s),this.mergeHandlerResult(n,r,u,o,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(a[o]=c))}let c={};for(let t in this._previousActiveHandlers)a[t]||(c[t]=i);this._previousActiveHandlers=a,(Object.keys(c).length||n_(n))&&(this._changes.push([n,r,c]),this._triggerRenderFrame()),(Object.keys(a).length||n_(n))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:d}=n;d&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],d(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new iO(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);let i=this._el;for(let[t,e,n]of(this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]],this._listeners))h.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(let[t,e,i]of this._listeners)h.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){let e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new i$(e,t));let n=e.boxZoom=new ij(e,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();let r=e.cooperativeGestures=new nm(e,t.cooperativeGestures);this._add("cooperativeGestures",r),t.cooperativeGestures&&r.enable();let a=new iW(e),o=new nc(e);e.doubleClickZoom=new nl(o,a),this._add("tapZoom",a),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();let s=new nd;this._add("tapDragZoom",s);let l=e.touchPitch=new ne(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);let c=i1(t),d=i2(t);e.dragRotate=new nh(t,c,d),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",d,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();let u=(({enable:t,clickTolerance:e})=>new iY({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:new iJ({checkCorrectEvent:t=>0===h.mouseButton(t)&&!t.ctrlKey}),enable:t,assignEvents:i0}))(t),p=new i5(t,e);e.dragPan=new nu(i,u,p),this._add("mousePan",u),this._add("touchPan",p,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);let m=new i9,f=new i7;e.touchZoomRotate=new np(i,f,m,s),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);let g=e.scrollZoom=new ns(e,()=>this._triggerRenderFrame());this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);let _=e.keyboard=new na(e);this._add("keyboard",_),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new iH(e))}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!nf(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(let n in t)if(n!==i&&(!e||0>e.indexOf(n)))return!0;return!1}_getMapTouches(t){let e=[];for(let i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,n,r,a){if(!n)return;e.e(t,n);let o={handlerName:r,originalEvent:n.originalEvent||a};void 0!==n.zoomDelta&&(i.zoom=o),void 0!==n.panDelta&&(i.drag=o),void 0!==n.pitchDelta&&(i.pitch=o),void 0!==n.bearingDelta&&(i.rotate=o)}_applyChanges(){let t={},i={},n={};for(let[r,a,o]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),e.e(i,a),e.e(n,o);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,e,i){let n=this._map,r=n._getTransformForUpdate(),a=n.terrain;if(!(n_(t)||a&&this._terrainMovement))return this._fireEvents(e,i,!0);let{panDelta:o,zoomDelta:s,bearingDelta:l,pitchDelta:c,around:d,pinchAround:u}=t;void 0!==u&&(d=u),n._stop(!0),d=d||n.transform.centerPoint;let h=r.pointLocation(o?d.sub(o):d);l&&(r.bearing+=l),c&&(r.pitch+=c),s&&(r.zoom+=s),a?!this._terrainMovement&&(e.drag||e.zoom)?(this._terrainMovement=!0,this._map._elevationFreeze=!0,r.setLocationAtPoint(h,d),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,r.recalculateZoom(n.terrain)})):e.drag&&this._terrainMovement?r.center=r.pointLocation(r.centerPoint.sub(o)):r.setLocationAtPoint(h,d):r.setLocationAtPoint(h,d),n._applyUpdatedTransform(r),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,i,n){let r,a=nf(this._eventsInProgress),o=nf(t),s={};for(let e in t){let{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}for(let t in!a&&o&&this._fireEvent("movestart",o.originalEvent),s)this._fireEvent(t,s[t]);for(let e in o&&this._fireEvent("move",o.originalEvent),t){let{originalEvent:i}=t[e];this._fireEvent(e,i)}let l={};for(let t in this._eventsInProgress){let{handlerName:e,originalEvent:n}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],r=i[e]||n,l[`${t}end`]=r)}for(let t in l)this._fireEvent(t,l[t]);let c=nf(this._eventsInProgress);if(n&&(a||o)&&!c){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t&&(t.essential||!u.prefersReducedMotion)?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:r})):(this._map.fire(new e.k("moveend",{originalEvent:r})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.k(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new ng("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class ny extends e.E{constructor(t,e){super(),this._renderFrameCallback=()=>{let t=Math.min((u.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new e.M(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),n)}panTo(t,i,n){return this.easeTo(e.e({center:t},i),n)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,n){return this.easeTo(e.e({zoom:t},i),n)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,n){return this.easeTo(e.e({bearing:t},i),n)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(t,e){t=G.convert(t);let i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,i,n,r){let a={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=e.e({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){let t=r.padding;r.padding={top:t,bottom:t,right:t,left:t}}r.padding=e.e(a,r.padding);let o=this.transform,s=o.padding,l=new G(t,i),c=o.project(l.getNorthWest()),d=o.project(l.getNorthEast()),u=o.project(l.getSouthEast()),h=o.project(l.getSouthWest()),p=e.b8(-n),m=c.rotate(p),f=d.rotate(p),g=u.rotate(p),_=h.rotate(p),b=new e.P(Math.max(m.x,f.x,_.x,g.x),Math.max(m.y,f.y,_.y,g.y)),y=new e.P(Math.min(m.x,f.x,_.x,g.x),Math.min(m.y,f.y,_.y,g.y)),v=b.sub(y),x=(o.width-(s.left+s.right+r.padding.left+r.padding.right))/v.x,w=(o.height-(s.top+s.bottom+r.padding.top+r.padding.bottom))/v.y;if(w<0||x<0)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let k=Math.min(o.scaleZoom(o.scale*Math.min(x,w)),r.maxZoom),E=e.P.convert(r.offset),C=new e.P((r.padding.left-r.padding.right)/2,(r.padding.top-r.padding.bottom)/2).rotate(e.b8(n)),A=E.add(C).mult(o.scale/o.zoomScale(k));return{center:o.unproject(c.add(u).div(2).sub(A)),zoom:k,bearing:n}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,i,n,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(e.P.convert(t)),this.transform.pointLocation(e.P.convert(i)),n,r),r,a)}_fitInternal(t,i,n){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,n):this.flyTo(i,n)):this}jumpTo(t,i){this.stop();let n=this._getTransformForUpdate(),r=!1,a=!1,o=!1;return"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.M.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(a=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(o=!0,n.pitch=+t.pitch),null==t.padding||n.isPaddingEqual(t.padding)||(n.padding=t.padding),this._applyUpdatedTransform(n),this.fire(new e.k("movestart",i)).fire(new e.k("move",i)),r&&this.fire(new e.k("zoomstart",i)).fire(new e.k("zoom",i)).fire(new e.k("zoomend",i)),a&&this.fire(new e.k("rotatestart",i)).fire(new e.k("rotate",i)).fire(new e.k("rotateend",i)),o&&this.fire(new e.k("pitchstart",i)).fire(new e.k("pitch",i)).fire(new e.k("pitchend",i)),this.fire(new e.k("moveend",i))}calculateCameraOptionsFromTo(t,i,n,r=0){let a=e.Y.fromLngLat(t,i),o=e.Y.fromLngLat(n,r),s=o.x-a.x,l=o.y-a.y,c=o.z-a.z,d=Math.hypot(s,l,c);if(0===d)throw Error("Can't calculate camera options with same From and To");let u=Math.hypot(s,l),h=this.transform.scaleZoom(this.transform.cameraToCenterDistance/d/this.transform.tileSize),p=180*Math.atan2(s,-l)/Math.PI,m=180*Math.acos(u/d)/Math.PI;return m=c<0?90-m:90+m,{center:o.toLngLat(),zoom:h,pitch:m,bearing:p}}easeTo(t,i){var n;let r,a;this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.b7},t)).animate||!t.essential&&u.prefersReducedMotion)&&(t.duration=0);let o=this._getTransformForUpdate(),s=this.getZoom(),l=this.getBearing(),c=this.getPitch(),d=this.getPadding(),h="bearing"in t?this._normalizeBearing(t.bearing,l):l,p="pitch"in t?+t.pitch:c,m="padding"in t?t.padding:o.padding,f=e.P.convert(t.offset),g=o.centerPoint.add(f),_=o.pointLocation(g),{center:b,zoom:y}=o.getConstrained(e.M.convert(t.center||_),null!=(n=t.zoom)?n:s);this._normalizeCenter(b);let v=o.project(_),x=o.project(b).sub(v),w=o.zoomScale(y-s);t.around&&(r=e.M.convert(t.around),a=o.locationPoint(r));let k={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||y!==s,this._rotating=this._rotating||l!==h,this._pitching=this._pitching||p!==c,this._padding=!o.isPaddingEqual(m),this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,k),this.terrain&&this._prepareElevation(b),this._ease(n=>{if(this._zooming&&(o.zoom=e.z.number(s,y,n)),this._rotating&&(o.bearing=e.z.number(l,h,n)),this._pitching&&(o.pitch=e.z.number(c,p,n)),this._padding&&(o.interpolatePadding(d,m,n),g=o.centerPoint.add(f)),this.terrain&&!t.freezeElevation&&this._updateElevation(n),r)o.setLocationAtPoint(r,a);else{let t=o.zoomScale(o.zoom-s),e=Math.pow(y>s?Math.min(2,w):Math.max(.5,w),1-n),i=o.unproject(v.add(x.mult(n*e)).mult(t));o.setLocationAtPoint(o.renderWorldCopies?i.wrap():i,g)}this._applyUpdatedTransform(o),this._fireMoveEvents(i)},t=>{this.terrain&&this._finalizeElevation(),this._afterEase(i,t)},t),this}_prepareEase(t,i,n={}){this._moving=!0,i||n.moving||this.fire(new e.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.k("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){let e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.elevation=e.z.number(this._elevationStart,this._elevationTarget,t)}_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(t){if(!this.transformCameraUpdate)return;let e=t.clone(),{center:i,zoom:n,pitch:r,bearing:a,elevation:o}=this.transformCameraUpdate(e);i&&(e.center=i),void 0!==n&&(e.zoom=n),void 0!==r&&(e.pitch=r),void 0!==a&&(e.bearing=a),void 0!==o&&(e.elevation=o),this.transform.apply(e)}_fireMoveEvents(t){this.fire(new e.k("move",t)),this._zooming&&this.fire(new e.k("zoom",t)),this._rotating&&this.fire(new e.k("rotate",t)),this._pitching&&this.fire(new e.k("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;let n=this._zooming,r=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.k("zoomend",t)),r&&this.fire(new e.k("rotateend",t)),a&&this.fire(new e.k("pitchend",t)),this.fire(new e.k("moveend",t))}flyTo(t,i){var n;if(!t.essential&&u.prefersReducedMotion){let n=e.L(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.b7},t);let r=this._getTransformForUpdate(),a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l=this.getPadding(),c="bearing"in t?this._normalizeBearing(t.bearing,o):o,d="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:r.padding,p=e.P.convert(t.offset),m=r.centerPoint.add(p),f=r.pointLocation(m),{center:g,zoom:_}=r.getConstrained(e.M.convert(t.center||f),null!=(n=t.zoom)?n:a);this._normalizeCenter(g);let b=r.zoomScale(_-a),y=r.project(f),v=r.project(g).sub(y),x=t.curve,w=Math.max(r.width,r.height),k=w/b,E=v.mag();if("minZoom"in t){let i=e.ac(Math.min(t.minZoom,a,_),r.minZoom,r.maxZoom);x=Math.sqrt(w/r.zoomScale(i-a)/E*2)}let C=x*x;function A(t){let e=(k*k-w*w+(t?-1:1)*C*C*E*E)/(2*(t?k:w)*C*E);return Math.log(Math.sqrt(e*e+1)-e)}function T(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}let S=A(!1),z=function(t){return I(S)/I(S+x*t)},M=function(t){var e;return w*((I(S)*(T(e=S+x*t)/I(e))-T(S))/C)/E},R=(A(!0)-S)/x;if(1e-6>Math.abs(E)||!isFinite(R)){if(1e-6>Math.abs(w-k))return this.easeTo(t,i);let e=k<w?-1:1;R=Math.abs(Math.log(k/w))/x,M=function(){return 0},z=function(t){return Math.exp(e*x*t)}}return t.duration="duration"in t?+t.duration:1e3*R/("screenSpeed"in t?t.screenSpeed/x:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=d!==s,this._padding=!r.isPaddingEqual(h),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g),this._ease(n=>{let u=n*R,f=1/z(u);r.zoom=1===n?_:a+r.scaleZoom(f),this._rotating&&(r.bearing=e.z.number(o,c,n)),this._pitching&&(r.pitch=e.z.number(s,d,n)),this._padding&&(r.interpolatePadding(l,h,n),m=r.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n);let b=1===n?g:r.unproject(y.add(v.mult(M(u))).mult(f));r.setLocationAtPoint(r.renderWorldCopies?b.wrap():b,m),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(i)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}if(!t){let t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=u.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){let n=Math.abs((t=e.b1(t,-180,180))-i);return Math.abs(t-360-i)<n&&(t-=360),Math.abs(t+360-i)<n&&(t+=360),t}_normalizeCenter(t){let e=this.transform;if(!e.renderWorldCopies||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:360*(i<-180)}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.M.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}let nv={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class nx{constructor(t=nv){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=t=>{t&&("metadata"===t.sourceDataType||"visibility"===t.sourceDataType||"style"===t.dataType||"terrain"===t.type)&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","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=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.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(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){let i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(t=>"string"!=typeof t?"":t)):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let e=this._map.style.sourceCaches;for(let i in e){let n=e[i];if(n.used||n.usedForTerrain){let e=n.getSource();e.attribution&&0>t.indexOf(e.attribution)&&t.push(e.attribution)}}(t=t.filter(t=>String(t).trim())).sort((t,e)=>t.length-e.length);let i=(t=t.filter((e,i)=>{for(let n=i+1;n<t.length;n++)if(t[n].indexOf(e)>=0)return!1;return!0})).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class nw{constructor(t={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");let e=h.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class nk{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){let e=this._currentlyRunning;for(let i of e?this._queue.concat(e):this._queue)if(i.id===t)return void(i.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let e=this._currentlyRunning=this._queue;for(let i of(this._queue=[],e))if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var nE=e.X([{name:"a_pos3d",type:"Int16",components:3}]);class nC extends e.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,i){this.sourceCache.update(t,i),this._renderableTilesKeys=[];let n={};for(let r of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.posMatrix=new Float64Array(16),e.aN(r.posMatrix,0,e.W,0,e.W,0,1),this._tiles[r.key]=new tl(r,this.tileSize));for(let t in this._tiles)n[t]||delete this._tiles[t]}freeRtt(t){for(let e in this._tiles){let i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){let i={};for(let n of this._renderableTilesKeys){let r=this._tiles[n].tileID;if(r.canonical.equals(t.canonical)){let r=t.clone();r.posMatrix=new Float64Array(16),e.aN(r.posMatrix,0,e.W,0,e.W,0,1),i[n]=r}else if(r.canonical.isChildOf(t.canonical)){let a=t.clone();a.posMatrix=new Float64Array(16);let o=r.canonical.z-t.canonical.z,s=r.canonical.x-(r.canonical.x>>o<<o),l=r.canonical.y-(r.canonical.y>>o<<o),c=e.W>>o;e.aN(a.posMatrix,0,c,0,c,0,1),e.H(a.posMatrix,a.posMatrix,[-s*c,-l*c,0]),i[n]=a}else if(t.canonical.isChildOf(r.canonical)){let a=t.clone();a.posMatrix=new Float64Array(16);let o=t.canonical.z-r.canonical.z,s=t.canonical.x-(t.canonical.x>>o<<o),l=t.canonical.y-(t.canonical.y>>o<<o),c=e.W>>o;e.aN(a.posMatrix,0,e.W,0,e.W,0,1),e.H(a.posMatrix,a.posMatrix,[s*c,l*c,0]),e.J(a.posMatrix,a.posMatrix,[1/2**o,1/2**o,0]),i[n]=a}}return i}getSourceTile(t,e){let i=this.sourceCache._source,n=t.overscaledZ-this.deltaZoom;if(n>i.maxzoom&&(n=i.maxzoom),n<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(n).key);let r=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!r||!r.dem)&&e)for(;n>=i.minzoom&&(!r||!r.dem);)r=this.sourceCache.getTileByID(t.scaledTo(n--).key);return r}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(e=>e.timeAdded>=t)}}class nA{constructor(t,e,i){this.painter=t,this.sourceCache=new nC(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,i,n,r=e.W){var a,o,s,l,c,d;if(!(i>=0&&i<r&&n>=0&&n<r))return 0;let u=this.getTerrainData(t),h=null==(a=u.tile)?void 0:a.dem;if(!h)return 0;let p=(o=[],s=[i/r*e.W,n/r*e.W],l=u.u_terrain_matrix,c=s[0],d=s[1],o[0]=l[0]*c+l[4]*d+l[12],o[1]=l[1]*c+l[5]*d+l[13],o),m=[p[0]*h.dim,p[1]*h.dim],f=Math.floor(m[0]),g=Math.floor(m[1]),_=m[0]-f,b=m[1]-g;return h.get(f,g)*(1-_)*(1-b)+h.get(f+1,g)*_*(1-b)+h.get(f,g+1)*(1-_)*b+h.get(f+1,g+1)*_*b}getElevationForLngLatZoom(t,i){let{tileID:n,mercatorX:r,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(n,r%e.W,a%e.W,e.W)}getElevation(t,i,n,r=e.W){return this.getDEMElevation(t,i,n,r)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,i=new e.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new S(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new S(t,new e.R({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=e.an([])}let i=this.sourceCache.getSourceTile(t,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){let t=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new S(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}let n=i&&i+i.tileID.key+t.key;if(n&&!this._demMatrixCache[n]){let n=this.sourceCache.sourceCache._source.maxzoom,r=t.canonical.z-i.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=n?r=t.canonical.z-n:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let a=t.canonical.x-(t.canonical.x>>r<<r),o=t.canonical.y-(t.canonical.y>>r<<r),s=e.b9(new Float64Array(16),[1/(e.W<<r),1/(e.W<<r),0]);e.H(s,s,[a*e.W,o*e.W,0]),this._demMatrixCache[t.key]={matrix:s,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:n?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(t){let e=this.painter,i=e.width/devicePixelRatio,n=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==i||this._fbo.height!==n)&&(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new S(e.context,{width:i,height:n,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new S(e.context,{width:i,height:n,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,n,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,n))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let n=0;n<this._coordsTextureSize;n++,e+=4)i[e+0]=255&n,i[e+1]=255&t,i[e+2]=n>>8<<4|t>>8,i[e+3]=0;let n=new S(t,new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),t.gl.RGBA,{premultiply:!1});return n.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);let i=new Uint8Array(4),n=this.painter.context,r=n.gl;n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);let a=i[0]+(i[2]>>4<<8),o=i[1]+((15&i[2])<<8),s=this.coordsIndex[255-i[3]],l=s&&this.sourceCache.getTileByID(s);if(!l)return null;let c=this._coordsTextureSize,d=(1<<l.tileID.canonical.z)*c;return new e.Y((l.tileID.canonical.x*c+a)/d+l.tileID.wrap,(l.tileID.canonical.y*c+o)/d,this.getElevation(l.tileID,a,o,c))}depthAtPoint(t){let e=new Uint8Array(4),i=this.painter.context,n=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),n.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,n.RGBA,n.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/0x1000000+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let t=this.painter.context,i=new e.ba,n=new e.aX,r=this.meshSize,a=e.W/r,o=r*r;for(let t=0;t<=r;t++)for(let e=0;e<=r;e++)i.emplaceBack(e*a,t*a,0);for(let t=0;t<o;t+=r+1)for(let e=0;e<r;e++)n.emplaceBack(e+t,r+e+t+1,r+e+t+2),n.emplaceBack(e+t,r+e+t+2,e+t+1);let s=i.length,l=s+2*(r+1);for(let t of[0,1])for(let n=0;n<=r;n++)for(let r of[0,1])i.emplaceBack(n*a,t*e.W,r);for(let t=0;t<2*r;t+=2)n.emplaceBack(l+t,l+t+1,l+t+3),n.emplaceBack(l+t,l+t+3,l+t+2),n.emplaceBack(s+t,s+t+3,s+t+1),n.emplaceBack(s+t,s+t+2,s+t+3);let c=i.length,d=c+2*(r+1);for(let t of[0,1])for(let n=0;n<=r;n++)for(let r of[0,1])i.emplaceBack(t*e.W,n*a,r);for(let t=0;t<2*r;t+=2)n.emplaceBack(c+t,c+t+1,c+t+3),n.emplaceBack(c+t,c+t+3,c+t+2),n.emplaceBack(d+t,d+t+3,d+t+1),n.emplaceBack(d+t,d+t+2,d+t+3);return this._mesh={indexBuffer:t.createIndexBuffer(n),vertexBuffer:t.createVertexBuffer(i,nE.members),segments:e.$.simpleSegment(0,0,i.length,n.length)},this._mesh}getMeshFrameDelta(t){return 2*Math.PI*e.bb/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,e){var i;let{tileID:n}=this._getOverscaledTileIDFromLngLatZoom(t,e);return null!=(i=this.getMinMaxElevation(n).minElevation)?i:0}getMinMaxElevation(t){let e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,i){let n=e.Y.fromLngLat(t.wrap()),r=(1<<i)*e.W,a=n.x*r,o=n.y*r,s=Math.floor(a/e.W),l=Math.floor(o/e.W);return{tileID:new e.Q(i,0,i,s,l),mercatorX:a,mercatorY:o}}}class nT{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){let e=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new S(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),e.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),e.colorAttachment.set(i.texture),{id:t,fbo:e,texture:i,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(e=>t.id!==e),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(let t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw Error("No free RenderPool available, call freeAllObjects() required!");let t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(let t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some(t=>!t.inUse)}}let nI={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class nS{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new nT(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){for(let i in this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(i=>!t._layers[i].isHidden(e)),this._coordsDescendingInv={},t.sourceCaches)for(let e of(this._coordsDescendingInv[i]={},t.sourceCaches[i].getVisibleCoordinates())){let t=this.terrain.sourceCache.getTerrainCoords(e);for(let e in t)this._coordsDescendingInv[i][e]||(this._coordsDescendingInv[i][e]=[]),this._coordsDescendingInv[i][e].push(t[e])}for(let e of(this._coordsDescendingInvStr={},t._order)){let i=t._layers[e],n=i.source;if(nI[i.type]&&!this._coordsDescendingInvStr[n])for(let t in this._coordsDescendingInvStr[n]={},this._coordsDescendingInv[n])this._coordsDescendingInvStr[n][t]=this._coordsDescendingInv[n][t].map(t=>t.key).sort().join()}for(let t of this._renderableTiles)for(let e in this._coordsDescendingInvStr){let i=this._coordsDescendingInvStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;let i=t.type,n=this.painter,r=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(nI[i]&&(this._prevType&&nI[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(t.id),!r))return!0;if(nI[this._prevType]||nI[i]&&r){this._prevType=i;let t=this._stacks.length-1,r=this._stacks[t]||[];for(let i of this._renderableTiles){if(this.pool.isFull()&&(ik(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[t]){let e=this.pool.getObjectForId(i.rtt[t].id);if(e.stamp===i.rtt[t].stamp){this.pool.useObject(e);continue}}let a=this.pool.getOrCreateFreeObject();this.pool.useObject(a),this.pool.stampObject(a),i.rtt[t]={id:a.id,stamp:a.stamp},n.context.bindFramebuffer.set(a.fbo.framebuffer),n.context.clear({color:e.aO.transparent,stencil:0}),n.currentStencilSource=void 0;for(let t=0;t<r.length;t++){let e=n.style._layers[r[t]],o=e.source?this._coordsDescendingInv[e.source][i.tileID.key]:[i.tileID];n.context.viewport.set([0,0,a.fbo.width,a.fbo.height]),n._renderTileClippingMasks(e,o),n.renderLayer(n,n.style.sourceCaches[e.source],e,o),e.source&&(i.rttCoords[e.source]=this._coordsDescendingInvStr[e.source][i.tileID.key])}}return ik(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),nI[i]}return!1}}let nz={"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 ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},nL={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:nv,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:e.a.MAX_TILE_CACHE_ZOOM_LEVELS,localIdeographFontFamily:"sans-serif",transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,validateStyle:!0,maxCanvasSize:[4096,4096]},nM=t=>{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd},nR={showCompass:!0,showZoom:!0,visualizePitch:!1};class nP{constructor(t,i,n=!1){this.mousedown=t=>{this.startMouse(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),h.mousePos(this.element,t)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.moveMouse(t,h.mousePos(this.element,t))},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&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 r=t.dragRotate._mouseRotate.getClickTolerance(),a=t.dragRotate._mousePitch.getClickTolerance();this.element=i,this.mouseRotate=i1({clickTolerance:r,enable:!0}),this.touchRotate=(({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>new iY({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:new iQ,enable:t,assignEvents:nM}))({clickTolerance:r,enable:!0}),this.map=t,n&&(this.mousePitch=i2({clickTolerance:a,enable:!0}),this.touchPitch=(({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>new iY({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new iQ,enable:t,assignEvents:nM}))({clickTolerance:a,enable:!0})),h.addEventListener(i,"mousedown",this.mousedown),h.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(i,"touchcancel",this.reset)}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),h.disableDrag()}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),h.disableDrag()}moveMouse(t,e){let i=this.map,{bearingDelta:n}=this.mouseRotate.dragMove(t,e)||{};if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){let{pitchDelta:n}=this.mousePitch.dragMove(t,e)||{};n&&i.setPitch(i.getPitch()+n)}}moveTouch(t,e){let i=this.map,{bearingDelta:n}=this.touchRotate.dragMove(t,e)||{};if(n&&i.setBearing(i.getBearing()+n),this.touchPitch){let{pitchDelta:n}=this.touchPitch.dragMove(t,e)||{};n&&i.setPitch(i.getPitch()+n)}}off(){let t=this.element;h.removeEventListener(t,"mousedown",this.mousedown),h.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}function nD(t,i,n){let r=new e.M(t.lng,t.lat);if(t=new e.M(t.lng,t.lat),i){let r=new e.M(t.lng-360,t.lat),a=new e.M(t.lng+360,t.lat),o=n.locationPoint(t).distSqr(i);n.locationPoint(r).distSqr(i)<o?t=r:n.locationPoint(a).distSqr(i)<o&&(t=a)}for(;Math.abs(t.lng-n.center.lng)>180;){let e=n.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t.lng!==r.lng&&n.locationPoint(t).y>n.height/2-n.getHorizon()?t:r}let nO={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 nB(t,e,i){let n=t.classList;for(let t in nO)n.remove(`maplibregl-${i}-anchor-${t}`);n.add(`maplibregl-${i}-anchor-${e}`)}class nF extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{let e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{let e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{var e;if(!this._map)return;let i=this._map.loaded()&&!this._map.isMoving();"terrain"!==(null==t?void 0:t.type)&&("render"!==(null==t?void 0:t.type)||i)||this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?nD(this._lngLat,this._flatPos,this._map.transform):null==(e=this._lngLat)?void 0:e.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let n="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?n=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${nO[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${n}`),u.frameAsync(new AbortController).then(()=>{this._updateOpacity(t&&"moveend"===t.type)}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){let e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.k("dragstart"))),this.fire(new e.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),"active"===this._state&&this.fire(new e.k("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.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=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div"),this._element.setAttribute("aria-label","Map marker");let i=h.createNS("http://www.w3.org/2000/svg","svg");i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height","41px"),i.setAttributeNS(null,"width","27px"),i.setAttributeNS(null,"viewBox","0 0 27 41");let n=h.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"stroke","none"),n.setAttributeNS(null,"stroke-width","1"),n.setAttributeNS(null,"fill","none"),n.setAttributeNS(null,"fill-rule","evenodd");let r=h.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"fill-rule","nonzero");let a=h.createNS("http://www.w3.org/2000/svg","g");for(let t of(a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000"),[{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"}])){let e=h.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),a.appendChild(e)}let o=h.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"fill",this._color);let s=h.createNS("http://www.w3.org/2000/svg","path");s.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"),o.appendChild(s);let l=h.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"opacity","0.25"),l.setAttributeNS(null,"fill","#000000");let c=h.createNS("http://www.w3.org/2000/svg","path");c.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"),l.appendChild(c);let d=h.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(6.0, 7.0)"),d.setAttributeNS(null,"fill","#FFFFFF");let u=h.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"transform","translate(8.0, 8.0)");let p=h.createNS("http://www.w3.org/2000/svg","circle");p.setAttributeNS(null,"fill","#000000"),p.setAttributeNS(null,"opacity","0.25"),p.setAttributeNS(null,"cx","5.5"),p.setAttributeNS(null,"cy","5.5"),p.setAttributeNS(null,"r","5.4999962");let m=h.createNS("http://www.w3.org/2000/svg","circle");m.setAttributeNS(null,"fill","#FFFFFF"),m.setAttributeNS(null,"cx","5.5"),m.setAttributeNS(null,"cy","5.5"),m.setAttributeNS(null,"r","5.4999962"),u.appendChild(p),u.appendChild(m),r.appendChild(a),r.appendChild(o),r.appendChild(l),r.appendChild(d),r.appendChild(u),i.appendChild(r),i.setAttributeNS(null,"height",41*this._scale+"px"),i.setAttributeNS(null,"width",27*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),nB(this._element,this._anchor,"marker"),t&&t.className)for(let e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.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),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.M.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){let e=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[e,-1*(24.6+e)],"bottom-right":[-e,-1*(24.6+e)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,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 t=this._popup;return this._element.style.opacity===this._opacityWhenCovered||t&&(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map))),this}_updateOpacity(t=!1){var i,n;if(!(null==(i=this._map)?void 0:i.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let r=this._map,a=r.terrain.depthAtPoint(this._pos),o=r.terrain.getElevationForLngLatZoom(this._lngLat,r.transform.tileZoom);if(r.transform.lngLatToCameraDepth(this._lngLat,o)-a<.006)return void(this._element.style.opacity=this._opacity);let s=-this._offset.y/r.transform._pixelPerMeter,l=Math.sin(r.getPitch()*Math.PI/180)*s,c=r.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),d=r.transform.lngLatToCameraDepth(this._lngLat,o+l)-c>.006;(null==(n=this._popup)?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(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(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return void 0===t&&void 0===e&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}let nN={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},nV=0,nU=!1,n$={maxWidth:100,unit:"metric"};function nH(t,e,i){let n=i&&i.maxWidth||100,r=t._container.clientHeight/2,a=t.unproject([0,r]),o=t.unproject([n,r]),s=a.distanceTo(o);if(i&&"imperial"===i.unit){let i=3.2808*s;i>5280?nq(e,n,i/5280,t._getUIString("ScaleControl.Miles")):nq(e,n,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?nq(e,n,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?nq(e,n,s/1e3,t._getUIString("ScaleControl.Kilometers")):nq(e,n,s,t._getUIString("ScaleControl.Meters"))}function nq(t,e,i,n){let r=function(t){let e=Math.pow(10,`${Math.floor(t)}`.length-1),i=t/e;return e*(i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){let e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i))}(i);t.style.width=r/i*e+"px",t.innerHTML=`${r}&nbsp;${n}`}let nj={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1};t.AJAXError=e.be,t.Evented=e.E,t.LngLat=e.M,t.MercatorCoordinate=e.Y,t.Point=e.P,t.addProtocol=e.bf,t.config=e.a,t.removeProtocol=e.bg,t.AttributionControl=nx,t.BoxZoomHandler=ij,t.CanvasSource=te,t.CooperativeGesturesHandler=nm,t.DoubleClickZoomHandler=nl,t.DragPanHandler=nu,t.DragRotateHandler=nh,t.EdgeInsets=iT,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null==(t=null==e?void 0:e.shadowRoot)?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.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(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let t=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_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 e.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.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()}},t.GeoJSONSource=K,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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 Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{let i=new e.M(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),a=e.e({bearing:r},this.options.fitBoundsOptions),o=G.fromLngLat(i,n);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let i=new e.M(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.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=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&nU)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{let t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new nF({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new nF({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",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.k("trackuserlocationend")))})}},this.options=e.e({},nN,t)}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),(function(){return e._(this,arguments,void 0,function*(t=!1){if(void 0!==l&&!t)return l;if(void 0===window.navigator.permissions)return l=!!window.navigator.geolocation;try{let t=yield window.navigator.permissions.query({name:"geolocation"});l="denied"!==t.state}catch(t){l=!!window.navigator.geolocation}return l})})().then(t=>this._setupUI(t)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(),h.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,nV=0,nU=!1}_isOutOfMapMaxBounds(t){let e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.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 Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),n=e.distanceTo(i),r=Math.ceil(this._accuracy/(n/this._map._container.clientHeight)*2);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}trigger(){if(!this._setup)return e.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 e.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":nV--,nU=!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 e.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 e.k("trackuserlocationstart"));break;default:throw 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 Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++nV>1?(t={maximumAge:6e5,timeout:0},nU=!0):(t=this.options.positionOptions,nU=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}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)}},t.Hash=iz,t.ImageSource=Q,t.KeyboardHandler=na,t.LngLatBounds=G,t.LogoControl=nw,t.Map=class extends ny{constructor(t){if(e.bc.mark(e.bd.create),null!=(t=e.e({},nL,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(super(new iI(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._renderTaskQueue=new nk,this._controls=[],this._mapId=e.a3(),this._locale=e.e({},nz,t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this._imageQueueHandle=k.addThrottleControl(()=>this.isMoving()),this._requestManager=new y(t.transformRequest),"string"==typeof t.container){if(this._container=document.getElementById(t.container),!this._container)throw Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.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}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1,e=iS(t=>{this._trackResize&&!this._removed&&this.resize(t)._update()},50);this._resizeObserver=new ResizeObserver(i=>{t?e(i):t=!0}),this._resizeObserver.observe(this._container)}this.handlers=new nb(this,t),this._hash=t.hash&&new iz("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new nx("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new nw,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.k(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.k(`${t.dataType}dataloading`,t))}),this.on("dataabort",t=>{this.fire(new e.k("sourcedataabort",t))})}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.j(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let n=t.onAdd(this);this._controls.push(t);let r=this._controlPositions[i];return -1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.j(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,n)}resize(t){var i;let n=this._containerDimensions(),r=n[0],a=n[1],o=this._getClampedPixelRatio(r,a);if(this._resizeCanvas(r,a,o),this.painter.resize(r,a,o),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let e=this._getClampedPixelRatio(r,a);this._resizeCanvas(r,a,e),this.painter.resize(r,a,e)}this.transform.resize(r,a),null==(i=this._requestedCameraState)||i.resize(r,a);let s=!this._moving;return s&&(this.stop(),this.fire(new e.k("movestart",t)).fire(new e.k("move",t))),this.fire(new e.k("resize",t)),s&&this.fire(new e.k("moveend",t)),this}_getClampedPixelRatio(t,e){let{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),a=t*r,o=e*r;return Math.min(a>i?i/a:1,o>n?n/o:1)*r}getPixelRatio(){var t;return null!=(t=this._overridePixelRatio)?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(G.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>85)throw Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(t){return this.transform.locationPoint(e.M.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null==(t=this.handlers)?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null==(t=this.handlers)?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null==(t=this.handlers)?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let n=!1,r=r=>{let a=this.getLayer(e)?this.queryRenderedFeatures(r.point,{layers:[e]}):[];a.length?n||(n=!0,i.call(this,new iN(t,this,r.originalEvent,{features:a}))):n=!1};return{layer:e,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===t||"mouseout"===t){let n=!1,r=r=>{(this.getLayer(e)?this.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?n=!0:n&&(n=!1,i.call(this,new iN(t,this,r.originalEvent)))},a=e=>{n&&(n=!1,i.call(this,new iN(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:r,mouseout:a}}}{let n=t=>{let n=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:n}}}}on(t,e,i){if(void 0===i)return super.on(t,e);let n=this._createDelegatedListener(t,e,i);for(let e in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(n),n.delegates)this.on(e,n.delegates[e]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);let n=this._createDelegatedListener(t,e,i);for(let t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(n=>{let r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){let n=r[t];if(n.layer===e&&n.listener===i){for(let t in n.delegates)this.off(t,n.delegates[t]);return r.splice(t,1),this}}})(),this)}queryRenderedFeatures(t,i){let n;if(!this.style)return[];let r=t instanceof e.P||Array.isArray(t),a=r?t:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:t)||{},a instanceof e.P||"number"==typeof a[0])n=[e.P.convert(a)];else{let t=e.P.convert(a[0]),i=e.P.convert(a[1]);n=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return!1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let e=this._locale[t];if(null==e)throw Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(t,e));let i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new t0(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i)):delete this.style,this}_lazyInitEmptyStyle(){this.style||(this.style=new t0(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){let n=this._requestManager.transformRequest(t,E.Style);e.h(n,new AbortController).then(t=>{this._updateDiff(t.data,i)}).catch(t=>{t&&this.fire(new e.j(t))})}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(n){e.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){let i=this.style&&this.style.sourceCaches[t];if(void 0!==i)return i.loaded();this.fire(new e.j(Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){let i=this.style.sourceCaches[t.source];if(!i)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);for(let n in null===this.terrain&&i.reload(),this.style._layers){let i=this.style._layers[n];"hillshade"===i.type&&i.source===t.source&&e.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 nA(this.painter,i,t),this.painter.renderToTexture=new nS(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=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.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(e.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 e.k("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!=(e=null==(t=this.terrain)?void 0:t.options)?e:null}areTilesLoaded(){let t=this.style&&this.style.sourceCaches;for(let e in t){let i=t[e]._tiles;for(let t in i){let e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,i,n={}){let{pixelRatio:r=1,sdf:a=!1,stretchX:o,stretchY:s,content:l}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.j(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:n,height:c,data:d}=i;return this.style.addImage(t,{data:new e.R({width:n,height:c},new Uint8Array(d)),pixelRatio:r,stretchX:o,stretchY:s,content:l,sdf:a,version:0,userImage:i}),i.onAdd&&i.onAdd(this,t),this}}{let{width:n,height:c,data:d}=u.getImageData(i);this.style.addImage(t,{data:new e.R({width:n,height:c},d),pixelRatio:r,stretchX:o,stretchY:s,content:l,sdf:a,version:0})}}updateImage(t,i){let n=this.style.getImage(t);if(!n)return this.fire(new e.j(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:o}=i instanceof HTMLImageElement||e.b(i)?u.getImageData(i):i;if(void 0===r||void 0===a)return this.fire(new e.j(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(r!==n.data.width||a!==n.data.height)return this.fire(new e.j(Error("The width and height of the updated image must be that same as the previous version of the image")));let s=!(i instanceof HTMLImageElement||e.b(i));return n.data.replace(o,s),this.style.updateImage(t,n),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.j(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return k.getImage(this._requestManager.transformRequest(t,E.Image),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,n={}){return this.style.setPaintProperty(t,e,i,n),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,n={}){return this.style.setLayoutProperty(t,e,i,n),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,t=>{t||this._update(!0)}),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,t=>{t||this._update(!0)}),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){let t=this._container;t.classList.add("maplibregl-map");let e=this._canvasContainer=h.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",e),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 i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);let r=this._controlContainer=h.create("div","maplibregl-control-container",t),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(t=>{a[t]=h.create("div",`maplibregl-ctrl-${t} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){let t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},e=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)},{once:!0});let i=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!i){let t="Failed to initialize WebGL";throw e?(e.message=t,Error(JSON.stringify(e))):Error(t)}this.painter=new iE(i,this.transform),p.testSupport(i)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded&&(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){let i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this.transform.zoom,r=u.now();this.style.zoomHistory.update(t,r);let a=new e.a8(t,{now:r,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=a.crossFadingFactor();1===o&&o===this._crossFadingFactor||(n=!0,this._crossFadingFactor=o),this.style.update(a)}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 e.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.bc.mark(e.bd.load),this.fire(new e.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let r=this._sourcesDirty||this._styleDirty||this._placementDirty;return r||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.k("idle")),!this._loaded||this._fullyLoaded||r||(this._fullyLoaded=!0,e.bc.mark(e.bd.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;for(let t of(this._hash&&this._hash.remove(),this._controls))t.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),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),k.removeThrottleControl(this._imageQueueHandle),null==(t=this._resizeObserver)||t.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),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),e.bc.clearMetrics(),this._removed=!0,this.fire(new e.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,u.frameAsync(this._frameRequest).then(t=>{e.bc.frame(t),this._frameRequest=null,this._render(t)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return d}getCameraTargetElevation(){return this.transform.elevation}},t.MapMouseEvent=iN,t.MapTouchEvent=iV,t.MapWheelEvent=iU,t.Marker=nF,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{let t=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=t},this._setButtonTitle=(t,e)=>{let i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},nR,t),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,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 nP(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.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(t,e){let i=h.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.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 e.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var i;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let t of this.options.className.split(" "))this._container.classList.add(t);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?nD(this._lngLat,this._flatPos,this._map.transform):null==(i=this._lngLat)?void 0:i.wrap(),this._trackPointer&&!t)return;let n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let r=this.options.anchor,a=function t(i){if(i){if("number"==typeof i){let t=Math.round(Math.abs(i)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,i),"top-left":new e.P(t,t),"top-right":new e.P(-t,t),bottom:new e.P(0,-i),"bottom-left":new e.P(t,-t),"bottom-right":new e.P(-t,-t),left:new e.P(i,0),right:new e.P(-i,0)}}if(i instanceof e.P||Array.isArray(i)){let t=e.P.convert(i);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:e.P.convert(i.center||[0,0]),top:e.P.convert(i.top||[0,0]),"top-left":e.P.convert(i["top-left"]||[0,0]),"top-right":e.P.convert(i["top-right"]||[0,0]),bottom:e.P.convert(i.bottom||[0,0]),"bottom-left":e.P.convert(i["bottom-left"]||[0,0]),"bottom-right":e.P.convert(i["bottom-right"]||[0,0]),left:e.P.convert(i.left||[0,0]),right:e.P.convert(i.right||[0,0])}}return t(new e.P(0,0))}(this.options.offset);if(!r){let t,e=this._container.offsetWidth,i=this._container.offsetHeight;t=n.y+a.bottom.y<i?["top"]:n.y>this._map.transform.height-i?["bottom"]:[],n.x<e/2?t.push("left"):n.x>this._map.transform.width-e/2&&t.push("right"),r=0===t.length?"bottom":t.join("-")}let o=n.add(a[r]);this.options.subpixelPositioning||(o=o.round()),h.setTransform(this._container,`${nO[r]} translate(${o.x}px,${o.y}px)`),nB(this._container,r,"popup")},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(nj),t)}addTo(t){return this._map&&this.remove(),this._map=t,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 e.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.M.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let e,i=document.createDocumentFragment(),n=document.createElement("body");for(n.innerHTML=t;e=n.firstChild;)i.appendChild(e);return this.setDOMContent(i)}getMaxWidth(){var t;return null==(t=this._container)?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.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 t=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");t&&t.focus()}},t.RasterDEMTileSource=Y,t.RasterTileSource=W,t.ScaleControl=class{constructor(t){this._onMove=()=>{nH(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,nH(this._map,this._container,this.options)},this.options=e.e({},n$,t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=ns,t.Style=t0,t.TerrainControl=class{constructor(t){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=t}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.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(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=ne,t.TwoFingersTouchRotateHandler=i9,t.TwoFingersTouchZoomHandler=i7,t.TwoFingersTouchZoomRotateHandler=np,t.VectorTileSource=Z,t.VideoSource=tt,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,function*(){if(tn(t))throw Error(`A source type called "${t}" already exists.`);ti[t]=i}),t.clearPrewarmedResources=function(){let t=a;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(F),a=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()"))},t.getMaxParallelImageRequests=function(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return ts().getRTLTextPluginStatus()},t.getVersion=function(){return d},t.getWorkerCount=function(){return N.workerCount},t.getWorkerUrl=function(){return e.a.WORKER_URL},t.importScriptInWorkers=function(t){return H().broadcast("importScript",t)},t.prewarm=function(){U().acquire(F)},t.setMaxParallelImageRequests=function(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setRTLTextPlugin=function(t,e){return ts().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){N.workerCount=t},t.setWorkerUrl=function(t){e.a.WORKER_URL=t}}),t}()}},a={};function o(t){var e=a[t];if(void 0!==e)return e.exports;var i=a[t]={id:t,loaded:!1,exports:{}};return r[t].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},(()=>{var t,e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__;o.t=function(i,n){if(1&n&&(i=this(i)),8&n||"object"==typeof i&&i&&(4&n&&i.__esModule||16&n&&"function"==typeof i.then))return i;var r=Object.create(null);o.r(r);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&i;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach(t=>{a[t]=()=>i[t]});return a.default=()=>i,o.d(r,a),r}})(),o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}})(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var s={};return(()=>{"use strict";let t;o.r(s),o.d(s,{OrMapLoadedEvent:()=>rh,geoJsonPointInputTemplateProvider:()=>rv,OrMapMarkerClickedEvent:()=>en,OrMap:()=>rx,OrMapMarker:()=>er,OrMapAssetCard:()=>rd,getMarkerConfigAttributeName:()=>es,Util:()=>p,DefaultConfig:()=>rc,CenterControl:()=>rg,OrMapAssetCardLoadAssetEvent:()=>rl,getMarkerConfigForAssetType:()=>eo,OrMapLongPressEvent:()=>rm,OrMapMarkerChangedEvent:()=>ei,CoordinatesControl:()=>ry,OrMapMarkerAsset:()=>el,OrMapGeocoderChangeEvent:()=>rf,OrMapClickedEvent:()=>rp});var e,i,n,r,a,l,c,d,u,h,p={};o.r(p),o.d(p,{getGeoJSONPoint:()=>tY,getLatLngBounds:()=>tJ,getLngLat:()=>tW,getLngLatBounds:()=>tK,getMarkerIconAndColorFromAssetType:()=>tQ});var m=o(801),f=o.n(m);function g(t,e,i){return{index:t,removed:e,addedCount:i}}window.JSCompiler_renameProperty=function(t,e){return t};let _=0,b=0,y=[],v=0,x=!1,w=document.createTextNode("");new window.MutationObserver(function(){x=!1;let t=y.length;for(let e=0;e<t;e++){let t=y[e];if(t)try{t()}catch(t){setTimeout(()=>{throw t})}}y.splice(0,t),b+=t}).observe(w,{characterData:!0});let k={run:t=>(x||(x=!0,w.textContent=v++),y.push(t),_++),cancel(t){let e=t-b;if(e>=0){if(!y[e])throw Error("invalid async handle: "+t);y[e]=null}}},E=window.ShadyDOM&&window.ShadyDOM.noPatch&&window.ShadyDOM.wrap?window.ShadyDOM.wrap:window.ShadyDOM?t=>ShadyDOM.patch(t):t=>t;function C(t){return"slot"===t.localName}let A=class{static getFlattenedNodes(t){let e=E(t);return C(t)?e.assignedNodes({flatten:!0}):Array.from(e.childNodes).map(t=>C(t)?E(t).assignedNodes({flatten:!0}):[t]).reduce((t,e)=>t.concat(e),[])}constructor(t,e){this._shadyChildrenObserver=null,this._nativeChildrenObserver=null,this._connected=!1,this._target=t,this.callback=e,this._effectiveNodes=[],this._observer=null,this._scheduled=!1,this._boundSchedule=()=>{this._schedule()},this.connect(),this._schedule()}connect(){C(this._target)?this._listenSlots([this._target]):E(this._target).children&&(this._listenSlots(E(this._target).children),window.ShadyDOM?this._shadyChildrenObserver=window.ShadyDOM.observeChildren(this._target,t=>{this._processMutations(t)}):(this._nativeChildrenObserver=new MutationObserver(t=>{this._processMutations(t)}),this._nativeChildrenObserver.observe(this._target,{childList:!0}))),this._connected=!0}disconnect(){C(this._target)?this._unlistenSlots([this._target]):E(this._target).children&&(this._unlistenSlots(E(this._target).children),window.ShadyDOM&&this._shadyChildrenObserver?(window.ShadyDOM.unobserveChildren(this._shadyChildrenObserver),this._shadyChildrenObserver=null):this._nativeChildrenObserver&&(this._nativeChildrenObserver.disconnect(),this._nativeChildrenObserver=null)),this._connected=!1}_schedule(){this._scheduled||(this._scheduled=!0,k.run(()=>this.flush()))}_processMutations(t){this._processSlotMutations(t),this.flush()}_processSlotMutations(t){if(t)for(let e=0;e<t.length;e++){let i=t[e];i.addedNodes&&this._listenSlots(i.addedNodes),i.removedNodes&&this._unlistenSlots(i.removedNodes)}}flush(){var t;if(!this._connected)return!1;window.ShadyDOM&&ShadyDOM.flush(),this._nativeChildrenObserver?this._processSlotMutations(this._nativeChildrenObserver.takeRecords()):this._shadyChildrenObserver&&this._processSlotMutations(this._shadyChildrenObserver.takeRecords()),this._scheduled=!1;let e={target:this._target,addedNodes:[],removedNodes:[]},i=this.constructor.getFlattenedNodes(this._target),n=(t=this._effectiveNodes,function(t,e,i,n,r,a){let o,s=0,l=0,c=Math.min(i-e,a-r);if(0==e&&0==r&&(s=function(t,e,i){for(let r=0;r<i;r++){var n;if(n=t[r],n!==e[r])return r}return i}(t,n,c)),i==t.length&&a==n.length&&(l=function(t,e,i){var n;let r=t.length,a=e.length,o=0;for(;o<i&&(n=t[--r],n===e[--a]);)o++;return o}(t,n,c-s)),e+=s,r+=s,i-=l,a-=l,i-e==0&&a-r==0)return[];if(e==i){for(o=g(e,[],0);r<a;)o.removed.push(n[r++]);return[o]}if(r==a)return[g(e,[],i-e)];let d=function(t){let e=t.length-1,i=t[0].length-1,n=t[e][i],r=[];for(;e>0||i>0;){let a;if(0==e){r.push(2),i--;continue}if(0==i){r.push(3),e--;continue}let o=t[e-1][i-1],s=t[e-1][i],l=t[e][i-1];(a=s<l?s<o?s:o:l<o?l:o)==o?(o==n?r.push(0):(r.push(1),n=o),e--,i--):a==s?(r.push(3),e--,n=s):(r.push(2),i--,n=l)}return r.reverse(),r}(function(t,e,i,n,r,a){let o=a-r+1,s=i-e+1,l=Array(o);for(let t=0;t<o;t++)l[t]=Array(s),l[t][0]=t;for(let t=0;t<s;t++)l[0][t]=t;for(let i=1;i<o;i++)for(let a=1;a<s;a++){var c;if(c=t[e+a-1],c===n[r+i-1])l[i][a]=l[i-1][a-1];else{let t=l[i-1][a]+1,e=l[i][a-1]+1;l[i][a]=t<e?t:e}}return l}(t,e,i,n,r,a));o=void 0;let u=[],h=e,p=r;for(let t=0;t<d.length;t++)switch(d[t]){case 0:o&&(u.push(o),o=void 0),h++,p++;break;case 1:o||(o=g(h,[],0)),o.addedCount++,h++,o.removed.push(n[p]),p++;break;case 2:o||(o=g(h,[],0)),o.addedCount++,h++;break;case 3:o||(o=g(h,[],0)),o.removed.push(n[p]),p++}return o&&u.push(o),u}(i,0,i.length,t,0,t.length));for(let t=0,i;t<n.length&&(i=n[t]);t++)for(let t=0,n;t<i.removed.length&&(n=i.removed[t]);t++)e.removedNodes.push(n);for(let t=0,r;t<n.length&&(r=n[t]);t++)for(let t=r.index;t<r.index+r.addedCount;t++)e.addedNodes.push(i[t]);this._effectiveNodes=i;let r=!1;return(e.addedNodes.length||e.removedNodes.length)&&(r=!0,this.callback.call(this._target,e)),r}_listenSlots(t){for(let e=0;e<t.length;e++){let i=t[e];C(i)&&i.addEventListener("slotchange",this._boundSchedule)}}_unlistenSlots(t){for(let e=0;e<t.length;e++){let i=t[e];C(i)&&i.removeEventListener("slotchange",this._boundSchedule)}}},T=globalThis,I=T.ShadowRoot&&(void 0===T.ShadyCSS||T.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,S=Symbol(),z=new WeakMap;class M{constructor(t,e,i){if(this._$cssResult$=!0,i!==S)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(I&&void 0===t){let i=void 0!==e&&1===e.length;i&&(t=z.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&z.set(e,t))}return t}toString(){return this.cssText}}let R=t=>new M("string"==typeof t?t:t+"",void 0,S),P=(t,...e)=>new M(1===t.length?t[0]:e.reduce((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1],t[0]),t,S),D=I?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(let i of t.cssRules)e+=i.cssText;return R(e)})(t):t,{is:O,defineProperty:B,getOwnPropertyDescriptor:F,getOwnPropertyNames:N,getOwnPropertySymbols:V,getPrototypeOf:U}=Object,$=globalThis,H=$.trustedTypes,q=H?H.emptyScript:"",j=$.reactiveElementPolyfillSupport,G={toAttribute(t,e){switch(e){case Boolean:t=t?q:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},X=(t,e)=>!O(t,e),Z={attribute:!0,type:String,converter:G,reflect:!1,useDefault:!1,hasChanged:X};Symbol.metadata??=Symbol("metadata"),$.litPropertyMetadata??=new WeakMap;class W extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Z){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&B(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){let{get:n,set:r}=F(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:n,set(e){let a=n?.call(this);r?.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Z}static _$Ei(){if(this.hasOwnProperty("elementProperties"))return;let t=U(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty("finalized"))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty("properties")){let t=this.properties;for(let e of[...N(t),...V(t)])this.createProperty(e,t[e])}let t=this[Symbol.metadata];if(null!==t){let e=litPropertyMetadata.get(t);if(void 0!==e)for(let[t,i]of e)this.elementProperties.set(t,i)}for(let[t,e]of(this._$Eh=new Map,this.elementProperties)){let i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t))for(let i of new Set(t.flat(1/0).reverse()))e.unshift(D(i));else void 0!==t&&e.push(D(t));return e}static _$Eu(t,e){let i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map;for(let e of this.constructor.elementProperties.keys())this.hasOwnProperty(e)&&(t.set(e,this[e]),delete this[e]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(I)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let i of e){let e=document.createElement("style"),n=T.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){let i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){let r=(void 0!==i.converter?.toAttribute?i.converter:G).toAttribute(e,i.type);this._$Em=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){let i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){let t=i.getPropertyOptions(n),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:G;this._$Em=n;let a=r.fromAttribute(e,t.type);this[n]=a??this._$Ej?.get(n)??a,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){let n=this.constructor,r=this[t];if(!(((i??=n.getPropertyOptions(t)).hasChanged??X)(r,e)||i.useDefault&&i.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:n,wrapped:r},a){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,a??e??this[t]),!0!==r||void 0!==a)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===n&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[e,i]of t){let{wrapped:t}=i,n=this[e];!0!==t||this._$AL.has(e)||void 0===n||this.C(e,void 0,i,n)}}let t=!1,e=this._$AL;try{(t=this.shouldUpdate(e))?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}W.elementStyles=[],W.shadowRootOptions={mode:"open"},W.elementProperties=new Map,W.finalized=new Map,j?.({ReactiveElement:W}),($.reactiveElementVersions??=[]).push("2.1.1");let Y=globalThis,K=Y.trustedTypes,J=K?K.createPolicy("lit-html",{createHTML:t=>t}):void 0,Q="$lit$",tt=`lit$${Math.random().toFixed(9).slice(2)}$`,te="?"+tt,ti=`<${te}>`,tn=document,tr=()=>tn.createComment(""),ta=t=>null===t||"object"!=typeof t&&"function"!=typeof t,to=Array.isArray,ts=t=>to(t)||"function"==typeof t?.[Symbol.iterator],tl="[ \n\f\r]",tc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,td=/-->/g,tu=/>/g,th=RegExp(`>|${tl}(?:([^\\s"'>=/]+)(${tl}*=${tl}*(?:[^
51
+ `}),staticAttributes:n,staticUniforms:o}}class t4{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,n,r,a,o,s,l){this.context=t;let c=this.boundPaintVertexBuffers.length!==n.length;for(let t=0;!c&&t<n.length;t++)this.boundPaintVertexBuffers[t]!==n[t]&&(c=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||c||this.boundIndexBuffer!==r||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,n,r,a,o,s,l):(t.bindVertexArray.set(this.vao),o&&o.bind(),r&&r.dynamicDraw&&r.bind(),s&&s.bind(),l&&l.bind())}freshBind(t,e,i,n,r,a,o,s){let l=t.numAttributes,c=this.context,d=c.gl;for(let l of(this.vao&&this.destroy(),this.vao=c.createVertexArray(),c.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=n,this.boundVertexOffset=r,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,e.enableAttributes(d,t),i))l.enableAttributes(d,t);for(let n of(a&&a.enableAttributes(d,t),o&&o.enableAttributes(d,t),s&&s.enableAttributes(d,t),e.bind(),e.setVertexAttribPointers(d,t,r),i))n.bind(),n.setVertexAttribPointers(d,t,r);a&&(a.bind(),a.setVertexAttribPointers(d,t,r)),n&&n.bind(),o&&(o.bind(),o.setVertexAttribPointers(d,t,r)),s&&(s.bind(),s.setVertexAttribPointers(d,t,r)),c.currentNumAttributes=l}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}function t6(t){let e=[];for(let i=0;i<t.length;i++){if(null===t[i])continue;let n=t[i].split(" ");e.push(n.pop())}return e}class t7{constructor(t,i,n,r,a,o){let s=t.gl;this.program=s.createProgram();let l=t6(i.staticAttributes),c=n?n.getBinderAttributes():[],d=l.concat(c),u=t5.prelude.staticUniforms?t6(t5.prelude.staticUniforms):[],h=i.staticUniforms?t6(i.staticUniforms):[],p=n?n.getBinderUniforms():[],m=u.concat(h).concat(p),f=[];for(let t of m)0>f.indexOf(t)&&f.push(t);let g=n?n.defines():[];a&&g.push("#define OVERDRAW_INSPECTOR;"),o&&g.push("#define TERRAIN3D;");let _=g.concat(t5.prelude.fragmentSource,i.fragmentSource).join("\n"),b=g.concat(t5.prelude.vertexSource,i.vertexSource).join("\n"),y=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);if(s.shaderSource(y,_),s.compileShader(y),!s.getShaderParameter(y,s.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${s.getShaderInfoLog(y)}`);s.attachShader(this.program,y);let v=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);if(s.shaderSource(v,b),s.compileShader(v),!s.getShaderParameter(v,s.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${s.getShaderInfoLog(v)}`);s.attachShader(this.program,v),this.attributes={};let x={};this.numAttributes=d.length;for(let t=0;t<this.numAttributes;t++)d[t]&&(s.bindAttribLocation(this.program,t,d[t]),this.attributes[d[t]]=t);if(s.linkProgram(this.program),!s.getProgramParameter(this.program,s.LINK_STATUS))throw Error(`Program failed to link: ${s.getProgramInfoLog(this.program)}`);s.deleteShader(v),s.deleteShader(y);for(let t=0;t<f.length;t++){let e=f[t];if(e&&!x[e]){let t=s.getUniformLocation(this.program,e);t&&(x[e]=t)}}this.fixedUniforms=r(t,x),this.terrainUniforms=((t,i)=>({u_depth:new e.aG(t,i.u_depth),u_terrain:new e.aG(t,i.u_terrain),u_terrain_dim:new e.aH(t,i.u_terrain_dim),u_terrain_matrix:new e.aI(t,i.u_terrain_matrix),u_terrain_unpack:new e.aJ(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.aH(t,i.u_terrain_exaggeration)}))(t,x),this.binderUniforms=n?n.getUniforms(t,x):[]}draw(t,e,i,n,r,a,o,s,l,c,d,u,h,p,m,f,g,_){let b=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(n),t.setColorMode(r),t.setCullFace(a),s)for(let e in t.activeTexture.set(b.TEXTURE2),b.bindTexture(b.TEXTURE_2D,s.depthTexture),t.activeTexture.set(b.TEXTURE3),b.bindTexture(b.TEXTURE_2D,s.texture),this.terrainUniforms)this.terrainUniforms[e].set(s[e]);for(let t in this.fixedUniforms)this.fixedUniforms[t].set(o[t]);m&&m.setUniforms(t,this.binderUniforms,h,{zoom:p});let y=0;switch(e){case b.LINES:y=2;break;case b.TRIANGLES:y=3;break;case b.LINE_STRIP:y=1}for(let i of u.get()){let n=i.vaos||(i.vaos={});(n[l]||(n[l]=new t4)).bind(t,this,c,m?m.getPaintVertexBuffers():[],d,i.vertexOffset,f,g,_),b.drawElements(e,i.primitiveLength*y,b.UNSIGNED_SHORT,i.primitiveOffset*y*2)}}}function t8(t,e,i){let n=1/tM(i,1,e.transform.tileZoom),r=Math.pow(2,i.tileID.overscaledZ),a=i.tileSize*Math.pow(2,e.transform.tileZoom)/r,o=a*(i.tileID.canonical.x+i.tileID.wrap*r),s=a*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[n,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,s>>16],u_pixel_coord_lower:[65535&o,65535&s]}}let t9=(t,i,n,r)=>{var a,o,s,l,c,d,u;let h=i.style.light,p=h.properties.get("position"),m=[p.x,p.y,p.z],f=(a=new e.A(9),e.A!=Float32Array&&(a[1]=0,a[2]=0,a[3]=0,a[5]=0,a[6]=0,a[7]=0),a[0]=1,a[4]=1,a[8]=1,a);"viewport"===h.properties.get("anchor")&&(s=Math.sin(o=-i.transform.angle),l=Math.cos(o),f[0]=l,f[1]=s,f[2]=0,f[3]=-s,f[4]=l,f[5]=0,f[6]=0,f[7]=0,f[8]=1),c=m[0],d=m[1],u=m[2],m[0]=c*f[0]+d*f[3]+u*f[6],m[1]=c*f[1]+d*f[4]+u*f[7],m[2]=c*f[2]+d*f[5]+u*f[8];let g=h.properties.get("color");return{u_matrix:t,u_lightpos:m,u_lightintensity:h.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+n,u_opacity:r}},et=(t,i,n,r,a,o,s)=>e.e(t9(t,i,n,r),t8(o,i,s),{u_height_factor:-Math.pow(2,a.overscaledZ)/s.tileSize/8}),ee=t=>({u_matrix:t}),ei=(t,i,n,r)=>e.e(ee(t),t8(n,i,r)),en=(t,e)=>({u_matrix:t,u_world:e}),er=(t,i,n,r,a)=>e.e(ei(t,i,n,r),{u_world:a}),ea=(t,e,i,n)=>{let r,a,o=t.transform;if("map"===n.paint.get("circle-pitch-alignment")){let t=tM(i,1,o.zoom);r=!0,a=[t,t]}else r=!1,a=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_matrix:t.translatePosMatrix(e.posMatrix,i,n.paint.get("circle-translate"),n.paint.get("circle-translate-anchor")),u_pitch_with_map:+r,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:a}},eo=(t,e,i)=>{let n=tM(i,1,e.zoom),r=Math.pow(2,e.zoom-i.tileID.overscaledZ),a=i.tileID.overscaleFactor();return{u_matrix:t,u_camera_to_center_distance:e.cameraToCenterDistance,u_pixels_to_tile_units:n,u_extrude_scale:[e.pixelsToGLUnits[0]/(n*r),e.pixelsToGLUnits[1]/(n*r)],u_overscale_factor:a}},es=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),el=t=>({u_matrix:t}),ec=(t,e,i,n)=>({u_matrix:t,u_extrude_scale:tM(e,1,i),u_intensity:n}),ed=(t,e,i,n)=>{let r=t.transform;return{u_matrix:ef(t,e,i,n),u_ratio:1/tM(e,1,r.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/r.pixelsToGLUnits[0],1/r.pixelsToGLUnits[1]]}},eu=(t,i,n,r,a)=>e.e(ed(t,i,n,a),{u_image:0,u_image_height:r}),eh=(t,e,i,n,r)=>{let a=t.transform,o=em(e,a);return{u_matrix:ef(t,e,i,r),u_texsize:e.imageAtlasTexture.size,u_ratio:1/tM(e,1,a.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[o,n.fromScale,n.toScale],u_fade:n.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},ep=(t,i,n,r,a,o)=>{let s=t.lineAtlas,l=em(i,t.transform),c="round"===n.layout.get("line-cap"),d=s.getDash(r.from,c),u=s.getDash(r.to,c),h=d.width*a.fromScale,p=u.width*a.toScale;return e.e(ed(t,i,n,o),{u_patternscale_a:[l/h,-d.height/2],u_patternscale_b:[l/p,-u.height/2],u_sdfgamma:s.width/(256*Math.min(h,p)*t.pixelRatio)/2,u_image:0,u_tex_y_a:d.y,u_tex_y_b:u.y,u_mix:a.t})};function em(t,e){return 1/tM(t,1,e.tileZoom)}function ef(t,e,i,n){return t.translatePosMatrix(n?n.posMatrix:e.tileID.posMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}let eg=(t,e,i,n,r)=>{var a,o;return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(o=r.paint.get("raster-saturation"))>0?1-1/(1.001-o):-o,u_contrast_factor:(a=r.paint.get("raster-contrast"))>0?1/(1-a):1+a,u_spin_weights:function(t){let e=Math.sin(t*=Math.PI/180),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}(r.paint.get("raster-hue-rotate"))}},e_=(t,e,i,n,r,a,o,s,l,c)=>{let d=r.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:d.width/d.height,u_fade_change:r.options.fadeDuration?r.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:o,u_coord_matrix:s,u_is_text:+l,u_pitch_with_map:+n,u_texsize:c,u_texture:0}},eb=(t,i,n,r,a,o,s,l,c,d,u)=>{let h=a.transform;return e.e(e_(t,i,n,r,a,o,s,l,c,d),{u_gamma_scale:r?Math.cos(h._pitch)*h.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:+u})},ey=(t,i,n,r,a,o,s,l,c,d)=>e.e(eb(t,i,n,r,a,o,s,l,!0,c,!0),{u_texsize_icon:d,u_texture_icon:1}),ev=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),ex=(t,i,n,r,a,o)=>e.e(function(t,e,i,n){let r=i.imageManager.getPattern(t.from.toString()),a=i.imageManager.getPattern(t.to.toString()),{width:o,height:s}=i.imageManager.getPixelSize(),l=Math.pow(2,n.tileID.overscaledZ),c=n.tileSize*Math.pow(2,i.transform.tileZoom)/l,d=c*(n.tileID.canonical.x+n.tileID.wrap*l),u=c*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:r.tl,u_pattern_br_a:r.br,u_pattern_tl_b:a.tl,u_pattern_br_b:a.br,u_texsize:[o,s],u_mix:e.t,u_pattern_size_a:r.displaySize,u_pattern_size_b:a.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/tM(n,1,i.transform.tileZoom),u_pixel_coord_upper:[d>>16,u>>16],u_pixel_coord_lower:[65535&d,65535&u]}}(r,o,n,a),{u_matrix:t,u_opacity:i}),ew={fillExtrusion:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_lightpos:new e.aK(t,i.u_lightpos),u_lightintensity:new e.aH(t,i.u_lightintensity),u_lightcolor:new e.aK(t,i.u_lightcolor),u_vertical_gradient:new e.aH(t,i.u_vertical_gradient),u_opacity:new e.aH(t,i.u_opacity)}),fillExtrusionPattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_lightpos:new e.aK(t,i.u_lightpos),u_lightintensity:new e.aH(t,i.u_lightintensity),u_lightcolor:new e.aK(t,i.u_lightcolor),u_vertical_gradient:new e.aH(t,i.u_vertical_gradient),u_height_factor:new e.aH(t,i.u_height_factor),u_image:new e.aG(t,i.u_image),u_texsize:new e.aL(t,i.u_texsize),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade),u_opacity:new e.aH(t,i.u_opacity)}),fill:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix)}),fillPattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_image:new e.aG(t,i.u_image),u_texsize:new e.aL(t,i.u_texsize),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade)}),fillOutline:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_world:new e.aL(t,i.u_world)}),fillOutlinePattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_world:new e.aL(t,i.u_world),u_image:new e.aG(t,i.u_image),u_texsize:new e.aL(t,i.u_texsize),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade)}),circle:(t,i)=>({u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_scale_with_map:new e.aG(t,i.u_scale_with_map),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_extrude_scale:new e.aL(t,i.u_extrude_scale),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_matrix:new e.aI(t,i.u_matrix)}),collisionBox:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pixels_to_tile_units:new e.aH(t,i.u_pixels_to_tile_units),u_extrude_scale:new e.aL(t,i.u_extrude_scale),u_overscale_factor:new e.aH(t,i.u_overscale_factor)}),collisionCircle:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_inv_matrix:new e.aI(t,i.u_inv_matrix),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_viewport_size:new e.aL(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.aM(t,i.u_color),u_matrix:new e.aI(t,i.u_matrix),u_overlay:new e.aG(t,i.u_overlay),u_overlay_scale:new e.aH(t,i.u_overlay_scale)}),clippingMask:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix)}),heatmap:(t,i)=>({u_extrude_scale:new e.aH(t,i.u_extrude_scale),u_intensity:new e.aH(t,i.u_intensity),u_matrix:new e.aI(t,i.u_matrix)}),heatmapTexture:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_world:new e.aL(t,i.u_world),u_image:new e.aG(t,i.u_image),u_color_ramp:new e.aG(t,i.u_color_ramp),u_opacity:new e.aH(t,i.u_opacity)}),hillshade:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_image:new e.aG(t,i.u_image),u_latrange:new e.aL(t,i.u_latrange),u_light:new e.aL(t,i.u_light),u_shadow:new e.aM(t,i.u_shadow),u_highlight:new e.aM(t,i.u_highlight),u_accent:new e.aM(t,i.u_accent)}),hillshadePrepare:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_image:new e.aG(t,i.u_image),u_dimension:new e.aL(t,i.u_dimension),u_zoom:new e.aH(t,i.u_zoom),u_unpack:new e.aJ(t,i.u_unpack)}),line:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels),u_image:new e.aG(t,i.u_image),u_image_height:new e.aH(t,i.u_image_height)}),linePattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_texsize:new e.aL(t,i.u_texsize),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_image:new e.aG(t,i.u_image),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels),u_scale:new e.aK(t,i.u_scale),u_fade:new e.aH(t,i.u_fade)}),lineSDF:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ratio:new e.aH(t,i.u_ratio),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.aL(t,i.u_units_to_pixels),u_patternscale_a:new e.aL(t,i.u_patternscale_a),u_patternscale_b:new e.aL(t,i.u_patternscale_b),u_sdfgamma:new e.aH(t,i.u_sdfgamma),u_image:new e.aG(t,i.u_image),u_tex_y_a:new e.aH(t,i.u_tex_y_a),u_tex_y_b:new e.aH(t,i.u_tex_y_b),u_mix:new e.aH(t,i.u_mix)}),raster:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_tl_parent:new e.aL(t,i.u_tl_parent),u_scale_parent:new e.aH(t,i.u_scale_parent),u_buffer_scale:new e.aH(t,i.u_buffer_scale),u_fade_t:new e.aH(t,i.u_fade_t),u_opacity:new e.aH(t,i.u_opacity),u_image0:new e.aG(t,i.u_image0),u_image1:new e.aG(t,i.u_image1),u_brightness_low:new e.aH(t,i.u_brightness_low),u_brightness_high:new e.aH(t,i.u_brightness_high),u_saturation_factor:new e.aH(t,i.u_saturation_factor),u_contrast_factor:new e.aH(t,i.u_contrast_factor),u_spin_weights:new e.aK(t,i.u_spin_weights)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.aG(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aG(t,i.u_is_size_feature_constant),u_size_t:new e.aH(t,i.u_size_t),u_size:new e.aH(t,i.u_size),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pitch:new e.aH(t,i.u_pitch),u_rotate_symbol:new e.aG(t,i.u_rotate_symbol),u_aspect_ratio:new e.aH(t,i.u_aspect_ratio),u_fade_change:new e.aH(t,i.u_fade_change),u_matrix:new e.aI(t,i.u_matrix),u_label_plane_matrix:new e.aI(t,i.u_label_plane_matrix),u_coord_matrix:new e.aI(t,i.u_coord_matrix),u_is_text:new e.aG(t,i.u_is_text),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_texsize:new e.aL(t,i.u_texsize),u_texture:new e.aG(t,i.u_texture)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.aG(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aG(t,i.u_is_size_feature_constant),u_size_t:new e.aH(t,i.u_size_t),u_size:new e.aH(t,i.u_size),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pitch:new e.aH(t,i.u_pitch),u_rotate_symbol:new e.aG(t,i.u_rotate_symbol),u_aspect_ratio:new e.aH(t,i.u_aspect_ratio),u_fade_change:new e.aH(t,i.u_fade_change),u_matrix:new e.aI(t,i.u_matrix),u_label_plane_matrix:new e.aI(t,i.u_label_plane_matrix),u_coord_matrix:new e.aI(t,i.u_coord_matrix),u_is_text:new e.aG(t,i.u_is_text),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_texsize:new e.aL(t,i.u_texsize),u_texture:new e.aG(t,i.u_texture),u_gamma_scale:new e.aH(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_is_halo:new e.aG(t,i.u_is_halo)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.aG(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.aG(t,i.u_is_size_feature_constant),u_size_t:new e.aH(t,i.u_size_t),u_size:new e.aH(t,i.u_size),u_camera_to_center_distance:new e.aH(t,i.u_camera_to_center_distance),u_pitch:new e.aH(t,i.u_pitch),u_rotate_symbol:new e.aG(t,i.u_rotate_symbol),u_aspect_ratio:new e.aH(t,i.u_aspect_ratio),u_fade_change:new e.aH(t,i.u_fade_change),u_matrix:new e.aI(t,i.u_matrix),u_label_plane_matrix:new e.aI(t,i.u_label_plane_matrix),u_coord_matrix:new e.aI(t,i.u_coord_matrix),u_is_text:new e.aG(t,i.u_is_text),u_pitch_with_map:new e.aG(t,i.u_pitch_with_map),u_texsize:new e.aL(t,i.u_texsize),u_texsize_icon:new e.aL(t,i.u_texsize_icon),u_texture:new e.aG(t,i.u_texture),u_texture_icon:new e.aG(t,i.u_texture_icon),u_gamma_scale:new e.aH(t,i.u_gamma_scale),u_device_pixel_ratio:new e.aH(t,i.u_device_pixel_ratio),u_is_halo:new e.aG(t,i.u_is_halo)}),background:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_opacity:new e.aH(t,i.u_opacity),u_color:new e.aM(t,i.u_color)}),backgroundPattern:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_opacity:new e.aH(t,i.u_opacity),u_image:new e.aG(t,i.u_image),u_pattern_tl_a:new e.aL(t,i.u_pattern_tl_a),u_pattern_br_a:new e.aL(t,i.u_pattern_br_a),u_pattern_tl_b:new e.aL(t,i.u_pattern_tl_b),u_pattern_br_b:new e.aL(t,i.u_pattern_br_b),u_texsize:new e.aL(t,i.u_texsize),u_mix:new e.aH(t,i.u_mix),u_pattern_size_a:new e.aL(t,i.u_pattern_size_a),u_pattern_size_b:new e.aL(t,i.u_pattern_size_b),u_scale_a:new e.aH(t,i.u_scale_a),u_scale_b:new e.aH(t,i.u_scale_b),u_pixel_coord_upper:new e.aL(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.aL(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.aH(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_texture:new e.aG(t,i.u_texture),u_ele_delta:new e.aH(t,i.u_ele_delta)}),terrainDepth:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_ele_delta:new e.aH(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_matrix:new e.aI(t,i.u_matrix),u_texture:new e.aG(t,i.u_texture),u_terrain_coords_id:new e.aH(t,i.u_terrain_coords_id),u_ele_delta:new e.aH(t,i.u_ele_delta)})};class ek{constructor(t,e,i){this.context=t;let n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let e=this.context.gl;if(!this.dynamicDraw)throw Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let eE={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class eC{constructor(t,e,i,n){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;let r=t.gl;this.buffer=r.createBuffer(),t.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete e.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i=0;i<this.attributes.length;i++){let n=e.attributes[this.attributes[i].name];void 0!==n&&t.enableVertexAttribArray(n)}}setVertexAttribPointers(t,e,i){for(let n=0;n<this.attributes.length;n++){let r=this.attributes[n],a=e.attributes[r.name];void 0!==a&&t.vertexAttribPointer(a,r.components,t[eE[r.type]],!1,this.itemSize,r.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let eA=new WeakMap;function eT(t){var e;if(eA.has(t))return eA.get(t);{let i=null==(e=t.getParameter(t.VERSION))?void 0:e.startsWith("WebGL 2.0");return eA.set(t,i),i}}class eI{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class eS extends eI{getDefault(){return e.aO.transparent}set(t){let e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class ez extends eI{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class eL extends eI{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class eM extends eI{getDefault(){return[!0,!0,!0,!0]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class eR extends eI{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class eP extends eI{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class eD extends eI{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class eO extends eI{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class eB extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class eF extends eI{getDefault(){return[0,1]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class eN extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class eV extends eI{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class eU extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class e$ extends eI{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class eH extends eI{getDefault(){return e.aO.transparent}set(t){let e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class eq extends eI{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ej extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class eG extends eI{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class eX extends eI{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class eZ extends eI{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class eW extends eI{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class eY extends eI{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class eK extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class eJ extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class eQ extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class e0 extends eI{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class e1 extends eI{getDefault(){return null}set(t){let e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class e2 extends eI{getDefault(){return null}set(t){var e;if(t===this.current&&!this.dirty)return;let i=this.gl;eT(i)?i.bindVertexArray(t):null==(e=i.getExtension("OES_vertex_array_object"))||e.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class e5 extends eI{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class e3 extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class e4 extends eI{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class e6 extends eI{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class e7 extends e6{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class e8 extends e6{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class e9 extends e6{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class it{constructor(t,e,i,n,r){this.context=t,this.width=e,this.height=i;let a=t.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new e7(t,o),n)this.depthAttachment=r?new e9(t,o):new e8(t,o);else if(r)throw Error("Stencil cannot be set without depth");if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error("Framebuffer is not complete")}destroy(){let t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){let e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class ie{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}ie.Replace=[1,0],ie.disabled=new ie(ie.Replace,e.aO.transparent,[!1,!1,!1,!1]),ie.unblended=new ie(ie.Replace,e.aO.transparent,[!0,!0,!0,!0]),ie.alphaBlended=new ie([1,771],e.aO.transparent,[!0,!0,!0,!0]);class ii{constructor(t){var e,i;if(this.gl=t,this.clearColor=new eS(this),this.clearDepth=new ez(this),this.clearStencil=new eL(this),this.colorMask=new eM(this),this.depthMask=new eR(this),this.stencilMask=new eP(this),this.stencilFunc=new eD(this),this.stencilOp=new eO(this),this.stencilTest=new eB(this),this.depthRange=new eF(this),this.depthTest=new eN(this),this.depthFunc=new eV(this),this.blend=new eU(this),this.blendFunc=new e$(this),this.blendColor=new eH(this),this.blendEquation=new eq(this),this.cullFace=new ej(this),this.cullFaceSide=new eG(this),this.frontFace=new eX(this),this.program=new eZ(this),this.activeTexture=new eW(this),this.viewport=new eY(this),this.bindFramebuffer=new eK(this),this.bindRenderbuffer=new eJ(this),this.bindTexture=new eQ(this),this.bindVertexBuffer=new e0(this),this.bindElementBuffer=new e1(this),this.bindVertexArray=new e2(this),this.pixelStoreUnpack=new e5(this),this.pixelStoreUnpackPremultiplyAlpha=new e3(this),this.pixelStoreUnpackFlipY=new e4(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),eT(t)){this.HALF_FLOAT=t.HALF_FLOAT;let n=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!=(e=t.RGBA16F)?e:null==n?void 0:n.RGBA16F_EXT,this.RGB16F=null!=(i=t.RGB16F)?i:null==n?void 0:n.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");let e=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==e?void 0:e.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(t,e){return new ek(this,t,e)}createVertexBuffer(t,e,i){return new eC(this,t,e,i)}createRenderbuffer(t,e,i){let n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),r}createFramebuffer(t,e,i,n){return new it(this,t,e,i,n)}clear({color:t,depth:e,stencil:i}){let n=this.gl,r=0;t&&(r|=n.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(r|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(r|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(r)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){e.aD(t.blendFunction,ie.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return eT(this.gl)?this.gl.createVertexArray():null==(t=this.gl.getExtension("OES_vertex_array_object"))?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var e;return eT(this.gl)?this.gl.deleteVertexArray(t):null==(e=this.gl.getExtension("OES_vertex_array_object"))?void 0:e.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class ir{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}ir.ReadOnly=!1,ir.ReadWrite=!0,ir.disabled=new ir(519,ir.ReadOnly,[0,1]);class ia{constructor(t,e,i,n,r,a){this.test=t,this.ref=e,this.mask=i,this.fail=n,this.depthFail=r,this.pass=a}}ia.disabled=new ia({func:519,mask:0},0,0,7680,7680,7680);class io{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}function is(t,i,n,r,a,o,l){var c;let d=t.context,u=d.gl,h=t.useProgram("collisionBox"),p=[],m=0,f=0;for(let s=0;s<r.length;s++){let c=r[s],g=i.getTile(c),_=g.getBucket(n);if(!_)continue;let b=c.posMatrix;0===a[0]&&0===a[1]||(b=t.translatePosMatrix(c.posMatrix,g,a,o));let y=l?_.textCollisionBox:_.iconCollisionBox,v=_.collisionCircleArray;if(v.length>0){let i=e.F(),n=b;e.aP(i,_.placementInvProjMatrix,t.transform.glCoordMatrix),e.aP(i,i,_.placementViewportMatrix),p.push({circleArray:v,circleOffset:f,transform:n,invTransform:i,coord:c}),m+=v.length/4,f=m}y&&h.draw(d,u.LINES,ir.disabled,ia.disabled,t.colorModeForRenderPass(),io.disabled,eo(b,t.transform,g),t.style.map.terrain&&t.style.map.terrain.getTerrainData(c),n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,null,t.transform.zoom,null,null,y.collisionVertexBuffer)}if(!l||!p.length)return;let g=t.useProgram("collisionCircle"),_=new e.aQ;_.resize(4*m),_._trim();let b=0;for(let t of p)for(let e=0;e<t.circleArray.length/4;e++){let i=4*e,n=t.circleArray[i+0],r=t.circleArray[i+1],a=t.circleArray[i+2],o=t.circleArray[i+3];_.emplace(b++,n,r,a,o,0),_.emplace(b++,n,r,a,o,1),_.emplace(b++,n,r,a,o,2),_.emplace(b++,n,r,a,o,3)}(!s||s.length<2*m)&&(s=function(t){let i=2*t,n=new e.aS;n.resize(i),n._trim();for(let t=0;t<i;t++){let e=6*t;n.uint16[e+0]=4*t+0,n.uint16[e+1]=4*t+1,n.uint16[e+2]=4*t+2,n.uint16[e+3]=4*t+2,n.uint16[e+4]=4*t+3,n.uint16[e+5]=4*t+0}return n}(m));let y=d.createIndexBuffer(s,!0),v=d.createVertexBuffer(_,e.aR.members,!0);for(let i of p){let r={u_matrix:i.transform,u_inv_matrix:i.invTransform,u_camera_to_center_distance:(c=t.transform).cameraToCenterDistance,u_viewport_size:[c.width,c.height]};g.draw(d,u.TRIANGLES,ir.disabled,ia.disabled,t.colorModeForRenderPass(),io.disabled,r,t.style.map.terrain&&t.style.map.terrain.getTerrainData(i.coord),n.id,v,y,e.$.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}v.destroy(),y.destroy()}io.disabled=new io(!1,1029,2305),io.backCCW=new io(!0,1029,2305);let il=e.an(new Float32Array(16));function ic(t,i,n,r,a,o,s,l,c,d,u,h){let p=t.context,m=p.gl,f=t.transform,g="map"===l,_="map"===c,b="viewport"!==l&&"point"!==n.layout.get("symbol-placement"),y=g&&!_&&!b,v=!n.layout.get("symbol-sort-key").isConstant(),x=!1,w=t.depthModeForSublayer(0,ir.ReadOnly),k=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[];for(let l of r){let r=i.getTile(l),c=r.getBucket(n);if(!c)continue;let u=a?c.text:c.icon;if(!u||!u.segments.get().length||!u.hasVisibleVertices)continue;let h=u.programConfigurations.get(n.id),p=a||c.sdfIcons,w=a?c.textSizeData:c.iconSizeData,C=_||0!==f.pitch,A=t.useProgram(c.iconsInText&&a?"symbolTextAndIcon":p?"symbolSDF":"symbolIcon",h),T=e.ag(w,f.zoom),I=t.style.map.terrain&&t.style.map.terrain.getTerrainData(l),S,z,M,R,P=[0,0],D=null;if(a)z=r.glyphAtlasTexture,M=m.LINEAR,S=r.glyphAtlasTexture.size,c.iconsInText&&(P=r.imageAtlasTexture.size,D=r.imageAtlasTexture,R=C||t.options.rotating||t.options.zooming||"composite"===w.kind||"camera"===w.kind?m.LINEAR:m.NEAREST);else{let e=1!==n.layout.get("icon-size").constantOr(0)||c.iconsNeedLinear;z=r.imageAtlasTexture,M=p||t.options.rotating||t.options.zooming||e||C?m.LINEAR:m.NEAREST,S=r.imageAtlasTexture.size}let O=tM(r,1,t.transform.zoom),B=t_(l.posMatrix,_,g,t.transform,O),F=tb(l.posMatrix,_,g,t.transform,O),N=k&&c.hasTextData(),V="none"!==n.layout.get("icon-text-fit")&&N&&c.hasIconData();if(b){let i=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(l,e,i):null,r="map"===n.layout.get("text-rotation-alignment");!function(t,i,n,r,a,o,s,l,c,d){let u=r?t.textSizeData:t.iconSizeData,h=e.ag(u,n.transform.zoom),p=[256/n.width*2+1,256/n.height*2+1],m=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;m.clear();let f=t.lineVertexArray,g=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,_=n.transform.width/n.transform.height,b=!1;for(let r=0;r<g.length;r++){let y,v=g.get(r);if(v.hidden||v.writingMode===e.ah.vertical&&!b||(b=!1,d?(y=[v.anchorX,v.anchorY,d(v.anchorX,v.anchorY),1],e.af(y,y,i)):tz(y=[v.anchorX,v.anchorY,0,1],y,i),!function(t,e){let i=t[0]/t[3],n=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&n>=-e[1]&&n<=e[1]}(y,p))){tS(v.numGlyphs,m);continue}let x=tv(n.transform.cameraToCenterDistance,y[3]),w=e.ai(u,h,v),k=s?w/x:w*x,E=new e.P(v.anchorX,v.anchorY),C=ty(E,a,d).point,A={projections:{},offsets:{}},T=tk(v,k,!1,l,i,a,o,t.glyphOffsetArray,f,m,C,E,A,_,c,d);b=T.useVertical,(T.notEnoughRoom||b||T.needsFlipping&&tk(v,k,!0,l,i,a,o,t.glyphOffsetArray,f,m,C,E,A,_,c,d).notEnoughRoom)&&tS(v.numGlyphs,m)}r?t.text.dynamicLayoutVertexBuffer.updateData(m):t.icon.dynamicLayoutVertexBuffer.updateData(m)}(c,l.posMatrix,t,a,B,F,_,d,r,i)}let U=t.translatePosMatrix(l.posMatrix,r,o,s),$=b||a&&k||V?il:B,H=t.translatePosMatrix(F,r,o,s,!0),q=p&&0!==n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1),j={program:A,buffers:u,uniformValues:p?c.iconsInText?ey(w.kind,T,y,_,t,U,$,H,S,P):eb(w.kind,T,y,_,t,U,$,H,a,S,!0):e_(w.kind,T,y,_,t,U,$,H,a,S),atlasTexture:z,atlasTextureIcon:D,atlasInterpolation:M,atlasInterpolationIcon:R,isSDF:p,hasHalo:q};if(v&&c.canOverlap)for(let t of(x=!0,u.segments.get()))E.push({segments:new e.$([t]),sortKey:t.sortKey,state:j,terrainData:I});else E.push({segments:u.segments,sortKey:0,state:j,terrainData:I})}for(let e of(x&&E.sort((t,e)=>t.sortKey-e.sortKey),E)){let i=e.state;if(p.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(p.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){let r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,id(i.buffers,e.segments,n,t,i.program,w,u,h,r,e.terrainData)),r.u_is_halo=0}id(i.buffers,e.segments,n,t,i.program,w,u,h,i.uniformValues,e.terrainData)}}function id(t,e,i,n,r,a,o,s,l,c){let d=n.context;r.draw(d,d.gl.TRIANGLES,a,o,s,io.disabled,l,c,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,n.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function iu(t,e,i,n,r){if(!i||!n||!n.imageAtlas)return;let a=n.imageAtlas.patternPositions,o=a[i.to.toString()],s=a[i.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let t=r.getPaintProperty(e);o=a[t],s=a[t]}o&&s&&t.setConstantPatternPositions(o,s)}function ih(t,e,i,n,r,a,o){let s,l,c,d,u,h=t.context.gl,p="fill-pattern",m=i.paint.get(p),f=m&&m.constantOr(1),g=i.getCrossfadeParameters();o?(l=f&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",s=h.LINES):(l=f?"fillPattern":"fill",s=h.TRIANGLES);let _=m.constantOr(null);for(let m of n){let n=e.getTile(m);if(f&&!n.patternsLoaded())continue;let b=n.getBucket(i);if(!b)continue;let y=b.programConfigurations.get(i.id),v=t.useProgram(l,y),x=t.style.map.terrain&&t.style.map.terrain.getTerrainData(m);f&&(t.context.activeTexture.set(h.TEXTURE0),n.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),y.updatePaintBuffers(g)),iu(y,p,_,n,i);let w=x?m:null,k=t.translatePosMatrix(w?w.posMatrix:m.posMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor"));if(o){d=b.indexBuffer2,u=b.segments2;let e=[h.drawingBufferWidth,h.drawingBufferHeight];c="fillOutlinePattern"===l&&f?er(k,t,g,n,e):en(k,e)}else d=b.indexBuffer,u=b.segments,c=f?ei(k,t,g,n):ee(k);v.draw(t.context,s,r,t.stencilModeForClipping(m),a,io.disabled,c,x,i.id,b.layoutVertexBuffer,d,u,i.paint,t.transform.zoom,y)}}function ip(t,e,i,n,r,a,o){let s=t.context,l=s.gl,c="fill-extrusion-pattern",d=i.paint.get(c),u=d.constantOr(1),h=i.getCrossfadeParameters(),p=i.paint.get("fill-extrusion-opacity"),m=d.constantOr(null);for(let d of n){let n=e.getTile(d),f=n.getBucket(i);if(!f)continue;let g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(d),_=f.programConfigurations.get(i.id),b=t.useProgram(u?"fillExtrusionPattern":"fillExtrusion",_);u&&(t.context.activeTexture.set(l.TEXTURE0),n.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),_.updatePaintBuffers(h)),iu(_,c,m,n,i);let y=t.translatePosMatrix(d.posMatrix,n,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),v=i.paint.get("fill-extrusion-vertical-gradient"),x=u?et(y,t,v,p,d,h,n):t9(y,t,v,p);b.draw(s,s.gl.TRIANGLES,r,a,o,io.backCCW,x,g,i.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,i.paint,t.transform.zoom,_,t.style.map.terrain&&f.centroidVertexBuffer)}}let im=new e.aO(1,0,0,1),ig=new e.aO(0,1,0,1),i_=new e.aO(0,0,1,1),ib=new e.aO(1,0,1,1),iy=new e.aO(0,1,1,1);function iv(t,e,i,n){iw(t,0,e+i/2,t.transform.width,i,n)}function ix(t,e,i,n){iw(t,e-i/2,0,i,t.transform.height,n)}function iw(t,e,i,n,r,a){let o=t.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(e*t.pixelRatio,i*t.pixelRatio,n*t.pixelRatio,r*t.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function ik(t,e,i){let n=t.context,r=n.gl,a=t.colorModeForRenderPass(),o=new ir(r.LEQUAL,ir.ReadWrite,t.depthRangeFor3D),s=t.useProgram("terrain"),l=e.getTerrainMesh();for(let c of(n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height]),i)){let i=t.renderToTexture.getTexture(c),d=e.getTerrainData(c.tileID);n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,i.texture);let u={u_matrix:t.transform.calculatePosMatrix(c.tileID.toUnwrapped()),u_texture:0,u_ele_delta:e.getMeshFrameDelta(t.transform.zoom)};s.draw(n,r.TRIANGLES,o,ia.disabled,a,io.backCCW,u,d,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}}class iE{constructor(t,i){this.context=new ii(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:e.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=tu.maxUnderzooming+tu.maxOverzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new tK}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,i=new e.aV;i.emplaceBack(0,0),i.emplaceBack(e.W,0),i.emplaceBack(0,e.W),i.emplaceBack(e.W,e.W),this.tileExtentBuffer=t.createVertexBuffer(i,t1.members),this.tileExtentSegments=e.$.simpleSegment(0,0,4,2);let n=new e.aV;n.emplaceBack(0,0),n.emplaceBack(e.W,0),n.emplaceBack(0,e.W),n.emplaceBack(e.W,e.W),this.debugBuffer=t.createVertexBuffer(n,t1.members),this.debugSegments=e.$.simpleSegment(0,0,4,5);let r=new e.Z;r.emplaceBack(0,0,0,0),r.emplaceBack(e.W,0,e.W,0),r.emplaceBack(0,e.W,0,e.W),r.emplaceBack(e.W,e.W,e.W,e.W),this.rasterBoundsBuffer=t.createVertexBuffer(r,J.members),this.rasterBoundsSegments=e.$.simpleSegment(0,0,4,2);let a=new e.aV;a.emplaceBack(0,0),a.emplaceBack(1,0),a.emplaceBack(0,1),a.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(a,t1.members),this.viewportSegments=e.$.simpleSegment(0,0,4,2);let o=new e.aW;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let s=new e.aX;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);let l=this.context.gl;this.stencilClearMode=new ia({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO)}clearStencil(){let t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let n=e.F();e.aN(n,0,this.width,this.height,0,0,1),e.J(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,i.TRIANGLES,ir.disabled,this.stencilClearMode,ie.disabled,io.disabled,el(n),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e||!e.length)return;this.currentStencilSource=t.source;let i=this.context,n=i.gl;this.nextStencilID+e.length>256&&this.clearStencil(),i.setColorMode(ie.disabled),i.setDepthMode(ir.disabled);let r=this.useProgram("clippingMask");for(let t of(this._tileClippingMaskIDs={},e)){let e=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,a=this.style.map.terrain&&this.style.map.terrain.getTerrainData(t);r.draw(i,n.TRIANGLES,ir.disabled,new ia({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),ie.disabled,io.disabled,el(t.posMatrix),a,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,e=this.context.gl;return new ia({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){let e=this.context.gl;return new ia({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}stencilConfigForOverlap(t){let e=this.context.gl,i=t.sort((t,e)=>e.overscaledZ-t.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();let t={};for(let i=0;i<r;i++)t[i+n]=new ia({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=r,[t,i]}return[{[n]:ia.disabled},i]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let i=1/8;return new ie([t.CONSTANT_COLOR,t.ONE],new e.aO(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ie.unblended:ie.alphaBlended}depthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return ir.disabled;let n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ir(i||this.context.gl.LEQUAL,e,[n,n])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(u.now()),this.imageManager.beginFrame();let n=this.style._order,r=this.style.sourceCaches,a={},o={},s={};for(let t in r){let e=r[t];e.used&&e.prepare(this.context),a[t]=e.getVisibleCoordinates(),o[t]=a[t].slice().reverse(),s[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<n.length;t++)if(this.style._layers[n[t]].is3D()){this.opaquePassCutoff=t;break}for(let t of(this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen",n)){let e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let i=o[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,r[e.source],e,i)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?e.aO.black:e.aO.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=n.length-1;this.currentLayer>=0;this.currentLayer--){let t=this.style._layers[n[this.currentLayer]],e=r[t.source],i=a[t.source];this._renderTileClippingMasks(t,i),this.renderLayer(this,e,t,i)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<n.length;this.currentLayer++){let t=this.style._layers[n[this.currentLayer]],e=r[t.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(t))continue;let i=("symbol"===t.type?s:o)[t.source];this._renderTileClippingMasks(t,a[t.source]),this.renderLayer(this,e,t,i)}if(this.options.showTileBoundaries){let t=function(t,e){let i=null,n=Object.values(t._layers).flatMap(i=>i.source&&!i.isHidden(e)?[t.sourceCaches[i.source]]:[]),r=n.filter(t=>"vector"===t.getSource().type),a=n.filter(t=>"vector"!==t.getSource().type),o=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};return r.forEach(t=>o(t)),i||a.forEach(t=>o(t)),i}(this.style,this.transform.zoom);t&&function(t,i,n){for(let r=0;r<n.length;r++)!function(t,i,n){let r=t.context,a=r.gl,o=n.posMatrix,s=t.useProgram("debug"),l=ir.disabled,c=ia.disabled,d=t.colorModeForRenderPass(),u="$debug",h=t.style.map.terrain&&t.style.map.terrain.getTerrainData(n);r.activeTexture.set(a.TEXTURE0);let p=i.getTileByID(n.key).latestRawTileData,m=Math.floor((p&&p.byteLength||0)/1024),f=512/Math.min(i.getTile(n).tileSize,512)*(n.overscaledZ/t.transform.zoom)*.5,g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();let i=t.debugOverlayCanvas,n=t.context.gl,r=t.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(e,5,5),r.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,`${g} ${m}kB`),s.draw(r,a.TRIANGLES,l,c,ie.alphaBlended,io.disabled,es(o,e.aO.transparent,f),null,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(r,a.LINE_STRIP,l,c,d,io.disabled,es(o,e.aO.red),h,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}(t,i,n[r])}(this,t,t.getVisibleCoordinates())}this.options.showPadding&&function(t){var e,i;let n=t.transform.padding;iv(t,t.transform.height-(n.top||0),3,im),iv(t,n.bottom||0,3,ig),ix(t,n.left||0,3,i_),ix(t,t.transform.width-(n.right||0),3,ib);let r=t.transform.centerPoint;e=r.x,i=t.transform.height-r.y,iw(t,e-1,i-10,2,20,iy),iw(t,e-10,i-1,20,2,iy)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;let i=this.terrainFacilitator.matrix,n=this.transform.projMatrix,r=this.terrainFacilitator.dirty;r||(r=t?!e.aY(i,n):!e.aZ(i,n)),r||(r=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),r&&(e.a_(i,n),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(t,i){let n=t.context,r=n.gl,a=ie.unblended,o=new ir(r.LEQUAL,ir.ReadWrite,[0,1]),s=i.getTerrainMesh(),l=i.sourceCache.getRenderableTiles(),c=t.useProgram("terrainDepth");for(let d of(n.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aO.transparent,depth:1}),l)){let e=i.getTerrainData(d.tileID),l={u_matrix:t.transform.calculatePosMatrix(d.tileID.toUnwrapped()),u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};c.draw(n,r.TRIANGLES,o,ia.disabled,a,io.backCCW,l,e,"terrain",s.vertexBuffer,s.indexBuffer,s.segments)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain),function(t,i){let n=t.context,r=n.gl,a=ie.unblended,o=new ir(r.LEQUAL,ir.ReadWrite,[0,1]),s=i.getTerrainMesh(),l=i.getCoordsTexture(),c=i.sourceCache.getRenderableTiles(),d=t.useProgram("terrainCoords");for(let u of(n.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.aO.transparent,depth:1}),i.coordsIndex=[],c)){let e=i.getTerrainData(u.tileID);n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,l.texture);let c={u_matrix:t.transform.calculatePosMatrix(u.tileID.toUnwrapped()),u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(t.transform.zoom)};d.draw(n,r.TRIANGLES,o,ia.disabled,a,io.backCCW,c,e,"terrain",s.vertexBuffer,s.indexBuffer,s.segments),i.coordsIndex.push(u.tileID.key)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}(this,this.style.map.terrain))}renderLayer(t,i,n,r){if(!n.isHidden(this.transform.zoom)&&("background"===n.type||"custom"===n.type||(r||[]).length))switch(this.id=n.id,n.type){case"symbol":!function(t,i,n,r,a){if("translucent"!==t.renderPass)return;let o=ia.disabled,s=t.colorModeForRenderPass();(n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,n,r,a,o,s){let l=i.transform,c="map"===a,d="map"===o;for(let a of t){let t=r.getTile(a),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;let u=e.ag(o.textSizeData,l.zoom),h=tM(t,1,i.transform.zoom),p=t_(a.posMatrix,d,c,i.transform,h),m="none"!==n.layout.get("icon-text-fit")&&o.hasIconData();if(u){let n=Math.pow(2,l.zoom-t.tileID.overscaledZ);!function(t,i,n,r,a,o,s,l,c,d,u){let h=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,f={};p.clear();for(let m=0;m<h.length;m++){let g=h.get(m),_=g.hidden||!g.crossTileID||t.allowVerticalPlacement&&!g.placedOrientation?null:r[g.crossTileID];if(_){let r=new e.P(g.anchorX,g.anchorY),h=ty(r,n?s:o,u),m=tv(a.cameraToCenterDistance,h.signedDistanceFromCamera),b=e.ai(t.textSizeData,c,g)*m/e.ao;n&&(b*=t.tilePixelRatio/l);let{width:y,height:v,anchor:x,textOffset:w,textBoxScale:k}=_,E=function(t,i,n,r,a,o){let{horizontalAlign:s,verticalAlign:l}=e.at(t);return new e.P((-(s-.5)*i/a+r[0])*o,(-(l-.5)*n/a+r[1])*o)}(x,y,v,w,k,b),C=n?ty(r.add(E),o,u).point:h.point.add(i?E.rotate(-a.angle):E),A=t.allowVerticalPlacement&&g.placedOrientation===e.ah.vertical?Math.PI/2:0;for(let t=0;t<g.numGlyphs;t++)e.aj(p,C,A);d&&g.associatedIconIndex>=0&&(f[g.associatedIconIndex]={shiftedAnchor:C,angle:A})}else tS(g.numGlyphs,p)}if(d){m.clear();let i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){let n=i.get(t);if(n.hidden)tS(n.numGlyphs,m);else{let i=f[t];if(i)for(let t=0;t<n.numGlyphs;t++)e.aj(m,i.shiftedAnchor,i.angle);else tS(n.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(p)}(o,c,d,s,l,p,a.posMatrix,n,u,m,i.style.map.terrain?(t,e)=>i.style.map.terrain.getElevation(a,t,e):null)}}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),a),0!==n.paint.get("icon-opacity").constantOr(1)&&ic(t,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),o,s),0!==n.paint.get("text-opacity").constantOr(1)&&ic(t,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),o,s),i.map.showCollisionBoxes&&(is(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),is(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))}(t,i,n,r,this.style.placement.variableOffsets);break;case"circle":!function(t,i,n,r){if("translucent"!==t.renderPass)return;let a=n.paint.get("circle-opacity"),o=n.paint.get("circle-stroke-width"),s=n.paint.get("circle-stroke-opacity"),l=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===o.constantOr(1)||0===s.constantOr(1)))return;let c=t.context,d=c.gl,u=t.depthModeForSublayer(0,ir.ReadOnly),h=ia.disabled,p=t.colorModeForRenderPass(),m=[];for(let a=0;a<r.length;a++){let o=r[a],s=i.getTile(o),c=s.getBucket(n);if(!c)continue;let d=c.programConfigurations.get(n.id),u=t.useProgram("circle",d),h=c.layoutVertexBuffer,p=c.indexBuffer,f=t.style.map.terrain&&t.style.map.terrain.getTerrainData(o),g={programConfiguration:d,program:u,layoutVertexBuffer:h,indexBuffer:p,uniformValues:ea(t,o,s,n),terrainData:f};if(l)for(let t of c.segments.get())m.push({segments:new e.$([t]),sortKey:t.sortKey,state:g});else m.push({segments:c.segments,sortKey:0,state:g})}for(let e of(l&&m.sort((t,e)=>t.sortKey-e.sortKey),m)){let{programConfiguration:i,program:r,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:l}=e.state;r.draw(c,d.TRIANGLES,u,h,p,io.disabled,s,l,n.id,a,o,e.segments,n.paint,t.transform.zoom,i)}}(t,i,n,r);break;case"heatmap":!function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){let a=t.context,o=a.gl,s=ia.disabled,l=new ie([o.ONE,o.ONE],e.aO.transparent,[!0,!0,!0,!0]);!function(t,e,i){let n=t.gl;t.activeTexture.set(n.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let r=i.heatmapFbo;if(r)n.bindTexture(n.TEXTURE_2D,r.colorAttachment.get()),t.bindFramebuffer.set(r.framebuffer);else{let a=n.createTexture();n.bindTexture(n.TEXTURE_2D,a),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),r=i.heatmapFbo=t.createFramebuffer(e.width/4,e.height/4,!1,!1),function(t,e,i,n){var r,a;let o=t.gl,s=null!=(r=t.HALF_FLOAT)?r:o.UNSIGNED_BYTE,l=null!=(a=t.RGBA16F)?a:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,e.width/4,e.height/4,0,o.RGBA,s,null),n.colorAttachment.set(i)}(t,e,a,r)}}(a,t,n),a.clear({color:e.aO.transparent});for(let e=0;e<r.length;e++){let c=r[e];if(i.hasRenderableParent(c))continue;let d=i.getTile(c),u=d.getBucket(n);if(!u)continue;let h=u.programConfigurations.get(n.id),p=t.useProgram("heatmap",h),{zoom:m}=t.transform;p.draw(a,o.TRIANGLES,ir.disabled,s,l,io.disabled,ec(c.posMatrix,d,m,n.paint.get("heatmap-intensity")),null,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,t.transform.zoom,h)}a.viewport.set([0,0,t.width,t.height])}else"translucent"===t.renderPass&&(t.context.setColorMode(t.colorModeForRenderPass()),function(t,i){let n=t.context,r=n.gl,a=i.heatmapFbo;if(!a)return;n.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),n.activeTexture.set(r.TEXTURE1);let o=i.colorRampTexture;o||(o=i.colorRampTexture=new S(n,i.colorRamp,r.RGBA)),o.bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(n,r.TRIANGLES,ir.disabled,ia.disabled,t.colorModeForRenderPass(),io.disabled,((t,i,n,r)=>{let a=e.F();e.aN(a,0,t.width,t.height,0,0,1);let o=t.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:i.paint.get("heatmap-opacity")}})(t,i),null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom)}(t,n))}(t,i,n,r);break;case"line":!function(t,i,n,r){if("translucent"!==t.renderPass)return;let a=n.paint.get("line-opacity"),o=n.paint.get("line-width");if(0===a.constantOr(1)||0===o.constantOr(1))return;let s=t.depthModeForSublayer(0,ir.ReadOnly),l=t.colorModeForRenderPass(),c=n.paint.get("line-dasharray"),d=n.paint.get("line-pattern"),u=d.constantOr(1),h=n.paint.get("line-gradient"),p=n.getCrossfadeParameters(),m=u?"linePattern":c?"lineSDF":h?"lineGradient":"line",f=t.context,g=f.gl,_=!0;for(let a of r){let r=i.getTile(a);if(u&&!r.patternsLoaded())continue;let o=r.getBucket(n);if(!o)continue;let b=o.programConfigurations.get(n.id),y=t.context.program.get(),v=t.useProgram(m,b),x=_||v.program!==y,w=t.style.map.terrain&&t.style.map.terrain.getTerrainData(a),k=d.constantOr(null);if(k&&r.imageAtlas){let t=r.imageAtlas,e=t.patternPositions[k.to.toString()],i=t.patternPositions[k.from.toString()];e&&i&&b.setConstantPatternPositions(e,i)}let E=w?a:null,C=u?eh(t,r,n,p,E):c?ep(t,r,n,c,p,E):h?eu(t,r,n,o.lineClipsArray.length,E):ed(t,r,n,E);if(u)f.activeTexture.set(g.TEXTURE0),r.imageAtlasTexture.bind(g.LINEAR,g.CLAMP_TO_EDGE),b.updatePaintBuffers(p);else if(c&&(x||t.lineAtlas.dirty))f.activeTexture.set(g.TEXTURE0),t.lineAtlas.bind(f);else if(h){let r=o.gradients[n.id],s=r.texture;if(n.gradientVersion!==r.version){let l=256;if(n.stepInterpolant){let n=i.getSource().maxzoom,r=a.canonical.z===n?Math.ceil(1<<t.transform.maxZoom-a.canonical.z):1;l=e.ac(e.aT(o.maxLineLength/e.W*1024*r),256,f.maxTextureSize)}r.gradient=e.aU({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:r.gradient||void 0,clips:o.lineClipsArray}),r.texture?r.texture.update(r.gradient):r.texture=new S(f,r.gradient,g.RGBA),r.version=n.gradientVersion,s=r.texture}f.activeTexture.set(g.TEXTURE0),s.bind(n.stepInterpolant?g.NEAREST:g.LINEAR,g.CLAMP_TO_EDGE)}v.draw(f,g.TRIANGLES,s,t.stencilModeForClipping(a),l,io.disabled,C,w,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segments,n.paint,t.transform.zoom,b,o.layoutVertexBuffer2),_=!1}}(t,i,n,r);break;case"fill":!function(t,i,n,r){let a=n.paint.get("fill-color"),o=n.paint.get("fill-opacity");if(0===o.constantOr(1))return;let s=t.colorModeForRenderPass(),l=n.paint.get("fill-pattern"),c=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===a.constantOr(e.aO.transparent).a&&1===o.constantOr(0)?"opaque":"translucent";if(t.renderPass===c){let e=t.depthModeForSublayer(1,"opaque"===t.renderPass?ir.ReadWrite:ir.ReadOnly);ih(t,i,n,r,e,s,!1)}if("translucent"===t.renderPass&&n.paint.get("fill-antialias")){let e=t.depthModeForSublayer(2*!!n.getPaintProperty("fill-outline-color"),ir.ReadOnly);ih(t,i,n,r,e,s,!0)}}(t,i,n,r);break;case"fill-extrusion":let a=n.paint.get("fill-extrusion-opacity");if(0!==a&&"translucent"===t.renderPass){let e=new ir(t.context.gl.LEQUAL,ir.ReadWrite,t.depthRangeFor3D);if(1!==a||n.paint.get("fill-extrusion-pattern").constantOr(1))ip(t,i,n,r,e,ia.disabled,ie.disabled),ip(t,i,n,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass());else{let a=t.colorModeForRenderPass();ip(t,i,n,r,e,ia.disabled,a)}}break;case"hillshade":!function(t,i,n,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;let a=t.context,o=t.depthModeForSublayer(0,ir.ReadOnly),s=t.colorModeForRenderPass(),[l,c]="translucent"===t.renderPass?t.stencilConfigForOverlap(r):[{},r];for(let r of c){let a=i.getTile(r);void 0!==a.needsHillshadePrepare&&a.needsHillshadePrepare&&"offscreen"===t.renderPass?function(t,i,n,r,a,o){let s=t.context,l=s.gl,c=i.dem;if(c&&c.data){let d=c.dim,u=c.stride,h=c.getPixels();if(s.activeTexture.set(l.TEXTURE1),s.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(u),i.demTexture){let t=i.demTexture;t.update(h,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new S(s,h,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);s.activeTexture.set(l.TEXTURE0);let p=i.fbo;if(!p){let t=new S(s,{width:d,height:d,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),(p=i.fbo=s.createFramebuffer(d,d,!0,!1)).colorAttachment.set(t.texture)}s.bindFramebuffer.set(p.framebuffer),s.viewport.set([0,0,d,d]),t.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,r,a,o,io.disabled,((t,i)=>{let n=i.stride,r=e.F();return e.aN(r,0,e.W,-e.W,0,0,1),e.H(r,r,[0,-e.W,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}})(i.tileID,c),null,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}}(t,a,n,o,ia.disabled,s):"translucent"===t.renderPass&&function(t,i,n,r,a,o,s){let l=t.context,c=l.gl,d=n.fbo;if(!d)return;let u=t.useProgram("hillshade"),h=t.style.map.terrain&&t.style.map.terrain.getTerrainData(i);l.activeTexture.set(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,d.colorAttachment.get()),u.draw(l,c.TRIANGLES,a,o,s,io.disabled,((t,i,n,r)=>{let a=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),s=n.paint.get("hillshade-accent-color"),l=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(l-=t.transform.angle);let c=!t.options.moving;return{u_matrix:r?r.posMatrix:t.transform.calculatePosMatrix(i.tileID.toUnwrapped(),c),u_image:0,u_latrange:function(t,i){let n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new e.Y(0,r/n).toLngLat().lat,new e.Y(0,(r+1)/n).toLngLat().lat]}(0,i.tileID),u_light:[n.paint.get("hillshade-exaggeration"),l],u_shadow:a,u_highlight:o,u_accent:s}})(t,n,r,h?i:null),h,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}(t,r,a,n,o,l[r.overscaledZ],s)}a.viewport.set([0,0,t.width,t.height])}(t,i,n,r);break;case"raster":!function(t,i,n,r){if("translucent"!==t.renderPass||0===n.paint.get("raster-opacity")||!r.length)return;let a=t.context,o=a.gl,s=i.getSource(),l=t.useProgram("raster"),c=t.colorModeForRenderPass(),[d,h]=s instanceof Q?[{},r]:t.stencilConfigForOverlap(r),p=h[h.length-1].overscaledZ,m=!t.options.moving;for(let r of h){let h,f,g=t.depthModeForSublayer(r.overscaledZ-p,1===n.paint.get("raster-opacity")?ir.ReadWrite:ir.ReadOnly,o.LESS),_=i.getTile(r);_.registerFadeDuration(n.paint.get("raster-fade-duration"));let b=i.findLoadedParent(r,0),y=function(t,i,n,r,a,o){let s=r.paint.get("raster-fade-duration");if(!o&&s>0){let r=u.now(),o=(r-t.timeAdded)/s,l=i?(r-i.timeAdded)/s:-1,c=n.getSource(),d=a.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-d)>Math.abs(t.tileID.overscaledZ-d),p=h&&t.refreshedUponExpiration?1:e.ac(h?o:1-l,0,1);return t.refreshedUponExpiration&&o>=1&&(t.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}(_,b,i,n,t.transform,t.style.map.terrain),v="nearest"===n.paint.get("raster-resampling")?o.NEAREST:o.LINEAR;a.activeTexture.set(o.TEXTURE0),_.texture.bind(v,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),a.activeTexture.set(o.TEXTURE1),b?(b.texture.bind(v,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST),h=Math.pow(2,b.tileID.overscaledZ-_.tileID.overscaledZ),f=[_.tileID.canonical.x*h%1,_.tileID.canonical.y*h%1]):_.texture.bind(v,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_NEAREST);let x=t.style.map.terrain&&t.style.map.terrain.getTerrainData(r),w=x?r:null,k=eg(w?w.posMatrix:t.transform.calculatePosMatrix(r.toUnwrapped(),m),f||[0,0],h||1,y,n);s instanceof Q?l.draw(a,o.TRIANGLES,g,ia.disabled,c,io.disabled,k,x,n.id,s.boundsBuffer,t.quadTriangleIndexBuffer,s.boundsSegments):l.draw(a,o.TRIANGLES,g,d[r.overscaledZ],c,io.disabled,k,x,n.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments)}}(t,i,n,r);break;case"background":!function(t,e,i,n){let r=i.paint.get("background-color"),a=i.paint.get("background-opacity");if(0===a)return;let o=t.context,s=o.gl,l=t.transform,c=l.tileSize,d=i.paint.get("background-pattern");if(t.isPatternMissing(d))return;let u=!d&&1===r.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==u)return;let h=ia.disabled,p=t.depthModeForSublayer(0,"opaque"===u?ir.ReadWrite:ir.ReadOnly),m=t.colorModeForRenderPass(),f=t.useProgram(d?"backgroundPattern":"background"),g=n||l.coveringTiles({tileSize:c,terrain:t.style.map.terrain});d&&(o.activeTexture.set(s.TEXTURE0),t.imageManager.bind(t.context));let _=i.getCrossfadeParameters();for(let e of g){let l=n?e.posMatrix:t.transform.calculatePosMatrix(e.toUnwrapped()),u=d?ex(l,a,t,d,{tileID:e,tileSize:c},_):ev(l,a,r),g=t.style.map.terrain&&t.style.map.terrain.getTerrainData(e);f.draw(o,s.TRIANGLES,p,h,m,io.disabled,u,g,i.id,t.tileExtentBuffer,t.quadTriangleIndexBuffer,t.tileExtentSegments)}}(t,0,n,r);break;case"custom":let o=t.context,s=n.implementation;if("offscreen"===t.renderPass){let e=s.prerender;e&&(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),e.call(s,o.gl,t.transform.customLayerMatrix()),o.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),o.setStencilMode(ia.disabled);let e="3d"===s.renderingMode?new ir(t.context.gl.LEQUAL,ir.ReadWrite,t.depthRangeFor3D):t.depthModeForSublayer(0,ir.ReadOnly);o.setDepthMode(e),s.render(o.gl,t.transform.customLayerMatrix()),o.setDirty(),t.setBaseState(),o.bindFramebuffer.set(null)}}}translatePosMatrix(t,i,n,r,a){if(!n[0]&&!n[1])return t;let o=a?"map"===r?this.transform.angle:0:"viewport"===r?-this.transform.angle:0;if(o){let t=Math.sin(o),e=Math.cos(o);n=[n[0]*e-n[1]*t,n[0]*t+n[1]*e]}let s=[a?n[0]:tM(i,n[0],this.transform.zoom),a?n[1]:tM(i,n[1],this.transform.zoom),0],l=new Float32Array(16);return e.H(l,t,s),l}saveTileTexture(t){let e=this._tileTextures[t.size[0]];e?e.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e){this.cache=this.cache||{};let i=t+(e?e.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[i]||(this.cache[i]=new t7(this.context,t5[t],e,ew[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[i]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new S(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}class iC{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,i,n){let r=Math.pow(2,n),a=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(n=>{let a=1/(n=e.af([],n,t))[3]/i*r;return e.a$(n,n,[a,a,1/n[3],a])}),o=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(t=>{var e,i,n,r,o,s,l,c,d,u,h,p,m,f,g,_;let b=(h=[],m=(i=[],n=A([],a[t[0]],a[t[1]]),r=A([],a[t[2]],a[t[1]]),o=n[0],s=n[1],l=n[2],c=r[0],d=r[1],u=r[2],i[0]=s*u-l*d,i[1]=l*c-o*u,i[2]=o*d-s*c,p=i)[0],(_=m*m+(f=p[1])*f+(g=p[2])*g)>0&&(_=1/Math.sqrt(_)),h[0]=p[0]*_,h[1]=p[1]*_,h[2]=p[2]*_,h),y=-(b[0]*(e=a[t[1]])[0]+b[1]*e[1]+b[2]*e[2]);return b.concat(y)});return new iC(a,o)}}class iA{constructor(t,e){this.min=t,this.max=e,this.center=function(t,e,i){return t[0]=.5*e[0],t[1]=.5*e[1],t[2]=.5*e[2],t}([],function(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}([],this.min,this.max))}quadrant(t){let e=[t%2==0,t<2],i=x(this.min),n=x(this.max);for(let t=0;t<e.length;t++)i[t]=e[t]?this.min[t]:this.center[t],n[t]=e[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new iA(i,n)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){let i=[[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]],n=!0;for(let r=0;r<t.planes.length;r++){let a=t.planes[r],o=0;for(let t=0;t<i.length;t++)e.b0(a,i[t])>=0&&o++;if(0===o)return 0;o!==i.length&&(n=!1)}if(n)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;r<t.points.length;r++){let a=t.points[r][e]-this.min[e];i=Math.min(i,a),n=Math.max(n,a)}if(n<0||i>this.max[e]-this.min[e])return 0}return 1}}class iT{constructor(t=0,e=0,i=0,n=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(n)||n<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.z.number(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.z.number(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.z.number(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.z.number(t.right,i.right,n)),this}getCenter(t,i){let n=e.ac((this.left+t-this.right)/2,0,t),r=e.ac((this.top+i-this.bottom)/2,0,i);return new e.P(n,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new iT(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}class iI{constructor(t,i,n,r,a){this.tileSize=512,this._renderWorldCopies=void 0===a||!!a,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setMaxBounds(),this.width=0,this.height=0,this._center=new e.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new iT,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){let t=new iI(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){var i,n,r,a,o,s,l,c,d,u;let h=-e.b1(t,-180,180)*Math.PI/180;this.angle!==h&&(this._unmodified=!1,this.angle=h,this._calcMatrices(),this.rotationMatrix=(i=new e.A(4),e.A!=Float32Array&&(i[1]=0,i[2]=0),i[0]=1,i[3]=1,i),n=this.rotationMatrix,r=this.rotationMatrix,a=this.angle,o=r[0],s=r[1],l=r[2],c=r[3],d=Math.sin(a),u=Math.cos(a),n[0]=o*u+l*d,n[1]=s*u+c*d,n[2]=-(o*d)+l*u,n[3]=-(s*d)+c*u)}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let i=e.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){let e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this.tileZoom=Math.max(0,Math.floor(e)),this.scale=this.zoomScale(e),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){return Math.max(0,(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize)))}getVisibleUnwrappedCoordinates(t){let i=[new e.b2(0,t)];if(this._renderWorldCopies){let n=this.pointCoordinate(new e.P(0,0)),r=this.pointCoordinate(new e.P(this.width,0)),a=this.pointCoordinate(new e.P(this.width,this.height)),o=this.pointCoordinate(new e.P(0,this.height)),s=Math.floor(Math.min(n.x,r.x,a.x,o.x)),l=Math.floor(Math.max(n.x,r.x,a.x,o.x));for(let n=s-1;n<=l+1;n++)0!==n&&i.push(new e.b2(n,t))}return i}coveringTiles(t){var i,n;let r=this.coveringZoomLevel(t),a=r;if(void 0!==t.minzoom&&r<t.minzoom)return[];void 0!==t.maxzoom&&r>t.maxzoom&&(r=t.maxzoom);let o=this.pointCoordinate(this.getCameraPoint()),s=e.Y.fromLngLat(this.center),l=Math.pow(2,r),c=[l*o.x,l*o.y,0],d=[l*s.x,l*s.y,0],u=iC.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,r),h=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(h=r);let p=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,m=t=>({aabb:new iA([t*l,0,0],[(t+1)*l,l,0]),zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),f=[],g=[],_=r,b=t.reparseOverscaled?a:r;if(this._renderWorldCopies)for(let t=1;t<=3;t++)f.push(m(-t)),f.push(m(t));for(f.push(m(0));f.length>0;){let r=f.pop(),a=r.x,o=r.y,s=r.fullyVisible;if(!s){let t=r.aabb.intersects(u);if(0===t)continue;s=2===t}let l=t.terrain?c:d,m=Math.max(Math.abs(r.aabb.distanceX(l)),Math.abs(r.aabb.distanceY(l)));if(r.zoom===_||m>p+(1<<_-r.zoom)-2&&r.zoom>=h){let t=_-r.zoom,i=c[0]-.5-(a<<t),n=c[1]-.5-(o<<t);g.push({tileID:new e.Q(r.zoom===_?b:r.zoom,r.wrap,r.zoom,a,o),distanceSq:T([d[0]-.5-a,d[1]-.5-o]),tileDistanceToCamera:Math.sqrt(i*i+n*n)})}else for(let l=0;l<4;l++){let c=(a<<1)+l%2,d=(o<<1)+(l>>1),u=r.zoom+1,h=r.aabb.quadrant(l);if(t.terrain){let a=new e.Q(u,r.wrap,u,c,d),o=t.terrain.getMinMaxElevation(a),s=null!=(i=o.minElevation)?i:this.elevation,l=null!=(n=o.maxElevation)?n:this.elevation;h=new iA([h.min[0],h.min[1],s],[h.max[0],h.max[1],l])}f.push({aabb:h,zoom:u,x:c,y:d,wrap:r.wrap,fullyVisible:s})}}return g.sort((t,e)=>t.distanceSq-e.distanceSq).map(t=>t.tileID)}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){let i=e.ac(t.lat,-85.051129,85.051129);return new e.P(e.N(t.lng)*this.worldSize,e.O(i)*this.worldSize)}unproject(t){return new e.Y(t.x/this.worldSize,t.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(t){let i=this.elevation,n=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,r=this.pointLocation(this.centerPoint,t),a=t.getElevationForLngLatZoom(r,this.tileZoom);if(!(this.elevation-a))return;let o=Math.cos(this._pitch)*this.cameraToCenterDistance/(n+i-a)/e.b3(1,r.lat),s=this.scaleZoom(o/this.tileSize);this._elevation=a,this._center=r,this.zoom=s}setLocationAtPoint(t,i){let n=this.pointCoordinate(i),r=this.pointCoordinate(this.centerPoint),a=this.locationCoordinate(t),o=new e.Y(a.x-(n.x-r.x),a.y-(n.y-r.y));this.center=this.coordinateLocation(o),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,e){return e?this.coordinatePoint(this.locationCoordinate(t),e.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,e){return this.coordinateLocation(this.pointCoordinate(t,e))}locationCoordinate(t){return e.Y.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,i){if(i){let e=i.pointCoordinate(t);if(null!=e)return e}let n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];e.af(n,n,this.pixelMatrixInverse),e.af(r,r,this.pixelMatrixInverse);let a=n[3],o=r[3],s=n[1]/a,l=r[1]/o,c=n[2]/a,d=r[2]/o,u=c===d?0:(0-c)/(d-c);return new e.Y(e.z.number(n[0]/a,r[0]/o,u)/this.worldSize,e.z.number(s,l,u)/this.worldSize)}coordinatePoint(t,i=0,n=this.pixelMatrix){let r=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.af(r,r,n),new e.P(r[0]/r[3],r[1]/r[3])}getBounds(){let t=Math.max(0,this.height/2-this.getHorizon());return(new G).extend(this.pointLocation(new e.P(0,t))).extend(this.pointLocation(new e.P(this.width,t))).extend(this.pointLocation(new e.P(this.width,this.height))).extend(this.pointLocation(new e.P(0,this.height)))}getMaxBounds(){return this.latRange&&2===this.latRange.length&&this.lngRange&&2===this.lngRange.length?new G([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(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,85.051129])}calculatePosMatrix(t,i=!1){let n=t.key,r=i?this._alignedPosMatrixCache:this._posMatrixCache;if(r[n])return r[n];let a=t.canonical,o=this.worldSize/this.zoomScale(a.z),s=a.x+Math.pow(2,a.z)*t.wrap,l=e.an(new Float64Array(16));return e.H(l,l,[s*o,a.y*o,0]),e.J(l,l,[o/e.W,o/e.W,1]),e.K(l,i?this.alignedProjMatrix:this.projMatrix,l),r[n]=new Float32Array(l),r[n]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,i){let n,r;i=e.ac(+i,this.minZoom,this.maxZoom);let a={center:new e.M(t.lng,t.lat),zoom:i},o=this.lngRange;this._renderWorldCopies||null!==o||(o=[-(180-1e-10),180-1e-10]);let s=this.tileSize*this.zoomScale(a.zoom),l=0,c=s,d=0,u=s,h=0,p=0,{x:m,y:f}=this.size;if(this.latRange){let t=this.latRange;l=e.O(t[1])*s,(c=e.O(t[0])*s)-l<f&&(h=f/(c-l))}o&&(d=e.b1(e.N(o[0])*s,0,s),(u=e.b1(e.N(o[1])*s,0,s))<d&&(u+=s),u-d<m&&(p=m/(u-d)));let{x:g,y:_}=this.project.call({worldSize:s},t),b=Math.max(p||0,h||0);if(b){let t=new e.P(p?(u+d)/2:g,h?(c+l)/2:_);return a.center=this.unproject.call({worldSize:s},t).wrap(),a.zoom+=this.scaleZoom(b),a}if(this.latRange){let t=f/2;_-t<l&&(r=l+t),_+t>c&&(r=c-t)}if(o){let t=(d+u)/2,i=g;this._renderWorldCopies&&(i=e.b1(g,t-s/2,t+s/2));let r=m/2;i-r<d&&(n=d+r),i+r>u&&(n=u-r)}if(void 0!==n||void 0!==r){let t=new e.P(null!=n?n:g,null!=r?r:_);a.center=this.unproject.call({worldSize:s},t).wrap()}return a}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:e,zoom:i}=this.getConstrained(this.center,this.zoom);this.center=e,this.zoom=i,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;let t=this.centerOffset,i=this.point.x,n=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=e.b3(1,this.center.lat)*this.worldSize;let r=e.an(new Float64Array(16));e.J(r,r,[this.width/2,-this.height/2,1]),e.H(r,r,[1,-1,0]),this.labelPlaneMatrix=r,r=e.an(new Float64Array(16)),e.J(r,r,[1,-1,1]),e.H(r,r,[-1,-1,0]),e.J(r,r,[2/this.width,2/this.height,1]),this.glCoordMatrix=r;let a=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),o=Math.min(this.elevation,this.minElevationForCurrentTile),s=a-o*this._pixelPerMeter/Math.cos(this._pitch),l=o<0?s:a,c=Math.PI/2+this._pitch,d=this._fov*(.5+t.y/this.height),u=Math.sin(d)*l/Math.sin(e.ac(Math.PI-c-d,.01,Math.PI-.01)),h=this.getHorizon(),p=2*Math.atan(h/this.cameraToCenterDistance)*(.5+t.y/(2*h)),m=Math.min(u,Math.sin(p)*l/Math.sin(e.ac(Math.PI-c-p,.01,Math.PI-.01))),f=1.01*(Math.cos(Math.PI/2-this._pitch)*m+l),g=this.height/50;r=new Float64Array(16),e.b4(r,this._fov,this.width/this.height,g,f),r[8]=-(2*t.x)/this.width,r[9]=2*t.y/this.height,e.J(r,r,[1,-1,1]),e.H(r,r,[0,0,-this.cameraToCenterDistance]),e.b5(r,r,this._pitch),e.ad(r,r,this.angle),e.H(r,r,[-i,-n,0]),this.mercatorMatrix=e.J([],r,[this.worldSize,this.worldSize,this.worldSize]),e.J(r,r,[1,1,this._pixelPerMeter]),this.pixelMatrix=e.K(new Float64Array(16),this.labelPlaneMatrix,r),e.H(r,r,[0,0,-this.elevation]),this.projMatrix=r,this.invProjMatrix=e.ar([],r),this.pixelMatrix3D=e.K(new Float64Array(16),this.labelPlaneMatrix,r);let _=this.width%2/2,b=this.height%2/2,y=Math.cos(this.angle),v=Math.sin(this.angle),x=i-Math.round(i)+y*_+v*b,w=n-Math.round(n)+y*b+v*_,k=new Float64Array(r);if(e.H(k,k,[x>.5?x-1:x,w>.5?w-1:w,0]),this.alignedProjMatrix=k,!(r=e.ar(new Float64Array(16),this.pixelMatrix)))throw Error("failed to invert matrix");this.pixelMatrixInverse=r,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let t=this.pointCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.af(i,i,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}getCameraQueryGeometry(t){let i=this.getCameraPoint();if(1===t.length)return[t[0],i];{let n=i.x,r=i.y,a=i.x,o=i.y;for(let e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),a=Math.max(a,e.x),o=Math.max(o,e.y);return[new e.P(n,r),new e.P(a,r),new e.P(a,o),new e.P(n,o),new e.P(n,r)]}}lngLatToCameraDepth(t,i){let n=this.locationCoordinate(t),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return e.af(r,r,this.projMatrix),r[2]/r[3]}}function iS(t,e){let i,n=!1,r=null,a=null,o=()=>{r=null,n&&(t.apply(a,i),r=setTimeout(o,e),n=!1)};return(...t)=>(n=!0,a=this,i=t,r||o(),r)}class iz{constructor(t){this._getCurrentHash=()=>{let t=window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(t=>t.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(t.length>=3&&!t.some(t=>isNaN(t))){let e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let t=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,t)}catch(t){}},this._updateHash=iS(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){let e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.pow(10,Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10)),r=Math.round(e.lng*n)/n,a=Math.round(e.lat*n)/n,o=this._map.getBearing(),s=this._map.getPitch(),l="";if(l+=t?`/${r}/${a}/${i}`:`${i}/${a}/${r}`,(o||s)&&(l+="/"+Math.round(10*o)/10),s&&(l+=`/${Math.round(s)}`),this._hashName){let t=this._hashName,e=!1,i=window.location.hash.slice(1).split("&").map(i=>{let n=i.split("=")[0];return n===t?(e=!0,`${n}=${l}`):i}).filter(t=>t);return e||i.push(`${t}=${l}`),`#${i.join("&")}`}return`#${l}`}}let iL={linearity:.3,easing:e.b6(0,0,.3,1)},iM=e.e({deceleration:2500,maxSpeed:1400},iL),iR=e.e({deceleration:20,maxSpeed:1400},iL),iP=e.e({deceleration:1e3,maxSpeed:360},iL),iD=e.e({deceleration:1e3,maxSpeed:90},iL);class iO{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:u.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,e=u.now();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let i={zoom:0,bearing:0,pitch:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);let n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){let a=iF(i.pan.mag(),n,e.e({},iM,t||{}));r.offset=i.pan.mult(a.amount/i.pan.mag()),r.center=this._map.transform.center,iB(r,a)}if(i.zoom){let t=iF(i.zoom,n,iR);r.zoom=this._map.transform.zoom+t.amount,iB(r,t)}if(i.bearing){let t=iF(i.bearing,n,iP);r.bearing=this._map.transform.bearing+e.ac(t.amount,-179,179),iB(r,t)}if(i.pitch){let t=iF(i.pitch,n,iD);r.pitch=this._map.transform.pitch+t.amount,iB(r,t)}if(r.zoom||r.bearing){let t=void 0===i.pinchAround?i.around:i.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(r,{noMoveStart:!0})}}function iB(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function iF(t,i,n){let{maxSpeed:r,linearity:a,deceleration:o}=n,s=e.ac(t*a/(i/1e3),-r,r),l=Math.abs(s)/(o*a);return{easing:n.easing,duration:1e3*l,amount:l/2*s}}class iN extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n,r={}){let a=h.mousePos(i.getCanvas(),n);super(t,e.e({point:a,lngLat:i.unproject(a),originalEvent:n},r)),this._defaultPrevented=!1,this.target=i}}class iV extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n){let r="touchend"===t?n.changedTouches:n.touches,a=h.touchPos(i.getCanvasContainer(),r),o=a.map(t=>i.unproject(t)),s=a.reduce((t,e,i,n)=>t.add(e.div(n.length)),new e.P(0,0));super(t,{points:a,point:s,lngLats:o,lngLat:i.unproject(s),originalEvent:n}),this._defaultPrevented=!1}}class iU extends e.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class i${constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new iU(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new iN(t.type,this._map,t))}mouseup(t){this._map.fire(new iN(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new iN(t.type,this._map,t))}dblclick(t){return this._firePreventable(new iN(t.type,this._map,t))}mouseover(t){this._map.fire(new iN(t.type,this._map,t))}mouseout(t){this._map.fire(new iN(t.type,this._map,t))}touchstart(t){return this._firePreventable(new iV(t.type,this._map,t))}touchmove(t){this._map.fire(new iV(t.type,this._map,t))}touchend(t){this._map.fire(new iV(t.type,this._map,t))}touchcancel(t){this._map.fire(new iV(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iH{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new iN(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new iN("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new iN(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class iq{constructor(t){this._map=t}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(t){return this.transform.pointLocation(e.P.convert(t),this._map.terrain)}}class ij{constructor(t,e){this._map=t,this._tr=new iq(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(h.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active||this._lastPos.equals(e)||!this._box&&e.dist(this._startPos)<this._clickTolerance)return;let i=this._startPos;this._lastPos=e,this._box||(this._box=h.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let n=Math.min(i.x,e.x),r=Math.max(i.x,e.x),a=Math.min(i.y,e.y),o=Math.max(i.y,e.y);h.setTransform(this._box,`translate(${n}px,${a}px)`),this._box.style.width=r-n+"px",this._box.style.height=o-a+"px"}mouseupWindow(t,i){if(!this._active||0!==t.button)return;let n=this._startPos;if(this.reset(),h.suppressClick(),n.x!==i.x||n.y!==i.y)return this._map.fire(new e.k("boxzoomend",{originalEvent:t})),{cameraAnimation:t=>t.fitScreenCoordinates(n,i,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(h.remove(this._box),this._box=null),h.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.k(t,{originalEvent:i}))}}function iG(t,e){if(t.length!==e.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);let i={};for(let n=0;n<t.length;n++)i[t[n].identifier]=e[n];return i}class iX{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){let i=new e.P(0,0);for(let e of t)i._add(e);return i.div(t.length)}(i),this.touches=iG(n,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;let n=iG(i,e);for(let t in this.touches){let e=n[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class iZ{constructor(t){this.singleTap=new iX(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){let n=this.singleTap.touchend(t,e,i);if(n){let e=t.timeStamp-this.lastTime<500,i=!this.lastTap||30>this.lastTap.dist(n);if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class iW{constructor(t){this._tr=new iq(t),this._zoomIn=new iZ({numTouches:1,numTaps:2}),this._zoomOut=new iZ({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){let n=this._zoomIn.touchend(t,e,i),r=this._zoomOut.touchend(t,e,i),a=this._tr;return n?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(n)},{originalEvent:t})}):r?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(r)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class iY{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){let e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=e.length?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;let i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let n=e.length?e[0]:e;return!this._moved&&n.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=n,this._move(i,n))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&h.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let iK={0:1,2:2};class iJ{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){let e=h.mouseButton(t);this._eventButton=e}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){let i=iK[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return h.mouseButton(t)===this._eventButton}}class iQ{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}let i0=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=function(t){t.preventDefault()}},i1=({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>new iY({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:new iJ({checkCorrectEvent:t=>0===h.mouseButton(t)&&t.ctrlKey||2===h.mouseButton(t)}),enable:t,assignEvents:i0}),i2=({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>new iY({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new iJ({checkCorrectEvent:t=>0===h.mouseButton(t)&&t.ctrlKey||2===h.mouseButton(t)}),enable:t,assignEvents:i0});class i5{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active&&!(i.length<this.minTouchs()))return t.preventDefault(),this._calculateTransform(t,e,i)}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&i.length<this.minTouchs()&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,n){n.length>0&&(this._active=!0);let r=iG(n,i),a=new e.P(0,0),o=new e.P(0,0),s=0;for(let t in r){let e=r[t],i=this._touches[t];i&&(a._add(e),o._add(e.sub(i)),s++,r[t]=e)}if(this._touches=r,s<this.minTouchs()||!o.mag())return;let l=o.div(s);return this._sum._add(l),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:l}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class i3{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();let[n,r]=this._firstTwoTouches,a=i4(i,e,n),o=i4(i,e,r);if(!a||!o)return;let s=this._aroundCenter?null:a.add(o).div(2);return this._move([a,o],s,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;let[n,r]=this._firstTwoTouches,a=i4(i,e,n),o=i4(i,e,r);a&&o||(this._active&&h.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function i4(t,e,i){for(let n=0;n<t.length;n++)if(t[n].identifier===i)return e[n]}function i6(t,e){return Math.log(t/e)/Math.LN2}class i7 extends i3{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){let i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(.1>Math.abs(i6(this._distance,this._startDistance))))return this._active=!0,{zoomDelta:i6(this._distance,i),pinchAround:e}}}function i8(t,e){return 180*t.angleWith(e)/Math.PI}class i9 extends i3{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e,i){let n=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:i8(this._vector,n),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let e=25/(Math.PI*this._minDiameter)*360;return Math.abs(i8(t,this._startVector))<e}}function nt(t){return Math.abs(t.y)>Math.abs(t.x)}class ne extends i3{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,nt(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let n=t[0].sub(this._lastPoints[0]),r=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:-((n.y+r.y)/2*.5)}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;let n=t.mag()>=2,r=e.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;let a=t.y>0==e.y>0;return nt(t)&&nt(e)&&a}}let ni=100,nn=15,nr=10;class na{constructor(t){this._tr=new iq(t),this._panStep=ni,this._bearingStep=nn,this._pitchStep=nr,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,n=0,r=0,a=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),r=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),r=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),a=-1);break;case 40:t.shiftKey?n=-1:(t.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:no,zoom:e?Math.round(s.zoom)+e*(t.shiftKey?2:1):s.zoom,bearing:s.bearing+i*this._bearingStep,pitch:s.pitch+n*this._pitchStep,offset:[-r*this._panStep,-a*this._panStep],center:s.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function no(t){return t*(2-t)}class ns{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new iq(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!t[this._map.cooperativeGestures._bypassKey])return;let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,i=u.now(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%4.000244140625==0?this._type="wheel":0!==e&&4>Math.abs(e)?this._type="trackpad":n>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=200>Math.abs(n*e)?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){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 i=h.mousePos(this._map.getCanvas(),t),n=this._tr;this._around=i.y>n.transform.height/2-n.transform.getHorizon()?e.M.convert(this._aroundCenter?n.center:n.unproject(i)):e.M.convert(n.center),this._aroundPoint=n.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let t=this._tr.transform;if(0!==this._delta){let e="wheel"===this._type&&Math.abs(this._delta)>4.000244140625?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);let n="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(n*i))),"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,n=this._startZoom,r=this._easing,a,o=!1;if("wheel"===this._type&&n&&r){let t=Math.min((u.now()-this._lastWheelEventTime)/200,1),s=r(t);a=e.z.number(n,i,s),t<1?this._frameId||(this._frameId=!0):o=!0}else a=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!o,zoomDelta:a-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.b7;if(this._prevEase){let t=this._prevEase,n=(u.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),a=.27/Math.sqrt(r*r+1e-4)*.01,o=Math.sqrt(.0729-a*a);i=e.b6(a,o,.25,1)}return this._prevEase={start:u.now(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class nl{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class nc{constructor(t){this._tr=new iq(t),this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nd{constructor(){this._tap=new iZ({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(t,e,i){if(!this._swipePoint)if(this._tapTime){let n=e[0],r=t.timeStamp-this._tapTime<500,a=30>this._tapPoint.dist(n);r&&a?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;let n=e[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,t.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{let n=this._tap.touchend(t,e,i);n&&(this._tapTime=t.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class nu{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}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 nh{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class np{constructor(t,e,i,n){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}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 nm{constructor(t,e){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=h.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=e,this._container.appendChild(n);let r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(h.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(t){this._onCooperativeGesture(1===t.touches.length)}wheel(t){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!t[this._bypassKey])}_onCooperativeGesture(t){this._enabled&&t&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let nf=t=>t.zoom||t.drag||t.pitch||t.rotate;class ng extends e.k{}function n_(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class nb{constructor(t,e){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;let i="renderFrame"===t.type?void 0:t,n={needsRenderFrame:!1},r={},a={},o=t.touches,s=o?this._getMapTouches(o):void 0,l=s?h.touchPos(this._map.getCanvas(),s):h.mousePos(this._map.getCanvas(),t);for(let{handlerName:o,handler:c,allowed:d}of this._handlers){let u;c.isEnabled()&&(this._blockedByActive(a,d,o)?c.reset():c[e||t.type]&&(u=c[e||t.type](t,l,s),this.mergeHandlerResult(n,r,u,o,i),u&&u.needsRenderFrame&&this._triggerRenderFrame()),(u||c.isActive())&&(a[o]=c))}let c={};for(let t in this._previousActiveHandlers)a[t]||(c[t]=i);this._previousActiveHandlers=a,(Object.keys(c).length||n_(n))&&(this._changes.push([n,r,c]),this._triggerRenderFrame()),(Object.keys(a).length||n_(n))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:d}=n;d&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],d(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new iO(t),this._bearingSnap=e.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(e);let i=this._el;for(let[t,e,n]of(this._listeners=[[i,"touchstart",{passive:!0}],[i,"touchmove",{passive:!1}],[i,"touchend",void 0],[i,"touchcancel",void 0],[i,"mousedown",void 0],[i,"mousemove",void 0],[i,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[i,"mouseover",void 0],[i,"mouseout",void 0],[i,"dblclick",void 0],[i,"click",void 0],[i,"keydown",{capture:!1}],[i,"keyup",void 0],[i,"wheel",{passive:!1}],[i,"contextmenu",void 0],[window,"blur",void 0]],this._listeners))h.addEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(let[t,e,i]of this._listeners)h.removeEventListener(t,e,t===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){let e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new i$(e,t));let n=e.boxZoom=new ij(e,t);this._add("boxZoom",n),t.interactive&&t.boxZoom&&n.enable();let r=e.cooperativeGestures=new nm(e,t.cooperativeGestures);this._add("cooperativeGestures",r),t.cooperativeGestures&&r.enable();let a=new iW(e),o=new nc(e);e.doubleClickZoom=new nl(o,a),this._add("tapZoom",a),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();let s=new nd;this._add("tapDragZoom",s);let l=e.touchPitch=new ne(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);let c=i1(t),d=i2(t);e.dragRotate=new nh(t,c,d),this._add("mouseRotate",c,["mousePitch"]),this._add("mousePitch",d,["mouseRotate"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();let u=(({enable:t,clickTolerance:e})=>new iY({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:new iJ({checkCorrectEvent:t=>0===h.mouseButton(t)&&!t.ctrlKey}),enable:t,assignEvents:i0}))(t),p=new i5(t,e);e.dragPan=new nu(i,u,p),this._add("mousePan",u),this._add("touchPan",p,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);let m=new i9,f=new i7;e.touchZoomRotate=new np(i,f,m,s),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate);let g=e.scrollZoom=new ns(e,()=>this._triggerRenderFrame());this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);let _=e.keyboard=new na(e);this._add("keyboard",_),t.interactive&&t.keyboard&&e.keyboard.enable(),this._add("blockableMapEvent",new iH(e))}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!nf(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(let n in t)if(n!==i&&(!e||0>e.indexOf(n)))return!0;return!1}_getMapTouches(t){let e=[];for(let i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,n,r,a){if(!n)return;e.e(t,n);let o={handlerName:r,originalEvent:n.originalEvent||a};void 0!==n.zoomDelta&&(i.zoom=o),void 0!==n.panDelta&&(i.drag=o),void 0!==n.pitchDelta&&(i.pitch=o),void 0!==n.bearingDelta&&(i.rotate=o)}_applyChanges(){let t={},i={},n={};for(let[r,a,o]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),e.e(i,a),e.e(n,o);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,e,i){let n=this._map,r=n._getTransformForUpdate(),a=n.terrain;if(!(n_(t)||a&&this._terrainMovement))return this._fireEvents(e,i,!0);let{panDelta:o,zoomDelta:s,bearingDelta:l,pitchDelta:c,around:d,pinchAround:u}=t;void 0!==u&&(d=u),n._stop(!0),d=d||n.transform.centerPoint;let h=r.pointLocation(o?d.sub(o):d);l&&(r.bearing+=l),c&&(r.pitch+=c),s&&(r.zoom+=s),a?!this._terrainMovement&&(e.drag||e.zoom)?(this._terrainMovement=!0,this._map._elevationFreeze=!0,r.setLocationAtPoint(h,d),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,r.recalculateZoom(n.terrain)})):e.drag&&this._terrainMovement?r.center=r.pointLocation(r.centerPoint.sub(o)):r.setLocationAtPoint(h,d):r.setLocationAtPoint(h,d),n._applyUpdatedTransform(r),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_fireEvents(t,i,n){let r,a=nf(this._eventsInProgress),o=nf(t),s={};for(let e in t){let{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}for(let t in!a&&o&&this._fireEvent("movestart",o.originalEvent),s)this._fireEvent(t,s[t]);for(let e in o&&this._fireEvent("move",o.originalEvent),t){let{originalEvent:i}=t[e];this._fireEvent(e,i)}let l={};for(let t in this._eventsInProgress){let{handlerName:e,originalEvent:n}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],r=i[e]||n,l[`${t}end`]=r)}for(let t in l)this._fireEvent(t,l[t]);let c=nf(this._eventsInProgress);if(n&&(a||o)&&!c){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;t&&(t.essential||!u.prefersReducedMotion)?(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:r})):(this._map.fire(new e.k("moveend",{originalEvent:r})),i(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.k(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new ng("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class ny extends e.E{constructor(t,e){super(),this._renderFrameCallback=()=>{let t=Math.min((u.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=e.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new e.M(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),n)}panTo(t,i,n){return this.easeTo(e.e({center:t},i),n)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,n){return this.easeTo(e.e({zoom:t},i),n)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,n){return this.easeTo(e.e({bearing:t},i),n)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}cameraForBounds(t,e){t=G.convert(t);let i=e&&e.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,i,n,r){let a={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=e.e({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){let t=r.padding;r.padding={top:t,bottom:t,right:t,left:t}}r.padding=e.e(a,r.padding);let o=this.transform,s=o.padding,l=new G(t,i),c=o.project(l.getNorthWest()),d=o.project(l.getNorthEast()),u=o.project(l.getSouthEast()),h=o.project(l.getSouthWest()),p=e.b8(-n),m=c.rotate(p),f=d.rotate(p),g=u.rotate(p),_=h.rotate(p),b=new e.P(Math.max(m.x,f.x,_.x,g.x),Math.max(m.y,f.y,_.y,g.y)),y=new e.P(Math.min(m.x,f.x,_.x,g.x),Math.min(m.y,f.y,_.y,g.y)),v=b.sub(y),x=(o.width-(s.left+s.right+r.padding.left+r.padding.right))/v.x,w=(o.height-(s.top+s.bottom+r.padding.top+r.padding.bottom))/v.y;if(w<0||x<0)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let k=Math.min(o.scaleZoom(o.scale*Math.min(x,w)),r.maxZoom),E=e.P.convert(r.offset),C=new e.P((r.padding.left-r.padding.right)/2,(r.padding.top-r.padding.bottom)/2).rotate(e.b8(n)),A=E.add(C).mult(o.scale/o.zoomScale(k));return{center:o.unproject(c.add(u).div(2).sub(A)),zoom:k,bearing:n}}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,i,n,r,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(e.P.convert(t)),this.transform.pointLocation(e.P.convert(i)),n,r),r,a)}_fitInternal(t,i,n){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,n):this.flyTo(i,n)):this}jumpTo(t,i){this.stop();let n=this._getTransformForUpdate(),r=!1,a=!1,o=!1;return"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.M.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(a=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(o=!0,n.pitch=+t.pitch),null==t.padding||n.isPaddingEqual(t.padding)||(n.padding=t.padding),this._applyUpdatedTransform(n),this.fire(new e.k("movestart",i)).fire(new e.k("move",i)),r&&this.fire(new e.k("zoomstart",i)).fire(new e.k("zoom",i)).fire(new e.k("zoomend",i)),a&&this.fire(new e.k("rotatestart",i)).fire(new e.k("rotate",i)).fire(new e.k("rotateend",i)),o&&this.fire(new e.k("pitchstart",i)).fire(new e.k("pitch",i)).fire(new e.k("pitchend",i)),this.fire(new e.k("moveend",i))}calculateCameraOptionsFromTo(t,i,n,r=0){let a=e.Y.fromLngLat(t,i),o=e.Y.fromLngLat(n,r),s=o.x-a.x,l=o.y-a.y,c=o.z-a.z,d=Math.hypot(s,l,c);if(0===d)throw Error("Can't calculate camera options with same From and To");let u=Math.hypot(s,l),h=this.transform.scaleZoom(this.transform.cameraToCenterDistance/d/this.transform.tileSize),p=180*Math.atan2(s,-l)/Math.PI,m=180*Math.acos(u/d)/Math.PI;return m=c<0?90-m:90+m,{center:o.toLngLat(),zoom:h,pitch:m,bearing:p}}easeTo(t,i){var n;let r,a;this._stop(!1,t.easeId),(!1===(t=e.e({offset:[0,0],duration:500,easing:e.b7},t)).animate||!t.essential&&u.prefersReducedMotion)&&(t.duration=0);let o=this._getTransformForUpdate(),s=this.getZoom(),l=this.getBearing(),c=this.getPitch(),d=this.getPadding(),h="bearing"in t?this._normalizeBearing(t.bearing,l):l,p="pitch"in t?+t.pitch:c,m="padding"in t?t.padding:o.padding,f=e.P.convert(t.offset),g=o.centerPoint.add(f),_=o.pointLocation(g),{center:b,zoom:y}=o.getConstrained(e.M.convert(t.center||_),null!=(n=t.zoom)?n:s);this._normalizeCenter(b);let v=o.project(_),x=o.project(b).sub(v),w=o.zoomScale(y-s);t.around&&(r=e.M.convert(t.around),a=o.locationPoint(r));let k={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||y!==s,this._rotating=this._rotating||l!==h,this._pitching=this._pitching||p!==c,this._padding=!o.isPaddingEqual(m),this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,k),this.terrain&&this._prepareElevation(b),this._ease(n=>{if(this._zooming&&(o.zoom=e.z.number(s,y,n)),this._rotating&&(o.bearing=e.z.number(l,h,n)),this._pitching&&(o.pitch=e.z.number(c,p,n)),this._padding&&(o.interpolatePadding(d,m,n),g=o.centerPoint.add(f)),this.terrain&&!t.freezeElevation&&this._updateElevation(n),r)o.setLocationAtPoint(r,a);else{let t=o.zoomScale(o.zoom-s),e=Math.pow(y>s?Math.min(2,w):Math.max(.5,w),1-n),i=o.unproject(v.add(x.mult(n*e)).mult(t));o.setLocationAtPoint(o.renderWorldCopies?i.wrap():i,g)}this._applyUpdatedTransform(o),this._fireMoveEvents(i)},t=>{this.terrain&&this._finalizeElevation(),this._afterEase(i,t)},t),this}_prepareEase(t,i,n={}){this._moving=!0,i||n.moving||this.fire(new e.k("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.k("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.k("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);let i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){let e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.elevation=e.z.number(this._elevationStart,this._elevationTarget,t)}_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(t){if(!this.transformCameraUpdate)return;let e=t.clone(),{center:i,zoom:n,pitch:r,bearing:a,elevation:o}=this.transformCameraUpdate(e);i&&(e.center=i),void 0!==n&&(e.zoom=n),void 0!==r&&(e.pitch=r),void 0!==a&&(e.bearing=a),void 0!==o&&(e.elevation=o),this.transform.apply(e)}_fireMoveEvents(t){this.fire(new e.k("move",t)),this._zooming&&this.fire(new e.k("zoom",t)),this._rotating&&this.fire(new e.k("rotate",t)),this._pitching&&this.fire(new e.k("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;let n=this._zooming,r=this._rotating,a=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.k("zoomend",t)),r&&this.fire(new e.k("rotateend",t)),a&&this.fire(new e.k("pitchend",t)),this.fire(new e.k("moveend",t))}flyTo(t,i){var n;if(!t.essential&&u.prefersReducedMotion){let n=e.L(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,i)}this.stop(),t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.b7},t);let r=this._getTransformForUpdate(),a=this.getZoom(),o=this.getBearing(),s=this.getPitch(),l=this.getPadding(),c="bearing"in t?this._normalizeBearing(t.bearing,o):o,d="pitch"in t?+t.pitch:s,h="padding"in t?t.padding:r.padding,p=e.P.convert(t.offset),m=r.centerPoint.add(p),f=r.pointLocation(m),{center:g,zoom:_}=r.getConstrained(e.M.convert(t.center||f),null!=(n=t.zoom)?n:a);this._normalizeCenter(g);let b=r.zoomScale(_-a),y=r.project(f),v=r.project(g).sub(y),x=t.curve,w=Math.max(r.width,r.height),k=w/b,E=v.mag();if("minZoom"in t){let i=e.ac(Math.min(t.minZoom,a,_),r.minZoom,r.maxZoom);x=Math.sqrt(w/r.zoomScale(i-a)/E*2)}let C=x*x;function A(t){let e=(k*k-w*w+(t?-1:1)*C*C*E*E)/(2*(t?k:w)*C*E);return Math.log(Math.sqrt(e*e+1)-e)}function T(t){return(Math.exp(t)-Math.exp(-t))/2}function I(t){return(Math.exp(t)+Math.exp(-t))/2}let S=A(!1),z=function(t){return I(S)/I(S+x*t)},M=function(t){var e;return w*((I(S)*(T(e=S+x*t)/I(e))-T(S))/C)/E},R=(A(!0)-S)/x;if(1e-6>Math.abs(E)||!isFinite(R)){if(1e-6>Math.abs(w-k))return this.easeTo(t,i);let e=k<w?-1:1;R=Math.abs(Math.log(k/w))/x,M=function(){return 0},z=function(t){return Math.exp(e*x*t)}}return t.duration="duration"in t?+t.duration:1e3*R/("screenSpeed"in t?t.screenSpeed/x:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=o!==c,this._pitching=d!==s,this._padding=!r.isPaddingEqual(h),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g),this._ease(n=>{let u=n*R,f=1/z(u);r.zoom=1===n?_:a+r.scaleZoom(f),this._rotating&&(r.bearing=e.z.number(o,c,n)),this._pitching&&(r.pitch=e.z.number(s,d,n)),this._padding&&(r.interpolatePadding(l,h,n),m=r.centerPoint.add(p)),this.terrain&&!t.freezeElevation&&this._updateElevation(n);let b=1===n?g:r.unproject(y.add(v.mult(M(u))).mult(f));r.setLocationAtPoint(r.renderWorldCopies?b.wrap():b,m),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(i)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}if(!t){let t=this.handlers;t&&t.stop(!1)}return this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=u.now(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){let n=Math.abs((t=e.b1(t,-180,180))-i);return Math.abs(t-360-i)<n&&(t-=360),Math.abs(t+360-i)<n&&(t+=360),t}_normalizeCenter(t){let e=this.transform;if(!e.renderWorldCopies||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:360*(i<-180)}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(e.M.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}let nv={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class nx{constructor(t=nv){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=t=>{t&&("metadata"===t.sourceDataType||"visibility"===t.sourceDataType||"style"===t.dataType||"terrain"===t.type)&&this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","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=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=h.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=h.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=h.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(){h.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){let i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(t=>"string"!=typeof t?"":t)):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let e=this._map.style.sourceCaches;for(let i in e){let n=e[i];if(n.used||n.usedForTerrain){let e=n.getSource();e.attribution&&0>t.indexOf(e.attribution)&&t.push(e.attribution)}}(t=t.filter(t=>String(t).trim())).sort((t,e)=>t.length-e.length);let i=(t=t.filter((e,i)=>{for(let n=i+1;n<t.length;n++)if(t[n].indexOf(e)>=0)return!1;return!0})).join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class nw{constructor(t={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=h.create("div","maplibregl-ctrl");let e=h.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){h.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class nk{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){let e=this._currentlyRunning;for(let i of e?this._queue.concat(e):this._queue)if(i.id===t)return void(i.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let e=this._currentlyRunning=this._queue;for(let i of(this._queue=[],e))if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var nE=e.X([{name:"a_pos3d",type:"Int16",components:3}]);class nC extends e.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,i){this.sourceCache.update(t,i),this._renderableTilesKeys=[];let n={};for(let r of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.posMatrix=new Float64Array(16),e.aN(r.posMatrix,0,e.W,0,e.W,0,1),this._tiles[r.key]=new tl(r,this.tileSize));for(let t in this._tiles)n[t]||delete this._tiles[t]}freeRtt(t){for(let e in this._tiles){let i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){let i={};for(let n of this._renderableTilesKeys){let r=this._tiles[n].tileID;if(r.canonical.equals(t.canonical)){let r=t.clone();r.posMatrix=new Float64Array(16),e.aN(r.posMatrix,0,e.W,0,e.W,0,1),i[n]=r}else if(r.canonical.isChildOf(t.canonical)){let a=t.clone();a.posMatrix=new Float64Array(16);let o=r.canonical.z-t.canonical.z,s=r.canonical.x-(r.canonical.x>>o<<o),l=r.canonical.y-(r.canonical.y>>o<<o),c=e.W>>o;e.aN(a.posMatrix,0,c,0,c,0,1),e.H(a.posMatrix,a.posMatrix,[-s*c,-l*c,0]),i[n]=a}else if(t.canonical.isChildOf(r.canonical)){let a=t.clone();a.posMatrix=new Float64Array(16);let o=t.canonical.z-r.canonical.z,s=t.canonical.x-(t.canonical.x>>o<<o),l=t.canonical.y-(t.canonical.y>>o<<o),c=e.W>>o;e.aN(a.posMatrix,0,e.W,0,e.W,0,1),e.H(a.posMatrix,a.posMatrix,[s*c,l*c,0]),e.J(a.posMatrix,a.posMatrix,[1/2**o,1/2**o,0]),i[n]=a}}return i}getSourceTile(t,e){let i=this.sourceCache._source,n=t.overscaledZ-this.deltaZoom;if(n>i.maxzoom&&(n=i.maxzoom),n<i.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(n).key);let r=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!r||!r.dem)&&e)for(;n>=i.minzoom&&(!r||!r.dem);)r=this.sourceCache.getTileByID(t.scaledTo(n--).key);return r}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(e=>e.timeAdded>=t)}}class nA{constructor(t,e,i){this.painter=t,this.sourceCache=new nC(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,i,n,r=e.W){var a,o,s,l,c,d;if(!(i>=0&&i<r&&n>=0&&n<r))return 0;let u=this.getTerrainData(t),h=null==(a=u.tile)?void 0:a.dem;if(!h)return 0;let p=(o=[],s=[i/r*e.W,n/r*e.W],l=u.u_terrain_matrix,c=s[0],d=s[1],o[0]=l[0]*c+l[4]*d+l[12],o[1]=l[1]*c+l[5]*d+l[13],o),m=[p[0]*h.dim,p[1]*h.dim],f=Math.floor(m[0]),g=Math.floor(m[1]),_=m[0]-f,b=m[1]-g;return h.get(f,g)*(1-_)*(1-b)+h.get(f+1,g)*_*(1-b)+h.get(f,g+1)*(1-_)*b+h.get(f+1,g+1)*_*b}getElevationForLngLatZoom(t,i){let{tileID:n,mercatorX:r,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(n,r%e.W,a%e.W,e.W)}getElevation(t,i,n,r=e.W){return this.getDEMElevation(t,i,n,r)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,i=new e.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new S(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new S(t,new e.R({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=e.an([])}let i=this.sourceCache.getSourceTile(t,!0);if(i&&i.dem&&(!i.demTexture||i.needsTerrainPrepare)){let t=this.painter.context;i.demTexture=this.painter.getTileTexture(i.dem.stride),i.demTexture?i.demTexture.update(i.dem.getPixels(),{premultiply:!1}):i.demTexture=new S(t,i.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),i.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),i.needsTerrainPrepare=!1}let n=i&&i+i.tileID.key+t.key;if(n&&!this._demMatrixCache[n]){let n=this.sourceCache.sourceCache._source.maxzoom,r=t.canonical.z-i.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=n?r=t.canonical.z-n:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let a=t.canonical.x-(t.canonical.x>>r<<r),o=t.canonical.y-(t.canonical.y>>r<<r),s=e.b9(new Float64Array(16),[1/(e.W<<r),1/(e.W<<r),0]);e.H(s,s,[a*e.W,o*e.W,0]),this._demMatrixCache[t.key]={matrix:s,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:i&&i.dem&&i.dem.dim||1,u_terrain_matrix:n?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:i&&i.dem&&i.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(i&&i.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:i}}getFramebuffer(t){let e=this.painter,i=e.width/devicePixelRatio,n=e.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==i||this._fbo.height!==n)&&(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new S(e.context,{width:i,height:n,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new S(e.context,{width:i,height:n,data:null},e.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(e.context.gl.NEAREST,e.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=e.context.createFramebuffer(i,n,!0,!1),this._fbo.depthAttachment.set(e.context.createRenderbuffer(e.context.gl.DEPTH_COMPONENT16,i,n))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let n=0;n<this._coordsTextureSize;n++,e+=4)i[e+0]=255&n,i[e+1]=255&t,i[e+2]=n>>8<<4|t>>8,i[e+3]=0;let n=new S(t,new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),t.gl.RGBA,{premultiply:!1});return n.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);let i=new Uint8Array(4),n=this.painter.context,r=n.gl;n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);let a=i[0]+(i[2]>>4<<8),o=i[1]+((15&i[2])<<8),s=this.coordsIndex[255-i[3]],l=s&&this.sourceCache.getTileByID(s);if(!l)return null;let c=this._coordsTextureSize,d=(1<<l.tileID.canonical.z)*c;return new e.Y((l.tileID.canonical.x*c+a)/d+l.tileID.wrap,(l.tileID.canonical.y*c+o)/d,this.getElevation(l.tileID,a,o,c))}depthAtPoint(t){let e=new Uint8Array(4),i=this.painter.context,n=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),n.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,n.RGBA,n.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/0x1000000+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let t=this.painter.context,i=new e.ba,n=new e.aX,r=this.meshSize,a=e.W/r,o=r*r;for(let t=0;t<=r;t++)for(let e=0;e<=r;e++)i.emplaceBack(e*a,t*a,0);for(let t=0;t<o;t+=r+1)for(let e=0;e<r;e++)n.emplaceBack(e+t,r+e+t+1,r+e+t+2),n.emplaceBack(e+t,r+e+t+2,e+t+1);let s=i.length,l=s+2*(r+1);for(let t of[0,1])for(let n=0;n<=r;n++)for(let r of[0,1])i.emplaceBack(n*a,t*e.W,r);for(let t=0;t<2*r;t+=2)n.emplaceBack(l+t,l+t+1,l+t+3),n.emplaceBack(l+t,l+t+3,l+t+2),n.emplaceBack(s+t,s+t+3,s+t+1),n.emplaceBack(s+t,s+t+2,s+t+3);let c=i.length,d=c+2*(r+1);for(let t of[0,1])for(let n=0;n<=r;n++)for(let r of[0,1])i.emplaceBack(t*e.W,n*a,r);for(let t=0;t<2*r;t+=2)n.emplaceBack(c+t,c+t+1,c+t+3),n.emplaceBack(c+t,c+t+3,c+t+2),n.emplaceBack(d+t,d+t+3,d+t+1),n.emplaceBack(d+t,d+t+2,d+t+3);return this._mesh={indexBuffer:t.createIndexBuffer(n),vertexBuffer:t.createVertexBuffer(i,nE.members),segments:e.$.simpleSegment(0,0,i.length,n.length)},this._mesh}getMeshFrameDelta(t){return 2*Math.PI*e.bb/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,e){var i;let{tileID:n}=this._getOverscaledTileIDFromLngLatZoom(t,e);return null!=(i=this.getMinMaxElevation(n).minElevation)?i:0}getMinMaxElevation(t){let e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return e&&e.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,i){let n=e.Y.fromLngLat(t.wrap()),r=(1<<i)*e.W,a=n.x*r,o=n.y*r,s=Math.floor(a/e.W),l=Math.floor(o/e.W);return{tileID:new e.Q(i,0,i,s,l),mercatorX:a,mercatorY:o}}}class nT{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){let e=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),i=new S(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return i.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),e.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),e.colorAttachment.set(i.texture),{id:t,fbo:e,texture:i,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(e=>t.id!==e),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(let t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw Error("No free RenderPool available, call freeAllObjects() required!");let t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(let t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some(t=>!t.inUse)}}let nI={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class nS{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new nT(t.context,30,e.sourceCache.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){for(let i in this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(i=>!t._layers[i].isHidden(e)),this._coordsDescendingInv={},t.sourceCaches)for(let e of(this._coordsDescendingInv[i]={},t.sourceCaches[i].getVisibleCoordinates())){let t=this.terrain.sourceCache.getTerrainCoords(e);for(let e in t)this._coordsDescendingInv[i][e]||(this._coordsDescendingInv[i][e]=[]),this._coordsDescendingInv[i][e].push(t[e])}for(let e of(this._coordsDescendingInvStr={},t._order)){let i=t._layers[e],n=i.source;if(nI[i.type]&&!this._coordsDescendingInvStr[n])for(let t in this._coordsDescendingInvStr[n]={},this._coordsDescendingInv[n])this._coordsDescendingInvStr[n][t]=this._coordsDescendingInv[n][t].map(t=>t.key).sort().join()}for(let t of this._renderableTiles)for(let e in this._coordsDescendingInvStr){let i=this._coordsDescendingInvStr[e][t.tileID.key];i&&i!==t.rttCoords[e]&&(t.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;let i=t.type,n=this.painter,r=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(nI[i]&&(this._prevType&&nI[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(t.id),!r))return!0;if(nI[this._prevType]||nI[i]&&r){this._prevType=i;let t=this._stacks.length-1,r=this._stacks[t]||[];for(let i of this._renderableTiles){if(this.pool.isFull()&&(ik(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[t]){let e=this.pool.getObjectForId(i.rtt[t].id);if(e.stamp===i.rtt[t].stamp){this.pool.useObject(e);continue}}let a=this.pool.getOrCreateFreeObject();this.pool.useObject(a),this.pool.stampObject(a),i.rtt[t]={id:a.id,stamp:a.stamp},n.context.bindFramebuffer.set(a.fbo.framebuffer),n.context.clear({color:e.aO.transparent,stencil:0}),n.currentStencilSource=void 0;for(let t=0;t<r.length;t++){let e=n.style._layers[r[t]],o=e.source?this._coordsDescendingInv[e.source][i.tileID.key]:[i.tileID];n.context.viewport.set([0,0,a.fbo.width,a.fbo.height]),n._renderTileClippingMasks(e,o),n.renderLayer(n,n.style.sourceCaches[e.source],e,o),e.source&&(i.rttCoords[e.source]=this._coordsDescendingInvStr[e.source][i.tileID.key])}}return ik(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),nI[i]}return!1}}let nz={"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 ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},nL={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:nv,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:e.a.MAX_TILE_CACHE_ZOOM_LEVELS,localIdeographFontFamily:"sans-serif",transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,validateStyle:!0,maxCanvasSize:[4096,4096]},nM=t=>{t.touchstart=t.dragStart,t.touchmoveWindow=t.dragMove,t.touchend=t.dragEnd},nR={showCompass:!0,showZoom:!0,visualizePitch:!1};class nP{constructor(t,i,n=!1){this.mousedown=t=>{this.startMouse(e.e({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),h.mousePos(this.element,t)),h.addEventListener(window,"mousemove",this.mousemove),h.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=t=>{this.moveMouse(t,h.mousePos(this.element,t))},this.mouseup=t=>{this.mouseRotate.dragEnd(t),this.mousePitch&&this.mousePitch.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=h.touchPos(this.element,t.targetTouches)[0],this.startTouch(t,this._startPos),h.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.addEventListener(window,"touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=h.touchPos(this.element,t.targetTouches)[0],this.moveTouch(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&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 r=t.dragRotate._mouseRotate.getClickTolerance(),a=t.dragRotate._mousePitch.getClickTolerance();this.element=i,this.mouseRotate=i1({clickTolerance:r,enable:!0}),this.touchRotate=(({enable:t,clickTolerance:e,bearingDegreesPerPixelMoved:i=.8})=>new iY({clickTolerance:e,move:(t,e)=>({bearingDelta:(e.x-t.x)*i}),moveStateManager:new iQ,enable:t,assignEvents:nM}))({clickTolerance:r,enable:!0}),this.map=t,n&&(this.mousePitch=i2({clickTolerance:a,enable:!0}),this.touchPitch=(({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5})=>new iY({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new iQ,enable:t,assignEvents:nM}))({clickTolerance:a,enable:!0})),h.addEventListener(i,"mousedown",this.mousedown),h.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),h.addEventListener(i,"touchcancel",this.reset)}startMouse(t,e){this.mouseRotate.dragStart(t,e),this.mousePitch&&this.mousePitch.dragStart(t,e),h.disableDrag()}startTouch(t,e){this.touchRotate.dragStart(t,e),this.touchPitch&&this.touchPitch.dragStart(t,e),h.disableDrag()}moveMouse(t,e){let i=this.map,{bearingDelta:n}=this.mouseRotate.dragMove(t,e)||{};if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){let{pitchDelta:n}=this.mousePitch.dragMove(t,e)||{};n&&i.setPitch(i.getPitch()+n)}}moveTouch(t,e){let i=this.map,{bearingDelta:n}=this.touchRotate.dragMove(t,e)||{};if(n&&i.setBearing(i.getBearing()+n),this.touchPitch){let{pitchDelta:n}=this.touchPitch.dragMove(t,e)||{};n&&i.setPitch(i.getPitch()+n)}}off(){let t=this.element;h.removeEventListener(t,"mousedown",this.mousedown),h.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend),h.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){h.enableDrag(),h.removeEventListener(window,"mousemove",this.mousemove),h.removeEventListener(window,"mouseup",this.mouseup),h.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),h.removeEventListener(window,"touchend",this.touchend)}}function nD(t,i,n){let r=new e.M(t.lng,t.lat);if(t=new e.M(t.lng,t.lat),i){let r=new e.M(t.lng-360,t.lat),a=new e.M(t.lng+360,t.lat),o=n.locationPoint(t).distSqr(i);n.locationPoint(r).distSqr(i)<o?t=r:n.locationPoint(a).distSqr(i)<o&&(t=a)}for(;Math.abs(t.lng-n.center.lng)>180;){let e=n.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t.lng!==r.lng&&n.locationPoint(t).y>n.height/2-n.getHorizon()?t:r}let nO={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 nB(t,e,i){let n=t.classList;for(let t in nO)n.remove(`maplibregl-${i}-anchor-${t}`);n.add(`maplibregl-${i}-anchor-${e}`)}class nF extends e.E{constructor(t){if(super(),this._onKeyPress=t=>{let e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=t=>{let e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{var e;if(!this._map)return;let i=this._map.loaded()&&!this._map.isMoving();"terrain"!==(null==t?void 0:t.type)&&("render"!==(null==t?void 0:t.type)||i)||this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?nD(this._lngLat,this._flatPos,this._map.transform):null==(e=this._lngLat)?void 0:e.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let n="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?n=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),t&&"moveend"!==t.type||(this._pos=this._pos.round()),h.setTransform(this._element,`${nO[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${n}`),u.frameAsync(new AbortController).then(()=>{this._updateOpacity(t&&"moveend"===t.type)}).catch(()=>{})},this._onMove=t=>{if(!this._isDragging){let e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.k("dragstart"))),this.fire(new e.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),"active"===this._state&&this.fire(new e.k("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.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=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=e.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=h.create("div"),this._element.setAttribute("aria-label","Map marker");let i=h.createNS("http://www.w3.org/2000/svg","svg");i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height","41px"),i.setAttributeNS(null,"width","27px"),i.setAttributeNS(null,"viewBox","0 0 27 41");let n=h.createNS("http://www.w3.org/2000/svg","g");n.setAttributeNS(null,"stroke","none"),n.setAttributeNS(null,"stroke-width","1"),n.setAttributeNS(null,"fill","none"),n.setAttributeNS(null,"fill-rule","evenodd");let r=h.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"fill-rule","nonzero");let a=h.createNS("http://www.w3.org/2000/svg","g");for(let t of(a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000"),[{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"}])){let e=h.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),a.appendChild(e)}let o=h.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"fill",this._color);let s=h.createNS("http://www.w3.org/2000/svg","path");s.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"),o.appendChild(s);let l=h.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"opacity","0.25"),l.setAttributeNS(null,"fill","#000000");let c=h.createNS("http://www.w3.org/2000/svg","path");c.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"),l.appendChild(c);let d=h.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"transform","translate(6.0, 7.0)"),d.setAttributeNS(null,"fill","#FFFFFF");let u=h.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"transform","translate(8.0, 8.0)");let p=h.createNS("http://www.w3.org/2000/svg","circle");p.setAttributeNS(null,"fill","#000000"),p.setAttributeNS(null,"opacity","0.25"),p.setAttributeNS(null,"cx","5.5"),p.setAttributeNS(null,"cy","5.5"),p.setAttributeNS(null,"r","5.4999962");let m=h.createNS("http://www.w3.org/2000/svg","circle");m.setAttributeNS(null,"fill","#FFFFFF"),m.setAttributeNS(null,"cx","5.5"),m.setAttributeNS(null,"cy","5.5"),m.setAttributeNS(null,"r","5.4999962"),u.appendChild(p),u.appendChild(m),r.appendChild(a),r.appendChild(o),r.appendChild(l),r.appendChild(d),r.appendChild(u),i.appendChild(r),i.setAttributeNS(null,"height",41*this._scale+"px"),i.setAttributeNS(null,"width",27*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",t=>{t.preventDefault()}),this._element.addEventListener("mousedown",t=>{t.preventDefault()}),nB(this._element,this._anchor,"marker"),t&&t.className)for(let e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.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),h.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.M.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){let e=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[e,-1*(24.6+e)],"bottom-right":[-e,-1*(24.6+e)],left:[13.5,-24.6],right:[-13.5,-24.6]}:this._offset}this._popup=t,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 t=this._popup;return this._element.style.opacity===this._opacityWhenCovered||t&&(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map))),this}_updateOpacity(t=!1){var i,n;if(!(null==(i=this._map)?void 0:i.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}let r=this._map,a=r.terrain.depthAtPoint(this._pos),o=r.terrain.getElevationForLngLatZoom(this._lngLat,r.transform.tileZoom);if(r.transform.lngLatToCameraDepth(this._lngLat,o)-a<.006)return void(this._element.style.opacity=this._opacity);let s=-this._offset.y/r.transform._pixelPerMeter,l=Math.sin(r.getPitch()*Math.PI/180)*s,c=r.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),d=r.transform.lngLatToCameraDepth(this._lngLat,o+l)-c>.006;(null==(n=this._popup)?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(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(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return void 0===t&&void 0===e&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=t),void 0!==e&&(this._opacityWhenCovered=e),this._map&&this._updateOpacity(!0),this}}let nN={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},nV=0,nU=!1,n$={maxWidth:100,unit:"metric"};function nH(t,e,i){let n=i&&i.maxWidth||100,r=t._container.clientHeight/2,a=t.unproject([0,r]),o=t.unproject([n,r]),s=a.distanceTo(o);if(i&&"imperial"===i.unit){let i=3.2808*s;i>5280?nq(e,n,i/5280,t._getUIString("ScaleControl.Miles")):nq(e,n,i,t._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?nq(e,n,s/1852,t._getUIString("ScaleControl.NauticalMiles")):s>=1e3?nq(e,n,s/1e3,t._getUIString("ScaleControl.Kilometers")):nq(e,n,s,t._getUIString("ScaleControl.Meters"))}function nq(t,e,i,n){let r=function(t){let e=Math.pow(10,`${Math.floor(t)}`.length-1),i=t/e;return e*(i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){let e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i))}(i);t.style.width=r/i*e+"px",t.innerHTML=`${r}&nbsp;${n}`}let nj={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1};t.AJAXError=e.be,t.Evented=e.E,t.LngLat=e.M,t.MercatorCoordinate=e.Y,t.Point=e.P,t.addProtocol=e.bf,t.config=e.a,t.removeProtocol=e.bg,t.AttributionControl=nx,t.BoxZoomHandler=ij,t.CanvasSource=te,t.CooperativeGesturesHandler=nm,t.DoubleClickZoomHandler=nl,t.DragPanHandler=nu,t.DragRotateHandler=nh,t.EdgeInsets=iT,t.FullscreenControl=class extends e.E{constructor(t={}){super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null==(t=null==e?void 0:e.shadowRoot)?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,t&&t.container&&(t.container instanceof HTMLElement?this._container=t.container:e.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(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){h.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let t=this._fullscreenButton=h.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);h.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_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 e.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.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()}},t.GeoJSONSource=K,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.k("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,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 Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{let i=new e.M(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),a=e.e({bearing:r},this.options.fitBoundsOptions),o=G.fromLngLat(i,n);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let i=new e.M(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.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=t=>{if(this._map){if(this.options.trackUserLocation)if(1===t.code){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 t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&nU)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=h.create("button","maplibregl-ctrl-geolocate",this._container),h.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");let t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{let t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=h.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new nF({element:this._dotElement}),this._circleElement=h.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new nF({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",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.k("trackuserlocationend")))})}},this.options=e.e({},nN,t)}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),(function(){return e._(this,arguments,void 0,function*(t=!1){if(void 0!==l&&!t)return l;if(void 0===window.navigator.permissions)return l=!!window.navigator.geolocation;try{let t=yield window.navigator.permissions.query({name:"geolocation"});l="denied"!==t.state}catch(t){l=!!window.navigator.geolocation}return l})})().then(t=>this._setupUI(t)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(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(),h.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,nV=0,nU=!1}_isOutOfMapMaxBounds(t){let e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.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 Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let t=this._map.getBounds(),e=t.getSouthEast(),i=t.getNorthEast(),n=e.distanceTo(i),r=Math.ceil(this._accuracy/(n/this._map._container.clientHeight)*2);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}px`}trigger(){if(!this._setup)return e.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 e.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":nV--,nU=!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 e.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 e.k("trackuserlocationstart"));break;default:throw 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 Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),++nV>1?(t={maximumAge:6e5,timeout:0},nU=!0):(t=this.options.positionOptions,nU=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}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)}},t.Hash=iz,t.ImageSource=Q,t.KeyboardHandler=na,t.LngLatBounds=G,t.LogoControl=nw,t.Map=class extends ny{constructor(t){if(e.bc.mark(e.bd.create),null!=(t=e.e({},nL,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw Error("maxPitch must be less than or equal to 85");if(super(new iI(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new e.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new e.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._renderTaskQueue=new nk,this._controls=[],this._mapId=e.a3(),this._locale=e.e({},nz,t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this._imageQueueHandle=k.addThrottleControl(()=>this.isMoving()),this._requestManager=new y(t.transformRequest),"string"==typeof t.container){if(this._container=document.getElementById(t.container),!this._container)throw Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.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}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let t=!1,e=iS(t=>{this._trackResize&&!this._removed&&this.resize(t)._update()},50);this._resizeObserver=new ResizeObserver(i=>{t?e(i):t=!0}),this._resizeObserver.observe(this._container)}this.handlers=new nb(this,t),this._hash=t.hash&&new iz("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new nx("boolean"==typeof t.attributionControl?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new nw,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.k(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.k(`${t.dataType}dataloading`,t))}),this.on("dataabort",t=>{this.fire(new e.k("sourcedataabort",t))})}_getMapId(){return this._mapId}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.j(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let n=t.onAdd(this);this._controls.push(t);let r=this._controlPositions[i];return -1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.j(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}calculateCameraOptionsFromTo(t,e,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(t,e,i,n)}resize(t){var i;let n=this._containerDimensions(),r=n[0],a=n[1],o=this._getClampedPixelRatio(r,a);if(this._resizeCanvas(r,a,o),this.painter.resize(r,a,o),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let e=this._getClampedPixelRatio(r,a);this._resizeCanvas(r,a,e),this.painter.resize(r,a,e)}this.transform.resize(r,a),null==(i=this._requestedCameraState)||i.resize(r,a);let s=!this._moving;return s&&(this.stop(),this.fire(new e.k("movestart",t)).fire(new e.k("move",t))),this.fire(new e.k("resize",t)),s&&this.fire(new e.k("moveend",t)),this}_getClampedPixelRatio(t,e){let{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),a=t*r,o=e*r;return Math.min(a>i?i/a:1,o>n?n/o:1)*r}getPixelRatio(){var t;return null!=(t=this._overridePixelRatio)?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(G.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()<t&&this.setZoom(t),this;throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t&&this.setZoom(t),this;throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()<t&&this.setPitch(t),this;throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>85)throw Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t&&this.setPitch(t),this;throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this._update()}project(t){return this.transform.locationPoint(e.M.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.pointLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null==(t=this.handlers)?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null==(t=this.handlers)?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null==(t=this.handlers)?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let n=!1,r=r=>{let a=this.getLayer(e)?this.queryRenderedFeatures(r.point,{layers:[e]}):[];a.length?n||(n=!0,i.call(this,new iN(t,this,r.originalEvent,{features:a}))):n=!1};return{layer:e,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===t||"mouseout"===t){let n=!1,r=r=>{(this.getLayer(e)?this.queryRenderedFeatures(r.point,{layers:[e]}):[]).length?n=!0:n&&(n=!1,i.call(this,new iN(t,this,r.originalEvent)))},a=e=>{n&&(n=!1,i.call(this,new iN(t,this,e.originalEvent)))};return{layer:e,listener:i,delegates:{mousemove:r,mouseout:a}}}{let n=t=>{let n=this.getLayer(e)?this.queryRenderedFeatures(t.point,{layers:[e]}):[];n.length&&(t.features=n,i.call(this,t),delete t.features)};return{layer:e,listener:i,delegates:{[t]:n}}}}on(t,e,i){if(void 0===i)return super.on(t,e);let n=this._createDelegatedListener(t,e,i);for(let e in this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(n),n.delegates)this.on(e,n.delegates[e]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);let n=this._createDelegatedListener(t,e,i);for(let t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._delegatedListeners&&this._delegatedListeners[t]&&(n=>{let r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){let n=r[t];if(n.layer===e&&n.listener===i){for(let t in n.delegates)this.off(t,n.delegates[t]);return r.splice(t,1),this}}})(),this)}queryRenderedFeatures(t,i){let n;if(!this.style)return[];let r=t instanceof e.P||Array.isArray(t),a=r?t:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:t)||{},a instanceof e.P||"number"==typeof a[0])n=[e.P.convert(a)];else{let t=e.P.convert(a[0]),i=e.P.convert(a[1]);n=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return!1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let e=this._locale[t];if(null==e)throw Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){if(e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(t,e));let i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new t0(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i)):delete this.style,this}_lazyInitEmptyStyle(){this.style||(this.style=new t0(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){if("string"==typeof t){let n=this._requestManager.transformRequest(t,E.Style);e.h(n,new AbortController).then(t=>{this._updateDiff(t.data,i)}).catch(t=>{t&&this.fire(new e.j(t))})}else"object"==typeof t&&this._updateDiff(t,i)}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(n){e.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){let i=this.style&&this.style.sourceCaches[t];if(void 0!==i)return i.loaded();this.fire(new e.j(Error(`There is no source with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){let i=this.style.sourceCaches[t.source];if(!i)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);for(let n in null===this.terrain&&i.reload(),this.style._layers){let i=this.style._layers[n];"hillshade"===i.type&&i.source===t.source&&e.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 nA(this.painter,i,t),this.painter.renderToTexture=new nS(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=e=>{"style"===e.dataType?this.terrain.sourceCache.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.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(e.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 e.k("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!=(e=null==(t=this.terrain)?void 0:t.options)?e:null}areTilesLoaded(){let t=this.style&&this.style.sourceCaches;for(let e in t){let i=t[e]._tiles;for(let t in i){let e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(t,i,n={}){let{pixelRatio:r=1,sdf:a=!1,stretchX:o,stretchY:s,content:l}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.j(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:n,height:c,data:d}=i;return this.style.addImage(t,{data:new e.R({width:n,height:c},new Uint8Array(d)),pixelRatio:r,stretchX:o,stretchY:s,content:l,sdf:a,version:0,userImage:i}),i.onAdd&&i.onAdd(this,t),this}}{let{width:n,height:c,data:d}=u.getImageData(i);this.style.addImage(t,{data:new e.R({width:n,height:c},d),pixelRatio:r,stretchX:o,stretchY:s,content:l,sdf:a,version:0})}}updateImage(t,i){let n=this.style.getImage(t);if(!n)return this.fire(new e.j(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:a,data:o}=i instanceof HTMLImageElement||e.b(i)?u.getImageData(i):i;if(void 0===r||void 0===a)return this.fire(new e.j(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(r!==n.data.width||a!==n.data.height)return this.fire(new e.j(Error("The width and height of the updated image must be that same as the previous version of the image")));let s=!(i instanceof HTMLImageElement||e.b(i));return n.data.replace(o,s),this.style.updateImage(t,n),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.j(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return k.getImage(this._requestManager.transformRequest(t,E.Image),new AbortController)}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,n={}){return this.style.setPaintProperty(t,e,i,n),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,n={}){return this.style.setLayoutProperty(t,e,i,n),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,t=>{t||this._update(!0)}),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,t=>{t||this._update(!0)}),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupContainer(){let t=this._container;t.classList.add("maplibregl-map");let e=this._canvasContainer=h.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=h.create("canvas","maplibregl-canvas",e),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 i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);let r=this._controlContainer=h.create("div","maplibregl-control-container",t),a=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(t=>{a[t]=h.create("div",`maplibregl-ctrl-${t} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){let t={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},e=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)},{once:!0});let i=this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t);if(!i){let t="Failed to initialize WebGL";throw e?(e.message=t,Error(JSON.stringify(e))):Error(t)}this.painter=new iE(i,this.transform),p.testSupport(i)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style&&this.style._loaded&&(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint()),this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){let i=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this.transform.zoom,r=u.now();this.style.zoomHistory.update(t,r);let a=new e.a8(t,{now:r,fadeDuration:i,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),o=a.crossFadingFactor();1===o&&o===this._crossFadingFactor||(n=!0,this._crossFadingFactor=o),this.style.update(a)}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 e.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,e.bc.mark(e.bd.load),this.fire(new e.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let r=this._sourcesDirty||this._styleDirty||this._placementDirty;return r||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.k("idle")),!this._loaded||this._fullyLoaded||r||(this._fullyLoaded=!0,e.bc.mark(e.bd.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t;for(let t of(this._hash&&this._hash.remove(),this._controls))t.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),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),k.removeThrottleControl(this._imageQueueHandle),null==(t=this._resizeObserver)||t.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),h.remove(this._canvasContainer),h.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),e.bc.clearMetrics(),this._removed=!0,this.fire(new e.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,u.frameAsync(this._frameRequest).then(t=>{e.bc.frame(t),this._frameRequest=null,this._render(t)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return d}getCameraTargetElevation(){return this.transform.elevation}},t.MapMouseEvent=iN,t.MapTouchEvent=iV,t.MapWheelEvent=iU,t.Marker=nF,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{let t=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=t},this._setButtonTitle=(t,e)=>{let i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},nR,t),this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),h.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),h.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=h.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,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 nP(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){h.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(t,e){let i=h.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this.remove=()=>(this._content&&h.remove(this._content),this._container&&(h.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 e.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var i;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=h.create("div","maplibregl-popup",this._map.getContainer()),this._tip=h.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let t of this.options.className.split(" "))this._container.classList.add(t);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?nD(this._lngLat,this._flatPos,this._map.transform):null==(i=this._lngLat)?void 0:i.wrap(),this._trackPointer&&!t)return;let n=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let r=this.options.anchor,a=function t(i){if(i){if("number"==typeof i){let t=Math.round(Math.abs(i)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,i),"top-left":new e.P(t,t),"top-right":new e.P(-t,t),bottom:new e.P(0,-i),"bottom-left":new e.P(t,-t),"bottom-right":new e.P(-t,-t),left:new e.P(i,0),right:new e.P(-i,0)}}if(i instanceof e.P||Array.isArray(i)){let t=e.P.convert(i);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:e.P.convert(i.center||[0,0]),top:e.P.convert(i.top||[0,0]),"top-left":e.P.convert(i["top-left"]||[0,0]),"top-right":e.P.convert(i["top-right"]||[0,0]),bottom:e.P.convert(i.bottom||[0,0]),"bottom-left":e.P.convert(i["bottom-left"]||[0,0]),"bottom-right":e.P.convert(i["bottom-right"]||[0,0]),left:e.P.convert(i.left||[0,0]),right:e.P.convert(i.right||[0,0])}}return t(new e.P(0,0))}(this.options.offset);if(!r){let t,e=this._container.offsetWidth,i=this._container.offsetHeight;t=n.y+a.bottom.y<i?["top"]:n.y>this._map.transform.height-i?["bottom"]:[],n.x<e/2?t.push("left"):n.x>this._map.transform.width-e/2&&t.push("right"),r=0===t.length?"bottom":t.join("-")}let o=n.add(a[r]);this.options.subpixelPositioning||(o=o.round()),h.setTransform(this._container,`${nO[r]} translate(${o.x}px,${o.y}px)`),nB(this._container,r,"popup")},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(nj),t)}addTo(t){return this._map&&this.remove(),this._map=t,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 e.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.M.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let e,i=document.createDocumentFragment(),n=document.createElement("body");for(n.innerHTML=t;e=n.firstChild;)i.appendChild(e);return this.setDOMContent(i)}getMaxWidth(){var t;return null==(t=this._container)?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=h.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){this._container&&this._container.classList.add(t)}removeClassName(t){this._container&&this._container.classList.remove(t)}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}_createCloseButton(){this.options.closeButton&&(this._closeButton=h.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 t=this._container.querySelector("a[href], [tabindex]:not([tabindex='-1']), [contenteditable]:not([contenteditable='false']), button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])");t&&t.focus()}},t.RasterDEMTileSource=Y,t.RasterTileSource=W,t.ScaleControl=class{constructor(t){this._onMove=()=>{nH(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,nH(this._map,this._container,this.options)},this.options=e.e({},n$,t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){h.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=ns,t.Style=t0,t.TerrainControl=class{constructor(t){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=t}onAdd(t){return this._map=t,this._container=h.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=h.create("button","maplibregl-ctrl-terrain",this._container),h.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(){h.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=ne,t.TwoFingersTouchRotateHandler=i9,t.TwoFingersTouchZoomHandler=i7,t.TwoFingersTouchZoomRotateHandler=np,t.VectorTileSource=Z,t.VideoSource=tt,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,function*(){if(tn(t))throw Error(`A source type called "${t}" already exists.`);ti[t]=i}),t.clearPrewarmedResources=function(){let t=a;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(F),a=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()"))},t.getMaxParallelImageRequests=function(){return e.a.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return ts().getRTLTextPluginStatus()},t.getVersion=function(){return d},t.getWorkerCount=function(){return N.workerCount},t.getWorkerUrl=function(){return e.a.WORKER_URL},t.importScriptInWorkers=function(t){return H().broadcast("importScript",t)},t.prewarm=function(){U().acquire(F)},t.setMaxParallelImageRequests=function(t){e.a.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setRTLTextPlugin=function(t,e){return ts().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){N.workerCount=t},t.setWorkerUrl=function(t){e.a.WORKER_URL=t}}),t}()}},a={};function o(t){var e=a[t];if(void 0!==e)return e.exports;var i=a[t]={id:t,loaded:!1,exports:{}};return r[t].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},(()=>{var t,e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__;o.t=function(i,n){if(1&n&&(i=this(i)),8&n||"object"==typeof i&&i&&(4&n&&i.__esModule||16&n&&"function"==typeof i.then))return i;var r=Object.create(null);o.r(r);var a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&i;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach(t=>{a[t]=()=>i[t]});return a.default=()=>i,o.d(r,a),r}})(),o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(t){if("object"==typeof window)return window}})(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.nmd=t=>(t.paths=[],t.children||(t.children=[]),t);var s={};return(()=>{"use strict";let t;o.r(s),o.d(s,{OrMapLoadedEvent:()=>rh,geoJsonPointInputTemplateProvider:()=>rv,OrMapMarkerClickedEvent:()=>en,OrMap:()=>rx,OrMapMarker:()=>er,OrMapAssetCard:()=>rd,getMarkerConfigAttributeName:()=>es,Util:()=>p,DefaultConfig:()=>rc,OrMapAssetCardLoadAssetEvent:()=>rl,CenterControl:()=>rg,getMarkerConfigForAssetType:()=>eo,OrMapLongPressEvent:()=>rm,OrMapMarkerChangedEvent:()=>ei,CoordinatesControl:()=>ry,LngLat:()=>tH.LngLat,OrMapMarkerAsset:()=>el,OrMapGeocoderChangeEvent:()=>rf,OrMapClickedEvent:()=>rp});var e,i,n,r,a,l,c,d,u,h,p={};o.r(p),o.d(p,{getGeoJSONPoint:()=>tY,getLatLngBounds:()=>tJ,getLngLat:()=>tW,getLngLatBounds:()=>tK,getMarkerIconAndColorFromAssetType:()=>tQ});var m=o(801),f=o.n(m);function g(t,e,i){return{index:t,removed:e,addedCount:i}}window.JSCompiler_renameProperty=function(t,e){return t};let _=0,b=0,y=[],v=0,x=!1,w=document.createTextNode("");new window.MutationObserver(function(){x=!1;let t=y.length;for(let e=0;e<t;e++){let t=y[e];if(t)try{t()}catch(t){setTimeout(()=>{throw t})}}y.splice(0,t),b+=t}).observe(w,{characterData:!0});let k={run:t=>(x||(x=!0,w.textContent=v++),y.push(t),_++),cancel(t){let e=t-b;if(e>=0){if(!y[e])throw Error("invalid async handle: "+t);y[e]=null}}},E=window.ShadyDOM&&window.ShadyDOM.noPatch&&window.ShadyDOM.wrap?window.ShadyDOM.wrap:window.ShadyDOM?t=>ShadyDOM.patch(t):t=>t;function C(t){return"slot"===t.localName}let A=class{static getFlattenedNodes(t){let e=E(t);return C(t)?e.assignedNodes({flatten:!0}):Array.from(e.childNodes).map(t=>C(t)?E(t).assignedNodes({flatten:!0}):[t]).reduce((t,e)=>t.concat(e),[])}constructor(t,e){this._shadyChildrenObserver=null,this._nativeChildrenObserver=null,this._connected=!1,this._target=t,this.callback=e,this._effectiveNodes=[],this._observer=null,this._scheduled=!1,this._boundSchedule=()=>{this._schedule()},this.connect(),this._schedule()}connect(){C(this._target)?this._listenSlots([this._target]):E(this._target).children&&(this._listenSlots(E(this._target).children),window.ShadyDOM?this._shadyChildrenObserver=window.ShadyDOM.observeChildren(this._target,t=>{this._processMutations(t)}):(this._nativeChildrenObserver=new MutationObserver(t=>{this._processMutations(t)}),this._nativeChildrenObserver.observe(this._target,{childList:!0}))),this._connected=!0}disconnect(){C(this._target)?this._unlistenSlots([this._target]):E(this._target).children&&(this._unlistenSlots(E(this._target).children),window.ShadyDOM&&this._shadyChildrenObserver?(window.ShadyDOM.unobserveChildren(this._shadyChildrenObserver),this._shadyChildrenObserver=null):this._nativeChildrenObserver&&(this._nativeChildrenObserver.disconnect(),this._nativeChildrenObserver=null)),this._connected=!1}_schedule(){this._scheduled||(this._scheduled=!0,k.run(()=>this.flush()))}_processMutations(t){this._processSlotMutations(t),this.flush()}_processSlotMutations(t){if(t)for(let e=0;e<t.length;e++){let i=t[e];i.addedNodes&&this._listenSlots(i.addedNodes),i.removedNodes&&this._unlistenSlots(i.removedNodes)}}flush(){var t;if(!this._connected)return!1;window.ShadyDOM&&ShadyDOM.flush(),this._nativeChildrenObserver?this._processSlotMutations(this._nativeChildrenObserver.takeRecords()):this._shadyChildrenObserver&&this._processSlotMutations(this._shadyChildrenObserver.takeRecords()),this._scheduled=!1;let e={target:this._target,addedNodes:[],removedNodes:[]},i=this.constructor.getFlattenedNodes(this._target),n=(t=this._effectiveNodes,function(t,e,i,n,r,a){let o,s=0,l=0,c=Math.min(i-e,a-r);if(0==e&&0==r&&(s=function(t,e,i){for(let r=0;r<i;r++){var n;if(n=t[r],n!==e[r])return r}return i}(t,n,c)),i==t.length&&a==n.length&&(l=function(t,e,i){var n;let r=t.length,a=e.length,o=0;for(;o<i&&(n=t[--r],n===e[--a]);)o++;return o}(t,n,c-s)),e+=s,r+=s,i-=l,a-=l,i-e==0&&a-r==0)return[];if(e==i){for(o=g(e,[],0);r<a;)o.removed.push(n[r++]);return[o]}if(r==a)return[g(e,[],i-e)];let d=function(t){let e=t.length-1,i=t[0].length-1,n=t[e][i],r=[];for(;e>0||i>0;){let a;if(0==e){r.push(2),i--;continue}if(0==i){r.push(3),e--;continue}let o=t[e-1][i-1],s=t[e-1][i],l=t[e][i-1];(a=s<l?s<o?s:o:l<o?l:o)==o?(o==n?r.push(0):(r.push(1),n=o),e--,i--):a==s?(r.push(3),e--,n=s):(r.push(2),i--,n=l)}return r.reverse(),r}(function(t,e,i,n,r,a){let o=a-r+1,s=i-e+1,l=Array(o);for(let t=0;t<o;t++)l[t]=Array(s),l[t][0]=t;for(let t=0;t<s;t++)l[0][t]=t;for(let i=1;i<o;i++)for(let a=1;a<s;a++){var c;if(c=t[e+a-1],c===n[r+i-1])l[i][a]=l[i-1][a-1];else{let t=l[i-1][a]+1,e=l[i][a-1]+1;l[i][a]=t<e?t:e}}return l}(t,e,i,n,r,a));o=void 0;let u=[],h=e,p=r;for(let t=0;t<d.length;t++)switch(d[t]){case 0:o&&(u.push(o),o=void 0),h++,p++;break;case 1:o||(o=g(h,[],0)),o.addedCount++,h++,o.removed.push(n[p]),p++;break;case 2:o||(o=g(h,[],0)),o.addedCount++,h++;break;case 3:o||(o=g(h,[],0)),o.removed.push(n[p]),p++}return o&&u.push(o),u}(i,0,i.length,t,0,t.length));for(let t=0,i;t<n.length&&(i=n[t]);t++)for(let t=0,n;t<i.removed.length&&(n=i.removed[t]);t++)e.removedNodes.push(n);for(let t=0,r;t<n.length&&(r=n[t]);t++)for(let t=r.index;t<r.index+r.addedCount;t++)e.addedNodes.push(i[t]);this._effectiveNodes=i;let r=!1;return(e.addedNodes.length||e.removedNodes.length)&&(r=!0,this.callback.call(this._target,e)),r}_listenSlots(t){for(let e=0;e<t.length;e++){let i=t[e];C(i)&&i.addEventListener("slotchange",this._boundSchedule)}}_unlistenSlots(t){for(let e=0;e<t.length;e++){let i=t[e];C(i)&&i.removeEventListener("slotchange",this._boundSchedule)}}},T=globalThis,I=T.ShadowRoot&&(void 0===T.ShadyCSS||T.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,S=Symbol(),z=new WeakMap;class M{constructor(t,e,i){if(this._$cssResult$=!0,i!==S)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(I&&void 0===t){let i=void 0!==e&&1===e.length;i&&(t=z.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&z.set(e,t))}return t}toString(){return this.cssText}}let R=t=>new M("string"==typeof t?t:t+"",void 0,S),P=(t,...e)=>new M(1===t.length?t[0]:e.reduce((e,i,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[n+1],t[0]),t,S),D=I?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(let i of t.cssRules)e+=i.cssText;return R(e)})(t):t,{is:O,defineProperty:B,getOwnPropertyDescriptor:F,getOwnPropertyNames:N,getOwnPropertySymbols:V,getPrototypeOf:U}=Object,$=globalThis,H=$.trustedTypes,q=H?H.emptyScript:"",j=$.reactiveElementPolyfillSupport,G={toAttribute(t,e){switch(e){case Boolean:t=t?q:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},X=(t,e)=>!O(t,e),Z={attribute:!0,type:String,converter:G,reflect:!1,useDefault:!1,hasChanged:X};Symbol.metadata??=Symbol("metadata"),$.litPropertyMetadata??=new WeakMap;class W extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Z){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let i=Symbol(),n=this.getPropertyDescriptor(t,i,e);void 0!==n&&B(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){let{get:n,set:r}=F(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:n,set(e){let a=n?.call(this);r?.call(this,e),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Z}static _$Ei(){if(this.hasOwnProperty("elementProperties"))return;let t=U(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty("finalized"))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty("properties")){let t=this.properties;for(let e of[...N(t),...V(t)])this.createProperty(e,t[e])}let t=this[Symbol.metadata];if(null!==t){let e=litPropertyMetadata.get(t);if(void 0!==e)for(let[t,i]of e)this.elementProperties.set(t,i)}for(let[t,e]of(this._$Eh=new Map,this.elementProperties)){let i=this._$Eu(t,e);void 0!==i&&this._$Eh.set(i,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t))for(let i of new Set(t.flat(1/0).reverse()))e.unshift(D(i));else void 0!==t&&e.push(D(t));return e}static _$Eu(t,e){let i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map;for(let e of this.constructor.elementProperties.keys())this.hasOwnProperty(e)&&(t.set(e,this[e]),delete this[e]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(I)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let i of e){let e=document.createElement("style"),n=T.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=i.cssText,t.appendChild(e)}})(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ET(t,e){let i=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,i);if(void 0!==n&&!0===i.reflect){let r=(void 0!==i.converter?.toAttribute?i.converter:G).toAttribute(e,i.type);this._$Em=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){let i=this.constructor,n=i._$Eh.get(t);if(void 0!==n&&this._$Em!==n){let t=i.getPropertyOptions(n),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:G;this._$Em=n;let a=r.fromAttribute(e,t.type);this[n]=a??this._$Ej?.get(n)??a,this._$Em=null}}requestUpdate(t,e,i){if(void 0!==t){let n=this.constructor,r=this[t];if(!(((i??=n.getPropertyOptions(t)).hasChanged??X)(r,e)||i.useDefault&&i.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,i))))return;this.C(t,e,i)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:i,reflect:n,wrapped:r},a){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,a??e??this[t]),!0!==r||void 0!==a)||(this._$AL.has(t)||(this.hasUpdated||i||(e=void 0),this._$AL.set(t,e)),!0===n&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}let t=this.constructor.elementProperties;if(t.size>0)for(let[e,i]of t){let{wrapped:t}=i,n=this[e];!0!==t||this._$AL.has(e)||void 0===n||this.C(e,void 0,i,n)}}let t=!1,e=this._$AL;try{(t=this.shouldUpdate(e))?(this.willUpdate(e),this._$EO?.forEach(t=>t.hostUpdate?.()),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(t=>this._$ET(t,this[t])),this._$EM()}updated(t){}firstUpdated(t){}}W.elementStyles=[],W.shadowRootOptions={mode:"open"},W.elementProperties=new Map,W.finalized=new Map,j?.({ReactiveElement:W}),($.reactiveElementVersions??=[]).push("2.1.1");let Y=globalThis,K=Y.trustedTypes,J=K?K.createPolicy("lit-html",{createHTML:t=>t}):void 0,Q="$lit$",tt=`lit$${Math.random().toFixed(9).slice(2)}$`,te="?"+tt,ti=`<${te}>`,tn=document,tr=()=>tn.createComment(""),ta=t=>null===t||"object"!=typeof t&&"function"!=typeof t,to=Array.isArray,ts=t=>to(t)||"function"==typeof t?.[Symbol.iterator],tl="[ \n\f\r]",tc=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,td=/-->/g,tu=/>/g,th=RegExp(`>|${tl}(?:([^\\s"'>=/]+)(${tl}*=${tl}*(?:[^
52
52
  \f\r"'\`<>=]|("|')|))|$)`,"g"),tp=/'/g,tm=/"/g,tf=/^(?:script|style|textarea|title)$/i,tg=t=>(e,...i)=>({_$litType$:t,strings:e,values:i}),t_=tg(1),tb=(tg(2),tg(3),Symbol.for("lit-noChange")),ty=Symbol.for("lit-nothing"),tv=new WeakMap,tx=tn.createTreeWalker(tn,129);function tw(t,e){if(!to(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==J?J.createHTML(e):e}let tk=(t,e)=>{let i=t.length-1,n=[],r,a=2===e?"<svg>":3===e?"<math>":"",o=tc;for(let e=0;e<i;e++){let i=t[e],s,l,c=-1,d=0;for(;d<i.length&&(o.lastIndex=d,null!==(l=o.exec(i)));)d=o.lastIndex,o===tc?"!--"===l[1]?o=td:void 0!==l[1]?o=tu:void 0!==l[2]?(tf.test(l[2])&&(r=RegExp("</"+l[2],"g")),o=th):void 0!==l[3]&&(o=th):o===th?">"===l[0]?(o=r??tc,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,s=l[1],o=void 0===l[3]?th:'"'===l[3]?tm:tp):o===tm||o===tp?o=th:o===td||o===tu?o=tc:(o=th,r=void 0);let u=o===th&&t[e+1].startsWith("/>")?" ":"";a+=o===tc?i+ti:c>=0?(n.push(s),i.slice(0,c)+Q+i.slice(c)+tt+u):i+tt+(-2===c?e:u)}return[tw(t,a+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),n]};class tE{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,a=0,o=t.length-1,s=this.parts,[l,c]=tk(t,e);if(this.el=tE.createElement(l,i),tx.currentNode=this.el.content,2===e||3===e){let t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=tx.nextNode())&&s.length<o;){if(1===n.nodeType){if(n.hasAttributes())for(let t of n.getAttributeNames())if(t.endsWith(Q)){let e=c[a++],i=n.getAttribute(t).split(tt),o=/([.?@])?(.*)/.exec(e);s.push({type:1,index:r,name:o[2],strings:i,ctor:"."===o[1]?tS:"?"===o[1]?tz:"@"===o[1]?tL:tI}),n.removeAttribute(t)}else t.startsWith(tt)&&(s.push({type:6,index:r}),n.removeAttribute(t));if(tf.test(n.tagName)){let t=n.textContent.split(tt),e=t.length-1;if(e>0){n.textContent=K?K.emptyScript:"";for(let i=0;i<e;i++)n.append(t[i],tr()),tx.nextNode(),s.push({type:2,index:++r});n.append(t[e],tr())}}}else if(8===n.nodeType)if(n.data===te)s.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(tt,t+1));)s.push({type:7,index:r}),t+=tt.length-1}r++}}static createElement(t,e){let i=tn.createElement("template");return i.innerHTML=t,i}}function tC(t,e,i=t,n){if(e===tb)return e;let r=void 0!==n?i._$Co?.[n]:i._$Cl,a=ta(e)?void 0:e._$litDirective$;return r?.constructor!==a&&(r?._$AO?.(!1),void 0===a?r=void 0:(r=new a(t))._$AT(t,i,n),void 0!==n?(i._$Co??=[])[n]=r:i._$Cl=r),void 0!==r&&(e=tC(t,r._$AS(t,e.values),r,n)),e}class tA{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:i}=this._$AD,n=(t?.creationScope??tn).importNode(e,!0);tx.currentNode=n;let r=tx.nextNode(),a=0,o=0,s=i[0];for(;void 0!==s;){if(a===s.index){let e;2===s.type?e=new tT(r,r.nextSibling,this,t):1===s.type?e=new s.ctor(r,s.name,s.strings,this,t):6===s.type&&(e=new tM(r,this,t)),this._$AV.push(e),s=i[++o]}a!==s?.index&&(r=tx.nextNode(),a++)}return tx.currentNode=tn,n}p(t){let e=0;for(let i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class tT{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=ty,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){ta(t=tC(this,t,e))?t===ty||null==t||""===t?(this._$AH!==ty&&this._$AR(),this._$AH=ty):t!==this._$AH&&t!==tb&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):ts(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==ty&&ta(this._$AH)?this._$AA.nextSibling.data=t:this.T(tn.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:i}=t,n="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=tE.createElement(tw(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===n)this._$AH.p(e);else{let t=new tA(n,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=tv.get(t.strings);return void 0===e&&tv.set(t.strings,e=new tE(t)),e}k(t){to(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,i,n=0;for(let r of t)n===e.length?e.push(i=new tT(this.O(tr()),this.O(tr()),this,this.options)):i=e[n],i._$AI(r),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class tI{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,n,r){this.type=1,this._$AH=ty,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ty}_$AI(t,e=this,i,n){let r=this.strings,a=!1;if(void 0===r)(a=!ta(t=tC(this,t,e,0))||t!==this._$AH&&t!==tb)&&(this._$AH=t);else{let n,o,s=t;for(t=r[0],n=0;n<r.length-1;n++)(o=tC(this,s[i+n],e,n))===tb&&(o=this._$AH[n]),a||=!ta(o)||o!==this._$AH[n],o===ty?t=ty:t!==ty&&(t+=(o??"")+r[n+1]),this._$AH[n]=o}a&&!n&&this.j(t)}j(t){t===ty?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tS extends tI{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===ty?void 0:t}}class tz extends tI{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==ty)}}class tL extends tI{constructor(t,e,i,n,r){super(t,e,i,n,r),this.type=5}_$AI(t,e=this){if((t=tC(this,t,e,0)??ty)===tb)return;let i=this._$AH,n=t===ty&&i!==ty||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==ty&&(i===ty||n);n&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class tM{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){tC(this,t)}}let tR=Y.litHtmlPolyfillSupport;tR?.(tE,tT),(Y.litHtmlVersions??=[]).push("3.3.1");let tP=globalThis;class tD extends W{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{let n=i?.renderBefore??e,r=n._$litPart$;if(void 0===r){let t=i?.renderBefore??null;n._$litPart$=r=new tT(e.insertBefore(tr(),t),t,void 0,i??{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return tb}}tD._$litElement$=!0,tD.finalized=!0,tP.litElementHydrateSupport?.({LitElement:tD});let tO=tP.litElementPolyfillSupport;tO?.({LitElement:tD}),(tP.litElementVersions??=[]).push("4.2.1");let tB=t=>(e,i)=>{void 0!==i?i.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},tF={attribute:!0,type:String,converter:G,reflect:!1,hasChanged:X};function tN(t){return(e,i)=>"object"==typeof i?((t=tF,e,i)=>{let{kind:n,metadata:r}=i,a=globalThis.litPropertyMetadata.get(r);if(void 0===a&&globalThis.litPropertyMetadata.set(r,a=new Map),"setter"===n&&((t=Object.create(t)).wrapped=!0),a.set(i.name,t),"accessor"===n){let{name:n}=i;return{set(i){let r=e.get.call(this);e.set.call(this,i),this.requestUpdate(n,r,t)},init(e){return void 0!==e&&this.C(n,void 0,t,e),e}}}if("setter"===n){let{name:n}=i;return function(i){let r=this[n];e.call(this,i),this.requestUpdate(n,r,t)}}throw Error("Unsupported decorator location: "+n)})(t,e,i):((t,e,i)=>{let n=e.hasOwnProperty(i);return e.constructor.createProperty(i,t),n?Object.getOwnPropertyDescriptor(e,i):void 0})(t,e,i)}function tV(t){return tN({...t,state:!0,attribute:!1})}let tU=(t,e,i)=>(i.configurable=!0,i.enumerable=!0,Reflect.decorate&&"object"!=typeof e&&Object.defineProperty(t,e,i),i);function t$(t,e){return(i,n,r)=>{let a=e=>e.renderRoot?.querySelector(t)??null;if(e){let{get:t,set:e}="object"==typeof n?i:r??(()=>{let t=Symbol();return{get(){return this[t]},set(e){this[t]=e}}})();return tU(i,n,{get(){let i=t.call(this);return void 0===i&&(null!==(i=a(this))||this.hasUpdated)&&e.call(this,i),i}})}return tU(i,n,{get(){return a(this)}})}}var tH=o(266),tq=o.n(tH),tj=o(230),tG=o.n(tj);o(811);var tX=o(891),tZ=o(297);function tW(t){if(t){if(t instanceof tH.LngLat)return t;if(t.lat)return t.lon?{lng:t.lon,lat:t.lat}:{lng:t.lng,lat:t.lat};if(Array.isArray(t))return{lng:t[0],lat:t[1]};if(t.coordinates&&Array.isArray(t.coordinates)&&t.coordinates.length>=2)return tW(t.coordinates);if(t.attributes){let e=t.attributes.location;return e&&e.value?tW(e.value):void 0}if(t.value)return tW(t.value)}}function tY(t){if(t)return Array.isArray(t)?{type:"Point",coordinates:t}:{type:"Point",coordinates:[t.hasOwnProperty("lng")?t.lng:t.lon,t.lat]}}function tK(t){if(t){if(t instanceof tH.LngLatBounds)return t;if(2===t.length){let e=tW(t[0]),i=tW(t[1]);if(e&&i)return new tH.LngLatBounds(e,i)}if(4===t.length)return new tH.LngLatBounds([t[0],t[1],t[2],t[3]])}}function tJ(t){let e=tK(t);if(e)return L.latLngBounds(e.getNorthEast(),e.getSouthWest())}function tQ(t,e){if(!t)return;let i="string"==typeof t?tZ.AssetModelUtil.getAssetDescriptor(t):t,n=i&&i.icon?i.icon:"help-circle",r=i&&i.colour?i.colour:void 0;if(e&&e.markerConfig){let t=e.markerConfig,i=e.currentValue;if("range"===t.type&&t.ranges&&"number"==typeof i){let e=t.ranges;r=(e.sort((t,e)=>e.min-t.min).find(t=>i>=t.min)||e.reduce((t,e)=>e.min>t.min?t:e)).colour||void 0}else"boolean"===t.type?r=t[!!i+""]:"string"===t.type&&(r=t[i+""])}return{color:r,icon:n}}function t0(t){let e=t.match(/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/);if(!e)throw Error("Unable to parse URL object");return{protocol:e[1],authority:e[2],path:e[3]||"/",params:e[4]?e[4].split("&"):[]}}function t1(t,e){let i=t0("https://api.mapbox.com");t.protocol=i.protocol,t.authority=i.authority,t.params.push(`access_token=${e}`);let n=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${n}`}var t2=function(t,e,i,n){return new(i||(i=Promise))(function(r,a){function o(t){try{l(n.next(t))}catch(t){a(t)}}function s(t){try{l(n.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?r(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(o,s)}l((n=n.apply(t,e||[])).next())})};let t5=o(278),t3=o(569),t4=o(811);class t6{constructor(t,e,i,n=!1,r=!1,a=!0,o=!0){this._loaded=!1,this._markersJs=new Map,this._markersGl=new Map,this._geoJsonSources=[],this._geoJsonLayers=new Map,this._showGeoCodingControl=!1,this._showBoundaryBox=!1,this._useZoomControls=!0,this._showGeoJson=!0,this._clickHandlers=new Map,this._type=t,this._styleParent=e,this._mapContainer=i,this._showGeoCodingControl=n,this._showBoundaryBox=r,this._useZoomControls=a,this._showGeoJson=o}setCenter(t){switch(this._center=tW(t),this._type){case"RASTER":if(this._mapJs){let t=tW(this._center)||(this._viewSettings?tW(this._viewSettings.center):void 0);t&&this._mapJs.setView(t,void 0,{pan:{animate:!1},zoom:{animate:!1}})}break;case"VECTOR":this._mapGl&&this._center&&this._mapGl.setCenter(this._center)}return this}flyTo(t,e){switch(this._type){case"RASTER":this._mapJs;break;case"VECTOR":t||(t=this._center?this._center:this._viewSettings?this._viewSettings.center:void 0),e||(e=this._zoom?this._zoom:this._viewSettings&&this._viewSettings.zoom?this._viewSettings.zoom:void 0),this._mapGl?t&&this._mapGl.flyTo({center:t,zoom:e}):(this._center=t,this._zoom=e)}return this}resize(){switch(this._type){case"RASTER":this._mapJs;break;case"VECTOR":this._mapGl&&this._mapGl.resize()}return this}setZoom(t){switch(this._zoom=t,this._type){case"RASTER":this._mapJs&&this._zoom&&this._mapJs.setZoom(this._zoom,{animate:!1});break;case"VECTOR":this._mapGl&&this._zoom&&this._mapGl.setZoom(this._zoom)}return this}setControls(t){return this._controls=t,this._mapGl&&(this._controls?this._controls.forEach(t=>{Array.isArray(t)?this._mapGl.addControl(t[0],t[1]):this._mapGl.addControl(t)}):this._mapGl.addControl(new tH.NavigationControl)),this}setGeoJson(t){var e;return this._geoJsonConfig=t,this._mapGl&&(this._geoJsonConfig?this.loadGeoJSON(this._geoJsonConfig):this.loadGeoJSON(null==(e=this._viewSettings)?void 0:e.geoJson)),this}loadViewSettings(){return t2(this,void 0,void 0,function*(){var t;let e=("RASTER"===this._type?yield f().rest.api.MapResource.getSettingsJs():yield f().rest.api.MapResource.getSettings()).data;if(e.override)return e.override;let i=f().displayRealm||"default";return this._viewSettings=e.options?e.options[i]?e.options[i]:e.options.default:null,this._viewSettings&&(this._mapGl&&(this._mapGl.setMinZoom(this._viewSettings.minZoom),this._mapGl.setMaxZoom(this._viewSettings.maxZoom),this._viewSettings.bounds&&this._mapGl.setMaxBounds(this._viewSettings.bounds),this._geoJsonConfig?yield this.loadGeoJSON(this._geoJsonConfig):yield this.loadGeoJSON(null==(t=this._viewSettings)?void 0:t.geoJson)),this._center?this.setCenter(this._center):this.setCenter(this._viewSettings.center)),e})}load(){return t2(this,void 0,void 0,function*(){var e;if(!this._loaded){if("RASTER"===this._type){let t,e=document.createElement("style");e.id="mapboxJsStyle",e.textContent=t5,this._styleParent.appendChild(e);let i=yield this.loadViewSettings();if(this._viewSettings){if((t={}).zoom=this._viewSettings.zoom?this._viewSettings.zoom+1:void 0,this._useZoomControls&&(t.maxZoom=this._viewSettings.maxZoom?this._viewSettings.maxZoom-1:void 0,t.minZoom=this._viewSettings.minZoom?this._viewSettings.minZoom+1:void 0),t.boxZoom=this._viewSettings.boxZoom,this._viewSettings.bounds&&(t.maxBounds=tJ(this._viewSettings.bounds)),this._viewSettings.center){let e=tW(this._viewSettings.center);t.center=e?L.latLng(e.lat,e.lng):void 0}if(this._center){let e=tW(this._center);t.center=e?L.latLng(e.lat,e.lng):void 0}this._zoom&&(t.zoom=this._zoom+1)}if(this._mapJs=L.mapbox.map(this._mapContainer,i,t),this._mapJs.on("click",t=>{this._onMapClick(t.latlng)}),t&&t.maxBounds){let e=this._mapJs.getBoundsZoom(t.maxBounds,!0);(!t.minZoom||t.minZoom<e)&&this._mapJs.setMinZoom(e)}}else{let i=document.createElement("style");i.id="maplibreGlStyle",i.textContent=t3,this._styleParent.appendChild(i),(i=document.createElement("style")).id="maplibreGeoCoderStyles",i.textContent=t4,this._styleParent.appendChild(i);let n=yield Promise.resolve().then(o.t.bind(o,266,23)),r=yield this.loadViewSettings(),a={attributionControl:{compact:!0},container:this._mapContainer,style:r,transformRequest:(e,i)=>{if(t||(t=new URL(e).searchParams.get("access_token")||""),0===e.indexOf("mapbox:")){var n;return n=t,e.indexOf("/styles/")>-1&&-1===e.indexOf("/sprite")?{url:function(t,e){let i=t0(t);return i.path=`/styles/v1${i.path}`,t1(i,e)}(e,n)}:e.indexOf("/sprites/")>-1?{url:function(t,e){let i=t0(t),n=i.path.split("."),r=n[0],a=n[1],o="";return r.indexOf("@2x")&&(r=r.split("@2x")[0],o="@2x"),i.path=`/styles/v1${r}/sprite${o}.${a}`,t1(i,e)}(e,n)}:e.indexOf("/fonts/")>-1?{url:function(t,e){let i=t0(t);return i.path=`/fonts/v1${i.path}`,t1(i,e)}(e,n)}:e.indexOf("/v4/")>-1||"Source"===i?{url:function(t,e){let i=t0(t);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),t1(i,e)}(e,n)}:void 0}return{headers:new URL(window.origin).hostname===new URL(e).hostname?{Authorization:f().getAuthorizationHeader()}:{},url:e}}};if(this._viewSettings&&(this._useZoomControls&&(a.maxZoom=this._viewSettings.maxZoom,a.minZoom=this._viewSettings.minZoom),this._viewSettings.bounds&&!this._showBoundaryBox&&(a.maxBounds=this._viewSettings.bounds),a.boxZoom=this._viewSettings.boxZoom,a.zoom=this._viewSettings.zoom,a.center=this._viewSettings.center),this._center=this._center||(this._viewSettings?this._viewSettings.center:void 0),a.center=this._center,this._zoom&&(a.zoom=this._zoom),!this.isWebglSupported())return void console.warn("WebGL is not supported in this environment. The map cannot be initialized.");this._mapGl=new n.Map(a),yield this.styleLoaded(),this._mapGl.on("click",t=>{this._onMapClick(t.lngLat)}),this._mapGl.on("dblclick",t=>{this._onMapClick(t.lngLat,!0)}),this._showGeoCodingControl&&this._viewSettings&&this._viewSettings.geocodeUrl&&(this._geocoder=new(tG())({forwardGeocode:this._forwardGeocode.bind(this),reverseGeocode:this._reverseGeocode},{maplibregl:tq(),showResultsWhileTyping:!0}),this._geocoder._onKeyDown=(0,tX.debounce)(t=>{if(27===t.keyCode&&this._geocoder.options.clearAndBlurOnEsc)return this._geocoder._clear(t),this._geocoder._inputEl.blur();var e=this._geocoder._inputEl.value||t.key;if(!e)return this._geocoder.fresh=!0,9!==t.keyCode&&this._geocoder.clear(t),this._geocoder._clearEl.style.display="none";if(!t.metaKey&&-1===[9,27,37,39,38,40].indexOf(t.keyCode)){if(13===t.keyCode)if(this._geocoder.options.showResultsWhileTyping){this._geocoder.options.showResultMarkers&&this._geocoder._fitBoundsForMarkers(),this._geocoder._inputEl.value=this._geocoder._typeahead.query,this._geocoder.lastSelected=null,this._geocoder._typeahead.selected=null;return}else this._geocoder._typeahead.list.selectingListItem||this._geocoder._geocode(e);e.length>=this._geocoder.options.minLength&&this._geocoder.options.showResultsWhileTyping&&this._geocoder._geocode(e)}},300),this._mapGl.addControl(this._geocoder,"top-left"),this._geocoder._inputEl.addEventListener("change",()=>{var t=this._geocoder._typeahead.selected;this._onGeocodeChange(t)})),this._controls?this._controls.forEach(t=>{Array.isArray(t)?this._mapGl.addControl(t[0],t[1]):this._mapGl.addControl(t)}):(this._mapGl.addControl(new tH.NavigationControl),this._mapGl.addControl(new tH.GeolocateControl({positionOptions:{enableHighAccuracy:!0},showAccuracyCircle:!0,showUserLocation:!0}))),this._geoJsonConfig?yield this.loadGeoJSON(this._geoJsonConfig):yield this.loadGeoJSON(null==(e=this._viewSettings)?void 0:e.geoJson),this._initLongPressEvent()}this._mapContainer.dispatchEvent(new rh),this._loaded=!0,this.createBoundaryBox()}})}styleLoaded(){return new Promise(t=>{this._mapGl&&this._mapGl.once("style.load",()=>{t()})})}unload(){this._mapGl&&(this._mapGl.remove(),this._mapGl=void 0),this._mapJs&&(this._mapJs.remove(),this._mapJs=void 0)}_onMapClick(t,e=!1){this._mapContainer.dispatchEvent(new rp(t,e))}loadGeoJSON(t){return t2(this,void 0,void 0,function*(){if(this._geoJsonLayers.size>0&&(this._geoJsonLayers.forEach((t,e)=>this._mapGl.removeLayer(e)),this._geoJsonLayers=new Map),this._geoJsonSources.length>0&&(this._geoJsonSources.forEach(t=>this._mapGl.removeSource(t)),this._geoJsonSources=[]),this._showGeoJson&&t)if("FeatureCollection"==t.source.type){let e=this.groupSourcesByGeometryType(t.source);null==e||e.forEach((t,e)=>{let i=this.addGeoJSONSource({type:"geojson",data:{type:"FeatureCollection",features:t}});i&&this.addGeoJSONLayer(e,i.sourceId)})}else if("Feature"==t.source.type){let e=this.addGeoJSONSource(t.source);e&&this.addGeoJSONLayer(e.source.type,e.sourceId)}else console.error("Could not create layer since source type is neither 'FeatureCollection' nor 'Feature'.")})}groupSourcesByGeometryType(t){let e=new Map;return t.features.forEach(t=>{let i=e.get(t.geometry.type);void 0==i&&(i=[]),i.push(t),e.set(t.geometry.type,i)}),e}addGeoJSONSource(t){if(!this._mapGl)return void console.error("mapGl instance not found!");let e=Date.now()+"-"+(this._geoJsonSources.length+1);return this._mapGl.addSource(e,t),this._geoJsonSources.push(e),{source:t,sourceId:e}}addGeoJSONLayer(t,e){if(!this._mapGl)return void console.error("mapGl instance not found!");let i=e+"-"+t;if(void 0==this._geoJsonLayers.get(i)){let n=getComputedStyle(this._mapContainer).getPropertyValue("--or-app-color4");(void 0==n||0==n.length)&&(n=m.DefaultColor4);let r={id:i,source:e};switch(t){case"Point":case"MultiPoint":r.type="circle",r.paint={"circle-radius":12,"circle-color":n},this._geoJsonLayers.set(i,r),this._mapGl.addLayer(r);break;case"LineString":case"MultiLineString":r.type="line",r.paint={"line-color":n,"line-width":4},this._geoJsonLayers.set(i,r),this._mapGl.addLayer(r);break;case"Polygon":case"MultiPolygon":{r.type="fill",r.paint={"fill-color":n,"fill-opacity":.3},this._geoJsonLayers.set(i,r),this._mapGl.addLayer(r);let t=i+"-outline",a={id:t,source:e,type:"line",paint:{"line-color":n,"line-width":2}};this._geoJsonLayers.set(t,a),this._mapGl.addLayer(a);break}case"GeometryCollection":return void console.error("GeometryCollection GeoJSON is not implemented yet!")}}}addMarker(t){t.hasPosition()&&this._updateMarkerElement(t,!0)}removeMarker(t){this._removeMarkerRadius(t),this._updateMarkerElement(t,!1)}onMarkerChanged(t,e){if(this._loaded)switch(e){case"lat":case"lng":case"radius":t.hasPosition()?t._actualMarkerElement?this._updateMarkerPosition(t):this._updateMarkerElement(t,!0):t._actualMarkerElement&&this._updateMarkerElement(t,!1)}}_updateMarkerPosition(t){switch(this._type){case"RASTER":let e=this._markersJs.get(t);e&&e.setLatLng([t.lat,t.lng]);break;case"VECTOR":let i=this._markersGl.get(t);i&&i.setLngLat([t.lng,t.lat])}this._createMarkerRadius(t)}_updateMarkerElement(t,e){switch(this._type){case"RASTER":let i=this._markersJs.get(t);if(i&&(this._removeMarkerClickHandler(t,t.markerContainer),t._actualMarkerElement=void 0,i.removeFrom(this._mapJs),this._markersJs.delete(t)),e){let e=t._createMarkerElement();if(e){let n=L.divIcon({html:e.outerHTML,className:"or-marker-raster"});(i=L.marker([t.lat,t.lng],{icon:n,clickable:t.interactive})).addTo(this._mapJs),t._actualMarkerElement=i.getElement()?i.getElement().firstElementChild:void 0,t.interactive&&this._addMarkerClickHandler(t,t.markerContainer),this._markersJs.set(t,i)}t.radius&&this._createMarkerRadius(t)}break;case"VECTOR":let n=this._markersGl.get(t);if(n&&(t._actualMarkerElement=void 0,this._removeMarkerClickHandler(t,n.getElement()),n.remove(),this._markersGl.delete(t)),e){let e=t._createMarkerElement();e&&(n=new tH.Marker({element:e,anchor:"top-left"}).setLngLat([t.lng,t.lat]).addTo(this._mapGl),this._markersGl.set(t,n),t._actualMarkerElement=n.getElement(),t.interactive&&this._addMarkerClickHandler(t,n.getElement())),t.radius&&this._createMarkerRadius(t)}}}_removeMarkerRadius(t){this._mapGl&&this._loaded&&t.radius&&t.lat&&t.lng&&this._mapGl.getSource("circleData")&&(this._mapGl.removeLayer("marker-radius-circle"),this._mapGl.removeSource("circleData"))}_createMarkerRadius(t){this._mapGl&&this._loaded&&t.radius&&t.lat&&t.lng&&(this._removeMarkerRadius(t),this._mapGl.addSource("circleData",{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{title:"You Found Me"}}]}}),this._mapGl.addLayer({id:"marker-radius-circle",type:"circle",source:"circleData",paint:{"circle-radius":["interpolate",["linear"],["zoom"],0,0,20,t.radius/.075/Math.cos(t.lat*Math.PI/180)],"circle-color":"red","circle-opacity":.3}}))}createBoundaryBox(t=[]){var e,i;if(this._mapGl&&this._loaded&&this._showBoundaryBox&&(null==(e=this._viewSettings)?void 0:e.bounds)){this._mapGl.getSource("bounds")&&(this._mapGl.removeLayer("bounds"),this._mapGl.removeSource("bounds")),4!==t.length&&(t=null==(i=this._viewSettings)?void 0:i.bounds.toString().split(","));var n=[[[t[0],t[3]],[t[2],t[3]],[t[2],t[1]],[t[0],t[1]],[t[0],t[3]]]];this._mapGl.fitBounds([parseFloat(t[0])+.01,parseFloat(t[1])-.01,parseFloat(t[2])-.01,parseFloat(t[3])+.01]),this._mapGl.addSource("bounds",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:n}}}),this._mapGl.addLayer({id:"bounds",type:"fill",source:"bounds",paint:{"fill-color":"#FF0000","fill-opacity":.4}})}}_addMarkerClickHandler(t,e){if(e){let i=e=>{e.stopPropagation(),t._onClick(e)};this._clickHandlers.set(t,i),e.addEventListener("click",i)}}_removeMarkerClickHandler(t,e){let i=this._clickHandlers.get(t);i&&e&&(e.removeEventListener("click",i),this._clickHandlers.delete(t))}_forwardGeocode(t){return t2(this,void 0,void 0,function*(){let e=[];try{let i=this._viewSettings.geocodeUrl+"/search?q="+t.query+"&format=geojson&polygon_geojson=1&addressdetails=1",n=yield fetch(i);for(let t of(yield n.json()).features){let i=[t.bbox[0]+(t.bbox[2]-t.bbox[0])/2,t.bbox[1]+(t.bbox[3]-t.bbox[1])/2],n={type:"Feature",geometry:{type:"Point",coordinates:i},place_name:t.properties.display_name,properties:t.properties,text:t.properties.display_name,place_type:["place"],center:i};e.push(n)}}catch(t){console.error(`Failed to forwardGeocode with error: ${t}`)}return{features:e}})}_reverseGeocode(t){return t2(this,void 0,void 0,function*(){let e=[];try{let i=this._viewSettings.geocodeUrl+"/reverse?lat="+t.lat+"&lon="+t.lon+"&format=geojson&polygon_geojson=1&addressdetails=1",n=yield fetch(i);for(let t of(yield n.json()).features){let i=[t.bbox[0]+(t.bbox[2]-t.bbox[0])/2,t.bbox[1]+(t.bbox[3]-t.bbox[1])/2],n={type:"Feature",geometry:{type:"Point",coordinates:i},place_name:t.properties.display_name,properties:t.properties,text:t.properties.display_name,place_type:["place"],center:i};e.push(n)}}catch(t){console.error(`Failed to reverseGeocode with error: ${t}`)}return{features:e}})}_initLongPressEvent(){if(this._mapGl){let t,e,i=()=>{t&&clearTimeout(t),t=null};this._mapGl.on("touchstart",i=>{i.originalEvent.touches.length>1||(e=i.lngLat,t=setTimeout(()=>{this._onLongPress(e)},500))}),this._mapGl.on("mousedown",i=>{t||(e=i.lngLat,t=setTimeout(()=>{this._onLongPress(e),t=null},500))}),this._mapGl.on("dragstart",i),this._mapGl.on("mouseup",i),this._mapGl.on("touchend",i),this._mapGl.on("touchcancel",i),this._mapGl.on("touchmove",i),this._mapGl.on("moveend",i),this._mapGl.on("gesturestart",i),this._mapGl.on("gesturechange",i),this._mapGl.on("gestureend",i)}}_onLongPress(t){this._mapContainer.dispatchEvent(new rm(t))}_onGeocodeChange(t){this._mapContainer.dispatchEvent(new rf(t))}isWebglSupported(){if(window.WebGLRenderingContext){let t=document.createElement("canvas");try{let e=t.getContext("webgl2")||t.getContext("webgl");if(e&&"function"==typeof e.getParameter)return!0}catch(t){}}return!1}}let t7="--internal-or-map-marker-color",t8="--internal-or-map-marker-active-color",t9=P`
53
53
  :host {
54
54
  --internal-or-map-width: var(--or-map-width, 100%);