@opengis/admin 0.3.64 → 0.3.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-page-Daf1yymq.js → add-page-B4Ine_Pn.js} +1 -1
- package/dist/{admin-interface-DnE5Mnwe.js → admin-interface-DFf_t0db.js} +1 -1
- package/dist/{admin-view-CmSe43Q3.js → admin-view-eDKr7GB4.js} +1 -1
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +1 -1
- package/dist/{card-view-CN8LO5mm.js → card-view-uroZ1ej6.js} +1 -1
- package/dist/{edit-page-C7eUwU-5.js → edit-page-DARuYr_l.js} +1 -1
- package/dist/{import-file-DRzOvv7x.js → import-file-Dt2mnHAW.js} +135 -133
- package/dist/{profile-page-4waAht89.js → profile-page-5pEpnlCB.js} +1 -1
- package/package.json +4 -4
- package/server/routes/properties/controllers/admin.properties.get.js +6 -12
- package/server/routes/properties/controllers/admin.properties.post.js +17 -11
package/dist/admin.umd.cjs
CHANGED
@@ -617,7 +617,7 @@ uniform ${$} ${j} u_${X};
|
|
617
617
|
#endif
|
618
618
|
`}),staticAttributes:b,staticUniforms:M}}class Ef{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(l,f,b,_,w,M,P,R,z){this.context=l;let $=this.boundPaintVertexBuffers.length!==_.length;for(let j=0;!$&&j<_.length;j++)this.boundPaintVertexBuffers[j]!==_[j]&&($=!0);!this.vao||this.boundProgram!==f||this.boundLayoutVertexBuffer!==b||$||this.boundIndexBuffer!==w||this.boundVertexOffset!==M||this.boundDynamicVertexBuffer!==P||this.boundDynamicVertexBuffer2!==R||this.boundDynamicVertexBuffer3!==z?this.freshBind(f,b,_,w,M,P,R,z):(l.bindVertexArray.set(this.vao),P&&P.bind(),w&&w.dynamicDraw&&w.bind(),R&&R.bind(),z&&z.bind())}freshBind(l,f,b,_,w,M,P,R){const z=l.numAttributes,$=this.context,j=$.gl;this.vao&&this.destroy(),this.vao=$.createVertexArray(),$.bindVertexArray.set(this.vao),this.boundProgram=l,this.boundLayoutVertexBuffer=f,this.boundPaintVertexBuffers=b,this.boundIndexBuffer=_,this.boundVertexOffset=w,this.boundDynamicVertexBuffer=M,this.boundDynamicVertexBuffer2=P,this.boundDynamicVertexBuffer3=R,f.enableAttributes(j,l);for(const X of b)X.enableAttributes(j,l);M&&M.enableAttributes(j,l),P&&P.enableAttributes(j,l),R&&R.enableAttributes(j,l),f.bind(),f.setVertexAttribPointers(j,l,w);for(const X of b)X.bind(),X.setVertexAttribPointers(j,l,w);M&&(M.bind(),M.setVertexAttribPointers(j,l,w)),_&&_.bind(),P&&(P.bind(),P.setVertexAttribPointers(j,l,w)),R&&(R.bind(),R.setVertexAttribPointers(j,l,w)),$.currentNumAttributes=z}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Sf=(E,l,f,b,_)=>({u_matrix:E,u_texture:0,u_ele_delta:l,u_fog_matrix:f,u_fog_color:b?b.properties.get("fog-color"):o.aM.white,u_fog_ground_blend:b?b.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:b?b.calculateFogBlendOpacity(_):0,u_horizon_color:b?b.properties.get("horizon-color"):o.aM.white,u_horizon_fog_blend:b?b.properties.get("horizon-fog-blend"):1});function ml(E){const l=[];for(let f=0;f<E.length;f++){if(E[f]===null)continue;const b=E[f].split(" ");l.push(b.pop())}return l}class Cf{constructor(l,f,b,_,w,M){const P=l.gl;this.program=P.createProgram();const R=ml(f.staticAttributes),z=b?b.getBinderAttributes():[],$=R.concat(z),j=Bo.prelude.staticUniforms?ml(Bo.prelude.staticUniforms):[],X=f.staticUniforms?ml(f.staticUniforms):[],ee=b?b.getBinderUniforms():[],te=j.concat(X).concat(ee),se=[];for(const Ce of te)se.indexOf(Ce)<0&&se.push(Ce);const le=b?b.defines():[];w&&le.push("#define OVERDRAW_INSPECTOR;"),M&&le.push("#define TERRAIN3D;");const de=le.concat(Bo.prelude.fragmentSource,f.fragmentSource).join(`
|
619
619
|
`),pe=le.concat(Bo.prelude.vertexSource,f.vertexSource).join(`
|
620
|
-
`),ie=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(ie,de),P.compileShader(ie),!P.getShaderParameter(ie,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(ie)}`);P.attachShader(this.program,ie);const _e=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(_e,pe),P.compileShader(_e),!P.getShaderParameter(_e,P.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${P.getShaderInfoLog(_e)}`);P.attachShader(this.program,_e),this.attributes={};const ve={};this.numAttributes=$.length;for(let Ce=0;Ce<this.numAttributes;Ce++)$[Ce]&&(P.bindAttribLocation(this.program,Ce,$[Ce]),this.attributes[$[Ce]]=Ce);if(P.linkProgram(this.program),!P.getProgramParameter(this.program,P.LINK_STATUS))throw new Error(`Program failed to link: ${P.getProgramInfoLog(this.program)}`);P.deleteShader(_e),P.deleteShader(ie);for(let Ce=0;Ce<se.length;Ce++){const ze=se[Ce];if(ze&&!ve[ze]){const Ze=P.getUniformLocation(this.program,ze);Ze&&(ve[ze]=Ze)}}this.fixedUniforms=_(l,ve),this.terrainUniforms=((Ce,ze)=>({u_depth:new o.aH(Ce,ze.u_depth),u_terrain:new o.aH(Ce,ze.u_terrain),u_terrain_dim:new o.aI(Ce,ze.u_terrain_dim),u_terrain_matrix:new o.aJ(Ce,ze.u_terrain_matrix),u_terrain_unpack:new o.aK(Ce,ze.u_terrain_unpack),u_terrain_exaggeration:new o.aI(Ce,ze.u_terrain_exaggeration)}))(l,ve),this.binderUniforms=b?b.getUniforms(l,ve):[]}draw(l,f,b,_,w,M,P,R,z,$,j,X,ee,te,se,le,de,pe){const ie=l.gl;if(this.failedToCreate)return;if(l.program.set(this.program),l.setDepthMode(b),l.setStencilMode(_),l.setColorMode(w),l.setCullFace(M),R){l.activeTexture.set(ie.TEXTURE2),ie.bindTexture(ie.TEXTURE_2D,R.depthTexture),l.activeTexture.set(ie.TEXTURE3),ie.bindTexture(ie.TEXTURE_2D,R.texture);for(const ve in this.terrainUniforms)this.terrainUniforms[ve].set(R[ve])}for(const ve in this.fixedUniforms)this.fixedUniforms[ve].set(P[ve]);se&&se.setUniforms(l,this.binderUniforms,ee,{zoom:te});let _e=0;switch(f){case ie.LINES:_e=2;break;case ie.TRIANGLES:_e=3;break;case ie.LINE_STRIP:_e=1}for(const ve of X.get()){const Ce=ve.vaos||(ve.vaos={});(Ce[z]||(Ce[z]=new Ef)).bind(l,this,$,se?se.getPaintVertexBuffers():[],j,ve.vertexOffset,le,de,pe),ie.drawElements(f,ve.primitiveLength*_e,ie.UNSIGNED_SHORT,ve.primitiveOffset*_e*2)}}}function du(E,l,f){const b=1/cn(f,1,l.transform.tileZoom),_=Math.pow(2,f.tileID.overscaledZ),w=f.tileSize*Math.pow(2,l.transform.tileZoom)/_,M=w*(f.tileID.canonical.x+f.tileID.wrap*_),P=w*f.tileID.canonical.y;return{u_image:0,u_texsize:f.imageAtlasTexture.size,u_scale:[b,E.fromScale,E.toScale],u_fade:E.t,u_pixel_coord_upper:[M>>16,P>>16],u_pixel_coord_lower:[65535&M,65535&P]}}const Pc=(E,l,f,b)=>{const _=l.style.light,w=_.properties.get("position"),M=[w.x,w.y,w.z],P=function(){var z=new o.A(9);return o.A!=Float32Array&&(z[1]=0,z[2]=0,z[3]=0,z[5]=0,z[6]=0,z[7]=0),z[0]=1,z[4]=1,z[8]=1,z}();_.properties.get("anchor")==="viewport"&&function(z,$){var j=Math.sin($),X=Math.cos($);z[0]=X,z[1]=j,z[2]=0,z[3]=-j,z[4]=X,z[5]=0,z[6]=0,z[7]=0,z[8]=1}(P,-l.transform.angle),function(z,$,j){var X=$[0],ee=$[1],te=$[2];z[0]=X*j[0]+ee*j[3]+te*j[6],z[1]=X*j[1]+ee*j[4]+te*j[7],z[2]=X*j[2]+ee*j[5]+te*j[8]}(M,M,P);const R=_.properties.get("color");return{u_matrix:E,u_lightpos:M,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[R.r,R.g,R.b],u_vertical_gradient:+f,u_opacity:b}},uu=(E,l,f,b,_,w,M)=>o.e(Pc(E,l,f,b),du(w,l,M),{u_height_factor:-Math.pow(2,_.overscaledZ)/M.tileSize/8}),gl=E=>({u_matrix:E}),ly=(E,l,f,b)=>o.e(gl(E),du(f,l,b)),Fv=(E,l)=>({u_matrix:E,u_world:l}),cy=(E,l,f,b,_)=>o.e(ly(E,l,f,b),{u_world:_}),$v=(E,l,f,b)=>{const _=E.transform;let w,M;if(b.paint.get("circle-pitch-alignment")==="map"){const P=cn(f,1,_.zoom);w=!0,M=[P,P]}else w=!1,M=_.pixelsToGLUnits;return{u_camera_to_center_distance:_.cameraToCenterDistance,u_scale_with_map:+(b.paint.get("circle-pitch-scale")==="map"),u_matrix:E.translatePosMatrix(l.posMatrix,f,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_pitch_with_map:+w,u_device_pixel_ratio:E.pixelRatio,u_extrude_scale:M}},xa=(E,l,f)=>({u_matrix:E,u_inv_matrix:l,u_camera_to_center_distance:f.cameraToCenterDistance,u_viewport_size:[f.width,f.height]}),Nc=(E,l,f=1)=>({u_matrix:E,u_color:l,u_overlay:0,u_overlay_scale:f}),Ei=E=>({u_matrix:E}),Si=(E,l,f,b)=>({u_matrix:E,u_extrude_scale:cn(l,1,f),u_intensity:b}),hu=(E,l,f,b)=>{const _=o.H();o.aP(_,0,E.width,E.height,0,0,1);const w=E.context.gl;return{u_matrix:_,u_world:[w.drawingBufferWidth,w.drawingBufferHeight],u_image:f,u_color_ramp:b,u_opacity:l.paint.get("heatmap-opacity")}};function fu(E,l){const f=Math.pow(2,l.canonical.z),b=l.canonical.y;return[new o.Z(0,b/f).toLngLat().lat,new o.Z(0,(b+1)/f).toLngLat().lat]}const pu=(E,l,f,b)=>{const _=E.transform;return{u_matrix:hy(E,l,f,b),u_ratio:1/cn(l,1,_.zoom),u_device_pixel_ratio:E.pixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]]}},dy=(E,l,f,b,_)=>o.e(pu(E,l,f,_),{u_image:0,u_image_height:b}),yl=(E,l,f,b,_)=>{const w=E.transform,M=uy(l,w);return{u_matrix:hy(E,l,f,_),u_texsize:l.imageAtlasTexture.size,u_ratio:1/cn(l,1,w.zoom),u_device_pixel_ratio:E.pixelRatio,u_image:0,u_scale:[M,b.fromScale,b.toScale],u_fade:b.t,u_units_to_pixels:[1/w.pixelsToGLUnits[0],1/w.pixelsToGLUnits[1]]}},jv=(E,l,f,b,_,w)=>{const M=E.lineAtlas,P=uy(l,E.transform),R=f.layout.get("line-cap")==="round",z=M.getDash(b.from,R),$=M.getDash(b.to,R),j=z.width*_.fromScale,X=$.width*_.toScale;return o.e(pu(E,l,f,w),{u_patternscale_a:[P/j,-z.height/2],u_patternscale_b:[P/X,-$.height/2],u_sdfgamma:M.width/(256*Math.min(j,X)*E.pixelRatio)/2,u_image:0,u_tex_y_a:z.y,u_tex_y_b:$.y,u_mix:_.t})};function uy(E,l){return 1/cn(E,1,l.tileZoom)}function hy(E,l,f,b){return E.translatePosMatrix(b?b.posMatrix:l.tileID.posMatrix,l,f.paint.get("line-translate"),f.paint.get("line-translate-anchor"))}const Hv=(E,l,f,b,_)=>{return{u_matrix:E,u_tl_parent:l,u_scale_parent:f,u_buffer_scale:1,u_fade_t:b.mix,u_opacity:b.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:(M=_.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(w=_.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:Uv(_.paint.get("raster-hue-rotate"))};var w,M};function Uv(E){E*=Math.PI/180;const l=Math.sin(E),f=Math.cos(E);return[(2*f+1)/3,(-Math.sqrt(3)*l-f+1)/3,(Math.sqrt(3)*l-f+1)/3]}const fy=(E,l,f,b,_,w,M,P,R,z,$,j,X,ee)=>{const te=M.transform;return{u_is_size_zoom_constant:+(E==="constant"||E==="source"),u_is_size_feature_constant:+(E==="constant"||E==="camera"),u_size_t:l?l.uSizeT:0,u_size:l?l.uSize:0,u_camera_to_center_distance:te.cameraToCenterDistance,u_pitch:te.pitch/360*2*Math.PI,u_rotate_symbol:+f,u_aspect_ratio:te.width/te.height,u_fade_change:M.options.fadeDuration?M.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:R,u_coord_matrix:z,u_is_text:+j,u_pitch_with_map:+b,u_is_along_line:_,u_is_variable_anchor:w,u_texsize:X,u_texture:0,u_translation:$,u_pitched_scale:ee}},Rc=(E,l,f,b,_,w,M,P,R,z,$,j,X,ee,te)=>{const se=M.transform;return o.e(fy(E,l,f,b,_,w,M,P,R,z,$,j,X,te),{u_gamma_scale:b?Math.cos(se._pitch)*se.cameraToCenterDistance:1,u_device_pixel_ratio:M.pixelRatio,u_is_halo:1})},Tf=(E,l,f,b,_,w,M,P,R,z,$,j,X,ee)=>o.e(Rc(E,l,f,b,_,w,M,P,R,z,$,!0,j,!0,ee),{u_texsize_icon:X,u_texture_icon:1}),mu=(E,l,f)=>({u_matrix:E,u_opacity:l,u_color:f}),Af=(E,l,f,b,_,w)=>o.e(function(M,P,R,z){const $=R.imageManager.getPattern(M.from.toString()),j=R.imageManager.getPattern(M.to.toString()),{width:X,height:ee}=R.imageManager.getPixelSize(),te=Math.pow(2,z.tileID.overscaledZ),se=z.tileSize*Math.pow(2,R.transform.tileZoom)/te,le=se*(z.tileID.canonical.x+z.tileID.wrap*te),de=se*z.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:$.tl,u_pattern_br_a:$.br,u_pattern_tl_b:j.tl,u_pattern_br_b:j.br,u_texsize:[X,ee],u_mix:P.t,u_pattern_size_a:$.displaySize,u_pattern_size_b:j.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/cn(z,1,R.transform.tileZoom),u_pixel_coord_upper:[le>>16,de>>16],u_pixel_coord_lower:[65535&le,65535&de]}}(b,w,f,_),{u_matrix:E,u_opacity:l}),Mf={fillExtrusion:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_lightpos:new o.aN(E,l.u_lightpos),u_lightintensity:new o.aI(E,l.u_lightintensity),u_lightcolor:new o.aN(E,l.u_lightcolor),u_vertical_gradient:new o.aI(E,l.u_vertical_gradient),u_opacity:new o.aI(E,l.u_opacity)}),fillExtrusionPattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_lightpos:new o.aN(E,l.u_lightpos),u_lightintensity:new o.aI(E,l.u_lightintensity),u_lightcolor:new o.aN(E,l.u_lightcolor),u_vertical_gradient:new o.aI(E,l.u_vertical_gradient),u_height_factor:new o.aI(E,l.u_height_factor),u_image:new o.aH(E,l.u_image),u_texsize:new o.aO(E,l.u_texsize),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade),u_opacity:new o.aI(E,l.u_opacity)}),fill:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix)}),fillPattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_image:new o.aH(E,l.u_image),u_texsize:new o.aO(E,l.u_texsize),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade)}),fillOutline:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_world:new o.aO(E,l.u_world)}),fillOutlinePattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_world:new o.aO(E,l.u_world),u_image:new o.aH(E,l.u_image),u_texsize:new o.aO(E,l.u_texsize),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade)}),circle:(E,l)=>({u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_scale_with_map:new o.aH(E,l.u_scale_with_map),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_extrude_scale:new o.aO(E,l.u_extrude_scale),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_matrix:new o.aJ(E,l.u_matrix)}),collisionBox:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_pixel_extrude_scale:new o.aO(E,l.u_pixel_extrude_scale)}),collisionCircle:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_inv_matrix:new o.aJ(E,l.u_inv_matrix),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_viewport_size:new o.aO(E,l.u_viewport_size)}),debug:(E,l)=>({u_color:new o.aL(E,l.u_color),u_matrix:new o.aJ(E,l.u_matrix),u_overlay:new o.aH(E,l.u_overlay),u_overlay_scale:new o.aI(E,l.u_overlay_scale)}),clippingMask:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix)}),heatmap:(E,l)=>({u_extrude_scale:new o.aI(E,l.u_extrude_scale),u_intensity:new o.aI(E,l.u_intensity),u_matrix:new o.aJ(E,l.u_matrix)}),heatmapTexture:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_world:new o.aO(E,l.u_world),u_image:new o.aH(E,l.u_image),u_color_ramp:new o.aH(E,l.u_color_ramp),u_opacity:new o.aI(E,l.u_opacity)}),hillshade:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_image:new o.aH(E,l.u_image),u_latrange:new o.aO(E,l.u_latrange),u_light:new o.aO(E,l.u_light),u_shadow:new o.aL(E,l.u_shadow),u_highlight:new o.aL(E,l.u_highlight),u_accent:new o.aL(E,l.u_accent)}),hillshadePrepare:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_image:new o.aH(E,l.u_image),u_dimension:new o.aO(E,l.u_dimension),u_zoom:new o.aI(E,l.u_zoom),u_unpack:new o.aK(E,l.u_unpack)}),line:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels)}),lineGradient:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels),u_image:new o.aH(E,l.u_image),u_image_height:new o.aI(E,l.u_image_height)}),linePattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_texsize:new o.aO(E,l.u_texsize),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_image:new o.aH(E,l.u_image),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade)}),lineSDF:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels),u_patternscale_a:new o.aO(E,l.u_patternscale_a),u_patternscale_b:new o.aO(E,l.u_patternscale_b),u_sdfgamma:new o.aI(E,l.u_sdfgamma),u_image:new o.aH(E,l.u_image),u_tex_y_a:new o.aI(E,l.u_tex_y_a),u_tex_y_b:new o.aI(E,l.u_tex_y_b),u_mix:new o.aI(E,l.u_mix)}),raster:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_tl_parent:new o.aO(E,l.u_tl_parent),u_scale_parent:new o.aI(E,l.u_scale_parent),u_buffer_scale:new o.aI(E,l.u_buffer_scale),u_fade_t:new o.aI(E,l.u_fade_t),u_opacity:new o.aI(E,l.u_opacity),u_image0:new o.aH(E,l.u_image0),u_image1:new o.aH(E,l.u_image1),u_brightness_low:new o.aI(E,l.u_brightness_low),u_brightness_high:new o.aI(E,l.u_brightness_high),u_saturation_factor:new o.aI(E,l.u_saturation_factor),u_contrast_factor:new o.aI(E,l.u_contrast_factor),u_spin_weights:new o.aN(E,l.u_spin_weights)}),symbolIcon:(E,l)=>({u_is_size_zoom_constant:new o.aH(E,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(E,l.u_is_size_feature_constant),u_size_t:new o.aI(E,l.u_size_t),u_size:new o.aI(E,l.u_size),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_pitch:new o.aI(E,l.u_pitch),u_rotate_symbol:new o.aH(E,l.u_rotate_symbol),u_aspect_ratio:new o.aI(E,l.u_aspect_ratio),u_fade_change:new o.aI(E,l.u_fade_change),u_matrix:new o.aJ(E,l.u_matrix),u_label_plane_matrix:new o.aJ(E,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(E,l.u_coord_matrix),u_is_text:new o.aH(E,l.u_is_text),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_is_along_line:new o.aH(E,l.u_is_along_line),u_is_variable_anchor:new o.aH(E,l.u_is_variable_anchor),u_texsize:new o.aO(E,l.u_texsize),u_texture:new o.aH(E,l.u_texture),u_translation:new o.aO(E,l.u_translation),u_pitched_scale:new o.aI(E,l.u_pitched_scale)}),symbolSDF:(E,l)=>({u_is_size_zoom_constant:new o.aH(E,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(E,l.u_is_size_feature_constant),u_size_t:new o.aI(E,l.u_size_t),u_size:new o.aI(E,l.u_size),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_pitch:new o.aI(E,l.u_pitch),u_rotate_symbol:new o.aH(E,l.u_rotate_symbol),u_aspect_ratio:new o.aI(E,l.u_aspect_ratio),u_fade_change:new o.aI(E,l.u_fade_change),u_matrix:new o.aJ(E,l.u_matrix),u_label_plane_matrix:new o.aJ(E,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(E,l.u_coord_matrix),u_is_text:new o.aH(E,l.u_is_text),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_is_along_line:new o.aH(E,l.u_is_along_line),u_is_variable_anchor:new o.aH(E,l.u_is_variable_anchor),u_texsize:new o.aO(E,l.u_texsize),u_texture:new o.aH(E,l.u_texture),u_gamma_scale:new o.aI(E,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_is_halo:new o.aH(E,l.u_is_halo),u_translation:new o.aO(E,l.u_translation),u_pitched_scale:new o.aI(E,l.u_pitched_scale)}),symbolTextAndIcon:(E,l)=>({u_is_size_zoom_constant:new o.aH(E,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(E,l.u_is_size_feature_constant),u_size_t:new o.aI(E,l.u_size_t),u_size:new o.aI(E,l.u_size),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_pitch:new o.aI(E,l.u_pitch),u_rotate_symbol:new o.aH(E,l.u_rotate_symbol),u_aspect_ratio:new o.aI(E,l.u_aspect_ratio),u_fade_change:new o.aI(E,l.u_fade_change),u_matrix:new o.aJ(E,l.u_matrix),u_label_plane_matrix:new o.aJ(E,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(E,l.u_coord_matrix),u_is_text:new o.aH(E,l.u_is_text),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_is_along_line:new o.aH(E,l.u_is_along_line),u_is_variable_anchor:new o.aH(E,l.u_is_variable_anchor),u_texsize:new o.aO(E,l.u_texsize),u_texsize_icon:new o.aO(E,l.u_texsize_icon),u_texture:new o.aH(E,l.u_texture),u_texture_icon:new o.aH(E,l.u_texture_icon),u_gamma_scale:new o.aI(E,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_is_halo:new o.aH(E,l.u_is_halo),u_translation:new o.aO(E,l.u_translation),u_pitched_scale:new o.aI(E,l.u_pitched_scale)}),background:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_opacity:new o.aI(E,l.u_opacity),u_color:new o.aL(E,l.u_color)}),backgroundPattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_opacity:new o.aI(E,l.u_opacity),u_image:new o.aH(E,l.u_image),u_pattern_tl_a:new o.aO(E,l.u_pattern_tl_a),u_pattern_br_a:new o.aO(E,l.u_pattern_br_a),u_pattern_tl_b:new o.aO(E,l.u_pattern_tl_b),u_pattern_br_b:new o.aO(E,l.u_pattern_br_b),u_texsize:new o.aO(E,l.u_texsize),u_mix:new o.aI(E,l.u_mix),u_pattern_size_a:new o.aO(E,l.u_pattern_size_a),u_pattern_size_b:new o.aO(E,l.u_pattern_size_b),u_scale_a:new o.aI(E,l.u_scale_a),u_scale_b:new o.aI(E,l.u_scale_b),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aI(E,l.u_tile_units_to_pixels)}),terrain:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_texture:new o.aH(E,l.u_texture),u_ele_delta:new o.aI(E,l.u_ele_delta),u_fog_matrix:new o.aJ(E,l.u_fog_matrix),u_fog_color:new o.aL(E,l.u_fog_color),u_fog_ground_blend:new o.aI(E,l.u_fog_ground_blend),u_fog_ground_blend_opacity:new o.aI(E,l.u_fog_ground_blend_opacity),u_horizon_color:new o.aL(E,l.u_horizon_color),u_horizon_fog_blend:new o.aI(E,l.u_horizon_fog_blend)}),terrainDepth:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ele_delta:new o.aI(E,l.u_ele_delta)}),terrainCoords:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_texture:new o.aH(E,l.u_texture),u_terrain_coords_id:new o.aI(E,l.u_terrain_coords_id),u_ele_delta:new o.aI(E,l.u_ele_delta)}),sky:(E,l)=>({u_sky_color:new o.aL(E,l.u_sky_color),u_horizon_color:new o.aL(E,l.u_horizon_color),u_horizon:new o.aI(E,l.u_horizon),u_sky_horizon_blend:new o.aI(E,l.u_sky_horizon_blend)})};class Zs{constructor(l,f,b){this.context=l;const _=l.gl;this.buffer=_.createBuffer(),this.dynamicDraw=!!b,this.context.unbindVAO(),l.bindElementBuffer.set(this.buffer),_.bufferData(_.ELEMENT_ARRAY_BUFFER,f.arrayBuffer,this.dynamicDraw?_.DYNAMIC_DRAW:_.STATIC_DRAW),this.dynamicDraw||delete f.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(l){const f=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),f.bufferSubData(f.ELEMENT_ARRAY_BUFFER,0,l.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Wv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Df{constructor(l,f,b,_){this.length=f.length,this.attributes=b,this.itemSize=f.bytesPerElement,this.dynamicDraw=_,this.context=l;const w=l.gl;this.buffer=w.createBuffer(),l.bindVertexBuffer.set(this.buffer),w.bufferData(w.ARRAY_BUFFER,f.arrayBuffer,this.dynamicDraw?w.DYNAMIC_DRAW:w.STATIC_DRAW),this.dynamicDraw||delete f.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(l){if(l.length!==this.length)throw new Error(`Length of new data is ${l.length}, which doesn't match current length of ${this.length}`);const f=this.context.gl;this.bind(),f.bufferSubData(f.ARRAY_BUFFER,0,l.arrayBuffer)}enableAttributes(l,f){for(let b=0;b<this.attributes.length;b++){const _=f.attributes[this.attributes[b].name];_!==void 0&&l.enableVertexAttribArray(_)}}setVertexAttribPointers(l,f,b){for(let _=0;_<this.attributes.length;_++){const w=this.attributes[_],M=f.attributes[w.name];M!==void 0&&l.vertexAttribPointer(M,w.components,l[Wv[w.type]],!1,this.itemSize,w.offset+this.itemSize*(b||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const va=new WeakMap;function Vo(E){var l;if(va.has(E))return va.get(E);{const f=(l=E.getParameter(E.VERSION))===null||l===void 0?void 0:l.startsWith("WebGL 2.0");return va.set(E,f),f}}class Pn{constructor(l){this.gl=l.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(l){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class gu extends Pn{getDefault(){return o.aM.transparent}set(l){const f=this.current;(l.r!==f.r||l.g!==f.g||l.b!==f.b||l.a!==f.a||this.dirty)&&(this.gl.clearColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class qv extends Pn{getDefault(){return 1}set(l){(l!==this.current||this.dirty)&&(this.gl.clearDepth(l),this.current=l,this.dirty=!1)}}class bl extends Pn{getDefault(){return 0}set(l){(l!==this.current||this.dirty)&&(this.gl.clearStencil(l),this.current=l,this.dirty=!1)}}class Gv extends Pn{getDefault(){return[!0,!0,!0,!0]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||l[2]!==f[2]||l[3]!==f[3]||this.dirty)&&(this.gl.colorMask(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class py extends Pn{getDefault(){return!0}set(l){(l!==this.current||this.dirty)&&(this.gl.depthMask(l),this.current=l,this.dirty=!1)}}class Yv extends Pn{getDefault(){return 255}set(l){(l!==this.current||this.dirty)&&(this.gl.stencilMask(l),this.current=l,this.dirty=!1)}}class my extends Pn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(l){const f=this.current;(l.func!==f.func||l.ref!==f.ref||l.mask!==f.mask||this.dirty)&&(this.gl.stencilFunc(l.func,l.ref,l.mask),this.current=l,this.dirty=!1)}}class If extends Pn{getDefault(){const l=this.gl;return[l.KEEP,l.KEEP,l.KEEP]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||l[2]!==f[2]||this.dirty)&&(this.gl.stencilOp(l[0],l[1],l[2]),this.current=l,this.dirty=!1)}}class gy extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.STENCIL_TEST):f.disable(f.STENCIL_TEST),this.current=l,this.dirty=!1}}class yy extends Pn{getDefault(){return[0,1]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||this.dirty)&&(this.gl.depthRange(l[0],l[1]),this.current=l,this.dirty=!1)}}class by extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),this.current=l,this.dirty=!1}}class _y extends Pn{getDefault(){return this.gl.LESS}set(l){(l!==this.current||this.dirty)&&(this.gl.depthFunc(l),this.current=l,this.dirty=!1)}}class wa extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.BLEND):f.disable(f.BLEND),this.current=l,this.dirty=!1}}class xy extends Pn{getDefault(){const l=this.gl;return[l.ONE,l.ZERO]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||this.dirty)&&(this.gl.blendFunc(l[0],l[1]),this.current=l,this.dirty=!1)}}class Zv extends Pn{getDefault(){return o.aM.transparent}set(l){const f=this.current;(l.r!==f.r||l.g!==f.g||l.b!==f.b||l.a!==f.a||this.dirty)&&(this.gl.blendColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class vy extends Pn{getDefault(){return this.gl.FUNC_ADD}set(l){(l!==this.current||this.dirty)&&(this.gl.blendEquation(l),this.current=l,this.dirty=!1)}}class Oc extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.CULL_FACE):f.disable(f.CULL_FACE),this.current=l,this.dirty=!1}}class Xv extends Pn{getDefault(){return this.gl.BACK}set(l){(l!==this.current||this.dirty)&&(this.gl.cullFace(l),this.current=l,this.dirty=!1)}}class yu extends Pn{getDefault(){return this.gl.CCW}set(l){(l!==this.current||this.dirty)&&(this.gl.frontFace(l),this.current=l,this.dirty=!1)}}class Kv extends Pn{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}}class Jv extends Pn{getDefault(){return this.gl.TEXTURE0}set(l){(l!==this.current||this.dirty)&&(this.gl.activeTexture(l),this.current=l,this.dirty=!1)}}class wy extends Pn{getDefault(){const l=this.gl;return[0,0,l.drawingBufferWidth,l.drawingBufferHeight]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||l[2]!==f[2]||l[3]!==f[3]||this.dirty)&&(this.gl.viewport(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class ky extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindFramebuffer(f.FRAMEBUFFER,l),this.current=l,this.dirty=!1}}class Ey extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindRenderbuffer(f.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Pf extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindTexture(f.TEXTURE_2D,l),this.current=l,this.dirty=!1}}class Sy extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindBuffer(f.ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class bu extends Pn{getDefault(){return null}set(l){const f=this.gl;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class ho extends Pn{getDefault(){return null}set(l){var f;if(l===this.current&&!this.dirty)return;const b=this.gl;Vo(b)?b.bindVertexArray(l):(f=b.getExtension("OES_vertex_array_object"))===null||f===void 0||f.bindVertexArrayOES(l),this.current=l,this.dirty=!1}}class Nf extends Pn{getDefault(){return 4}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.pixelStorei(f.UNPACK_ALIGNMENT,l),this.current=l,this.dirty=!1}}class Rf extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),this.current=l,this.dirty=!1}}class Of extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,l),this.current=l,this.dirty=!1}}class _u extends Pn{constructor(l,f){super(l),this.context=l,this.parent=f}getDefault(){return null}}class Bf extends _u{setDirty(){this.dirty=!0}set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const f=this.gl;f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l,0),this.current=l,this.dirty=!1}}class ka extends _u{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const f=this.gl;f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Vf extends _u{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const f=this.gl;f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Qv{constructor(l,f,b,_,w){this.context=l,this.width=f,this.height=b;const M=l.gl,P=this.framebuffer=M.createFramebuffer();if(this.colorAttachment=new Bf(l,P),_)this.depthAttachment=w?new Vf(l,P):new ka(l,P);else if(w)throw new Error("Stencil cannot be set without depth");if(M.checkFramebufferStatus(M.FRAMEBUFFER)!==M.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const l=this.context.gl,f=this.colorAttachment.get();if(f&&l.deleteTexture(f),this.depthAttachment){const b=this.depthAttachment.get();b&&l.deleteRenderbuffer(b)}l.deleteFramebuffer(this.framebuffer)}}class pr{constructor(l,f,b){this.blendFunction=l,this.blendColor=f,this.mask=b}}pr.Replace=[1,0],pr.disabled=new pr(pr.Replace,o.aM.transparent,[!1,!1,!1,!1]),pr.unblended=new pr(pr.Replace,o.aM.transparent,[!0,!0,!0,!0]),pr.alphaBlended=new pr([1,771],o.aM.transparent,[!0,!0,!0,!0]);class e1{constructor(l){var f,b;if(this.gl=l,this.clearColor=new gu(this),this.clearDepth=new qv(this),this.clearStencil=new bl(this),this.colorMask=new Gv(this),this.depthMask=new py(this),this.stencilMask=new Yv(this),this.stencilFunc=new my(this),this.stencilOp=new If(this),this.stencilTest=new gy(this),this.depthRange=new yy(this),this.depthTest=new by(this),this.depthFunc=new _y(this),this.blend=new wa(this),this.blendFunc=new xy(this),this.blendColor=new Zv(this),this.blendEquation=new vy(this),this.cullFace=new Oc(this),this.cullFaceSide=new Xv(this),this.frontFace=new yu(this),this.program=new Kv(this),this.activeTexture=new Jv(this),this.viewport=new wy(this),this.bindFramebuffer=new ky(this),this.bindRenderbuffer=new Ey(this),this.bindTexture=new Pf(this),this.bindVertexBuffer=new Sy(this),this.bindElementBuffer=new bu(this),this.bindVertexArray=new ho(this),this.pixelStoreUnpack=new Nf(this),this.pixelStoreUnpackPremultiplyAlpha=new Rf(this),this.pixelStoreUnpackFlipY=new Of(this),this.extTextureFilterAnisotropic=l.getExtension("EXT_texture_filter_anisotropic")||l.getExtension("MOZ_EXT_texture_filter_anisotropic")||l.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=l.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=l.getParameter(l.MAX_TEXTURE_SIZE),Vo(l)){this.HALF_FLOAT=l.HALF_FLOAT;const _=l.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(f=l.RGBA16F)!==null&&f!==void 0?f:_==null?void 0:_.RGBA16F_EXT,this.RGB16F=(b=l.RGB16F)!==null&&b!==void 0?b:_==null?void 0:_.RGB16F_EXT,l.getExtension("EXT_color_buffer_float")}else{l.getExtension("EXT_color_buffer_half_float"),l.getExtension("OES_texture_half_float_linear");const _=l.getExtension("OES_texture_half_float");this.HALF_FLOAT=_==null?void 0:_.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(l,f){return new Zs(this,l,f)}createVertexBuffer(l,f,b){return new Df(this,l,f,b)}createRenderbuffer(l,f,b){const _=this.gl,w=_.createRenderbuffer();return this.bindRenderbuffer.set(w),_.renderbufferStorage(_.RENDERBUFFER,l,f,b),this.bindRenderbuffer.set(null),w}createFramebuffer(l,f,b,_){return new Qv(this,l,f,b,_)}clear({color:l,depth:f,stencil:b}){const _=this.gl;let w=0;l&&(w|=_.COLOR_BUFFER_BIT,this.clearColor.set(l),this.colorMask.set([!0,!0,!0,!0])),f!==void 0&&(w|=_.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(f),this.depthMask.set(!0)),b!==void 0&&(w|=_.STENCIL_BUFFER_BIT,this.clearStencil.set(b),this.stencilMask.set(255)),_.clear(w)}setCullFace(l){l.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(l.mode),this.frontFace.set(l.frontFace))}setDepthMode(l){l.func!==this.gl.ALWAYS||l.mask?(this.depthTest.set(!0),this.depthFunc.set(l.func),this.depthMask.set(l.mask),this.depthRange.set(l.range)):this.depthTest.set(!1)}setStencilMode(l){l.test.func!==this.gl.ALWAYS||l.mask?(this.stencilTest.set(!0),this.stencilMask.set(l.mask),this.stencilOp.set([l.fail,l.depthFail,l.pass]),this.stencilFunc.set({func:l.test.func,ref:l.ref,mask:l.test.mask})):this.stencilTest.set(!1)}setColorMode(l){o.aE(l.blendFunction,pr.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(l.blendFunction),this.blendColor.set(l.blendColor)),this.colorMask.set(l.mask)}createVertexArray(){var l;return Vo(this.gl)?this.gl.createVertexArray():(l=this.gl.getExtension("OES_vertex_array_object"))===null||l===void 0?void 0:l.createVertexArrayOES()}deleteVertexArray(l){var f;return Vo(this.gl)?this.gl.deleteVertexArray(l):(f=this.gl.getExtension("OES_vertex_array_object"))===null||f===void 0?void 0:f.deleteVertexArrayOES(l)}unbindVAO(){this.bindVertexArray.set(null)}}class rn{constructor(l,f,b){this.func=l,this.mask=f,this.range=b}}rn.ReadOnly=!1,rn.ReadWrite=!0,rn.disabled=new rn(519,rn.ReadOnly,[0,1]);const xu=7680;class qn{constructor(l,f,b,_,w,M){this.test=l,this.ref=f,this.mask=b,this.fail=_,this.depthFail=w,this.pass=M}}qn.disabled=new qn({func:519,mask:0},0,0,xu,xu,xu);class Fn{constructor(l,f,b){this.enable=l,this.mode=f,this.frontFace=b}}let Ea;function Bc(E,l,f,b,_){const w=E.context,M=w.gl,P=E.useProgram("collisionBox"),R=[];let z=0,$=0;for(let de=0;de<b.length;de++){const pe=b[de],ie=l.getTile(pe).getBucket(f);if(!ie)continue;const _e=_?ie.textCollisionBox:ie.iconCollisionBox,ve=ie.collisionCircleArray;if(ve.length>0){const Ce=o.H();o.aQ(Ce,ie.placementInvProjMatrix,E.transform.glCoordMatrix),o.aQ(Ce,Ce,ie.placementViewportMatrix),R.push({circleArray:ve,circleOffset:$,transform:pe.posMatrix,invTransform:Ce,coord:pe}),z+=ve.length/4,$=z}_e&&P.draw(w,M.LINES,rn.disabled,qn.disabled,E.colorModeForRenderPass(),Fn.disabled,{u_matrix:pe.posMatrix,u_pixel_extrude_scale:[1/(j=E.transform).width,1/j.height]},E.style.map.terrain&&E.style.map.terrain.getTerrainData(pe),f.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,null,E.transform.zoom,null,null,_e.collisionVertexBuffer)}var j;if(!_||!R.length)return;const X=E.useProgram("collisionCircle"),ee=new o.aR;ee.resize(4*z),ee._trim();let te=0;for(const de of R)for(let pe=0;pe<de.circleArray.length/4;pe++){const ie=4*pe,_e=de.circleArray[ie+0],ve=de.circleArray[ie+1],Ce=de.circleArray[ie+2],ze=de.circleArray[ie+3];ee.emplace(te++,_e,ve,Ce,ze,0),ee.emplace(te++,_e,ve,Ce,ze,1),ee.emplace(te++,_e,ve,Ce,ze,2),ee.emplace(te++,_e,ve,Ce,ze,3)}(!Ea||Ea.length<2*z)&&(Ea=function(de){const pe=2*de,ie=new o.aT;ie.resize(pe),ie._trim();for(let _e=0;_e<pe;_e++){const ve=6*_e;ie.uint16[ve+0]=4*_e+0,ie.uint16[ve+1]=4*_e+1,ie.uint16[ve+2]=4*_e+2,ie.uint16[ve+3]=4*_e+2,ie.uint16[ve+4]=4*_e+3,ie.uint16[ve+5]=4*_e+0}return ie}(z));const se=w.createIndexBuffer(Ea,!0),le=w.createVertexBuffer(ee,o.aS.members,!0);for(const de of R){const pe=xa(de.transform,de.invTransform,E.transform);X.draw(w,M.TRIANGLES,rn.disabled,qn.disabled,E.colorModeForRenderPass(),Fn.disabled,pe,E.style.map.terrain&&E.style.map.terrain.getTerrainData(de.coord),f.id,le,se,o.a0.simpleSegment(0,2*de.circleOffset,de.circleArray.length,de.circleArray.length/2),null,E.transform.zoom,null,null,null)}le.destroy(),se.destroy()}Fn.disabled=new Fn(!1,1029,2305),Fn.backCCW=new Fn(!0,1029,2305);const Vc=o.an(new Float32Array(16));function zf(E,l,f,b,_,w){const{horizontalAlign:M,verticalAlign:P}=o.au(E);return new o.P((-(M-.5)*l/_+b[0])*w,(-(P-.5)*f/_+b[1])*w)}function Sa(E,l,f,b,_,w){const M=l.tileAnchorPoint.add(new o.P(l.translation[0],l.translation[1]));if(l.pitchWithMap){let P=b.mult(w);f||(P=P.rotate(-_));const R=M.add(P);return oe(R.x,R.y,l.labelPlaneMatrix,l.getElevation).point}if(f){const P=Ne(l.tileAnchorPoint.x+1,l.tileAnchorPoint.y,l).point.sub(E),R=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return E.add(b.rotate(R))}return E.add(b)}function _l(E,l,f,b,_,w,M,P,R,z,$,j,X,ee){const te=E.text.placedSymbolArray,se=E.text.dynamicLayoutVertexArray,le=E.icon.dynamicLayoutVertexArray,de={};se.clear();for(let pe=0;pe<te.length;pe++){const ie=te.get(pe),_e=ie.hidden||!ie.crossTileID||E.allowVerticalPlacement&&!ie.placedOrientation?null:b[ie.crossTileID];if(_e){const ve=new o.P(ie.anchorX,ie.anchorY),Ce={getElevation:ee,width:_.width,height:_.height,labelPlaneMatrix:w,pitchWithMap:f,projection:$,tileAnchorPoint:ve,translation:j,unwrappedTileID:X},ze=f?oe(ve.x,ve.y,M,ee):Ne(ve.x,ve.y,Ce),Ze=q(_.cameraToCenterDistance,ze.signedDistanceFromCamera);let ot=o.ai(E.textSizeData,R,ie)*Ze/o.ap;f&&(ot*=E.tilePixelRatio/P);const{width:ut,height:rt,anchor:nt,textOffset:vt,textBoxScale:Ht}=_e,it=zf(nt,ut,rt,vt,Ht,ot),lt=$.getPitchedTextCorrection(_,ve.add(new o.P(j[0],j[1])),X),Ft=Sa(ze.point,Ce,l,it,_.angle,lt),Xn=E.allowVerticalPlacement&&ie.placedOrientation===o.ah.vertical?Math.PI/2:0;for(let Jt=0;Jt<ie.numGlyphs;Jt++)o.aj(se,Ft,Xn);z&&ie.associatedIconIndex>=0&&(de[ie.associatedIconIndex]={shiftedAnchor:Ft,angle:Xn})}else Pt(ie.numGlyphs,se)}if(z){le.clear();const pe=E.icon.placedSymbolArray;for(let ie=0;ie<pe.length;ie++){const _e=pe.get(ie);if(_e.hidden)Pt(_e.numGlyphs,le);else{const ve=de[ie];if(ve)for(let Ce=0;Ce<_e.numGlyphs;Ce++)o.aj(le,ve.shiftedAnchor,ve.angle);else Pt(_e.numGlyphs,le)}}E.icon.dynamicLayoutVertexBuffer.updateData(le)}E.text.dynamicLayoutVertexBuffer.updateData(se)}function rs(E,l,f){return f.iconsInText&&l?"symbolTextAndIcon":E?"symbolSDF":"symbolIcon"}function Lf(E,l,f,b,_,w,M,P,R,z,$,j){const X=E.context,ee=X.gl,te=E.transform,se=ba(),le=P==="map",de=R==="map",pe=P!=="viewport"&&f.layout.get("symbol-placement")!=="point",ie=le&&!de&&!pe,_e=!de&&pe,ve=!f.layout.get("symbol-sort-key").isConstant();let Ce=!1;const ze=E.depthModeForSublayer(0,rn.ReadOnly),Ze=f._unevaluatedLayout.hasValue("text-variable-anchor")||f._unevaluatedLayout.hasValue("text-variable-anchor-offset"),ot=[],ut=se.getCircleRadiusCorrection(te);for(const rt of b){const nt=l.getTile(rt),vt=nt.getBucket(f);if(!vt)continue;const Ht=_?vt.text:vt.icon;if(!Ht||!Ht.segments.get().length||!Ht.hasVisibleVertices)continue;const it=Ht.programConfigurations.get(f.id),lt=_||vt.sdfIcons,Ft=_?vt.textSizeData:vt.iconSizeData,Xn=de||te.pitch!==0,Jt=E.useProgram(rs(lt,_,vt),it),dn=o.ag(Ft,te.zoom),Kn=E.style.map.terrain&&E.style.map.terrain.getTerrainData(rt);let Kr,Ts,Jn,Ci,hi=[0,0],Jr=null;if(_)Ts=nt.glyphAtlasTexture,Jn=ee.LINEAR,Kr=nt.glyphAtlasTexture.size,vt.iconsInText&&(hi=nt.imageAtlasTexture.size,Jr=nt.imageAtlasTexture,Ci=Xn||E.options.rotating||E.options.zooming||Ft.kind==="composite"||Ft.kind==="camera"?ee.LINEAR:ee.NEAREST);else{const fn=f.layout.get("icon-size").constantOr(0)!==1||vt.iconsNeedLinear;Ts=nt.imageAtlasTexture,Jn=lt||E.options.rotating||E.options.zooming||fn||Xn?ee.LINEAR:ee.NEAREST,Kr=nt.imageAtlasTexture.size}const fi=cn(nt,1,E.transform.zoom),Js=_e?rt.posMatrix:Vc,Rl=di(Js,de,le,E.transform,fi),Lu=zi(Js,de,le,E.transform,fi),Ol=zi(rt.posMatrix,de,le,E.transform,fi),as=se.translatePosition(E.transform,nt,w,M),Fu=Ze&&vt.hasTextData(),dp=f.layout.get("icon-text-fit")!=="none"&&Fu&&vt.hasIconData();if(pe){const fn=E.style.map.terrain?(Bl,Vl)=>E.style.map.terrain.getElevation(rt,Bl,Vl):null,Da=f.layout.get("text-rotation-alignment")==="map";J(vt,rt.posMatrix,E,_,Rl,Ol,de,z,Da,se,rt.toUnwrapped(),te.width,te.height,as,fn)}const ls=rt.posMatrix,cs=_&&Ze||dp,zo=pe||cs?Vc:Rl,As=Lu,Lr=lt&&f.paint.get(_?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Qr;Qr=lt?vt.iconsInText?Tf(Ft.kind,dn,ie,de,pe,cs,E,ls,zo,As,as,Kr,hi,ut):Rc(Ft.kind,dn,ie,de,pe,cs,E,ls,zo,As,as,_,Kr,!0,ut):fy(Ft.kind,dn,ie,de,pe,cs,E,ls,zo,As,as,_,Kr,ut);const Ui={program:Jt,buffers:Ht,uniformValues:Qr,atlasTexture:Ts,atlasTextureIcon:Jr,atlasInterpolation:Jn,atlasInterpolationIcon:Ci,isSDF:lt,hasHalo:Lr};if(ve&&vt.canOverlap){Ce=!0;const fn=Ht.segments.get();for(const Da of fn)ot.push({segments:new o.a0([Da]),sortKey:Da.sortKey,state:Ui,terrainData:Kn})}else ot.push({segments:Ht.segments,sortKey:0,state:Ui,terrainData:Kn})}Ce&&ot.sort((rt,nt)=>rt.sortKey-nt.sortKey);for(const rt of ot){const nt=rt.state;if(X.activeTexture.set(ee.TEXTURE0),nt.atlasTexture.bind(nt.atlasInterpolation,ee.CLAMP_TO_EDGE),nt.atlasTextureIcon&&(X.activeTexture.set(ee.TEXTURE1),nt.atlasTextureIcon&&nt.atlasTextureIcon.bind(nt.atlasInterpolationIcon,ee.CLAMP_TO_EDGE)),nt.isSDF){const vt=nt.uniformValues;nt.hasHalo&&(vt.u_is_halo=1,Ff(nt.buffers,rt.segments,f,E,nt.program,ze,$,j,vt,rt.terrainData)),vt.u_is_halo=0}Ff(nt.buffers,rt.segments,f,E,nt.program,ze,$,j,nt.uniformValues,rt.terrainData)}}function Ff(E,l,f,b,_,w,M,P,R,z){const $=b.context;_.draw($,$.gl.TRIANGLES,w,M,P,Fn.disabled,R,z,f.id,E.layoutVertexBuffer,E.indexBuffer,l,f.paint,b.transform.zoom,E.programConfigurations.get(f.id),E.dynamicLayoutVertexBuffer,E.opacityVertexBuffer)}function $f(E,l,f,b){const _=E.context,w=_.gl,M=qn.disabled,P=new pr([w.ONE,w.ONE],o.aM.transparent,[!0,!0,!0,!0]),R=l.getBucket(f);if(!R)return;const z=b.key;let $=f.heatmapFbos.get(z);$||($=zc(_,l.tileSize,l.tileSize),f.heatmapFbos.set(z,$)),_.bindFramebuffer.set($.framebuffer),_.viewport.set([0,0,l.tileSize,l.tileSize]),_.clear({color:o.aM.transparent});const j=R.programConfigurations.get(f.id),X=E.useProgram("heatmap",j),ee=E.style.map.terrain.getTerrainData(b);X.draw(_,w.TRIANGLES,rn.disabled,M,P,Fn.disabled,Si(b.posMatrix,l,E.transform.zoom,f.paint.get("heatmap-intensity")),ee,f.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,f.paint,E.transform.zoom,j)}function Ca(E,l,f){const b=E.context,_=b.gl;b.setColorMode(E.colorModeForRenderPass());const w=Lc(b,l),M=f.key,P=l.heatmapFbos.get(M);P&&(b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,P.colorAttachment.get()),b.activeTexture.set(_.TEXTURE1),w.bind(_.LINEAR,_.CLAMP_TO_EDGE),E.useProgram("heatmapTexture").draw(b,_.TRIANGLES,rn.disabled,qn.disabled,E.colorModeForRenderPass(),Fn.disabled,hu(E,l,0,1),null,l.id,E.rasterBoundsBuffer,E.quadTriangleIndexBuffer,E.rasterBoundsSegments,l.paint,E.transform.zoom),P.destroy(),l.heatmapFbos.delete(M))}function zc(E,l,f){var b,_;const w=E.gl,M=w.createTexture();w.bindTexture(w.TEXTURE_2D,M),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_S,w.CLAMP_TO_EDGE),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_T,w.CLAMP_TO_EDGE),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MIN_FILTER,w.LINEAR),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MAG_FILTER,w.LINEAR);const P=(b=E.HALF_FLOAT)!==null&&b!==void 0?b:w.UNSIGNED_BYTE,R=(_=E.RGBA16F)!==null&&_!==void 0?_:w.RGBA;w.texImage2D(w.TEXTURE_2D,0,R,l,f,0,w.RGBA,P,null);const z=E.createFramebuffer(l,f,!1,!1);return z.colorAttachment.set(M),z}function Lc(E,l){return l.colorRampTexture||(l.colorRampTexture=new Le(E,l.colorRamp,E.gl.RGBA)),l.colorRampTexture}function xl(E,l,f,b,_){if(!f||!b||!b.imageAtlas)return;const w=b.imageAtlas.patternPositions;let M=w[f.to.toString()],P=w[f.from.toString()];if(!M&&P&&(M=P),!P&&M&&(P=M),!M||!P){const R=_.getPaintProperty(l);M=w[R],P=w[R]}M&&P&&E.setConstantPatternPositions(M,P)}function Fc(E,l,f,b,_,w,M){const P=E.context.gl,R="fill-pattern",z=f.paint.get(R),$=z&&z.constantOr(1),j=f.getCrossfadeParameters();let X,ee,te,se,le;M?(ee=$&&!f.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",X=P.LINES):(ee=$?"fillPattern":"fill",X=P.TRIANGLES);const de=z.constantOr(null);for(const pe of b){const ie=l.getTile(pe);if($&&!ie.patternsLoaded())continue;const _e=ie.getBucket(f);if(!_e)continue;const ve=_e.programConfigurations.get(f.id),Ce=E.useProgram(ee,ve),ze=E.style.map.terrain&&E.style.map.terrain.getTerrainData(pe);$&&(E.context.activeTexture.set(P.TEXTURE0),ie.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ve.updatePaintBuffers(j)),xl(ve,R,de,ie,f);const Ze=ze?pe:null,ot=E.translatePosMatrix(Ze?Ze.posMatrix:pe.posMatrix,ie,f.paint.get("fill-translate"),f.paint.get("fill-translate-anchor"));if(M){se=_e.indexBuffer2,le=_e.segments2;const ut=[P.drawingBufferWidth,P.drawingBufferHeight];te=ee==="fillOutlinePattern"&&$?cy(ot,E,j,ie,ut):Fv(ot,ut)}else se=_e.indexBuffer,le=_e.segments,te=$?ly(ot,E,j,ie):gl(ot);Ce.draw(E.context,X,_,E.stencilModeForClipping(pe),w,Fn.disabled,te,ze,f.id,_e.layoutVertexBuffer,se,le,f.paint,E.transform.zoom,ve)}}function vu(E,l,f,b,_,w,M){const P=E.context,R=P.gl,z="fill-extrusion-pattern",$=f.paint.get(z),j=$.constantOr(1),X=f.getCrossfadeParameters(),ee=f.paint.get("fill-extrusion-opacity"),te=$.constantOr(null);for(const se of b){const le=l.getTile(se),de=le.getBucket(f);if(!de)continue;const pe=E.style.map.terrain&&E.style.map.terrain.getTerrainData(se),ie=de.programConfigurations.get(f.id),_e=E.useProgram(j?"fillExtrusionPattern":"fillExtrusion",ie);j&&(E.context.activeTexture.set(R.TEXTURE0),le.imageAtlasTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),ie.updatePaintBuffers(X)),xl(ie,z,te,le,f);const ve=E.translatePosMatrix(se.posMatrix,le,f.paint.get("fill-extrusion-translate"),f.paint.get("fill-extrusion-translate-anchor")),Ce=f.paint.get("fill-extrusion-vertical-gradient"),ze=j?uu(ve,E,Ce,ee,se,X,le):Pc(ve,E,Ce,ee);_e.draw(P,P.gl.TRIANGLES,_,w,M,Fn.backCCW,ze,pe,f.id,de.layoutVertexBuffer,de.indexBuffer,de.segments,f.paint,E.transform.zoom,ie,E.style.map.terrain&&de.centroidVertexBuffer)}}function vl(E,l,f,b,_,w,M){const P=E.context,R=P.gl,z=f.fbo;if(!z)return;const $=E.useProgram("hillshade"),j=E.style.map.terrain&&E.style.map.terrain.getTerrainData(l);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,z.colorAttachment.get()),$.draw(P,R.TRIANGLES,_,w,M,Fn.disabled,((X,ee,te,se)=>{const le=te.paint.get("hillshade-shadow-color"),de=te.paint.get("hillshade-highlight-color"),pe=te.paint.get("hillshade-accent-color");let ie=te.paint.get("hillshade-illumination-direction")*(Math.PI/180);te.paint.get("hillshade-illumination-anchor")==="viewport"&&(ie-=X.transform.angle);const _e=!X.options.moving;return{u_matrix:se?se.posMatrix:X.transform.calculatePosMatrix(ee.tileID.toUnwrapped(),_e),u_image:0,u_latrange:fu(0,ee.tileID),u_light:[te.paint.get("hillshade-exaggeration"),ie],u_shadow:le,u_highlight:de,u_accent:pe}})(E,f,b,j?l:null),j,b.id,E.rasterBoundsBuffer,E.quadTriangleIndexBuffer,E.rasterBoundsSegments)}function wl(E,l,f,b,_,w){const M=E.context,P=M.gl,R=l.dem;if(R&&R.data){const z=R.dim,$=R.stride,j=R.getPixels();if(M.activeTexture.set(P.TEXTURE1),M.pixelStoreUnpackPremultiplyAlpha.set(!1),l.demTexture=l.demTexture||E.getTileTexture($),l.demTexture){const ee=l.demTexture;ee.update(j,{premultiply:!1}),ee.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else l.demTexture=new Le(M,j,P.RGBA,{premultiply:!1}),l.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);M.activeTexture.set(P.TEXTURE0);let X=l.fbo;if(!X){const ee=new Le(M,{width:z,height:z,data:null},P.RGBA);ee.bind(P.LINEAR,P.CLAMP_TO_EDGE),X=l.fbo=M.createFramebuffer(z,z,!0,!1),X.colorAttachment.set(ee.texture)}M.bindFramebuffer.set(X.framebuffer),M.viewport.set([0,0,z,z]),E.useProgram("hillshadePrepare").draw(M,P.TRIANGLES,b,_,w,Fn.disabled,((ee,te)=>{const se=te.stride,le=o.H();return o.aP(le,0,o.X,-o.X,0,0,1),o.J(le,le,[0,-o.X,0]),{u_matrix:le,u_image:1,u_dimension:[se,se],u_zoom:ee.overscaledZ,u_unpack:te.getUnpackVector()}})(l.tileID,R),null,f.id,E.rasterBoundsBuffer,E.quadTriangleIndexBuffer,E.rasterBoundsSegments),l.needsHillshadePrepare=!1}}function Cy(E,l,f,b,_,w){const M=b.paint.get("raster-fade-duration");if(!w&&M>0){const P=v.now(),R=(P-E.timeAdded)/M,z=l?(P-l.timeAdded)/M:-1,$=f.getSource(),j=_.coveringZoomLevel({tileSize:$.tileSize,roundZoom:$.roundZoom}),X=!l||Math.abs(l.tileID.overscaledZ-j)>Math.abs(E.tileID.overscaledZ-j),ee=X&&E.refreshedUponExpiration?1:o.ac(X?R:1-z,0,1);return E.refreshedUponExpiration&&R>=1&&(E.refreshedUponExpiration=!1),l?{opacity:1,mix:1-ee}:{opacity:ee,mix:0}}return{opacity:1,mix:0}}const jf=new o.aM(1,0,0,1),Sn=new o.aM(0,1,0,1),wu=new o.aM(0,0,1,1),t1=new o.aM(1,0,1,1),Ty=new o.aM(0,1,1,1);function kl(E,l,f,b){ku(E,0,l+f/2,E.transform.width,f,b)}function Ay(E,l,f,b){ku(E,l-f/2,0,f,E.transform.height,b)}function ku(E,l,f,b,_,w){const M=E.context,P=M.gl;P.enable(P.SCISSOR_TEST),P.scissor(l*E.pixelRatio,f*E.pixelRatio,b*E.pixelRatio,_*E.pixelRatio),M.clear({color:w}),P.disable(P.SCISSOR_TEST)}function My(E,l,f){const b=E.context,_=b.gl,w=f.posMatrix,M=E.useProgram("debug"),P=rn.disabled,R=qn.disabled,z=E.colorModeForRenderPass(),$="$debug",j=E.style.map.terrain&&E.style.map.terrain.getTerrainData(f);b.activeTexture.set(_.TEXTURE0);const X=l.getTileByID(f.key).latestRawTileData,ee=Math.floor((X&&X.byteLength||0)/1024),te=l.getTile(f).tileSize,se=512/Math.min(te,512)*(f.overscaledZ/E.transform.zoom)*.5;let le=f.canonical.toString();f.overscaledZ!==f.canonical.z&&(le+=` => ${f.overscaledZ}`),function(de,pe){de.initDebugOverlayCanvas();const ie=de.debugOverlayCanvas,_e=de.context.gl,ve=de.debugOverlayCanvas.getContext("2d");ve.clearRect(0,0,ie.width,ie.height),ve.shadowColor="white",ve.shadowBlur=2,ve.lineWidth=1.5,ve.strokeStyle="white",ve.textBaseline="top",ve.font="bold 36px Open Sans, sans-serif",ve.fillText(pe,5,5),ve.strokeText(pe,5,5),de.debugOverlayTexture.update(ie),de.debugOverlayTexture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE)}(E,`${le} ${ee}kB`),M.draw(b,_.TRIANGLES,P,R,pr.alphaBlended,Fn.disabled,Nc(w,o.aM.transparent,se),null,$,E.debugBuffer,E.quadTriangleIndexBuffer,E.debugSegments),M.draw(b,_.LINE_STRIP,P,R,z,Fn.disabled,Nc(w,o.aM.red),j,$,E.debugBuffer,E.tileBorderIndexBuffer,E.debugSegments)}function Dy(E,l,f){const b=E.context,_=b.gl,w=E.colorModeForRenderPass(),M=new rn(_.LEQUAL,rn.ReadWrite,E.depthRangeFor3D),P=E.useProgram("terrain"),R=l.getTerrainMesh();b.bindFramebuffer.set(null),b.viewport.set([0,0,E.width,E.height]);for(const z of f){const $=E.renderToTexture.getTexture(z),j=l.getTerrainData(z.tileID);b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,$.texture);const X=E.transform.calculatePosMatrix(z.tileID.toUnwrapped()),ee=l.getMeshFrameDelta(E.transform.zoom),te=E.transform.calculateFogMatrix(z.tileID.toUnwrapped()),se=Sf(X,ee,te,E.style.sky,E.transform.pitch);P.draw(b,_.TRIANGLES,M,qn.disabled,w,Fn.backCCW,se,j,"terrain",R.vertexBuffer,R.indexBuffer,R.segments)}}class Eu{constructor(l,f,b){this.vertexBuffer=l,this.indexBuffer=f,this.segments=b}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class Su{constructor(l,f){this.context=new e1(l),this.transform=f,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$e.maxUnderzooming+$e.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new kf}resize(l,f,b){if(this.width=Math.floor(l*b),this.height=Math.floor(f*b),this.pixelRatio=b,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const _ of this.style._order)this.style._layers[_].resize()}setup(){const l=this.context,f=new o.aX;f.emplaceBack(0,0),f.emplaceBack(o.X,0),f.emplaceBack(0,o.X),f.emplaceBack(o.X,o.X),this.tileExtentBuffer=l.createVertexBuffer(f,_a.members),this.tileExtentSegments=o.a0.simpleSegment(0,0,4,2);const b=new o.aX;b.emplaceBack(0,0),b.emplaceBack(o.X,0),b.emplaceBack(0,o.X),b.emplaceBack(o.X,o.X),this.debugBuffer=l.createVertexBuffer(b,_a.members),this.debugSegments=o.a0.simpleSegment(0,0,4,5);const _=new o.$;_.emplaceBack(0,0,0,0),_.emplaceBack(o.X,0,o.X,0),_.emplaceBack(0,o.X,0,o.X),_.emplaceBack(o.X,o.X,o.X,o.X),this.rasterBoundsBuffer=l.createVertexBuffer(_,dt.members),this.rasterBoundsSegments=o.a0.simpleSegment(0,0,4,2);const w=new o.aX;w.emplaceBack(0,0),w.emplaceBack(1,0),w.emplaceBack(0,1),w.emplaceBack(1,1),this.viewportBuffer=l.createVertexBuffer(w,_a.members),this.viewportSegments=o.a0.simpleSegment(0,0,4,2);const M=new o.aZ;M.emplaceBack(0),M.emplaceBack(1),M.emplaceBack(3),M.emplaceBack(2),M.emplaceBack(0),this.tileBorderIndexBuffer=l.createIndexBuffer(M);const P=new o.aY;P.emplaceBack(0,1,2),P.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=l.createIndexBuffer(P);const R=this.context.gl;this.stencilClearMode=new qn({func:R.ALWAYS,mask:0},0,255,R.ZERO,R.ZERO,R.ZERO)}clearStencil(){const l=this.context,f=l.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const b=o.H();o.aP(b,0,this.width,this.height,0,0,1),o.K(b,b,[f.drawingBufferWidth,f.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(l,f.TRIANGLES,rn.disabled,this.stencilClearMode,pr.disabled,Fn.disabled,Ei(b),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(l,f){if(this.currentStencilSource===l.source||!l.isTileClipped()||!f||!f.length)return;this.currentStencilSource=l.source;const b=this.context,_=b.gl;this.nextStencilID+f.length>256&&this.clearStencil(),b.setColorMode(pr.disabled),b.setDepthMode(rn.disabled);const w=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of f){const P=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,R=this.style.map.terrain&&this.style.map.terrain.getTerrainData(M);w.draw(b,_.TRIANGLES,rn.disabled,new qn({func:_.ALWAYS,mask:0},P,255,_.KEEP,_.KEEP,_.REPLACE),pr.disabled,Fn.disabled,Ei(M.posMatrix),R,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const l=this.nextStencilID++,f=this.context.gl;return new qn({func:f.NOTEQUAL,mask:255},l,255,f.KEEP,f.KEEP,f.REPLACE)}stencilModeForClipping(l){const f=this.context.gl;return new qn({func:f.EQUAL,mask:255},this._tileClippingMaskIDs[l.key],0,f.KEEP,f.KEEP,f.REPLACE)}stencilConfigForOverlap(l){const f=this.context.gl,b=l.sort((M,P)=>P.overscaledZ-M.overscaledZ),_=b[b.length-1].overscaledZ,w=b[0].overscaledZ-_+1;if(w>1){this.currentStencilSource=void 0,this.nextStencilID+w>256&&this.clearStencil();const M={};for(let P=0;P<w;P++)M[P+_]=new qn({func:f.GEQUAL,mask:255},P+this.nextStencilID,255,f.KEEP,f.KEEP,f.REPLACE);return this.nextStencilID+=w,[M,b]}return[{[_]:qn.disabled},b]}colorModeForRenderPass(){const l=this.context.gl;return this._showOverdrawInspector?new pr([l.CONSTANT_COLOR,l.ONE],new o.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?pr.unblended:pr.alphaBlended}depthModeForSublayer(l,f,b){if(!this.opaquePassEnabledForLayer())return rn.disabled;const _=1-((1+this.currentLayer)*this.numSublayers+l)*this.depthEpsilon;return new rn(b||this.context.gl.LEQUAL,f,[_,_])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(l,f){this.style=l,this.options=f,this.lineAtlas=l.lineAtlas,this.imageManager=l.imageManager,this.glyphManager=l.glyphManager,this.symbolFadeChange=l.placement.symbolFadeChange(v.now()),this.imageManager.beginFrame();const b=this.style._order,_=this.style.sourceCaches,w={},M={},P={};for(const R in _){const z=_[R];z.used&&z.prepare(this.context),w[R]=z.getVisibleCoordinates(),M[R]=w[R].slice().reverse(),P[R]=z.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let R=0;R<b.length;R++)if(this.style._layers[b[R]].is3D()){this.opaquePassCutoff=R;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const R of b){const z=this.style._layers[R];if(!z.hasOffscreenPass()||z.isHidden(this.transform.zoom))continue;const $=M[z.source];(z.type==="custom"||$.length)&&this.renderLayer(this,_[z.source],z,$)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:f.showOverdrawInspector?o.aM.black:o.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(R,z){const $=R.context,j=$.gl,X=((de,pe,ie)=>({u_sky_color:de.properties.get("sky-color"),u_horizon_color:de.properties.get("horizon-color"),u_horizon:(pe.height/2+pe.getHorizon())*ie,u_sky_horizon_blend:de.properties.get("sky-horizon-blend")*pe.height/2*ie}))(z,R.style.map.transform,R.pixelRatio),ee=new rn(j.LEQUAL,rn.ReadWrite,[0,1]),te=qn.disabled,se=R.colorModeForRenderPass(),le=R.useProgram("sky");if(!z.mesh){const de=new o.aX;de.emplaceBack(-1,-1),de.emplaceBack(1,-1),de.emplaceBack(1,1),de.emplaceBack(-1,1);const pe=new o.aY;pe.emplaceBack(0,1,2),pe.emplaceBack(0,2,3),z.mesh=new Eu($.createVertexBuffer(de,_a.members),$.createIndexBuffer(pe),o.a0.simpleSegment(0,0,de.length,pe.length))}le.draw($,j.TRIANGLES,ee,te,se,Fn.disabled,X,void 0,"sky",z.mesh.vertexBuffer,z.mesh.indexBuffer,z.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=f.showOverdrawInspector,this.depthRangeFor3D=[0,1-(l._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=b.length-1;this.currentLayer>=0;this.currentLayer--){const R=this.style._layers[b[this.currentLayer]],z=_[R.source],$=w[R.source];this._renderTileClippingMasks(R,$),this.renderLayer(this,z,R,$)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<b.length;this.currentLayer++){const R=this.style._layers[b[this.currentLayer]],z=_[R.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(R))continue;const $=(R.type==="symbol"?P:M)[R.source];this._renderTileClippingMasks(R,w[R.source]),this.renderLayer(this,z,R,$)}if(this.options.showTileBoundaries){const R=function(z,$){let j=null;const X=Object.values(z._layers).flatMap(le=>le.source&&!le.isHidden($)?[z.sourceCaches[le.source]]:[]),ee=X.filter(le=>le.getSource().type==="vector"),te=X.filter(le=>le.getSource().type!=="vector"),se=le=>{(!j||j.getSource().maxzoom<le.getSource().maxzoom)&&(j=le)};return ee.forEach(le=>se(le)),j||te.forEach(le=>se(le)),j}(this.style,this.transform.zoom);R&&function(z,$,j){for(let X=0;X<j.length;X++)My(z,$,j[X])}(this,R,R.getVisibleCoordinates())}this.options.showPadding&&function(R){const z=R.transform.padding;kl(R,R.transform.height-(z.top||0),3,jf),kl(R,z.bottom||0,3,Sn),Ay(R,z.left||0,3,wu),Ay(R,R.transform.width-(z.right||0),3,t1);const $=R.transform.centerPoint;(function(j,X,ee,te){ku(j,X-1,ee-10,2,20,te),ku(j,X-10,ee-1,20,2,te)})(R,$.x,R.transform.height-$.y,Ty)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(l){if(!this.style||!this.style.map||!this.style.map.terrain)return;const f=this.terrainFacilitator.matrix,b=this.transform.modelViewProjectionMatrix;let _=this.terrainFacilitator.dirty;_||(_=l?!o.a_(f,b):!o.a$(f,b)),_||(_=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),_&&(o.b0(f,b),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(w,M){const P=w.context,R=P.gl,z=pr.unblended,$=new rn(R.LEQUAL,rn.ReadWrite,[0,1]),j=M.getTerrainMesh(),X=M.sourceCache.getRenderableTiles(),ee=w.useProgram("terrainDepth");P.bindFramebuffer.set(M.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1});for(const te of X){const se=M.getTerrainData(te.tileID),le={u_matrix:w.transform.calculatePosMatrix(te.tileID.toUnwrapped()),u_ele_delta:M.getMeshFrameDelta(w.transform.zoom)};ee.draw(P,R.TRIANGLES,$,qn.disabled,z,Fn.backCCW,le,se,"terrain",j.vertexBuffer,j.indexBuffer,j.segments)}P.bindFramebuffer.set(null),P.viewport.set([0,0,w.width,w.height])}(this,this.style.map.terrain),function(w,M){const P=w.context,R=P.gl,z=pr.unblended,$=new rn(R.LEQUAL,rn.ReadWrite,[0,1]),j=M.getTerrainMesh(),X=M.getCoordsTexture(),ee=M.sourceCache.getRenderableTiles(),te=w.useProgram("terrainCoords");P.bindFramebuffer.set(M.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1}),M.coordsIndex=[];for(const se of ee){const le=M.getTerrainData(se.tileID);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,X.texture);const de={u_matrix:w.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_terrain_coords_id:(255-M.coordsIndex.length)/255,u_texture:0,u_ele_delta:M.getMeshFrameDelta(w.transform.zoom)};te.draw(P,R.TRIANGLES,$,qn.disabled,z,Fn.backCCW,de,le,"terrain",j.vertexBuffer,j.indexBuffer,j.segments),M.coordsIndex.push(se.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,w.width,w.height])}(this,this.style.map.terrain))}renderLayer(l,f,b,_){if(!b.isHidden(this.transform.zoom)&&(b.type==="background"||b.type==="custom"||(_||[]).length))switch(this.id=b.id,b.type){case"symbol":(function(w,M,P,R,z){if(w.renderPass!=="translucent")return;const $=qn.disabled,j=w.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(X,ee,te,se,le,de,pe,ie,_e){const ve=ee.transform,Ce=ba(),ze=le==="map",Ze=de==="map";for(const ot of X){const ut=se.getTile(ot),rt=ut.getBucket(te);if(!rt||!rt.text||!rt.text.segments.get().length)continue;const nt=o.ag(rt.textSizeData,ve.zoom),vt=cn(ut,1,ee.transform.zoom),Ht=di(ot.posMatrix,Ze,ze,ee.transform,vt),it=te.layout.get("icon-text-fit")!=="none"&&rt.hasIconData();if(nt){const lt=Math.pow(2,ve.zoom-ut.tileID.overscaledZ),Ft=ee.style.map.terrain?(Jt,dn)=>ee.style.map.terrain.getElevation(ot,Jt,dn):null,Xn=Ce.translatePosition(ve,ut,pe,ie);_l(rt,ze,Ze,_e,ve,Ht,ot.posMatrix,lt,nt,it,Ce,Xn,ot.toUnwrapped(),Ft)}}}(R,w,P,M,P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),z),P.paint.get("icon-opacity").constantOr(1)!==0&&Lf(w,M,P,R,!1,P.paint.get("icon-translate"),P.paint.get("icon-translate-anchor"),P.layout.get("icon-rotation-alignment"),P.layout.get("icon-pitch-alignment"),P.layout.get("icon-keep-upright"),$,j),P.paint.get("text-opacity").constantOr(1)!==0&&Lf(w,M,P,R,!0,P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.layout.get("text-keep-upright"),$,j),M.map.showCollisionBoxes&&(Bc(w,M,P,R,!0),Bc(w,M,P,R,!1))})(l,f,b,_,this.style.placement.variableOffsets);break;case"circle":(function(w,M,P,R){if(w.renderPass!=="translucent")return;const z=P.paint.get("circle-opacity"),$=P.paint.get("circle-stroke-width"),j=P.paint.get("circle-stroke-opacity"),X=!P.layout.get("circle-sort-key").isConstant();if(z.constantOr(1)===0&&($.constantOr(1)===0||j.constantOr(1)===0))return;const ee=w.context,te=ee.gl,se=w.depthModeForSublayer(0,rn.ReadOnly),le=qn.disabled,de=w.colorModeForRenderPass(),pe=[];for(let ie=0;ie<R.length;ie++){const _e=R[ie],ve=M.getTile(_e),Ce=ve.getBucket(P);if(!Ce)continue;const ze=Ce.programConfigurations.get(P.id),Ze=w.useProgram("circle",ze),ot=Ce.layoutVertexBuffer,ut=Ce.indexBuffer,rt=w.style.map.terrain&&w.style.map.terrain.getTerrainData(_e),nt={programConfiguration:ze,program:Ze,layoutVertexBuffer:ot,indexBuffer:ut,uniformValues:$v(w,_e,ve,P),terrainData:rt};if(X){const vt=Ce.segments.get();for(const Ht of vt)pe.push({segments:new o.a0([Ht]),sortKey:Ht.sortKey,state:nt})}else pe.push({segments:Ce.segments,sortKey:0,state:nt})}X&&pe.sort((ie,_e)=>ie.sortKey-_e.sortKey);for(const ie of pe){const{programConfiguration:_e,program:ve,layoutVertexBuffer:Ce,indexBuffer:ze,uniformValues:Ze,terrainData:ot}=ie.state;ve.draw(ee,te.TRIANGLES,se,le,de,Fn.disabled,Ze,ot,P.id,Ce,ze,ie.segments,P.paint,w.transform.zoom,_e)}})(l,f,b,_);break;case"heatmap":(function(w,M,P,R){if(P.paint.get("heatmap-opacity")===0)return;const z=w.context;if(w.style.map.terrain){for(const $ of R){const j=M.getTile($);M.hasRenderableParent($)||(w.renderPass==="offscreen"?$f(w,j,P,$):w.renderPass==="translucent"&&Ca(w,P,$))}z.viewport.set([0,0,w.width,w.height])}else w.renderPass==="offscreen"?function($,j,X,ee){const te=$.context,se=te.gl,le=qn.disabled,de=new pr([se.ONE,se.ONE],o.aM.transparent,[!0,!0,!0,!0]);(function(pe,ie,_e){const ve=pe.gl;pe.activeTexture.set(ve.TEXTURE1),pe.viewport.set([0,0,ie.width/4,ie.height/4]);let Ce=_e.heatmapFbos.get(o.aU);Ce?(ve.bindTexture(ve.TEXTURE_2D,Ce.colorAttachment.get()),pe.bindFramebuffer.set(Ce.framebuffer)):(Ce=zc(pe,ie.width/4,ie.height/4),_e.heatmapFbos.set(o.aU,Ce))})(te,$,X),te.clear({color:o.aM.transparent});for(let pe=0;pe<ee.length;pe++){const ie=ee[pe];if(j.hasRenderableParent(ie))continue;const _e=j.getTile(ie),ve=_e.getBucket(X);if(!ve)continue;const Ce=ve.programConfigurations.get(X.id),ze=$.useProgram("heatmap",Ce),{zoom:Ze}=$.transform;ze.draw(te,se.TRIANGLES,rn.disabled,le,de,Fn.disabled,Si(ie.posMatrix,_e,Ze,X.paint.get("heatmap-intensity")),null,X.id,ve.layoutVertexBuffer,ve.indexBuffer,ve.segments,X.paint,$.transform.zoom,Ce)}te.viewport.set([0,0,$.width,$.height])}(w,M,P,R):w.renderPass==="translucent"&&function($,j){const X=$.context,ee=X.gl;X.setColorMode($.colorModeForRenderPass());const te=j.heatmapFbos.get(o.aU);te&&(X.activeTexture.set(ee.TEXTURE0),ee.bindTexture(ee.TEXTURE_2D,te.colorAttachment.get()),X.activeTexture.set(ee.TEXTURE1),Lc(X,j).bind(ee.LINEAR,ee.CLAMP_TO_EDGE),$.useProgram("heatmapTexture").draw(X,ee.TRIANGLES,rn.disabled,qn.disabled,$.colorModeForRenderPass(),Fn.disabled,hu($,j,0,1),null,j.id,$.viewportBuffer,$.quadTriangleIndexBuffer,$.viewportSegments,j.paint,$.transform.zoom))}(w,P)})(l,f,b,_);break;case"line":(function(w,M,P,R){if(w.renderPass!=="translucent")return;const z=P.paint.get("line-opacity"),$=P.paint.get("line-width");if(z.constantOr(1)===0||$.constantOr(1)===0)return;const j=w.depthModeForSublayer(0,rn.ReadOnly),X=w.colorModeForRenderPass(),ee=P.paint.get("line-dasharray"),te=P.paint.get("line-pattern"),se=te.constantOr(1),le=P.paint.get("line-gradient"),de=P.getCrossfadeParameters(),pe=se?"linePattern":ee?"lineSDF":le?"lineGradient":"line",ie=w.context,_e=ie.gl;let ve=!0;for(const Ce of R){const ze=M.getTile(Ce);if(se&&!ze.patternsLoaded())continue;const Ze=ze.getBucket(P);if(!Ze)continue;const ot=Ze.programConfigurations.get(P.id),ut=w.context.program.get(),rt=w.useProgram(pe,ot),nt=ve||rt.program!==ut,vt=w.style.map.terrain&&w.style.map.terrain.getTerrainData(Ce),Ht=te.constantOr(null);if(Ht&&ze.imageAtlas){const Ft=ze.imageAtlas,Xn=Ft.patternPositions[Ht.to.toString()],Jt=Ft.patternPositions[Ht.from.toString()];Xn&&Jt&&ot.setConstantPatternPositions(Xn,Jt)}const it=vt?Ce:null,lt=se?yl(w,ze,P,de,it):ee?jv(w,ze,P,ee,de,it):le?dy(w,ze,P,Ze.lineClipsArray.length,it):pu(w,ze,P,it);if(se)ie.activeTexture.set(_e.TEXTURE0),ze.imageAtlasTexture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE),ot.updatePaintBuffers(de);else if(ee&&(nt||w.lineAtlas.dirty))ie.activeTexture.set(_e.TEXTURE0),w.lineAtlas.bind(ie);else if(le){const Ft=Ze.gradients[P.id];let Xn=Ft.texture;if(P.gradientVersion!==Ft.version){let Jt=256;if(P.stepInterpolant){const dn=M.getSource().maxzoom,Kn=Ce.canonical.z===dn?Math.ceil(1<<w.transform.maxZoom-Ce.canonical.z):1;Jt=o.ac(o.aV(Ze.maxLineLength/o.X*1024*Kn),256,ie.maxTextureSize)}Ft.gradient=o.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:Jt,image:Ft.gradient||void 0,clips:Ze.lineClipsArray}),Ft.texture?Ft.texture.update(Ft.gradient):Ft.texture=new Le(ie,Ft.gradient,_e.RGBA),Ft.version=P.gradientVersion,Xn=Ft.texture}ie.activeTexture.set(_e.TEXTURE0),Xn.bind(P.stepInterpolant?_e.NEAREST:_e.LINEAR,_e.CLAMP_TO_EDGE)}rt.draw(ie,_e.TRIANGLES,j,w.stencilModeForClipping(Ce),X,Fn.disabled,lt,vt,P.id,Ze.layoutVertexBuffer,Ze.indexBuffer,Ze.segments,P.paint,w.transform.zoom,ot,Ze.layoutVertexBuffer2),ve=!1}})(l,f,b,_);break;case"fill":(function(w,M,P,R){const z=P.paint.get("fill-color"),$=P.paint.get("fill-opacity");if($.constantOr(1)===0)return;const j=w.colorModeForRenderPass(),X=P.paint.get("fill-pattern"),ee=w.opaquePassEnabledForLayer()&&!X.constantOr(1)&&z.constantOr(o.aM.transparent).a===1&&$.constantOr(0)===1?"opaque":"translucent";if(w.renderPass===ee){const te=w.depthModeForSublayer(1,w.renderPass==="opaque"?rn.ReadWrite:rn.ReadOnly);Fc(w,M,P,R,te,j,!1)}if(w.renderPass==="translucent"&&P.paint.get("fill-antialias")){const te=w.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,rn.ReadOnly);Fc(w,M,P,R,te,j,!0)}})(l,f,b,_);break;case"fill-extrusion":(function(w,M,P,R){const z=P.paint.get("fill-extrusion-opacity");if(z!==0&&w.renderPass==="translucent"){const $=new rn(w.context.gl.LEQUAL,rn.ReadWrite,w.depthRangeFor3D);if(z!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))vu(w,M,P,R,$,qn.disabled,pr.disabled),vu(w,M,P,R,$,w.stencilModeFor3D(),w.colorModeForRenderPass());else{const j=w.colorModeForRenderPass();vu(w,M,P,R,$,qn.disabled,j)}}})(l,f,b,_);break;case"hillshade":(function(w,M,P,R){if(w.renderPass!=="offscreen"&&w.renderPass!=="translucent")return;const z=w.context,$=w.depthModeForSublayer(0,rn.ReadOnly),j=w.colorModeForRenderPass(),[X,ee]=w.renderPass==="translucent"?w.stencilConfigForOverlap(R):[{},R];for(const te of ee){const se=M.getTile(te);se.needsHillshadePrepare!==void 0&&se.needsHillshadePrepare&&w.renderPass==="offscreen"?wl(w,se,P,$,qn.disabled,j):w.renderPass==="translucent"&&vl(w,te,se,P,$,X[te.overscaledZ],j)}z.viewport.set([0,0,w.width,w.height])})(l,f,b,_);break;case"raster":(function(w,M,P,R){if(w.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!R.length)return;const z=w.context,$=z.gl,j=M.getSource(),X=w.useProgram("raster"),ee=w.colorModeForRenderPass(),[te,se]=j instanceof ir?[{},R]:w.stencilConfigForOverlap(R),le=se[se.length-1].overscaledZ,de=!w.options.moving;for(const pe of se){const ie=w.depthModeForSublayer(pe.overscaledZ-le,P.paint.get("raster-opacity")===1?rn.ReadWrite:rn.ReadOnly,$.LESS),_e=M.getTile(pe);_e.registerFadeDuration(P.paint.get("raster-fade-duration"));const ve=M.findLoadedParent(pe,0),Ce=M.findLoadedSibling(pe),ze=Cy(_e,ve||Ce||null,M,P,w.transform,w.style.map.terrain);let Ze,ot;const ut=P.paint.get("raster-resampling")==="nearest"?$.NEAREST:$.LINEAR;z.activeTexture.set($.TEXTURE0),_e.texture.bind(ut,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),z.activeTexture.set($.TEXTURE1),ve?(ve.texture.bind(ut,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),Ze=Math.pow(2,ve.tileID.overscaledZ-_e.tileID.overscaledZ),ot=[_e.tileID.canonical.x*Ze%1,_e.tileID.canonical.y*Ze%1]):_e.texture.bind(ut,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),_e.texture.useMipmap&&z.extTextureFilterAnisotropic&&w.transform.pitch>20&&$.texParameterf($.TEXTURE_2D,z.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,z.extTextureFilterAnisotropicMax);const rt=w.style.map.terrain&&w.style.map.terrain.getTerrainData(pe),nt=rt?pe:null,vt=nt?nt.posMatrix:w.transform.calculatePosMatrix(pe.toUnwrapped(),de),Ht=Hv(vt,ot||[0,0],Ze||1,ze,P);j instanceof ir?X.draw(z,$.TRIANGLES,ie,qn.disabled,ee,Fn.disabled,Ht,rt,P.id,j.boundsBuffer,w.quadTriangleIndexBuffer,j.boundsSegments):X.draw(z,$.TRIANGLES,ie,te[pe.overscaledZ],ee,Fn.disabled,Ht,rt,P.id,w.rasterBoundsBuffer,w.quadTriangleIndexBuffer,w.rasterBoundsSegments)}})(l,f,b,_);break;case"background":(function(w,M,P,R){const z=P.paint.get("background-color"),$=P.paint.get("background-opacity");if($===0)return;const j=w.context,X=j.gl,ee=w.transform,te=ee.tileSize,se=P.paint.get("background-pattern");if(w.isPatternMissing(se))return;const le=!se&&z.a===1&&$===1&&w.opaquePassEnabledForLayer()?"opaque":"translucent";if(w.renderPass!==le)return;const de=qn.disabled,pe=w.depthModeForSublayer(0,le==="opaque"?rn.ReadWrite:rn.ReadOnly),ie=w.colorModeForRenderPass(),_e=w.useProgram(se?"backgroundPattern":"background"),ve=R||ee.coveringTiles({tileSize:te,terrain:w.style.map.terrain});se&&(j.activeTexture.set(X.TEXTURE0),w.imageManager.bind(w.context));const Ce=P.getCrossfadeParameters();for(const ze of ve){const Ze=R?ze.posMatrix:w.transform.calculatePosMatrix(ze.toUnwrapped()),ot=se?Af(Ze,$,w,se,{tileID:ze,tileSize:te},Ce):mu(Ze,$,z),ut=w.style.map.terrain&&w.style.map.terrain.getTerrainData(ze);_e.draw(j,X.TRIANGLES,pe,de,ie,Fn.disabled,ot,ut,P.id,w.tileExtentBuffer,w.quadTriangleIndexBuffer,w.tileExtentSegments)}})(l,0,b,_);break;case"custom":(function(w,M,P){const R=w.context,z=P.implementation;if(w.renderPass==="offscreen"){const $=z.prerender;$&&(w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),$.call(z,R.gl,w.transform.customLayerMatrix()),R.setDirty(),w.setBaseState())}else if(w.renderPass==="translucent"){w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),R.setStencilMode(qn.disabled);const $=z.renderingMode==="3d"?new rn(w.context.gl.LEQUAL,rn.ReadWrite,w.depthRangeFor3D):w.depthModeForSublayer(0,rn.ReadOnly);R.setDepthMode($),z.render(R.gl,w.transform.customLayerMatrix(),{farZ:w.transform.farZ,nearZ:w.transform.nearZ,fov:w.transform._fov,modelViewProjectionMatrix:w.transform.modelViewProjectionMatrix,projectionMatrix:w.transform.projectionMatrix}),R.setDirty(),w.setBaseState(),R.bindFramebuffer.set(null)}})(l,0,b)}}translatePosMatrix(l,f,b,_,w){if(!b[0]&&!b[1])return l;const M=w?_==="map"?this.transform.angle:0:_==="viewport"?-this.transform.angle:0;if(M){const z=Math.sin(M),$=Math.cos(M);b=[b[0]*$-b[1]*z,b[0]*z+b[1]*$]}const P=[w?b[0]:cn(f,b[0],this.transform.zoom),w?b[1]:cn(f,b[1],this.transform.zoom),0],R=new Float32Array(16);return o.J(R,l,P),R}saveTileTexture(l){const f=this._tileTextures[l.size[0]];f?f.push(l):this._tileTextures[l.size[0]]=[l]}getTileTexture(l){const f=this._tileTextures[l];return f&&f.length>0?f.pop():null}isPatternMissing(l){if(!l)return!1;if(!l.from||!l.to)return!0;const f=this.imageManager.getPattern(l.from.toString()),b=this.imageManager.getPattern(l.to.toString());return!f||!b}useProgram(l,f){this.cache=this.cache||{};const b=l+(f?f.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[b]||(this.cache[b]=new Cf(this.context,Bo[l],f,Mf[l],this._showOverdrawInspector,this.style.map.terrain)),this.cache[b]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const l=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(l.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Le(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:l,drawingBufferHeight:f}=this.context.gl;return this.width!==l||this.height!==f}}class El{constructor(l,f){this.points=l,this.planes=f}static fromInvProjectionMatrix(l,f,b){const _=Math.pow(2,b),w=[[-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(P=>{const R=1/(P=o.af([],P,l))[3]/f*_;return o.b1(P,P,[R,R,1/P[3],R])}),M=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const R=function(X,ee){var te=ee[0],se=ee[1],le=ee[2],de=te*te+se*se+le*le;return de>0&&(de=1/Math.sqrt(de)),X[0]=ee[0]*de,X[1]=ee[1]*de,X[2]=ee[2]*de,X}([],function(X,ee,te){var se=ee[0],le=ee[1],de=ee[2],pe=te[0],ie=te[1],_e=te[2];return X[0]=le*_e-de*ie,X[1]=de*pe-se*_e,X[2]=se*ie-le*pe,X}([],xe([],w[P[0]],w[P[1]]),xe([],w[P[2]],w[P[1]]))),z=-(($=R)[0]*(j=w[P[1]])[0]+$[1]*j[1]+$[2]*j[2]);var $,j;return R.concat(z)});return new El(w,M)}}class Sl{constructor(l,f){this.min=l,this.max=f,this.center=function(b,_,w){return b[0]=.5*_[0],b[1]=.5*_[1],b[2]=.5*_[2],b}([],function(b,_,w){return b[0]=_[0]+w[0],b[1]=_[1]+w[1],b[2]=_[2]+w[2],b}([],this.min,this.max))}quadrant(l){const f=[l%2==0,l<2],b=he(this.min),_=he(this.max);for(let w=0;w<f.length;w++)b[w]=f[w]?this.min[w]:this.center[w],_[w]=f[w]?this.center[w]:this.max[w];return _[2]=this.max[2],new Sl(b,_)}distanceX(l){return Math.max(Math.min(this.max[0],l[0]),this.min[0])-l[0]}distanceY(l){return Math.max(Math.min(this.max[1],l[1]),this.min[1])-l[1]}intersects(l){const f=[[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]];let b=!0;for(let _=0;_<l.planes.length;_++){const w=l.planes[_];let M=0;for(let P=0;P<f.length;P++)o.b2(w,f[P])>=0&&M++;if(M===0)return 0;M!==f.length&&(b=!1)}if(b)return 2;for(let _=0;_<3;_++){let w=Number.MAX_VALUE,M=-Number.MAX_VALUE;for(let P=0;P<l.points.length;P++){const R=l.points[P][_]-this.min[_];w=Math.min(w,R),M=Math.max(M,R)}if(M<0||w>this.max[_]-this.min[_])return 0}return 1}}class Cl{constructor(l=0,f=0,b=0,_=0){if(isNaN(l)||l<0||isNaN(f)||f<0||isNaN(b)||b<0||isNaN(_)||_<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=l,this.bottom=f,this.left=b,this.right=_}interpolate(l,f,b){return f.top!=null&&l.top!=null&&(this.top=o.y.number(l.top,f.top,b)),f.bottom!=null&&l.bottom!=null&&(this.bottom=o.y.number(l.bottom,f.bottom,b)),f.left!=null&&l.left!=null&&(this.left=o.y.number(l.left,f.left,b)),f.right!=null&&l.right!=null&&(this.right=o.y.number(l.right,f.right,b)),this}getCenter(l,f){const b=o.ac((this.left+l-this.right)/2,0,l),_=o.ac((this.top+f-this.bottom)/2,0,f);return new o.P(b,_)}equals(l){return this.top===l.top&&this.bottom===l.bottom&&this.left===l.left&&this.right===l.right}clone(){return new Cl(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Hf=85.051129;class Tl{constructor(l,f,b,_,w){this.tileSize=512,this._renderWorldCopies=w===void 0||!!w,this._minZoom=l||0,this._maxZoom=f||22,this._minPitch=b??0,this._maxPitch=_??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Cl,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const l=new Tl(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return l.apply(this),l}apply(l){this.tileSize=l.tileSize,this.latRange=l.latRange,this.lngRange=l.lngRange,this.width=l.width,this.height=l.height,this._center=l._center,this._elevation=l._elevation,this.minElevationForCurrentTile=l.minElevationForCurrentTile,this.zoom=l.zoom,this.angle=l.angle,this._fov=l._fov,this._pitch=l._pitch,this._unmodified=l._unmodified,this._edgeInsets=l._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(l){this._minZoom!==l&&(this._minZoom=l,this.zoom=Math.max(this.zoom,l))}get maxZoom(){return this._maxZoom}set maxZoom(l){this._maxZoom!==l&&(this._maxZoom=l,this.zoom=Math.min(this.zoom,l))}get minPitch(){return this._minPitch}set minPitch(l){this._minPitch!==l&&(this._minPitch=l,this.pitch=Math.max(this.pitch,l))}get maxPitch(){return this._maxPitch}set maxPitch(l){this._maxPitch!==l&&(this._maxPitch=l,this.pitch=Math.min(this.pitch,l))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(l){l===void 0?l=!0:l===null&&(l=!1),this._renderWorldCopies=l}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(l){const f=-o.b3(l,-180,180)*Math.PI/180;this.angle!==f&&(this._unmodified=!1,this.angle=f,this._calcMatrices(),this.rotationMatrix=function(){var b=new o.A(4);return o.A!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b}(),function(b,_,w){var M=_[0],P=_[1],R=_[2],z=_[3],$=Math.sin(w),j=Math.cos(w);b[0]=M*j+R*$,b[1]=P*j+z*$,b[2]=M*-$+R*j,b[3]=P*-$+z*j}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(l){const f=o.ac(l,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==f&&(this._unmodified=!1,this._pitch=f,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(l){l=Math.max(.01,Math.min(60,l)),this._fov!==l&&(this._unmodified=!1,this._fov=l/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(l){const f=Math.min(Math.max(l,this.minZoom),this.maxZoom);this._zoom!==f&&(this._unmodified=!1,this._zoom=f,this.tileZoom=Math.max(0,Math.floor(f)),this.scale=this.zoomScale(f),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(l){l.lat===this._center.lat&&l.lng===this._center.lng||(this._unmodified=!1,this._center=l,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(l){l!==this._elevation&&(this._elevation=l,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(l){this._edgeInsets.equals(l)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,l,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(l){return this._edgeInsets.equals(l)}interpolatePadding(l,f,b){this._unmodified=!1,this._edgeInsets.interpolate(l,f,b),this._constrain(),this._calcMatrices()}coveringZoomLevel(l){const f=(l.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/l.tileSize));return Math.max(0,f)}getVisibleUnwrappedCoordinates(l){const f=[new o.b4(0,l)];if(this._renderWorldCopies){const b=this.pointCoordinate(new o.P(0,0)),_=this.pointCoordinate(new o.P(this.width,0)),w=this.pointCoordinate(new o.P(this.width,this.height)),M=this.pointCoordinate(new o.P(0,this.height)),P=Math.floor(Math.min(b.x,_.x,w.x,M.x)),R=Math.floor(Math.max(b.x,_.x,w.x,M.x)),z=1;for(let $=P-z;$<=R+z;$++)$!==0&&f.push(new o.b4($,l))}return f}coveringTiles(l){var f,b;let _=this.coveringZoomLevel(l);const w=_;if(l.minzoom!==void 0&&_<l.minzoom)return[];l.maxzoom!==void 0&&_>l.maxzoom&&(_=l.maxzoom);const M=this.pointCoordinate(this.getCameraPoint()),P=o.Z.fromLngLat(this.center),R=Math.pow(2,_),z=[R*M.x,R*M.y,0],$=[R*P.x,R*P.y,0],j=El.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,_);let X=l.minzoom||0;!l.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(X=_);const ee=l.terrain?2/Math.min(this.tileSize,l.tileSize)*this.tileSize:3,te=ie=>({aabb:new Sl([ie*R,0,0],[(ie+1)*R,R,0]),zoom:0,x:0,y:0,wrap:ie,fullyVisible:!1}),se=[],le=[],de=_,pe=l.reparseOverscaled?w:_;if(this._renderWorldCopies)for(let ie=1;ie<=3;ie++)se.push(te(-ie)),se.push(te(ie));for(se.push(te(0));se.length>0;){const ie=se.pop(),_e=ie.x,ve=ie.y;let Ce=ie.fullyVisible;if(!Ce){const rt=ie.aabb.intersects(j);if(rt===0)continue;Ce=rt===2}const ze=l.terrain?z:$,Ze=ie.aabb.distanceX(ze),ot=ie.aabb.distanceY(ze),ut=Math.max(Math.abs(Ze),Math.abs(ot));if(ie.zoom===de||ut>ee+(1<<de-ie.zoom)-2&&ie.zoom>=X){const rt=de-ie.zoom,nt=z[0]-.5-(_e<<rt),vt=z[1]-.5-(ve<<rt);le.push({tileID:new o.S(ie.zoom===de?pe:ie.zoom,ie.wrap,ie.zoom,_e,ve),distanceSq:Re([$[0]-.5-_e,$[1]-.5-ve]),tileDistanceToCamera:Math.sqrt(nt*nt+vt*vt)})}else for(let rt=0;rt<4;rt++){const nt=(_e<<1)+rt%2,vt=(ve<<1)+(rt>>1),Ht=ie.zoom+1;let it=ie.aabb.quadrant(rt);if(l.terrain){const lt=new o.S(Ht,ie.wrap,Ht,nt,vt),Ft=l.terrain.getMinMaxElevation(lt),Xn=(f=Ft.minElevation)!==null&&f!==void 0?f:this.elevation,Jt=(b=Ft.maxElevation)!==null&&b!==void 0?b:this.elevation;it=new Sl([it.min[0],it.min[1],Xn],[it.max[0],it.max[1],Jt])}se.push({aabb:it,zoom:Ht,x:nt,y:vt,wrap:ie.wrap,fullyVisible:Ce})}}return le.sort((ie,_e)=>ie.distanceSq-_e.distanceSq).map(ie=>ie.tileID)}resize(l,f){this.width=l,this.height=f,this.pixelsToGLUnits=[2/l,-2/f],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(l){return Math.pow(2,l)}scaleZoom(l){return Math.log(l)/Math.LN2}project(l){const f=o.ac(l.lat,-85.051129,Hf);return new o.P(o.O(l.lng)*this.worldSize,o.Q(f)*this.worldSize)}unproject(l){return new o.Z(l.x/this.worldSize,l.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(l){const f=this.elevation,b=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,_=this.pointLocation(this.centerPoint,l),w=l.getElevationForLngLatZoom(_,this.tileZoom);if(!(this.elevation-w))return;const M=b+f-w,P=Math.cos(this._pitch)*this.cameraToCenterDistance/M/o.b5(1,_.lat),R=this.scaleZoom(P/this.tileSize);this._elevation=w,this._center=_,this.zoom=R}setLocationAtPoint(l,f){const b=this.pointCoordinate(f),_=this.pointCoordinate(this.centerPoint),w=this.locationCoordinate(l),M=new o.Z(w.x-(b.x-_.x),w.y-(b.y-_.y));this.center=this.coordinateLocation(M),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(l,f){return f?this.coordinatePoint(this.locationCoordinate(l),f.getElevationForLngLatZoom(l,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(l))}pointLocation(l,f){return this.coordinateLocation(this.pointCoordinate(l,f))}locationCoordinate(l){return o.Z.fromLngLat(l)}coordinateLocation(l){return l&&l.toLngLat()}pointCoordinate(l,f){if(f){const X=f.pointCoordinate(l);if(X!=null)return X}const b=[l.x,l.y,0,1],_=[l.x,l.y,1,1];o.af(b,b,this.pixelMatrixInverse),o.af(_,_,this.pixelMatrixInverse);const w=b[3],M=_[3],P=b[1]/w,R=_[1]/M,z=b[2]/w,$=_[2]/M,j=z===$?0:(0-z)/($-z);return new o.Z(o.y.number(b[0]/w,_[0]/M,j)/this.worldSize,o.y.number(P,R,j)/this.worldSize)}coordinatePoint(l,f=0,b=this.pixelMatrix){const _=[l.x*this.worldSize,l.y*this.worldSize,f,1];return o.af(_,_,b),new o.P(_[0]/_[3],_[1]/_[3])}getBounds(){const l=Math.max(0,this.height/2-this.getHorizon());return new Ae().extend(this.pointLocation(new o.P(0,l))).extend(this.pointLocation(new o.P(this.width,l))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Ae([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(l){l?(this.lngRange=[l.getWest(),l.getEast()],this.latRange=[l.getSouth(),l.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,Hf])}calculateTileMatrix(l){const f=l.canonical,b=this.worldSize/this.zoomScale(f.z),_=f.x+Math.pow(2,f.z)*l.wrap,w=o.an(new Float64Array(16));return o.J(w,w,[_*b,f.y*b,0]),o.K(w,w,[b/o.X,b/o.X,1]),w}calculatePosMatrix(l,f=!1){const b=l.key,_=f?this._alignedPosMatrixCache:this._posMatrixCache;if(_[b])return _[b];const w=this.calculateTileMatrix(l);return o.L(w,f?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,w),_[b]=new Float32Array(w),_[b]}calculateFogMatrix(l){const f=l.key,b=this._fogMatrixCache;if(b[f])return b[f];const _=this.calculateTileMatrix(l);return o.L(_,this.fogMatrix,_),b[f]=new Float32Array(_),b[f]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(l,f){f=o.ac(+f,this.minZoom,this.maxZoom);const b={center:new o.N(l.lng,l.lat),zoom:f};let _=this.lngRange;!this._renderWorldCopies&&_===null&&(_=[-179.9999999999,179.9999999999]);const w=this.tileSize*this.zoomScale(b.zoom);let M=0,P=w,R=0,z=w,$=0,j=0;const{x:X,y:ee}=this.size;if(this.latRange){const ie=this.latRange;M=o.Q(ie[1])*w,P=o.Q(ie[0])*w,P-M<ee&&($=ee/(P-M))}_&&(R=o.b3(o.O(_[0])*w,0,w),z=o.b3(o.O(_[1])*w,0,w),z<R&&(z+=w),z-R<X&&(j=X/(z-R)));const{x:te,y:se}=this.project.call({worldSize:w},l);let le,de;const pe=Math.max(j||0,$||0);if(pe){const ie=new o.P(j?(z+R)/2:te,$?(P+M)/2:se);return b.center=this.unproject.call({worldSize:w},ie).wrap(),b.zoom+=this.scaleZoom(pe),b}if(this.latRange){const ie=ee/2;se-ie<M&&(de=M+ie),se+ie>P&&(de=P-ie)}if(_){const ie=(R+z)/2;let _e=te;this._renderWorldCopies&&(_e=o.b3(te,ie-w/2,ie+w/2));const ve=X/2;_e-ve<R&&(le=R+ve),_e+ve>z&&(le=z-ve)}if(le!==void 0||de!==void 0){const ie=new o.P(le??te,de??se);b.center=this.unproject.call({worldSize:w},ie).wrap()}return b}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const l=this._unmodified,{center:f,zoom:b}=this.getConstrained(this.center,this.zoom);this.center=f,this.zoom=b,this._unmodified=l,this._constraining=!1}_calcMatrices(){if(!this.height)return;const l=this.centerOffset,f=this.point.x,b=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=o.b5(1,this.center.lat)*this.worldSize;let _=o.an(new Float64Array(16));o.K(_,_,[this.width/2,-this.height/2,1]),o.J(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=o.an(new Float64Array(16)),o.K(_,_,[1,-1,1]),o.J(_,_,[-1,-1,0]),o.K(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_;const w=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),M=Math.min(this.elevation,this.minElevationForCurrentTile),P=w-M*this._pixelPerMeter/Math.cos(this._pitch),R=M<0?P:w,z=Math.PI/2+this._pitch,$=this._fov*(.5+l.y/this.height),j=Math.sin($)*R/Math.sin(o.ac(Math.PI-z-$,.01,Math.PI-.01)),X=this.getHorizon(),ee=2*Math.atan(X/this.cameraToCenterDistance)*(.5+l.y/(2*X)),te=Math.sin(ee)*R/Math.sin(o.ac(Math.PI-z-ee,.01,Math.PI-.01)),se=Math.min(j,te);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*se+R),this.nearZ=this.height/50,_=new Float64Array(16),o.b6(_,this._fov,this.width/this.height,this.nearZ,this.farZ),_[8]=2*-l.x/this.width,_[9]=2*l.y/this.height,this.projectionMatrix=o.ae(_),o.K(_,_,[1,-1,1]),o.J(_,_,[0,0,-this.cameraToCenterDistance]),o.b7(_,_,this._pitch),o.ad(_,_,this.angle),o.J(_,_,[-f,-b,0]),this.mercatorMatrix=o.K([],_,[this.worldSize,this.worldSize,this.worldSize]),o.K(_,_,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.L(new Float64Array(16),this.labelPlaneMatrix,_),o.J(_,_,[0,0,-this.elevation]),this.modelViewProjectionMatrix=_,this.invModelViewProjectionMatrix=o.as([],_),this.fogMatrix=new Float64Array(16),o.b6(this.fogMatrix,this._fov,this.width/this.height,w,this.farZ),this.fogMatrix[8]=2*-l.x/this.width,this.fogMatrix[9]=2*l.y/this.height,o.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),o.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),o.b7(this.fogMatrix,this.fogMatrix,this._pitch),o.ad(this.fogMatrix,this.fogMatrix,this.angle),o.J(this.fogMatrix,this.fogMatrix,[-f,-b,0]),o.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),o.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=o.L(new Float64Array(16),this.labelPlaneMatrix,_);const le=this.width%2/2,de=this.height%2/2,pe=Math.cos(this.angle),ie=Math.sin(this.angle),_e=f-Math.round(f)+pe*le+ie*de,ve=b-Math.round(b)+pe*de+ie*le,Ce=new Float64Array(_);if(o.J(Ce,Ce,[_e>.5?_e-1:_e,ve>.5?ve-1:ve,0]),this.alignedModelViewProjectionMatrix=Ce,_=o.as(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const l=this.pointCoordinate(new o.P(0,0)),f=[l.x*this.worldSize,l.y*this.worldSize,0,1];return o.af(f,f,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const l=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,l))}getCameraQueryGeometry(l){const f=this.getCameraPoint();if(l.length===1)return[l[0],f];{let b=f.x,_=f.y,w=f.x,M=f.y;for(const P of l)b=Math.min(b,P.x),_=Math.min(_,P.y),w=Math.max(w,P.x),M=Math.max(M,P.y);return[new o.P(b,_),new o.P(w,_),new o.P(w,M),new o.P(b,M),new o.P(b,_)]}}lngLatToCameraDepth(l,f){const b=this.locationCoordinate(l),_=[b.x*this.worldSize,b.y*this.worldSize,f,1];return o.af(_,_,this.modelViewProjectionMatrix),_[2]/_[3]}}function $c(E,l){let f,b=!1,_=null,w=null;const M=()=>{_=null,b&&(E.apply(w,f),_=setTimeout(M,l),b=!1)};return(...P)=>(b=!0,w=this,f=P,_||M(),_)}class Cu{constructor(l){this._getCurrentHash=()=>{const f=window.location.hash.replace("#","");if(this._hashName){let b;return f.split("&").map(_=>_.split("=")).forEach(_=>{_[0]===this._hashName&&(b=_)}),(b&&b[1]||"").split("/")}return f.split("/")},this._onHashChange=()=>{const f=this._getCurrentHash();if(f.length>=3&&!f.some(b=>isNaN(b))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(f[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+f[2],+f[1]],zoom:+f[0],bearing:b,pitch:+(f[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const f=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,f)},this._removeHash=()=>{const f=this._getCurrentHash();if(f.length===0)return;const b=f.join("/");let _=b;_.split("&").length>0&&(_=_.split("&")[0]),this._hashName&&(_=`${this._hashName}=${b}`);let w=window.location.hash.replace(_,"");w.startsWith("#&")?w=w.slice(0,1)+w.slice(2):w==="#"&&(w="");let M=window.location.href.replace(/(#.+)?$/,w);M=M.replace("&&","&"),window.history.replaceState(window.history.state,null,M)},this._updateHash=$c(this._updateHashUnthrottled,300),this._hashName=l&&encodeURIComponent(l)}addTo(l){return this._map=l,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(l){const f=this._map.getCenter(),b=Math.round(100*this._map.getZoom())/100,_=Math.ceil((b*Math.LN2+Math.log(512/360/.5))/Math.LN10),w=Math.pow(10,_),M=Math.round(f.lng*w)/w,P=Math.round(f.lat*w)/w,R=this._map.getBearing(),z=this._map.getPitch();let $="";if($+=l?`/${M}/${P}/${b}`:`${b}/${P}/${M}`,(R||z)&&($+="/"+Math.round(10*R)/10),z&&($+=`/${Math.round(z)}`),this._hashName){const j=this._hashName;let X=!1;const ee=window.location.hash.slice(1).split("&").map(te=>{const se=te.split("=")[0];return se===j?(X=!0,`${se}=${$}`):te}).filter(te=>te);return X||ee.push(`${j}=${$}`),`#${ee.join("&")}`}return`#${$}`}}const Tu={linearity:.3,easing:o.b8(0,0,.3,1)},Uf=o.e({deceleration:2500,maxSpeed:1400},Tu),n1=o.e({deceleration:20,maxSpeed:1400},Tu),Iy=o.e({deceleration:1e3,maxSpeed:360},Tu),Au=o.e({deceleration:1e3,maxSpeed:90},Tu);class Wf{constructor(l){this._map=l,this.clear()}clear(){this._inertiaBuffer=[]}record(l){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:v.now(),settings:l})}_drainInertiaBuffer(){const l=this._inertiaBuffer,f=v.now();for(;l.length>0&&f-l[0].time>160;)l.shift()}_onMoveEnd(l){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const f={zoom:0,bearing:0,pitch:0,pan:new o.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:w}of this._inertiaBuffer)f.zoom+=w.zoomDelta||0,f.bearing+=w.bearingDelta||0,f.pitch+=w.pitchDelta||0,w.panDelta&&f.pan._add(w.panDelta),w.around&&(f.around=w.around),w.pinchAround&&(f.pinchAround=w.pinchAround);const b=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(f.pan.mag()){const w=Hc(f.pan.mag(),b,o.e({},Uf,l||{}));_.offset=f.pan.mult(w.amount/f.pan.mag()),_.center=this._map.transform.center,jc(_,w)}if(f.zoom){const w=Hc(f.zoom,b,n1);_.zoom=this._map.transform.zoom+w.amount,jc(_,w)}if(f.bearing){const w=Hc(f.bearing,b,Iy);_.bearing=this._map.transform.bearing+o.ac(w.amount,-179,179),jc(_,w)}if(f.pitch){const w=Hc(f.pitch,b,Au);_.pitch=this._map.transform.pitch+w.amount,jc(_,w)}if(_.zoom||_.bearing){const w=f.pinchAround===void 0?f.around:f.pinchAround;_.around=w?this._map.unproject(w):this._map.getCenter()}return this.clear(),o.e(_,{noMoveStart:!0})}}function jc(E,l){(!E.duration||E.duration<l.duration)&&(E.duration=l.duration,E.easing=l.easing)}function Hc(E,l,f){const{maxSpeed:b,linearity:_,deceleration:w}=f,M=o.ac(E*_/(l/1e3),-b,b),P=Math.abs(M)/(w*_);return{easing:f.easing,duration:1e3*P,amount:M*(P/2)}}class Xr extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,f,b,_={}){const w=k.mousePos(f.getCanvas(),b),M=f.unproject(w);super(l,o.e({point:w,lngLat:M,originalEvent:b},_)),this._defaultPrevented=!1,this.target=f}}class Ta extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,f,b){const _=l==="touchend"?b.changedTouches:b.touches,w=k.touchPos(f.getCanvasContainer(),_),M=w.map(R=>f.unproject(R)),P=w.reduce((R,z,$,j)=>R.add(z.div(j.length)),new o.P(0,0));super(l,{points:w,point:P,lngLats:M,lngLat:f.unproject(P),originalEvent:b}),this._defaultPrevented=!1}}class Py extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,f,b){super(l,{originalEvent:b}),this._defaultPrevented=!1}}class Ny{constructor(l,f){this._map=l,this._clickTolerance=f.clickTolerance}reset(){delete this._mousedownPos}wheel(l){return this._firePreventable(new Py(l.type,this._map,l))}mousedown(l,f){return this._mousedownPos=f,this._firePreventable(new Xr(l.type,this._map,l))}mouseup(l){this._map.fire(new Xr(l.type,this._map,l))}click(l,f){this._mousedownPos&&this._mousedownPos.dist(f)>=this._clickTolerance||this._map.fire(new Xr(l.type,this._map,l))}dblclick(l){return this._firePreventable(new Xr(l.type,this._map,l))}mouseover(l){this._map.fire(new Xr(l.type,this._map,l))}mouseout(l){this._map.fire(new Xr(l.type,this._map,l))}touchstart(l){return this._firePreventable(new Ta(l.type,this._map,l))}touchmove(l){this._map.fire(new Ta(l.type,this._map,l))}touchend(l){this._map.fire(new Ta(l.type,this._map,l))}touchcancel(l){this._map.fire(new Ta(l.type,this._map,l))}_firePreventable(l){if(this._map.fire(l),l.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class mr{constructor(l){this._map=l}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(l){this._map.fire(new Xr(l.type,this._map,l))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Xr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(l){this._delayContextMenu?this._contextMenuEvent=l:this._ignoreContextMenu||this._map.fire(new Xr(l.type,this._map,l)),this._map.listens("contextmenu")&&l.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ss{constructor(l){this._map=l}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(l){return this.transform.pointLocation(o.P.convert(l),this._map.terrain)}}class ji{constructor(l,f){this._map=l,this._tr=new Ss(l),this._el=l.getCanvasContainer(),this._container=l.getContainer(),this._clickTolerance=f.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(l,f){this.isEnabled()&&l.shiftKey&&l.button===0&&(k.disableDrag(),this._startPos=this._lastPos=f,this._active=!0)}mousemoveWindow(l,f){if(!this._active)return;const b=f;if(this._lastPos.equals(b)||!this._box&&b.dist(this._startPos)<this._clickTolerance)return;const _=this._startPos;this._lastPos=b,this._box||(this._box=k.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",l));const w=Math.min(_.x,b.x),M=Math.max(_.x,b.x),P=Math.min(_.y,b.y),R=Math.max(_.y,b.y);k.setTransform(this._box,`translate(${w}px,${P}px)`),this._box.style.width=M-w+"px",this._box.style.height=R-P+"px"}mouseupWindow(l,f){if(!this._active||l.button!==0)return;const b=this._startPos,_=f;if(this.reset(),k.suppressClick(),b.x!==_.x||b.y!==_.y)return this._map.fire(new o.k("boxzoomend",{originalEvent:l})),{cameraAnimation:w=>w.fitScreenCoordinates(b,_,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",l)}keydown(l){this._active&&l.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",l))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(k.remove(this._box),this._box=null),k.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(l,f){return this._map.fire(new o.k(l,{originalEvent:f}))}}function Uc(E,l){if(E.length!==l.length)throw new Error(`The number of touches and points are not equal - touches ${E.length}, points ${l.length}`);const f={};for(let b=0;b<E.length;b++)f[E[b].identifier]=l[b];return f}class qf{constructor(l){this.reset(),this.numTouches=l.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(l,f,b){(this.centroid||b.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=l.timeStamp),b.length===this.numTouches&&(this.centroid=function(_){const w=new o.P(0,0);for(const M of _)w._add(M);return w.div(_.length)}(f),this.touches=Uc(b,f)))}touchmove(l,f,b){if(this.aborted||!this.centroid)return;const _=Uc(b,f);for(const w in this.touches){const M=_[w];(!M||M.dist(this.touches[w])>30)&&(this.aborted=!0)}}touchend(l,f,b){if((!this.centroid||l.timeStamp-this.startTime>500)&&(this.aborted=!0),b.length===0){const _=!this.aborted&&this.centroid;if(this.reset(),_)return _}}}class Mu{constructor(l){this.singleTap=new qf(l),this.numTaps=l.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(l,f,b){this.singleTap.touchstart(l,f,b)}touchmove(l,f,b){this.singleTap.touchmove(l,f,b)}touchend(l,f,b){const _=this.singleTap.touchend(l,f,b);if(_){const w=l.timeStamp-this.lastTime<500,M=!this.lastTap||this.lastTap.dist(_)<30;if(w&&M||this.reset(),this.count++,this.lastTime=l.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Al{constructor(l){this._tr=new Ss(l),this._zoomIn=new Mu({numTouches:1,numTaps:2}),this._zoomOut=new Mu({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(l,f,b){this._zoomIn.touchstart(l,f,b),this._zoomOut.touchstart(l,f,b)}touchmove(l,f,b){this._zoomIn.touchmove(l,f,b),this._zoomOut.touchmove(l,f,b)}touchend(l,f,b){const _=this._zoomIn.touchend(l,f,b),w=this._zoomOut.touchend(l,f,b),M=this._tr;return _?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom+1,around:M.unproject(_)},{originalEvent:l})}):w?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom-1,around:M.unproject(w)},{originalEvent:l})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class fo{constructor(l){this._enabled=!!l.enable,this._moveStateManager=l.moveStateManager,this._clickTolerance=l.clickTolerance||1,this._moveFunction=l.move,this._activateOnStart=!!l.activateOnStart,l.assignEvents(this),this.reset()}reset(l){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(l)}_move(...l){const f=this._moveFunction(...l);if(f.bearingDelta||f.pitchDelta||f.around||f.panDelta)return this._active=!0,f}dragStart(l,f){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(l)&&(this._moveStateManager.startMove(l),this._lastPoint=f.length?f[0]:f,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(l,f){if(!this.isEnabled())return;const b=this._lastPoint;if(!b)return;if(l.preventDefault(),!this._moveStateManager.isValidMoveEvent(l))return void this.reset(l);const _=f.length?f[0]:f;return!this._moved&&_.dist(b)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=_,this._move(b,_))}dragEnd(l){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(l)&&(this._moved&&k.suppressClick(),this.reset(l))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const Gf={0:1,2:2};class Du{constructor(l){this._correctEvent=l.checkCorrectEvent}startMove(l){const f=k.mouseButton(l);this._eventButton=f}endMove(l){delete this._eventButton}isValidStartEvent(l){return this._correctEvent(l)}isValidMoveEvent(l){return!function(f,b){const _=Gf[b];return f.buttons===void 0||(f.buttons&_)!==_}(l,this._eventButton)}isValidEndEvent(l){return k.mouseButton(l)===this._eventButton}}class Yf{constructor(){this._firstTouch=void 0}_isOneFingerTouch(l){return l.targetTouches.length===1}_isSameTouchEvent(l){return l.targetTouches[0].identifier===this._firstTouch}startMove(l){this._firstTouch=l.targetTouches[0].identifier}endMove(l){delete this._firstTouch}isValidStartEvent(l){return this._isOneFingerTouch(l)}isValidMoveEvent(l){return this._isOneFingerTouch(l)&&this._isSameTouchEvent(l)}isValidEndEvent(l){return this._isOneFingerTouch(l)&&this._isSameTouchEvent(l)}}const Iu=E=>{E.mousedown=E.dragStart,E.mousemoveWindow=E.dragMove,E.mouseup=E.dragEnd,E.contextmenu=l=>{l.preventDefault()}},Zf=({enable:E,clickTolerance:l,bearingDegreesPerPixelMoved:f=.8})=>{const b=new Du({checkCorrectEvent:_=>k.mouseButton(_)===0&&_.ctrlKey||k.mouseButton(_)===2});return new fo({clickTolerance:l,move:(_,w)=>({bearingDelta:(w.x-_.x)*f}),moveStateManager:b,enable:E,assignEvents:Iu})},Xf=({enable:E,clickTolerance:l,pitchDegreesPerPixelMoved:f=-.5})=>{const b=new Du({checkCorrectEvent:_=>k.mouseButton(_)===0&&_.ctrlKey||k.mouseButton(_)===2});return new fo({clickTolerance:l,move:(_,w)=>({pitchDelta:(w.y-_.y)*f}),moveStateManager:b,enable:E,assignEvents:Iu})};class Aa{constructor(l,f){this._clickTolerance=l.clickTolerance||1,this._map=f,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o.P(0,0)}_shouldBePrevented(l){return l<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(l,f,b){return this._calculateTransform(l,f,b)}touchmove(l,f,b){if(this._active){if(!this._shouldBePrevented(b.length))return l.preventDefault(),this._calculateTransform(l,f,b);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",l)}}touchend(l,f,b){this._calculateTransform(l,f,b),this._active&&this._shouldBePrevented(b.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(l,f,b){b.length>0&&(this._active=!0);const _=Uc(b,f),w=new o.P(0,0),M=new o.P(0,0);let P=0;for(const z in _){const $=_[z],j=this._touches[z];j&&(w._add($),M._add($.sub(j)),P++,_[z]=$)}if(this._touches=_,this._shouldBePrevented(P)||!M.mag())return;const R=M.div(P);return this._sum._add(R),this._sum.mag()<this._clickTolerance?void 0:{around:w.div(P),panDelta:R}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Pu{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(l,f,b){this._firstTwoTouches||b.length<2||(this._firstTwoTouches=[b[0].identifier,b[1].identifier],this._start([f[0],f[1]]))}touchmove(l,f,b){if(!this._firstTwoTouches)return;l.preventDefault();const[_,w]=this._firstTwoTouches,M=Wc(b,f,_),P=Wc(b,f,w);if(!M||!P)return;const R=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],R,l)}touchend(l,f,b){if(!this._firstTwoTouches)return;const[_,w]=this._firstTwoTouches,M=Wc(b,f,_),P=Wc(b,f,w);M&&P||(this._active&&k.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(l){this._enabled=!0,this._aroundCenter=!!l&&l.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Wc(E,l,f){for(let b=0;b<E.length;b++)if(E[b].identifier===f)return l[b]}function Kf(E,l){return Math.log(E/l)/Math.LN2}class Jf extends Pu{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(l){this._startDistance=this._distance=l[0].dist(l[1])}_move(l,f){const b=this._distance;if(this._distance=l[0].dist(l[1]),this._active||!(Math.abs(Kf(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Kf(this._distance,b),pinchAround:f}}}function Qf(E,l){return 180*E.angleWith(l)/Math.PI}class ep extends Pu{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(l){this._startVector=this._vector=l[0].sub(l[1]),this._minDiameter=l[0].dist(l[1])}_move(l,f,b){const _=this._vector;if(this._vector=l[0].sub(l[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Qf(this._vector,_),pinchAround:f}}_isBelowThreshold(l){this._minDiameter=Math.min(this._minDiameter,l.mag());const f=25/(Math.PI*this._minDiameter)*360,b=Qf(l,this._startVector);return Math.abs(b)<f}}function Nu(E){return Math.abs(E.y)>Math.abs(E.x)}class qc extends Pu{constructor(l){super(),this._currentTouchCount=0,this._map=l}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(l,f,b){super.touchstart(l,f,b),this._currentTouchCount=b.length}_start(l){this._lastPoints=l,Nu(l[0].sub(l[1]))&&(this._valid=!1)}_move(l,f,b){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const _=l[0].sub(this._lastPoints[0]),w=l[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(_,w,b.timeStamp),this._valid?(this._lastPoints=l,this._active=!0,{pitchDelta:(_.y+w.y)/2*-.5}):void 0}gestureBeginsVertically(l,f,b){if(this._valid!==void 0)return this._valid;const _=l.mag()>=2,w=f.mag()>=2;if(!_&&!w)return;if(!_||!w)return this._firstMove===void 0&&(this._firstMove=b),b-this._firstMove<100&&void 0;const M=l.y>0==f.y>0;return Nu(l)&&Nu(f)&&M}}const Ry={panStep:100,bearingStep:15,pitchStep:10};class is{constructor(l){this._tr=new Ss(l);const f=Ry;this._panStep=f.panStep,this._bearingStep=f.bearingStep,this._pitchStep=f.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(l){if(l.altKey||l.ctrlKey||l.metaKey)return;let f=0,b=0,_=0,w=0,M=0;switch(l.keyCode){case 61:case 107:case 171:case 187:f=1;break;case 189:case 109:case 173:f=-1;break;case 37:l.shiftKey?b=-1:(l.preventDefault(),w=-1);break;case 39:l.shiftKey?b=1:(l.preventDefault(),w=1);break;case 38:l.shiftKey?_=1:(l.preventDefault(),M=-1);break;case 40:l.shiftKey?_=-1:(l.preventDefault(),M=1);break;default:return}return this._rotationDisabled&&(b=0,_=0),{cameraAnimation:P=>{const R=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:Xs,zoom:f?Math.round(R.zoom)+f*(l.shiftKey?2:1):R.zoom,bearing:R.bearing+b*this._bearingStep,pitch:R.pitch+_*this._pitchStep,offset:[-w*this._panStep,-M*this._panStep],center:R.center},{originalEvent:l})}}}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 Xs(E){return E*(2-E)}const tp=4.000244140625;class Cs{constructor(l,f){this._onTimeout=b=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(b)},this._map=l,this._tr=new Ss(l),this._triggerRenderFrame=f,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(l){this._defaultZoomRate=l}setWheelZoomRate(l){this._wheelZoomRate=l}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(l){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!l&&l.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(l){return!!this._map.cooperativeGestures.isEnabled()&&!(l.ctrlKey||this._map.cooperativeGestures.isBypassed(l))}wheel(l){if(!this.isEnabled())return;if(this._shouldBePrevented(l))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",l);let f=l.deltaMode===WheelEvent.DOM_DELTA_LINE?40*l.deltaY:l.deltaY;const b=v.now(),_=b-(this._lastWheelEventTime||0);this._lastWheelEventTime=b,f!==0&&f%tp==0?this._type="wheel":f!==0&&Math.abs(f)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=f,this._timeout=setTimeout(this._onTimeout,40,l)):this._type||(this._type=Math.abs(_*f)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,f+=this._lastValue)),l.shiftKey&&f&&(f/=4),this._type&&(this._lastWheelEvent=l,this._delta-=f,this._active||this._start(l)),l.preventDefault()}_start(l){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const f=k.mousePos(this._map.getCanvas(),l),b=this._tr;this._around=f.y>b.transform.height/2-b.transform.getHorizon()?o.N.convert(this._aroundCenter?b.center:b.unproject(f)):o.N.convert(b.center),this._aroundPoint=b.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const l=this._tr.transform;if(this._delta!==0){const R=this._type==="wheel"&&Math.abs(this._delta)>tp?this._wheelZoomRate:this._defaultZoomRate;let z=2/(1+Math.exp(-Math.abs(this._delta*R)));this._delta<0&&z!==0&&(z=1/z);const $=typeof this._targetZoom=="number"?l.zoomScale(this._targetZoom):l.scale;this._targetZoom=Math.min(l.maxZoom,Math.max(l.minZoom,l.scaleZoom($*z))),this._type==="wheel"&&(this._startZoom=l.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const f=typeof this._targetZoom=="number"?this._targetZoom:l.zoom,b=this._startZoom,_=this._easing;let w,M=!1;const P=v.now()-this._lastWheelEventTime;if(this._type==="wheel"&&b&&_&&P){const R=Math.min(P/200,1),z=_(R);w=o.y.number(b,f,z),R<1?this._frameId||(this._frameId=!0):M=!0}else w=f,M=!0;return this._active=!0,M&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!M,zoomDelta:w-l.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(l){let f=o.b9;if(this._prevEase){const b=this._prevEase,_=(v.now()-b.start)/b.duration,w=b.easing(_+.01)-b.easing(_),M=.27/Math.sqrt(w*w+1e-4)*.01,P=Math.sqrt(.0729-M*M);f=o.b8(M,P,.25,1)}return this._prevEase={start:v.now(),duration:l,easing:f},f}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ma{constructor(l,f){this._clickZoom=l,this._tapZoom=f}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 r1{constructor(l){this._tr=new Ss(l),this.reset()}reset(){this._active=!1}dblclick(l,f){return l.preventDefault(),{cameraAnimation:b=>{b.easeTo({duration:300,zoom:this._tr.zoom+(l.shiftKey?-1:1),around:this._tr.unproject(f)},{originalEvent:l})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class i1{constructor(){this._tap=new Mu({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(l,f,b){if(!this._swipePoint)if(this._tapTime){const _=f[0],w=l.timeStamp-this._tapTime<500,M=this._tapPoint.dist(_)<30;w&&M?b.length>0&&(this._swipePoint=_,this._swipeTouch=b[0].identifier):this.reset()}else this._tap.touchstart(l,f,b)}touchmove(l,f,b){if(this._tapTime){if(this._swipePoint){if(b[0].identifier!==this._swipeTouch)return;const _=f[0],w=_.y-this._swipePoint.y;return this._swipePoint=_,l.preventDefault(),this._active=!0,{zoomDelta:w/128}}}else this._tap.touchmove(l,f,b)}touchend(l,f,b){if(this._tapTime)this._swipePoint&&b.length===0&&this.reset();else{const _=this._tap.touchend(l,f,b);_&&(this._tapTime=l.timeStamp,this._tapPoint=_)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Oy{constructor(l,f,b){this._el=l,this._mousePan=f,this._touchPan=b}enable(l){this._inertiaOptions=l||{},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 By{constructor(l,f,b){this._pitchWithRotate=l.pitchWithRotate,this._mouseRotate=f,this._mousePitch=b}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(l,f,b,_){this._el=l,this._touchZoom=f,this._touchRotate=b,this._tapDragZoom=_,this._rotationDisabled=!1,this._enabled=!0}enable(l){this._touchZoom.enable(l),this._rotationDisabled||this._touchRotate.enable(l),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 Ml{constructor(l,f){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=l,this._options=f,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const l=this._map.getCanvasContainer();l.classList.add("maplibregl-cooperative-gestures"),this._container=k.create("div","maplibregl-cooperative-gesture-screen",l);let f=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(f=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const b=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),_=document.createElement("div");_.className="maplibregl-desktop-message",_.textContent=f,this._container.appendChild(_);const w=document.createElement("div");w.className="maplibregl-mobile-message",w.textContent=b,this._container.appendChild(w),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(k.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(l){return l[this._bypassKey]}notifyGestureBlocked(l,f){this._enabled&&(this._map.fire(new o.k("cooperativegestureprevented",{gestureType:l,originalEvent:f})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const ss=E=>E.zoom||E.drag||E.pitch||E.rotate;class gt extends o.k{}function Ru(E){return E.panDelta&&E.panDelta.mag()||E.zoomDelta||E.bearingDelta||E.pitchDelta}class rp{constructor(l,f){this.handleWindowEvent=_=>{this.handleEvent(_,`${_.type}Window`)},this.handleEvent=(_,w)=>{if(_.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const M=_.type==="renderFrame"?void 0:_,P={needsRenderFrame:!1},R={},z={},$=_.touches,j=$?this._getMapTouches($):void 0,X=j?k.touchPos(this._map.getCanvas(),j):k.mousePos(this._map.getCanvas(),_);for(const{handlerName:se,handler:le,allowed:de}of this._handlers){if(!le.isEnabled())continue;let pe;this._blockedByActive(z,de,se)?le.reset():le[w||_.type]&&(pe=le[w||_.type](_,X,j),this.mergeHandlerResult(P,R,pe,se,M),pe&&pe.needsRenderFrame&&this._triggerRenderFrame()),(pe||le.isActive())&&(z[se]=le)}const ee={};for(const se in this._previousActiveHandlers)z[se]||(ee[se]=M);this._previousActiveHandlers=z,(Object.keys(ee).length||Ru(P))&&(this._changes.push([P,R,ee]),this._triggerRenderFrame()),(Object.keys(z).length||Ru(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:te}=P;te&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],te(this._map))},this._map=l,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wf(l),this._bearingSnap=f.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(f);const b=this._el;this._listeners=[[b,"touchstart",{passive:!0}],[b,"touchmove",{passive:!1}],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1}],[b,"keyup",void 0],[b,"wheel",{passive:!1}],[b,"contextmenu",void 0],[window,"blur",void 0]];for(const[_,w,M]of this._listeners)k.addEventListener(_,w,_===document?this.handleWindowEvent:this.handleEvent,M)}destroy(){for(const[l,f,b]of this._listeners)k.removeEventListener(l,f,l===document?this.handleWindowEvent:this.handleEvent,b)}_addDefaultHandlers(l){const f=this._map,b=f.getCanvasContainer();this._add("mapEvent",new Ny(f,l));const _=f.boxZoom=new ji(f,l);this._add("boxZoom",_),l.interactive&&l.boxZoom&&_.enable();const w=f.cooperativeGestures=new Ml(f,l.cooperativeGestures);this._add("cooperativeGestures",w),l.cooperativeGestures&&w.enable();const M=new Al(f),P=new r1(f);f.doubleClickZoom=new Ma(P,M),this._add("tapZoom",M),this._add("clickZoom",P),l.interactive&&l.doubleClickZoom&&f.doubleClickZoom.enable();const R=new i1;this._add("tapDragZoom",R);const z=f.touchPitch=new qc(f);this._add("touchPitch",z),l.interactive&&l.touchPitch&&f.touchPitch.enable(l.touchPitch);const $=Zf(l),j=Xf(l);f.dragRotate=new By(l,$,j),this._add("mouseRotate",$,["mousePitch"]),this._add("mousePitch",j,["mouseRotate"]),l.interactive&&l.dragRotate&&f.dragRotate.enable();const X=(({enable:pe,clickTolerance:ie})=>{const _e=new Du({checkCorrectEvent:ve=>k.mouseButton(ve)===0&&!ve.ctrlKey});return new fo({clickTolerance:ie,move:(ve,Ce)=>({around:Ce,panDelta:Ce.sub(ve)}),activateOnStart:!0,moveStateManager:_e,enable:pe,assignEvents:Iu})})(l),ee=new Aa(l,f);f.dragPan=new Oy(b,X,ee),this._add("mousePan",X),this._add("touchPan",ee,["touchZoom","touchRotate"]),l.interactive&&l.dragPan&&f.dragPan.enable(l.dragPan);const te=new ep,se=new Jf;f.touchZoomRotate=new np(b,se,te,R),this._add("touchRotate",te,["touchPan","touchZoom"]),this._add("touchZoom",se,["touchPan","touchRotate"]),l.interactive&&l.touchZoomRotate&&f.touchZoomRotate.enable(l.touchZoomRotate);const le=f.scrollZoom=new Cs(f,()=>this._triggerRenderFrame());this._add("scrollZoom",le,["mousePan"]),l.interactive&&l.scrollZoom&&f.scrollZoom.enable(l.scrollZoom);const de=f.keyboard=new is(f);this._add("keyboard",de),l.interactive&&l.keyboard&&f.keyboard.enable(),this._add("blockableMapEvent",new mr(f))}_add(l,f,b){this._handlers.push({handlerName:l,handler:f,allowed:b}),this._handlersById[l]=f}stop(l){if(!this._updatingCamera){for(const{handler:f}of this._handlers)f.reset();this._inertia.clear(),this._fireEvents({},{},l),this._changes=[]}}isActive(){for(const{handler:l}of this._handlers)if(l.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ss(this._eventsInProgress)||this.isZooming()}_blockedByActive(l,f,b){for(const _ in l)if(_!==b&&(!f||f.indexOf(_)<0))return!0;return!1}_getMapTouches(l){const f=[];for(const b of l)this._el.contains(b.target)&&f.push(b);return f}mergeHandlerResult(l,f,b,_,w){if(!b)return;o.e(l,b);const M={handlerName:_,originalEvent:b.originalEvent||w};b.zoomDelta!==void 0&&(f.zoom=M),b.panDelta!==void 0&&(f.drag=M),b.pitchDelta!==void 0&&(f.pitch=M),b.bearingDelta!==void 0&&(f.rotate=M)}_applyChanges(){const l={},f={},b={};for(const[_,w,M]of this._changes)_.panDelta&&(l.panDelta=(l.panDelta||new o.P(0,0))._add(_.panDelta)),_.zoomDelta&&(l.zoomDelta=(l.zoomDelta||0)+_.zoomDelta),_.bearingDelta&&(l.bearingDelta=(l.bearingDelta||0)+_.bearingDelta),_.pitchDelta&&(l.pitchDelta=(l.pitchDelta||0)+_.pitchDelta),_.around!==void 0&&(l.around=_.around),_.pinchAround!==void 0&&(l.pinchAround=_.pinchAround),_.noInertia&&(l.noInertia=_.noInertia),o.e(f,w),o.e(b,M);this._updateMapTransform(l,f,b),this._changes=[]}_updateMapTransform(l,f,b){const _=this._map,w=_._getTransformForUpdate(),M=_.terrain;if(!(Ru(l)||M&&this._terrainMovement))return this._fireEvents(f,b,!0);let{panDelta:P,zoomDelta:R,bearingDelta:z,pitchDelta:$,around:j,pinchAround:X}=l;X!==void 0&&(j=X),_._stop(!0),j=j||_.transform.centerPoint;const ee=w.pointLocation(P?j.sub(P):j);z&&(w.bearing+=z),$&&(w.pitch+=$),R&&(w.zoom+=R),M?this._terrainMovement||!f.drag&&!f.zoom?f.drag&&this._terrainMovement?w.center=w.pointLocation(w.centerPoint.sub(P)):w.setLocationAtPoint(ee,j):(this._terrainMovement=!0,this._map._elevationFreeze=!0,w.setLocationAtPoint(ee,j)):w.setLocationAtPoint(ee,j),_._applyUpdatedTransform(w),this._map._update(),l.noInertia||this._inertia.record(l),this._fireEvents(f,b,!0)}_fireEvents(l,f,b){const _=ss(this._eventsInProgress),w=ss(l),M={};for(const j in l){const{originalEvent:X}=l[j];this._eventsInProgress[j]||(M[`${j}start`]=X),this._eventsInProgress[j]=l[j]}!_&&w&&this._fireEvent("movestart",w.originalEvent);for(const j in M)this._fireEvent(j,M[j]);w&&this._fireEvent("move",w.originalEvent);for(const j in l){const{originalEvent:X}=l[j];this._fireEvent(j,X)}const P={};let R;for(const j in this._eventsInProgress){const{handlerName:X,originalEvent:ee}=this._eventsInProgress[j];this._handlersById[X].isActive()||(delete this._eventsInProgress[j],R=f[X]||ee,P[`${j}end`]=R)}for(const j in P)this._fireEvent(j,P[j]);const z=ss(this._eventsInProgress),$=(_||w)&&!z;if($&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const j=this._map._getTransformForUpdate();j.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(j)}if(b&&$){this._updatingCamera=!0;const j=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),X=ee=>ee!==0&&-this._bearingSnap<ee&&ee<this._bearingSnap;!j||!j.essential&&v.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:R})),X(this._map.getBearing())&&this._map.resetNorth()):(X(j.bearing||this._map.getBearing())&&(j.bearing=0),j.freezeElevation=!0,this._map.easeTo(j,{originalEvent:R})),this._updatingCamera=!1}}_fireEvent(l,f){this._map.fire(new o.k(l,f?{originalEvent:f}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(l=>{delete this._frameId,this.handleEvent(new gt("renderFrame",{timeStamp:l})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Vy extends o.E{constructor(l,f){super(),this._renderFrameCallback=()=>{const b=Math.min((v.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=l,this._bearingSnap=f.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.N(this.transform.center.lng,this.transform.center.lat)}setCenter(l,f){return this.jumpTo({center:l},f)}panBy(l,f,b){return l=o.P.convert(l).mult(-1),this.panTo(this.transform.center,o.e({offset:l},f),b)}panTo(l,f,b){return this.easeTo(o.e({center:l},f),b)}getZoom(){return this.transform.zoom}setZoom(l,f){return this.jumpTo({zoom:l},f),this}zoomTo(l,f,b){return this.easeTo(o.e({zoom:l},f),b)}zoomIn(l,f){return this.zoomTo(this.getZoom()+1,l,f),this}zoomOut(l,f){return this.zoomTo(this.getZoom()-1,l,f),this}getBearing(){return this.transform.bearing}setBearing(l,f){return this.jumpTo({bearing:l},f),this}getPadding(){return this.transform.padding}setPadding(l,f){return this.jumpTo({padding:l},f),this}rotateTo(l,f,b){return this.easeTo(o.e({bearing:l},f),b)}resetNorth(l,f){return this.rotateTo(0,o.e({duration:1e3},l),f),this}resetNorthPitch(l,f){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},l),f),this}snapToNorth(l,f){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(l,f):this}getPitch(){return this.transform.pitch}setPitch(l,f){return this.jumpTo({pitch:l},f),this}cameraForBounds(l,f){l=Ae.convert(l).adjustAntiMeridian();const b=f&&f.bearing||0;return this._cameraForBoxAndBearing(l.getNorthWest(),l.getSouthEast(),b,f)}_cameraForBoxAndBearing(l,f,b,_){const w={top:0,bottom:0,right:0,left:0};if(typeof(_=o.e({padding:w,offset:[0,0],maxZoom:this.transform.maxZoom},_)).padding=="number"){const rt=_.padding;_.padding={top:rt,bottom:rt,right:rt,left:rt}}_.padding=o.e(w,_.padding);const M=this.transform,P=M.padding,R=new Ae(l,f),z=M.project(R.getNorthWest()),$=M.project(R.getNorthEast()),j=M.project(R.getSouthEast()),X=M.project(R.getSouthWest()),ee=o.ba(-b),te=z.rotate(ee),se=$.rotate(ee),le=j.rotate(ee),de=X.rotate(ee),pe=new o.P(Math.max(te.x,se.x,de.x,le.x),Math.max(te.y,se.y,de.y,le.y)),ie=new o.P(Math.min(te.x,se.x,de.x,le.x),Math.min(te.y,se.y,de.y,le.y)),_e=pe.sub(ie),ve=(M.width-(P.left+P.right+_.padding.left+_.padding.right))/_e.x,Ce=(M.height-(P.top+P.bottom+_.padding.top+_.padding.bottom))/_e.y;if(Ce<0||ve<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ze=Math.min(M.scaleZoom(M.scale*Math.min(ve,Ce)),_.maxZoom),Ze=o.P.convert(_.offset),ot=new o.P((_.padding.left-_.padding.right)/2,(_.padding.top-_.padding.bottom)/2).rotate(o.ba(b)),ut=Ze.add(ot).mult(M.scale/M.zoomScale(ze));return{center:M.unproject(z.add(j).div(2).sub(ut)),zoom:ze,bearing:b}}fitBounds(l,f,b){return this._fitInternal(this.cameraForBounds(l,f),f,b)}fitScreenCoordinates(l,f,b,_,w){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(l)),this.transform.pointLocation(o.P.convert(f)),b,_),_,w)}_fitInternal(l,f,b){return l?(delete(f=o.e(l,f)).padding,f.linear?this.easeTo(f,b):this.flyTo(f,b)):this}jumpTo(l,f){this.stop();const b=this._getTransformForUpdate();let _=!1,w=!1,M=!1;return"zoom"in l&&b.zoom!==+l.zoom&&(_=!0,b.zoom=+l.zoom),l.center!==void 0&&(b.center=o.N.convert(l.center)),"bearing"in l&&b.bearing!==+l.bearing&&(w=!0,b.bearing=+l.bearing),"pitch"in l&&b.pitch!==+l.pitch&&(M=!0,b.pitch=+l.pitch),l.padding==null||b.isPaddingEqual(l.padding)||(b.padding=l.padding),this._applyUpdatedTransform(b),this.fire(new o.k("movestart",f)).fire(new o.k("move",f)),_&&this.fire(new o.k("zoomstart",f)).fire(new o.k("zoom",f)).fire(new o.k("zoomend",f)),w&&this.fire(new o.k("rotatestart",f)).fire(new o.k("rotate",f)).fire(new o.k("rotateend",f)),M&&this.fire(new o.k("pitchstart",f)).fire(new o.k("pitch",f)).fire(new o.k("pitchend",f)),this.fire(new o.k("moveend",f))}calculateCameraOptionsFromTo(l,f,b,_=0){const w=o.Z.fromLngLat(l,f),M=o.Z.fromLngLat(b,_),P=M.x-w.x,R=M.y-w.y,z=M.z-w.z,$=Math.hypot(P,R,z);if($===0)throw new Error("Can't calculate camera options with same From and To");const j=Math.hypot(P,R),X=this.transform.scaleZoom(this.transform.cameraToCenterDistance/$/this.transform.tileSize),ee=180*Math.atan2(P,-R)/Math.PI;let te=180*Math.acos(j/$)/Math.PI;return te=z<0?90-te:90+te,{center:M.toLngLat(),zoom:X,pitch:te,bearing:ee}}easeTo(l,f){var b;this._stop(!1,l.easeId),((l=o.e({offset:[0,0],duration:500,easing:o.b9},l)).animate===!1||!l.essential&&v.prefersReducedMotion)&&(l.duration=0);const _=this._getTransformForUpdate(),w=_.zoom,M=_.bearing,P=_.pitch,R=_.padding,z="bearing"in l?this._normalizeBearing(l.bearing,M):M,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,X=o.P.convert(l.offset);let ee=_.centerPoint.add(X);const te=_.pointLocation(ee),{center:se,zoom:le}=_.getConstrained(o.N.convert(l.center||te),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(se,_);const de=_.project(te),pe=_.project(se).sub(de),ie=_.zoomScale(le-w);let _e,ve;l.around&&(_e=o.N.convert(l.around),ve=_.locationPoint(_e));const Ce={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||le!==w,this._rotating=this._rotating||M!==z,this._pitching=this._pitching||$!==P,this._padding=!_.isPaddingEqual(j),this._easeId=l.easeId,this._prepareEase(f,l.noMoveStart,Ce),this.terrain&&this._prepareElevation(se),this._ease(ze=>{if(this._zooming&&(_.zoom=o.y.number(w,le,ze)),this._rotating&&(_.bearing=o.y.number(M,z,ze)),this._pitching&&(_.pitch=o.y.number(P,$,ze)),this._padding&&(_.interpolatePadding(R,j,ze),ee=_.centerPoint.add(X)),this.terrain&&!l.freezeElevation&&this._updateElevation(ze),_e)_.setLocationAtPoint(_e,ve);else{const Ze=_.zoomScale(_.zoom-w),ot=le>w?Math.min(2,ie):Math.max(.5,ie),ut=Math.pow(ot,1-ze),rt=_.unproject(de.add(pe.mult(ze*ut)).mult(Ze));_.setLocationAtPoint(_.renderWorldCopies?rt.wrap():rt,ee)}this._applyUpdatedTransform(_),this._fireMoveEvents(f)},ze=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(f,ze)},l),this}_prepareEase(l,f,b={}){this._moving=!0,f||b.moving||this.fire(new o.k("movestart",l)),this._zooming&&!b.zooming&&this.fire(new o.k("zoomstart",l)),this._rotating&&!b.rotating&&this.fire(new o.k("rotatestart",l)),this._pitching&&!b.pitching&&this.fire(new o.k("pitchstart",l))}_prepareElevation(l){this._elevationCenter=l,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(l,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(l){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const f=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(l<1&&f!==this._elevationTarget){const b=this._elevationTarget-this._elevationStart;this._elevationStart+=l*(b-(f-(b*l+this._elevationStart))/(1-l)),this._elevationTarget=f}this.transform.elevation=o.y.number(this._elevationStart,this._elevationTarget,l)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(l){const f=l.getCameraPosition(),b=this.terrain.getElevationForLngLatZoom(f.lngLat,l.zoom);if(f.altitude<b){const _=this.calculateCameraOptionsFromTo(f.lngLat,b,l.center,l.elevation);return{pitch:_.pitch,zoom:_.zoom}}return{}}_applyUpdatedTransform(l){const f=[];if(this.terrain&&f.push(_=>this._elevateCameraIfInsideTerrain(_)),this.transformCameraUpdate&&f.push(_=>this.transformCameraUpdate(_)),!f.length)return;const b=l.clone();for(const _ of f){const w=b.clone(),{center:M,zoom:P,pitch:R,bearing:z,elevation:$}=_(w);M&&(w.center=M),P!==void 0&&(w.zoom=P),R!==void 0&&(w.pitch=R),z!==void 0&&(w.bearing=z),$!==void 0&&(w.elevation=$),b.apply(w)}this.transform.apply(b)}_fireMoveEvents(l){this.fire(new o.k("move",l)),this._zooming&&this.fire(new o.k("zoom",l)),this._rotating&&this.fire(new o.k("rotate",l)),this._pitching&&this.fire(new o.k("pitch",l))}_afterEase(l,f){if(this._easeId&&f&&this._easeId===f)return;delete this._easeId;const b=this._zooming,_=this._rotating,w=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,b&&this.fire(new o.k("zoomend",l)),_&&this.fire(new o.k("rotateend",l)),w&&this.fire(new o.k("pitchend",l)),this.fire(new o.k("moveend",l))}flyTo(l,f){var b;if(!l.essential&&v.prefersReducedMotion){const lt=o.M(l,["center","zoom","bearing","pitch","around"]);return this.jumpTo(lt,f)}this.stop(),l=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b9},l);const _=this._getTransformForUpdate(),w=_.zoom,M=_.bearing,P=_.pitch,R=_.padding,z="bearing"in l?this._normalizeBearing(l.bearing,M):M,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,X=o.P.convert(l.offset);let ee=_.centerPoint.add(X);const te=_.pointLocation(ee),{center:se,zoom:le}=_.getConstrained(o.N.convert(l.center||te),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(se,_);const de=_.zoomScale(le-w),pe=_.project(te),ie=_.project(se).sub(pe);let _e=l.curve;const ve=Math.max(_.width,_.height),Ce=ve/de,ze=ie.mag();if("minZoom"in l){const lt=o.ac(Math.min(l.minZoom,w,le),_.minZoom,_.maxZoom),Ft=ve/_.zoomScale(lt-w);_e=Math.sqrt(Ft/ze*2)}const Ze=_e*_e;function ot(lt){const Ft=(Ce*Ce-ve*ve+(lt?-1:1)*Ze*Ze*ze*ze)/(2*(lt?Ce:ve)*Ze*ze);return Math.log(Math.sqrt(Ft*Ft+1)-Ft)}function ut(lt){return(Math.exp(lt)-Math.exp(-lt))/2}function rt(lt){return(Math.exp(lt)+Math.exp(-lt))/2}const nt=ot(!1);let vt=function(lt){return rt(nt)/rt(nt+_e*lt)},Ht=function(lt){return ve*((rt(nt)*(ut(Ft=nt+_e*lt)/rt(Ft))-ut(nt))/Ze)/ze;var Ft},it=(ot(!0)-nt)/_e;if(Math.abs(ze)<1e-6||!isFinite(it)){if(Math.abs(ve-Ce)<1e-6)return this.easeTo(l,f);const lt=Ce<ve?-1:1;it=Math.abs(Math.log(Ce/ve))/_e,Ht=()=>0,vt=Ft=>Math.exp(lt*_e*Ft)}return l.duration="duration"in l?+l.duration:1e3*it/("screenSpeed"in l?+l.screenSpeed/_e:+l.speed),l.maxDuration&&l.duration>l.maxDuration&&(l.duration=0),this._zooming=!0,this._rotating=M!==z,this._pitching=$!==P,this._padding=!_.isPaddingEqual(j),this._prepareEase(f,!1),this.terrain&&this._prepareElevation(se),this._ease(lt=>{const Ft=lt*it,Xn=1/vt(Ft);_.zoom=lt===1?le:w+_.scaleZoom(Xn),this._rotating&&(_.bearing=o.y.number(M,z,lt)),this._pitching&&(_.pitch=o.y.number(P,$,lt)),this._padding&&(_.interpolatePadding(R,j,lt),ee=_.centerPoint.add(X)),this.terrain&&!l.freezeElevation&&this._updateElevation(lt);const Jt=lt===1?se:_.unproject(pe.add(ie.mult(Ht(Ft))).mult(Xn));_.setLocationAtPoint(_.renderWorldCopies?Jt.wrap():Jt,ee),this._applyUpdatedTransform(_),this._fireMoveEvents(f)},()=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(f)},l),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(l,f){var b;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const _=this._onEaseEnd;delete this._onEaseEnd,_.call(this,f)}return l||(b=this.handlers)===null||b===void 0||b.stop(!1),this}_ease(l,f,b){b.animate===!1||b.duration===0?(l(1),f()):(this._easeStart=v.now(),this._easeOptions=b,this._onEaseFrame=l,this._onEaseEnd=f,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(l,f){l=o.b3(l,-180,180);const b=Math.abs(l-f);return Math.abs(l-360-f)<b&&(l-=360),Math.abs(l+360-f)<b&&(l+=360),l}_normalizeCenter(l,f){if(!f.renderWorldCopies||f.lngRange)return;const b=l.lng-f.center.lng;l.lng+=b>180?-360:b<-180?360:0}queryTerrainElevation(l){return this.terrain?this.terrain.getElevationForLngLatZoom(o.N.convert(l),this.transform.tileZoom)-this.transform.elevation:null}}const Dl={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Il{constructor(l=Dl){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=f=>{!f||f.sourceDataType!=="metadata"&&f.sourceDataType!=="visibility"&&f.dataType!=="style"&&f.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=l}getDefaultPosition(){return"bottom-right"}onAdd(l){return this._map=l,this._compact=this.options.compact,this._container=k.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=k.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=k.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(){k.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(l,f){const b=this._map._getUIString(`AttributionControl.${f}`);l.title=b,l.setAttribute("aria-label",b)}_updateAttributions(){if(!this._map.style)return;let l=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?l=l.concat(this.options.customAttribution.map(_=>typeof _!="string"?"":_)):typeof this.options.customAttribution=="string"&&l.push(this.options.customAttribution)),this._map.style.stylesheet){const _=this._map.style.stylesheet;this.styleOwner=_.owner,this.styleId=_.id}const f=this._map.style.sourceCaches;for(const _ in f){const w=f[_];if(w.used||w.usedForTerrain){const M=w.getSource();M.attribution&&l.indexOf(M.attribution)<0&&l.push(M.attribution)}}l=l.filter(_=>String(_).trim()),l.sort((_,w)=>_.length-w.length),l=l.filter((_,w)=>{for(let M=w+1;M<l.length;M++)if(l[M].indexOf(_)>=0)return!1;return!0});const b=l.join(" | ");b!==this._attribHTML&&(this._attribHTML=b,l.length?(this._innerContainer.innerHTML=b,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class ip{constructor(l={}){this._updateCompact=()=>{const f=this._container.children;if(f.length){const b=f[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&b.classList.add("maplibregl-compact"):b.classList.remove("maplibregl-compact")}},this.options=l}getDefaultPosition(){return"bottom-left"}onAdd(l){this._map=l,this._compact=this.options&&this.options.compact,this._container=k.create("div","maplibregl-ctrl");const f=k.create("a","maplibregl-ctrl-logo");return f.target="_blank",f.rel="noopener nofollow",f.href="https://maplibre.org/",f.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),f.setAttribute("rel","noopener nofollow"),this._container.appendChild(f),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){k.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class hn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(l){const f=++this._id;return this._queue.push({callback:l,id:f,cancelled:!1}),f}remove(l){const f=this._currentlyRunning,b=f?this._queue.concat(f):this._queue;for(const _ of b)if(_.id===l)return void(_.cancelled=!0)}run(l=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const f=this._currentlyRunning=this._queue;this._queue=[];for(const b of f)if(!b.cancelled&&(b.callback(l),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var sp=o.Y([{name:"a_pos3d",type:"Int16",components:3}]);class s1 extends o.E{constructor(l){super(),this.sourceCache=l,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,l.usedForTerrain=!0,l.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(l,f){this.sourceCache.update(l,f),this._renderableTilesKeys=[];const b={};for(const _ of l.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:f}))b[_.key]=!0,this._renderableTilesKeys.push(_.key),this._tiles[_.key]||(_.posMatrix=new Float64Array(16),o.aP(_.posMatrix,0,o.X,0,o.X,0,1),this._tiles[_.key]=new Vi(_,this.tileSize));for(const _ in this._tiles)b[_]||delete this._tiles[_]}freeRtt(l){for(const f in this._tiles){const b=this._tiles[f];(!l||b.tileID.equals(l)||b.tileID.isChildOf(l)||l.isChildOf(b.tileID))&&(b.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(l=>this.getTileByID(l))}getTileByID(l){return this._tiles[l]}getTerrainCoords(l){const f={};for(const b of this._renderableTilesKeys){const _=this._tiles[b].tileID;if(_.canonical.equals(l.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16),o.aP(w.posMatrix,0,o.X,0,o.X,0,1),f[b]=w}else if(_.canonical.isChildOf(l.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const M=_.canonical.z-l.canonical.z,P=_.canonical.x-(_.canonical.x>>M<<M),R=_.canonical.y-(_.canonical.y>>M<<M),z=o.X>>M;o.aP(w.posMatrix,0,z,0,z,0,1),o.J(w.posMatrix,w.posMatrix,[-P*z,-R*z,0]),f[b]=w}else if(l.canonical.isChildOf(_.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const M=l.canonical.z-_.canonical.z,P=l.canonical.x-(l.canonical.x>>M<<M),R=l.canonical.y-(l.canonical.y>>M<<M),z=o.X>>M;o.aP(w.posMatrix,0,o.X,0,o.X,0,1),o.J(w.posMatrix,w.posMatrix,[P*z,R*z,0]),o.K(w.posMatrix,w.posMatrix,[1/2**M,1/2**M,0]),f[b]=w}}return f}getSourceTile(l,f){const b=this.sourceCache._source;let _=l.overscaledZ-this.deltaZoom;if(_>b.maxzoom&&(_=b.maxzoom),_<b.minzoom)return null;this._sourceTileCache[l.key]||(this._sourceTileCache[l.key]=l.scaledTo(_).key);let w=this.sourceCache.getTileByID(this._sourceTileCache[l.key]);if((!w||!w.dem)&&f)for(;_>=b.minzoom&&(!w||!w.dem);)w=this.sourceCache.getTileByID(l.scaledTo(_--).key);return w}tilesAfterTime(l=Date.now()){return Object.values(this._tiles).filter(f=>f.timeAdded>=l)}}class op{constructor(l,f,b){this.painter=l,this.sourceCache=new s1(f),this.options=b,this.exaggeration=typeof b.exaggeration=="number"?b.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(l,f,b,_=o.X){var w;if(!(f>=0&&f<_&&b>=0&&b<_))return 0;const M=this.getTerrainData(l),P=(w=M.tile)===null||w===void 0?void 0:w.dem;if(!P)return 0;const R=function(te,se,le){var de=se[0],pe=se[1];return te[0]=le[0]*de+le[4]*pe+le[12],te[1]=le[1]*de+le[5]*pe+le[13],te}([],[f/_*o.X,b/_*o.X],M.u_terrain_matrix),z=[R[0]*P.dim,R[1]*P.dim],$=Math.floor(z[0]),j=Math.floor(z[1]),X=z[0]-$,ee=z[1]-j;return P.get($,j)*(1-X)*(1-ee)+P.get($+1,j)*X*(1-ee)+P.get($,j+1)*(1-X)*ee+P.get($+1,j+1)*X*ee}getElevationForLngLatZoom(l,f){if(!o.bb(f,l.wrap()))return 0;const{tileID:b,mercatorX:_,mercatorY:w}=this._getOverscaledTileIDFromLngLatZoom(l,f);return this.getElevation(b,_%o.X,w%o.X,o.X)}getElevation(l,f,b,_=o.X){return this.getDEMElevation(l,f,b,_)*this.exaggeration}getTerrainData(l){if(!this._emptyDemTexture){const _=this.painter.context,w=new o.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Le(_,w,_.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Le(_,new o.R({width:1,height:1}),_.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=o.an([])}const f=this.sourceCache.getSourceTile(l,!0);if(f&&f.dem&&(!f.demTexture||f.needsTerrainPrepare)){const _=this.painter.context;f.demTexture=this.painter.getTileTexture(f.dem.stride),f.demTexture?f.demTexture.update(f.dem.getPixels(),{premultiply:!1}):f.demTexture=new Le(_,f.dem.getPixels(),_.gl.RGBA,{premultiply:!1}),f.demTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),f.needsTerrainPrepare=!1}const b=f&&f+f.tileID.key+l.key;if(b&&!this._demMatrixCache[b]){const _=this.sourceCache.sourceCache._source.maxzoom;let w=l.canonical.z-f.tileID.canonical.z;l.overscaledZ>l.canonical.z&&(l.canonical.z>=_?w=l.canonical.z-_:o.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const M=l.canonical.x-(l.canonical.x>>w<<w),P=l.canonical.y-(l.canonical.y>>w<<w),R=o.bc(new Float64Array(16),[1/(o.X<<w),1/(o.X<<w),0]);o.J(R,R,[M*o.X,P*o.X,0]),this._demMatrixCache[l.key]={matrix:R,coord:l}}return{u_depth:2,u_terrain:3,u_terrain_dim:f&&f.dem&&f.dem.dim||1,u_terrain_matrix:b?this._demMatrixCache[l.key].matrix:this._emptyDemMatrix,u_terrain_unpack:f&&f.dem&&f.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(f&&f.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:f}}getFramebuffer(l){const f=this.painter,b=f.width/devicePixelRatio,_=f.height/devicePixelRatio;return!this._fbo||this._fbo.width===b&&this._fbo.height===_||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Le(f.context,{width:b,height:_,data:null},f.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(f.context.gl.NEAREST,f.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Le(f.context,{width:b,height:_,data:null},f.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(f.context.gl.NEAREST,f.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=f.context.createFramebuffer(b,_,!0,!1),this._fbo.depthAttachment.set(f.context.createRenderbuffer(f.context.gl.DEPTH_COMPONENT16,b,_))),this._fbo.colorAttachment.set(l==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const l=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const f=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let w=0,M=0;w<this._coordsTextureSize;w++)for(let P=0;P<this._coordsTextureSize;P++,M+=4)f[M+0]=255&P,f[M+1]=255&w,f[M+2]=P>>8<<4|w>>8,f[M+3]=0;const b=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(f.buffer)),_=new Le(l,b,l.gl.RGBA,{premultiply:!1});return _.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._coordsTexture=_,_}pointCoordinate(l){this.painter.maybeDrawDepthAndCoords(!0);const f=new Uint8Array(4),b=this.painter.context,_=b.gl,w=Math.round(l.x*this.painter.pixelRatio/devicePixelRatio),M=Math.round(l.y*this.painter.pixelRatio/devicePixelRatio),P=Math.round(this.painter.height/devicePixelRatio);b.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),_.readPixels(w,P-M-1,1,1,_.RGBA,_.UNSIGNED_BYTE,f),b.bindFramebuffer.set(null);const R=f[0]+(f[2]>>4<<8),z=f[1]+((15&f[2])<<8),$=this.coordsIndex[255-f[3]],j=$&&this.sourceCache.getTileByID($);if(!j)return null;const X=this._coordsTextureSize,ee=(1<<j.tileID.canonical.z)*X;return new o.Z((j.tileID.canonical.x*X+R)/ee+j.tileID.wrap,(j.tileID.canonical.y*X+z)/ee,this.getElevation(j.tileID,R,z,X))}depthAtPoint(l){const f=new Uint8Array(4),b=this.painter.context,_=b.gl;return b.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),_.readPixels(l.x,this.painter.height/devicePixelRatio-l.y-1,1,1,_.RGBA,_.UNSIGNED_BYTE,f),b.bindFramebuffer.set(null),(f[0]/16777216+f[1]/65536+f[2]/256+f[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const l=this.painter.context,f=new o.bd,b=new o.aY,_=this.meshSize,w=o.X/_,M=_*_;for(let j=0;j<=_;j++)for(let X=0;X<=_;X++)f.emplaceBack(X*w,j*w,0);for(let j=0;j<M;j+=_+1)for(let X=0;X<_;X++)b.emplaceBack(X+j,_+X+j+1,_+X+j+2),b.emplaceBack(X+j,_+X+j+2,X+j+1);const P=f.length,R=P+2*(_+1);for(const j of[0,1])for(let X=0;X<=_;X++)for(const ee of[0,1])f.emplaceBack(X*w,j*o.X,ee);for(let j=0;j<2*_;j+=2)b.emplaceBack(R+j,R+j+1,R+j+3),b.emplaceBack(R+j,R+j+3,R+j+2),b.emplaceBack(P+j,P+j+3,P+j+1),b.emplaceBack(P+j,P+j+2,P+j+3);const z=f.length,$=z+2*(_+1);for(const j of[0,1])for(let X=0;X<=_;X++)for(const ee of[0,1])f.emplaceBack(j*o.X,X*w,ee);for(let j=0;j<2*_;j+=2)b.emplaceBack(z+j,z+j+1,z+j+3),b.emplaceBack(z+j,z+j+3,z+j+2),b.emplaceBack($+j,$+j+3,$+j+1),b.emplaceBack($+j,$+j+2,$+j+3);return this._mesh=new Eu(l.createVertexBuffer(f,sp.members),l.createIndexBuffer(b),o.a0.simpleSegment(0,0,f.length,b.length)),this._mesh}getMeshFrameDelta(l){return 2*Math.PI*o.be/Math.pow(2,l)/5}getMinTileElevationForLngLatZoom(l,f){var b;const{tileID:_}=this._getOverscaledTileIDFromLngLatZoom(l,f);return(b=this.getMinMaxElevation(_).minElevation)!==null&&b!==void 0?b:0}getMinMaxElevation(l){const f=this.getTerrainData(l).tile,b={minElevation:null,maxElevation:null};return f&&f.dem&&(b.minElevation=f.dem.min*this.exaggeration,b.maxElevation=f.dem.max*this.exaggeration),b}_getOverscaledTileIDFromLngLatZoom(l,f){const b=o.Z.fromLngLat(l.wrap()),_=(1<<f)*o.X,w=b.x*_,M=b.y*_,P=Math.floor(w/o.X),R=Math.floor(M/o.X);return{tileID:new o.S(f,0,f,P,R),mercatorX:w,mercatorY:M}}}class o1{constructor(l,f,b){this._context=l,this._size=f,this._tileSize=b,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const l of this._objects)l.texture.destroy(),l.fbo.destroy()}_createObject(l){const f=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),b=new Le(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return b.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),f.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),f.colorAttachment.set(b.texture),{id:l,fbo:f,texture:b,stamp:-1,inUse:!1}}getObjectForId(l){return this._objects[l]}useObject(l){l.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(f=>l.id!==f),this._recentlyUsed.push(l.id)}stampObject(l){l.stamp=++this._stamp}getOrCreateFreeObject(){for(const f of this._recentlyUsed)if(!this._objects[f].inUse)return this._objects[f];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const l=this._createObject(this._objects.length);return this._objects.push(l),l}freeObject(l){l.inUse=!1}freeAllObjects(){for(const l of this._objects)this.freeObject(l)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(l=>!l.inUse)===!1}}const Pl={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class zy{constructor(l,f){this.painter=l,this.terrain=f,this.pool=new o1(l.context,30,f.sourceCache.tileSize*f.qualityFactor)}destruct(){this.pool.destruct()}getTexture(l){return this.pool.getObjectForId(l.rtt[this._stacks.length-1].id).texture}prepareForRender(l,f){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=l._order.filter(b=>!l._layers[b].isHidden(f)),this._coordsDescendingInv={};for(const b in l.sourceCaches){this._coordsDescendingInv[b]={};const _=l.sourceCaches[b].getVisibleCoordinates();for(const w of _){const M=this.terrain.sourceCache.getTerrainCoords(w);for(const P in M)this._coordsDescendingInv[b][P]||(this._coordsDescendingInv[b][P]=[]),this._coordsDescendingInv[b][P].push(M[P])}}this._coordsDescendingInvStr={};for(const b of l._order){const _=l._layers[b],w=_.source;if(Pl[_.type]&&!this._coordsDescendingInvStr[w]){this._coordsDescendingInvStr[w]={};for(const M in this._coordsDescendingInv[w])this._coordsDescendingInvStr[w][M]=this._coordsDescendingInv[w][M].map(P=>P.key).sort().join()}}for(const b of this._renderableTiles)for(const _ in this._coordsDescendingInvStr){const w=this._coordsDescendingInvStr[_][b.tileID.key];w&&w!==b.rttCoords[_]&&(b.rtt=[])}}renderLayer(l){if(l.isHidden(this.painter.transform.zoom))return!1;const f=l.type,b=this.painter,_=this._renderableLayerIds[this._renderableLayerIds.length-1]===l.id;if(Pl[f]&&(this._prevType&&Pl[this._prevType]||this._stacks.push([]),this._prevType=f,this._stacks[this._stacks.length-1].push(l.id),!_))return!0;if(Pl[this._prevType]||Pl[f]&&_){this._prevType=f;const w=this._stacks.length-1,M=this._stacks[w]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(Dy(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[w]){const z=this.pool.getObjectForId(P.rtt[w].id);if(z.stamp===P.rtt[w].stamp){this.pool.useObject(z);continue}}const R=this.pool.getOrCreateFreeObject();this.pool.useObject(R),this.pool.stampObject(R),P.rtt[w]={id:R.id,stamp:R.stamp},b.context.bindFramebuffer.set(R.fbo.framebuffer),b.context.clear({color:o.aM.transparent,stencil:0}),b.currentStencilSource=void 0;for(let z=0;z<M.length;z++){const $=b.style._layers[M[z]],j=$.source?this._coordsDescendingInv[$.source][P.tileID.key]:[P.tileID];b.context.viewport.set([0,0,R.fbo.width,R.fbo.height]),b._renderTileClippingMasks($,j),b.renderLayer(b,b.style.sourceCaches[$.source],$,j),$.source&&(P.rttCoords[$.source]=this._coordsDescendingInvStr[$.source][P.tileID.key])}}return Dy(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Pl[f]}return!1}}const ap={"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","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","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"},Ly=p,a1={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Dl,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:o.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},lp=E=>{E.touchstart=E.dragStart,E.touchmoveWindow=E.dragMove,E.touchend=E.dragEnd},l1={showCompass:!0,showZoom:!0,visualizePitch:!1};class c1{constructor(l,f,b=!1){this.mousedown=M=>{this.startMouse(o.e({},M,{ctrlKey:!0,preventDefault:()=>M.preventDefault()}),k.mousePos(this.element,M)),k.addEventListener(window,"mousemove",this.mousemove),k.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=M=>{this.moveMouse(M,k.mousePos(this.element,M))},this.mouseup=M=>{this.mouseRotate.dragEnd(M),this.mousePitch&&this.mousePitch.dragEnd(M),this.offTemp()},this.touchstart=M=>{M.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=k.touchPos(this.element,M.targetTouches)[0],this.startTouch(M,this._startPos),k.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),k.addEventListener(window,"touchend",this.touchend))},this.touchmove=M=>{M.targetTouches.length!==1?this.reset():(this._lastPos=k.touchPos(this.element,M.targetTouches)[0],this.moveTouch(M,this._lastPos))},this.touchend=M=>{M.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._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;const _=l.dragRotate._mouseRotate.getClickTolerance(),w=l.dragRotate._mousePitch.getClickTolerance();this.element=f,this.mouseRotate=Zf({clickTolerance:_,enable:!0}),this.touchRotate=(({enable:M,clickTolerance:P,bearingDegreesPerPixelMoved:R=.8})=>{const z=new Yf;return new fo({clickTolerance:P,move:($,j)=>({bearingDelta:(j.x-$.x)*R}),moveStateManager:z,enable:M,assignEvents:lp})})({clickTolerance:_,enable:!0}),this.map=l,b&&(this.mousePitch=Xf({clickTolerance:w,enable:!0}),this.touchPitch=(({enable:M,clickTolerance:P,pitchDegreesPerPixelMoved:R=-.5})=>{const z=new Yf;return new fo({clickTolerance:P,move:($,j)=>({pitchDelta:(j.y-$.y)*R}),moveStateManager:z,enable:M,assignEvents:lp})})({clickTolerance:w,enable:!0})),k.addEventListener(f,"mousedown",this.mousedown),k.addEventListener(f,"touchstart",this.touchstart,{passive:!1}),k.addEventListener(f,"touchcancel",this.reset)}startMouse(l,f){this.mouseRotate.dragStart(l,f),this.mousePitch&&this.mousePitch.dragStart(l,f),k.disableDrag()}startTouch(l,f){this.touchRotate.dragStart(l,f),this.touchPitch&&this.touchPitch.dragStart(l,f),k.disableDrag()}moveMouse(l,f){const b=this.map,{bearingDelta:_}=this.mouseRotate.dragMove(l,f)||{};if(_&&b.setBearing(b.getBearing()+_),this.mousePitch){const{pitchDelta:w}=this.mousePitch.dragMove(l,f)||{};w&&b.setPitch(b.getPitch()+w)}}moveTouch(l,f){const b=this.map,{bearingDelta:_}=this.touchRotate.dragMove(l,f)||{};if(_&&b.setBearing(b.getBearing()+_),this.touchPitch){const{pitchDelta:w}=this.touchPitch.dragMove(l,f)||{};w&&b.setPitch(b.getPitch()+w)}}off(){const l=this.element;k.removeEventListener(l,"mousedown",this.mousedown),k.removeEventListener(l,"touchstart",this.touchstart,{passive:!1}),k.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),k.removeEventListener(window,"touchend",this.touchend),k.removeEventListener(l,"touchcancel",this.reset),this.offTemp()}offTemp(){k.enableDrag(),k.removeEventListener(window,"mousemove",this.mousemove),k.removeEventListener(window,"mouseup",this.mouseup),k.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),k.removeEventListener(window,"touchend",this.touchend)}}let Hi;function Zn(E,l,f){const b=new o.N(E.lng,E.lat);if(E=new o.N(E.lng,E.lat),l){const _=new o.N(E.lng-360,E.lat),w=new o.N(E.lng+360,E.lat),M=f.locationPoint(E).distSqr(l);f.locationPoint(_).distSqr(l)<M?E=_:f.locationPoint(w).distSqr(l)<M&&(E=w)}for(;Math.abs(E.lng-f.center.lng)>180;){const _=f.locationPoint(E);if(_.x>=0&&_.y>=0&&_.x<=f.width&&_.y<=f.height)break;E.lng>f.center.lng?E.lng-=360:E.lng+=360}return E.lng!==b.lng&&f.locationPoint(E).y>f.height/2-f.getHorizon()?E:b}const Nl={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 Ou(E,l,f){const b=E.classList;for(const _ in Nl)b.remove(`maplibregl-${f}-anchor-${_}`);b.add(`maplibregl-${f}-anchor-${l}`)}class Bu extends o.E{constructor(l){if(super(),this._onKeyPress=f=>{const b=f.code,_=f.charCode||f.keyCode;b!=="Space"&&b!=="Enter"&&_!==32&&_!==13||this.togglePopup()},this._onMapClick=f=>{const b=f.originalEvent.target,_=this._element;this._popup&&(b===_||_.contains(b))&&this.togglePopup()},this._update=f=>{var b;if(!this._map)return;const _=this._map.loaded()&&!this._map.isMoving();((f==null?void 0:f.type)==="terrain"||(f==null?void 0:f.type)==="render"&&!_)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Zn(this._lngLat,this._flatPos,this._map.transform):(b=this._lngLat)===null||b===void 0?void 0:b.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 w="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?w=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(w=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let M="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?M="rotateX(0deg)":this._pitchAlignment==="map"&&(M=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||f&&f.type!=="moveend"||(this._pos=this._pos.round()),k.setTransform(this._element,`${Nl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${M} ${w}`),v.frameAsync(new AbortController).then(()=>{this._updateOpacity(f&&f.type==="moveend")}).catch(()=>{})},this._onMove=f=>{if(!this._isDragging){const b=this._clickTolerance||this._map._clickTolerance;this._isDragging=f.point.dist(this._pointerdownPos)>=b}this._isDragging&&(this._pos=f.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new o.k("dragstart"))),this.fire(new o.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new o.k("dragend")),this._state="inactive"},this._addDragHandler=f=>{this._element.contains(f.originalEvent.target)&&(f.preventDefault(),this._positionDelta=f.point.sub(this._pos).add(this._offset),this._pointerdownPos=f.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=l&&l.anchor||"center",this._color=l&&l.color||"#3FB1CE",this._scale=l&&l.scale||1,this._draggable=l&&l.draggable||!1,this._clickTolerance=l&&l.clickTolerance||0,this._subpixelPositioning=l&&l.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=l&&l.rotation||0,this._rotationAlignment=l&&l.rotationAlignment||"auto",this._pitchAlignment=l&&l.pitchAlignment&&l.pitchAlignment!=="auto"?l.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(l==null?void 0:l.opacity,l==null?void 0:l.opacityWhenCovered),l&&l.element)this._element=l.element,this._offset=o.P.convert(l&&l.offset||[0,0]);else{this._defaultMarker=!0,this._element=k.create("div");const f=k.createNS("http://www.w3.org/2000/svg","svg"),b=41,_=27;f.setAttributeNS(null,"display","block"),f.setAttributeNS(null,"height",`${b}px`),f.setAttributeNS(null,"width",`${_}px`),f.setAttributeNS(null,"viewBox",`0 0 ${_} ${b}`);const w=k.createNS("http://www.w3.org/2000/svg","g");w.setAttributeNS(null,"stroke","none"),w.setAttributeNS(null,"stroke-width","1"),w.setAttributeNS(null,"fill","none"),w.setAttributeNS(null,"fill-rule","evenodd");const M=k.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"fill-rule","nonzero");const P=k.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(3.0, 29.0)"),P.setAttributeNS(null,"fill","#000000");const R=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const de of R){const pe=k.createNS("http://www.w3.org/2000/svg","ellipse");pe.setAttributeNS(null,"opacity","0.04"),pe.setAttributeNS(null,"cx","10.5"),pe.setAttributeNS(null,"cy","5.80029008"),pe.setAttributeNS(null,"rx",de.rx),pe.setAttributeNS(null,"ry",de.ry),P.appendChild(pe)}const z=k.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"fill",this._color);const $=k.createNS("http://www.w3.org/2000/svg","path");$.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"),z.appendChild($);const j=k.createNS("http://www.w3.org/2000/svg","g");j.setAttributeNS(null,"opacity","0.25"),j.setAttributeNS(null,"fill","#000000");const X=k.createNS("http://www.w3.org/2000/svg","path");X.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"),j.appendChild(X);const ee=k.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"transform","translate(6.0, 7.0)"),ee.setAttributeNS(null,"fill","#FFFFFF");const te=k.createNS("http://www.w3.org/2000/svg","g");te.setAttributeNS(null,"transform","translate(8.0, 8.0)");const se=k.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#000000"),se.setAttributeNS(null,"opacity","0.25"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962");const le=k.createNS("http://www.w3.org/2000/svg","circle");le.setAttributeNS(null,"fill","#FFFFFF"),le.setAttributeNS(null,"cx","5.5"),le.setAttributeNS(null,"cy","5.5"),le.setAttributeNS(null,"r","5.4999962"),te.appendChild(se),te.appendChild(le),M.appendChild(P),M.appendChild(z),M.appendChild(j),M.appendChild(ee),M.appendChild(te),f.appendChild(M),f.setAttributeNS(null,"height",b*this._scale+"px"),f.setAttributeNS(null,"width",_*this._scale+"px"),this._element.appendChild(f),this._offset=o.P.convert(l&&l.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",f=>{f.preventDefault()}),this._element.addEventListener("mousedown",f=>{f.preventDefault()}),Ou(this._element,this._anchor,"marker"),l&&l.className)for(const f of l.className.split(" "))this._element.classList.add(f);this._popup=null}addTo(l){return this.remove(),this._map=l,this._element.setAttribute("aria-label",l._getUIString("Marker.Title")),l.getCanvasContainer().appendChild(this._element),l.on("move",this._update),l.on("moveend",this._update),l.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),k.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(l){return this._lngLat=o.N.convert(l),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(l){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),l){if(!("offset"in l.options)){const _=Math.abs(13.5)/Math.SQRT2;l.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[_,-1*(38.1-13.5+_)],"bottom-right":[-_,-1*(38.1-13.5+_)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=l,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(l){return this._subpixelPositioning=l,this}getPopup(){return this._popup}togglePopup(){const l=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:l?(l.isOpen()?l.remove():(l.setLngLat(this._lngLat),l.addTo(this._map)),this):this}_updateOpacity(l=!1){var f,b;if(!(!((f=this._map)===null||f===void 0)&&f.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(l)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const _=this._map,w=_.terrain.depthAtPoint(this._pos),M=_.terrain.getElevationForLngLatZoom(this._lngLat,_.transform.tileZoom);if(_.transform.lngLatToCameraDepth(this._lngLat,M)-w<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/_.transform._pixelPerMeter,R=Math.sin(_.getPitch()*Math.PI/180)*P,z=_.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),$=_.transform.lngLatToCameraDepth(this._lngLat,M+R)-z>.006;!((b=this._popup)===null||b===void 0)&&b.isOpen()&&$&&this._popup.remove(),this._element.style.opacity=$?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(l){return this._offset=o.P.convert(l),this._update(),this}addClassName(l){this._element.classList.add(l)}removeClassName(l){this._element.classList.remove(l)}toggleClassName(l){return this._element.classList.toggle(l)}setDraggable(l){return this._draggable=!!l,this._map&&(l?(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(l){return this._rotation=l||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(l){return this._rotationAlignment=l||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(l){return this._pitchAlignment=l&&l!=="auto"?l:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(l,f){return l===void 0&&f===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),l!==void 0&&(this._opacity=l),f!==void 0&&(this._opacityWhenCovered=f),this._map&&this._updateOpacity(!0),this}}const Fy={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Gc=0,Yc=!1;const Ks={maxWidth:100,unit:"metric"};function Zc(E,l,f){const b=f&&f.maxWidth||100,_=E._container.clientHeight/2,w=E.unproject([0,_]),M=E.unproject([b,_]),P=w.distanceTo(M);if(f&&f.unit==="imperial"){const R=3.2808*P;R>5280?xt(l,b,R/5280,E._getUIString("ScaleControl.Miles")):xt(l,b,R,E._getUIString("ScaleControl.Feet"))}else f&&f.unit==="nautical"?xt(l,b,P/1852,E._getUIString("ScaleControl.NauticalMiles")):P>=1e3?xt(l,b,P/1e3,E._getUIString("ScaleControl.Kilometers")):xt(l,b,P,E._getUIString("ScaleControl.Meters"))}function xt(E,l,f,b){const _=function(w){const M=Math.pow(10,`${Math.floor(w)}`.length-1);let P=w/M;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(R){const z=Math.pow(10,Math.ceil(-Math.log(R)/Math.LN10));return Math.round(R*z)/z}(P),M*P}(f);E.style.width=l*(_/f)+"px",E.innerHTML=`${_} ${b}`}const Rt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Vu=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function zu(E){if(E){if(typeof E=="number"){const l=Math.round(Math.abs(E)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,E),"top-left":new o.P(l,l),"top-right":new o.P(-l,l),bottom:new o.P(0,-E),"bottom-left":new o.P(l,-l),"bottom-right":new o.P(-l,-l),left:new o.P(E,0),right:new o.P(-E,0)}}if(E instanceof o.P||Array.isArray(E)){const l=o.P.convert(E);return{center:l,top:l,"top-left":l,"top-right":l,bottom:l,"bottom-left":l,"bottom-right":l,left:l,right:l}}return{center:o.P.convert(E.center||[0,0]),top:o.P.convert(E.top||[0,0]),"top-left":o.P.convert(E["top-left"]||[0,0]),"top-right":o.P.convert(E["top-right"]||[0,0]),bottom:o.P.convert(E.bottom||[0,0]),"bottom-left":o.P.convert(E["bottom-left"]||[0,0]),"bottom-right":o.P.convert(E["bottom-right"]||[0,0]),left:o.P.convert(E.left||[0,0]),right:o.P.convert(E.right||[0,0])}}return zu(new o.P(0,0))}const cp=p;a.AJAXError=o.bh,a.Evented=o.E,a.LngLat=o.N,a.MercatorCoordinate=o.Z,a.Point=o.P,a.addProtocol=o.bi,a.config=o.a,a.removeProtocol=o.bj,a.AttributionControl=Il,a.BoxZoomHandler=ji,a.CanvasSource=hr,a.CooperativeGesturesHandler=Ml,a.DoubleClickZoomHandler=Ma,a.DragPanHandler=Oy,a.DragRotateHandler=By,a.EdgeInsets=Cl,a.FullscreenControl=class extends o.E{constructor(E={}){super(),this._onFullscreenChange=()=>{var l;let f=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((l=f==null?void 0:f.shadowRoot)===null||l===void 0)&&l.fullscreenElement;)f=f.shadowRoot.fullscreenElement;f===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,E&&E.container&&(E.container instanceof HTMLElement?this._container=E.container:o.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(E){return this._map=E,this._container||(this._container=this._map.getContainer()),this._controlContainer=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){k.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const E=this._fullscreenButton=k.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);k.create("span","maplibregl-ctrl-icon",E).setAttribute("aria-hidden","true"),E.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const E=this._getTitle();this._fullscreenButton.setAttribute("aria-label",E),this._fullscreenButton.title=E}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new o.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new o.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},a.GeoJSONSource=Vr,a.GeolocateControl=class extends o.E{constructor(E){super(),this._onSuccess=l=>{if(this._map){if(this._isOutOfMapMaxBounds(l))return this._setErrorState(),this.fire(new o.k("outofmaxbounds",l)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=l,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(l),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(l),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new o.k("geolocate",l)),this._finish()}},this._updateCamera=l=>{const f=new o.N(l.coords.longitude,l.coords.latitude),b=l.coords.accuracy,_=this._map.getBearing(),w=o.e({bearing:_},this.options.fitBoundsOptions),M=Ae.fromLngLat(f,b);this._map.fitBounds(M,w,{geolocateSource:!0})},this._updateMarker=l=>{if(l){const f=new o.N(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(f).addTo(this._map),this._userLocationDotMarker.setLngLat(f).addTo(this._map),this._accuracy=l.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=l=>{if(this._map){if(this.options.trackUserLocation)if(l.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const f=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=f,this._geolocateButton.setAttribute("aria-label",f),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&Yc)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.k("error",l)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",l=>l.preventDefault()),this._geolocateButton=k.create("button","maplibregl-ctrl-geolocate",this._container),k.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=l=>{if(this._map){if(l===!1){o.w("Geolocation support is not available so the GeolocateControl will be disabled.");const f=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=f,this._geolocateButton.setAttribute("aria-label",f)}else{const f=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=f,this._geolocateButton.setAttribute("aria-label",f)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=k.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Bu({element:this._dotElement}),this._circleElement=k.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Bu({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",f=>{f.geolocateSource||this._watchState!=="ACTIVE_LOCK"||f.originalEvent&&f.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new o.k("trackuserlocationend")),this.fire(new o.k("userlocationlostfocus")))})}},this.options=o.e({},Fy,E)}onAdd(E){return this._map=E,this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return o._(this,arguments,void 0,function*(l=!1){if(Hi!==void 0&&!l)return Hi;if(window.navigator.permissions===void 0)return Hi=!!window.navigator.geolocation,Hi;try{Hi=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Hi=!!window.navigator.geolocation}return Hi})}().then(l=>this._finishSetupUI(l)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),k.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Gc=0,Yc=!1}_isOutOfMapMaxBounds(E){const l=this._map.getMaxBounds(),f=E.coords;return l&&(f.longitude<l.getWest()||f.longitude>l.getEast()||f.latitude<l.getSouth()||f.latitude>l.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const E=this._map.getBounds(),l=E.getSouthEast(),f=E.getNorthEast(),b=l.distanceTo(f),_=Math.ceil(this._accuracy/(b/this._map._container.clientHeight)*2);this._circleElement.style.width=`${_}px`,this._circleElement.style.height=`${_}px`}trigger(){if(!this._setup)return o.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Gc--,Yc=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new o.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new o.k("trackuserlocationstart")),this.fire(new o.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let E;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Gc++,Gc>1?(E={maximumAge:6e5,timeout:0},Yc=!0):(E=this.options.positionOptions,Yc=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,E)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},a.Hash=Cu,a.ImageSource=ir,a.KeyboardHandler=is,a.LngLatBounds=Ae,a.LogoControl=ip,a.Map=class extends Vy{constructor(E){o.bf.mark(o.bg.create);const l=Object.assign(Object.assign({},a1),E);if(l.minZoom!=null&&l.maxZoom!=null&&l.minZoom>l.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(l.minPitch!=null&&l.maxPitch!=null&&l.minPitch>l.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(l.minPitch!=null&&l.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(l.maxPitch!=null&&l.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Tl(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),{bearingSnap:l.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new hn,this._controls=[],this._mapId=o.a4(),this._contextLost=f=>{f.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:f}))},this._contextRestored=f=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:f}))},this._onMapScroll=f=>{if(f.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=l.interactive,this._maxTileCacheSize=l.maxTileCacheSize,this._maxTileCacheZoomLevels=l.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=l.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=l.preserveDrawingBuffer===!0,this._antialias=l.antialias===!0,this._trackResize=l.trackResize===!0,this._bearingSnap=l.bearingSnap,this._refreshExpiredTiles=l.refreshExpiredTiles===!0,this._fadeDuration=l.fadeDuration,this._crossSourceCollisions=l.crossSourceCollisions===!0,this._collectResourceTiming=l.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},ap),l.locale),this._clickTolerance=l.clickTolerance,this._overridePixelRatio=l.pixelRatio,this._maxCanvasSize=l.maxCanvasSize,this.transformCameraUpdate=l.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=l.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Z.addThrottleControl(()=>this.isMoving()),this._requestManager=new Y(l.transformRequest),typeof l.container=="string"){if(this._container=document.getElementById(l.container),!this._container)throw new Error(`Container '${l.container}' not found.`)}else{if(!(l.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=l.container}if(l.maxBounds&&this.setMaxBounds(l.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let f=!1;const b=$c(_=>{this._trackResize&&!this._removed&&(this.resize(_),this.redraw())},50);this._resizeObserver=new ResizeObserver(_=>{f?b(_):f=!0}),this._resizeObserver.observe(this._container)}this.handlers=new rp(this,l),this._hash=l.hash&&new Cu(typeof l.hash=="string"&&l.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch}),l.bounds&&(this.resize(),this.fitBounds(l.bounds,o.e({},l.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=l.localIdeographFontFamily,this._validateStyle=l.validateStyle,l.style&&this.setStyle(l.style,{localIdeographFontFamily:l.localIdeographFontFamily}),l.attributionControl&&this.addControl(new Il(typeof l.attributionControl=="boolean"?void 0:l.attributionControl)),l.maplibreLogo&&this.addControl(new ip,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",f=>{this._update(f.dataType==="style"),this.fire(new o.k(`${f.dataType}data`,f))}),this.on("dataloading",f=>{this.fire(new o.k(`${f.dataType}dataloading`,f))}),this.on("dataabort",f=>{this.fire(new o.k("sourcedataabort",f))})}_getMapId(){return this._mapId}addControl(E,l){if(l===void 0&&(l=E.getDefaultPosition?E.getDefaultPosition():"top-right"),!E||!E.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const f=E.onAdd(this);this._controls.push(E);const b=this._controlPositions[l];return l.indexOf("bottom")!==-1?b.insertBefore(f,b.firstChild):b.appendChild(f),this}removeControl(E){if(!E||!E.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const l=this._controls.indexOf(E);return l>-1&&this._controls.splice(l,1),E.onRemove(this),this}hasControl(E){return this._controls.indexOf(E)>-1}calculateCameraOptionsFromTo(E,l,f,b){return b==null&&this.terrain&&(b=this.terrain.getElevationForLngLatZoom(f,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(E,l,f,b)}resize(E){var l;const f=this._containerDimensions(),b=f[0],_=f[1],w=this._getClampedPixelRatio(b,_);if(this._resizeCanvas(b,_,w),this.painter.resize(b,_,w),this.painter.overLimit()){const P=this.painter.context.gl;this._maxCanvasSize=[P.drawingBufferWidth,P.drawingBufferHeight];const R=this._getClampedPixelRatio(b,_);this._resizeCanvas(b,_,R),this.painter.resize(b,_,R)}this.transform.resize(b,_),(l=this._requestedCameraState)===null||l===void 0||l.resize(b,_);const M=!this._moving;return M&&(this.stop(),this.fire(new o.k("movestart",E)).fire(new o.k("move",E))),this.fire(new o.k("resize",E)),M&&this.fire(new o.k("moveend",E)),this}_getClampedPixelRatio(E,l){const{0:f,1:b}=this._maxCanvasSize,_=this.getPixelRatio(),w=E*_,M=l*_;return Math.min(w>f?f/w:1,M>b?b/M:1)*_}getPixelRatio(){var E;return(E=this._overridePixelRatio)!==null&&E!==void 0?E:devicePixelRatio}setPixelRatio(E){this._overridePixelRatio=E,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(E){return this.transform.setMaxBounds(Ae.convert(E)),this._update()}setMinZoom(E){if((E=E??-2)>=-2&&E<=this.transform.maxZoom)return this.transform.minZoom=E,this._update(),this.getZoom()<E&&this.setZoom(E),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(E){if((E=E??22)>=this.transform.minZoom)return this.transform.maxZoom=E,this._update(),this.getZoom()>E&&this.setZoom(E),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(E){if((E=E??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(E>=0&&E<=this.transform.maxPitch)return this.transform.minPitch=E,this._update(),this.getPitch()<E&&this.setPitch(E),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(E){if((E=E??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(E>=this.transform.minPitch)return this.transform.maxPitch=E,this._update(),this.getPitch()>E&&this.setPitch(E),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(E){return this.transform.renderWorldCopies=E,this._update()}project(E){return this.transform.locationPoint(o.N.convert(E),this.style&&this.terrain)}unproject(E){return this.transform.pointLocation(o.P.convert(E),this.terrain)}isMoving(){var E;return this._moving||((E=this.handlers)===null||E===void 0?void 0:E.isMoving())}isZooming(){var E;return this._zooming||((E=this.handlers)===null||E===void 0?void 0:E.isZooming())}isRotating(){var E;return this._rotating||((E=this.handlers)===null||E===void 0?void 0:E.isRotating())}_createDelegatedListener(E,l,f){if(E==="mouseenter"||E==="mouseover"){let b=!1;return{layers:l,listener:f,delegates:{mousemove:w=>{const M=l.filter(R=>this.getLayer(R)),P=M.length!==0?this.queryRenderedFeatures(w.point,{layers:M}):[];P.length?b||(b=!0,f.call(this,new Xr(E,this,w.originalEvent,{features:P}))):b=!1},mouseout:()=>{b=!1}}}}if(E==="mouseleave"||E==="mouseout"){let b=!1;return{layers:l,listener:f,delegates:{mousemove:M=>{const P=l.filter(R=>this.getLayer(R));(P.length!==0?this.queryRenderedFeatures(M.point,{layers:P}):[]).length?b=!0:b&&(b=!1,f.call(this,new Xr(E,this,M.originalEvent)))},mouseout:M=>{b&&(b=!1,f.call(this,new Xr(E,this,M.originalEvent)))}}}}{const b=_=>{const w=l.filter(P=>this.getLayer(P)),M=w.length!==0?this.queryRenderedFeatures(_.point,{layers:w}):[];M.length&&(_.features=M,f.call(this,_),delete _.features)};return{layers:l,listener:f,delegates:{[E]:b}}}}_saveDelegatedListener(E,l){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[E]=this._delegatedListeners[E]||[],this._delegatedListeners[E].push(l)}_removeDelegatedListener(E,l,f){if(!this._delegatedListeners||!this._delegatedListeners[E])return;const b=this._delegatedListeners[E];for(let _=0;_<b.length;_++){const w=b[_];if(w.listener===f&&w.layers.length===l.length&&w.layers.every(M=>l.includes(M))){for(const M in w.delegates)this.off(M,w.delegates[M]);return void b.splice(_,1)}}}on(E,l,f){if(f===void 0)return super.on(E,l);const b=this._createDelegatedListener(E,typeof l=="string"?[l]:l,f);this._saveDelegatedListener(E,b);for(const _ in b.delegates)this.on(_,b.delegates[_]);return this}once(E,l,f){if(f===void 0)return super.once(E,l);const b=typeof l=="string"?[l]:l,_=this._createDelegatedListener(E,b,f);for(const w in _.delegates){const M=_.delegates[w];_.delegates[w]=(...P)=>{this._removeDelegatedListener(E,b,f),M(...P)}}this._saveDelegatedListener(E,_);for(const w in _.delegates)this.once(w,_.delegates[w]);return this}off(E,l,f){return f===void 0?super.off(E,l):(this._removeDelegatedListener(E,typeof l=="string"?[l]:l,f),this)}queryRenderedFeatures(E,l){if(!this.style)return[];let f;const b=E instanceof o.P||Array.isArray(E),_=b?E:[[0,0],[this.transform.width,this.transform.height]];if(l=l||(b?{}:E)||{},_ instanceof o.P||typeof _[0]=="number")f=[o.P.convert(_)];else{const w=o.P.convert(_[0]),M=o.P.convert(_[1]);f=[w,new o.P(M.x,w.y),M,new o.P(w.x,M.y),w]}return this.style.queryRenderedFeatures(f,l,this.transform)}querySourceFeatures(E,l){return this.style.querySourceFeatures(E,l)}setStyle(E,l){return(l=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},l)).diff!==!1&&l.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&E?(this._diffStyle(E,l),this):(this._localIdeographFontFamily=l.localIdeographFontFamily,this._updateStyle(E,l))}setTransformRequest(E){return this._requestManager.setTransformRequest(E),this}_getUIString(E){const l=this._locale[E];if(l==null)throw new Error(`Missing UI string '${E}'`);return l}_updateStyle(E,l){if(l.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(E,l));const f=this.style&&l.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!E)),E?(this.style=new cu(this,l||{}),this.style.setEventedParent(this,{style:this.style}),typeof E=="string"?this.style.loadURL(E,l,f):this.style.loadJSON(E,l,f),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new cu(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(E,l){if(typeof E=="string"){const f=this._requestManager.transformRequest(E,"Style");o.h(f,new AbortController).then(b=>{this._updateDiff(b.data,l)}).catch(b=>{b&&this.fire(new o.j(b))})}else typeof E=="object"&&this._updateDiff(E,l)}_updateDiff(E,l){try{this.style.setState(E,l)&&this._update(!0)}catch(f){o.w(`Unable to perform style diff: ${f.message||f.error||f}. Rebuilding the style from scratch.`),this._updateStyle(E,l)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(E,l){return this._lazyInitEmptyStyle(),this.style.addSource(E,l),this._update(!0)}isSourceLoaded(E){const l=this.style&&this.style.sourceCaches[E];if(l!==void 0)return l.loaded();this.fire(new o.j(new Error(`There is no source with ID '${E}'`)))}setTerrain(E){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),E){const l=this.style.sourceCaches[E.source];if(!l)throw new Error(`cannot load terrain, because there exists no source with ID: ${E.source}`);this.terrain===null&&l.reload();for(const f in this.style._layers){const b=this.style._layers[f];b.type==="hillshade"&&b.source===E.source&&o.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new op(this.painter,l,E),this.painter.renderToTexture=new zy(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=f=>{f.dataType==="style"?this.terrain.sourceCache.freeRtt():f.dataType==="source"&&f.tile&&(f.sourceId!==E.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(f.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new o.k("terrain",{terrain:E})),this}getTerrain(){var E,l;return(l=(E=this.terrain)===null||E===void 0?void 0:E.options)!==null&&l!==void 0?l:null}areTilesLoaded(){const E=this.style&&this.style.sourceCaches;for(const l in E){const f=E[l]._tiles;for(const b in f){const _=f[b];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}removeSource(E){return this.style.removeSource(E),this._update(!0)}getSource(E){return this.style.getSource(E)}addImage(E,l,f={}){const{pixelRatio:b=1,sdf:_=!1,stretchX:w,stretchY:M,content:P,textFitWidth:R,textFitHeight:z}=f;if(this._lazyInitEmptyStyle(),!(l instanceof HTMLImageElement||o.b(l))){if(l.width===void 0||l.height===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:$,height:j,data:X}=l,ee=l;return this.style.addImage(E,{data:new o.R({width:$,height:j},new Uint8Array(X)),pixelRatio:b,stretchX:w,stretchY:M,content:P,textFitWidth:R,textFitHeight:z,sdf:_,version:0,userImage:ee}),ee.onAdd&&ee.onAdd(this,E),this}}{const{width:$,height:j,data:X}=v.getImageData(l);this.style.addImage(E,{data:new o.R({width:$,height:j},X),pixelRatio:b,stretchX:w,stretchY:M,content:P,textFitWidth:R,textFitHeight:z,sdf:_,version:0})}}updateImage(E,l){const f=this.style.getImage(E);if(!f)return this.fire(new o.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const b=l instanceof HTMLImageElement||o.b(l)?v.getImageData(l):l,{width:_,height:w,data:M}=b;if(_===void 0||w===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(_!==f.data.width||w!==f.data.height)return this.fire(new o.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const P=!(l instanceof HTMLImageElement||o.b(l));return f.data.replace(M,P),this.style.updateImage(E,f),this}getImage(E){return this.style.getImage(E)}hasImage(E){return E?!!this.style.getImage(E):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(E){this.style.removeImage(E)}loadImage(E){return Z.getImage(this._requestManager.transformRequest(E,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(E,l){return this._lazyInitEmptyStyle(),this.style.addLayer(E,l),this._update(!0)}moveLayer(E,l){return this.style.moveLayer(E,l),this._update(!0)}removeLayer(E){return this.style.removeLayer(E),this._update(!0)}getLayer(E){return this.style.getLayer(E)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(E,l,f){return this.style.setLayerZoomRange(E,l,f),this._update(!0)}setFilter(E,l,f={}){return this.style.setFilter(E,l,f),this._update(!0)}getFilter(E){return this.style.getFilter(E)}setPaintProperty(E,l,f,b={}){return this.style.setPaintProperty(E,l,f,b),this._update(!0)}getPaintProperty(E,l){return this.style.getPaintProperty(E,l)}setLayoutProperty(E,l,f,b={}){return this.style.setLayoutProperty(E,l,f,b),this._update(!0)}getLayoutProperty(E,l){return this.style.getLayoutProperty(E,l)}setGlyphs(E,l={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(E,l),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(E,l,f={}){return this._lazyInitEmptyStyle(),this.style.addSprite(E,l,f,b=>{b||this._update(!0)}),this}removeSprite(E){return this._lazyInitEmptyStyle(),this.style.removeSprite(E),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(E,l={}){return this._lazyInitEmptyStyle(),this.style.setSprite(E,l,f=>{f||this._update(!0)}),this}setLight(E,l={}){return this._lazyInitEmptyStyle(),this.style.setLight(E,l),this._update(!0)}getLight(){return this.style.getLight()}setSky(E){return this._lazyInitEmptyStyle(),this.style.setSky(E),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(E,l){return this.style.setFeatureState(E,l),this._update()}removeFeatureState(E,l){return this.style.removeFeatureState(E,l),this._update()}getFeatureState(E){return this.style.getFeatureState(E)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let E=0,l=0;return this._container&&(E=this._container.clientWidth||400,l=this._container.clientHeight||300),[E,l]}_setupContainer(){const E=this._container;E.classList.add("maplibregl-map");const l=this._canvasContainer=k.create("div","maplibregl-canvas-container",E);this._interactive&&l.classList.add("maplibregl-interactive"),this._canvas=k.create("canvas","maplibregl-canvas",l),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const f=this._containerDimensions(),b=this._getClampedPixelRatio(f[0],f[1]);this._resizeCanvas(f[0],f[1],b);const _=this._controlContainer=k.create("div","maplibregl-control-container",E),w=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(M=>{w[M]=k.create("div",`maplibregl-ctrl-${M} `,_)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(E,l,f){this._canvas.width=Math.floor(f*E),this._canvas.height=Math.floor(f*l),this._canvas.style.width=`${E}px`,this._canvas.style.height=`${l}px`}_setupPainter(){const E={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let l=null;this._canvas.addEventListener("webglcontextcreationerror",b=>{l={requestedAttributes:E},b&&(l.statusMessage=b.statusMessage,l.type=b.type)},{once:!0});const f=this._canvas.getContext("webgl2",E)||this._canvas.getContext("webgl",E);if(!f){const b="Failed to initialize WebGL";throw l?(l.message=b,new Error(JSON.stringify(l))):new Error(b)}this.painter=new Su(f,this.transform),T.testSupport(f)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(E){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||E,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(E){return this._update(),this._renderTaskQueue.add(E)}_cancelRenderFrame(E){this._renderTaskQueue.remove(E)}_render(E){const l=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(E),this._removed)return;let f=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const _=this.transform.zoom,w=v.now();this.style.zoomHistory.update(_,w);const M=new o.z(_,{now:w,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),P=M.crossFadingFactor();P===1&&P===this._crossFadingFactor||(f=!0,this._crossFadingFactor=P),this.style.update(M)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bf.mark(o.bg.load),this.fire(new o.k("load"))),this.style&&(this.style.hasTransitions()||f)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const b=this._sourcesDirty||this._styleDirty||this._placementDirty;return b||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new o.k("idle")),!this._loaded||this._fullyLoaded||b||(this._fullyLoaded=!0,o.bf.mark(o.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var E;this._hash&&this._hash.remove();for(const f of this._controls)f.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Z.removeThrottleControl(this._imageQueueHandle),(E=this._resizeObserver)===null||E===void 0||E.disconnect();const l=this.painter.context.gl.getExtension("WEBGL_lose_context");l!=null&&l.loseContext&&l.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),k.remove(this._canvasContainer),k.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),o.bf.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,v.frameAsync(this._frameRequest).then(E=>{o.bf.frame(E),this._frameRequest=null,this._render(E)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(E){this._showTileBoundaries!==E&&(this._showTileBoundaries=E,this._update())}get showPadding(){return!!this._showPadding}set showPadding(E){this._showPadding!==E&&(this._showPadding=E,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(E){this._showCollisionBoxes!==E&&(this._showCollisionBoxes=E,E?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(E){this._showOverdrawInspector!==E&&(this._showOverdrawInspector=E,this._update())}get repaint(){return!!this._repaint}set repaint(E){this._repaint!==E&&(this._repaint=E,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(E){this._vertices=E,this._update()}get version(){return Ly}getCameraTargetElevation(){return this.transform.elevation}},a.MapMouseEvent=Xr,a.MapTouchEvent=Ta,a.MapWheelEvent=Py,a.Marker=Bu,a.NavigationControl=class{constructor(E){this._updateZoomButtons=()=>{const l=this._map.getZoom(),f=l===this._map.getMaxZoom(),b=l===this._map.getMinZoom();this._zoomInButton.disabled=f,this._zoomOutButton.disabled=b,this._zoomInButton.setAttribute("aria-disabled",f.toString()),this._zoomOutButton.setAttribute("aria-disabled",b.toString())},this._rotateCompassArrow=()=>{const l=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=l},this._setButtonTitle=(l,f)=>{const b=this._map._getUIString(`NavigationControl.${f}`);l.title=b,l.setAttribute("aria-label",b)},this.options=o.e({},l1,E),this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",l=>l.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",l=>this._map.zoomIn({},{originalEvent:l})),k.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",l=>this._map.zoomOut({},{originalEvent:l})),k.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",l=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:l}):this._map.resetNorth({},{originalEvent:l})}),this._compassIcon=k.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(E){return this._map=E,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 c1(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){k.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(E,l){const f=k.create("button",E,this._container);return f.type="button",f.addEventListener("click",l),f}},a.Popup=class extends o.E{constructor(E){super(),this.remove=()=>(this._content&&k.remove(this._content),this._container&&(k.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new o.k("close"))),this),this._onMouseUp=l=>{this._update(l.point)},this._onMouseMove=l=>{this._update(l.point)},this._onDrag=l=>{this._update(l.point)},this._update=l=>{var f;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=k.create("div","maplibregl-popup",this._map.getContainer()),this._tip=k.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const P of this.options.className.split(" "))this._container.classList.add(P);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Zn(this._lngLat,this._flatPos,this._map.transform):(f=this._lngLat)===null||f===void 0?void 0:f.wrap(),this._trackPointer&&!l)return;const b=this._flatPos=this._pos=this._trackPointer&&l?l:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&l?l:this._map.transform.locationPoint(this._lngLat));let _=this.options.anchor;const w=zu(this.options.offset);if(!_){const P=this._container.offsetWidth,R=this._container.offsetHeight;let z;z=b.y+w.bottom.y<R?["top"]:b.y>this._map.transform.height-R?["bottom"]:[],b.x<P/2?z.push("left"):b.x>this._map.transform.width-P/2&&z.push("right"),_=z.length===0?"bottom":z.join("-")}let M=b.add(w[_]);this.options.subpixelPositioning||(M=M.round()),k.setTransform(this._container,`${Nl[_]} translate(${M.x}px,${M.y}px)`),Ou(this._container,_,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(Rt),E)}addTo(E){return this._map&&this.remove(),this._map=E,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(E){return this._lngLat=o.N.convert(E),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(E){return this.setDOMContent(document.createTextNode(E))}setHTML(E){const l=document.createDocumentFragment(),f=document.createElement("body");let b;for(f.innerHTML=E;b=f.firstChild,b;)l.appendChild(b);return this.setDOMContent(l)}getMaxWidth(){var E;return(E=this._container)===null||E===void 0?void 0:E.style.maxWidth}setMaxWidth(E){return this.options.maxWidth=E,this._update(),this}setDOMContent(E){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=k.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(E),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(E){return this._container&&this._container.classList.add(E),this}removeClassName(E){return this._container&&this._container.classList.remove(E),this}setOffset(E){return this.options.offset=E,this._update(),this}toggleClassName(E){if(this._container)return this._container.classList.toggle(E)}setSubpixelPositioning(E){this.options.subpixelPositioning=E}_createCloseButton(){this.options.closeButton&&(this._closeButton=k.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const E=this._container.querySelector(Vu);E&&E.focus()}},a.RasterDEMTileSource=bn,a.RasterTileSource=nn,a.ScaleControl=class{constructor(E){this._onMove=()=>{Zc(this._map,this._container,this.options)},this.setUnit=l=>{this.options.unit=l,Zc(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ks),E)}getDefaultPosition(){return"bottom-left"}onAdd(E){return this._map=E,this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-scale",E.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){k.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},a.ScrollZoomHandler=Cs,a.Style=cu,a.TerrainControl=class{constructor(E){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=E}onAdd(E){return this._map=E,this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=k.create("button","maplibregl-ctrl-terrain",this._container),k.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(){k.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},a.TwoFingersTouchPitchHandler=qc,a.TwoFingersTouchRotateHandler=ep,a.TwoFingersTouchZoomHandler=Jf,a.TwoFingersTouchZoomRotateHandler=np,a.VectorTileSource=Bi,a.VideoSource=Ir,a.addSourceType=(E,l)=>o._(void 0,void 0,void 0,function*(){if(Zr(E))throw new Error(`A source type called "${E}" already exists.`);((f,b)=>{Yr[f]=b})(E,l)}),a.clearPrewarmedResources=function(){const E=Me;E&&(E.isPreloaded()&&E.numActive()===1?(E.release(_n),Me=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},a.getMaxParallelImageRequests=function(){return o.a.MAX_PARALLEL_IMAGE_REQUESTS},a.getRTLTextPluginStatus=function(){return ci().getRTLTextPluginStatus()},a.getVersion=function(){return cp},a.getWorkerCount=function(){return gn.workerCount},a.getWorkerUrl=function(){return o.a.WORKER_URL},a.importScriptInWorkers=function(E){return Gt().broadcast("IS",E)},a.prewarm=function(){Qe().acquire(_n)},a.setMaxParallelImageRequests=function(E){o.a.MAX_PARALLEL_IMAGE_REQUESTS=E},a.setRTLTextPlugin=function(E,l){return ci().setRTLTextPlugin(E,l)},a.setWorkerCount=function(E){gn.workerCount=E},a.setWorkerUrl=function(E){o.a.WORKER_URL=E}});var s=n;return s})})(DE);var E5=DE.exports;const pm=k5(E5);function IE(t,e,n){if(t!==null)for(var r,i,s,a,o,p,g,y=0,v=0,k,T=t.type,D=T==="FeatureCollection",N=T==="Feature",B=D?t.features.length:1,L=0;L<B;L++){g=D?t.features[L].geometry:N?t.geometry:t,k=g?g.type==="GeometryCollection":!1,o=k?g.geometries.length:1;for(var U=0;U<o;U++){var Z=0,Y=0;if(a=k?g.geometries[U]:g,a!==null){p=a.coordinates;var he=a.type;switch(y=0,he){case null:break;case"Point":if(e(p,v,L,Z,Y)===!1)return!1;v++,Z++;break;case"LineString":case"MultiPoint":for(r=0;r<p.length;r++){if(e(p[r],v,L,Z,Y)===!1)return!1;v++,he==="MultiPoint"&&Z++}he==="LineString"&&Z++;break;case"Polygon":case"MultiLineString":for(r=0;r<p.length;r++){for(i=0;i<p[r].length-y;i++){if(e(p[r][i],v,L,Z,Y)===!1)return!1;v++}he==="MultiLineString"&&Z++,he==="Polygon"&&Y++}he==="Polygon"&&Z++;break;case"MultiPolygon":for(r=0;r<p.length;r++){for(Y=0,i=0;i<p[r].length;i++){for(s=0;s<p[r][i].length-y;s++){if(e(p[r][i][s],v,L,Z,Y)===!1)return!1;v++}Y++}Z++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(IE(a.geometries[r],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function S5(t,e={}){if(t.bbox!=null&&e.recompute!==!0)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return IE(t,r=>{n[0]>r[0]&&(n[0]=r[0]),n[1]>r[1]&&(n[1]=r[1]),n[2]<r[0]&&(n[2]=r[0]),n[3]<r[1]&&(n[3]=r[1])}),n}function C5(t,e,n={}){const r={type:"Feature"};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties={},r.geometry=t,r}function PE(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}const T5={},A5={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-x"};function M5(t,e,n,r,i,s){return d.openBlock(),d.createElementBlock("svg",A5,e[0]||(e[0]=[d.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),d.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),d.createElementVNode("path",{d:"M6 6l12 12"},null,-1)]))}const D5=He(T5,[["render",M5]]);function I5(t){const e=[{type:"fill",minzoom:t.pointZoom||0,paint:{"fill-color":t.color||"#ccc","fill-outline-color":t.stroke||"#blue","fill-opacity":t.opacity||1}}];return t.pointZoom&&e.push({type:"circle",maxzoom:t.pointZoom,paint:{"circle-color":t.color||"#ccc","circle-stroke-color":t.stroke||"#ccc","circle-stroke-width":t.width||1,"circle-opacity":t.opacity||1}}),t.label&&e.push({type:"symbol",layout:{"text-field":["get",t.label],"text-font":["Open Sans Regular"],"text-size":12,"text-anchor":"center"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.5}}),e}function P5(t){const e=[{type:"line",paint:{"line-color":t.color||"#ccc","line-opacity":t.opacity||1}}];return t.label&&e.push({type:"symbol",layout:{"text-field":["get",t.label],"text-font":["Open Sans Regular"],"text-size":12,"symbol-placement":"line-center"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.5}}),e}function N5(t){const e=[{type:"circle",maxzoom:t.icon&&+t.iconZoom||22,paint:{"circle-radius":t.radius||6,"circle-stroke-color":t.stroke||"#ccc","circle-stroke-width":t.width||1,"circle-color":t.color||"blue","circle-opacity":t.opacity||1}}];return t!=null&&t.clusterZoom&&(e.push({type:"circle",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#51bbd6",100,"#f1f075",750,"#f28cb1"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),e.push({type:"symbol",filter:["has","point_count"],layout:{"text-field":["get","point_count"],"text-font":["Open Sans Regular"],"text-size":12}})),t.icon&&e.push({type:"symbol",minzoom:+t.iconZoom||16,layout:{"icon-image":t.icon,"icon-allow-overlap":!0}}),t.label&&e.push({type:"symbol",layout:{"text-field":["get",t.label],"text-font":["Open Sans Regular"],"text-size":12,"text-anchor":"top"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.5}}),e}function R5(t){if(!t)return null;const e=t.type||"point";return e==="polygon"?I5(t):e==="line"?P5(t):N5(t)}const O5=["#69D2E7","yellow","#FE4365","#125B9A","#41B3A2","#D7C3F1","#F1D3CE"],B5=["ma-star","ma-water","ma-swimming","fa-home","fa-search","fa-trash","fa-check"],NE={};async function RE(t,e){const n=await fetch(`/api/gis-layer/${t}/${e}`),{rows:r}=await n.json();return r}async function mb(t,e,n,r){if(!t)return null;const i=JSON.parse(JSON.stringify(t)),s=i.colorAttr?await RE(e,i.colorAttr):null;s==null||s.forEach((o,p)=>{var g,y;o.color=o.color||((g=i.colorSet)==null?void 0:g[o.id])||((y=i.colorSet)==null?void 0:y[p])||O5[p],o.icon=i.icon?i.icon.split("+")[0]+"+"+o.color.replace("#","")+".png":null});const a=i.iconAttr?await RE(e,i.iconAttr):null;if(a==null||a.forEach((o,p)=>{var T,D,N,B;const g=o.icon||((T=i.iconSet)==null?void 0:T[o.id])||((D=i.iconPattern)==null?void 0:D.replace("{id}",o.id))||((N=i.iconSet)==null?void 0:N[p])||(i.iconPrefix?null:B5[p]);if(!g)return;const y=o.color||((B=i.color)==null?void 0:B.replace("#",""))||"red",[v="pin6",k="m"]=i.icon?i.icon.split("-"):[];o.icon=i.iconPrefix||g!=null&&g.includes("/")?(i.iconPrefix||"")+g:`${v}-${k}-${g}+${y}.png`}),i.colorAttr&&s){const o=["match",["get",i.colorAttr]];s.forEach(p=>{o.push(p.id),o.push(p.color)}),o.push(i.color||"gray"),i.color=o}if(i.icon&&i.iconAttr&&a){const o=["match",["get",i.iconAttr]];a.filter(p=>p.icon).forEach(({id:p,icon:g})=>{if(i.colorAttr&&s){o.push(p);const y=["match",["get",i.colorAttr]];s.forEach(v=>{y.push(v.id);const k=g.split("+")[0]+"+"+v.color.replace("#","")+".png";y.push(k),_d(k,n)}),y.push(i.icon),o.push(y)}else o.push(p),o.push(g),_d(g,n)}),o.push((i.iconPrefix||"")+i.icon),_d((i.iconPrefix||"")+i.icon,n),console.log(o),i.icon=o}else if(i.icon&&i.colorAttr&&s){const o=["match",["get",i.colorAttr]];s.forEach(p=>{o.push(p.id),o.push(p.icon),_d(p.icon,n)}),o.push(i.icon),_d(i.icon,n),i.icon=o}else i.icon&&await _d(i.icon,n);return i.stroke=["case",["boolean",["feature-state","selected"],!1],"#000000",i.stroke||"#000000"],R5(i)}async function _d(t="pin4-sm-mi-plumber+f45942.png",e=null){if(NE[t])return null;NE[t]=!0;const n=await(e==null?void 0:e.loadImage(t!=null&&t.includes("/")?t:`/api/marker_icon/${t.replace(".png","")}.png`));e==null||e.addImage(t,n.data)}const V5={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(t=>t==null?void 0:t.interactive).map(t=>t.id)}},methods:{moveLayer(t,e=this.map){e.getStyle().layers.forEach(n=>{n.id.match(t)&&e.moveLayer(n.id)})},async setVisible(t,e=!0,n=this.map){if(!t)return;const r=(t==null?void 0:t.id)||t,i=this.layerList.find(a=>a.id===t)||t;if(!(i!=null&&i.id))throw new Error("MixinError: Layer has no id");const s=n.getStyle().layers.filter(a=>a.id.match(r));s.forEach(a=>{n.setLayoutProperty(a.id,"visibility",e?"visible":"none")}),!s.length&&e&&await this.addLayer(i)},async addLayer(t,e=this==null?void 0:this.map){var i,s;const n=this.layerList.find(a=>a.id===t)||t;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===n.id)||(this.layerList.find(a=>a.id===n.id)||this.layerList.push(n),(n.service==="vtile"||n.service==="vector"||(i=n.url)!=null&&i.includes(".vmt"))&&this.addVtileLayer(n,e),n.service==="geojson"&&this.addGeoJsonLayer(n,e),((s=n.url)!=null&&s.includes(".png")||["tms","raster"].includes(n.service))&&await this.addRasterLayer(n,e))},async addRasterLayer(t,e=this==null?void 0:this.map){e.getSource(t.id)||(await e.addSource(t.id,{type:"raster",tiles:[t==null?void 0:t.url],tileSize:256,...t.bounds?{bounds:t.bounds.map(n=>n-0)}:{},...t!=null&&t.scheme?{scheme:t==null?void 0:t.scheme}:{}}),await e.addLayer({id:t.id,type:"raster",source:t.id,minzoom:0,maxzoom:(t==null?void 0:t.maxzoom)||22}))},async updateStyle(t,e=this==null?void 0:this.map){const n=t.id;e.getStyle().layers.forEach(async i=>{i.source===n&&await e.removeLayer(i.id)}),(await mb(t.style,t.source,e)||t.layers||[]).forEach((i,s)=>{const a={...i,id:`${t.id}-${s}`,source:t.id,"source-layer":i["source-layer"]||t.source||t.id,maxzoom:+i.maxzoom||24,minzoom:+i.minzoom||0};e.addLayer(a)})},async addVtileLayer(t,e=this==null?void 0:this.map){var a;const n=["props","pointZoom","nocache"].filter(o=>t.style[o]).map(o=>{var p;return`&${o}=${(p=t.style)==null?void 0:p[o]}`}),r=new Date().toISOString().split("T")[0],i={type:"vector",tiles:[`${(a=t==null?void 0:t.url)!=null&&a.startsWith("http")?"":window.location.origin}${t==null?void 0:t.url}?dt=${r}${n}`],minzoom:t.minzoom||5,maxzoom:t.maxzoom||24};e.addSource(t.id,i),(t.layers||await mb(t.style,t.source||t.id,e)||[]).forEach((o,p)=>{const g={...o,id:`${t.id}-${p}`,source:t.id,"source-layer":o["source-layer"]||t.source||t.id,maxzoom:+o.maxzoom||24,minzoom:+o.minzoom||0};e.addLayer(g)})},async addGeoJsonLayer(t,e=this.map){var i;const n=t.data||((i=t==null?void 0:t.url)!=null&&i.startsWith("http")?"":window.location.origin)+t.url;e.addSource(t.id,{type:"geojson",data:n}),(await mb(t.style,n.source,e)||t.layers||[]).forEach(s=>{const a={...s,source:t.id,id:s.id||t.id,maxzoom:+s.maxzoom||24,minzoom:+s.minzoom||0,type:s.type||"circle"};e.addLayer(a)})},setLayerData(t,e){this.layerList=this.layerList.map(n=>n.id===t?{...n,...e}:n)},async removeLayer(t,e=this.map){e.getSource(t)&&(await e.getStyle().layers.forEach(async n=>{n.source===t&&await e.removeLayer(n.id)}),await e.removeSource(t))},async setFilter(t,e){const n=this.layerList.find(i=>i.id===t),r=await this.map.getSource(t);if(n.service==="vtile"){await r.setTiles([`${window.location.origin}${n.url}${n.url.includes("?")?"&":"?"}filter=${e}${n.props?`&props=${n.props}`:""}`]);return}n.service},async changeBaseLayer(t){t!==this.activeLayer&&(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),await this.setVisible(this.activeLayer,!1),await this.setVisible(t,!0),this.map.getStyle().layers.forEach(e=>{e.source!==t&&e.type!=="background"&&this.map.moveLayer(e.id)}),this.activeLayer=t)},async refreshLayer(t,e=this.map){await e.getStyle().layers.forEach(n=>{n.source===t&&e.removeLayer(n.id)}),await e.removeSource(t),this.setVisible(t)},addGeom(t,e={}){if(!this.map)return;const n={type:"FeatureCollection",features:[{type:"Feature",geometry:t.geometry,properties:{id:t.id,name:t==null?void 0:t.text}}]};if(this.map.getSource(t.id))this.map.getSource(t.id).setData(n);else{this.map.addSource(t.id,{type:"geojson",data:n});const r=t.geometry.type;let i={};switch(r){case"Point":i={"circle-color":e.color||"#ff0000","circle-radius":e.radius||5,"circle-opacity":e.opacity||1},this.map.addLayer({id:t.id,type:"circle",source:t.id,paint:i});break;case"LineString":i={"line-color":e.color||"#0000ff","line-width":e.width||2,"line-opacity":e.opacity||1},this.map.addLayer({id:t.id,type:"line",source:t.id,paint:i});break;case"Polygon":this.map.addLayer({id:t.id,type:"fill",source:t.id,paint:{"fill-color":e.color||"#00ff00","fill-opacity":e.opacity||.5}}),this.map.addLayer({id:`${t.id}-outline`,type:"line",source:t.id,paint:{"line-color":e.color||"#00ff00","line-width":e.width||2,"line-opacity":.8}});break;default:console.warn(`Unsupported geometry type: ${r}`);return}}},removeGeom(t){this.map&&(this.map.getLayer(t)&&this.map.removeLayer(t),this.map.getLayer(`${t}-outline`)&&this.map.removeLayer(`${t}-outline`),this.map.getSource(t)&&this.map.removeSource(t))}}},{Map:z5}=pm,yr="widget-map-source",L5={mixins:[V5],props:{geometry:{type:Object,default:()=>null},zoom:{type:Number,default:()=>{var t,e;return((e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)==null?void 0:e.zoom)||10}},center:{type:Array,default:()=>{var t,e;return((e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)==null?void 0:e.center)||[30.5,50.45]}},height:{type:String,default:"400px"},layers:{type:Array,default:()=>{var t,e;return((e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)==null?void 0:e.layers)||[]}},card:{type:Boolean,default:!1}},data(){return{cardData:null,cardPosition:{top:"0px",right:"0px",left:"0px"},map:null,mapId:`gis-map-${Math.floor(Math.random()*1e3)}`,isOpen:!1,selectedBaseLayer:"topo100",isGeometryVisible:!0,localLayers:[],idleEventWorked:!1,selectedLayers:[],baseLayers:[{id:"topo100",name:"Карта України",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png"},{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS"},{id:"osmb",name:"Open Street Map",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",service:"TMS"}]}},mounted(){window.addEventListener("resize",this.updateCardPosition),this.updateCardPosition(),this.localLayers=this.layers,this.initMap()},components:{IconClose:D5},beforeUnmount(){window.removeEventListener("resize",this.updateCardPosition)},watch:{selectedLayers:{handler(){this.selectedLayers.forEach(t=>{this.map.getSource(t)&&this.map.getStyle().layers.forEach(n=>{n.source===t&&this.map.moveLayer(n.id)}),[`${yr}-polygon`,`${yr}-polygon-line`,`${yr}-line`,`${yr}-point`].forEach(n=>{this.map.getLayer(n)&&this.map.moveLayer(n)}),this.map.getLayer("selected-feature")&&this.map.moveLayer("selected-feature")})},immediate:!0},geometry(){this.initGeometryLayer()},layers:{handler(t){t&&!this.layers.length&&(this.localLayers=t)},deep:!0,immediate:!0}},methods:{updateCardPosition(){this.$nextTick(()=>{if(this.$refs.relativeContainer){const t=this.$refs.relativeContainer.getBoundingClientRect();this.cardPosition.top=`${t.top+10}`,this.cardPosition.right=`${t.right+10}`,this.cardPosition.left=`${t.left+10}`}})},initMap(){const t={version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=new z5({container:this.mapId,style:t,center:this.center,zoom:this.zoom,interactive:!0}),window==null||window.addEventListener("resize",()=>{this.map.resize()}),this.map.on("load",this.onMapLoad)},async onMapLoad(){var t,e,n,r,i,s,a,o;this.map.resize(),this.map.doubleClickZoom.disable(),(e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)!=null&&e.bounds&&this.map.fitBounds(Tt.value.geom.bounds,{padding:20,duration:0}),(r=(n=Tt==null?void 0:Tt.value)==null?void 0:n.geom)!=null&&r.zoom&&this.map.setZoom(Tt.value.geom.zoom),this.changeBaseLayer(this.getLayerById(this.selectedBaseLayer)),this.localLayers.forEach(async p=>{p.enabled&&(await this.setLayerVisible(p,!0),this.selectedLayers.push(p.id))}),this.geometry&&this.initGeometryLayer(),(s=(i=Tt==null?void 0:Tt.value)==null?void 0:i.geom)!=null&&s.katottg&&await this.createAtuLayer((o=(a=Tt==null?void 0:Tt.value)==null?void 0:a.geom)==null?void 0:o.katottg),this.map.on("idle",()=>{this.idleEventWorked||this.selectedLayers.forEach(p=>{this.map.getSource(p)&&this.map.getStyle().layers.forEach(y=>{y.source===p&&this.map.moveLayer(y.id)}),[`${yr}-polygon`,`${yr}-polygon-line`,`${yr}-line`,`${yr}-point`].forEach(y=>{this.map.getLayer(y)&&this.map.moveLayer(y)})}),this.idleEventWorked=!0}),this.card&&this.map.on("click",async p=>{debugger;const g=this.map.queryRenderedFeatures(p.point);if(!g.length)return;const y=g.filter(v=>!v.source.includes(yr));if(y.length)try{const v=y.map(T=>Ue.get(`/api/gis-format-admin?table=${T.sourceLayer}&id=${T.properties.id}`)),k=await Promise.all(v);this.cardData=k.map(T=>T.data)}catch(v){console.error("Помилка при отриманні даних",v)}})},async createAtuLayer(t){try{const{map:e}=this;if(!e)return;const{data:n}=await Ue.get(`https://data.gki.com.ua/api-user/atu/${t}`);e.addSource("atu",{type:"geojson",data:n}),e.addLayer({id:"atu",type:"line",source:"atu",paint:{"line-color":"#3b82f6","line-width":2}})}catch(e){console.error(e)}},changeBaseLayer(t){const e="base-layer",n="base-layer";if(!this.map.getSource(e))this.map.addSource(e,{type:"raster",tiles:[t.url],tileSize:256}),this.map.addLayer({id:n,type:"raster",source:e});else{const r=this.map.getSource(e);r&&(r.tiles=[t.url],this.map.style.sourceCaches[e].clearTiles(),this.map.style.sourceCaches[e].update(this.map.transform),this.map.triggerRepaint())}},getLayerById(t){return this.baseLayers.find(e=>e.id===t)},initGeometryLayer(){const{map:t}=this;if(!t)return;const e=this.formatGeojson(this.geometry),n=t.getSource(yr);if(this.zoomToGeometry(e),n){n.setData(e);return}t.addSource(yr,{type:"geojson",data:e}),t.addLayer({id:`${yr}-point`,type:"circle",source:yr,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),t.addLayer({id:`${yr}-polygon`,type:"fill",source:yr,layout:{},paint:{"fill-color":"#4b0082","fill-opacity":.3},filter:["==","$type","Polygon"]}),t.addLayer({id:`${yr}-polygon-line`,type:"line",source:yr,layout:{},paint:{"line-color":"#4b0082","line-width":2},filter:["==","$type","Polygon"]}),t.addLayer({id:`${yr}-line`,type:"line",source:yr,layout:{},paint:{"line-color":"#4b0082","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(t){let e=t;const n=t==null?void 0:t.type;if(Array.isArray(t))return PE(t);if(!n)throw new Error("Unknown geometry type!");return n==="FeatureCollection"?t:(n==="Feature"&&(e=[t]),!["FeatureCollection","Feature"].includes(n)&&(e=[C5(t)]),PE(e))},zoomToGeometry(t){const{map:e}=this,n=S5(t);e.fitBounds(n,{padding:30,duration:0})},toggleGeometryVisibility(){[`${yr}-polygon`,`${yr}-polygon-line`,`${yr}-line`,`${yr}-point`].forEach(e=>{this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility",this.isGeometryVisible?"visible":"none")})},async setLayerVisible(t,e){await this.setVisible(t,e,this.map)},closeCard(){this.cardData=null,this.removeGeom("selected-feature")}}},F5={key:1,class:"bg-white absolute top-[10px] right-[10px] z-20 border rounded-lg cursor-pointer"},$5={class:"flex items-center justify-between p-2 border-b"},j5={class:"flex items-center"},H5=["value","onChange"],U5={class:"ml-2"},W5={key:0,class:"p-2 border-b"},q5={class:"flex items-center"},G5=["value","onChange"],Y5={class:"ml-2"},Z5={key:1,class:"p-2"},X5={class:"flex items-center"},K5=["id"];function J5(t,e,n,r,i,s){var o;const a=d.resolveComponent("IconClose");return d.openBlock(),d.createElementBlock("div",{class:"relative",ref:"relativeContainer",onClick:e[6]||(e[6]=(...p)=>s.updateCardPosition&&s.updateCardPosition(...p))},[i.isOpen?(d.openBlock(),d.createElementBlock("div",F5,[d.createElementVNode("div",$5,[e[7]||(e[7]=d.createElementVNode("div",null,"Шари",-1)),d.createVNode(a,{onClick:e[1]||(e[1]=p=>i.isOpen=!1),class:"w-4 h-4"})]),d.createElementVNode("div",{class:d.normalizeClass(["p-2 border-b",{"border-b":n.geometry}])},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.baseLayers,p=>(d.openBlock(),d.createElementBlock("div",{key:p.id},[d.createElementVNode("label",j5,[d.withDirectives(d.createElementVNode("input",{type:"radio",name:"base-layer",value:p.id,"onUpdate:modelValue":e[2]||(e[2]=g=>i.selectedBaseLayer=g),onChange:g=>s.changeBaseLayer(p)},null,40,H5),[[d.vModelRadio,i.selectedBaseLayer]]),d.createElementVNode("span",U5,d.toDisplayString(p.name),1)])]))),128))],2),(o=i.localLayers)!=null&&o.length?(d.openBlock(),d.createElementBlock("div",W5,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.localLayers,p=>(d.openBlock(),d.createElementBlock("div",{key:p.id},[d.createElementVNode("label",q5,[d.withDirectives(d.createElementVNode("input",{type:"checkbox",value:p.id,"onUpdate:modelValue":e[3]||(e[3]=g=>i.selectedLayers=g),onChange:g=>s.setLayerVisible(p,g.target.checked)},null,40,G5),[[d.vModelCheckbox,i.selectedLayers]]),d.createElementVNode("span",Y5,d.toDisplayString(p.name),1)])]))),128))])):d.createCommentVNode("",!0),n.geometry?(d.openBlock(),d.createElementBlock("div",Z5,[d.createElementVNode("label",X5,[d.withDirectives(d.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":e[4]||(e[4]=p=>i.isGeometryVisible=p),onChange:e[5]||(e[5]=(...p)=>s.toggleGeometryVisibility&&s.toggleGeometryVisibility(...p))},null,544),[[d.vModelCheckbox,i.isGeometryVisible]]),e[8]||(e[8]=d.createElementVNode("span",{class:"ml-2"},"Показати геометрію",-1))])])):d.createCommentVNode("",!0)])):(d.openBlock(),d.createElementBlock("div",{key:0,class:"bg-white absolute top-[10px] right-[10px] z-[1] p-2 border rounded-lg cursor-pointer",onClick:e[0]||(e[0]=p=>i.isOpen=!0)}," Шари ")),d.createElementVNode("div",{id:i.mapId,style:d.normalizeStyle({height:n.height})},null,12,K5),d.renderSlot(t.$slots,"card",{map:i.map,cardData:i.cardData,cardPosition:i.cardPosition,closeCard:s.closeCard})],512)}const gb=He(L5,[["render",J5]]),mt=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),yb=function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY,r=n.indexOf("hidden")!==-1,i=n.indexOf("visible")!==-1;return e&&!r&&!i},mm=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(yb(t)?t:mm(t.parentElement,e))},wo=function(t){var e=new DOMParser().parseFromString(t,"text/html").body;if(e.childElementCount>1){for(var n=document.createElement("div");e.firstChild;)n.appendChild(e.firstChild);return n}return e.firstChild},bb=t=>`${t||""}`.split(" ").filter(e=>!!e),ko=(t,e,n)=>{t&&bb(e).forEach(r=>{t.classList.toggle(r,n||!1)})};let xd=class{constructor(e){Object.defineProperty(this,"pageX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pageY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativePointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=e,this.pageX=e.pageX,this.pageY=e.pageY,this.clientX=e.clientX,this.clientY=e.clientY,this.id=self.Touch&&e instanceof Touch?e.identifier:-1,this.time=Date.now()}};const vd={passive:!1};let Q5=class{constructor(e,{start:n=()=>!0,move:r=()=>{},end:i=()=>{}}){Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"moveCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"currentPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"startPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=e,this.startCallback=n,this.moveCallback=r,this.endCallback=i;for(const s of["onPointerStart","onTouchStart","onMove","onTouchEnd","onPointerEnd","onWindowBlur"])this[s]=this[s].bind(this);this.element.addEventListener("mousedown",this.onPointerStart,vd),this.element.addEventListener("touchstart",this.onTouchStart,vd),this.element.addEventListener("touchmove",this.onMove,vd),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(e){if(!e.buttons||e.button!==0)return;const n=new xd(e);this.currentPointers.some(r=>r.id===n.id)||this.triggerPointerStart(n,e)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(e){for(const n of Array.from(e.changedTouches||[]))this.triggerPointerStart(new xd(n),e);window.addEventListener("blur",this.onWindowBlur)}onMove(e){const n=this.currentPointers.slice(),r="changedTouches"in e?Array.from(e.changedTouches||[]).map(s=>new xd(s)):[new xd(e)],i=[];for(const s of r){const a=this.currentPointers.findIndex(o=>o.id===s.id);a<0||(i.push(s),this.currentPointers[a]=s)}i.length&&this.moveCallback(e,this.currentPointers.slice(),n)}onPointerEnd(e){e.buttons>0&&e.button!==0||(this.triggerPointerEnd(e,new xd(e)),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur))}onTouchEnd(e){for(const n of Array.from(e.changedTouches||[]))this.triggerPointerEnd(e,new xd(n))}triggerPointerStart(e,n){return!!this.startCallback(n,e,this.currentPointers.slice())&&(this.currentPointers.push(e),this.startPointers.push(e),!0)}triggerPointerEnd(e,n){const r=this.currentPointers.findIndex(i=>i.id===n.id);r<0||(this.currentPointers.splice(r,1),this.startPointers.splice(r,1),this.endCallback(e,n,this.currentPointers.slice()))}onWindowBlur(){this.clear()}clear(){for(;this.currentPointers.length;){const e=this.currentPointers[this.currentPointers.length-1];this.currentPointers.splice(this.currentPointers.length-1,1),this.startPointers.splice(this.currentPointers.length-1,1),this.endCallback(new Event("touchend",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY}),e,this.currentPointers.slice())}}stop(){this.element.removeEventListener("mousedown",this.onPointerStart,vd),this.element.removeEventListener("touchstart",this.onTouchStart,vd),this.element.removeEventListener("touchmove",this.onMove,vd),this.element.removeEventListener("touchend",this.onTouchEnd),this.element.removeEventListener("touchcancel",this.onTouchEnd),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur)}};function OE(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function BE(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const _b=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.prototype.toString.call(t)==="[object Object]",Zi=(t,...e)=>{const n=e.length;for(let r=0;r<n;r++){const i=e[r]||{};Object.entries(i).forEach(([s,a])=>{const o=Array.isArray(a)?[]:{};t[s]||Object.assign(t,{[s]:o}),_b(a)?Object.assign(t[s],Zi(o,a)):Array.isArray(a)?Object.assign(t,{[s]:[...a]}):Object.assign(t,{[s]:a})})}return t},xb=function(t,e){return t.split(".").reduce((n,r)=>typeof n=="object"?n[r]:void 0,e)};let gm=class{constructor(e={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(e);for(const n of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))n.startsWith("on")&&typeof this[n]=="function"&&(this[n]=this[n].bind(this))}setOptions(e){this.options=e?Zi({},this.constructor.defaults,e):{};for(const[n,r]of Object.entries(this.option("on")||{}))this.on(n,r)}option(e,...n){let r=xb(e,this.options);return r&&typeof r=="function"&&(r=r.call(this,this,...n)),r}optionFor(e,n,r,...i){let s=xb(n,e);var a;typeof(a=s)!="string"||isNaN(a)||isNaN(parseFloat(a))||(s=parseFloat(s)),s==="true"&&(s=!0),s==="false"&&(s=!1),s&&typeof s=="function"&&(s=s.call(this,this,e,...i));let o=xb(n,this.options);return o&&typeof o=="function"?s=o.call(this,this,e,...i,s):s===void 0&&(s=o),s===void 0?r:s}cn(e){const n=this.options.classes;return n&&n[e]||""}localize(e,n=[]){e=String(e).replace(/\{\{(\w+).?(\w+)?\}\}/g,(r,i,s)=>{let a="";return s?a=this.option(`${i[0]+i.toLowerCase().substring(1)}.l10n.${s}`):i&&(a=this.option(`l10n.${i}`)),a||(a=r),a});for(let r=0;r<n.length;r++)e=e.split(n[r][0]).join(n[r][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(r,i)=>i)}on(e,n){let r=[];typeof e=="string"?r=e.split(" "):Array.isArray(e)&&(r=e),this.events||(this.events=new Map),r.forEach(i=>{let s=this.events.get(i);s||(this.events.set(i,[]),s=[]),s.includes(n)||s.push(n),this.events.set(i,s)})}off(e,n){let r=[];typeof e=="string"?r=e.split(" "):Array.isArray(e)&&(r=e),r.forEach(i=>{const s=this.events.get(i);if(Array.isArray(s)){const a=s.indexOf(n);a>-1&&s.splice(a,1)}})}emit(e,...n){[...this.events.get(e)||[]].forEach(r=>r(this,...n)),e!=="*"&&this.emit("*",e,...n)}};Object.defineProperty(gm,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(gm,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});let vb=class extends gm{constructor(e={}){super(e),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(e={}){const n=new Map;for(const[r,i]of Object.entries(e)){const s=this.option(r),a=this.plugins[r];a||s===!1?a&&s===!1&&(a.detach(),delete this.plugins[r]):n.set(r,new i(this,s||{}))}for(const[r,i]of n)this.plugins[r]=i,i.attach()}detachPlugins(e){e=e||Object.keys(this.plugins);for(const n of e){const r=this.plugins[n];r&&r.detach(),delete this.plugins[n]}return this.emit("detachPlugins"),this}};var Hn;(function(t){t[t.Init=0]="Init",t[t.Error=1]="Error",t[t.Ready=2]="Ready",t[t.Panning=3]="Panning",t[t.Mousemove=4]="Mousemove",t[t.Destroy=5]="Destroy"})(Hn||(Hn={}));const ta=["a","b","c","d","e","f"],VE={PANUP:"Move up",PANDOWN:"Move down",PANLEFT:"Move left",PANRIGHT:"Move right",ZOOMIN:"Zoom in",ZOOMOUT:"Zoom out",TOGGLEZOOM:"Toggle zoom level",TOGGLE1TO1:"Toggle zoom level",ITERATEZOOM:"Toggle zoom level",ROTATECCW:"Rotate counterclockwise",ROTATECW:"Rotate clockwise",FLIPX:"Flip horizontally",FLIPY:"Flip vertically",FITX:"Fit horizontally",FITY:"Fit vertically",RESET:"Reset",TOGGLEFS:"Toggle fullscreen"},e3={content:null,width:"auto",height:"auto",panMode:"drag",touch:!0,dragMinThreshold:3,lockAxis:!1,mouseMoveFactor:1,mouseMoveFriction:.12,zoom:!0,pinchToZoom:!0,panOnlyZoomed:"auto",minScale:1,maxScale:2,friction:.25,dragFriction:.35,decelFriction:.05,click:"toggleZoom",dblClick:!1,wheel:"zoom",wheelLimit:7,spinner:!0,bounds:"auto",infinite:!1,rubberband:!0,bounce:!0,maxVelocity:75,transformParent:!1,classes:{content:"f-panzoom__content",isLoading:"is-loading",canZoomIn:"can-zoom_in",canZoomOut:"can-zoom_out",isDraggable:"is-draggable",isDragging:"is-dragging",inFullscreen:"in-fullscreen",htmlHasFullscreen:"with-panzoom-in-fullscreen"},l10n:VE},zE='<circle cx="25" cy="25" r="20"></circle>',wb='<div class="f-spinner"><svg viewBox="0 0 50 50">'+zE+zE+"</svg></div>",Xi=t=>t&&t!==null&&t instanceof Element&&"nodeType"in t,Ln=(t,e)=>{t&&bb(e).forEach(n=>{t.classList.remove(n)})},Ot=(t,e)=>{t&&bb(e).forEach(n=>{t.classList.add(n)})},ym={a:1,b:0,c:0,d:1,e:0,f:0},t3=1e5,bm=1e4,Vs="mousemove",LE="drag",FE="content",zs="auto";let kb=null,Eb=null,wd=class yN extends vb{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return Eb===null&&(Eb=window.matchMedia("(hover: none)").matches),Eb}get isMobile(){return kb===null&&(kb=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),kb}get panMode(){return this.options.panMode!==Vs||this.isTouchDevice?LE:Vs}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===zs?this.isTouchDevice:e}get isInfinite(){return this.option("infinite")}get angle(){return 180*Math.atan2(this.current.b,this.current.a)/Math.PI||0}get targetAngle(){return 180*Math.atan2(this.target.b,this.target.a)/Math.PI||0}get scale(){const{a:e,b:n}=this.current;return Math.sqrt(e*e+n*n)||1}get targetScale(){const{a:e,b:n}=this.target;return Math.sqrt(e*e+n*n)||1}get minScale(){return this.option("minScale")||1}get fullScale(){const{contentRect:e}=this;return e.fullWidth/e.fitWidth||1}get maxScale(){return this.fullScale*(this.option("maxScale")||1)||1}get coverScale(){const{containerRect:e,contentRect:n}=this,r=Math.max(e.height/n.fitHeight,e.width/n.fitWidth)||1;return Math.min(this.fullScale,r)}get isScaling(){return Math.abs(this.targetScale-this.scale)>1e-5&&!this.isResting}get isContentLoading(){const e=this.content;return!!(e&&e instanceof HTMLImageElement)&&!e.complete}get isResting(){if(this.isBouncingX||this.isBouncingY)return!1;for(const e of ta){const n=e=="e"||e==="f"?1e-4:1e-5;if(Math.abs(this.target[e]-this.current[e])>n)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(e,n={},r={}){var i;if(super(n),Object.defineProperty(this,"pointerTracker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"resizeObserver",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"updateTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"clickTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rAF",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isTicking",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreBounds",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingX",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingY",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"clicks",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"trackingPoints",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pwt",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"cwd",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pmme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"friction",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Hn.Init}),Object.defineProperty(this,"isDragging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"spinner",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"containerRect",{enumerable:!0,configurable:!0,writable:!0,value:{width:0,height:0,innerWidth:0,innerHeight:0}}),Object.defineProperty(this,"contentRect",{enumerable:!0,configurable:!0,writable:!0,value:{top:0,right:0,bottom:0,left:0,fullWidth:0,fullHeight:0,fitWidth:0,fitHeight:0,width:0,height:0}}),Object.defineProperty(this,"dragStart",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,top:0,left:0,time:0}}),Object.defineProperty(this,"dragOffset",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,time:0}}),Object.defineProperty(this,"current",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},ym)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},ym)}),Object.defineProperty(this,"velocity",{enumerable:!0,configurable:!0,writable:!0,value:{a:0,b:0,c:0,d:0,e:0,f:0}}),Object.defineProperty(this,"lockedAxis",{enumerable:!0,configurable:!0,writable:!0,value:!1}),!e)throw new Error("Container Element Not Found");this.container=e,this.initContent(),this.attachPlugins(Object.assign(Object.assign({},yN.Plugins),r)),this.emit("attachPlugins"),this.emit("init");const s=this.content;if(s.addEventListener("load",this.onLoad),s.addEventListener("error",this.onError),this.isContentLoading){if(this.option("spinner")){e.classList.add(this.cn("isLoading"));const a=wo(wb);!e.contains(s)||s.parentElement instanceof HTMLPictureElement?this.spinner=e.appendChild(a):this.spinner=((i=s.parentElement)===null||i===void 0?void 0:i.insertBefore(a,s))||null}this.emit("beforeLoad")}else queueMicrotask(()=>{this.enable()})}initContent(){const{container:e}=this,n=this.cn(FE);let r=this.option(FE)||e.querySelector(`.${n}`);if(r||(r=e.querySelector("img,picture")||e.firstElementChild,r&&Ot(r,n)),r instanceof HTMLPictureElement&&(r=r.querySelector("img")),!r)throw new Error("No content found");this.content=r}onLoad(){const{spinner:e,container:n,state:r}=this;e&&(e.remove(),this.spinner=null),this.option("spinner")&&n.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),r===Hn.Init?this.enable():this.updateMetrics()}onError(){this.state!==Hn.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=Hn.Error,this.emit("error"))}getNextScale(e){const{fullScale:n,targetScale:r,coverScale:i,maxScale:s,minScale:a}=this;let o=a;switch(e){case"toggleMax":o=r-a<.5*(s-a)?s:a;break;case"toggleCover":o=r-a<.5*(i-a)?i:a;break;case"toggleZoom":o=r-a<.5*(n-a)?n:a;break;case"iterateZoom":let p=[1,n,s].sort((y,v)=>y-v),g=p.findIndex(y=>y>r+1e-5);o=p[g]||1}return o}attachObserver(){var e;const n=()=>{const{container:r,containerRect:i}=this;return Math.abs(i.width-r.getBoundingClientRect().width)>.1||Math.abs(i.height-r.getBoundingClientRect().height)>.1};this.resizeObserver||window.ResizeObserver===void 0||(this.resizeObserver=new ResizeObserver(()=>{this.updateTimer||(n()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout(()=>{n()&&this.onResize(),this.updateTimer=null},500))):this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null))})),(e=this.resizeObserver)===null||e===void 0||e.observe(this.container)}detachObserver(){var e;(e=this.resizeObserver)===null||e===void 0||e.disconnect()}attachEvents(){const{container:e}=this;e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("wheel",this.onWheel,{passive:!1}),this.pointerTracker=new Q5(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(Vs,this.onMouseMove)}detachEvents(){var e;const{container:n}=this;n.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),n.removeEventListener("wheel",this.onWheel,{passive:!1}),(e=this.pointerTracker)===null||e===void 0||e.stop(),this.pointerTracker=null,document.removeEventListener(Vs,this.onMouseMove),document.removeEventListener("keydown",this.onKeydown,!0),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}animate(){this.setTargetForce();const e=this.friction,n=this.option("maxVelocity");for(const r of ta)e?(this.velocity[r]*=1-e,n&&!this.isScaling&&(this.velocity[r]=Math.max(Math.min(this.velocity[r],n),-1*n)),this.current[r]+=this.velocity[r]):this.current[r]=this.target[r];this.setTransform(),this.setEdgeForce(),!this.isResting||this.isDragging?this.rAF=requestAnimationFrame(()=>this.animate()):this.stop("current")}setTargetForce(){for(const e of ta)e==="e"&&this.isBouncingX||e==="f"&&this.isBouncingY||(this.velocity[e]=(1/(1-this.friction)-1)*(this.target[e]-this.current[e]))}checkBounds(e=0,n=0){const{current:r}=this,i=r.e+e,s=r.f+n,a=this.getBounds(),{x:o,y:p}=a,g=o.min,y=o.max,v=p.min,k=p.max;let T=0,D=0;return g!==1/0&&i<g?T=g-i:y!==1/0&&i>y&&(T=y-i),v!==1/0&&s<v?D=v-s:k!==1/0&&s>k&&(D=k-s),Math.abs(T)<1e-4&&(T=0),Math.abs(D)<1e-4&&(D=0),Object.assign(Object.assign({},a),{xDiff:T,yDiff:D,inBounds:!T&&!D})}clampTargetBounds(){const{target:e}=this,{x:n,y:r}=this.getBounds();n.min!==1/0&&(e.e=Math.max(e.e,n.min)),n.max!==1/0&&(e.e=Math.min(e.e,n.max)),r.min!==1/0&&(e.f=Math.max(e.f,r.min)),r.max!==1/0&&(e.f=Math.min(e.f,r.max))}calculateContentDim(e=this.current){const{content:n,contentRect:r}=this,{fitWidth:i,fitHeight:s,fullWidth:a,fullHeight:o}=r;let p=a,g=o;if(this.option("zoom")||this.angle!==0){const y=!(n instanceof HTMLImageElement)&&(window.getComputedStyle(n).maxWidth==="none"||window.getComputedStyle(n).maxHeight==="none"),v=y?a:i,k=y?o:s,T=this.getMatrix(e),D=new DOMPoint(0,0).matrixTransform(T),N=new DOMPoint(0+v,0).matrixTransform(T),B=new DOMPoint(0+v,0+k).matrixTransform(T),L=new DOMPoint(0,0+k).matrixTransform(T),U=Math.abs(B.x-D.x),Z=Math.abs(B.y-D.y),Y=Math.abs(L.x-N.x),he=Math.abs(L.y-N.y);p=Math.max(U,Y),g=Math.max(Z,he)}return{contentWidth:p,contentHeight:g}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===Vs||this.targetScale<this.scale)return this.isBouncingX=!1,void(this.isBouncingY=!1);const{target:e}=this,{x:n,y:r,xDiff:i,yDiff:s}=this.checkBounds(),a=this.option("maxVelocity");let o=this.velocity.e,p=this.velocity.f;i!==0?(this.isBouncingX=!0,i*o<=0?o+=.14*i:(o=.14*i,n.min!==1/0&&(this.target.e=Math.max(e.e,n.min)),n.max!==1/0&&(this.target.e=Math.min(e.e,n.max))),a&&(o=Math.max(Math.min(o,a),-1*a))):this.isBouncingX=!1,s!==0?(this.isBouncingY=!0,s*p<=0?p+=.14*s:(p=.14*s,r.min!==1/0&&(this.target.f=Math.max(e.f,r.min)),r.max!==1/0&&(this.target.f=Math.min(e.f,r.max))),a&&(p=Math.max(Math.min(p,a),-1*a))):this.isBouncingY=!1,this.isBouncingX&&(this.velocity.e=o),this.isBouncingY&&(this.velocity.f=p)}enable(){const{content:e}=this,n=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const r of ta)this.current[r]=this.target[r]=n[r];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=Hn.Ready,this.emit("ready")}onClick(e){var n;e.type==="click"&&e.detail===0&&(this.dragOffset.x=0,this.dragOffset.y=0),this.isDragging&&((n=this.pointerTracker)===null||n===void 0||n.clear(),this.trackingPoints=[],this.startDecelAnim());const r=e.target;if(!r||e.defaultPrevented)return;if(r.hasAttribute("disabled"))return e.preventDefault(),void e.stopPropagation();if((()=>{const T=window.getSelection();return T&&T.type==="Range"})()&&!r.closest("button"))return;const i=r.closest("[data-panzoom-action]"),s=r.closest("[data-panzoom-change]"),a=i||s,o=a&&Xi(a)?a.dataset:null;if(o){const T=o.panzoomChange,D=o.panzoomAction;if((T||D)&&e.preventDefault(),T){let N={};try{N=JSON.parse(T)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(N)}if(D)return void(this[D]&&this[D]())}if(Math.abs(this.dragOffset.x)>3||Math.abs(this.dragOffset.y)>3)return e.preventDefault(),void e.stopPropagation();if(r.closest("[data-fancybox]"))return;const p=this.content.getBoundingClientRect(),g=this.dragStart;if(g.time&&!this.canZoomOut()&&(Math.abs(p.x-g.x)>2||Math.abs(p.y-g.y)>2))return;this.dragStart.time=0;const y=T=>{this.option("zoom",e)&&T&&typeof T=="string"&&/(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(T)&&typeof this[T]=="function"&&(e.preventDefault(),this[T]({event:e}))},v=this.option("click",e),k=this.option("dblClick",e);k?(this.clicks++,this.clicks==1&&(this.clickTimer=setTimeout(()=>{this.clicks===1?(this.emit("click",e),!e.defaultPrevented&&v&&y(v)):(this.emit("dblClick",e),e.defaultPrevented||y(k)),this.clicks=0,this.clickTimer=null},350))):(this.emit("click",e),!e.defaultPrevented&&v&&y(v))}addTrackingPoint(e){const n=this.trackingPoints.filter(r=>r.time>Date.now()-100);n.push(e),this.trackingPoints=n}onPointerDown(e,n,r){var i;if(this.option("touch",e)===!1)return!1;this.pwt=0,this.dragOffset={x:0,y:0,time:0},this.trackingPoints=[];const s=this.content.getBoundingClientRect();if(this.dragStart={x:s.x,y:s.y,top:s.top,left:s.left,time:Date.now()},this.clickTimer)return!1;if(this.panMode===Vs&&this.targetScale>1)return e.preventDefault(),e.stopPropagation(),!1;const a=e.composedPath()[0];if(!r.length){if(["TEXTAREA","OPTION","INPUT","SELECT","VIDEO","IFRAME"].includes(a.nodeName)||a.closest("[contenteditable],[data-selectable],[data-draggable],[data-clickable],[data-panzoom-change],[data-panzoom-action]"))return!1;(i=window.getSelection())===null||i===void 0||i.removeAllRanges()}if(e.type==="mousedown")["A","BUTTON"].includes(a.nodeName)||e.preventDefault();else if(Math.abs(this.velocity.a)>.3)return!1;return this.target.e=this.current.e,this.target.f=this.current.f,this.stop(),this.isDragging||(this.isDragging=!0,this.addTrackingPoint(n),this.emit("touchStart",e)),!0}onPointerMove(e,n,r){if(this.option("touch",e)===!1||!this.isDragging||n.length<2&&this.panOnlyZoomed&&mt(this.targetScale)<=mt(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(n[0]);const{content:i}=this,s=BE(r[0],r[1]),a=BE(n[0],n[1]);let o=0,p=0;if(n.length>1){const Z=i.getBoundingClientRect();o=s.clientX-Z.left-.5*Z.width,p=s.clientY-Z.top-.5*Z.height}const g=OE(r[0],r[1]),y=OE(n[0],n[1]);let v=g?y/g:1,k=a.clientX-s.clientX,T=a.clientY-s.clientY;this.dragOffset.x+=k,this.dragOffset.y+=T,this.dragOffset.time=Date.now()-this.dragStart.time;let D=mt(this.targetScale)===mt(this.minScale)&&this.option("lockAxis");if(D&&!this.lockedAxis)if(D==="xy"||D==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const Z=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=Z>45&&Z<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,k=0,T=0}else this.lockedAxis=D;if(mm(e.target,this.content)&&(D="x",this.dragOffset.y=0),D&&D!=="xy"&&this.lockedAxis!==D&&mt(this.targetScale)===mt(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const N=this.checkBounds(k,T);this.option("rubberband")?(this.isInfinite!=="x"&&(N.xDiff>0&&k<0||N.xDiff<0&&k>0)&&(k*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*N.xDiff))),this.isInfinite!=="y"&&(N.yDiff>0&&T<0||N.yDiff<0&&T>0)&&(T*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*N.yDiff)))):(N.xDiff&&(k=0),N.yDiff&&(T=0));const B=this.targetScale,L=this.minScale,U=this.maxScale;B<.5*L&&(v=Math.max(v,L)),B>1.5*U&&(v=Math.min(v,U)),this.lockedAxis==="y"&&mt(B)===mt(L)&&(k=0),this.lockedAxis==="x"&&mt(B)===mt(L)&&(T=0),this.applyChange({originX:o,originY:p,panX:k,panY:T,scale:v,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(e,n,r){if(r.length)return this.dragOffset.x=0,this.dragOffset.y=0,void(this.trackingPoints=[]);this.container.classList.remove(this.cn("isDragging")),this.isDragging&&(this.addTrackingPoint(n),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),mm(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==Hn.Destroy&&(e.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const n=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const Z of ta)this.velocity[Z]=0;this.target.e=this.current.e,this.target.f=this.current.f,Ln(this.container,"is-scaling"),Ln(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:r}=this,i=r[0],s=r[r.length-1];let a=0,o=0,p=0;s&&i&&(a=s.clientX-i.clientX,o=s.clientY-i.clientY,p=s.time-i.time);const g=((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1;g!==1&&(a*=g,o*=g);let y=0,v=0,k=0,T=0,D=this.option("decelFriction");const N=this.targetScale;if(p>0){k=Math.abs(a)>3?a/(p/30):0,T=Math.abs(o)>3?o/(p/30):0;const Z=this.option("maxVelocity");Z&&(k=Math.max(Math.min(k,Z),-1*Z),T=Math.max(Math.min(T,Z),-1*Z))}k&&(y=k/(1/(1-D)-1)),T&&(v=T/(1/(1-D)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&mt(N)===this.minScale)&&(y=k=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&mt(N)===this.minScale)&&(v=T=0);const B=this.dragOffset.x,L=this.dragOffset.y,U=this.option("dragMinThreshold")||0;Math.abs(B)<U&&Math.abs(L)<U&&(y=v=0,k=T=0),(this.option("zoom")&&(N<this.minScale-1e-5||N>this.maxScale+1e-5)||n&&!y&&!v)&&(D=.35),this.applyChange({panX:y,panY:v,friction:D}),this.emit("decel",k,T,B,L)}onWheel(e){var n=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(s,a){return Math.abs(a)>Math.abs(s)?a:s});const r=Math.max(-1,Math.min(1,n));if(this.emit("wheel",e,r),this.panMode===Vs||e.defaultPrevented)return;const i=this.option("wheel");i==="pan"?(e.preventDefault(),this.panOnlyZoomed&&!this.canZoomOut()||this.applyChange({panX:2*-e.deltaX,panY:2*-e.deltaY,bounce:!1})):i==="zoom"&&this.option("zoom")!==!1&&this.zoomWithWheel(e)}onMouseMove(e){this.panWithMouse(e)}onKeydown(e){e.key==="Escape"&&this.toggleFS()}onResize(){this.updateMetrics(),this.checkBounds().inBounds||this.requestTick()}setTransform(){this.emit("beforeTransform");const{current:e,target:n,content:r,contentRect:i}=this,s=Object.assign({},ym);for(const B of ta){const L=B=="e"||B==="f"?bm:t3;s[B]=mt(e[B],L),Math.abs(n[B]-e[B])<(B=="e"||B==="f"?.51:.001)&&(e[B]=n[B])}let{a,b:o,c:p,d:g,e:y,f:v}=s,k=`matrix(${a}, ${o}, ${p}, ${g}, ${y}, ${v})`,T=r.parentElement instanceof HTMLPictureElement?r.parentElement:r;if(this.option("transformParent")&&(T=T.parentElement||T),T.style.transform===k)return;T.style.transform=k;const{contentWidth:D,contentHeight:N}=this.calculateContentDim();i.width=D,i.height=N,this.emit("afterTransform")}updateMetrics(e=!1){var n;if(!this||this.state===Hn.Destroy||this.isContentLoading)return;const r=Math.max(1,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1),{container:i,content:s}=this,a=s instanceof HTMLImageElement,o=i.getBoundingClientRect(),p=getComputedStyle(this.container);let g=o.width*r,y=o.height*r;const v=parseFloat(p.paddingTop)+parseFloat(p.paddingBottom),k=g-(parseFloat(p.paddingLeft)+parseFloat(p.paddingRight)),T=y-v;this.containerRect={width:g,height:y,innerWidth:k,innerHeight:T};const D=parseFloat(s.dataset.width||"")||(qe=>{let fe=0;return fe=qe instanceof HTMLImageElement?qe.naturalWidth:qe instanceof SVGElement?qe.width.baseVal.value:Math.max(qe.offsetWidth,qe.scrollWidth),fe||0})(s),N=parseFloat(s.dataset.height||"")||(qe=>{let fe=0;return fe=qe instanceof HTMLImageElement?qe.naturalHeight:qe instanceof SVGElement?qe.height.baseVal.value:Math.max(qe.offsetHeight,qe.scrollHeight),fe||0})(s);let B=this.option("width",D)||zs,L=this.option("height",N)||zs;const U=B===zs,Z=L===zs;typeof B!="number"&&(B=D),typeof L!="number"&&(L=N),U&&(B=D*(L/N)),Z&&(L=N/(D/B));let Y=s.parentElement instanceof HTMLPictureElement?s.parentElement:s;this.option("transformParent")&&(Y=Y.parentElement||Y);const he=Y.getAttribute("style")||"";Y.style.setProperty("transform","none","important"),a&&(Y.style.width="",Y.style.height=""),Y.offsetHeight;const me=s.getBoundingClientRect();let xe=me.width*r,Re=me.height*r,ke=xe,Oe=Re;xe=Math.min(xe,B),Re=Math.min(Re,L),a?{width:xe,height:Re}=((qe,fe,ht,Mt)=>{const Dt=ht/qe,Bt=Mt/fe,qt=Math.min(Dt,Bt);return{width:qe*=qt,height:fe*=qt}})(B,L,xe,Re):(xe=Math.min(xe,B),Re=Math.min(Re,L));let Le=.5*(Oe-Re),Fe=.5*(ke-xe);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:me.top-o.top+Le,bottom:o.bottom-me.bottom+Le,left:me.left-o.left+Fe,right:o.right-me.right+Fe,fitWidth:xe,fitHeight:Re,width:xe,height:Re,fullWidth:B,fullHeight:L}),Y.style.cssText=he,a&&(Y.style.width=`${xe}px`,Y.style.height=`${Re}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(mt(this.targetScale)<mt(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===Hn.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}calculateBounds(){const{contentWidth:e,contentHeight:n}=this.calculateContentDim(this.target),{targetScale:r,lockedAxis:i}=this,{fitWidth:s,fitHeight:a}=this.contentRect;let o=0,p=0,g=0,y=0;const v=this.option("infinite");if(v===!0||i&&v===i)o=-1/0,g=1/0,p=-1/0,y=1/0;else{let{containerRect:k,contentRect:T}=this,D=mt(s*r,bm),N=mt(a*r,bm),{innerWidth:B,innerHeight:L}=k;if(k.width===D&&(B=k.width),k.width===N&&(L=k.height),e>B){g=.5*(e-B),o=-1*g;let U=.5*(T.right-T.left);o+=U,g+=U}if(s>B&&e<B&&(o-=.5*(s-B),g-=.5*(s-B)),n>L){y=.5*(n-L),p=-1*y;let U=.5*(T.bottom-T.top);p+=U,y+=U}a>L&&n<L&&(o-=.5*(a-L),g-=.5*(a-L))}return{x:{min:o,max:g},y:{min:p,max:y}}}getBounds(){const e=this.option("bounds");return e!==zs?e:this.calculateBounds()}updateControls(){const e=this,n=e.container,{panMode:r,contentRect:i,targetScale:s,minScale:a}=e;let o=a,p=e.option("click")||!1;p&&(o=e.getNextScale(p));let g=e.canZoomIn(),y=e.canZoomOut(),v=r===LE&&!!this.option("touch"),k=y&&v;if(v&&(mt(s)<mt(a)&&!this.panOnlyZoomed&&(k=!0),(mt(i.width,1)>mt(i.fitWidth,1)||mt(i.height,1)>mt(i.fitHeight,1))&&(k=!0)),mt(i.width*s,1)<mt(i.fitWidth,1)&&(k=!1),r===Vs&&(k=!1),ko(n,this.cn("isDraggable"),k),!this.option("zoom"))return;let T=g&&mt(o)>mt(s),D=!T&&!k&&y&&mt(o)<mt(s);ko(n,this.cn("canZoomIn"),T),ko(n,this.cn("canZoomOut"),D);for(const N of n.querySelectorAll("[data-panzoom-action]")){let B=!1,L=!1;switch(N.dataset.panzoomAction){case"zoomIn":g?B=!0:L=!0;break;case"zoomOut":y?B=!0:L=!0;break;case"toggleZoom":case"iterateZoom":g||y?B=!0:L=!0;const U=N.querySelector("g");U&&(U.style.display=g?"":"none")}B?(N.removeAttribute("disabled"),N.removeAttribute("tabindex")):L&&(N.setAttribute("disabled",""),N.setAttribute("tabindex","-1"))}}panTo({x:e=this.target.e,y:n=this.target.f,scale:r=this.targetScale,friction:i=this.option("friction"),angle:s=0,originX:a=0,originY:o=0,flipX:p=!1,flipY:g=!1,ignoreBounds:y=!1}){this.state!==Hn.Destroy&&this.applyChange({panX:e-this.target.e,panY:n-this.target.f,scale:r/this.targetScale,angle:s,originX:a,originY:o,friction:i,flipX:p,flipY:g,ignoreBounds:y})}applyChange({panX:e=0,panY:n=0,scale:r=1,angle:i=0,originX:s=-this.current.e,originY:a=-this.current.f,friction:o=this.option("friction"),flipX:p=!1,flipY:g=!1,ignoreBounds:y=!1,bounce:v=this.option("bounce")}){const k=this.state;if(k===Hn.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=o||0,this.ignoreBounds=y;const{current:T}=this,D=T.e,N=T.f,B=this.getMatrix(this.target);let L=new DOMMatrix().translate(D,N).translate(s,a).translate(e,n);if(this.option("zoom")){if(!y){const U=this.targetScale,Z=this.minScale,Y=this.maxScale;U*r<Z&&(r=Z/U),U*r>Y&&(r=Y/U)}L=L.scale(r)}L=L.translate(-s,-a).translate(-D,-N).multiply(B),i&&(L=L.rotate(i)),p&&(L=L.scale(-1,1)),g&&(L=L.scale(1,-1));for(const U of ta)U!=="e"&&U!=="f"&&(L[U]>this.minScale+1e-5||L[U]<this.minScale-1e-5)?this.target[U]=L[U]:this.target[U]=mt(L[U],bm);(this.targetScale<this.scale||Math.abs(r-1)>.1||this.panMode===Vs||v===!1)&&!y&&this.clampTargetBounds(),k===Hn.Init?this.animate():this.isResting||(this.state=Hn.Panning,this.requestTick())}stop(e=!1){if(this.state===Hn.Init||this.state===Hn.Destroy)return;const n=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const r of ta)this.velocity[r]=0,e==="current"?this.current[r]=this.target[r]:e==="target"&&(this.target[r]=this.current[r]);this.setTransform(),Ln(this.container,"is-scaling"),Ln(this.container,"is-animating"),this.isTicking=!1,this.state=Hn.Ready,n&&(this.emit("endAnimation"),this.updateControls())}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),Ot(this.container,"is-animating"),this.isScaling&&Ot(this.container,"is-scaling")),this.isTicking=!0,this.rAF||(this.rAF=requestAnimationFrame(()=>this.animate()))}panWithMouse(e,n=this.option("mouseMoveFriction")){if(this.pmme=e,this.panMode!==Vs||!e||mt(this.targetScale)<=mt(this.minScale))return;this.emit("mouseMove",e);const{container:r,containerRect:i,contentRect:s}=this,a=i.width,o=i.height,p=r.getBoundingClientRect(),g=(e.clientX||0)-p.left,y=(e.clientY||0)-p.top;let{contentWidth:v,contentHeight:k}=this.calculateContentDim(this.target);const T=this.option("mouseMoveFactor");T>1&&(v!==a&&(v*=T),k!==o&&(k*=T));let D=.5*(v-a)-g/a*100/100*(v-a);D+=.5*(s.right-s.left);let N=.5*(k-o)-y/o*100/100*(k-o);N+=.5*(s.bottom-s.top),this.applyChange({panX:D-this.target.e,panY:N-this.target.f,friction:n})}zoomWithWheel(e){if(this.state===Hn.Destroy||this.state===Hn.Init)return;const n=Date.now();if(n-this.pwt<45)return void e.preventDefault();this.pwt=n;var r=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(g,y){return Math.abs(y)>Math.abs(g)?y:g});const i=Math.max(-1,Math.min(1,r)),{targetScale:s,maxScale:a,minScale:o}=this;let p=s*(100+45*i)/100;mt(p)<mt(o)&&mt(s)<=mt(o)?(this.cwd+=Math.abs(i),p=o):mt(p)>mt(a)&&mt(s)>=mt(a)?(this.cwd+=Math.abs(i),p=a):(this.cwd=0,p=Math.max(Math.min(p,a),o)),this.cwd>this.option("wheelLimit")||(e.preventDefault(),mt(p)!==mt(s)&&this.zoomTo(p,{event:e}))}canZoomIn(){return this.option("zoom")&&(mt(this.contentRect.width,1)<mt(this.contentRect.fitWidth,1)||mt(this.targetScale)<mt(this.maxScale))}canZoomOut(){return this.option("zoom")&&mt(this.targetScale)>mt(this.minScale)}zoomIn(e=1.25,n){this.zoomTo(this.targetScale*e,n)}zoomOut(e=.8,n){this.zoomTo(this.targetScale*e,n)}zoomToFit(e){this.zoomTo("fit",e)}zoomToCover(e){this.zoomTo("cover",e)}zoomToFull(e){this.zoomTo("full",e)}zoomToMax(e){this.zoomTo("max",e)}toggleZoom(e){this.zoomTo(this.getNextScale("toggleZoom"),e)}toggleMax(e){this.zoomTo(this.getNextScale("toggleMax"),e)}toggleCover(e){this.zoomTo(this.getNextScale("toggleCover"),e)}iterateZoom(e){this.zoomTo("next",e)}zoomTo(e=1,{friction:n=zs,originX:r=zs,originY:i=zs,event:s}={}){if(this.isContentLoading||this.state===Hn.Destroy)return;const{targetScale:a,fullScale:o,maxScale:p,coverScale:g}=this;if(this.stop(),this.panMode===Vs&&(s=this.pmme||s),s||r===zs||i===zs){const v=this.content.getBoundingClientRect(),k=this.container.getBoundingClientRect(),T=s?s.clientX:k.left+.5*k.width,D=s?s.clientY:k.top+.5*k.height;r=T-v.left-.5*v.width,i=D-v.top-.5*v.height}let y=1;typeof e=="number"?y=e:e==="full"?y=o:e==="cover"?y=g:e==="max"?y=p:e==="fit"?y=1:e==="next"&&(y=this.getNextScale("iterateZoom")),y=y/a||1,n=n===zs?y>1?.15:.25:n,this.applyChange({scale:y,originX:r,originY:i,friction:n}),s&&this.panMode===Vs&&this.panWithMouse(s,n)}rotateCCW(){this.applyChange({angle:-90})}rotateCW(){this.applyChange({angle:90})}flipX(){this.applyChange({flipX:!0})}flipY(){this.applyChange({flipY:!0})}fitX(){this.stop("target");const{containerRect:e,contentRect:n,target:r}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-r.e,panY:.5*e.height-(n.top+.5*n.fitHeight)-r.f,scale:e.width/n.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:e,contentRect:n,target:r}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-r.e,panY:.5*e.innerHeight-(n.top+.5*n.fitHeight)-r.f,scale:e.height/n.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:e}=this,n=this.cn("inFullscreen"),r=this.cn("htmlHasFullscreen");e.classList.toggle(n);const i=e.classList.contains(n);i?(document.documentElement.classList.add(r),document.addEventListener("keydown",this.onKeydown,!0)):(document.documentElement.classList.remove(r),document.removeEventListener("keydown",this.onKeydown,!0)),this.updateMetrics(),this.emit(i?"enterFS":"exitFS")}getMatrix(e=this.current){const{a:n,b:r,c:i,d:s,e:a,f:o}=e;return new DOMMatrix([n,r,i,s,a,o])}reset(e){if(this.state!==Hn.Init&&this.state!==Hn.Destroy){this.stop("current");for(const n of ta)this.target[n]=ym[n];this.target.a=this.minScale,this.target.d=this.minScale,this.clampTargetBounds(),this.isResting||(this.friction=e===void 0?this.option("friction"):e,this.state=Hn.Panning,this.requestTick())}}destroy(){this.stop(),this.state=Hn.Destroy,this.detachEvents(),this.detachObserver();const{container:e,content:n}=this,r=this.option("classes")||{};for(const i of Object.values(r))e.classList.remove(i+"");n&&(n.removeEventListener("load",this.onLoad),n.removeEventListener("error",this.onError)),this.detachPlugins()}};Object.defineProperty(wd,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:e3}),Object.defineProperty(wd,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const $E=function(t,e){let n=!0;return(...r)=>{n&&(n=!1,t(...r),setTimeout(()=>{n=!0},e))}},jE=(t,e)=>{let n=[];return t.childNodes.forEach(r=>{r.nodeType!==Node.ELEMENT_NODE||e&&!r.matches(e)||n.push(r)}),n},n3={viewport:null,track:null,enabled:!0,slides:[],axis:"x",transition:"fade",preload:1,slidesPerPage:"auto",initialPage:0,friction:.12,Panzoom:{decelFriction:.12},center:!0,infinite:!0,fill:!0,dragFree:!1,adaptiveHeight:!1,direction:"ltr",classes:{container:"f-carousel",viewport:"f-carousel__viewport",track:"f-carousel__track",slide:"f-carousel__slide",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",inTransition:"in-transition",isSelected:"is-selected"},l10n:{NEXT:"Next slide",PREV:"Previous slide",GOTO:"Go to slide #%d"}};var Ar;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"})(Ar||(Ar={}));const Sb=t=>{if(typeof t=="string"||t instanceof HTMLElement)t={html:t};else{const e=t.thumb;e!==void 0&&(typeof e=="string"&&(t.thumbSrc=e),e instanceof HTMLImageElement&&(t.thumbEl=e,t.thumbElSrc=e.src,t.thumbSrc=e.src),delete t.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",customClass:"",index:-1,dim:0,gap:0,pos:0,transition:!1},t)},r3=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);let oo=class extends gm{constructor(e,n){super(n),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}};const i3={classes:{list:"f-carousel__dots",isDynamic:"is-dynamic",hasDots:"has-dots",dot:"f-carousel__dot",isBeforePrev:"is-before-prev",isPrev:"is-prev",isCurrent:"is-current",isNext:"is-next",isAfterNext:"is-after-next"},dotTpl:'<button type="button" data-carousel-page="%i" aria-label="{{GOTO}}"><span class="f-carousel__dot" aria-hidden="true"></span></button>',dynamicFrom:11,maxCount:1/0,minCount:2};let HE=class extends oo{constructor(){super(...arguments),Object.defineProperty(this,"isDynamic",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:null})}onRefresh(){this.refresh()}build(){let e=this.list;if(!e){e=document.createElement("ul"),Ot(e,this.cn("list")),e.setAttribute("role","tablist");const n=this.instance.container;n.appendChild(e),Ot(n,this.cn("hasDots")),this.list=e}return e}refresh(){var e;const n=this.instance.pages.length,r=Math.min(2,this.option("minCount")),i=Math.max(2e3,this.option("maxCount")),s=this.option("dynamicFrom");if(n<r||n>i)return void this.cleanup();const a=typeof s=="number"&&n>5&&n>=s,o=!this.list||this.isDynamic!==a||this.list.children.length!==n;o&&this.cleanup();const p=this.build();if(ko(p,this.cn("isDynamic"),!!a),o)for(let v=0;v<n;v++)p.append(this.createItem(v));let g,y=0;for(const v of[...p.children]){const k=y===this.instance.page;k&&(g=v),ko(v,this.cn("isCurrent"),k),(e=v.children[0])===null||e===void 0||e.setAttribute("aria-selected",k?"true":"false");for(const T of["isBeforePrev","isPrev","isNext","isAfterNext"])Ln(v,this.cn(T));y++}if(g=g||p.firstChild,a&&g){const v=g.previousElementSibling,k=v&&v.previousElementSibling;Ot(v,this.cn("isPrev")),Ot(k,this.cn("isBeforePrev"));const T=g.nextElementSibling,D=T&&T.nextElementSibling;Ot(T,this.cn("isNext")),Ot(D,this.cn("isAfterNext"))}this.isDynamic=a}createItem(e=0){var n;const r=document.createElement("li");r.setAttribute("role","presentation");const i=wo(this.instance.localize(this.option("dotTpl"),[["%d",e+1]]).replace(/\%i/g,e+""));return r.appendChild(i),(n=r.children[0])===null||n===void 0||n.setAttribute("role","tab"),r}cleanup(){this.list&&(this.list.remove(),this.list=null),this.isDynamic=!1,Ln(this.instance.container,this.cn("hasDots"))}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}};Object.defineProperty(HE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:i3});const _m="disabled",xm="next",UE="prev";let WE=class extends oo{constructor(){super(...arguments),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"prev",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"next",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isDom",{enumerable:!0,configurable:!0,writable:!0,value:!1})}onRefresh(){const e=this.instance,n=e.pages.length,r=e.page;if(n<2)return void this.cleanup();this.build();let i=this.prev,s=this.next;i&&s&&(i.removeAttribute(_m),s.removeAttribute(_m),e.isInfinite||(r<=0&&i.setAttribute(_m,""),r>=n-1&&s.setAttribute(_m,"")))}addBtn(e){var n;const r=this.instance,i=document.createElement("button");i.setAttribute("tabindex","0"),i.setAttribute("title",r.localize(`{{${e.toUpperCase()}}}`)),Ot(i,this.cn("button")+" "+this.cn(e===xm?"isNext":"isPrev"));const s=r.isRTL?e===xm?UE:xm:e;var a;return i.innerHTML=r.localize(this.option(`${s}Tpl`)),i.dataset[`carousel${a=e,a?a.match("^[a-z]")?a.charAt(0).toUpperCase()+a.substring(1):a:""}`]="true",(n=this.container)===null||n===void 0||n.appendChild(i),i}build(){const e=this.instance.container,n=this.cn("container");let{container:r,prev:i,next:s}=this;r||(r=e.querySelector("."+n),this.isDom=!!r),r||(r=document.createElement("div"),Ot(r,n),e.appendChild(r)),this.container=r,s||(s=r.querySelector("[data-carousel-next]")),s||(s=this.addBtn(xm)),this.next=s,i||(i=r.querySelector("[data-carousel-prev]")),i||(i=this.addBtn(UE)),this.prev=i}cleanup(){this.isDom||(this.prev&&this.prev.remove(),this.next&&this.next.remove(),this.container&&this.container.remove()),this.prev=null,this.next=null,this.container=null,this.isDom=!1}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}};Object.defineProperty(WE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{classes:{container:"f-carousel__nav",button:"f-button",isNext:"is-next",isPrev:"is-prev"},nextTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>',prevTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>'}});let qE=class extends oo{constructor(){super(...arguments),Object.defineProperty(this,"selectedIndex",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nav",{enumerable:!0,configurable:!0,writable:!0,value:null})}addAsTargetFor(e){this.target=this.instance,this.nav=e,this.attachEvents()}addAsNavFor(e){this.nav=this.instance,this.target=e,this.attachEvents()}attachEvents(){const{nav:e,target:n}=this;e&&n&&(e.options.initialSlide=n.options.initialPage,e.state===Ar.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),n.state===Ar.Ready?this.onTargetReady(n):n.on("ready",this.onTargetReady))}onNavReady(e){e.on("createSlide",this.onNavCreateSlide),e.on("Panzoom.click",this.onNavClick),e.on("Panzoom.touchEnd",this.onNavTouch),this.onTargetChange()}onTargetReady(e){e.on("change",this.onTargetChange),e.on("Panzoom.refresh",this.onTargetChange),this.onTargetChange()}onNavClick(e,n,r){this.onNavTouch(e,e.panzoom,r)}onNavTouch(e,n,r){var i,s;if(Math.abs(n.dragOffset.x)>3||Math.abs(n.dragOffset.y)>3)return;const a=r.target,{nav:o,target:p}=this;if(!o||!p||!a)return;const g=a.closest("[data-index]");if(r.stopPropagation(),r.preventDefault(),!g)return;const y=parseInt(g.dataset.index||"",10)||0,v=p.getPageForSlide(y),k=o.getPageForSlide(y);o.slideTo(k),p.slideTo(v,{friction:((s=(i=this.nav)===null||i===void 0?void 0:i.plugins)===null||s===void 0?void 0:s.Sync.option("friction"))||0}),this.markSelectedSlide(y)}onNavCreateSlide(e,n){n.index===this.selectedIndex&&this.markSelectedSlide(n.index)}onTargetChange(){var e,n;const{target:r,nav:i}=this;if(!r||!i||i.state!==Ar.Ready||r.state!==Ar.Ready)return;const s=(n=(e=r.pages[r.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index,a=i.getPageForSlide(s);this.markSelectedSlide(s),i.slideTo(a,i.prevPage===null&&r.prevPage===null?{friction:0}:void 0)}markSelectedSlide(e){const n=this.nav;n&&n.state===Ar.Ready&&(this.selectedIndex=e,[...n.slides].map(r=>{r.el&&r.el.classList[r.index===e?"add":"remove"]("is-nav-selected")}))}attach(){const e=this;let n=e.options.target,r=e.options.nav;n?e.addAsNavFor(n):r&&e.addAsTargetFor(r)}detach(){const e=this,n=e.nav,r=e.target;n&&(n.off("ready",e.onNavReady),n.off("createSlide",e.onNavCreateSlide),n.off("Panzoom.click",e.onNavClick),n.off("Panzoom.touchEnd",e.onNavTouch)),e.nav=null,r&&(r.off("ready",e.onTargetReady),r.off("refresh",e.onTargetChange),r.off("change",e.onTargetChange)),e.target=null}};Object.defineProperty(qE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const s3={Navigation:WE,Dots:HE,Sync:qE},vm="animationend",GE="isSelected",wm="slide";let kh=class Q1 extends vb{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===Ar.Ready}get isInfinite(){let e=!1;const{contentDim:n,viewportDim:r,pages:i,slides:s}=this,a=s[0];return i.length>=2&&a&&n+a.dim>=r&&(e=this.option("infinite")),e}get isRTL(){return this.option("direction")==="rtl"}get isHorizontal(){return this.option("axis")==="x"}constructor(e,n={},r={}){if(super(),Object.defineProperty(this,"bp",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"lp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userOptions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"userPlugins",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Ar.Init}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevPage",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"viewport",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"track",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"slides",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"panzoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"inTransition",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"contentDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"viewportDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),typeof e=="string"&&(e=document.querySelector(e)),!e||!Xi(e))throw new Error("No Element found");this.container=e,this.slideNext=$E(this.slideNext.bind(this),150),this.slidePrev=$E(this.slidePrev.bind(this),150),this.userOptions=n,this.userPlugins=r,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,n;const r=Zi({},Q1.defaults,this.userOptions);let i="";const s=r.breakpoints;if(s&&_b(s))for(const[a,o]of Object.entries(s))window.matchMedia(a).matches&&_b(o)&&(i+=a,Zi(r,o));i===this.bp&&this.state!==Ar.Init||(this.bp=i,this.state===Ar.Ready&&(r.initialSlide=((n=(e=this.pages[this.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index)||0),this.state!==Ar.Init&&this.destroy(),super.setOptions(r),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=Ar.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},Q1.Plugins),this.userPlugins)),this.emit("attachPlugins"),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=Ar.Ready,this.emit("ready")}initLayout(){const{container:e}=this,n=this.option("classes");Ot(e,this.cn("container")),ko(e,n.isLTR,!this.isRTL),ko(e,n.isRTL,this.isRTL),ko(e,n.isVertical,!this.isHorizontal),ko(e,n.isHorizontal,this.isHorizontal);let r=this.option("viewport")||e.querySelector(`.${n.viewport}`);r||(r=document.createElement("div"),Ot(r,n.viewport),r.append(...jE(e,`.${n.slide}`)),e.prepend(r)),r.addEventListener("scroll",this.onScroll);let i=this.option("track")||e.querySelector(`.${n.track}`);i||(i=document.createElement("div"),Ot(i,n.track),i.append(...Array.from(r.childNodes))),i.setAttribute("aria-live","polite"),r.contains(i)||r.prepend(i),this.viewport=r,this.track=i,this.emit("initLayout")}initSlides(){const{track:e}=this;if(!e)return;const n=[...this.slides],r=[];[...jE(e,`.${this.cn(wm)}`)].forEach(i=>{if(Xi(i)){const s=Sb({el:i,isDom:!0,index:this.slides.length});r.push(s)}});for(let i of[...this.option("slides",[])||[],...n])r.push(Sb(i));this.slides=r;for(let i=0;i<this.slides.length;i++)this.slides[i].index=i;for(const i of r)this.emit("beforeInitSlide",i,i.index),this.emit("initSlide",i,i.index);this.emit("initSlides")}setInitialPage(){const e=this.option("initialSlide");this.page=typeof e=="number"?this.getPageForSlide(e):parseInt(this.option("initialPage",0)+"",10)||0}setInitialPosition(){const{track:e,pages:n,isHorizontal:r}=this;if(!e||!n.length)return;let i=this.page;n[i]||(this.page=i=0);const s=(n[i].pos||0)*(this.isRTL&&r?1:-1),a=r?`${s}px`:"0",o=r?"0":`${s}px`;e.style.transform=`translate3d(${a}, ${o}, 0) scale(1)`,this.option("adaptiveHeight")&&this.setViewportHeight()}initPanzoom(){this.panzoom&&(this.panzoom.destroy(),this.panzoom=null);const e=this.option("Panzoom")||{};this.panzoom=new wd(this.viewport,Zi({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,click:!1,dblClick:!1,touch:n=>!(this.pages.length<2&&!n.options.infinite),bounds:()=>this.getBounds(),maxVelocity:n=>Math.abs(n.target[this.axis]-n.current[this.axis])<2*this.viewportDim?100:0},e)),this.panzoom.on("*",(n,r,...i)=>{this.emit(`Panzoom.${r}`,n,...i)}),this.panzoom.on("decel",this.onDecel),this.panzoom.on("refresh",this.onRefresh),this.panzoom.on("beforeTransform",this.onBeforeTransform),this.panzoom.on("endAnimation",this.onEndAnimation)}attachEvents(){const e=this.container;e&&(e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("slideTo",this.onSlideTo)),window.addEventListener("resize",this.onResize)}createPages(){let e=[];const{contentDim:n,viewportDim:r}=this;let i=this.option("slidesPerPage");i=(i==="auto"||n<=r)&&this.option("fill")!==!1?1/0:parseFloat(i+"");let s=0,a=0,o=0;for(const p of this.slides)(!e.length||a+p.dim-r>.05||o>=i)&&(e.push(r3()),s=e.length-1,a=0,o=0),e[s].slides.push(p),a+=p.dim+p.gap,o++;return e}processPages(){const e=this.pages,{contentDim:n,viewportDim:r,isInfinite:i}=this,s=this.option("center"),a=this.option("fill"),o=a&&s&&n>r&&!i;if(e.forEach((y,v)=>{var k;y.index=v,y.pos=((k=y.slides[0])===null||k===void 0?void 0:k.pos)||0,y.dim=0;for(const[T,D]of y.slides.entries())y.dim+=D.dim,T<y.slides.length-1&&(y.dim+=D.gap);o&&y.pos+.5*y.dim<.5*r?y.pos=0:o&&y.pos+.5*y.dim>=n-.5*r?y.pos=n-r:s&&(y.pos+=-.5*(r-y.dim))}),e.forEach(y=>{a&&!i&&n>r&&(y.pos=Math.max(y.pos,0),y.pos=Math.min(y.pos,n-r)),y.pos=mt(y.pos,1e3),y.dim=mt(y.dim,1e3),Math.abs(y.pos)<=.1&&(y.pos=0)}),i)return e;const p=[];let g;return e.forEach(y=>{const v=Object.assign({},y);g&&v.pos===g.pos?(g.dim+=v.dim,g.slides=[...g.slides,...v.slides]):(v.index=p.length,g=v,p.push(v))}),p}getPageFromIndex(e=0){const n=this.pages.length;let r;return e=parseInt((e||0).toString())||0,r=this.isInfinite?(e%n+n)%n:Math.max(Math.min(e,n-1),0),r}getSlideMetrics(e){var n,r;const i=this.isHorizontal?"width":"height";let s=0,a=0,o=e.el;const p=!(!o||o.parentNode);if(o?s=parseFloat(o.dataset[i]||"")||0:(o=document.createElement("div"),o.style.visibility="hidden",(this.track||document.body).prepend(o)),Ot(o,this.cn(wm)+" "+e.class+" "+e.customClass),s)o.style[i]=`${s}px`,o.style[i==="width"?"height":"width"]="";else{p&&(this.track||document.body).prepend(o),s=o.getBoundingClientRect()[i]*Math.max(1,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1);let y=o[this.isHorizontal?"offsetWidth":"offsetHeight"];y-1>s&&(s=y)}const g=getComputedStyle(o);return g.boxSizing==="content-box"&&(this.isHorizontal?(s+=parseFloat(g.paddingLeft)||0,s+=parseFloat(g.paddingRight)||0):(s+=parseFloat(g.paddingTop)||0,s+=parseFloat(g.paddingBottom)||0)),a=parseFloat(g[this.isHorizontal?"marginRight":"marginBottom"])||0,p?(r=o.parentElement)===null||r===void 0||r.removeChild(o):e.el||o.remove(),{dim:mt(s,1e3),gap:mt(a,1e3)}}getBounds(){const{isInfinite:e,isRTL:n,isHorizontal:r,pages:i}=this;let s={min:0,max:0};if(e)s={min:-1/0,max:1/0};else if(i.length){const a=i[0].pos,o=i[i.length-1].pos;s=n&&r?{min:a,max:o}:{min:-1*o,max:-1*a}}return{x:r?s:{min:0,max:0},y:r?{min:0,max:0}:s}}repositionSlides(){let e,{isHorizontal:n,isRTL:r,isInfinite:i,viewport:s,viewportDim:a,contentDim:o,page:p,pages:g,slides:y,panzoom:v}=this,k=0,T=0,D=0,N=0;v?N=-1*v.current[this.axis]:g[p]&&(N=g[p].pos||0),e=n?r?"right":"left":"top",r&&n&&(N*=-1);for(const Z of y){const Y=Z.el;Y?(e==="top"?(Y.style.right="",Y.style.left=""):Y.style.top="",Z.index!==k?Y.style[e]=T===0?"":`${mt(T,1e3)}px`:Y.style[e]="",D+=Z.dim+Z.gap,k++):T+=Z.dim+Z.gap}if(i&&D&&s){let Z=getComputedStyle(s),Y="padding",he=n?"Right":"Bottom",me=parseFloat(Z[Y+(n?"Left":"Top")]);N-=me,a+=me,a+=parseFloat(Z[Y+he]);for(const xe of y)xe.el&&(mt(xe.pos)<mt(a)&&mt(xe.pos+xe.dim+xe.gap)<mt(N)&&mt(N)>mt(o-a)&&(xe.el.style[e]=`${mt(T+D,1e3)}px`),mt(xe.pos+xe.gap)>=mt(o-a)&&mt(xe.pos)>mt(N+a)&&mt(N)<mt(a)&&(xe.el.style[e]=`-${mt(D,1e3)}px`))}let B,L,U=[...this.inTransition];if(U.length>1&&(B=g[U[0]],L=g[U[1]]),B&&L){let Z=0;for(const Y of y)Y.el?this.inTransition.has(Y.index)&&B.slides.indexOf(Y)<0&&(Y.el.style[e]=`${mt(Z+(B.pos-L.pos),1e3)}px`):Z+=Y.dim+Y.gap}}createSlideEl(e){const{track:n,slides:r}=this;if(!n||!e||e.el&&e.el.parentNode)return;const i=e.el||document.createElement("div");Ot(i,this.cn(wm)),Ot(i,e.class),Ot(i,e.customClass);const s=e.html;s&&(s instanceof HTMLElement?i.appendChild(s):i.innerHTML=e.html+"");const a=[];r.forEach((y,v)=>{y.el&&a.push(v)});const o=e.index;let p=null;a.length&&(p=r[a.reduce((y,v)=>Math.abs(v-o)<Math.abs(y-o)?v:y)]);const g=p&&p.el&&p.el.parentNode?p.index<e.index?p.el.nextSibling:p.el:null;n.insertBefore(i,n.contains(g)?g:null),e.el=i,this.emit("createSlide",e)}removeSlideEl(e,n=!1){const r=e==null?void 0:e.el;if(!r||!r.parentNode)return;const i=this.cn(GE);if(r.classList.contains(i)&&(Ln(r,i),this.emit("unselectSlide",e)),e.isDom&&!n)return r.removeAttribute("aria-hidden"),r.removeAttribute("data-index"),void(r.style.left="");this.emit("removeSlide",e);const s=new CustomEvent(vm);r.dispatchEvent(s),e.el&&(e.el.remove(),e.el=null)}transitionTo(e=0,n=this.option("transition")){var r,i,s,a;if(!n)return!1;const o=this.page,{pages:p,panzoom:g}=this;e=parseInt((e||0).toString())||0;const y=this.getPageFromIndex(e);if(!g||!p[y]||p.length<2||Math.abs((((i=(r=p[o])===null||r===void 0?void 0:r.slides[0])===null||i===void 0?void 0:i.dim)||0)-this.viewportDim)>1)return!1;let v=e>o?1:-1;this.isInfinite&&(o===0&&e===p.length-1&&(v=-1),o===p.length-1&&e===0&&(v=1));const k=p[y].pos*(this.isRTL?1:-1);if(o===y&&Math.abs(k-g.target[this.axis])<1)return!1;this.clearTransitions();const T=g.isResting;Ot(this.container,this.cn("inTransition"));const D=((s=p[o])===null||s===void 0?void 0:s.slides[0])||null,N=((a=p[y])===null||a===void 0?void 0:a.slides[0])||null;this.inTransition.add(N.index),this.createSlideEl(N);let B=D.el,L=N.el;T||n===wm||(n="fadeFast",B=null);const U=this.isRTL?"next":"prev",Z=this.isRTL?"prev":"next";return B&&(this.inTransition.add(D.index),D.transition=n,B.addEventListener(vm,this.onAnimationEnd),B.classList.add(`f-${n}Out`,`to-${v>0?Z:U}`)),L&&(N.transition=n,L.addEventListener(vm,this.onAnimationEnd),L.classList.add(`f-${n}In`,`from-${v>0?U:Z}`)),g.current[this.axis]=k,g.target[this.axis]=k,g.requestTick(),this.onChange(y),!0}manageSlideVisiblity(){const e=new Set,n=new Set,r=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const i of this.slides)r.has(i)?e.add(i):n.add(i);for(const i of this.inTransition)e.add(this.slides[i]);for(const i of e)this.createSlideEl(i),this.lazyLoadSlide(i);for(const i of n)e.has(i)||this.removeSlideEl(i);this.markSelectedSlides(),this.repositionSlides()}markSelectedSlides(){if(!this.pages[this.page]||!this.pages[this.page].slides)return;const e="aria-hidden";let n=this.cn(GE);if(n)for(const r of this.slides){const i=r.el;i&&(i.dataset.index=`${r.index}`,i.classList.contains("f-thumbs__slide")?this.getVisibleSlides(0).has(r)?i.removeAttribute(e):i.setAttribute(e,"true"):this.pages[this.page].slides.includes(r)?(i.classList.contains(n)||(Ot(i,n),this.emit("selectSlide",r)),i.removeAttribute(e)):(i.classList.contains(n)&&(Ln(i,n),this.emit("unselectSlide",r)),i.setAttribute(e,"true")))}}flipInfiniteTrack(){const{axis:e,isHorizontal:n,isInfinite:r,isRTL:i,viewportDim:s,contentDim:a}=this,o=this.panzoom;if(!o||!r)return;let p=o.current[e],g=o.target[e]-p,y=0,v=.5*s;i&&n?(p<-v&&(y=-1,p+=a),p>a-v&&(y=1,p-=a)):(p>v&&(y=1,p-=a),p<-a+v&&(y=-1,p+=a)),y&&(o.current[e]=p,o.target[e]=p+g)}lazyLoadImg(e,n){const r=this,i="f-fadeIn",s="is-preloading";let a=!1,o=null;const p=()=>{a||(a=!0,o&&(o.remove(),o=null),Ln(n,s),n.complete&&(Ot(n,i),setTimeout(()=>{Ln(n,i)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(r.updateMetrics(),r.setViewportHeight()),this.emit("load",e))};Ot(n,s),n.src=n.dataset.lazySrcset||n.dataset.lazySrc||"",delete n.dataset.lazySrc,delete n.dataset.lazySrcset,n.addEventListener("error",()=>{p()}),n.addEventListener("load",()=>{p()}),setTimeout(()=>{const g=n.parentNode;g&&e.el&&(n.complete?p():a||(o=wo(wb),g.insertBefore(o,n)))},300)}lazyLoadSlide(e){const n=e&&e.el;if(!n)return;const r=new Set;let i=Array.from(n.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));n.dataset.lazySrc&&i.push(n),i.map(s=>{s instanceof HTMLImageElement?r.add(s):s instanceof HTMLElement&&s.dataset.lazySrc&&(s.style.backgroundImage=`url('${s.dataset.lazySrc}')`,delete s.dataset.lazySrc)});for(const s of r)this.lazyLoadImg(e,s)}onAnimationEnd(e){var n;const r=e.target,i=r?parseInt(r.dataset.index||"",10)||0:-1,s=this.slides[i],a=e.animationName;if(!r||!s||!a)return;const o=!!this.inTransition.has(i)&&s.transition;o&&a.substring(0,o.length+2)===`f-${o}`&&this.inTransition.delete(i),this.inTransition.size||this.clearTransitions(),i===this.page&&(!((n=this.panzoom)===null||n===void 0)&&n.isResting)&&this.emit("settle")}onDecel(e,n=0,r=0,i=0,s=0){if(this.option("dragFree"))return void this.setPageFromPosition();const{isRTL:a,isHorizontal:o,axis:p,pages:g}=this,y=g.length,v=Math.abs(Math.atan2(r,n)/(Math.PI/180));let k=0;if(k=v>45&&v<135?o?0:r:o?n:0,!y)return;let T=this.page,D=a&&o?1:-1;const N=e.current[p]*D;let{pageIndex:B}=this.getPageFromPosition(N);Math.abs(k)>5?(g[T].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(T=B),T=a&&o?k<0?T-1:T+1:k<0?T+1:T-1):T=i===0&&s===0?T:B,this.slideTo(T,{transition:!1,friction:e.option("decelFriction")})}onClick(e){const n=e.target,r=n&&Xi(n)?n.dataset:null;let i,s;r&&(r.carouselPage!==void 0?(s="slideTo",i=r.carouselPage):r.carouselNext!==void 0?s="slideNext":r.carouselPrev!==void 0&&(s="slidePrev")),s?(e.preventDefault(),e.stopPropagation(),n&&!n.hasAttribute("disabled")&&this[s](i)):this.emit("click",e)}onSlideTo(e){const n=e.detail||0;this.slideTo(this.getPageForSlide(n),{friction:0})}onChange(e,n=0){const r=this.page;this.prevPage=r,this.page=e,this.option("adaptiveHeight")&&this.setViewportHeight(),e!==r&&(this.markSelectedSlides(),this.emit("change",e,r,n))}onRefresh(){let e=this.contentDim,n=this.viewportDim;this.updateMetrics(),this.contentDim===e&&this.viewportDim===n||this.slideTo(this.page,{friction:0,transition:!1})}onScroll(){var e;(e=this.viewport)===null||e===void 0||e.scroll(0,0)}onResize(){this.option("breakpoints")&&this.processOptions()}onBeforeTransform(e){this.lp!==e.current[this.axis]&&(this.flipInfiniteTrack(),this.manageSlideVisiblity()),this.lp=e.current.e}onEndAnimation(){this.inTransition.size||this.emit("settle")}reInit(e=null,n=null){this.destroy(),this.state=Ar.Init,this.prevPage=null,this.userOptions=e||this.userOptions,this.userPlugins=n||this.userPlugins,this.processOptions()}slideTo(e=0,{friction:n=this.option("friction"),transition:r=this.option("transition")}={}){if(this.state===Ar.Destroy)return;e=parseInt((e||0).toString())||0;const i=this.getPageFromIndex(e),{axis:s,isHorizontal:a,isRTL:o,pages:p,panzoom:g}=this,y=p.length,v=o&&a?1:-1;if(!g||!y)return;if(this.page!==i){const T=new Event("beforeChange",{bubbles:!0,cancelable:!0});if(this.emit("beforeChange",T,e),T.defaultPrevented)return}if(this.transitionTo(e,r))return;let k=p[i].pos;if(this.isInfinite){const T=this.contentDim,D=g.target[s]*v;y===2?k+=T*Math.floor(parseFloat(e+"")/2):k=[k,k-T,k+T].reduce(function(N,B){return Math.abs(B-D)<Math.abs(N-D)?B:N})}k*=v,Math.abs(g.target[s]-k)<1||(g.panTo({x:a?k:0,y:a?0:k,friction:n}),this.onChange(i))}slideToClosest(e){if(this.panzoom){const{pageIndex:n}=this.getPageFromPosition();this.slideTo(n,e)}}slideNext(){this.slideTo(this.page+1)}slidePrev(){this.slideTo(this.page-1)}clearTransitions(){this.inTransition.clear(),Ln(this.container,this.cn("inTransition"));const e=["to-prev","to-next","from-prev","from-next"];for(const n of this.slides){const r=n.el;if(r){r.removeEventListener(vm,this.onAnimationEnd),r.classList.remove(...e);const i=n.transition;i&&r.classList.remove(`f-${i}Out`,`f-${i}In`)}}this.manageSlideVisiblity()}addSlide(e,n){var r,i,s,a;const o=this.panzoom,p=((r=this.pages[this.page])===null||r===void 0?void 0:r.pos)||0,g=((i=this.pages[this.page])===null||i===void 0?void 0:i.dim)||0,y=this.contentDim<this.viewportDim;let v=Array.isArray(n)?n:[n];const k=[];for(const T of v)k.push(Sb(T));this.slides.splice(e,0,...k);for(let T=0;T<this.slides.length;T++)this.slides[T].index=T;for(const T of k)this.emit("beforeInitSlide",T,T.index);if(this.page>=e&&(this.page+=k.length),this.updateMetrics(),o){const T=((s=this.pages[this.page])===null||s===void 0?void 0:s.pos)||0,D=((a=this.pages[this.page])===null||a===void 0?void 0:a.dim)||0,N=this.pages.length||1,B=this.isRTL?g-D:D-g,L=this.isRTL?p-T:T-p;y&&N===1?(e<=this.page&&(o.current[this.axis]-=B,o.target[this.axis]-=B),o.panTo({[this.isHorizontal?"x":"y"]:-1*T})):L&&e<=this.page&&(o.target[this.axis]-=L,o.current[this.axis]-=L,o.requestTick())}for(const T of k)this.emit("initSlide",T,T.index)}prependSlide(e){this.addSlide(0,e)}appendSlide(e){this.addSlide(this.slides.length,e)}removeSlide(e){const n=this.slides.length;e=(e%n+n)%n;const r=this.slides[e];if(r){this.removeSlideEl(r,!0),this.slides.splice(e,1);for(let i=0;i<this.slides.length;i++)this.slides[i].index=i;this.updateMetrics(),this.slideTo(this.page,{friction:0,transition:!1}),this.emit("destroySlide",r)}}updateMetrics(){const{panzoom:e,viewport:n,track:r,slides:i,isHorizontal:s,isInfinite:a}=this;if(!r)return;const o=s?"width":"height",p=s?"offsetWidth":"offsetHeight";if(n){let v=Math.max(n[p],mt(n.getBoundingClientRect()[o],1e3)),k=getComputedStyle(n),T="padding",D=s?"Right":"Bottom";v-=parseFloat(k[T+(s?"Left":"Top")])+parseFloat(k[T+D]),this.viewportDim=v}let g,y=0;for(const[v,k]of i.entries()){let T=0,D=0;!k.el&&g?(T=g.dim,D=g.gap):({dim:T,gap:D}=this.getSlideMetrics(k),g=k),T=mt(T,1e3),D=mt(D,1e3),k.dim=T,k.gap=D,k.pos=y,y+=T,(a||v<i.length-1)&&(y+=D)}y=mt(y,1e3),this.contentDim=y,e&&(e.contentRect[o]=y,e.contentRect[s?"fullWidth":"fullHeight"]=y),this.pages=this.createPages(),this.pages=this.processPages(),this.state===Ar.Init&&this.setInitialPage(),this.page=Math.max(0,Math.min(this.page,this.pages.length-1)),this.manageSlideVisiblity(),this.emit("refresh")}getProgress(e,n=!1,r=!1){e===void 0&&(e=this.page);const i=this,s=i.panzoom,a=i.contentDim,o=i.pages[e]||0;if(!o||!s)return e>this.page?-1:1;let p=-1*s.current.e,g=mt((p-o.pos)/(1*o.dim),1e3),y=g,v=g;this.isInfinite&&r!==!0&&(y=mt((p-o.pos+a)/(1*o.dim),1e3),v=mt((p-o.pos-a)/(1*o.dim),1e3));let k=[g,y,v].reduce(function(T,D){return Math.abs(D)<Math.abs(T)?D:T});return n?k:k>1?1:k<-1?-1:k}setViewportHeight(){const{page:e,pages:n,viewport:r,isHorizontal:i}=this;if(!r||!n[e])return;let s=0;i&&this.track&&(this.track.style.height="auto",n[e].slides.forEach(a=>{a.el&&(s=Math.max(s,a.el.offsetHeight))})),r.style.height=s?`${s}px`:""}getPageForSlide(e){for(const n of this.pages)for(const r of n.slides)if(r.index===e)return n.index;return-1}getVisibleSlides(e=0){var n;const r=new Set;let{panzoom:i,contentDim:s,viewportDim:a,pages:o,page:p}=this;if(a){s=s+((n=this.slides[this.slides.length-1])===null||n===void 0?void 0:n.gap)||0;let g=0;g=i&&i.state!==Hn.Init&&i.state!==Hn.Destroy?-1*i.current[this.axis]:o[p]&&o[p].pos||0,this.isInfinite&&(g-=Math.floor(g/s)*s),this.isRTL&&this.isHorizontal&&(g*=-1);const y=g-a*e,v=g+a*(e+1),k=this.isInfinite?[-1,0,1]:[0];for(const T of this.slides)for(const D of k){const N=T.pos+D*s,B=N+T.dim+T.gap;N<v&&B>y&&r.add(T)}}return r}getPageFromPosition(e){const{viewportDim:n,contentDim:r,slides:i,pages:s,panzoom:a}=this,o=s.length,p=i.length,g=i[0],y=i[p-1],v=this.option("center");let k=0,T=0,D=0,N=e===void 0?-1*((a==null?void 0:a.target[this.axis])||0):e;v&&(N+=.5*n),this.isInfinite?(N<g.pos-.5*y.gap&&(N-=r,D=-1),N>y.pos+y.dim+.5*y.gap&&(N-=r,D=1)):N=Math.max(g.pos||0,Math.min(N,y.pos));let B=y,L=i.find(U=>{const Z=U.pos-.5*B.gap,Y=U.pos+U.dim+.5*U.gap;return B=U,N>=Z&&N<Y});return L||(L=y),T=this.getPageForSlide(L.index),k=T+D*o,{page:k,pageIndex:T}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([Ar.Destroy].includes(this.state))return;this.state=Ar.Destroy;const{container:e,viewport:n,track:r,slides:i,panzoom:s}=this,a=this.option("classes");e.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),e.removeEventListener("slideTo",this.onSlideTo),window.removeEventListener("resize",this.onResize),s&&(s.destroy(),this.panzoom=null),i&&i.forEach(p=>{this.removeSlideEl(p)}),this.detachPlugins(),n&&(n.removeEventListener("scroll",this.onScroll),n.offsetParent&&r&&r.offsetParent&&n.replaceWith(...r.childNodes));for(const[p,g]of Object.entries(a))p!=="container"&&g&&e.classList.remove(g);this.track=null,this.viewport=null,this.page=0,this.slides=[];const o=this.events.get("ready");this.events=new Map,o&&this.events.set("ready",o)}};Object.defineProperty(kh,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:wd}),Object.defineProperty(kh,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:n3}),Object.defineProperty(kh,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:s3});const YE=function(t){if(!Xi(t))return 0;const e=window.scrollY,n=window.innerHeight,r=e+n,i=t.getBoundingClientRect(),s=i.y+e,a=i.height,o=s+a;if(e>o||r<s)return 0;if(e<s&&r>o||s<e&&o>r)return 100;let p=a;s<e&&(p-=e-s),o>r&&(p-=o-r);const g=p/n*100;return Math.round(g)},Eh=!(typeof window>"u"||!window.document||!window.document.createElement);let Cb;const Tb=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)","iframe","object","embed","video","audio","[contenteditable]",'[tabindex]:not([tabindex^="-"]):not([disabled]):not([aria-hidden])'].join(","),ZE=t=>{if(t&&Eh){Cb===void 0&&document.createElement("div").focus({get preventScroll(){return Cb=!0,!1}});try{if(Cb)t.focus({preventScroll:!0});else{const e=window.scrollY||document.body.scrollTop,n=window.scrollX||document.body.scrollLeft;t.focus(),document.body.scrollTo({top:e,left:n,behavior:"auto"})}}catch{}}},XE=()=>{const t=document;let e,n="",r="",i="";return t.fullscreenEnabled?(n="requestFullscreen",r="exitFullscreen",i="fullscreenElement"):t.webkitFullscreenEnabled&&(n="webkitRequestFullscreen",r="webkitExitFullscreen",i="webkitFullscreenElement"),n&&(e={request:function(s=t.documentElement){return n==="webkitRequestFullscreen"?s[n](Element.ALLOW_KEYBOARD_INPUT):s[n]()},exit:function(){return t[i]&&t[r]()},isFullscreen:function(){return t[i]}}),e},Ab={animated:!0,autoFocus:!0,backdropClick:"close",Carousel:{classes:{container:"fancybox__carousel",viewport:"fancybox__viewport",track:"fancybox__track",slide:"fancybox__slide"}},closeButton:"auto",closeExisting:!1,commonCaption:!1,compact:()=>window.matchMedia("(max-width: 578px), (max-height: 578px)").matches,contentClick:"toggleZoom",contentDblClick:!1,defaultType:"image",defaultDisplay:"flex",dragToClose:!0,Fullscreen:{autoStart:!1},groupAll:!1,groupAttr:"data-fancybox",hideClass:"f-fadeOut",hideScrollbar:!0,idle:3500,keyboard:{Escape:"close",Delete:"close",Backspace:"close",PageUp:"next",PageDown:"prev",ArrowUp:"prev",ArrowDown:"next",ArrowRight:"next",ArrowLeft:"prev"},l10n:Object.assign(Object.assign({},VE),{CLOSE:"Close",NEXT:"Next",PREV:"Previous",MODAL:"You can close this modal content with the ESC key",ERROR:"Something Went Wrong, Please Try Again Later",IMAGE_ERROR:"Image Not Found",ELEMENT_NOT_FOUND:"HTML Element Not Found",AJAX_NOT_FOUND:"Error Loading AJAX : Not Found",AJAX_FORBIDDEN:"Error Loading AJAX : Forbidden",IFRAME_ERROR:"Error Loading Page",TOGGLE_ZOOM:"Toggle zoom level",TOGGLE_THUMBS:"Toggle thumbnails",TOGGLE_SLIDESHOW:"Toggle slideshow",TOGGLE_FULLSCREEN:"Toggle full-screen mode",DOWNLOAD:"Download"}),parentEl:null,placeFocusBack:!0,showClass:"f-zoomInUp",startIndex:0,tpl:{closeButton:'<button data-fancybox-close class="f-button is-close-btn" title="{{CLOSE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"/></svg></button>',main:`<div class="fancybox__container" role="dialog" aria-modal="true" aria-label="{{MODAL}}" tabindex="-1">
|
620
|
+
`),ie=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(ie,de),P.compileShader(ie),!P.getShaderParameter(ie,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(ie)}`);P.attachShader(this.program,ie);const _e=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(_e,pe),P.compileShader(_e),!P.getShaderParameter(_e,P.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${P.getShaderInfoLog(_e)}`);P.attachShader(this.program,_e),this.attributes={};const ve={};this.numAttributes=$.length;for(let Ce=0;Ce<this.numAttributes;Ce++)$[Ce]&&(P.bindAttribLocation(this.program,Ce,$[Ce]),this.attributes[$[Ce]]=Ce);if(P.linkProgram(this.program),!P.getProgramParameter(this.program,P.LINK_STATUS))throw new Error(`Program failed to link: ${P.getProgramInfoLog(this.program)}`);P.deleteShader(_e),P.deleteShader(ie);for(let Ce=0;Ce<se.length;Ce++){const ze=se[Ce];if(ze&&!ve[ze]){const Ze=P.getUniformLocation(this.program,ze);Ze&&(ve[ze]=Ze)}}this.fixedUniforms=_(l,ve),this.terrainUniforms=((Ce,ze)=>({u_depth:new o.aH(Ce,ze.u_depth),u_terrain:new o.aH(Ce,ze.u_terrain),u_terrain_dim:new o.aI(Ce,ze.u_terrain_dim),u_terrain_matrix:new o.aJ(Ce,ze.u_terrain_matrix),u_terrain_unpack:new o.aK(Ce,ze.u_terrain_unpack),u_terrain_exaggeration:new o.aI(Ce,ze.u_terrain_exaggeration)}))(l,ve),this.binderUniforms=b?b.getUniforms(l,ve):[]}draw(l,f,b,_,w,M,P,R,z,$,j,X,ee,te,se,le,de,pe){const ie=l.gl;if(this.failedToCreate)return;if(l.program.set(this.program),l.setDepthMode(b),l.setStencilMode(_),l.setColorMode(w),l.setCullFace(M),R){l.activeTexture.set(ie.TEXTURE2),ie.bindTexture(ie.TEXTURE_2D,R.depthTexture),l.activeTexture.set(ie.TEXTURE3),ie.bindTexture(ie.TEXTURE_2D,R.texture);for(const ve in this.terrainUniforms)this.terrainUniforms[ve].set(R[ve])}for(const ve in this.fixedUniforms)this.fixedUniforms[ve].set(P[ve]);se&&se.setUniforms(l,this.binderUniforms,ee,{zoom:te});let _e=0;switch(f){case ie.LINES:_e=2;break;case ie.TRIANGLES:_e=3;break;case ie.LINE_STRIP:_e=1}for(const ve of X.get()){const Ce=ve.vaos||(ve.vaos={});(Ce[z]||(Ce[z]=new Ef)).bind(l,this,$,se?se.getPaintVertexBuffers():[],j,ve.vertexOffset,le,de,pe),ie.drawElements(f,ve.primitiveLength*_e,ie.UNSIGNED_SHORT,ve.primitiveOffset*_e*2)}}}function du(E,l,f){const b=1/cn(f,1,l.transform.tileZoom),_=Math.pow(2,f.tileID.overscaledZ),w=f.tileSize*Math.pow(2,l.transform.tileZoom)/_,M=w*(f.tileID.canonical.x+f.tileID.wrap*_),P=w*f.tileID.canonical.y;return{u_image:0,u_texsize:f.imageAtlasTexture.size,u_scale:[b,E.fromScale,E.toScale],u_fade:E.t,u_pixel_coord_upper:[M>>16,P>>16],u_pixel_coord_lower:[65535&M,65535&P]}}const Pc=(E,l,f,b)=>{const _=l.style.light,w=_.properties.get("position"),M=[w.x,w.y,w.z],P=function(){var z=new o.A(9);return o.A!=Float32Array&&(z[1]=0,z[2]=0,z[3]=0,z[5]=0,z[6]=0,z[7]=0),z[0]=1,z[4]=1,z[8]=1,z}();_.properties.get("anchor")==="viewport"&&function(z,$){var j=Math.sin($),X=Math.cos($);z[0]=X,z[1]=j,z[2]=0,z[3]=-j,z[4]=X,z[5]=0,z[6]=0,z[7]=0,z[8]=1}(P,-l.transform.angle),function(z,$,j){var X=$[0],ee=$[1],te=$[2];z[0]=X*j[0]+ee*j[3]+te*j[6],z[1]=X*j[1]+ee*j[4]+te*j[7],z[2]=X*j[2]+ee*j[5]+te*j[8]}(M,M,P);const R=_.properties.get("color");return{u_matrix:E,u_lightpos:M,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[R.r,R.g,R.b],u_vertical_gradient:+f,u_opacity:b}},uu=(E,l,f,b,_,w,M)=>o.e(Pc(E,l,f,b),du(w,l,M),{u_height_factor:-Math.pow(2,_.overscaledZ)/M.tileSize/8}),gl=E=>({u_matrix:E}),ly=(E,l,f,b)=>o.e(gl(E),du(f,l,b)),Fv=(E,l)=>({u_matrix:E,u_world:l}),cy=(E,l,f,b,_)=>o.e(ly(E,l,f,b),{u_world:_}),$v=(E,l,f,b)=>{const _=E.transform;let w,M;if(b.paint.get("circle-pitch-alignment")==="map"){const P=cn(f,1,_.zoom);w=!0,M=[P,P]}else w=!1,M=_.pixelsToGLUnits;return{u_camera_to_center_distance:_.cameraToCenterDistance,u_scale_with_map:+(b.paint.get("circle-pitch-scale")==="map"),u_matrix:E.translatePosMatrix(l.posMatrix,f,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_pitch_with_map:+w,u_device_pixel_ratio:E.pixelRatio,u_extrude_scale:M}},xa=(E,l,f)=>({u_matrix:E,u_inv_matrix:l,u_camera_to_center_distance:f.cameraToCenterDistance,u_viewport_size:[f.width,f.height]}),Nc=(E,l,f=1)=>({u_matrix:E,u_color:l,u_overlay:0,u_overlay_scale:f}),Ei=E=>({u_matrix:E}),Si=(E,l,f,b)=>({u_matrix:E,u_extrude_scale:cn(l,1,f),u_intensity:b}),hu=(E,l,f,b)=>{const _=o.H();o.aP(_,0,E.width,E.height,0,0,1);const w=E.context.gl;return{u_matrix:_,u_world:[w.drawingBufferWidth,w.drawingBufferHeight],u_image:f,u_color_ramp:b,u_opacity:l.paint.get("heatmap-opacity")}};function fu(E,l){const f=Math.pow(2,l.canonical.z),b=l.canonical.y;return[new o.Z(0,b/f).toLngLat().lat,new o.Z(0,(b+1)/f).toLngLat().lat]}const pu=(E,l,f,b)=>{const _=E.transform;return{u_matrix:hy(E,l,f,b),u_ratio:1/cn(l,1,_.zoom),u_device_pixel_ratio:E.pixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]]}},dy=(E,l,f,b,_)=>o.e(pu(E,l,f,_),{u_image:0,u_image_height:b}),yl=(E,l,f,b,_)=>{const w=E.transform,M=uy(l,w);return{u_matrix:hy(E,l,f,_),u_texsize:l.imageAtlasTexture.size,u_ratio:1/cn(l,1,w.zoom),u_device_pixel_ratio:E.pixelRatio,u_image:0,u_scale:[M,b.fromScale,b.toScale],u_fade:b.t,u_units_to_pixels:[1/w.pixelsToGLUnits[0],1/w.pixelsToGLUnits[1]]}},jv=(E,l,f,b,_,w)=>{const M=E.lineAtlas,P=uy(l,E.transform),R=f.layout.get("line-cap")==="round",z=M.getDash(b.from,R),$=M.getDash(b.to,R),j=z.width*_.fromScale,X=$.width*_.toScale;return o.e(pu(E,l,f,w),{u_patternscale_a:[P/j,-z.height/2],u_patternscale_b:[P/X,-$.height/2],u_sdfgamma:M.width/(256*Math.min(j,X)*E.pixelRatio)/2,u_image:0,u_tex_y_a:z.y,u_tex_y_b:$.y,u_mix:_.t})};function uy(E,l){return 1/cn(E,1,l.tileZoom)}function hy(E,l,f,b){return E.translatePosMatrix(b?b.posMatrix:l.tileID.posMatrix,l,f.paint.get("line-translate"),f.paint.get("line-translate-anchor"))}const Hv=(E,l,f,b,_)=>{return{u_matrix:E,u_tl_parent:l,u_scale_parent:f,u_buffer_scale:1,u_fade_t:b.mix,u_opacity:b.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:(M=_.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(w=_.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:Uv(_.paint.get("raster-hue-rotate"))};var w,M};function Uv(E){E*=Math.PI/180;const l=Math.sin(E),f=Math.cos(E);return[(2*f+1)/3,(-Math.sqrt(3)*l-f+1)/3,(Math.sqrt(3)*l-f+1)/3]}const fy=(E,l,f,b,_,w,M,P,R,z,$,j,X,ee)=>{const te=M.transform;return{u_is_size_zoom_constant:+(E==="constant"||E==="source"),u_is_size_feature_constant:+(E==="constant"||E==="camera"),u_size_t:l?l.uSizeT:0,u_size:l?l.uSize:0,u_camera_to_center_distance:te.cameraToCenterDistance,u_pitch:te.pitch/360*2*Math.PI,u_rotate_symbol:+f,u_aspect_ratio:te.width/te.height,u_fade_change:M.options.fadeDuration?M.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:R,u_coord_matrix:z,u_is_text:+j,u_pitch_with_map:+b,u_is_along_line:_,u_is_variable_anchor:w,u_texsize:X,u_texture:0,u_translation:$,u_pitched_scale:ee}},Rc=(E,l,f,b,_,w,M,P,R,z,$,j,X,ee,te)=>{const se=M.transform;return o.e(fy(E,l,f,b,_,w,M,P,R,z,$,j,X,te),{u_gamma_scale:b?Math.cos(se._pitch)*se.cameraToCenterDistance:1,u_device_pixel_ratio:M.pixelRatio,u_is_halo:1})},Tf=(E,l,f,b,_,w,M,P,R,z,$,j,X,ee)=>o.e(Rc(E,l,f,b,_,w,M,P,R,z,$,!0,j,!0,ee),{u_texsize_icon:X,u_texture_icon:1}),mu=(E,l,f)=>({u_matrix:E,u_opacity:l,u_color:f}),Af=(E,l,f,b,_,w)=>o.e(function(M,P,R,z){const $=R.imageManager.getPattern(M.from.toString()),j=R.imageManager.getPattern(M.to.toString()),{width:X,height:ee}=R.imageManager.getPixelSize(),te=Math.pow(2,z.tileID.overscaledZ),se=z.tileSize*Math.pow(2,R.transform.tileZoom)/te,le=se*(z.tileID.canonical.x+z.tileID.wrap*te),de=se*z.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:$.tl,u_pattern_br_a:$.br,u_pattern_tl_b:j.tl,u_pattern_br_b:j.br,u_texsize:[X,ee],u_mix:P.t,u_pattern_size_a:$.displaySize,u_pattern_size_b:j.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/cn(z,1,R.transform.tileZoom),u_pixel_coord_upper:[le>>16,de>>16],u_pixel_coord_lower:[65535&le,65535&de]}}(b,w,f,_),{u_matrix:E,u_opacity:l}),Mf={fillExtrusion:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_lightpos:new o.aN(E,l.u_lightpos),u_lightintensity:new o.aI(E,l.u_lightintensity),u_lightcolor:new o.aN(E,l.u_lightcolor),u_vertical_gradient:new o.aI(E,l.u_vertical_gradient),u_opacity:new o.aI(E,l.u_opacity)}),fillExtrusionPattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_lightpos:new o.aN(E,l.u_lightpos),u_lightintensity:new o.aI(E,l.u_lightintensity),u_lightcolor:new o.aN(E,l.u_lightcolor),u_vertical_gradient:new o.aI(E,l.u_vertical_gradient),u_height_factor:new o.aI(E,l.u_height_factor),u_image:new o.aH(E,l.u_image),u_texsize:new o.aO(E,l.u_texsize),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade),u_opacity:new o.aI(E,l.u_opacity)}),fill:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix)}),fillPattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_image:new o.aH(E,l.u_image),u_texsize:new o.aO(E,l.u_texsize),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade)}),fillOutline:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_world:new o.aO(E,l.u_world)}),fillOutlinePattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_world:new o.aO(E,l.u_world),u_image:new o.aH(E,l.u_image),u_texsize:new o.aO(E,l.u_texsize),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade)}),circle:(E,l)=>({u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_scale_with_map:new o.aH(E,l.u_scale_with_map),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_extrude_scale:new o.aO(E,l.u_extrude_scale),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_matrix:new o.aJ(E,l.u_matrix)}),collisionBox:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_pixel_extrude_scale:new o.aO(E,l.u_pixel_extrude_scale)}),collisionCircle:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_inv_matrix:new o.aJ(E,l.u_inv_matrix),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_viewport_size:new o.aO(E,l.u_viewport_size)}),debug:(E,l)=>({u_color:new o.aL(E,l.u_color),u_matrix:new o.aJ(E,l.u_matrix),u_overlay:new o.aH(E,l.u_overlay),u_overlay_scale:new o.aI(E,l.u_overlay_scale)}),clippingMask:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix)}),heatmap:(E,l)=>({u_extrude_scale:new o.aI(E,l.u_extrude_scale),u_intensity:new o.aI(E,l.u_intensity),u_matrix:new o.aJ(E,l.u_matrix)}),heatmapTexture:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_world:new o.aO(E,l.u_world),u_image:new o.aH(E,l.u_image),u_color_ramp:new o.aH(E,l.u_color_ramp),u_opacity:new o.aI(E,l.u_opacity)}),hillshade:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_image:new o.aH(E,l.u_image),u_latrange:new o.aO(E,l.u_latrange),u_light:new o.aO(E,l.u_light),u_shadow:new o.aL(E,l.u_shadow),u_highlight:new o.aL(E,l.u_highlight),u_accent:new o.aL(E,l.u_accent)}),hillshadePrepare:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_image:new o.aH(E,l.u_image),u_dimension:new o.aO(E,l.u_dimension),u_zoom:new o.aI(E,l.u_zoom),u_unpack:new o.aK(E,l.u_unpack)}),line:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels)}),lineGradient:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels),u_image:new o.aH(E,l.u_image),u_image_height:new o.aI(E,l.u_image_height)}),linePattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_texsize:new o.aO(E,l.u_texsize),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_image:new o.aH(E,l.u_image),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels),u_scale:new o.aN(E,l.u_scale),u_fade:new o.aI(E,l.u_fade)}),lineSDF:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ratio:new o.aI(E,l.u_ratio),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(E,l.u_units_to_pixels),u_patternscale_a:new o.aO(E,l.u_patternscale_a),u_patternscale_b:new o.aO(E,l.u_patternscale_b),u_sdfgamma:new o.aI(E,l.u_sdfgamma),u_image:new o.aH(E,l.u_image),u_tex_y_a:new o.aI(E,l.u_tex_y_a),u_tex_y_b:new o.aI(E,l.u_tex_y_b),u_mix:new o.aI(E,l.u_mix)}),raster:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_tl_parent:new o.aO(E,l.u_tl_parent),u_scale_parent:new o.aI(E,l.u_scale_parent),u_buffer_scale:new o.aI(E,l.u_buffer_scale),u_fade_t:new o.aI(E,l.u_fade_t),u_opacity:new o.aI(E,l.u_opacity),u_image0:new o.aH(E,l.u_image0),u_image1:new o.aH(E,l.u_image1),u_brightness_low:new o.aI(E,l.u_brightness_low),u_brightness_high:new o.aI(E,l.u_brightness_high),u_saturation_factor:new o.aI(E,l.u_saturation_factor),u_contrast_factor:new o.aI(E,l.u_contrast_factor),u_spin_weights:new o.aN(E,l.u_spin_weights)}),symbolIcon:(E,l)=>({u_is_size_zoom_constant:new o.aH(E,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(E,l.u_is_size_feature_constant),u_size_t:new o.aI(E,l.u_size_t),u_size:new o.aI(E,l.u_size),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_pitch:new o.aI(E,l.u_pitch),u_rotate_symbol:new o.aH(E,l.u_rotate_symbol),u_aspect_ratio:new o.aI(E,l.u_aspect_ratio),u_fade_change:new o.aI(E,l.u_fade_change),u_matrix:new o.aJ(E,l.u_matrix),u_label_plane_matrix:new o.aJ(E,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(E,l.u_coord_matrix),u_is_text:new o.aH(E,l.u_is_text),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_is_along_line:new o.aH(E,l.u_is_along_line),u_is_variable_anchor:new o.aH(E,l.u_is_variable_anchor),u_texsize:new o.aO(E,l.u_texsize),u_texture:new o.aH(E,l.u_texture),u_translation:new o.aO(E,l.u_translation),u_pitched_scale:new o.aI(E,l.u_pitched_scale)}),symbolSDF:(E,l)=>({u_is_size_zoom_constant:new o.aH(E,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(E,l.u_is_size_feature_constant),u_size_t:new o.aI(E,l.u_size_t),u_size:new o.aI(E,l.u_size),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_pitch:new o.aI(E,l.u_pitch),u_rotate_symbol:new o.aH(E,l.u_rotate_symbol),u_aspect_ratio:new o.aI(E,l.u_aspect_ratio),u_fade_change:new o.aI(E,l.u_fade_change),u_matrix:new o.aJ(E,l.u_matrix),u_label_plane_matrix:new o.aJ(E,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(E,l.u_coord_matrix),u_is_text:new o.aH(E,l.u_is_text),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_is_along_line:new o.aH(E,l.u_is_along_line),u_is_variable_anchor:new o.aH(E,l.u_is_variable_anchor),u_texsize:new o.aO(E,l.u_texsize),u_texture:new o.aH(E,l.u_texture),u_gamma_scale:new o.aI(E,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_is_halo:new o.aH(E,l.u_is_halo),u_translation:new o.aO(E,l.u_translation),u_pitched_scale:new o.aI(E,l.u_pitched_scale)}),symbolTextAndIcon:(E,l)=>({u_is_size_zoom_constant:new o.aH(E,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(E,l.u_is_size_feature_constant),u_size_t:new o.aI(E,l.u_size_t),u_size:new o.aI(E,l.u_size),u_camera_to_center_distance:new o.aI(E,l.u_camera_to_center_distance),u_pitch:new o.aI(E,l.u_pitch),u_rotate_symbol:new o.aH(E,l.u_rotate_symbol),u_aspect_ratio:new o.aI(E,l.u_aspect_ratio),u_fade_change:new o.aI(E,l.u_fade_change),u_matrix:new o.aJ(E,l.u_matrix),u_label_plane_matrix:new o.aJ(E,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(E,l.u_coord_matrix),u_is_text:new o.aH(E,l.u_is_text),u_pitch_with_map:new o.aH(E,l.u_pitch_with_map),u_is_along_line:new o.aH(E,l.u_is_along_line),u_is_variable_anchor:new o.aH(E,l.u_is_variable_anchor),u_texsize:new o.aO(E,l.u_texsize),u_texsize_icon:new o.aO(E,l.u_texsize_icon),u_texture:new o.aH(E,l.u_texture),u_texture_icon:new o.aH(E,l.u_texture_icon),u_gamma_scale:new o.aI(E,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(E,l.u_device_pixel_ratio),u_is_halo:new o.aH(E,l.u_is_halo),u_translation:new o.aO(E,l.u_translation),u_pitched_scale:new o.aI(E,l.u_pitched_scale)}),background:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_opacity:new o.aI(E,l.u_opacity),u_color:new o.aL(E,l.u_color)}),backgroundPattern:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_opacity:new o.aI(E,l.u_opacity),u_image:new o.aH(E,l.u_image),u_pattern_tl_a:new o.aO(E,l.u_pattern_tl_a),u_pattern_br_a:new o.aO(E,l.u_pattern_br_a),u_pattern_tl_b:new o.aO(E,l.u_pattern_tl_b),u_pattern_br_b:new o.aO(E,l.u_pattern_br_b),u_texsize:new o.aO(E,l.u_texsize),u_mix:new o.aI(E,l.u_mix),u_pattern_size_a:new o.aO(E,l.u_pattern_size_a),u_pattern_size_b:new o.aO(E,l.u_pattern_size_b),u_scale_a:new o.aI(E,l.u_scale_a),u_scale_b:new o.aI(E,l.u_scale_b),u_pixel_coord_upper:new o.aO(E,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(E,l.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aI(E,l.u_tile_units_to_pixels)}),terrain:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_texture:new o.aH(E,l.u_texture),u_ele_delta:new o.aI(E,l.u_ele_delta),u_fog_matrix:new o.aJ(E,l.u_fog_matrix),u_fog_color:new o.aL(E,l.u_fog_color),u_fog_ground_blend:new o.aI(E,l.u_fog_ground_blend),u_fog_ground_blend_opacity:new o.aI(E,l.u_fog_ground_blend_opacity),u_horizon_color:new o.aL(E,l.u_horizon_color),u_horizon_fog_blend:new o.aI(E,l.u_horizon_fog_blend)}),terrainDepth:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_ele_delta:new o.aI(E,l.u_ele_delta)}),terrainCoords:(E,l)=>({u_matrix:new o.aJ(E,l.u_matrix),u_texture:new o.aH(E,l.u_texture),u_terrain_coords_id:new o.aI(E,l.u_terrain_coords_id),u_ele_delta:new o.aI(E,l.u_ele_delta)}),sky:(E,l)=>({u_sky_color:new o.aL(E,l.u_sky_color),u_horizon_color:new o.aL(E,l.u_horizon_color),u_horizon:new o.aI(E,l.u_horizon),u_sky_horizon_blend:new o.aI(E,l.u_sky_horizon_blend)})};class Zs{constructor(l,f,b){this.context=l;const _=l.gl;this.buffer=_.createBuffer(),this.dynamicDraw=!!b,this.context.unbindVAO(),l.bindElementBuffer.set(this.buffer),_.bufferData(_.ELEMENT_ARRAY_BUFFER,f.arrayBuffer,this.dynamicDraw?_.DYNAMIC_DRAW:_.STATIC_DRAW),this.dynamicDraw||delete f.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(l){const f=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),f.bufferSubData(f.ELEMENT_ARRAY_BUFFER,0,l.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Wv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Df{constructor(l,f,b,_){this.length=f.length,this.attributes=b,this.itemSize=f.bytesPerElement,this.dynamicDraw=_,this.context=l;const w=l.gl;this.buffer=w.createBuffer(),l.bindVertexBuffer.set(this.buffer),w.bufferData(w.ARRAY_BUFFER,f.arrayBuffer,this.dynamicDraw?w.DYNAMIC_DRAW:w.STATIC_DRAW),this.dynamicDraw||delete f.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(l){if(l.length!==this.length)throw new Error(`Length of new data is ${l.length}, which doesn't match current length of ${this.length}`);const f=this.context.gl;this.bind(),f.bufferSubData(f.ARRAY_BUFFER,0,l.arrayBuffer)}enableAttributes(l,f){for(let b=0;b<this.attributes.length;b++){const _=f.attributes[this.attributes[b].name];_!==void 0&&l.enableVertexAttribArray(_)}}setVertexAttribPointers(l,f,b){for(let _=0;_<this.attributes.length;_++){const w=this.attributes[_],M=f.attributes[w.name];M!==void 0&&l.vertexAttribPointer(M,w.components,l[Wv[w.type]],!1,this.itemSize,w.offset+this.itemSize*(b||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const va=new WeakMap;function Vo(E){var l;if(va.has(E))return va.get(E);{const f=(l=E.getParameter(E.VERSION))===null||l===void 0?void 0:l.startsWith("WebGL 2.0");return va.set(E,f),f}}class Pn{constructor(l){this.gl=l.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(l){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class gu extends Pn{getDefault(){return o.aM.transparent}set(l){const f=this.current;(l.r!==f.r||l.g!==f.g||l.b!==f.b||l.a!==f.a||this.dirty)&&(this.gl.clearColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class qv extends Pn{getDefault(){return 1}set(l){(l!==this.current||this.dirty)&&(this.gl.clearDepth(l),this.current=l,this.dirty=!1)}}class bl extends Pn{getDefault(){return 0}set(l){(l!==this.current||this.dirty)&&(this.gl.clearStencil(l),this.current=l,this.dirty=!1)}}class Gv extends Pn{getDefault(){return[!0,!0,!0,!0]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||l[2]!==f[2]||l[3]!==f[3]||this.dirty)&&(this.gl.colorMask(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class py extends Pn{getDefault(){return!0}set(l){(l!==this.current||this.dirty)&&(this.gl.depthMask(l),this.current=l,this.dirty=!1)}}class Yv extends Pn{getDefault(){return 255}set(l){(l!==this.current||this.dirty)&&(this.gl.stencilMask(l),this.current=l,this.dirty=!1)}}class my extends Pn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(l){const f=this.current;(l.func!==f.func||l.ref!==f.ref||l.mask!==f.mask||this.dirty)&&(this.gl.stencilFunc(l.func,l.ref,l.mask),this.current=l,this.dirty=!1)}}class If extends Pn{getDefault(){const l=this.gl;return[l.KEEP,l.KEEP,l.KEEP]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||l[2]!==f[2]||this.dirty)&&(this.gl.stencilOp(l[0],l[1],l[2]),this.current=l,this.dirty=!1)}}class gy extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.STENCIL_TEST):f.disable(f.STENCIL_TEST),this.current=l,this.dirty=!1}}class yy extends Pn{getDefault(){return[0,1]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||this.dirty)&&(this.gl.depthRange(l[0],l[1]),this.current=l,this.dirty=!1)}}class by extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),this.current=l,this.dirty=!1}}class _y extends Pn{getDefault(){return this.gl.LESS}set(l){(l!==this.current||this.dirty)&&(this.gl.depthFunc(l),this.current=l,this.dirty=!1)}}class wa extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.BLEND):f.disable(f.BLEND),this.current=l,this.dirty=!1}}class xy extends Pn{getDefault(){const l=this.gl;return[l.ONE,l.ZERO]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||this.dirty)&&(this.gl.blendFunc(l[0],l[1]),this.current=l,this.dirty=!1)}}class Zv extends Pn{getDefault(){return o.aM.transparent}set(l){const f=this.current;(l.r!==f.r||l.g!==f.g||l.b!==f.b||l.a!==f.a||this.dirty)&&(this.gl.blendColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class vy extends Pn{getDefault(){return this.gl.FUNC_ADD}set(l){(l!==this.current||this.dirty)&&(this.gl.blendEquation(l),this.current=l,this.dirty=!1)}}class Oc extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;l?f.enable(f.CULL_FACE):f.disable(f.CULL_FACE),this.current=l,this.dirty=!1}}class Xv extends Pn{getDefault(){return this.gl.BACK}set(l){(l!==this.current||this.dirty)&&(this.gl.cullFace(l),this.current=l,this.dirty=!1)}}class yu extends Pn{getDefault(){return this.gl.CCW}set(l){(l!==this.current||this.dirty)&&(this.gl.frontFace(l),this.current=l,this.dirty=!1)}}class Kv extends Pn{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}}class Jv extends Pn{getDefault(){return this.gl.TEXTURE0}set(l){(l!==this.current||this.dirty)&&(this.gl.activeTexture(l),this.current=l,this.dirty=!1)}}class wy extends Pn{getDefault(){const l=this.gl;return[0,0,l.drawingBufferWidth,l.drawingBufferHeight]}set(l){const f=this.current;(l[0]!==f[0]||l[1]!==f[1]||l[2]!==f[2]||l[3]!==f[3]||this.dirty)&&(this.gl.viewport(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class ky extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindFramebuffer(f.FRAMEBUFFER,l),this.current=l,this.dirty=!1}}class Ey extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindRenderbuffer(f.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Pf extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindTexture(f.TEXTURE_2D,l),this.current=l,this.dirty=!1}}class Sy extends Pn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.bindBuffer(f.ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class bu extends Pn{getDefault(){return null}set(l){const f=this.gl;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class ho extends Pn{getDefault(){return null}set(l){var f;if(l===this.current&&!this.dirty)return;const b=this.gl;Vo(b)?b.bindVertexArray(l):(f=b.getExtension("OES_vertex_array_object"))===null||f===void 0||f.bindVertexArrayOES(l),this.current=l,this.dirty=!1}}class Nf extends Pn{getDefault(){return 4}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.pixelStorei(f.UNPACK_ALIGNMENT,l),this.current=l,this.dirty=!1}}class Rf extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.pixelStorei(f.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),this.current=l,this.dirty=!1}}class Of extends Pn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const f=this.gl;f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,l),this.current=l,this.dirty=!1}}class _u extends Pn{constructor(l,f){super(l),this.context=l,this.parent=f}getDefault(){return null}}class Bf extends _u{setDirty(){this.dirty=!0}set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const f=this.gl;f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l,0),this.current=l,this.dirty=!1}}class ka extends _u{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const f=this.gl;f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Vf extends _u{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const f=this.gl;f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Qv{constructor(l,f,b,_,w){this.context=l,this.width=f,this.height=b;const M=l.gl,P=this.framebuffer=M.createFramebuffer();if(this.colorAttachment=new Bf(l,P),_)this.depthAttachment=w?new Vf(l,P):new ka(l,P);else if(w)throw new Error("Stencil cannot be set without depth");if(M.checkFramebufferStatus(M.FRAMEBUFFER)!==M.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const l=this.context.gl,f=this.colorAttachment.get();if(f&&l.deleteTexture(f),this.depthAttachment){const b=this.depthAttachment.get();b&&l.deleteRenderbuffer(b)}l.deleteFramebuffer(this.framebuffer)}}class pr{constructor(l,f,b){this.blendFunction=l,this.blendColor=f,this.mask=b}}pr.Replace=[1,0],pr.disabled=new pr(pr.Replace,o.aM.transparent,[!1,!1,!1,!1]),pr.unblended=new pr(pr.Replace,o.aM.transparent,[!0,!0,!0,!0]),pr.alphaBlended=new pr([1,771],o.aM.transparent,[!0,!0,!0,!0]);class e1{constructor(l){var f,b;if(this.gl=l,this.clearColor=new gu(this),this.clearDepth=new qv(this),this.clearStencil=new bl(this),this.colorMask=new Gv(this),this.depthMask=new py(this),this.stencilMask=new Yv(this),this.stencilFunc=new my(this),this.stencilOp=new If(this),this.stencilTest=new gy(this),this.depthRange=new yy(this),this.depthTest=new by(this),this.depthFunc=new _y(this),this.blend=new wa(this),this.blendFunc=new xy(this),this.blendColor=new Zv(this),this.blendEquation=new vy(this),this.cullFace=new Oc(this),this.cullFaceSide=new Xv(this),this.frontFace=new yu(this),this.program=new Kv(this),this.activeTexture=new Jv(this),this.viewport=new wy(this),this.bindFramebuffer=new ky(this),this.bindRenderbuffer=new Ey(this),this.bindTexture=new Pf(this),this.bindVertexBuffer=new Sy(this),this.bindElementBuffer=new bu(this),this.bindVertexArray=new ho(this),this.pixelStoreUnpack=new Nf(this),this.pixelStoreUnpackPremultiplyAlpha=new Rf(this),this.pixelStoreUnpackFlipY=new Of(this),this.extTextureFilterAnisotropic=l.getExtension("EXT_texture_filter_anisotropic")||l.getExtension("MOZ_EXT_texture_filter_anisotropic")||l.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=l.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=l.getParameter(l.MAX_TEXTURE_SIZE),Vo(l)){this.HALF_FLOAT=l.HALF_FLOAT;const _=l.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(f=l.RGBA16F)!==null&&f!==void 0?f:_==null?void 0:_.RGBA16F_EXT,this.RGB16F=(b=l.RGB16F)!==null&&b!==void 0?b:_==null?void 0:_.RGB16F_EXT,l.getExtension("EXT_color_buffer_float")}else{l.getExtension("EXT_color_buffer_half_float"),l.getExtension("OES_texture_half_float_linear");const _=l.getExtension("OES_texture_half_float");this.HALF_FLOAT=_==null?void 0:_.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(l,f){return new Zs(this,l,f)}createVertexBuffer(l,f,b){return new Df(this,l,f,b)}createRenderbuffer(l,f,b){const _=this.gl,w=_.createRenderbuffer();return this.bindRenderbuffer.set(w),_.renderbufferStorage(_.RENDERBUFFER,l,f,b),this.bindRenderbuffer.set(null),w}createFramebuffer(l,f,b,_){return new Qv(this,l,f,b,_)}clear({color:l,depth:f,stencil:b}){const _=this.gl;let w=0;l&&(w|=_.COLOR_BUFFER_BIT,this.clearColor.set(l),this.colorMask.set([!0,!0,!0,!0])),f!==void 0&&(w|=_.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(f),this.depthMask.set(!0)),b!==void 0&&(w|=_.STENCIL_BUFFER_BIT,this.clearStencil.set(b),this.stencilMask.set(255)),_.clear(w)}setCullFace(l){l.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(l.mode),this.frontFace.set(l.frontFace))}setDepthMode(l){l.func!==this.gl.ALWAYS||l.mask?(this.depthTest.set(!0),this.depthFunc.set(l.func),this.depthMask.set(l.mask),this.depthRange.set(l.range)):this.depthTest.set(!1)}setStencilMode(l){l.test.func!==this.gl.ALWAYS||l.mask?(this.stencilTest.set(!0),this.stencilMask.set(l.mask),this.stencilOp.set([l.fail,l.depthFail,l.pass]),this.stencilFunc.set({func:l.test.func,ref:l.ref,mask:l.test.mask})):this.stencilTest.set(!1)}setColorMode(l){o.aE(l.blendFunction,pr.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(l.blendFunction),this.blendColor.set(l.blendColor)),this.colorMask.set(l.mask)}createVertexArray(){var l;return Vo(this.gl)?this.gl.createVertexArray():(l=this.gl.getExtension("OES_vertex_array_object"))===null||l===void 0?void 0:l.createVertexArrayOES()}deleteVertexArray(l){var f;return Vo(this.gl)?this.gl.deleteVertexArray(l):(f=this.gl.getExtension("OES_vertex_array_object"))===null||f===void 0?void 0:f.deleteVertexArrayOES(l)}unbindVAO(){this.bindVertexArray.set(null)}}class rn{constructor(l,f,b){this.func=l,this.mask=f,this.range=b}}rn.ReadOnly=!1,rn.ReadWrite=!0,rn.disabled=new rn(519,rn.ReadOnly,[0,1]);const xu=7680;class qn{constructor(l,f,b,_,w,M){this.test=l,this.ref=f,this.mask=b,this.fail=_,this.depthFail=w,this.pass=M}}qn.disabled=new qn({func:519,mask:0},0,0,xu,xu,xu);class Fn{constructor(l,f,b){this.enable=l,this.mode=f,this.frontFace=b}}let Ea;function Bc(E,l,f,b,_){const w=E.context,M=w.gl,P=E.useProgram("collisionBox"),R=[];let z=0,$=0;for(let de=0;de<b.length;de++){const pe=b[de],ie=l.getTile(pe).getBucket(f);if(!ie)continue;const _e=_?ie.textCollisionBox:ie.iconCollisionBox,ve=ie.collisionCircleArray;if(ve.length>0){const Ce=o.H();o.aQ(Ce,ie.placementInvProjMatrix,E.transform.glCoordMatrix),o.aQ(Ce,Ce,ie.placementViewportMatrix),R.push({circleArray:ve,circleOffset:$,transform:pe.posMatrix,invTransform:Ce,coord:pe}),z+=ve.length/4,$=z}_e&&P.draw(w,M.LINES,rn.disabled,qn.disabled,E.colorModeForRenderPass(),Fn.disabled,{u_matrix:pe.posMatrix,u_pixel_extrude_scale:[1/(j=E.transform).width,1/j.height]},E.style.map.terrain&&E.style.map.terrain.getTerrainData(pe),f.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,null,E.transform.zoom,null,null,_e.collisionVertexBuffer)}var j;if(!_||!R.length)return;const X=E.useProgram("collisionCircle"),ee=new o.aR;ee.resize(4*z),ee._trim();let te=0;for(const de of R)for(let pe=0;pe<de.circleArray.length/4;pe++){const ie=4*pe,_e=de.circleArray[ie+0],ve=de.circleArray[ie+1],Ce=de.circleArray[ie+2],ze=de.circleArray[ie+3];ee.emplace(te++,_e,ve,Ce,ze,0),ee.emplace(te++,_e,ve,Ce,ze,1),ee.emplace(te++,_e,ve,Ce,ze,2),ee.emplace(te++,_e,ve,Ce,ze,3)}(!Ea||Ea.length<2*z)&&(Ea=function(de){const pe=2*de,ie=new o.aT;ie.resize(pe),ie._trim();for(let _e=0;_e<pe;_e++){const ve=6*_e;ie.uint16[ve+0]=4*_e+0,ie.uint16[ve+1]=4*_e+1,ie.uint16[ve+2]=4*_e+2,ie.uint16[ve+3]=4*_e+2,ie.uint16[ve+4]=4*_e+3,ie.uint16[ve+5]=4*_e+0}return ie}(z));const se=w.createIndexBuffer(Ea,!0),le=w.createVertexBuffer(ee,o.aS.members,!0);for(const de of R){const pe=xa(de.transform,de.invTransform,E.transform);X.draw(w,M.TRIANGLES,rn.disabled,qn.disabled,E.colorModeForRenderPass(),Fn.disabled,pe,E.style.map.terrain&&E.style.map.terrain.getTerrainData(de.coord),f.id,le,se,o.a0.simpleSegment(0,2*de.circleOffset,de.circleArray.length,de.circleArray.length/2),null,E.transform.zoom,null,null,null)}le.destroy(),se.destroy()}Fn.disabled=new Fn(!1,1029,2305),Fn.backCCW=new Fn(!0,1029,2305);const Vc=o.an(new Float32Array(16));function zf(E,l,f,b,_,w){const{horizontalAlign:M,verticalAlign:P}=o.au(E);return new o.P((-(M-.5)*l/_+b[0])*w,(-(P-.5)*f/_+b[1])*w)}function Sa(E,l,f,b,_,w){const M=l.tileAnchorPoint.add(new o.P(l.translation[0],l.translation[1]));if(l.pitchWithMap){let P=b.mult(w);f||(P=P.rotate(-_));const R=M.add(P);return oe(R.x,R.y,l.labelPlaneMatrix,l.getElevation).point}if(f){const P=Ne(l.tileAnchorPoint.x+1,l.tileAnchorPoint.y,l).point.sub(E),R=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return E.add(b.rotate(R))}return E.add(b)}function _l(E,l,f,b,_,w,M,P,R,z,$,j,X,ee){const te=E.text.placedSymbolArray,se=E.text.dynamicLayoutVertexArray,le=E.icon.dynamicLayoutVertexArray,de={};se.clear();for(let pe=0;pe<te.length;pe++){const ie=te.get(pe),_e=ie.hidden||!ie.crossTileID||E.allowVerticalPlacement&&!ie.placedOrientation?null:b[ie.crossTileID];if(_e){const ve=new o.P(ie.anchorX,ie.anchorY),Ce={getElevation:ee,width:_.width,height:_.height,labelPlaneMatrix:w,pitchWithMap:f,projection:$,tileAnchorPoint:ve,translation:j,unwrappedTileID:X},ze=f?oe(ve.x,ve.y,M,ee):Ne(ve.x,ve.y,Ce),Ze=q(_.cameraToCenterDistance,ze.signedDistanceFromCamera);let ot=o.ai(E.textSizeData,R,ie)*Ze/o.ap;f&&(ot*=E.tilePixelRatio/P);const{width:ut,height:rt,anchor:nt,textOffset:vt,textBoxScale:Ht}=_e,it=zf(nt,ut,rt,vt,Ht,ot),lt=$.getPitchedTextCorrection(_,ve.add(new o.P(j[0],j[1])),X),Ft=Sa(ze.point,Ce,l,it,_.angle,lt),Xn=E.allowVerticalPlacement&&ie.placedOrientation===o.ah.vertical?Math.PI/2:0;for(let Jt=0;Jt<ie.numGlyphs;Jt++)o.aj(se,Ft,Xn);z&&ie.associatedIconIndex>=0&&(de[ie.associatedIconIndex]={shiftedAnchor:Ft,angle:Xn})}else Pt(ie.numGlyphs,se)}if(z){le.clear();const pe=E.icon.placedSymbolArray;for(let ie=0;ie<pe.length;ie++){const _e=pe.get(ie);if(_e.hidden)Pt(_e.numGlyphs,le);else{const ve=de[ie];if(ve)for(let Ce=0;Ce<_e.numGlyphs;Ce++)o.aj(le,ve.shiftedAnchor,ve.angle);else Pt(_e.numGlyphs,le)}}E.icon.dynamicLayoutVertexBuffer.updateData(le)}E.text.dynamicLayoutVertexBuffer.updateData(se)}function rs(E,l,f){return f.iconsInText&&l?"symbolTextAndIcon":E?"symbolSDF":"symbolIcon"}function Lf(E,l,f,b,_,w,M,P,R,z,$,j){const X=E.context,ee=X.gl,te=E.transform,se=ba(),le=P==="map",de=R==="map",pe=P!=="viewport"&&f.layout.get("symbol-placement")!=="point",ie=le&&!de&&!pe,_e=!de&&pe,ve=!f.layout.get("symbol-sort-key").isConstant();let Ce=!1;const ze=E.depthModeForSublayer(0,rn.ReadOnly),Ze=f._unevaluatedLayout.hasValue("text-variable-anchor")||f._unevaluatedLayout.hasValue("text-variable-anchor-offset"),ot=[],ut=se.getCircleRadiusCorrection(te);for(const rt of b){const nt=l.getTile(rt),vt=nt.getBucket(f);if(!vt)continue;const Ht=_?vt.text:vt.icon;if(!Ht||!Ht.segments.get().length||!Ht.hasVisibleVertices)continue;const it=Ht.programConfigurations.get(f.id),lt=_||vt.sdfIcons,Ft=_?vt.textSizeData:vt.iconSizeData,Xn=de||te.pitch!==0,Jt=E.useProgram(rs(lt,_,vt),it),dn=o.ag(Ft,te.zoom),Kn=E.style.map.terrain&&E.style.map.terrain.getTerrainData(rt);let Kr,Ts,Jn,Ci,hi=[0,0],Jr=null;if(_)Ts=nt.glyphAtlasTexture,Jn=ee.LINEAR,Kr=nt.glyphAtlasTexture.size,vt.iconsInText&&(hi=nt.imageAtlasTexture.size,Jr=nt.imageAtlasTexture,Ci=Xn||E.options.rotating||E.options.zooming||Ft.kind==="composite"||Ft.kind==="camera"?ee.LINEAR:ee.NEAREST);else{const fn=f.layout.get("icon-size").constantOr(0)!==1||vt.iconsNeedLinear;Ts=nt.imageAtlasTexture,Jn=lt||E.options.rotating||E.options.zooming||fn||Xn?ee.LINEAR:ee.NEAREST,Kr=nt.imageAtlasTexture.size}const fi=cn(nt,1,E.transform.zoom),Js=_e?rt.posMatrix:Vc,Rl=di(Js,de,le,E.transform,fi),Lu=zi(Js,de,le,E.transform,fi),Ol=zi(rt.posMatrix,de,le,E.transform,fi),as=se.translatePosition(E.transform,nt,w,M),Fu=Ze&&vt.hasTextData(),dp=f.layout.get("icon-text-fit")!=="none"&&Fu&&vt.hasIconData();if(pe){const fn=E.style.map.terrain?(Bl,Vl)=>E.style.map.terrain.getElevation(rt,Bl,Vl):null,Da=f.layout.get("text-rotation-alignment")==="map";J(vt,rt.posMatrix,E,_,Rl,Ol,de,z,Da,se,rt.toUnwrapped(),te.width,te.height,as,fn)}const ls=rt.posMatrix,cs=_&&Ze||dp,zo=pe||cs?Vc:Rl,As=Lu,Lr=lt&&f.paint.get(_?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Qr;Qr=lt?vt.iconsInText?Tf(Ft.kind,dn,ie,de,pe,cs,E,ls,zo,As,as,Kr,hi,ut):Rc(Ft.kind,dn,ie,de,pe,cs,E,ls,zo,As,as,_,Kr,!0,ut):fy(Ft.kind,dn,ie,de,pe,cs,E,ls,zo,As,as,_,Kr,ut);const Ui={program:Jt,buffers:Ht,uniformValues:Qr,atlasTexture:Ts,atlasTextureIcon:Jr,atlasInterpolation:Jn,atlasInterpolationIcon:Ci,isSDF:lt,hasHalo:Lr};if(ve&&vt.canOverlap){Ce=!0;const fn=Ht.segments.get();for(const Da of fn)ot.push({segments:new o.a0([Da]),sortKey:Da.sortKey,state:Ui,terrainData:Kn})}else ot.push({segments:Ht.segments,sortKey:0,state:Ui,terrainData:Kn})}Ce&&ot.sort((rt,nt)=>rt.sortKey-nt.sortKey);for(const rt of ot){const nt=rt.state;if(X.activeTexture.set(ee.TEXTURE0),nt.atlasTexture.bind(nt.atlasInterpolation,ee.CLAMP_TO_EDGE),nt.atlasTextureIcon&&(X.activeTexture.set(ee.TEXTURE1),nt.atlasTextureIcon&&nt.atlasTextureIcon.bind(nt.atlasInterpolationIcon,ee.CLAMP_TO_EDGE)),nt.isSDF){const vt=nt.uniformValues;nt.hasHalo&&(vt.u_is_halo=1,Ff(nt.buffers,rt.segments,f,E,nt.program,ze,$,j,vt,rt.terrainData)),vt.u_is_halo=0}Ff(nt.buffers,rt.segments,f,E,nt.program,ze,$,j,nt.uniformValues,rt.terrainData)}}function Ff(E,l,f,b,_,w,M,P,R,z){const $=b.context;_.draw($,$.gl.TRIANGLES,w,M,P,Fn.disabled,R,z,f.id,E.layoutVertexBuffer,E.indexBuffer,l,f.paint,b.transform.zoom,E.programConfigurations.get(f.id),E.dynamicLayoutVertexBuffer,E.opacityVertexBuffer)}function $f(E,l,f,b){const _=E.context,w=_.gl,M=qn.disabled,P=new pr([w.ONE,w.ONE],o.aM.transparent,[!0,!0,!0,!0]),R=l.getBucket(f);if(!R)return;const z=b.key;let $=f.heatmapFbos.get(z);$||($=zc(_,l.tileSize,l.tileSize),f.heatmapFbos.set(z,$)),_.bindFramebuffer.set($.framebuffer),_.viewport.set([0,0,l.tileSize,l.tileSize]),_.clear({color:o.aM.transparent});const j=R.programConfigurations.get(f.id),X=E.useProgram("heatmap",j),ee=E.style.map.terrain.getTerrainData(b);X.draw(_,w.TRIANGLES,rn.disabled,M,P,Fn.disabled,Si(b.posMatrix,l,E.transform.zoom,f.paint.get("heatmap-intensity")),ee,f.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,f.paint,E.transform.zoom,j)}function Ca(E,l,f){const b=E.context,_=b.gl;b.setColorMode(E.colorModeForRenderPass());const w=Lc(b,l),M=f.key,P=l.heatmapFbos.get(M);P&&(b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,P.colorAttachment.get()),b.activeTexture.set(_.TEXTURE1),w.bind(_.LINEAR,_.CLAMP_TO_EDGE),E.useProgram("heatmapTexture").draw(b,_.TRIANGLES,rn.disabled,qn.disabled,E.colorModeForRenderPass(),Fn.disabled,hu(E,l,0,1),null,l.id,E.rasterBoundsBuffer,E.quadTriangleIndexBuffer,E.rasterBoundsSegments,l.paint,E.transform.zoom),P.destroy(),l.heatmapFbos.delete(M))}function zc(E,l,f){var b,_;const w=E.gl,M=w.createTexture();w.bindTexture(w.TEXTURE_2D,M),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_S,w.CLAMP_TO_EDGE),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_WRAP_T,w.CLAMP_TO_EDGE),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MIN_FILTER,w.LINEAR),w.texParameteri(w.TEXTURE_2D,w.TEXTURE_MAG_FILTER,w.LINEAR);const P=(b=E.HALF_FLOAT)!==null&&b!==void 0?b:w.UNSIGNED_BYTE,R=(_=E.RGBA16F)!==null&&_!==void 0?_:w.RGBA;w.texImage2D(w.TEXTURE_2D,0,R,l,f,0,w.RGBA,P,null);const z=E.createFramebuffer(l,f,!1,!1);return z.colorAttachment.set(M),z}function Lc(E,l){return l.colorRampTexture||(l.colorRampTexture=new Le(E,l.colorRamp,E.gl.RGBA)),l.colorRampTexture}function xl(E,l,f,b,_){if(!f||!b||!b.imageAtlas)return;const w=b.imageAtlas.patternPositions;let M=w[f.to.toString()],P=w[f.from.toString()];if(!M&&P&&(M=P),!P&&M&&(P=M),!M||!P){const R=_.getPaintProperty(l);M=w[R],P=w[R]}M&&P&&E.setConstantPatternPositions(M,P)}function Fc(E,l,f,b,_,w,M){const P=E.context.gl,R="fill-pattern",z=f.paint.get(R),$=z&&z.constantOr(1),j=f.getCrossfadeParameters();let X,ee,te,se,le;M?(ee=$&&!f.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",X=P.LINES):(ee=$?"fillPattern":"fill",X=P.TRIANGLES);const de=z.constantOr(null);for(const pe of b){const ie=l.getTile(pe);if($&&!ie.patternsLoaded())continue;const _e=ie.getBucket(f);if(!_e)continue;const ve=_e.programConfigurations.get(f.id),Ce=E.useProgram(ee,ve),ze=E.style.map.terrain&&E.style.map.terrain.getTerrainData(pe);$&&(E.context.activeTexture.set(P.TEXTURE0),ie.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ve.updatePaintBuffers(j)),xl(ve,R,de,ie,f);const Ze=ze?pe:null,ot=E.translatePosMatrix(Ze?Ze.posMatrix:pe.posMatrix,ie,f.paint.get("fill-translate"),f.paint.get("fill-translate-anchor"));if(M){se=_e.indexBuffer2,le=_e.segments2;const ut=[P.drawingBufferWidth,P.drawingBufferHeight];te=ee==="fillOutlinePattern"&&$?cy(ot,E,j,ie,ut):Fv(ot,ut)}else se=_e.indexBuffer,le=_e.segments,te=$?ly(ot,E,j,ie):gl(ot);Ce.draw(E.context,X,_,E.stencilModeForClipping(pe),w,Fn.disabled,te,ze,f.id,_e.layoutVertexBuffer,se,le,f.paint,E.transform.zoom,ve)}}function vu(E,l,f,b,_,w,M){const P=E.context,R=P.gl,z="fill-extrusion-pattern",$=f.paint.get(z),j=$.constantOr(1),X=f.getCrossfadeParameters(),ee=f.paint.get("fill-extrusion-opacity"),te=$.constantOr(null);for(const se of b){const le=l.getTile(se),de=le.getBucket(f);if(!de)continue;const pe=E.style.map.terrain&&E.style.map.terrain.getTerrainData(se),ie=de.programConfigurations.get(f.id),_e=E.useProgram(j?"fillExtrusionPattern":"fillExtrusion",ie);j&&(E.context.activeTexture.set(R.TEXTURE0),le.imageAtlasTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),ie.updatePaintBuffers(X)),xl(ie,z,te,le,f);const ve=E.translatePosMatrix(se.posMatrix,le,f.paint.get("fill-extrusion-translate"),f.paint.get("fill-extrusion-translate-anchor")),Ce=f.paint.get("fill-extrusion-vertical-gradient"),ze=j?uu(ve,E,Ce,ee,se,X,le):Pc(ve,E,Ce,ee);_e.draw(P,P.gl.TRIANGLES,_,w,M,Fn.backCCW,ze,pe,f.id,de.layoutVertexBuffer,de.indexBuffer,de.segments,f.paint,E.transform.zoom,ie,E.style.map.terrain&&de.centroidVertexBuffer)}}function vl(E,l,f,b,_,w,M){const P=E.context,R=P.gl,z=f.fbo;if(!z)return;const $=E.useProgram("hillshade"),j=E.style.map.terrain&&E.style.map.terrain.getTerrainData(l);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,z.colorAttachment.get()),$.draw(P,R.TRIANGLES,_,w,M,Fn.disabled,((X,ee,te,se)=>{const le=te.paint.get("hillshade-shadow-color"),de=te.paint.get("hillshade-highlight-color"),pe=te.paint.get("hillshade-accent-color");let ie=te.paint.get("hillshade-illumination-direction")*(Math.PI/180);te.paint.get("hillshade-illumination-anchor")==="viewport"&&(ie-=X.transform.angle);const _e=!X.options.moving;return{u_matrix:se?se.posMatrix:X.transform.calculatePosMatrix(ee.tileID.toUnwrapped(),_e),u_image:0,u_latrange:fu(0,ee.tileID),u_light:[te.paint.get("hillshade-exaggeration"),ie],u_shadow:le,u_highlight:de,u_accent:pe}})(E,f,b,j?l:null),j,b.id,E.rasterBoundsBuffer,E.quadTriangleIndexBuffer,E.rasterBoundsSegments)}function wl(E,l,f,b,_,w){const M=E.context,P=M.gl,R=l.dem;if(R&&R.data){const z=R.dim,$=R.stride,j=R.getPixels();if(M.activeTexture.set(P.TEXTURE1),M.pixelStoreUnpackPremultiplyAlpha.set(!1),l.demTexture=l.demTexture||E.getTileTexture($),l.demTexture){const ee=l.demTexture;ee.update(j,{premultiply:!1}),ee.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else l.demTexture=new Le(M,j,P.RGBA,{premultiply:!1}),l.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);M.activeTexture.set(P.TEXTURE0);let X=l.fbo;if(!X){const ee=new Le(M,{width:z,height:z,data:null},P.RGBA);ee.bind(P.LINEAR,P.CLAMP_TO_EDGE),X=l.fbo=M.createFramebuffer(z,z,!0,!1),X.colorAttachment.set(ee.texture)}M.bindFramebuffer.set(X.framebuffer),M.viewport.set([0,0,z,z]),E.useProgram("hillshadePrepare").draw(M,P.TRIANGLES,b,_,w,Fn.disabled,((ee,te)=>{const se=te.stride,le=o.H();return o.aP(le,0,o.X,-o.X,0,0,1),o.J(le,le,[0,-o.X,0]),{u_matrix:le,u_image:1,u_dimension:[se,se],u_zoom:ee.overscaledZ,u_unpack:te.getUnpackVector()}})(l.tileID,R),null,f.id,E.rasterBoundsBuffer,E.quadTriangleIndexBuffer,E.rasterBoundsSegments),l.needsHillshadePrepare=!1}}function Cy(E,l,f,b,_,w){const M=b.paint.get("raster-fade-duration");if(!w&&M>0){const P=v.now(),R=(P-E.timeAdded)/M,z=l?(P-l.timeAdded)/M:-1,$=f.getSource(),j=_.coveringZoomLevel({tileSize:$.tileSize,roundZoom:$.roundZoom}),X=!l||Math.abs(l.tileID.overscaledZ-j)>Math.abs(E.tileID.overscaledZ-j),ee=X&&E.refreshedUponExpiration?1:o.ac(X?R:1-z,0,1);return E.refreshedUponExpiration&&R>=1&&(E.refreshedUponExpiration=!1),l?{opacity:1,mix:1-ee}:{opacity:ee,mix:0}}return{opacity:1,mix:0}}const jf=new o.aM(1,0,0,1),Sn=new o.aM(0,1,0,1),wu=new o.aM(0,0,1,1),t1=new o.aM(1,0,1,1),Ty=new o.aM(0,1,1,1);function kl(E,l,f,b){ku(E,0,l+f/2,E.transform.width,f,b)}function Ay(E,l,f,b){ku(E,l-f/2,0,f,E.transform.height,b)}function ku(E,l,f,b,_,w){const M=E.context,P=M.gl;P.enable(P.SCISSOR_TEST),P.scissor(l*E.pixelRatio,f*E.pixelRatio,b*E.pixelRatio,_*E.pixelRatio),M.clear({color:w}),P.disable(P.SCISSOR_TEST)}function My(E,l,f){const b=E.context,_=b.gl,w=f.posMatrix,M=E.useProgram("debug"),P=rn.disabled,R=qn.disabled,z=E.colorModeForRenderPass(),$="$debug",j=E.style.map.terrain&&E.style.map.terrain.getTerrainData(f);b.activeTexture.set(_.TEXTURE0);const X=l.getTileByID(f.key).latestRawTileData,ee=Math.floor((X&&X.byteLength||0)/1024),te=l.getTile(f).tileSize,se=512/Math.min(te,512)*(f.overscaledZ/E.transform.zoom)*.5;let le=f.canonical.toString();f.overscaledZ!==f.canonical.z&&(le+=` => ${f.overscaledZ}`),function(de,pe){de.initDebugOverlayCanvas();const ie=de.debugOverlayCanvas,_e=de.context.gl,ve=de.debugOverlayCanvas.getContext("2d");ve.clearRect(0,0,ie.width,ie.height),ve.shadowColor="white",ve.shadowBlur=2,ve.lineWidth=1.5,ve.strokeStyle="white",ve.textBaseline="top",ve.font="bold 36px Open Sans, sans-serif",ve.fillText(pe,5,5),ve.strokeText(pe,5,5),de.debugOverlayTexture.update(ie),de.debugOverlayTexture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE)}(E,`${le} ${ee}kB`),M.draw(b,_.TRIANGLES,P,R,pr.alphaBlended,Fn.disabled,Nc(w,o.aM.transparent,se),null,$,E.debugBuffer,E.quadTriangleIndexBuffer,E.debugSegments),M.draw(b,_.LINE_STRIP,P,R,z,Fn.disabled,Nc(w,o.aM.red),j,$,E.debugBuffer,E.tileBorderIndexBuffer,E.debugSegments)}function Dy(E,l,f){const b=E.context,_=b.gl,w=E.colorModeForRenderPass(),M=new rn(_.LEQUAL,rn.ReadWrite,E.depthRangeFor3D),P=E.useProgram("terrain"),R=l.getTerrainMesh();b.bindFramebuffer.set(null),b.viewport.set([0,0,E.width,E.height]);for(const z of f){const $=E.renderToTexture.getTexture(z),j=l.getTerrainData(z.tileID);b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,$.texture);const X=E.transform.calculatePosMatrix(z.tileID.toUnwrapped()),ee=l.getMeshFrameDelta(E.transform.zoom),te=E.transform.calculateFogMatrix(z.tileID.toUnwrapped()),se=Sf(X,ee,te,E.style.sky,E.transform.pitch);P.draw(b,_.TRIANGLES,M,qn.disabled,w,Fn.backCCW,se,j,"terrain",R.vertexBuffer,R.indexBuffer,R.segments)}}class Eu{constructor(l,f,b){this.vertexBuffer=l,this.indexBuffer=f,this.segments=b}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class Su{constructor(l,f){this.context=new e1(l),this.transform=f,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$e.maxUnderzooming+$e.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new kf}resize(l,f,b){if(this.width=Math.floor(l*b),this.height=Math.floor(f*b),this.pixelRatio=b,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const _ of this.style._order)this.style._layers[_].resize()}setup(){const l=this.context,f=new o.aX;f.emplaceBack(0,0),f.emplaceBack(o.X,0),f.emplaceBack(0,o.X),f.emplaceBack(o.X,o.X),this.tileExtentBuffer=l.createVertexBuffer(f,_a.members),this.tileExtentSegments=o.a0.simpleSegment(0,0,4,2);const b=new o.aX;b.emplaceBack(0,0),b.emplaceBack(o.X,0),b.emplaceBack(0,o.X),b.emplaceBack(o.X,o.X),this.debugBuffer=l.createVertexBuffer(b,_a.members),this.debugSegments=o.a0.simpleSegment(0,0,4,5);const _=new o.$;_.emplaceBack(0,0,0,0),_.emplaceBack(o.X,0,o.X,0),_.emplaceBack(0,o.X,0,o.X),_.emplaceBack(o.X,o.X,o.X,o.X),this.rasterBoundsBuffer=l.createVertexBuffer(_,dt.members),this.rasterBoundsSegments=o.a0.simpleSegment(0,0,4,2);const w=new o.aX;w.emplaceBack(0,0),w.emplaceBack(1,0),w.emplaceBack(0,1),w.emplaceBack(1,1),this.viewportBuffer=l.createVertexBuffer(w,_a.members),this.viewportSegments=o.a0.simpleSegment(0,0,4,2);const M=new o.aZ;M.emplaceBack(0),M.emplaceBack(1),M.emplaceBack(3),M.emplaceBack(2),M.emplaceBack(0),this.tileBorderIndexBuffer=l.createIndexBuffer(M);const P=new o.aY;P.emplaceBack(0,1,2),P.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=l.createIndexBuffer(P);const R=this.context.gl;this.stencilClearMode=new qn({func:R.ALWAYS,mask:0},0,255,R.ZERO,R.ZERO,R.ZERO)}clearStencil(){const l=this.context,f=l.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const b=o.H();o.aP(b,0,this.width,this.height,0,0,1),o.K(b,b,[f.drawingBufferWidth,f.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(l,f.TRIANGLES,rn.disabled,this.stencilClearMode,pr.disabled,Fn.disabled,Ei(b),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(l,f){if(this.currentStencilSource===l.source||!l.isTileClipped()||!f||!f.length)return;this.currentStencilSource=l.source;const b=this.context,_=b.gl;this.nextStencilID+f.length>256&&this.clearStencil(),b.setColorMode(pr.disabled),b.setDepthMode(rn.disabled);const w=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of f){const P=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,R=this.style.map.terrain&&this.style.map.terrain.getTerrainData(M);w.draw(b,_.TRIANGLES,rn.disabled,new qn({func:_.ALWAYS,mask:0},P,255,_.KEEP,_.KEEP,_.REPLACE),pr.disabled,Fn.disabled,Ei(M.posMatrix),R,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const l=this.nextStencilID++,f=this.context.gl;return new qn({func:f.NOTEQUAL,mask:255},l,255,f.KEEP,f.KEEP,f.REPLACE)}stencilModeForClipping(l){const f=this.context.gl;return new qn({func:f.EQUAL,mask:255},this._tileClippingMaskIDs[l.key],0,f.KEEP,f.KEEP,f.REPLACE)}stencilConfigForOverlap(l){const f=this.context.gl,b=l.sort((M,P)=>P.overscaledZ-M.overscaledZ),_=b[b.length-1].overscaledZ,w=b[0].overscaledZ-_+1;if(w>1){this.currentStencilSource=void 0,this.nextStencilID+w>256&&this.clearStencil();const M={};for(let P=0;P<w;P++)M[P+_]=new qn({func:f.GEQUAL,mask:255},P+this.nextStencilID,255,f.KEEP,f.KEEP,f.REPLACE);return this.nextStencilID+=w,[M,b]}return[{[_]:qn.disabled},b]}colorModeForRenderPass(){const l=this.context.gl;return this._showOverdrawInspector?new pr([l.CONSTANT_COLOR,l.ONE],new o.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?pr.unblended:pr.alphaBlended}depthModeForSublayer(l,f,b){if(!this.opaquePassEnabledForLayer())return rn.disabled;const _=1-((1+this.currentLayer)*this.numSublayers+l)*this.depthEpsilon;return new rn(b||this.context.gl.LEQUAL,f,[_,_])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(l,f){this.style=l,this.options=f,this.lineAtlas=l.lineAtlas,this.imageManager=l.imageManager,this.glyphManager=l.glyphManager,this.symbolFadeChange=l.placement.symbolFadeChange(v.now()),this.imageManager.beginFrame();const b=this.style._order,_=this.style.sourceCaches,w={},M={},P={};for(const R in _){const z=_[R];z.used&&z.prepare(this.context),w[R]=z.getVisibleCoordinates(),M[R]=w[R].slice().reverse(),P[R]=z.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let R=0;R<b.length;R++)if(this.style._layers[b[R]].is3D()){this.opaquePassCutoff=R;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const R of b){const z=this.style._layers[R];if(!z.hasOffscreenPass()||z.isHidden(this.transform.zoom))continue;const $=M[z.source];(z.type==="custom"||$.length)&&this.renderLayer(this,_[z.source],z,$)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:f.showOverdrawInspector?o.aM.black:o.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(R,z){const $=R.context,j=$.gl,X=((de,pe,ie)=>({u_sky_color:de.properties.get("sky-color"),u_horizon_color:de.properties.get("horizon-color"),u_horizon:(pe.height/2+pe.getHorizon())*ie,u_sky_horizon_blend:de.properties.get("sky-horizon-blend")*pe.height/2*ie}))(z,R.style.map.transform,R.pixelRatio),ee=new rn(j.LEQUAL,rn.ReadWrite,[0,1]),te=qn.disabled,se=R.colorModeForRenderPass(),le=R.useProgram("sky");if(!z.mesh){const de=new o.aX;de.emplaceBack(-1,-1),de.emplaceBack(1,-1),de.emplaceBack(1,1),de.emplaceBack(-1,1);const pe=new o.aY;pe.emplaceBack(0,1,2),pe.emplaceBack(0,2,3),z.mesh=new Eu($.createVertexBuffer(de,_a.members),$.createIndexBuffer(pe),o.a0.simpleSegment(0,0,de.length,pe.length))}le.draw($,j.TRIANGLES,ee,te,se,Fn.disabled,X,void 0,"sky",z.mesh.vertexBuffer,z.mesh.indexBuffer,z.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=f.showOverdrawInspector,this.depthRangeFor3D=[0,1-(l._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=b.length-1;this.currentLayer>=0;this.currentLayer--){const R=this.style._layers[b[this.currentLayer]],z=_[R.source],$=w[R.source];this._renderTileClippingMasks(R,$),this.renderLayer(this,z,R,$)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<b.length;this.currentLayer++){const R=this.style._layers[b[this.currentLayer]],z=_[R.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(R))continue;const $=(R.type==="symbol"?P:M)[R.source];this._renderTileClippingMasks(R,w[R.source]),this.renderLayer(this,z,R,$)}if(this.options.showTileBoundaries){const R=function(z,$){let j=null;const X=Object.values(z._layers).flatMap(le=>le.source&&!le.isHidden($)?[z.sourceCaches[le.source]]:[]),ee=X.filter(le=>le.getSource().type==="vector"),te=X.filter(le=>le.getSource().type!=="vector"),se=le=>{(!j||j.getSource().maxzoom<le.getSource().maxzoom)&&(j=le)};return ee.forEach(le=>se(le)),j||te.forEach(le=>se(le)),j}(this.style,this.transform.zoom);R&&function(z,$,j){for(let X=0;X<j.length;X++)My(z,$,j[X])}(this,R,R.getVisibleCoordinates())}this.options.showPadding&&function(R){const z=R.transform.padding;kl(R,R.transform.height-(z.top||0),3,jf),kl(R,z.bottom||0,3,Sn),Ay(R,z.left||0,3,wu),Ay(R,R.transform.width-(z.right||0),3,t1);const $=R.transform.centerPoint;(function(j,X,ee,te){ku(j,X-1,ee-10,2,20,te),ku(j,X-10,ee-1,20,2,te)})(R,$.x,R.transform.height-$.y,Ty)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(l){if(!this.style||!this.style.map||!this.style.map.terrain)return;const f=this.terrainFacilitator.matrix,b=this.transform.modelViewProjectionMatrix;let _=this.terrainFacilitator.dirty;_||(_=l?!o.a_(f,b):!o.a$(f,b)),_||(_=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),_&&(o.b0(f,b),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(w,M){const P=w.context,R=P.gl,z=pr.unblended,$=new rn(R.LEQUAL,rn.ReadWrite,[0,1]),j=M.getTerrainMesh(),X=M.sourceCache.getRenderableTiles(),ee=w.useProgram("terrainDepth");P.bindFramebuffer.set(M.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1});for(const te of X){const se=M.getTerrainData(te.tileID),le={u_matrix:w.transform.calculatePosMatrix(te.tileID.toUnwrapped()),u_ele_delta:M.getMeshFrameDelta(w.transform.zoom)};ee.draw(P,R.TRIANGLES,$,qn.disabled,z,Fn.backCCW,le,se,"terrain",j.vertexBuffer,j.indexBuffer,j.segments)}P.bindFramebuffer.set(null),P.viewport.set([0,0,w.width,w.height])}(this,this.style.map.terrain),function(w,M){const P=w.context,R=P.gl,z=pr.unblended,$=new rn(R.LEQUAL,rn.ReadWrite,[0,1]),j=M.getTerrainMesh(),X=M.getCoordsTexture(),ee=M.sourceCache.getRenderableTiles(),te=w.useProgram("terrainCoords");P.bindFramebuffer.set(M.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1}),M.coordsIndex=[];for(const se of ee){const le=M.getTerrainData(se.tileID);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,X.texture);const de={u_matrix:w.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_terrain_coords_id:(255-M.coordsIndex.length)/255,u_texture:0,u_ele_delta:M.getMeshFrameDelta(w.transform.zoom)};te.draw(P,R.TRIANGLES,$,qn.disabled,z,Fn.backCCW,de,le,"terrain",j.vertexBuffer,j.indexBuffer,j.segments),M.coordsIndex.push(se.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,w.width,w.height])}(this,this.style.map.terrain))}renderLayer(l,f,b,_){if(!b.isHidden(this.transform.zoom)&&(b.type==="background"||b.type==="custom"||(_||[]).length))switch(this.id=b.id,b.type){case"symbol":(function(w,M,P,R,z){if(w.renderPass!=="translucent")return;const $=qn.disabled,j=w.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(X,ee,te,se,le,de,pe,ie,_e){const ve=ee.transform,Ce=ba(),ze=le==="map",Ze=de==="map";for(const ot of X){const ut=se.getTile(ot),rt=ut.getBucket(te);if(!rt||!rt.text||!rt.text.segments.get().length)continue;const nt=o.ag(rt.textSizeData,ve.zoom),vt=cn(ut,1,ee.transform.zoom),Ht=di(ot.posMatrix,Ze,ze,ee.transform,vt),it=te.layout.get("icon-text-fit")!=="none"&&rt.hasIconData();if(nt){const lt=Math.pow(2,ve.zoom-ut.tileID.overscaledZ),Ft=ee.style.map.terrain?(Jt,dn)=>ee.style.map.terrain.getElevation(ot,Jt,dn):null,Xn=Ce.translatePosition(ve,ut,pe,ie);_l(rt,ze,Ze,_e,ve,Ht,ot.posMatrix,lt,nt,it,Ce,Xn,ot.toUnwrapped(),Ft)}}}(R,w,P,M,P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),z),P.paint.get("icon-opacity").constantOr(1)!==0&&Lf(w,M,P,R,!1,P.paint.get("icon-translate"),P.paint.get("icon-translate-anchor"),P.layout.get("icon-rotation-alignment"),P.layout.get("icon-pitch-alignment"),P.layout.get("icon-keep-upright"),$,j),P.paint.get("text-opacity").constantOr(1)!==0&&Lf(w,M,P,R,!0,P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.layout.get("text-keep-upright"),$,j),M.map.showCollisionBoxes&&(Bc(w,M,P,R,!0),Bc(w,M,P,R,!1))})(l,f,b,_,this.style.placement.variableOffsets);break;case"circle":(function(w,M,P,R){if(w.renderPass!=="translucent")return;const z=P.paint.get("circle-opacity"),$=P.paint.get("circle-stroke-width"),j=P.paint.get("circle-stroke-opacity"),X=!P.layout.get("circle-sort-key").isConstant();if(z.constantOr(1)===0&&($.constantOr(1)===0||j.constantOr(1)===0))return;const ee=w.context,te=ee.gl,se=w.depthModeForSublayer(0,rn.ReadOnly),le=qn.disabled,de=w.colorModeForRenderPass(),pe=[];for(let ie=0;ie<R.length;ie++){const _e=R[ie],ve=M.getTile(_e),Ce=ve.getBucket(P);if(!Ce)continue;const ze=Ce.programConfigurations.get(P.id),Ze=w.useProgram("circle",ze),ot=Ce.layoutVertexBuffer,ut=Ce.indexBuffer,rt=w.style.map.terrain&&w.style.map.terrain.getTerrainData(_e),nt={programConfiguration:ze,program:Ze,layoutVertexBuffer:ot,indexBuffer:ut,uniformValues:$v(w,_e,ve,P),terrainData:rt};if(X){const vt=Ce.segments.get();for(const Ht of vt)pe.push({segments:new o.a0([Ht]),sortKey:Ht.sortKey,state:nt})}else pe.push({segments:Ce.segments,sortKey:0,state:nt})}X&&pe.sort((ie,_e)=>ie.sortKey-_e.sortKey);for(const ie of pe){const{programConfiguration:_e,program:ve,layoutVertexBuffer:Ce,indexBuffer:ze,uniformValues:Ze,terrainData:ot}=ie.state;ve.draw(ee,te.TRIANGLES,se,le,de,Fn.disabled,Ze,ot,P.id,Ce,ze,ie.segments,P.paint,w.transform.zoom,_e)}})(l,f,b,_);break;case"heatmap":(function(w,M,P,R){if(P.paint.get("heatmap-opacity")===0)return;const z=w.context;if(w.style.map.terrain){for(const $ of R){const j=M.getTile($);M.hasRenderableParent($)||(w.renderPass==="offscreen"?$f(w,j,P,$):w.renderPass==="translucent"&&Ca(w,P,$))}z.viewport.set([0,0,w.width,w.height])}else w.renderPass==="offscreen"?function($,j,X,ee){const te=$.context,se=te.gl,le=qn.disabled,de=new pr([se.ONE,se.ONE],o.aM.transparent,[!0,!0,!0,!0]);(function(pe,ie,_e){const ve=pe.gl;pe.activeTexture.set(ve.TEXTURE1),pe.viewport.set([0,0,ie.width/4,ie.height/4]);let Ce=_e.heatmapFbos.get(o.aU);Ce?(ve.bindTexture(ve.TEXTURE_2D,Ce.colorAttachment.get()),pe.bindFramebuffer.set(Ce.framebuffer)):(Ce=zc(pe,ie.width/4,ie.height/4),_e.heatmapFbos.set(o.aU,Ce))})(te,$,X),te.clear({color:o.aM.transparent});for(let pe=0;pe<ee.length;pe++){const ie=ee[pe];if(j.hasRenderableParent(ie))continue;const _e=j.getTile(ie),ve=_e.getBucket(X);if(!ve)continue;const Ce=ve.programConfigurations.get(X.id),ze=$.useProgram("heatmap",Ce),{zoom:Ze}=$.transform;ze.draw(te,se.TRIANGLES,rn.disabled,le,de,Fn.disabled,Si(ie.posMatrix,_e,Ze,X.paint.get("heatmap-intensity")),null,X.id,ve.layoutVertexBuffer,ve.indexBuffer,ve.segments,X.paint,$.transform.zoom,Ce)}te.viewport.set([0,0,$.width,$.height])}(w,M,P,R):w.renderPass==="translucent"&&function($,j){const X=$.context,ee=X.gl;X.setColorMode($.colorModeForRenderPass());const te=j.heatmapFbos.get(o.aU);te&&(X.activeTexture.set(ee.TEXTURE0),ee.bindTexture(ee.TEXTURE_2D,te.colorAttachment.get()),X.activeTexture.set(ee.TEXTURE1),Lc(X,j).bind(ee.LINEAR,ee.CLAMP_TO_EDGE),$.useProgram("heatmapTexture").draw(X,ee.TRIANGLES,rn.disabled,qn.disabled,$.colorModeForRenderPass(),Fn.disabled,hu($,j,0,1),null,j.id,$.viewportBuffer,$.quadTriangleIndexBuffer,$.viewportSegments,j.paint,$.transform.zoom))}(w,P)})(l,f,b,_);break;case"line":(function(w,M,P,R){if(w.renderPass!=="translucent")return;const z=P.paint.get("line-opacity"),$=P.paint.get("line-width");if(z.constantOr(1)===0||$.constantOr(1)===0)return;const j=w.depthModeForSublayer(0,rn.ReadOnly),X=w.colorModeForRenderPass(),ee=P.paint.get("line-dasharray"),te=P.paint.get("line-pattern"),se=te.constantOr(1),le=P.paint.get("line-gradient"),de=P.getCrossfadeParameters(),pe=se?"linePattern":ee?"lineSDF":le?"lineGradient":"line",ie=w.context,_e=ie.gl;let ve=!0;for(const Ce of R){const ze=M.getTile(Ce);if(se&&!ze.patternsLoaded())continue;const Ze=ze.getBucket(P);if(!Ze)continue;const ot=Ze.programConfigurations.get(P.id),ut=w.context.program.get(),rt=w.useProgram(pe,ot),nt=ve||rt.program!==ut,vt=w.style.map.terrain&&w.style.map.terrain.getTerrainData(Ce),Ht=te.constantOr(null);if(Ht&&ze.imageAtlas){const Ft=ze.imageAtlas,Xn=Ft.patternPositions[Ht.to.toString()],Jt=Ft.patternPositions[Ht.from.toString()];Xn&&Jt&&ot.setConstantPatternPositions(Xn,Jt)}const it=vt?Ce:null,lt=se?yl(w,ze,P,de,it):ee?jv(w,ze,P,ee,de,it):le?dy(w,ze,P,Ze.lineClipsArray.length,it):pu(w,ze,P,it);if(se)ie.activeTexture.set(_e.TEXTURE0),ze.imageAtlasTexture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE),ot.updatePaintBuffers(de);else if(ee&&(nt||w.lineAtlas.dirty))ie.activeTexture.set(_e.TEXTURE0),w.lineAtlas.bind(ie);else if(le){const Ft=Ze.gradients[P.id];let Xn=Ft.texture;if(P.gradientVersion!==Ft.version){let Jt=256;if(P.stepInterpolant){const dn=M.getSource().maxzoom,Kn=Ce.canonical.z===dn?Math.ceil(1<<w.transform.maxZoom-Ce.canonical.z):1;Jt=o.ac(o.aV(Ze.maxLineLength/o.X*1024*Kn),256,ie.maxTextureSize)}Ft.gradient=o.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:Jt,image:Ft.gradient||void 0,clips:Ze.lineClipsArray}),Ft.texture?Ft.texture.update(Ft.gradient):Ft.texture=new Le(ie,Ft.gradient,_e.RGBA),Ft.version=P.gradientVersion,Xn=Ft.texture}ie.activeTexture.set(_e.TEXTURE0),Xn.bind(P.stepInterpolant?_e.NEAREST:_e.LINEAR,_e.CLAMP_TO_EDGE)}rt.draw(ie,_e.TRIANGLES,j,w.stencilModeForClipping(Ce),X,Fn.disabled,lt,vt,P.id,Ze.layoutVertexBuffer,Ze.indexBuffer,Ze.segments,P.paint,w.transform.zoom,ot,Ze.layoutVertexBuffer2),ve=!1}})(l,f,b,_);break;case"fill":(function(w,M,P,R){const z=P.paint.get("fill-color"),$=P.paint.get("fill-opacity");if($.constantOr(1)===0)return;const j=w.colorModeForRenderPass(),X=P.paint.get("fill-pattern"),ee=w.opaquePassEnabledForLayer()&&!X.constantOr(1)&&z.constantOr(o.aM.transparent).a===1&&$.constantOr(0)===1?"opaque":"translucent";if(w.renderPass===ee){const te=w.depthModeForSublayer(1,w.renderPass==="opaque"?rn.ReadWrite:rn.ReadOnly);Fc(w,M,P,R,te,j,!1)}if(w.renderPass==="translucent"&&P.paint.get("fill-antialias")){const te=w.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,rn.ReadOnly);Fc(w,M,P,R,te,j,!0)}})(l,f,b,_);break;case"fill-extrusion":(function(w,M,P,R){const z=P.paint.get("fill-extrusion-opacity");if(z!==0&&w.renderPass==="translucent"){const $=new rn(w.context.gl.LEQUAL,rn.ReadWrite,w.depthRangeFor3D);if(z!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))vu(w,M,P,R,$,qn.disabled,pr.disabled),vu(w,M,P,R,$,w.stencilModeFor3D(),w.colorModeForRenderPass());else{const j=w.colorModeForRenderPass();vu(w,M,P,R,$,qn.disabled,j)}}})(l,f,b,_);break;case"hillshade":(function(w,M,P,R){if(w.renderPass!=="offscreen"&&w.renderPass!=="translucent")return;const z=w.context,$=w.depthModeForSublayer(0,rn.ReadOnly),j=w.colorModeForRenderPass(),[X,ee]=w.renderPass==="translucent"?w.stencilConfigForOverlap(R):[{},R];for(const te of ee){const se=M.getTile(te);se.needsHillshadePrepare!==void 0&&se.needsHillshadePrepare&&w.renderPass==="offscreen"?wl(w,se,P,$,qn.disabled,j):w.renderPass==="translucent"&&vl(w,te,se,P,$,X[te.overscaledZ],j)}z.viewport.set([0,0,w.width,w.height])})(l,f,b,_);break;case"raster":(function(w,M,P,R){if(w.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!R.length)return;const z=w.context,$=z.gl,j=M.getSource(),X=w.useProgram("raster"),ee=w.colorModeForRenderPass(),[te,se]=j instanceof ir?[{},R]:w.stencilConfigForOverlap(R),le=se[se.length-1].overscaledZ,de=!w.options.moving;for(const pe of se){const ie=w.depthModeForSublayer(pe.overscaledZ-le,P.paint.get("raster-opacity")===1?rn.ReadWrite:rn.ReadOnly,$.LESS),_e=M.getTile(pe);_e.registerFadeDuration(P.paint.get("raster-fade-duration"));const ve=M.findLoadedParent(pe,0),Ce=M.findLoadedSibling(pe),ze=Cy(_e,ve||Ce||null,M,P,w.transform,w.style.map.terrain);let Ze,ot;const ut=P.paint.get("raster-resampling")==="nearest"?$.NEAREST:$.LINEAR;z.activeTexture.set($.TEXTURE0),_e.texture.bind(ut,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),z.activeTexture.set($.TEXTURE1),ve?(ve.texture.bind(ut,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),Ze=Math.pow(2,ve.tileID.overscaledZ-_e.tileID.overscaledZ),ot=[_e.tileID.canonical.x*Ze%1,_e.tileID.canonical.y*Ze%1]):_e.texture.bind(ut,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),_e.texture.useMipmap&&z.extTextureFilterAnisotropic&&w.transform.pitch>20&&$.texParameterf($.TEXTURE_2D,z.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,z.extTextureFilterAnisotropicMax);const rt=w.style.map.terrain&&w.style.map.terrain.getTerrainData(pe),nt=rt?pe:null,vt=nt?nt.posMatrix:w.transform.calculatePosMatrix(pe.toUnwrapped(),de),Ht=Hv(vt,ot||[0,0],Ze||1,ze,P);j instanceof ir?X.draw(z,$.TRIANGLES,ie,qn.disabled,ee,Fn.disabled,Ht,rt,P.id,j.boundsBuffer,w.quadTriangleIndexBuffer,j.boundsSegments):X.draw(z,$.TRIANGLES,ie,te[pe.overscaledZ],ee,Fn.disabled,Ht,rt,P.id,w.rasterBoundsBuffer,w.quadTriangleIndexBuffer,w.rasterBoundsSegments)}})(l,f,b,_);break;case"background":(function(w,M,P,R){const z=P.paint.get("background-color"),$=P.paint.get("background-opacity");if($===0)return;const j=w.context,X=j.gl,ee=w.transform,te=ee.tileSize,se=P.paint.get("background-pattern");if(w.isPatternMissing(se))return;const le=!se&&z.a===1&&$===1&&w.opaquePassEnabledForLayer()?"opaque":"translucent";if(w.renderPass!==le)return;const de=qn.disabled,pe=w.depthModeForSublayer(0,le==="opaque"?rn.ReadWrite:rn.ReadOnly),ie=w.colorModeForRenderPass(),_e=w.useProgram(se?"backgroundPattern":"background"),ve=R||ee.coveringTiles({tileSize:te,terrain:w.style.map.terrain});se&&(j.activeTexture.set(X.TEXTURE0),w.imageManager.bind(w.context));const Ce=P.getCrossfadeParameters();for(const ze of ve){const Ze=R?ze.posMatrix:w.transform.calculatePosMatrix(ze.toUnwrapped()),ot=se?Af(Ze,$,w,se,{tileID:ze,tileSize:te},Ce):mu(Ze,$,z),ut=w.style.map.terrain&&w.style.map.terrain.getTerrainData(ze);_e.draw(j,X.TRIANGLES,pe,de,ie,Fn.disabled,ot,ut,P.id,w.tileExtentBuffer,w.quadTriangleIndexBuffer,w.tileExtentSegments)}})(l,0,b,_);break;case"custom":(function(w,M,P){const R=w.context,z=P.implementation;if(w.renderPass==="offscreen"){const $=z.prerender;$&&(w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),$.call(z,R.gl,w.transform.customLayerMatrix()),R.setDirty(),w.setBaseState())}else if(w.renderPass==="translucent"){w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),R.setStencilMode(qn.disabled);const $=z.renderingMode==="3d"?new rn(w.context.gl.LEQUAL,rn.ReadWrite,w.depthRangeFor3D):w.depthModeForSublayer(0,rn.ReadOnly);R.setDepthMode($),z.render(R.gl,w.transform.customLayerMatrix(),{farZ:w.transform.farZ,nearZ:w.transform.nearZ,fov:w.transform._fov,modelViewProjectionMatrix:w.transform.modelViewProjectionMatrix,projectionMatrix:w.transform.projectionMatrix}),R.setDirty(),w.setBaseState(),R.bindFramebuffer.set(null)}})(l,0,b)}}translatePosMatrix(l,f,b,_,w){if(!b[0]&&!b[1])return l;const M=w?_==="map"?this.transform.angle:0:_==="viewport"?-this.transform.angle:0;if(M){const z=Math.sin(M),$=Math.cos(M);b=[b[0]*$-b[1]*z,b[0]*z+b[1]*$]}const P=[w?b[0]:cn(f,b[0],this.transform.zoom),w?b[1]:cn(f,b[1],this.transform.zoom),0],R=new Float32Array(16);return o.J(R,l,P),R}saveTileTexture(l){const f=this._tileTextures[l.size[0]];f?f.push(l):this._tileTextures[l.size[0]]=[l]}getTileTexture(l){const f=this._tileTextures[l];return f&&f.length>0?f.pop():null}isPatternMissing(l){if(!l)return!1;if(!l.from||!l.to)return!0;const f=this.imageManager.getPattern(l.from.toString()),b=this.imageManager.getPattern(l.to.toString());return!f||!b}useProgram(l,f){this.cache=this.cache||{};const b=l+(f?f.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[b]||(this.cache[b]=new Cf(this.context,Bo[l],f,Mf[l],this._showOverdrawInspector,this.style.map.terrain)),this.cache[b]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const l=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(l.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new Le(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:l,drawingBufferHeight:f}=this.context.gl;return this.width!==l||this.height!==f}}class El{constructor(l,f){this.points=l,this.planes=f}static fromInvProjectionMatrix(l,f,b){const _=Math.pow(2,b),w=[[-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(P=>{const R=1/(P=o.af([],P,l))[3]/f*_;return o.b1(P,P,[R,R,1/P[3],R])}),M=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const R=function(X,ee){var te=ee[0],se=ee[1],le=ee[2],de=te*te+se*se+le*le;return de>0&&(de=1/Math.sqrt(de)),X[0]=ee[0]*de,X[1]=ee[1]*de,X[2]=ee[2]*de,X}([],function(X,ee,te){var se=ee[0],le=ee[1],de=ee[2],pe=te[0],ie=te[1],_e=te[2];return X[0]=le*_e-de*ie,X[1]=de*pe-se*_e,X[2]=se*ie-le*pe,X}([],xe([],w[P[0]],w[P[1]]),xe([],w[P[2]],w[P[1]]))),z=-(($=R)[0]*(j=w[P[1]])[0]+$[1]*j[1]+$[2]*j[2]);var $,j;return R.concat(z)});return new El(w,M)}}class Sl{constructor(l,f){this.min=l,this.max=f,this.center=function(b,_,w){return b[0]=.5*_[0],b[1]=.5*_[1],b[2]=.5*_[2],b}([],function(b,_,w){return b[0]=_[0]+w[0],b[1]=_[1]+w[1],b[2]=_[2]+w[2],b}([],this.min,this.max))}quadrant(l){const f=[l%2==0,l<2],b=he(this.min),_=he(this.max);for(let w=0;w<f.length;w++)b[w]=f[w]?this.min[w]:this.center[w],_[w]=f[w]?this.center[w]:this.max[w];return _[2]=this.max[2],new Sl(b,_)}distanceX(l){return Math.max(Math.min(this.max[0],l[0]),this.min[0])-l[0]}distanceY(l){return Math.max(Math.min(this.max[1],l[1]),this.min[1])-l[1]}intersects(l){const f=[[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]];let b=!0;for(let _=0;_<l.planes.length;_++){const w=l.planes[_];let M=0;for(let P=0;P<f.length;P++)o.b2(w,f[P])>=0&&M++;if(M===0)return 0;M!==f.length&&(b=!1)}if(b)return 2;for(let _=0;_<3;_++){let w=Number.MAX_VALUE,M=-Number.MAX_VALUE;for(let P=0;P<l.points.length;P++){const R=l.points[P][_]-this.min[_];w=Math.min(w,R),M=Math.max(M,R)}if(M<0||w>this.max[_]-this.min[_])return 0}return 1}}class Cl{constructor(l=0,f=0,b=0,_=0){if(isNaN(l)||l<0||isNaN(f)||f<0||isNaN(b)||b<0||isNaN(_)||_<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=l,this.bottom=f,this.left=b,this.right=_}interpolate(l,f,b){return f.top!=null&&l.top!=null&&(this.top=o.y.number(l.top,f.top,b)),f.bottom!=null&&l.bottom!=null&&(this.bottom=o.y.number(l.bottom,f.bottom,b)),f.left!=null&&l.left!=null&&(this.left=o.y.number(l.left,f.left,b)),f.right!=null&&l.right!=null&&(this.right=o.y.number(l.right,f.right,b)),this}getCenter(l,f){const b=o.ac((this.left+l-this.right)/2,0,l),_=o.ac((this.top+f-this.bottom)/2,0,f);return new o.P(b,_)}equals(l){return this.top===l.top&&this.bottom===l.bottom&&this.left===l.left&&this.right===l.right}clone(){return new Cl(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Hf=85.051129;class Tl{constructor(l,f,b,_,w){this.tileSize=512,this._renderWorldCopies=w===void 0||!!w,this._minZoom=l||0,this._maxZoom=f||22,this._minPitch=b??0,this._maxPitch=_??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new o.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Cl,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const l=new Tl(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return l.apply(this),l}apply(l){this.tileSize=l.tileSize,this.latRange=l.latRange,this.lngRange=l.lngRange,this.width=l.width,this.height=l.height,this._center=l._center,this._elevation=l._elevation,this.minElevationForCurrentTile=l.minElevationForCurrentTile,this.zoom=l.zoom,this.angle=l.angle,this._fov=l._fov,this._pitch=l._pitch,this._unmodified=l._unmodified,this._edgeInsets=l._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(l){this._minZoom!==l&&(this._minZoom=l,this.zoom=Math.max(this.zoom,l))}get maxZoom(){return this._maxZoom}set maxZoom(l){this._maxZoom!==l&&(this._maxZoom=l,this.zoom=Math.min(this.zoom,l))}get minPitch(){return this._minPitch}set minPitch(l){this._minPitch!==l&&(this._minPitch=l,this.pitch=Math.max(this.pitch,l))}get maxPitch(){return this._maxPitch}set maxPitch(l){this._maxPitch!==l&&(this._maxPitch=l,this.pitch=Math.min(this.pitch,l))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(l){l===void 0?l=!0:l===null&&(l=!1),this._renderWorldCopies=l}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new o.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(l){const f=-o.b3(l,-180,180)*Math.PI/180;this.angle!==f&&(this._unmodified=!1,this.angle=f,this._calcMatrices(),this.rotationMatrix=function(){var b=new o.A(4);return o.A!=Float32Array&&(b[1]=0,b[2]=0),b[0]=1,b[3]=1,b}(),function(b,_,w){var M=_[0],P=_[1],R=_[2],z=_[3],$=Math.sin(w),j=Math.cos(w);b[0]=M*j+R*$,b[1]=P*j+z*$,b[2]=M*-$+R*j,b[3]=P*-$+z*j}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(l){const f=o.ac(l,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==f&&(this._unmodified=!1,this._pitch=f,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(l){l=Math.max(.01,Math.min(60,l)),this._fov!==l&&(this._unmodified=!1,this._fov=l/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(l){const f=Math.min(Math.max(l,this.minZoom),this.maxZoom);this._zoom!==f&&(this._unmodified=!1,this._zoom=f,this.tileZoom=Math.max(0,Math.floor(f)),this.scale=this.zoomScale(f),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(l){l.lat===this._center.lat&&l.lng===this._center.lng||(this._unmodified=!1,this._center=l,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(l){l!==this._elevation&&(this._elevation=l,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(l){this._edgeInsets.equals(l)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,l,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(l){return this._edgeInsets.equals(l)}interpolatePadding(l,f,b){this._unmodified=!1,this._edgeInsets.interpolate(l,f,b),this._constrain(),this._calcMatrices()}coveringZoomLevel(l){const f=(l.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/l.tileSize));return Math.max(0,f)}getVisibleUnwrappedCoordinates(l){const f=[new o.b4(0,l)];if(this._renderWorldCopies){const b=this.pointCoordinate(new o.P(0,0)),_=this.pointCoordinate(new o.P(this.width,0)),w=this.pointCoordinate(new o.P(this.width,this.height)),M=this.pointCoordinate(new o.P(0,this.height)),P=Math.floor(Math.min(b.x,_.x,w.x,M.x)),R=Math.floor(Math.max(b.x,_.x,w.x,M.x)),z=1;for(let $=P-z;$<=R+z;$++)$!==0&&f.push(new o.b4($,l))}return f}coveringTiles(l){var f,b;let _=this.coveringZoomLevel(l);const w=_;if(l.minzoom!==void 0&&_<l.minzoom)return[];l.maxzoom!==void 0&&_>l.maxzoom&&(_=l.maxzoom);const M=this.pointCoordinate(this.getCameraPoint()),P=o.Z.fromLngLat(this.center),R=Math.pow(2,_),z=[R*M.x,R*M.y,0],$=[R*P.x,R*P.y,0],j=El.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,_);let X=l.minzoom||0;!l.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(X=_);const ee=l.terrain?2/Math.min(this.tileSize,l.tileSize)*this.tileSize:3,te=ie=>({aabb:new Sl([ie*R,0,0],[(ie+1)*R,R,0]),zoom:0,x:0,y:0,wrap:ie,fullyVisible:!1}),se=[],le=[],de=_,pe=l.reparseOverscaled?w:_;if(this._renderWorldCopies)for(let ie=1;ie<=3;ie++)se.push(te(-ie)),se.push(te(ie));for(se.push(te(0));se.length>0;){const ie=se.pop(),_e=ie.x,ve=ie.y;let Ce=ie.fullyVisible;if(!Ce){const rt=ie.aabb.intersects(j);if(rt===0)continue;Ce=rt===2}const ze=l.terrain?z:$,Ze=ie.aabb.distanceX(ze),ot=ie.aabb.distanceY(ze),ut=Math.max(Math.abs(Ze),Math.abs(ot));if(ie.zoom===de||ut>ee+(1<<de-ie.zoom)-2&&ie.zoom>=X){const rt=de-ie.zoom,nt=z[0]-.5-(_e<<rt),vt=z[1]-.5-(ve<<rt);le.push({tileID:new o.S(ie.zoom===de?pe:ie.zoom,ie.wrap,ie.zoom,_e,ve),distanceSq:Re([$[0]-.5-_e,$[1]-.5-ve]),tileDistanceToCamera:Math.sqrt(nt*nt+vt*vt)})}else for(let rt=0;rt<4;rt++){const nt=(_e<<1)+rt%2,vt=(ve<<1)+(rt>>1),Ht=ie.zoom+1;let it=ie.aabb.quadrant(rt);if(l.terrain){const lt=new o.S(Ht,ie.wrap,Ht,nt,vt),Ft=l.terrain.getMinMaxElevation(lt),Xn=(f=Ft.minElevation)!==null&&f!==void 0?f:this.elevation,Jt=(b=Ft.maxElevation)!==null&&b!==void 0?b:this.elevation;it=new Sl([it.min[0],it.min[1],Xn],[it.max[0],it.max[1],Jt])}se.push({aabb:it,zoom:Ht,x:nt,y:vt,wrap:ie.wrap,fullyVisible:Ce})}}return le.sort((ie,_e)=>ie.distanceSq-_e.distanceSq).map(ie=>ie.tileID)}resize(l,f){this.width=l,this.height=f,this.pixelsToGLUnits=[2/l,-2/f],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(l){return Math.pow(2,l)}scaleZoom(l){return Math.log(l)/Math.LN2}project(l){const f=o.ac(l.lat,-85.051129,Hf);return new o.P(o.O(l.lng)*this.worldSize,o.Q(f)*this.worldSize)}unproject(l){return new o.Z(l.x/this.worldSize,l.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(l){const f=this.elevation,b=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,_=this.pointLocation(this.centerPoint,l),w=l.getElevationForLngLatZoom(_,this.tileZoom);if(!(this.elevation-w))return;const M=b+f-w,P=Math.cos(this._pitch)*this.cameraToCenterDistance/M/o.b5(1,_.lat),R=this.scaleZoom(P/this.tileSize);this._elevation=w,this._center=_,this.zoom=R}setLocationAtPoint(l,f){const b=this.pointCoordinate(f),_=this.pointCoordinate(this.centerPoint),w=this.locationCoordinate(l),M=new o.Z(w.x-(b.x-_.x),w.y-(b.y-_.y));this.center=this.coordinateLocation(M),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(l,f){return f?this.coordinatePoint(this.locationCoordinate(l),f.getElevationForLngLatZoom(l,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(l))}pointLocation(l,f){return this.coordinateLocation(this.pointCoordinate(l,f))}locationCoordinate(l){return o.Z.fromLngLat(l)}coordinateLocation(l){return l&&l.toLngLat()}pointCoordinate(l,f){if(f){const X=f.pointCoordinate(l);if(X!=null)return X}const b=[l.x,l.y,0,1],_=[l.x,l.y,1,1];o.af(b,b,this.pixelMatrixInverse),o.af(_,_,this.pixelMatrixInverse);const w=b[3],M=_[3],P=b[1]/w,R=_[1]/M,z=b[2]/w,$=_[2]/M,j=z===$?0:(0-z)/($-z);return new o.Z(o.y.number(b[0]/w,_[0]/M,j)/this.worldSize,o.y.number(P,R,j)/this.worldSize)}coordinatePoint(l,f=0,b=this.pixelMatrix){const _=[l.x*this.worldSize,l.y*this.worldSize,f,1];return o.af(_,_,b),new o.P(_[0]/_[3],_[1]/_[3])}getBounds(){const l=Math.max(0,this.height/2-this.getHorizon());return new Ae().extend(this.pointLocation(new o.P(0,l))).extend(this.pointLocation(new o.P(this.width,l))).extend(this.pointLocation(new o.P(this.width,this.height))).extend(this.pointLocation(new o.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Ae([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(l){l?(this.lngRange=[l.getWest(),l.getEast()],this.latRange=[l.getSouth(),l.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,Hf])}calculateTileMatrix(l){const f=l.canonical,b=this.worldSize/this.zoomScale(f.z),_=f.x+Math.pow(2,f.z)*l.wrap,w=o.an(new Float64Array(16));return o.J(w,w,[_*b,f.y*b,0]),o.K(w,w,[b/o.X,b/o.X,1]),w}calculatePosMatrix(l,f=!1){const b=l.key,_=f?this._alignedPosMatrixCache:this._posMatrixCache;if(_[b])return _[b];const w=this.calculateTileMatrix(l);return o.L(w,f?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,w),_[b]=new Float32Array(w),_[b]}calculateFogMatrix(l){const f=l.key,b=this._fogMatrixCache;if(b[f])return b[f];const _=this.calculateTileMatrix(l);return o.L(_,this.fogMatrix,_),b[f]=new Float32Array(_),b[f]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(l,f){f=o.ac(+f,this.minZoom,this.maxZoom);const b={center:new o.N(l.lng,l.lat),zoom:f};let _=this.lngRange;!this._renderWorldCopies&&_===null&&(_=[-179.9999999999,179.9999999999]);const w=this.tileSize*this.zoomScale(b.zoom);let M=0,P=w,R=0,z=w,$=0,j=0;const{x:X,y:ee}=this.size;if(this.latRange){const ie=this.latRange;M=o.Q(ie[1])*w,P=o.Q(ie[0])*w,P-M<ee&&($=ee/(P-M))}_&&(R=o.b3(o.O(_[0])*w,0,w),z=o.b3(o.O(_[1])*w,0,w),z<R&&(z+=w),z-R<X&&(j=X/(z-R)));const{x:te,y:se}=this.project.call({worldSize:w},l);let le,de;const pe=Math.max(j||0,$||0);if(pe){const ie=new o.P(j?(z+R)/2:te,$?(P+M)/2:se);return b.center=this.unproject.call({worldSize:w},ie).wrap(),b.zoom+=this.scaleZoom(pe),b}if(this.latRange){const ie=ee/2;se-ie<M&&(de=M+ie),se+ie>P&&(de=P-ie)}if(_){const ie=(R+z)/2;let _e=te;this._renderWorldCopies&&(_e=o.b3(te,ie-w/2,ie+w/2));const ve=X/2;_e-ve<R&&(le=R+ve),_e+ve>z&&(le=z-ve)}if(le!==void 0||de!==void 0){const ie=new o.P(le??te,de??se);b.center=this.unproject.call({worldSize:w},ie).wrap()}return b}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const l=this._unmodified,{center:f,zoom:b}=this.getConstrained(this.center,this.zoom);this.center=f,this.zoom=b,this._unmodified=l,this._constraining=!1}_calcMatrices(){if(!this.height)return;const l=this.centerOffset,f=this.point.x,b=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=o.b5(1,this.center.lat)*this.worldSize;let _=o.an(new Float64Array(16));o.K(_,_,[this.width/2,-this.height/2,1]),o.J(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=o.an(new Float64Array(16)),o.K(_,_,[1,-1,1]),o.J(_,_,[-1,-1,0]),o.K(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_;const w=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),M=Math.min(this.elevation,this.minElevationForCurrentTile),P=w-M*this._pixelPerMeter/Math.cos(this._pitch),R=M<0?P:w,z=Math.PI/2+this._pitch,$=this._fov*(.5+l.y/this.height),j=Math.sin($)*R/Math.sin(o.ac(Math.PI-z-$,.01,Math.PI-.01)),X=this.getHorizon(),ee=2*Math.atan(X/this.cameraToCenterDistance)*(.5+l.y/(2*X)),te=Math.sin(ee)*R/Math.sin(o.ac(Math.PI-z-ee,.01,Math.PI-.01)),se=Math.min(j,te);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*se+R),this.nearZ=this.height/50,_=new Float64Array(16),o.b6(_,this._fov,this.width/this.height,this.nearZ,this.farZ),_[8]=2*-l.x/this.width,_[9]=2*l.y/this.height,this.projectionMatrix=o.ae(_),o.K(_,_,[1,-1,1]),o.J(_,_,[0,0,-this.cameraToCenterDistance]),o.b7(_,_,this._pitch),o.ad(_,_,this.angle),o.J(_,_,[-f,-b,0]),this.mercatorMatrix=o.K([],_,[this.worldSize,this.worldSize,this.worldSize]),o.K(_,_,[1,1,this._pixelPerMeter]),this.pixelMatrix=o.L(new Float64Array(16),this.labelPlaneMatrix,_),o.J(_,_,[0,0,-this.elevation]),this.modelViewProjectionMatrix=_,this.invModelViewProjectionMatrix=o.as([],_),this.fogMatrix=new Float64Array(16),o.b6(this.fogMatrix,this._fov,this.width/this.height,w,this.farZ),this.fogMatrix[8]=2*-l.x/this.width,this.fogMatrix[9]=2*l.y/this.height,o.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),o.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),o.b7(this.fogMatrix,this.fogMatrix,this._pitch),o.ad(this.fogMatrix,this.fogMatrix,this.angle),o.J(this.fogMatrix,this.fogMatrix,[-f,-b,0]),o.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),o.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=o.L(new Float64Array(16),this.labelPlaneMatrix,_);const le=this.width%2/2,de=this.height%2/2,pe=Math.cos(this.angle),ie=Math.sin(this.angle),_e=f-Math.round(f)+pe*le+ie*de,ve=b-Math.round(b)+pe*de+ie*le,Ce=new Float64Array(_);if(o.J(Ce,Ce,[_e>.5?_e-1:_e,ve>.5?ve-1:ve,0]),this.alignedModelViewProjectionMatrix=Ce,_=o.as(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const l=this.pointCoordinate(new o.P(0,0)),f=[l.x*this.worldSize,l.y*this.worldSize,0,1];return o.af(f,f,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const l=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new o.P(0,l))}getCameraQueryGeometry(l){const f=this.getCameraPoint();if(l.length===1)return[l[0],f];{let b=f.x,_=f.y,w=f.x,M=f.y;for(const P of l)b=Math.min(b,P.x),_=Math.min(_,P.y),w=Math.max(w,P.x),M=Math.max(M,P.y);return[new o.P(b,_),new o.P(w,_),new o.P(w,M),new o.P(b,M),new o.P(b,_)]}}lngLatToCameraDepth(l,f){const b=this.locationCoordinate(l),_=[b.x*this.worldSize,b.y*this.worldSize,f,1];return o.af(_,_,this.modelViewProjectionMatrix),_[2]/_[3]}}function $c(E,l){let f,b=!1,_=null,w=null;const M=()=>{_=null,b&&(E.apply(w,f),_=setTimeout(M,l),b=!1)};return(...P)=>(b=!0,w=this,f=P,_||M(),_)}class Cu{constructor(l){this._getCurrentHash=()=>{const f=window.location.hash.replace("#","");if(this._hashName){let b;return f.split("&").map(_=>_.split("=")).forEach(_=>{_[0]===this._hashName&&(b=_)}),(b&&b[1]||"").split("/")}return f.split("/")},this._onHashChange=()=>{const f=this._getCurrentHash();if(f.length>=3&&!f.some(b=>isNaN(b))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(f[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+f[2],+f[1]],zoom:+f[0],bearing:b,pitch:+(f[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const f=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,f)},this._removeHash=()=>{const f=this._getCurrentHash();if(f.length===0)return;const b=f.join("/");let _=b;_.split("&").length>0&&(_=_.split("&")[0]),this._hashName&&(_=`${this._hashName}=${b}`);let w=window.location.hash.replace(_,"");w.startsWith("#&")?w=w.slice(0,1)+w.slice(2):w==="#"&&(w="");let M=window.location.href.replace(/(#.+)?$/,w);M=M.replace("&&","&"),window.history.replaceState(window.history.state,null,M)},this._updateHash=$c(this._updateHashUnthrottled,300),this._hashName=l&&encodeURIComponent(l)}addTo(l){return this._map=l,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(l){const f=this._map.getCenter(),b=Math.round(100*this._map.getZoom())/100,_=Math.ceil((b*Math.LN2+Math.log(512/360/.5))/Math.LN10),w=Math.pow(10,_),M=Math.round(f.lng*w)/w,P=Math.round(f.lat*w)/w,R=this._map.getBearing(),z=this._map.getPitch();let $="";if($+=l?`/${M}/${P}/${b}`:`${b}/${P}/${M}`,(R||z)&&($+="/"+Math.round(10*R)/10),z&&($+=`/${Math.round(z)}`),this._hashName){const j=this._hashName;let X=!1;const ee=window.location.hash.slice(1).split("&").map(te=>{const se=te.split("=")[0];return se===j?(X=!0,`${se}=${$}`):te}).filter(te=>te);return X||ee.push(`${j}=${$}`),`#${ee.join("&")}`}return`#${$}`}}const Tu={linearity:.3,easing:o.b8(0,0,.3,1)},Uf=o.e({deceleration:2500,maxSpeed:1400},Tu),n1=o.e({deceleration:20,maxSpeed:1400},Tu),Iy=o.e({deceleration:1e3,maxSpeed:360},Tu),Au=o.e({deceleration:1e3,maxSpeed:90},Tu);class Wf{constructor(l){this._map=l,this.clear()}clear(){this._inertiaBuffer=[]}record(l){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:v.now(),settings:l})}_drainInertiaBuffer(){const l=this._inertiaBuffer,f=v.now();for(;l.length>0&&f-l[0].time>160;)l.shift()}_onMoveEnd(l){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const f={zoom:0,bearing:0,pitch:0,pan:new o.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:w}of this._inertiaBuffer)f.zoom+=w.zoomDelta||0,f.bearing+=w.bearingDelta||0,f.pitch+=w.pitchDelta||0,w.panDelta&&f.pan._add(w.panDelta),w.around&&(f.around=w.around),w.pinchAround&&(f.pinchAround=w.pinchAround);const b=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(f.pan.mag()){const w=Hc(f.pan.mag(),b,o.e({},Uf,l||{}));_.offset=f.pan.mult(w.amount/f.pan.mag()),_.center=this._map.transform.center,jc(_,w)}if(f.zoom){const w=Hc(f.zoom,b,n1);_.zoom=this._map.transform.zoom+w.amount,jc(_,w)}if(f.bearing){const w=Hc(f.bearing,b,Iy);_.bearing=this._map.transform.bearing+o.ac(w.amount,-179,179),jc(_,w)}if(f.pitch){const w=Hc(f.pitch,b,Au);_.pitch=this._map.transform.pitch+w.amount,jc(_,w)}if(_.zoom||_.bearing){const w=f.pinchAround===void 0?f.around:f.pinchAround;_.around=w?this._map.unproject(w):this._map.getCenter()}return this.clear(),o.e(_,{noMoveStart:!0})}}function jc(E,l){(!E.duration||E.duration<l.duration)&&(E.duration=l.duration,E.easing=l.easing)}function Hc(E,l,f){const{maxSpeed:b,linearity:_,deceleration:w}=f,M=o.ac(E*_/(l/1e3),-b,b),P=Math.abs(M)/(w*_);return{easing:f.easing,duration:1e3*P,amount:M*(P/2)}}class Xr extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,f,b,_={}){const w=k.mousePos(f.getCanvas(),b),M=f.unproject(w);super(l,o.e({point:w,lngLat:M,originalEvent:b},_)),this._defaultPrevented=!1,this.target=f}}class Ta extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,f,b){const _=l==="touchend"?b.changedTouches:b.touches,w=k.touchPos(f.getCanvasContainer(),_),M=w.map(R=>f.unproject(R)),P=w.reduce((R,z,$,j)=>R.add(z.div(j.length)),new o.P(0,0));super(l,{points:w,point:P,lngLats:M,lngLat:f.unproject(P),originalEvent:b}),this._defaultPrevented=!1}}class Py extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,f,b){super(l,{originalEvent:b}),this._defaultPrevented=!1}}class Ny{constructor(l,f){this._map=l,this._clickTolerance=f.clickTolerance}reset(){delete this._mousedownPos}wheel(l){return this._firePreventable(new Py(l.type,this._map,l))}mousedown(l,f){return this._mousedownPos=f,this._firePreventable(new Xr(l.type,this._map,l))}mouseup(l){this._map.fire(new Xr(l.type,this._map,l))}click(l,f){this._mousedownPos&&this._mousedownPos.dist(f)>=this._clickTolerance||this._map.fire(new Xr(l.type,this._map,l))}dblclick(l){return this._firePreventable(new Xr(l.type,this._map,l))}mouseover(l){this._map.fire(new Xr(l.type,this._map,l))}mouseout(l){this._map.fire(new Xr(l.type,this._map,l))}touchstart(l){return this._firePreventable(new Ta(l.type,this._map,l))}touchmove(l){this._map.fire(new Ta(l.type,this._map,l))}touchend(l){this._map.fire(new Ta(l.type,this._map,l))}touchcancel(l){this._map.fire(new Ta(l.type,this._map,l))}_firePreventable(l){if(this._map.fire(l),l.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class mr{constructor(l){this._map=l}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(l){this._map.fire(new Xr(l.type,this._map,l))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Xr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(l){this._delayContextMenu?this._contextMenuEvent=l:this._ignoreContextMenu||this._map.fire(new Xr(l.type,this._map,l)),this._map.listens("contextmenu")&&l.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ss{constructor(l){this._map=l}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(l){return this.transform.pointLocation(o.P.convert(l),this._map.terrain)}}class ji{constructor(l,f){this._map=l,this._tr=new Ss(l),this._el=l.getCanvasContainer(),this._container=l.getContainer(),this._clickTolerance=f.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(l,f){this.isEnabled()&&l.shiftKey&&l.button===0&&(k.disableDrag(),this._startPos=this._lastPos=f,this._active=!0)}mousemoveWindow(l,f){if(!this._active)return;const b=f;if(this._lastPos.equals(b)||!this._box&&b.dist(this._startPos)<this._clickTolerance)return;const _=this._startPos;this._lastPos=b,this._box||(this._box=k.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",l));const w=Math.min(_.x,b.x),M=Math.max(_.x,b.x),P=Math.min(_.y,b.y),R=Math.max(_.y,b.y);k.setTransform(this._box,`translate(${w}px,${P}px)`),this._box.style.width=M-w+"px",this._box.style.height=R-P+"px"}mouseupWindow(l,f){if(!this._active||l.button!==0)return;const b=this._startPos,_=f;if(this.reset(),k.suppressClick(),b.x!==_.x||b.y!==_.y)return this._map.fire(new o.k("boxzoomend",{originalEvent:l})),{cameraAnimation:w=>w.fitScreenCoordinates(b,_,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",l)}keydown(l){this._active&&l.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",l))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(k.remove(this._box),this._box=null),k.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(l,f){return this._map.fire(new o.k(l,{originalEvent:f}))}}function Uc(E,l){if(E.length!==l.length)throw new Error(`The number of touches and points are not equal - touches ${E.length}, points ${l.length}`);const f={};for(let b=0;b<E.length;b++)f[E[b].identifier]=l[b];return f}class qf{constructor(l){this.reset(),this.numTouches=l.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(l,f,b){(this.centroid||b.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=l.timeStamp),b.length===this.numTouches&&(this.centroid=function(_){const w=new o.P(0,0);for(const M of _)w._add(M);return w.div(_.length)}(f),this.touches=Uc(b,f)))}touchmove(l,f,b){if(this.aborted||!this.centroid)return;const _=Uc(b,f);for(const w in this.touches){const M=_[w];(!M||M.dist(this.touches[w])>30)&&(this.aborted=!0)}}touchend(l,f,b){if((!this.centroid||l.timeStamp-this.startTime>500)&&(this.aborted=!0),b.length===0){const _=!this.aborted&&this.centroid;if(this.reset(),_)return _}}}class Mu{constructor(l){this.singleTap=new qf(l),this.numTaps=l.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(l,f,b){this.singleTap.touchstart(l,f,b)}touchmove(l,f,b){this.singleTap.touchmove(l,f,b)}touchend(l,f,b){const _=this.singleTap.touchend(l,f,b);if(_){const w=l.timeStamp-this.lastTime<500,M=!this.lastTap||this.lastTap.dist(_)<30;if(w&&M||this.reset(),this.count++,this.lastTime=l.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Al{constructor(l){this._tr=new Ss(l),this._zoomIn=new Mu({numTouches:1,numTaps:2}),this._zoomOut=new Mu({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(l,f,b){this._zoomIn.touchstart(l,f,b),this._zoomOut.touchstart(l,f,b)}touchmove(l,f,b){this._zoomIn.touchmove(l,f,b),this._zoomOut.touchmove(l,f,b)}touchend(l,f,b){const _=this._zoomIn.touchend(l,f,b),w=this._zoomOut.touchend(l,f,b),M=this._tr;return _?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom+1,around:M.unproject(_)},{originalEvent:l})}):w?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom-1,around:M.unproject(w)},{originalEvent:l})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class fo{constructor(l){this._enabled=!!l.enable,this._moveStateManager=l.moveStateManager,this._clickTolerance=l.clickTolerance||1,this._moveFunction=l.move,this._activateOnStart=!!l.activateOnStart,l.assignEvents(this),this.reset()}reset(l){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(l)}_move(...l){const f=this._moveFunction(...l);if(f.bearingDelta||f.pitchDelta||f.around||f.panDelta)return this._active=!0,f}dragStart(l,f){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(l)&&(this._moveStateManager.startMove(l),this._lastPoint=f.length?f[0]:f,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(l,f){if(!this.isEnabled())return;const b=this._lastPoint;if(!b)return;if(l.preventDefault(),!this._moveStateManager.isValidMoveEvent(l))return void this.reset(l);const _=f.length?f[0]:f;return!this._moved&&_.dist(b)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=_,this._move(b,_))}dragEnd(l){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(l)&&(this._moved&&k.suppressClick(),this.reset(l))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const Gf={0:1,2:2};class Du{constructor(l){this._correctEvent=l.checkCorrectEvent}startMove(l){const f=k.mouseButton(l);this._eventButton=f}endMove(l){delete this._eventButton}isValidStartEvent(l){return this._correctEvent(l)}isValidMoveEvent(l){return!function(f,b){const _=Gf[b];return f.buttons===void 0||(f.buttons&_)!==_}(l,this._eventButton)}isValidEndEvent(l){return k.mouseButton(l)===this._eventButton}}class Yf{constructor(){this._firstTouch=void 0}_isOneFingerTouch(l){return l.targetTouches.length===1}_isSameTouchEvent(l){return l.targetTouches[0].identifier===this._firstTouch}startMove(l){this._firstTouch=l.targetTouches[0].identifier}endMove(l){delete this._firstTouch}isValidStartEvent(l){return this._isOneFingerTouch(l)}isValidMoveEvent(l){return this._isOneFingerTouch(l)&&this._isSameTouchEvent(l)}isValidEndEvent(l){return this._isOneFingerTouch(l)&&this._isSameTouchEvent(l)}}const Iu=E=>{E.mousedown=E.dragStart,E.mousemoveWindow=E.dragMove,E.mouseup=E.dragEnd,E.contextmenu=l=>{l.preventDefault()}},Zf=({enable:E,clickTolerance:l,bearingDegreesPerPixelMoved:f=.8})=>{const b=new Du({checkCorrectEvent:_=>k.mouseButton(_)===0&&_.ctrlKey||k.mouseButton(_)===2});return new fo({clickTolerance:l,move:(_,w)=>({bearingDelta:(w.x-_.x)*f}),moveStateManager:b,enable:E,assignEvents:Iu})},Xf=({enable:E,clickTolerance:l,pitchDegreesPerPixelMoved:f=-.5})=>{const b=new Du({checkCorrectEvent:_=>k.mouseButton(_)===0&&_.ctrlKey||k.mouseButton(_)===2});return new fo({clickTolerance:l,move:(_,w)=>({pitchDelta:(w.y-_.y)*f}),moveStateManager:b,enable:E,assignEvents:Iu})};class Aa{constructor(l,f){this._clickTolerance=l.clickTolerance||1,this._map=f,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new o.P(0,0)}_shouldBePrevented(l){return l<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(l,f,b){return this._calculateTransform(l,f,b)}touchmove(l,f,b){if(this._active){if(!this._shouldBePrevented(b.length))return l.preventDefault(),this._calculateTransform(l,f,b);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",l)}}touchend(l,f,b){this._calculateTransform(l,f,b),this._active&&this._shouldBePrevented(b.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(l,f,b){b.length>0&&(this._active=!0);const _=Uc(b,f),w=new o.P(0,0),M=new o.P(0,0);let P=0;for(const z in _){const $=_[z],j=this._touches[z];j&&(w._add($),M._add($.sub(j)),P++,_[z]=$)}if(this._touches=_,this._shouldBePrevented(P)||!M.mag())return;const R=M.div(P);return this._sum._add(R),this._sum.mag()<this._clickTolerance?void 0:{around:w.div(P),panDelta:R}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Pu{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(l,f,b){this._firstTwoTouches||b.length<2||(this._firstTwoTouches=[b[0].identifier,b[1].identifier],this._start([f[0],f[1]]))}touchmove(l,f,b){if(!this._firstTwoTouches)return;l.preventDefault();const[_,w]=this._firstTwoTouches,M=Wc(b,f,_),P=Wc(b,f,w);if(!M||!P)return;const R=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],R,l)}touchend(l,f,b){if(!this._firstTwoTouches)return;const[_,w]=this._firstTwoTouches,M=Wc(b,f,_),P=Wc(b,f,w);M&&P||(this._active&&k.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(l){this._enabled=!0,this._aroundCenter=!!l&&l.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Wc(E,l,f){for(let b=0;b<E.length;b++)if(E[b].identifier===f)return l[b]}function Kf(E,l){return Math.log(E/l)/Math.LN2}class Jf extends Pu{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(l){this._startDistance=this._distance=l[0].dist(l[1])}_move(l,f){const b=this._distance;if(this._distance=l[0].dist(l[1]),this._active||!(Math.abs(Kf(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Kf(this._distance,b),pinchAround:f}}}function Qf(E,l){return 180*E.angleWith(l)/Math.PI}class ep extends Pu{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(l){this._startVector=this._vector=l[0].sub(l[1]),this._minDiameter=l[0].dist(l[1])}_move(l,f,b){const _=this._vector;if(this._vector=l[0].sub(l[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Qf(this._vector,_),pinchAround:f}}_isBelowThreshold(l){this._minDiameter=Math.min(this._minDiameter,l.mag());const f=25/(Math.PI*this._minDiameter)*360,b=Qf(l,this._startVector);return Math.abs(b)<f}}function Nu(E){return Math.abs(E.y)>Math.abs(E.x)}class qc extends Pu{constructor(l){super(),this._currentTouchCount=0,this._map=l}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(l,f,b){super.touchstart(l,f,b),this._currentTouchCount=b.length}_start(l){this._lastPoints=l,Nu(l[0].sub(l[1]))&&(this._valid=!1)}_move(l,f,b){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const _=l[0].sub(this._lastPoints[0]),w=l[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(_,w,b.timeStamp),this._valid?(this._lastPoints=l,this._active=!0,{pitchDelta:(_.y+w.y)/2*-.5}):void 0}gestureBeginsVertically(l,f,b){if(this._valid!==void 0)return this._valid;const _=l.mag()>=2,w=f.mag()>=2;if(!_&&!w)return;if(!_||!w)return this._firstMove===void 0&&(this._firstMove=b),b-this._firstMove<100&&void 0;const M=l.y>0==f.y>0;return Nu(l)&&Nu(f)&&M}}const Ry={panStep:100,bearingStep:15,pitchStep:10};class is{constructor(l){this._tr=new Ss(l);const f=Ry;this._panStep=f.panStep,this._bearingStep=f.bearingStep,this._pitchStep=f.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(l){if(l.altKey||l.ctrlKey||l.metaKey)return;let f=0,b=0,_=0,w=0,M=0;switch(l.keyCode){case 61:case 107:case 171:case 187:f=1;break;case 189:case 109:case 173:f=-1;break;case 37:l.shiftKey?b=-1:(l.preventDefault(),w=-1);break;case 39:l.shiftKey?b=1:(l.preventDefault(),w=1);break;case 38:l.shiftKey?_=1:(l.preventDefault(),M=-1);break;case 40:l.shiftKey?_=-1:(l.preventDefault(),M=1);break;default:return}return this._rotationDisabled&&(b=0,_=0),{cameraAnimation:P=>{const R=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:Xs,zoom:f?Math.round(R.zoom)+f*(l.shiftKey?2:1):R.zoom,bearing:R.bearing+b*this._bearingStep,pitch:R.pitch+_*this._pitchStep,offset:[-w*this._panStep,-M*this._panStep],center:R.center},{originalEvent:l})}}}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 Xs(E){return E*(2-E)}const tp=4.000244140625;class Cs{constructor(l,f){this._onTimeout=b=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(b)},this._map=l,this._tr=new Ss(l),this._triggerRenderFrame=f,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(l){this._defaultZoomRate=l}setWheelZoomRate(l){this._wheelZoomRate=l}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(l){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!l&&l.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(l){return!!this._map.cooperativeGestures.isEnabled()&&!(l.ctrlKey||this._map.cooperativeGestures.isBypassed(l))}wheel(l){if(!this.isEnabled())return;if(this._shouldBePrevented(l))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",l);let f=l.deltaMode===WheelEvent.DOM_DELTA_LINE?40*l.deltaY:l.deltaY;const b=v.now(),_=b-(this._lastWheelEventTime||0);this._lastWheelEventTime=b,f!==0&&f%tp==0?this._type="wheel":f!==0&&Math.abs(f)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=f,this._timeout=setTimeout(this._onTimeout,40,l)):this._type||(this._type=Math.abs(_*f)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,f+=this._lastValue)),l.shiftKey&&f&&(f/=4),this._type&&(this._lastWheelEvent=l,this._delta-=f,this._active||this._start(l)),l.preventDefault()}_start(l){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const f=k.mousePos(this._map.getCanvas(),l),b=this._tr;this._around=f.y>b.transform.height/2-b.transform.getHorizon()?o.N.convert(this._aroundCenter?b.center:b.unproject(f)):o.N.convert(b.center),this._aroundPoint=b.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const l=this._tr.transform;if(this._delta!==0){const R=this._type==="wheel"&&Math.abs(this._delta)>tp?this._wheelZoomRate:this._defaultZoomRate;let z=2/(1+Math.exp(-Math.abs(this._delta*R)));this._delta<0&&z!==0&&(z=1/z);const $=typeof this._targetZoom=="number"?l.zoomScale(this._targetZoom):l.scale;this._targetZoom=Math.min(l.maxZoom,Math.max(l.minZoom,l.scaleZoom($*z))),this._type==="wheel"&&(this._startZoom=l.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const f=typeof this._targetZoom=="number"?this._targetZoom:l.zoom,b=this._startZoom,_=this._easing;let w,M=!1;const P=v.now()-this._lastWheelEventTime;if(this._type==="wheel"&&b&&_&&P){const R=Math.min(P/200,1),z=_(R);w=o.y.number(b,f,z),R<1?this._frameId||(this._frameId=!0):M=!0}else w=f,M=!0;return this._active=!0,M&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!M,zoomDelta:w-l.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(l){let f=o.b9;if(this._prevEase){const b=this._prevEase,_=(v.now()-b.start)/b.duration,w=b.easing(_+.01)-b.easing(_),M=.27/Math.sqrt(w*w+1e-4)*.01,P=Math.sqrt(.0729-M*M);f=o.b8(M,P,.25,1)}return this._prevEase={start:v.now(),duration:l,easing:f},f}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ma{constructor(l,f){this._clickZoom=l,this._tapZoom=f}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 r1{constructor(l){this._tr=new Ss(l),this.reset()}reset(){this._active=!1}dblclick(l,f){return l.preventDefault(),{cameraAnimation:b=>{b.easeTo({duration:300,zoom:this._tr.zoom+(l.shiftKey?-1:1),around:this._tr.unproject(f)},{originalEvent:l})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class i1{constructor(){this._tap=new Mu({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(l,f,b){if(!this._swipePoint)if(this._tapTime){const _=f[0],w=l.timeStamp-this._tapTime<500,M=this._tapPoint.dist(_)<30;w&&M?b.length>0&&(this._swipePoint=_,this._swipeTouch=b[0].identifier):this.reset()}else this._tap.touchstart(l,f,b)}touchmove(l,f,b){if(this._tapTime){if(this._swipePoint){if(b[0].identifier!==this._swipeTouch)return;const _=f[0],w=_.y-this._swipePoint.y;return this._swipePoint=_,l.preventDefault(),this._active=!0,{zoomDelta:w/128}}}else this._tap.touchmove(l,f,b)}touchend(l,f,b){if(this._tapTime)this._swipePoint&&b.length===0&&this.reset();else{const _=this._tap.touchend(l,f,b);_&&(this._tapTime=l.timeStamp,this._tapPoint=_)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Oy{constructor(l,f,b){this._el=l,this._mousePan=f,this._touchPan=b}enable(l){this._inertiaOptions=l||{},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 By{constructor(l,f,b){this._pitchWithRotate=l.pitchWithRotate,this._mouseRotate=f,this._mousePitch=b}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(l,f,b,_){this._el=l,this._touchZoom=f,this._touchRotate=b,this._tapDragZoom=_,this._rotationDisabled=!1,this._enabled=!0}enable(l){this._touchZoom.enable(l),this._rotationDisabled||this._touchRotate.enable(l),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 Ml{constructor(l,f){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=l,this._options=f,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const l=this._map.getCanvasContainer();l.classList.add("maplibregl-cooperative-gestures"),this._container=k.create("div","maplibregl-cooperative-gesture-screen",l);let f=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(f=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const b=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),_=document.createElement("div");_.className="maplibregl-desktop-message",_.textContent=f,this._container.appendChild(_);const w=document.createElement("div");w.className="maplibregl-mobile-message",w.textContent=b,this._container.appendChild(w),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(k.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(l){return l[this._bypassKey]}notifyGestureBlocked(l,f){this._enabled&&(this._map.fire(new o.k("cooperativegestureprevented",{gestureType:l,originalEvent:f})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const ss=E=>E.zoom||E.drag||E.pitch||E.rotate;class gt extends o.k{}function Ru(E){return E.panDelta&&E.panDelta.mag()||E.zoomDelta||E.bearingDelta||E.pitchDelta}class rp{constructor(l,f){this.handleWindowEvent=_=>{this.handleEvent(_,`${_.type}Window`)},this.handleEvent=(_,w)=>{if(_.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const M=_.type==="renderFrame"?void 0:_,P={needsRenderFrame:!1},R={},z={},$=_.touches,j=$?this._getMapTouches($):void 0,X=j?k.touchPos(this._map.getCanvas(),j):k.mousePos(this._map.getCanvas(),_);for(const{handlerName:se,handler:le,allowed:de}of this._handlers){if(!le.isEnabled())continue;let pe;this._blockedByActive(z,de,se)?le.reset():le[w||_.type]&&(pe=le[w||_.type](_,X,j),this.mergeHandlerResult(P,R,pe,se,M),pe&&pe.needsRenderFrame&&this._triggerRenderFrame()),(pe||le.isActive())&&(z[se]=le)}const ee={};for(const se in this._previousActiveHandlers)z[se]||(ee[se]=M);this._previousActiveHandlers=z,(Object.keys(ee).length||Ru(P))&&(this._changes.push([P,R,ee]),this._triggerRenderFrame()),(Object.keys(z).length||Ru(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:te}=P;te&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],te(this._map))},this._map=l,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Wf(l),this._bearingSnap=f.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(f);const b=this._el;this._listeners=[[b,"touchstart",{passive:!0}],[b,"touchmove",{passive:!1}],[b,"touchend",void 0],[b,"touchcancel",void 0],[b,"mousedown",void 0],[b,"mousemove",void 0],[b,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[b,"mouseover",void 0],[b,"mouseout",void 0],[b,"dblclick",void 0],[b,"click",void 0],[b,"keydown",{capture:!1}],[b,"keyup",void 0],[b,"wheel",{passive:!1}],[b,"contextmenu",void 0],[window,"blur",void 0]];for(const[_,w,M]of this._listeners)k.addEventListener(_,w,_===document?this.handleWindowEvent:this.handleEvent,M)}destroy(){for(const[l,f,b]of this._listeners)k.removeEventListener(l,f,l===document?this.handleWindowEvent:this.handleEvent,b)}_addDefaultHandlers(l){const f=this._map,b=f.getCanvasContainer();this._add("mapEvent",new Ny(f,l));const _=f.boxZoom=new ji(f,l);this._add("boxZoom",_),l.interactive&&l.boxZoom&&_.enable();const w=f.cooperativeGestures=new Ml(f,l.cooperativeGestures);this._add("cooperativeGestures",w),l.cooperativeGestures&&w.enable();const M=new Al(f),P=new r1(f);f.doubleClickZoom=new Ma(P,M),this._add("tapZoom",M),this._add("clickZoom",P),l.interactive&&l.doubleClickZoom&&f.doubleClickZoom.enable();const R=new i1;this._add("tapDragZoom",R);const z=f.touchPitch=new qc(f);this._add("touchPitch",z),l.interactive&&l.touchPitch&&f.touchPitch.enable(l.touchPitch);const $=Zf(l),j=Xf(l);f.dragRotate=new By(l,$,j),this._add("mouseRotate",$,["mousePitch"]),this._add("mousePitch",j,["mouseRotate"]),l.interactive&&l.dragRotate&&f.dragRotate.enable();const X=(({enable:pe,clickTolerance:ie})=>{const _e=new Du({checkCorrectEvent:ve=>k.mouseButton(ve)===0&&!ve.ctrlKey});return new fo({clickTolerance:ie,move:(ve,Ce)=>({around:Ce,panDelta:Ce.sub(ve)}),activateOnStart:!0,moveStateManager:_e,enable:pe,assignEvents:Iu})})(l),ee=new Aa(l,f);f.dragPan=new Oy(b,X,ee),this._add("mousePan",X),this._add("touchPan",ee,["touchZoom","touchRotate"]),l.interactive&&l.dragPan&&f.dragPan.enable(l.dragPan);const te=new ep,se=new Jf;f.touchZoomRotate=new np(b,se,te,R),this._add("touchRotate",te,["touchPan","touchZoom"]),this._add("touchZoom",se,["touchPan","touchRotate"]),l.interactive&&l.touchZoomRotate&&f.touchZoomRotate.enable(l.touchZoomRotate);const le=f.scrollZoom=new Cs(f,()=>this._triggerRenderFrame());this._add("scrollZoom",le,["mousePan"]),l.interactive&&l.scrollZoom&&f.scrollZoom.enable(l.scrollZoom);const de=f.keyboard=new is(f);this._add("keyboard",de),l.interactive&&l.keyboard&&f.keyboard.enable(),this._add("blockableMapEvent",new mr(f))}_add(l,f,b){this._handlers.push({handlerName:l,handler:f,allowed:b}),this._handlersById[l]=f}stop(l){if(!this._updatingCamera){for(const{handler:f}of this._handlers)f.reset();this._inertia.clear(),this._fireEvents({},{},l),this._changes=[]}}isActive(){for(const{handler:l}of this._handlers)if(l.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!ss(this._eventsInProgress)||this.isZooming()}_blockedByActive(l,f,b){for(const _ in l)if(_!==b&&(!f||f.indexOf(_)<0))return!0;return!1}_getMapTouches(l){const f=[];for(const b of l)this._el.contains(b.target)&&f.push(b);return f}mergeHandlerResult(l,f,b,_,w){if(!b)return;o.e(l,b);const M={handlerName:_,originalEvent:b.originalEvent||w};b.zoomDelta!==void 0&&(f.zoom=M),b.panDelta!==void 0&&(f.drag=M),b.pitchDelta!==void 0&&(f.pitch=M),b.bearingDelta!==void 0&&(f.rotate=M)}_applyChanges(){const l={},f={},b={};for(const[_,w,M]of this._changes)_.panDelta&&(l.panDelta=(l.panDelta||new o.P(0,0))._add(_.panDelta)),_.zoomDelta&&(l.zoomDelta=(l.zoomDelta||0)+_.zoomDelta),_.bearingDelta&&(l.bearingDelta=(l.bearingDelta||0)+_.bearingDelta),_.pitchDelta&&(l.pitchDelta=(l.pitchDelta||0)+_.pitchDelta),_.around!==void 0&&(l.around=_.around),_.pinchAround!==void 0&&(l.pinchAround=_.pinchAround),_.noInertia&&(l.noInertia=_.noInertia),o.e(f,w),o.e(b,M);this._updateMapTransform(l,f,b),this._changes=[]}_updateMapTransform(l,f,b){const _=this._map,w=_._getTransformForUpdate(),M=_.terrain;if(!(Ru(l)||M&&this._terrainMovement))return this._fireEvents(f,b,!0);let{panDelta:P,zoomDelta:R,bearingDelta:z,pitchDelta:$,around:j,pinchAround:X}=l;X!==void 0&&(j=X),_._stop(!0),j=j||_.transform.centerPoint;const ee=w.pointLocation(P?j.sub(P):j);z&&(w.bearing+=z),$&&(w.pitch+=$),R&&(w.zoom+=R),M?this._terrainMovement||!f.drag&&!f.zoom?f.drag&&this._terrainMovement?w.center=w.pointLocation(w.centerPoint.sub(P)):w.setLocationAtPoint(ee,j):(this._terrainMovement=!0,this._map._elevationFreeze=!0,w.setLocationAtPoint(ee,j)):w.setLocationAtPoint(ee,j),_._applyUpdatedTransform(w),this._map._update(),l.noInertia||this._inertia.record(l),this._fireEvents(f,b,!0)}_fireEvents(l,f,b){const _=ss(this._eventsInProgress),w=ss(l),M={};for(const j in l){const{originalEvent:X}=l[j];this._eventsInProgress[j]||(M[`${j}start`]=X),this._eventsInProgress[j]=l[j]}!_&&w&&this._fireEvent("movestart",w.originalEvent);for(const j in M)this._fireEvent(j,M[j]);w&&this._fireEvent("move",w.originalEvent);for(const j in l){const{originalEvent:X}=l[j];this._fireEvent(j,X)}const P={};let R;for(const j in this._eventsInProgress){const{handlerName:X,originalEvent:ee}=this._eventsInProgress[j];this._handlersById[X].isActive()||(delete this._eventsInProgress[j],R=f[X]||ee,P[`${j}end`]=R)}for(const j in P)this._fireEvent(j,P[j]);const z=ss(this._eventsInProgress),$=(_||w)&&!z;if($&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const j=this._map._getTransformForUpdate();j.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(j)}if(b&&$){this._updatingCamera=!0;const j=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),X=ee=>ee!==0&&-this._bearingSnap<ee&&ee<this._bearingSnap;!j||!j.essential&&v.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:R})),X(this._map.getBearing())&&this._map.resetNorth()):(X(j.bearing||this._map.getBearing())&&(j.bearing=0),j.freezeElevation=!0,this._map.easeTo(j,{originalEvent:R})),this._updatingCamera=!1}}_fireEvent(l,f){this._map.fire(new o.k(l,f?{originalEvent:f}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(l=>{delete this._frameId,this.handleEvent(new gt("renderFrame",{timeStamp:l})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Vy extends o.E{constructor(l,f){super(),this._renderFrameCallback=()=>{const b=Math.min((v.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(b)),b<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=l,this._bearingSnap=f.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.N(this.transform.center.lng,this.transform.center.lat)}setCenter(l,f){return this.jumpTo({center:l},f)}panBy(l,f,b){return l=o.P.convert(l).mult(-1),this.panTo(this.transform.center,o.e({offset:l},f),b)}panTo(l,f,b){return this.easeTo(o.e({center:l},f),b)}getZoom(){return this.transform.zoom}setZoom(l,f){return this.jumpTo({zoom:l},f),this}zoomTo(l,f,b){return this.easeTo(o.e({zoom:l},f),b)}zoomIn(l,f){return this.zoomTo(this.getZoom()+1,l,f),this}zoomOut(l,f){return this.zoomTo(this.getZoom()-1,l,f),this}getBearing(){return this.transform.bearing}setBearing(l,f){return this.jumpTo({bearing:l},f),this}getPadding(){return this.transform.padding}setPadding(l,f){return this.jumpTo({padding:l},f),this}rotateTo(l,f,b){return this.easeTo(o.e({bearing:l},f),b)}resetNorth(l,f){return this.rotateTo(0,o.e({duration:1e3},l),f),this}resetNorthPitch(l,f){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},l),f),this}snapToNorth(l,f){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(l,f):this}getPitch(){return this.transform.pitch}setPitch(l,f){return this.jumpTo({pitch:l},f),this}cameraForBounds(l,f){l=Ae.convert(l).adjustAntiMeridian();const b=f&&f.bearing||0;return this._cameraForBoxAndBearing(l.getNorthWest(),l.getSouthEast(),b,f)}_cameraForBoxAndBearing(l,f,b,_){const w={top:0,bottom:0,right:0,left:0};if(typeof(_=o.e({padding:w,offset:[0,0],maxZoom:this.transform.maxZoom},_)).padding=="number"){const rt=_.padding;_.padding={top:rt,bottom:rt,right:rt,left:rt}}_.padding=o.e(w,_.padding);const M=this.transform,P=M.padding,R=new Ae(l,f),z=M.project(R.getNorthWest()),$=M.project(R.getNorthEast()),j=M.project(R.getSouthEast()),X=M.project(R.getSouthWest()),ee=o.ba(-b),te=z.rotate(ee),se=$.rotate(ee),le=j.rotate(ee),de=X.rotate(ee),pe=new o.P(Math.max(te.x,se.x,de.x,le.x),Math.max(te.y,se.y,de.y,le.y)),ie=new o.P(Math.min(te.x,se.x,de.x,le.x),Math.min(te.y,se.y,de.y,le.y)),_e=pe.sub(ie),ve=(M.width-(P.left+P.right+_.padding.left+_.padding.right))/_e.x,Ce=(M.height-(P.top+P.bottom+_.padding.top+_.padding.bottom))/_e.y;if(Ce<0||ve<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const ze=Math.min(M.scaleZoom(M.scale*Math.min(ve,Ce)),_.maxZoom),Ze=o.P.convert(_.offset),ot=new o.P((_.padding.left-_.padding.right)/2,(_.padding.top-_.padding.bottom)/2).rotate(o.ba(b)),ut=Ze.add(ot).mult(M.scale/M.zoomScale(ze));return{center:M.unproject(z.add(j).div(2).sub(ut)),zoom:ze,bearing:b}}fitBounds(l,f,b){return this._fitInternal(this.cameraForBounds(l,f),f,b)}fitScreenCoordinates(l,f,b,_,w){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(l)),this.transform.pointLocation(o.P.convert(f)),b,_),_,w)}_fitInternal(l,f,b){return l?(delete(f=o.e(l,f)).padding,f.linear?this.easeTo(f,b):this.flyTo(f,b)):this}jumpTo(l,f){this.stop();const b=this._getTransformForUpdate();let _=!1,w=!1,M=!1;return"zoom"in l&&b.zoom!==+l.zoom&&(_=!0,b.zoom=+l.zoom),l.center!==void 0&&(b.center=o.N.convert(l.center)),"bearing"in l&&b.bearing!==+l.bearing&&(w=!0,b.bearing=+l.bearing),"pitch"in l&&b.pitch!==+l.pitch&&(M=!0,b.pitch=+l.pitch),l.padding==null||b.isPaddingEqual(l.padding)||(b.padding=l.padding),this._applyUpdatedTransform(b),this.fire(new o.k("movestart",f)).fire(new o.k("move",f)),_&&this.fire(new o.k("zoomstart",f)).fire(new o.k("zoom",f)).fire(new o.k("zoomend",f)),w&&this.fire(new o.k("rotatestart",f)).fire(new o.k("rotate",f)).fire(new o.k("rotateend",f)),M&&this.fire(new o.k("pitchstart",f)).fire(new o.k("pitch",f)).fire(new o.k("pitchend",f)),this.fire(new o.k("moveend",f))}calculateCameraOptionsFromTo(l,f,b,_=0){const w=o.Z.fromLngLat(l,f),M=o.Z.fromLngLat(b,_),P=M.x-w.x,R=M.y-w.y,z=M.z-w.z,$=Math.hypot(P,R,z);if($===0)throw new Error("Can't calculate camera options with same From and To");const j=Math.hypot(P,R),X=this.transform.scaleZoom(this.transform.cameraToCenterDistance/$/this.transform.tileSize),ee=180*Math.atan2(P,-R)/Math.PI;let te=180*Math.acos(j/$)/Math.PI;return te=z<0?90-te:90+te,{center:M.toLngLat(),zoom:X,pitch:te,bearing:ee}}easeTo(l,f){var b;this._stop(!1,l.easeId),((l=o.e({offset:[0,0],duration:500,easing:o.b9},l)).animate===!1||!l.essential&&v.prefersReducedMotion)&&(l.duration=0);const _=this._getTransformForUpdate(),w=_.zoom,M=_.bearing,P=_.pitch,R=_.padding,z="bearing"in l?this._normalizeBearing(l.bearing,M):M,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,X=o.P.convert(l.offset);let ee=_.centerPoint.add(X);const te=_.pointLocation(ee),{center:se,zoom:le}=_.getConstrained(o.N.convert(l.center||te),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(se,_);const de=_.project(te),pe=_.project(se).sub(de),ie=_.zoomScale(le-w);let _e,ve;l.around&&(_e=o.N.convert(l.around),ve=_.locationPoint(_e));const Ce={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||le!==w,this._rotating=this._rotating||M!==z,this._pitching=this._pitching||$!==P,this._padding=!_.isPaddingEqual(j),this._easeId=l.easeId,this._prepareEase(f,l.noMoveStart,Ce),this.terrain&&this._prepareElevation(se),this._ease(ze=>{if(this._zooming&&(_.zoom=o.y.number(w,le,ze)),this._rotating&&(_.bearing=o.y.number(M,z,ze)),this._pitching&&(_.pitch=o.y.number(P,$,ze)),this._padding&&(_.interpolatePadding(R,j,ze),ee=_.centerPoint.add(X)),this.terrain&&!l.freezeElevation&&this._updateElevation(ze),_e)_.setLocationAtPoint(_e,ve);else{const Ze=_.zoomScale(_.zoom-w),ot=le>w?Math.min(2,ie):Math.max(.5,ie),ut=Math.pow(ot,1-ze),rt=_.unproject(de.add(pe.mult(ze*ut)).mult(Ze));_.setLocationAtPoint(_.renderWorldCopies?rt.wrap():rt,ee)}this._applyUpdatedTransform(_),this._fireMoveEvents(f)},ze=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(f,ze)},l),this}_prepareEase(l,f,b={}){this._moving=!0,f||b.moving||this.fire(new o.k("movestart",l)),this._zooming&&!b.zooming&&this.fire(new o.k("zoomstart",l)),this._rotating&&!b.rotating&&this.fire(new o.k("rotatestart",l)),this._pitching&&!b.pitching&&this.fire(new o.k("pitchstart",l))}_prepareElevation(l){this._elevationCenter=l,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(l,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(l){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const f=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(l<1&&f!==this._elevationTarget){const b=this._elevationTarget-this._elevationStart;this._elevationStart+=l*(b-(f-(b*l+this._elevationStart))/(1-l)),this._elevationTarget=f}this.transform.elevation=o.y.number(this._elevationStart,this._elevationTarget,l)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(l){const f=l.getCameraPosition(),b=this.terrain.getElevationForLngLatZoom(f.lngLat,l.zoom);if(f.altitude<b){const _=this.calculateCameraOptionsFromTo(f.lngLat,b,l.center,l.elevation);return{pitch:_.pitch,zoom:_.zoom}}return{}}_applyUpdatedTransform(l){const f=[];if(this.terrain&&f.push(_=>this._elevateCameraIfInsideTerrain(_)),this.transformCameraUpdate&&f.push(_=>this.transformCameraUpdate(_)),!f.length)return;const b=l.clone();for(const _ of f){const w=b.clone(),{center:M,zoom:P,pitch:R,bearing:z,elevation:$}=_(w);M&&(w.center=M),P!==void 0&&(w.zoom=P),R!==void 0&&(w.pitch=R),z!==void 0&&(w.bearing=z),$!==void 0&&(w.elevation=$),b.apply(w)}this.transform.apply(b)}_fireMoveEvents(l){this.fire(new o.k("move",l)),this._zooming&&this.fire(new o.k("zoom",l)),this._rotating&&this.fire(new o.k("rotate",l)),this._pitching&&this.fire(new o.k("pitch",l))}_afterEase(l,f){if(this._easeId&&f&&this._easeId===f)return;delete this._easeId;const b=this._zooming,_=this._rotating,w=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,b&&this.fire(new o.k("zoomend",l)),_&&this.fire(new o.k("rotateend",l)),w&&this.fire(new o.k("pitchend",l)),this.fire(new o.k("moveend",l))}flyTo(l,f){var b;if(!l.essential&&v.prefersReducedMotion){const lt=o.M(l,["center","zoom","bearing","pitch","around"]);return this.jumpTo(lt,f)}this.stop(),l=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b9},l);const _=this._getTransformForUpdate(),w=_.zoom,M=_.bearing,P=_.pitch,R=_.padding,z="bearing"in l?this._normalizeBearing(l.bearing,M):M,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,X=o.P.convert(l.offset);let ee=_.centerPoint.add(X);const te=_.pointLocation(ee),{center:se,zoom:le}=_.getConstrained(o.N.convert(l.center||te),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(se,_);const de=_.zoomScale(le-w),pe=_.project(te),ie=_.project(se).sub(pe);let _e=l.curve;const ve=Math.max(_.width,_.height),Ce=ve/de,ze=ie.mag();if("minZoom"in l){const lt=o.ac(Math.min(l.minZoom,w,le),_.minZoom,_.maxZoom),Ft=ve/_.zoomScale(lt-w);_e=Math.sqrt(Ft/ze*2)}const Ze=_e*_e;function ot(lt){const Ft=(Ce*Ce-ve*ve+(lt?-1:1)*Ze*Ze*ze*ze)/(2*(lt?Ce:ve)*Ze*ze);return Math.log(Math.sqrt(Ft*Ft+1)-Ft)}function ut(lt){return(Math.exp(lt)-Math.exp(-lt))/2}function rt(lt){return(Math.exp(lt)+Math.exp(-lt))/2}const nt=ot(!1);let vt=function(lt){return rt(nt)/rt(nt+_e*lt)},Ht=function(lt){return ve*((rt(nt)*(ut(Ft=nt+_e*lt)/rt(Ft))-ut(nt))/Ze)/ze;var Ft},it=(ot(!0)-nt)/_e;if(Math.abs(ze)<1e-6||!isFinite(it)){if(Math.abs(ve-Ce)<1e-6)return this.easeTo(l,f);const lt=Ce<ve?-1:1;it=Math.abs(Math.log(Ce/ve))/_e,Ht=()=>0,vt=Ft=>Math.exp(lt*_e*Ft)}return l.duration="duration"in l?+l.duration:1e3*it/("screenSpeed"in l?+l.screenSpeed/_e:+l.speed),l.maxDuration&&l.duration>l.maxDuration&&(l.duration=0),this._zooming=!0,this._rotating=M!==z,this._pitching=$!==P,this._padding=!_.isPaddingEqual(j),this._prepareEase(f,!1),this.terrain&&this._prepareElevation(se),this._ease(lt=>{const Ft=lt*it,Xn=1/vt(Ft);_.zoom=lt===1?le:w+_.scaleZoom(Xn),this._rotating&&(_.bearing=o.y.number(M,z,lt)),this._pitching&&(_.pitch=o.y.number(P,$,lt)),this._padding&&(_.interpolatePadding(R,j,lt),ee=_.centerPoint.add(X)),this.terrain&&!l.freezeElevation&&this._updateElevation(lt);const Jt=lt===1?se:_.unproject(pe.add(ie.mult(Ht(Ft))).mult(Xn));_.setLocationAtPoint(_.renderWorldCopies?Jt.wrap():Jt,ee),this._applyUpdatedTransform(_),this._fireMoveEvents(f)},()=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(f)},l),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(l,f){var b;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const _=this._onEaseEnd;delete this._onEaseEnd,_.call(this,f)}return l||(b=this.handlers)===null||b===void 0||b.stop(!1),this}_ease(l,f,b){b.animate===!1||b.duration===0?(l(1),f()):(this._easeStart=v.now(),this._easeOptions=b,this._onEaseFrame=l,this._onEaseEnd=f,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(l,f){l=o.b3(l,-180,180);const b=Math.abs(l-f);return Math.abs(l-360-f)<b&&(l-=360),Math.abs(l+360-f)<b&&(l+=360),l}_normalizeCenter(l,f){if(!f.renderWorldCopies||f.lngRange)return;const b=l.lng-f.center.lng;l.lng+=b>180?-360:b<-180?360:0}queryTerrainElevation(l){return this.terrain?this.terrain.getElevationForLngLatZoom(o.N.convert(l),this.transform.tileZoom)-this.transform.elevation:null}}const Dl={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Il{constructor(l=Dl){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=f=>{!f||f.sourceDataType!=="metadata"&&f.sourceDataType!=="visibility"&&f.dataType!=="style"&&f.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=l}getDefaultPosition(){return"bottom-right"}onAdd(l){return this._map=l,this._compact=this.options.compact,this._container=k.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=k.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=k.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(){k.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(l,f){const b=this._map._getUIString(`AttributionControl.${f}`);l.title=b,l.setAttribute("aria-label",b)}_updateAttributions(){if(!this._map.style)return;let l=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?l=l.concat(this.options.customAttribution.map(_=>typeof _!="string"?"":_)):typeof this.options.customAttribution=="string"&&l.push(this.options.customAttribution)),this._map.style.stylesheet){const _=this._map.style.stylesheet;this.styleOwner=_.owner,this.styleId=_.id}const f=this._map.style.sourceCaches;for(const _ in f){const w=f[_];if(w.used||w.usedForTerrain){const M=w.getSource();M.attribution&&l.indexOf(M.attribution)<0&&l.push(M.attribution)}}l=l.filter(_=>String(_).trim()),l.sort((_,w)=>_.length-w.length),l=l.filter((_,w)=>{for(let M=w+1;M<l.length;M++)if(l[M].indexOf(_)>=0)return!1;return!0});const b=l.join(" | ");b!==this._attribHTML&&(this._attribHTML=b,l.length?(this._innerContainer.innerHTML=b,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class ip{constructor(l={}){this._updateCompact=()=>{const f=this._container.children;if(f.length){const b=f[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&b.classList.add("maplibregl-compact"):b.classList.remove("maplibregl-compact")}},this.options=l}getDefaultPosition(){return"bottom-left"}onAdd(l){this._map=l,this._compact=this.options&&this.options.compact,this._container=k.create("div","maplibregl-ctrl");const f=k.create("a","maplibregl-ctrl-logo");return f.target="_blank",f.rel="noopener nofollow",f.href="https://maplibre.org/",f.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),f.setAttribute("rel","noopener nofollow"),this._container.appendChild(f),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){k.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class hn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(l){const f=++this._id;return this._queue.push({callback:l,id:f,cancelled:!1}),f}remove(l){const f=this._currentlyRunning,b=f?this._queue.concat(f):this._queue;for(const _ of b)if(_.id===l)return void(_.cancelled=!0)}run(l=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const f=this._currentlyRunning=this._queue;this._queue=[];for(const b of f)if(!b.cancelled&&(b.callback(l),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var sp=o.Y([{name:"a_pos3d",type:"Int16",components:3}]);class s1 extends o.E{constructor(l){super(),this.sourceCache=l,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,l.usedForTerrain=!0,l.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(l,f){this.sourceCache.update(l,f),this._renderableTilesKeys=[];const b={};for(const _ of l.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:f}))b[_.key]=!0,this._renderableTilesKeys.push(_.key),this._tiles[_.key]||(_.posMatrix=new Float64Array(16),o.aP(_.posMatrix,0,o.X,0,o.X,0,1),this._tiles[_.key]=new Vi(_,this.tileSize));for(const _ in this._tiles)b[_]||delete this._tiles[_]}freeRtt(l){for(const f in this._tiles){const b=this._tiles[f];(!l||b.tileID.equals(l)||b.tileID.isChildOf(l)||l.isChildOf(b.tileID))&&(b.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(l=>this.getTileByID(l))}getTileByID(l){return this._tiles[l]}getTerrainCoords(l){const f={};for(const b of this._renderableTilesKeys){const _=this._tiles[b].tileID;if(_.canonical.equals(l.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16),o.aP(w.posMatrix,0,o.X,0,o.X,0,1),f[b]=w}else if(_.canonical.isChildOf(l.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const M=_.canonical.z-l.canonical.z,P=_.canonical.x-(_.canonical.x>>M<<M),R=_.canonical.y-(_.canonical.y>>M<<M),z=o.X>>M;o.aP(w.posMatrix,0,z,0,z,0,1),o.J(w.posMatrix,w.posMatrix,[-P*z,-R*z,0]),f[b]=w}else if(l.canonical.isChildOf(_.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const M=l.canonical.z-_.canonical.z,P=l.canonical.x-(l.canonical.x>>M<<M),R=l.canonical.y-(l.canonical.y>>M<<M),z=o.X>>M;o.aP(w.posMatrix,0,o.X,0,o.X,0,1),o.J(w.posMatrix,w.posMatrix,[P*z,R*z,0]),o.K(w.posMatrix,w.posMatrix,[1/2**M,1/2**M,0]),f[b]=w}}return f}getSourceTile(l,f){const b=this.sourceCache._source;let _=l.overscaledZ-this.deltaZoom;if(_>b.maxzoom&&(_=b.maxzoom),_<b.minzoom)return null;this._sourceTileCache[l.key]||(this._sourceTileCache[l.key]=l.scaledTo(_).key);let w=this.sourceCache.getTileByID(this._sourceTileCache[l.key]);if((!w||!w.dem)&&f)for(;_>=b.minzoom&&(!w||!w.dem);)w=this.sourceCache.getTileByID(l.scaledTo(_--).key);return w}tilesAfterTime(l=Date.now()){return Object.values(this._tiles).filter(f=>f.timeAdded>=l)}}class op{constructor(l,f,b){this.painter=l,this.sourceCache=new s1(f),this.options=b,this.exaggeration=typeof b.exaggeration=="number"?b.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(l,f,b,_=o.X){var w;if(!(f>=0&&f<_&&b>=0&&b<_))return 0;const M=this.getTerrainData(l),P=(w=M.tile)===null||w===void 0?void 0:w.dem;if(!P)return 0;const R=function(te,se,le){var de=se[0],pe=se[1];return te[0]=le[0]*de+le[4]*pe+le[12],te[1]=le[1]*de+le[5]*pe+le[13],te}([],[f/_*o.X,b/_*o.X],M.u_terrain_matrix),z=[R[0]*P.dim,R[1]*P.dim],$=Math.floor(z[0]),j=Math.floor(z[1]),X=z[0]-$,ee=z[1]-j;return P.get($,j)*(1-X)*(1-ee)+P.get($+1,j)*X*(1-ee)+P.get($,j+1)*(1-X)*ee+P.get($+1,j+1)*X*ee}getElevationForLngLatZoom(l,f){if(!o.bb(f,l.wrap()))return 0;const{tileID:b,mercatorX:_,mercatorY:w}=this._getOverscaledTileIDFromLngLatZoom(l,f);return this.getElevation(b,_%o.X,w%o.X,o.X)}getElevation(l,f,b,_=o.X){return this.getDEMElevation(l,f,b,_)*this.exaggeration}getTerrainData(l){if(!this._emptyDemTexture){const _=this.painter.context,w=new o.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Le(_,w,_.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Le(_,new o.R({width:1,height:1}),_.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=o.an([])}const f=this.sourceCache.getSourceTile(l,!0);if(f&&f.dem&&(!f.demTexture||f.needsTerrainPrepare)){const _=this.painter.context;f.demTexture=this.painter.getTileTexture(f.dem.stride),f.demTexture?f.demTexture.update(f.dem.getPixels(),{premultiply:!1}):f.demTexture=new Le(_,f.dem.getPixels(),_.gl.RGBA,{premultiply:!1}),f.demTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),f.needsTerrainPrepare=!1}const b=f&&f+f.tileID.key+l.key;if(b&&!this._demMatrixCache[b]){const _=this.sourceCache.sourceCache._source.maxzoom;let w=l.canonical.z-f.tileID.canonical.z;l.overscaledZ>l.canonical.z&&(l.canonical.z>=_?w=l.canonical.z-_:o.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const M=l.canonical.x-(l.canonical.x>>w<<w),P=l.canonical.y-(l.canonical.y>>w<<w),R=o.bc(new Float64Array(16),[1/(o.X<<w),1/(o.X<<w),0]);o.J(R,R,[M*o.X,P*o.X,0]),this._demMatrixCache[l.key]={matrix:R,coord:l}}return{u_depth:2,u_terrain:3,u_terrain_dim:f&&f.dem&&f.dem.dim||1,u_terrain_matrix:b?this._demMatrixCache[l.key].matrix:this._emptyDemMatrix,u_terrain_unpack:f&&f.dem&&f.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(f&&f.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:f}}getFramebuffer(l){const f=this.painter,b=f.width/devicePixelRatio,_=f.height/devicePixelRatio;return!this._fbo||this._fbo.width===b&&this._fbo.height===_||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Le(f.context,{width:b,height:_,data:null},f.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(f.context.gl.NEAREST,f.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Le(f.context,{width:b,height:_,data:null},f.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(f.context.gl.NEAREST,f.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=f.context.createFramebuffer(b,_,!0,!1),this._fbo.depthAttachment.set(f.context.createRenderbuffer(f.context.gl.DEPTH_COMPONENT16,b,_))),this._fbo.colorAttachment.set(l==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const l=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const f=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let w=0,M=0;w<this._coordsTextureSize;w++)for(let P=0;P<this._coordsTextureSize;P++,M+=4)f[M+0]=255&P,f[M+1]=255&w,f[M+2]=P>>8<<4|w>>8,f[M+3]=0;const b=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(f.buffer)),_=new Le(l,b,l.gl.RGBA,{premultiply:!1});return _.bind(l.gl.NEAREST,l.gl.CLAMP_TO_EDGE),this._coordsTexture=_,_}pointCoordinate(l){this.painter.maybeDrawDepthAndCoords(!0);const f=new Uint8Array(4),b=this.painter.context,_=b.gl,w=Math.round(l.x*this.painter.pixelRatio/devicePixelRatio),M=Math.round(l.y*this.painter.pixelRatio/devicePixelRatio),P=Math.round(this.painter.height/devicePixelRatio);b.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),_.readPixels(w,P-M-1,1,1,_.RGBA,_.UNSIGNED_BYTE,f),b.bindFramebuffer.set(null);const R=f[0]+(f[2]>>4<<8),z=f[1]+((15&f[2])<<8),$=this.coordsIndex[255-f[3]],j=$&&this.sourceCache.getTileByID($);if(!j)return null;const X=this._coordsTextureSize,ee=(1<<j.tileID.canonical.z)*X;return new o.Z((j.tileID.canonical.x*X+R)/ee+j.tileID.wrap,(j.tileID.canonical.y*X+z)/ee,this.getElevation(j.tileID,R,z,X))}depthAtPoint(l){const f=new Uint8Array(4),b=this.painter.context,_=b.gl;return b.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),_.readPixels(l.x,this.painter.height/devicePixelRatio-l.y-1,1,1,_.RGBA,_.UNSIGNED_BYTE,f),b.bindFramebuffer.set(null),(f[0]/16777216+f[1]/65536+f[2]/256+f[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const l=this.painter.context,f=new o.bd,b=new o.aY,_=this.meshSize,w=o.X/_,M=_*_;for(let j=0;j<=_;j++)for(let X=0;X<=_;X++)f.emplaceBack(X*w,j*w,0);for(let j=0;j<M;j+=_+1)for(let X=0;X<_;X++)b.emplaceBack(X+j,_+X+j+1,_+X+j+2),b.emplaceBack(X+j,_+X+j+2,X+j+1);const P=f.length,R=P+2*(_+1);for(const j of[0,1])for(let X=0;X<=_;X++)for(const ee of[0,1])f.emplaceBack(X*w,j*o.X,ee);for(let j=0;j<2*_;j+=2)b.emplaceBack(R+j,R+j+1,R+j+3),b.emplaceBack(R+j,R+j+3,R+j+2),b.emplaceBack(P+j,P+j+3,P+j+1),b.emplaceBack(P+j,P+j+2,P+j+3);const z=f.length,$=z+2*(_+1);for(const j of[0,1])for(let X=0;X<=_;X++)for(const ee of[0,1])f.emplaceBack(j*o.X,X*w,ee);for(let j=0;j<2*_;j+=2)b.emplaceBack(z+j,z+j+1,z+j+3),b.emplaceBack(z+j,z+j+3,z+j+2),b.emplaceBack($+j,$+j+3,$+j+1),b.emplaceBack($+j,$+j+2,$+j+3);return this._mesh=new Eu(l.createVertexBuffer(f,sp.members),l.createIndexBuffer(b),o.a0.simpleSegment(0,0,f.length,b.length)),this._mesh}getMeshFrameDelta(l){return 2*Math.PI*o.be/Math.pow(2,l)/5}getMinTileElevationForLngLatZoom(l,f){var b;const{tileID:_}=this._getOverscaledTileIDFromLngLatZoom(l,f);return(b=this.getMinMaxElevation(_).minElevation)!==null&&b!==void 0?b:0}getMinMaxElevation(l){const f=this.getTerrainData(l).tile,b={minElevation:null,maxElevation:null};return f&&f.dem&&(b.minElevation=f.dem.min*this.exaggeration,b.maxElevation=f.dem.max*this.exaggeration),b}_getOverscaledTileIDFromLngLatZoom(l,f){const b=o.Z.fromLngLat(l.wrap()),_=(1<<f)*o.X,w=b.x*_,M=b.y*_,P=Math.floor(w/o.X),R=Math.floor(M/o.X);return{tileID:new o.S(f,0,f,P,R),mercatorX:w,mercatorY:M}}}class o1{constructor(l,f,b){this._context=l,this._size=f,this._tileSize=b,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const l of this._objects)l.texture.destroy(),l.fbo.destroy()}_createObject(l){const f=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),b=new Le(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return b.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),f.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),f.colorAttachment.set(b.texture),{id:l,fbo:f,texture:b,stamp:-1,inUse:!1}}getObjectForId(l){return this._objects[l]}useObject(l){l.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(f=>l.id!==f),this._recentlyUsed.push(l.id)}stampObject(l){l.stamp=++this._stamp}getOrCreateFreeObject(){for(const f of this._recentlyUsed)if(!this._objects[f].inUse)return this._objects[f];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const l=this._createObject(this._objects.length);return this._objects.push(l),l}freeObject(l){l.inUse=!1}freeAllObjects(){for(const l of this._objects)this.freeObject(l)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(l=>!l.inUse)===!1}}const Pl={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class zy{constructor(l,f){this.painter=l,this.terrain=f,this.pool=new o1(l.context,30,f.sourceCache.tileSize*f.qualityFactor)}destruct(){this.pool.destruct()}getTexture(l){return this.pool.getObjectForId(l.rtt[this._stacks.length-1].id).texture}prepareForRender(l,f){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=l._order.filter(b=>!l._layers[b].isHidden(f)),this._coordsDescendingInv={};for(const b in l.sourceCaches){this._coordsDescendingInv[b]={};const _=l.sourceCaches[b].getVisibleCoordinates();for(const w of _){const M=this.terrain.sourceCache.getTerrainCoords(w);for(const P in M)this._coordsDescendingInv[b][P]||(this._coordsDescendingInv[b][P]=[]),this._coordsDescendingInv[b][P].push(M[P])}}this._coordsDescendingInvStr={};for(const b of l._order){const _=l._layers[b],w=_.source;if(Pl[_.type]&&!this._coordsDescendingInvStr[w]){this._coordsDescendingInvStr[w]={};for(const M in this._coordsDescendingInv[w])this._coordsDescendingInvStr[w][M]=this._coordsDescendingInv[w][M].map(P=>P.key).sort().join()}}for(const b of this._renderableTiles)for(const _ in this._coordsDescendingInvStr){const w=this._coordsDescendingInvStr[_][b.tileID.key];w&&w!==b.rttCoords[_]&&(b.rtt=[])}}renderLayer(l){if(l.isHidden(this.painter.transform.zoom))return!1;const f=l.type,b=this.painter,_=this._renderableLayerIds[this._renderableLayerIds.length-1]===l.id;if(Pl[f]&&(this._prevType&&Pl[this._prevType]||this._stacks.push([]),this._prevType=f,this._stacks[this._stacks.length-1].push(l.id),!_))return!0;if(Pl[this._prevType]||Pl[f]&&_){this._prevType=f;const w=this._stacks.length-1,M=this._stacks[w]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(Dy(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[w]){const z=this.pool.getObjectForId(P.rtt[w].id);if(z.stamp===P.rtt[w].stamp){this.pool.useObject(z);continue}}const R=this.pool.getOrCreateFreeObject();this.pool.useObject(R),this.pool.stampObject(R),P.rtt[w]={id:R.id,stamp:R.stamp},b.context.bindFramebuffer.set(R.fbo.framebuffer),b.context.clear({color:o.aM.transparent,stencil:0}),b.currentStencilSource=void 0;for(let z=0;z<M.length;z++){const $=b.style._layers[M[z]],j=$.source?this._coordsDescendingInv[$.source][P.tileID.key]:[P.tileID];b.context.viewport.set([0,0,R.fbo.width,R.fbo.height]),b._renderTileClippingMasks($,j),b.renderLayer(b,b.style.sourceCaches[$.source],$,j),$.source&&(P.rttCoords[$.source]=this._coordsDescendingInvStr[$.source][P.tileID.key])}}return Dy(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Pl[f]}return!1}}const ap={"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","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","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"},Ly=p,a1={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Dl,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:o.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},lp=E=>{E.touchstart=E.dragStart,E.touchmoveWindow=E.dragMove,E.touchend=E.dragEnd},l1={showCompass:!0,showZoom:!0,visualizePitch:!1};class c1{constructor(l,f,b=!1){this.mousedown=M=>{this.startMouse(o.e({},M,{ctrlKey:!0,preventDefault:()=>M.preventDefault()}),k.mousePos(this.element,M)),k.addEventListener(window,"mousemove",this.mousemove),k.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=M=>{this.moveMouse(M,k.mousePos(this.element,M))},this.mouseup=M=>{this.mouseRotate.dragEnd(M),this.mousePitch&&this.mousePitch.dragEnd(M),this.offTemp()},this.touchstart=M=>{M.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=k.touchPos(this.element,M.targetTouches)[0],this.startTouch(M,this._startPos),k.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),k.addEventListener(window,"touchend",this.touchend))},this.touchmove=M=>{M.targetTouches.length!==1?this.reset():(this._lastPos=k.touchPos(this.element,M.targetTouches)[0],this.moveTouch(M,this._lastPos))},this.touchend=M=>{M.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._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;const _=l.dragRotate._mouseRotate.getClickTolerance(),w=l.dragRotate._mousePitch.getClickTolerance();this.element=f,this.mouseRotate=Zf({clickTolerance:_,enable:!0}),this.touchRotate=(({enable:M,clickTolerance:P,bearingDegreesPerPixelMoved:R=.8})=>{const z=new Yf;return new fo({clickTolerance:P,move:($,j)=>({bearingDelta:(j.x-$.x)*R}),moveStateManager:z,enable:M,assignEvents:lp})})({clickTolerance:_,enable:!0}),this.map=l,b&&(this.mousePitch=Xf({clickTolerance:w,enable:!0}),this.touchPitch=(({enable:M,clickTolerance:P,pitchDegreesPerPixelMoved:R=-.5})=>{const z=new Yf;return new fo({clickTolerance:P,move:($,j)=>({pitchDelta:(j.y-$.y)*R}),moveStateManager:z,enable:M,assignEvents:lp})})({clickTolerance:w,enable:!0})),k.addEventListener(f,"mousedown",this.mousedown),k.addEventListener(f,"touchstart",this.touchstart,{passive:!1}),k.addEventListener(f,"touchcancel",this.reset)}startMouse(l,f){this.mouseRotate.dragStart(l,f),this.mousePitch&&this.mousePitch.dragStart(l,f),k.disableDrag()}startTouch(l,f){this.touchRotate.dragStart(l,f),this.touchPitch&&this.touchPitch.dragStart(l,f),k.disableDrag()}moveMouse(l,f){const b=this.map,{bearingDelta:_}=this.mouseRotate.dragMove(l,f)||{};if(_&&b.setBearing(b.getBearing()+_),this.mousePitch){const{pitchDelta:w}=this.mousePitch.dragMove(l,f)||{};w&&b.setPitch(b.getPitch()+w)}}moveTouch(l,f){const b=this.map,{bearingDelta:_}=this.touchRotate.dragMove(l,f)||{};if(_&&b.setBearing(b.getBearing()+_),this.touchPitch){const{pitchDelta:w}=this.touchPitch.dragMove(l,f)||{};w&&b.setPitch(b.getPitch()+w)}}off(){const l=this.element;k.removeEventListener(l,"mousedown",this.mousedown),k.removeEventListener(l,"touchstart",this.touchstart,{passive:!1}),k.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),k.removeEventListener(window,"touchend",this.touchend),k.removeEventListener(l,"touchcancel",this.reset),this.offTemp()}offTemp(){k.enableDrag(),k.removeEventListener(window,"mousemove",this.mousemove),k.removeEventListener(window,"mouseup",this.mouseup),k.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),k.removeEventListener(window,"touchend",this.touchend)}}let Hi;function Zn(E,l,f){const b=new o.N(E.lng,E.lat);if(E=new o.N(E.lng,E.lat),l){const _=new o.N(E.lng-360,E.lat),w=new o.N(E.lng+360,E.lat),M=f.locationPoint(E).distSqr(l);f.locationPoint(_).distSqr(l)<M?E=_:f.locationPoint(w).distSqr(l)<M&&(E=w)}for(;Math.abs(E.lng-f.center.lng)>180;){const _=f.locationPoint(E);if(_.x>=0&&_.y>=0&&_.x<=f.width&&_.y<=f.height)break;E.lng>f.center.lng?E.lng-=360:E.lng+=360}return E.lng!==b.lng&&f.locationPoint(E).y>f.height/2-f.getHorizon()?E:b}const Nl={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 Ou(E,l,f){const b=E.classList;for(const _ in Nl)b.remove(`maplibregl-${f}-anchor-${_}`);b.add(`maplibregl-${f}-anchor-${l}`)}class Bu extends o.E{constructor(l){if(super(),this._onKeyPress=f=>{const b=f.code,_=f.charCode||f.keyCode;b!=="Space"&&b!=="Enter"&&_!==32&&_!==13||this.togglePopup()},this._onMapClick=f=>{const b=f.originalEvent.target,_=this._element;this._popup&&(b===_||_.contains(b))&&this.togglePopup()},this._update=f=>{var b;if(!this._map)return;const _=this._map.loaded()&&!this._map.isMoving();((f==null?void 0:f.type)==="terrain"||(f==null?void 0:f.type)==="render"&&!_)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Zn(this._lngLat,this._flatPos,this._map.transform):(b=this._lngLat)===null||b===void 0?void 0:b.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 w="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?w=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(w=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let M="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?M="rotateX(0deg)":this._pitchAlignment==="map"&&(M=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||f&&f.type!=="moveend"||(this._pos=this._pos.round()),k.setTransform(this._element,`${Nl[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${M} ${w}`),v.frameAsync(new AbortController).then(()=>{this._updateOpacity(f&&f.type==="moveend")}).catch(()=>{})},this._onMove=f=>{if(!this._isDragging){const b=this._clickTolerance||this._map._clickTolerance;this._isDragging=f.point.dist(this._pointerdownPos)>=b}this._isDragging&&(this._pos=f.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new o.k("dragstart"))),this.fire(new o.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new o.k("dragend")),this._state="inactive"},this._addDragHandler=f=>{this._element.contains(f.originalEvent.target)&&(f.preventDefault(),this._positionDelta=f.point.sub(this._pos).add(this._offset),this._pointerdownPos=f.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=l&&l.anchor||"center",this._color=l&&l.color||"#3FB1CE",this._scale=l&&l.scale||1,this._draggable=l&&l.draggable||!1,this._clickTolerance=l&&l.clickTolerance||0,this._subpixelPositioning=l&&l.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=l&&l.rotation||0,this._rotationAlignment=l&&l.rotationAlignment||"auto",this._pitchAlignment=l&&l.pitchAlignment&&l.pitchAlignment!=="auto"?l.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(l==null?void 0:l.opacity,l==null?void 0:l.opacityWhenCovered),l&&l.element)this._element=l.element,this._offset=o.P.convert(l&&l.offset||[0,0]);else{this._defaultMarker=!0,this._element=k.create("div");const f=k.createNS("http://www.w3.org/2000/svg","svg"),b=41,_=27;f.setAttributeNS(null,"display","block"),f.setAttributeNS(null,"height",`${b}px`),f.setAttributeNS(null,"width",`${_}px`),f.setAttributeNS(null,"viewBox",`0 0 ${_} ${b}`);const w=k.createNS("http://www.w3.org/2000/svg","g");w.setAttributeNS(null,"stroke","none"),w.setAttributeNS(null,"stroke-width","1"),w.setAttributeNS(null,"fill","none"),w.setAttributeNS(null,"fill-rule","evenodd");const M=k.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"fill-rule","nonzero");const P=k.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(3.0, 29.0)"),P.setAttributeNS(null,"fill","#000000");const R=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const de of R){const pe=k.createNS("http://www.w3.org/2000/svg","ellipse");pe.setAttributeNS(null,"opacity","0.04"),pe.setAttributeNS(null,"cx","10.5"),pe.setAttributeNS(null,"cy","5.80029008"),pe.setAttributeNS(null,"rx",de.rx),pe.setAttributeNS(null,"ry",de.ry),P.appendChild(pe)}const z=k.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"fill",this._color);const $=k.createNS("http://www.w3.org/2000/svg","path");$.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"),z.appendChild($);const j=k.createNS("http://www.w3.org/2000/svg","g");j.setAttributeNS(null,"opacity","0.25"),j.setAttributeNS(null,"fill","#000000");const X=k.createNS("http://www.w3.org/2000/svg","path");X.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"),j.appendChild(X);const ee=k.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"transform","translate(6.0, 7.0)"),ee.setAttributeNS(null,"fill","#FFFFFF");const te=k.createNS("http://www.w3.org/2000/svg","g");te.setAttributeNS(null,"transform","translate(8.0, 8.0)");const se=k.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#000000"),se.setAttributeNS(null,"opacity","0.25"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962");const le=k.createNS("http://www.w3.org/2000/svg","circle");le.setAttributeNS(null,"fill","#FFFFFF"),le.setAttributeNS(null,"cx","5.5"),le.setAttributeNS(null,"cy","5.5"),le.setAttributeNS(null,"r","5.4999962"),te.appendChild(se),te.appendChild(le),M.appendChild(P),M.appendChild(z),M.appendChild(j),M.appendChild(ee),M.appendChild(te),f.appendChild(M),f.setAttributeNS(null,"height",b*this._scale+"px"),f.setAttributeNS(null,"width",_*this._scale+"px"),this._element.appendChild(f),this._offset=o.P.convert(l&&l.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",f=>{f.preventDefault()}),this._element.addEventListener("mousedown",f=>{f.preventDefault()}),Ou(this._element,this._anchor,"marker"),l&&l.className)for(const f of l.className.split(" "))this._element.classList.add(f);this._popup=null}addTo(l){return this.remove(),this._map=l,this._element.setAttribute("aria-label",l._getUIString("Marker.Title")),l.getCanvasContainer().appendChild(this._element),l.on("move",this._update),l.on("moveend",this._update),l.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),k.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(l){return this._lngLat=o.N.convert(l),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(l){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),l){if(!("offset"in l.options)){const _=Math.abs(13.5)/Math.SQRT2;l.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[_,-1*(38.1-13.5+_)],"bottom-right":[-_,-1*(38.1-13.5+_)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=l,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(l){return this._subpixelPositioning=l,this}getPopup(){return this._popup}togglePopup(){const l=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:l?(l.isOpen()?l.remove():(l.setLngLat(this._lngLat),l.addTo(this._map)),this):this}_updateOpacity(l=!1){var f,b;if(!(!((f=this._map)===null||f===void 0)&&f.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(l)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const _=this._map,w=_.terrain.depthAtPoint(this._pos),M=_.terrain.getElevationForLngLatZoom(this._lngLat,_.transform.tileZoom);if(_.transform.lngLatToCameraDepth(this._lngLat,M)-w<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/_.transform._pixelPerMeter,R=Math.sin(_.getPitch()*Math.PI/180)*P,z=_.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),$=_.transform.lngLatToCameraDepth(this._lngLat,M+R)-z>.006;!((b=this._popup)===null||b===void 0)&&b.isOpen()&&$&&this._popup.remove(),this._element.style.opacity=$?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(l){return this._offset=o.P.convert(l),this._update(),this}addClassName(l){this._element.classList.add(l)}removeClassName(l){this._element.classList.remove(l)}toggleClassName(l){return this._element.classList.toggle(l)}setDraggable(l){return this._draggable=!!l,this._map&&(l?(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(l){return this._rotation=l||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(l){return this._rotationAlignment=l||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(l){return this._pitchAlignment=l&&l!=="auto"?l:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(l,f){return l===void 0&&f===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),l!==void 0&&(this._opacity=l),f!==void 0&&(this._opacityWhenCovered=f),this._map&&this._updateOpacity(!0),this}}const Fy={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Gc=0,Yc=!1;const Ks={maxWidth:100,unit:"metric"};function Zc(E,l,f){const b=f&&f.maxWidth||100,_=E._container.clientHeight/2,w=E.unproject([0,_]),M=E.unproject([b,_]),P=w.distanceTo(M);if(f&&f.unit==="imperial"){const R=3.2808*P;R>5280?xt(l,b,R/5280,E._getUIString("ScaleControl.Miles")):xt(l,b,R,E._getUIString("ScaleControl.Feet"))}else f&&f.unit==="nautical"?xt(l,b,P/1852,E._getUIString("ScaleControl.NauticalMiles")):P>=1e3?xt(l,b,P/1e3,E._getUIString("ScaleControl.Kilometers")):xt(l,b,P,E._getUIString("ScaleControl.Meters"))}function xt(E,l,f,b){const _=function(w){const M=Math.pow(10,`${Math.floor(w)}`.length-1);let P=w/M;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(R){const z=Math.pow(10,Math.ceil(-Math.log(R)/Math.LN10));return Math.round(R*z)/z}(P),M*P}(f);E.style.width=l*(_/f)+"px",E.innerHTML=`${_} ${b}`}const Rt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Vu=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function zu(E){if(E){if(typeof E=="number"){const l=Math.round(Math.abs(E)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,E),"top-left":new o.P(l,l),"top-right":new o.P(-l,l),bottom:new o.P(0,-E),"bottom-left":new o.P(l,-l),"bottom-right":new o.P(-l,-l),left:new o.P(E,0),right:new o.P(-E,0)}}if(E instanceof o.P||Array.isArray(E)){const l=o.P.convert(E);return{center:l,top:l,"top-left":l,"top-right":l,bottom:l,"bottom-left":l,"bottom-right":l,left:l,right:l}}return{center:o.P.convert(E.center||[0,0]),top:o.P.convert(E.top||[0,0]),"top-left":o.P.convert(E["top-left"]||[0,0]),"top-right":o.P.convert(E["top-right"]||[0,0]),bottom:o.P.convert(E.bottom||[0,0]),"bottom-left":o.P.convert(E["bottom-left"]||[0,0]),"bottom-right":o.P.convert(E["bottom-right"]||[0,0]),left:o.P.convert(E.left||[0,0]),right:o.P.convert(E.right||[0,0])}}return zu(new o.P(0,0))}const cp=p;a.AJAXError=o.bh,a.Evented=o.E,a.LngLat=o.N,a.MercatorCoordinate=o.Z,a.Point=o.P,a.addProtocol=o.bi,a.config=o.a,a.removeProtocol=o.bj,a.AttributionControl=Il,a.BoxZoomHandler=ji,a.CanvasSource=hr,a.CooperativeGesturesHandler=Ml,a.DoubleClickZoomHandler=Ma,a.DragPanHandler=Oy,a.DragRotateHandler=By,a.EdgeInsets=Cl,a.FullscreenControl=class extends o.E{constructor(E={}){super(),this._onFullscreenChange=()=>{var l;let f=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((l=f==null?void 0:f.shadowRoot)===null||l===void 0)&&l.fullscreenElement;)f=f.shadowRoot.fullscreenElement;f===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,E&&E.container&&(E.container instanceof HTMLElement?this._container=E.container:o.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(E){return this._map=E,this._container||(this._container=this._map.getContainer()),this._controlContainer=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){k.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const E=this._fullscreenButton=k.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);k.create("span","maplibregl-ctrl-icon",E).setAttribute("aria-hidden","true"),E.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const E=this._getTitle();this._fullscreenButton.setAttribute("aria-label",E),this._fullscreenButton.title=E}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new o.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new o.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},a.GeoJSONSource=Vr,a.GeolocateControl=class extends o.E{constructor(E){super(),this._onSuccess=l=>{if(this._map){if(this._isOutOfMapMaxBounds(l))return this._setErrorState(),this.fire(new o.k("outofmaxbounds",l)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=l,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(l),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(l),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new o.k("geolocate",l)),this._finish()}},this._updateCamera=l=>{const f=new o.N(l.coords.longitude,l.coords.latitude),b=l.coords.accuracy,_=this._map.getBearing(),w=o.e({bearing:_},this.options.fitBoundsOptions),M=Ae.fromLngLat(f,b);this._map.fitBounds(M,w,{geolocateSource:!0})},this._updateMarker=l=>{if(l){const f=new o.N(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(f).addTo(this._map),this._userLocationDotMarker.setLngLat(f).addTo(this._map),this._accuracy=l.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=l=>{if(this._map){if(this.options.trackUserLocation)if(l.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const f=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=f,this._geolocateButton.setAttribute("aria-label",f),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&Yc)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new o.k("error",l)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",l=>l.preventDefault()),this._geolocateButton=k.create("button","maplibregl-ctrl-geolocate",this._container),k.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=l=>{if(this._map){if(l===!1){o.w("Geolocation support is not available so the GeolocateControl will be disabled.");const f=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=f,this._geolocateButton.setAttribute("aria-label",f)}else{const f=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=f,this._geolocateButton.setAttribute("aria-label",f)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=k.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Bu({element:this._dotElement}),this._circleElement=k.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Bu({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",f=>{f.geolocateSource||this._watchState!=="ACTIVE_LOCK"||f.originalEvent&&f.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new o.k("trackuserlocationend")),this.fire(new o.k("userlocationlostfocus")))})}},this.options=o.e({},Fy,E)}onAdd(E){return this._map=E,this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return o._(this,arguments,void 0,function*(l=!1){if(Hi!==void 0&&!l)return Hi;if(window.navigator.permissions===void 0)return Hi=!!window.navigator.geolocation,Hi;try{Hi=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Hi=!!window.navigator.geolocation}return Hi})}().then(l=>this._finishSetupUI(l)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),k.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Gc=0,Yc=!1}_isOutOfMapMaxBounds(E){const l=this._map.getMaxBounds(),f=E.coords;return l&&(f.longitude<l.getWest()||f.longitude>l.getEast()||f.latitude<l.getSouth()||f.latitude>l.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const E=this._map.getBounds(),l=E.getSouthEast(),f=E.getNorthEast(),b=l.distanceTo(f),_=Math.ceil(this._accuracy/(b/this._map._container.clientHeight)*2);this._circleElement.style.width=`${_}px`,this._circleElement.style.height=`${_}px`}trigger(){if(!this._setup)return o.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new o.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Gc--,Yc=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new o.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new o.k("trackuserlocationstart")),this.fire(new o.k("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let E;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Gc++,Gc>1?(E={maximumAge:6e5,timeout:0},Yc=!0):(E=this.options.positionOptions,Yc=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,E)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},a.Hash=Cu,a.ImageSource=ir,a.KeyboardHandler=is,a.LngLatBounds=Ae,a.LogoControl=ip,a.Map=class extends Vy{constructor(E){o.bf.mark(o.bg.create);const l=Object.assign(Object.assign({},a1),E);if(l.minZoom!=null&&l.maxZoom!=null&&l.minZoom>l.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(l.minPitch!=null&&l.maxPitch!=null&&l.minPitch>l.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(l.minPitch!=null&&l.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(l.maxPitch!=null&&l.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Tl(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),{bearingSnap:l.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new hn,this._controls=[],this._mapId=o.a4(),this._contextLost=f=>{f.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:f}))},this._contextRestored=f=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:f}))},this._onMapScroll=f=>{if(f.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=l.interactive,this._maxTileCacheSize=l.maxTileCacheSize,this._maxTileCacheZoomLevels=l.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=l.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=l.preserveDrawingBuffer===!0,this._antialias=l.antialias===!0,this._trackResize=l.trackResize===!0,this._bearingSnap=l.bearingSnap,this._refreshExpiredTiles=l.refreshExpiredTiles===!0,this._fadeDuration=l.fadeDuration,this._crossSourceCollisions=l.crossSourceCollisions===!0,this._collectResourceTiming=l.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},ap),l.locale),this._clickTolerance=l.clickTolerance,this._overridePixelRatio=l.pixelRatio,this._maxCanvasSize=l.maxCanvasSize,this.transformCameraUpdate=l.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=l.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Z.addThrottleControl(()=>this.isMoving()),this._requestManager=new Y(l.transformRequest),typeof l.container=="string"){if(this._container=document.getElementById(l.container),!this._container)throw new Error(`Container '${l.container}' not found.`)}else{if(!(l.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=l.container}if(l.maxBounds&&this.setMaxBounds(l.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let f=!1;const b=$c(_=>{this._trackResize&&!this._removed&&(this.resize(_),this.redraw())},50);this._resizeObserver=new ResizeObserver(_=>{f?b(_):f=!0}),this._resizeObserver.observe(this._container)}this.handlers=new rp(this,l),this._hash=l.hash&&new Cu(typeof l.hash=="string"&&l.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:l.center,zoom:l.zoom,bearing:l.bearing,pitch:l.pitch}),l.bounds&&(this.resize(),this.fitBounds(l.bounds,o.e({},l.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=l.localIdeographFontFamily,this._validateStyle=l.validateStyle,l.style&&this.setStyle(l.style,{localIdeographFontFamily:l.localIdeographFontFamily}),l.attributionControl&&this.addControl(new Il(typeof l.attributionControl=="boolean"?void 0:l.attributionControl)),l.maplibreLogo&&this.addControl(new ip,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",f=>{this._update(f.dataType==="style"),this.fire(new o.k(`${f.dataType}data`,f))}),this.on("dataloading",f=>{this.fire(new o.k(`${f.dataType}dataloading`,f))}),this.on("dataabort",f=>{this.fire(new o.k("sourcedataabort",f))})}_getMapId(){return this._mapId}addControl(E,l){if(l===void 0&&(l=E.getDefaultPosition?E.getDefaultPosition():"top-right"),!E||!E.onAdd)return this.fire(new o.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const f=E.onAdd(this);this._controls.push(E);const b=this._controlPositions[l];return l.indexOf("bottom")!==-1?b.insertBefore(f,b.firstChild):b.appendChild(f),this}removeControl(E){if(!E||!E.onRemove)return this.fire(new o.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const l=this._controls.indexOf(E);return l>-1&&this._controls.splice(l,1),E.onRemove(this),this}hasControl(E){return this._controls.indexOf(E)>-1}calculateCameraOptionsFromTo(E,l,f,b){return b==null&&this.terrain&&(b=this.terrain.getElevationForLngLatZoom(f,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(E,l,f,b)}resize(E){var l;const f=this._containerDimensions(),b=f[0],_=f[1],w=this._getClampedPixelRatio(b,_);if(this._resizeCanvas(b,_,w),this.painter.resize(b,_,w),this.painter.overLimit()){const P=this.painter.context.gl;this._maxCanvasSize=[P.drawingBufferWidth,P.drawingBufferHeight];const R=this._getClampedPixelRatio(b,_);this._resizeCanvas(b,_,R),this.painter.resize(b,_,R)}this.transform.resize(b,_),(l=this._requestedCameraState)===null||l===void 0||l.resize(b,_);const M=!this._moving;return M&&(this.stop(),this.fire(new o.k("movestart",E)).fire(new o.k("move",E))),this.fire(new o.k("resize",E)),M&&this.fire(new o.k("moveend",E)),this}_getClampedPixelRatio(E,l){const{0:f,1:b}=this._maxCanvasSize,_=this.getPixelRatio(),w=E*_,M=l*_;return Math.min(w>f?f/w:1,M>b?b/M:1)*_}getPixelRatio(){var E;return(E=this._overridePixelRatio)!==null&&E!==void 0?E:devicePixelRatio}setPixelRatio(E){this._overridePixelRatio=E,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(E){return this.transform.setMaxBounds(Ae.convert(E)),this._update()}setMinZoom(E){if((E=E??-2)>=-2&&E<=this.transform.maxZoom)return this.transform.minZoom=E,this._update(),this.getZoom()<E&&this.setZoom(E),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(E){if((E=E??22)>=this.transform.minZoom)return this.transform.maxZoom=E,this._update(),this.getZoom()>E&&this.setZoom(E),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(E){if((E=E??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(E>=0&&E<=this.transform.maxPitch)return this.transform.minPitch=E,this._update(),this.getPitch()<E&&this.setPitch(E),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(E){if((E=E??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(E>=this.transform.minPitch)return this.transform.maxPitch=E,this._update(),this.getPitch()>E&&this.setPitch(E),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(E){return this.transform.renderWorldCopies=E,this._update()}project(E){return this.transform.locationPoint(o.N.convert(E),this.style&&this.terrain)}unproject(E){return this.transform.pointLocation(o.P.convert(E),this.terrain)}isMoving(){var E;return this._moving||((E=this.handlers)===null||E===void 0?void 0:E.isMoving())}isZooming(){var E;return this._zooming||((E=this.handlers)===null||E===void 0?void 0:E.isZooming())}isRotating(){var E;return this._rotating||((E=this.handlers)===null||E===void 0?void 0:E.isRotating())}_createDelegatedListener(E,l,f){if(E==="mouseenter"||E==="mouseover"){let b=!1;return{layers:l,listener:f,delegates:{mousemove:w=>{const M=l.filter(R=>this.getLayer(R)),P=M.length!==0?this.queryRenderedFeatures(w.point,{layers:M}):[];P.length?b||(b=!0,f.call(this,new Xr(E,this,w.originalEvent,{features:P}))):b=!1},mouseout:()=>{b=!1}}}}if(E==="mouseleave"||E==="mouseout"){let b=!1;return{layers:l,listener:f,delegates:{mousemove:M=>{const P=l.filter(R=>this.getLayer(R));(P.length!==0?this.queryRenderedFeatures(M.point,{layers:P}):[]).length?b=!0:b&&(b=!1,f.call(this,new Xr(E,this,M.originalEvent)))},mouseout:M=>{b&&(b=!1,f.call(this,new Xr(E,this,M.originalEvent)))}}}}{const b=_=>{const w=l.filter(P=>this.getLayer(P)),M=w.length!==0?this.queryRenderedFeatures(_.point,{layers:w}):[];M.length&&(_.features=M,f.call(this,_),delete _.features)};return{layers:l,listener:f,delegates:{[E]:b}}}}_saveDelegatedListener(E,l){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[E]=this._delegatedListeners[E]||[],this._delegatedListeners[E].push(l)}_removeDelegatedListener(E,l,f){if(!this._delegatedListeners||!this._delegatedListeners[E])return;const b=this._delegatedListeners[E];for(let _=0;_<b.length;_++){const w=b[_];if(w.listener===f&&w.layers.length===l.length&&w.layers.every(M=>l.includes(M))){for(const M in w.delegates)this.off(M,w.delegates[M]);return void b.splice(_,1)}}}on(E,l,f){if(f===void 0)return super.on(E,l);const b=this._createDelegatedListener(E,typeof l=="string"?[l]:l,f);this._saveDelegatedListener(E,b);for(const _ in b.delegates)this.on(_,b.delegates[_]);return this}once(E,l,f){if(f===void 0)return super.once(E,l);const b=typeof l=="string"?[l]:l,_=this._createDelegatedListener(E,b,f);for(const w in _.delegates){const M=_.delegates[w];_.delegates[w]=(...P)=>{this._removeDelegatedListener(E,b,f),M(...P)}}this._saveDelegatedListener(E,_);for(const w in _.delegates)this.once(w,_.delegates[w]);return this}off(E,l,f){return f===void 0?super.off(E,l):(this._removeDelegatedListener(E,typeof l=="string"?[l]:l,f),this)}queryRenderedFeatures(E,l){if(!this.style)return[];let f;const b=E instanceof o.P||Array.isArray(E),_=b?E:[[0,0],[this.transform.width,this.transform.height]];if(l=l||(b?{}:E)||{},_ instanceof o.P||typeof _[0]=="number")f=[o.P.convert(_)];else{const w=o.P.convert(_[0]),M=o.P.convert(_[1]);f=[w,new o.P(M.x,w.y),M,new o.P(w.x,M.y),w]}return this.style.queryRenderedFeatures(f,l,this.transform)}querySourceFeatures(E,l){return this.style.querySourceFeatures(E,l)}setStyle(E,l){return(l=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},l)).diff!==!1&&l.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&E?(this._diffStyle(E,l),this):(this._localIdeographFontFamily=l.localIdeographFontFamily,this._updateStyle(E,l))}setTransformRequest(E){return this._requestManager.setTransformRequest(E),this}_getUIString(E){const l=this._locale[E];if(l==null)throw new Error(`Missing UI string '${E}'`);return l}_updateStyle(E,l){if(l.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(E,l));const f=this.style&&l.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!E)),E?(this.style=new cu(this,l||{}),this.style.setEventedParent(this,{style:this.style}),typeof E=="string"?this.style.loadURL(E,l,f):this.style.loadJSON(E,l,f),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new cu(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(E,l){if(typeof E=="string"){const f=this._requestManager.transformRequest(E,"Style");o.h(f,new AbortController).then(b=>{this._updateDiff(b.data,l)}).catch(b=>{b&&this.fire(new o.j(b))})}else typeof E=="object"&&this._updateDiff(E,l)}_updateDiff(E,l){try{this.style.setState(E,l)&&this._update(!0)}catch(f){o.w(`Unable to perform style diff: ${f.message||f.error||f}. Rebuilding the style from scratch.`),this._updateStyle(E,l)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():o.w("There is no style added to the map.")}addSource(E,l){return this._lazyInitEmptyStyle(),this.style.addSource(E,l),this._update(!0)}isSourceLoaded(E){const l=this.style&&this.style.sourceCaches[E];if(l!==void 0)return l.loaded();this.fire(new o.j(new Error(`There is no source with ID '${E}'`)))}setTerrain(E){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),E){const l=this.style.sourceCaches[E.source];if(!l)throw new Error(`cannot load terrain, because there exists no source with ID: ${E.source}`);this.terrain===null&&l.reload();for(const f in this.style._layers){const b=this.style._layers[f];b.type==="hillshade"&&b.source===E.source&&o.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new op(this.painter,l,E),this.painter.renderToTexture=new zy(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=f=>{f.dataType==="style"?this.terrain.sourceCache.freeRtt():f.dataType==="source"&&f.tile&&(f.sourceId!==E.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(f.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new o.k("terrain",{terrain:E})),this}getTerrain(){var E,l;return(l=(E=this.terrain)===null||E===void 0?void 0:E.options)!==null&&l!==void 0?l:null}areTilesLoaded(){const E=this.style&&this.style.sourceCaches;for(const l in E){const f=E[l]._tiles;for(const b in f){const _=f[b];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}removeSource(E){return this.style.removeSource(E),this._update(!0)}getSource(E){return this.style.getSource(E)}addImage(E,l,f={}){const{pixelRatio:b=1,sdf:_=!1,stretchX:w,stretchY:M,content:P,textFitWidth:R,textFitHeight:z}=f;if(this._lazyInitEmptyStyle(),!(l instanceof HTMLImageElement||o.b(l))){if(l.width===void 0||l.height===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:$,height:j,data:X}=l,ee=l;return this.style.addImage(E,{data:new o.R({width:$,height:j},new Uint8Array(X)),pixelRatio:b,stretchX:w,stretchY:M,content:P,textFitWidth:R,textFitHeight:z,sdf:_,version:0,userImage:ee}),ee.onAdd&&ee.onAdd(this,E),this}}{const{width:$,height:j,data:X}=v.getImageData(l);this.style.addImage(E,{data:new o.R({width:$,height:j},X),pixelRatio:b,stretchX:w,stretchY:M,content:P,textFitWidth:R,textFitHeight:z,sdf:_,version:0})}}updateImage(E,l){const f=this.style.getImage(E);if(!f)return this.fire(new o.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const b=l instanceof HTMLImageElement||o.b(l)?v.getImageData(l):l,{width:_,height:w,data:M}=b;if(_===void 0||w===void 0)return this.fire(new o.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(_!==f.data.width||w!==f.data.height)return this.fire(new o.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const P=!(l instanceof HTMLImageElement||o.b(l));return f.data.replace(M,P),this.style.updateImage(E,f),this}getImage(E){return this.style.getImage(E)}hasImage(E){return E?!!this.style.getImage(E):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(E){this.style.removeImage(E)}loadImage(E){return Z.getImage(this._requestManager.transformRequest(E,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(E,l){return this._lazyInitEmptyStyle(),this.style.addLayer(E,l),this._update(!0)}moveLayer(E,l){return this.style.moveLayer(E,l),this._update(!0)}removeLayer(E){return this.style.removeLayer(E),this._update(!0)}getLayer(E){return this.style.getLayer(E)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(E,l,f){return this.style.setLayerZoomRange(E,l,f),this._update(!0)}setFilter(E,l,f={}){return this.style.setFilter(E,l,f),this._update(!0)}getFilter(E){return this.style.getFilter(E)}setPaintProperty(E,l,f,b={}){return this.style.setPaintProperty(E,l,f,b),this._update(!0)}getPaintProperty(E,l){return this.style.getPaintProperty(E,l)}setLayoutProperty(E,l,f,b={}){return this.style.setLayoutProperty(E,l,f,b),this._update(!0)}getLayoutProperty(E,l){return this.style.getLayoutProperty(E,l)}setGlyphs(E,l={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(E,l),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(E,l,f={}){return this._lazyInitEmptyStyle(),this.style.addSprite(E,l,f,b=>{b||this._update(!0)}),this}removeSprite(E){return this._lazyInitEmptyStyle(),this.style.removeSprite(E),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(E,l={}){return this._lazyInitEmptyStyle(),this.style.setSprite(E,l,f=>{f||this._update(!0)}),this}setLight(E,l={}){return this._lazyInitEmptyStyle(),this.style.setLight(E,l),this._update(!0)}getLight(){return this.style.getLight()}setSky(E){return this._lazyInitEmptyStyle(),this.style.setSky(E),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(E,l){return this.style.setFeatureState(E,l),this._update()}removeFeatureState(E,l){return this.style.removeFeatureState(E,l),this._update()}getFeatureState(E){return this.style.getFeatureState(E)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let E=0,l=0;return this._container&&(E=this._container.clientWidth||400,l=this._container.clientHeight||300),[E,l]}_setupContainer(){const E=this._container;E.classList.add("maplibregl-map");const l=this._canvasContainer=k.create("div","maplibregl-canvas-container",E);this._interactive&&l.classList.add("maplibregl-interactive"),this._canvas=k.create("canvas","maplibregl-canvas",l),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const f=this._containerDimensions(),b=this._getClampedPixelRatio(f[0],f[1]);this._resizeCanvas(f[0],f[1],b);const _=this._controlContainer=k.create("div","maplibregl-control-container",E),w=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(M=>{w[M]=k.create("div",`maplibregl-ctrl-${M} `,_)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(E,l,f){this._canvas.width=Math.floor(f*E),this._canvas.height=Math.floor(f*l),this._canvas.style.width=`${E}px`,this._canvas.style.height=`${l}px`}_setupPainter(){const E={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let l=null;this._canvas.addEventListener("webglcontextcreationerror",b=>{l={requestedAttributes:E},b&&(l.statusMessage=b.statusMessage,l.type=b.type)},{once:!0});const f=this._canvas.getContext("webgl2",E)||this._canvas.getContext("webgl",E);if(!f){const b="Failed to initialize WebGL";throw l?(l.message=b,new Error(JSON.stringify(l))):new Error(b)}this.painter=new Su(f,this.transform),T.testSupport(f)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(E){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||E,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(E){return this._update(),this._renderTaskQueue.add(E)}_cancelRenderFrame(E){this._renderTaskQueue.remove(E)}_render(E){const l=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(E),this._removed)return;let f=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const _=this.transform.zoom,w=v.now();this.style.zoomHistory.update(_,w);const M=new o.z(_,{now:w,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),P=M.crossFadingFactor();P===1&&P===this._crossFadingFactor||(f=!0,this._crossFadingFactor=P),this.style.update(M)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:l,showPadding:this.showPadding}),this.fire(new o.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,o.bf.mark(o.bg.load),this.fire(new o.k("load"))),this.style&&(this.style.hasTransitions()||f)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const b=this._sourcesDirty||this._styleDirty||this._placementDirty;return b||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new o.k("idle")),!this._loaded||this._fullyLoaded||b||(this._fullyLoaded=!0,o.bf.mark(o.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var E;this._hash&&this._hash.remove();for(const f of this._controls)f.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Z.removeThrottleControl(this._imageQueueHandle),(E=this._resizeObserver)===null||E===void 0||E.disconnect();const l=this.painter.context.gl.getExtension("WEBGL_lose_context");l!=null&&l.loseContext&&l.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),k.remove(this._canvasContainer),k.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),o.bf.clearMetrics(),this._removed=!0,this.fire(new o.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,v.frameAsync(this._frameRequest).then(E=>{o.bf.frame(E),this._frameRequest=null,this._render(E)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(E){this._showTileBoundaries!==E&&(this._showTileBoundaries=E,this._update())}get showPadding(){return!!this._showPadding}set showPadding(E){this._showPadding!==E&&(this._showPadding=E,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(E){this._showCollisionBoxes!==E&&(this._showCollisionBoxes=E,E?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(E){this._showOverdrawInspector!==E&&(this._showOverdrawInspector=E,this._update())}get repaint(){return!!this._repaint}set repaint(E){this._repaint!==E&&(this._repaint=E,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(E){this._vertices=E,this._update()}get version(){return Ly}getCameraTargetElevation(){return this.transform.elevation}},a.MapMouseEvent=Xr,a.MapTouchEvent=Ta,a.MapWheelEvent=Py,a.Marker=Bu,a.NavigationControl=class{constructor(E){this._updateZoomButtons=()=>{const l=this._map.getZoom(),f=l===this._map.getMaxZoom(),b=l===this._map.getMinZoom();this._zoomInButton.disabled=f,this._zoomOutButton.disabled=b,this._zoomInButton.setAttribute("aria-disabled",f.toString()),this._zoomOutButton.setAttribute("aria-disabled",b.toString())},this._rotateCompassArrow=()=>{const l=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=l},this._setButtonTitle=(l,f)=>{const b=this._map._getUIString(`NavigationControl.${f}`);l.title=b,l.setAttribute("aria-label",b)},this.options=o.e({},l1,E),this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",l=>l.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",l=>this._map.zoomIn({},{originalEvent:l})),k.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",l=>this._map.zoomOut({},{originalEvent:l})),k.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",l=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:l}):this._map.resetNorth({},{originalEvent:l})}),this._compassIcon=k.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(E){return this._map=E,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 c1(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){k.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(E,l){const f=k.create("button",E,this._container);return f.type="button",f.addEventListener("click",l),f}},a.Popup=class extends o.E{constructor(E){super(),this.remove=()=>(this._content&&k.remove(this._content),this._container&&(k.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new o.k("close"))),this),this._onMouseUp=l=>{this._update(l.point)},this._onMouseMove=l=>{this._update(l.point)},this._onDrag=l=>{this._update(l.point)},this._update=l=>{var f;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=k.create("div","maplibregl-popup",this._map.getContainer()),this._tip=k.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const P of this.options.className.split(" "))this._container.classList.add(P);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Zn(this._lngLat,this._flatPos,this._map.transform):(f=this._lngLat)===null||f===void 0?void 0:f.wrap(),this._trackPointer&&!l)return;const b=this._flatPos=this._pos=this._trackPointer&&l?l:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&l?l:this._map.transform.locationPoint(this._lngLat));let _=this.options.anchor;const w=zu(this.options.offset);if(!_){const P=this._container.offsetWidth,R=this._container.offsetHeight;let z;z=b.y+w.bottom.y<R?["top"]:b.y>this._map.transform.height-R?["bottom"]:[],b.x<P/2?z.push("left"):b.x>this._map.transform.width-P/2&&z.push("right"),_=z.length===0?"bottom":z.join("-")}let M=b.add(w[_]);this.options.subpixelPositioning||(M=M.round()),k.setTransform(this._container,`${Nl[_]} translate(${M.x}px,${M.y}px)`),Ou(this._container,_,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(Rt),E)}addTo(E){return this._map&&this.remove(),this._map=E,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new o.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(E){return this._lngLat=o.N.convert(E),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(E){return this.setDOMContent(document.createTextNode(E))}setHTML(E){const l=document.createDocumentFragment(),f=document.createElement("body");let b;for(f.innerHTML=E;b=f.firstChild,b;)l.appendChild(b);return this.setDOMContent(l)}getMaxWidth(){var E;return(E=this._container)===null||E===void 0?void 0:E.style.maxWidth}setMaxWidth(E){return this.options.maxWidth=E,this._update(),this}setDOMContent(E){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=k.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(E),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(E){return this._container&&this._container.classList.add(E),this}removeClassName(E){return this._container&&this._container.classList.remove(E),this}setOffset(E){return this.options.offset=E,this._update(),this}toggleClassName(E){if(this._container)return this._container.classList.toggle(E)}setSubpixelPositioning(E){this.options.subpixelPositioning=E}_createCloseButton(){this.options.closeButton&&(this._closeButton=k.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const E=this._container.querySelector(Vu);E&&E.focus()}},a.RasterDEMTileSource=bn,a.RasterTileSource=nn,a.ScaleControl=class{constructor(E){this._onMove=()=>{Zc(this._map,this._container,this.options)},this.setUnit=l=>{this.options.unit=l,Zc(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ks),E)}getDefaultPosition(){return"bottom-left"}onAdd(E){return this._map=E,this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-scale",E.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){k.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},a.ScrollZoomHandler=Cs,a.Style=cu,a.TerrainControl=class{constructor(E){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=E}onAdd(E){return this._map=E,this._container=k.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=k.create("button","maplibregl-ctrl-terrain",this._container),k.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(){k.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},a.TwoFingersTouchPitchHandler=qc,a.TwoFingersTouchRotateHandler=ep,a.TwoFingersTouchZoomHandler=Jf,a.TwoFingersTouchZoomRotateHandler=np,a.VectorTileSource=Bi,a.VideoSource=Ir,a.addSourceType=(E,l)=>o._(void 0,void 0,void 0,function*(){if(Zr(E))throw new Error(`A source type called "${E}" already exists.`);((f,b)=>{Yr[f]=b})(E,l)}),a.clearPrewarmedResources=function(){const E=Me;E&&(E.isPreloaded()&&E.numActive()===1?(E.release(_n),Me=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},a.getMaxParallelImageRequests=function(){return o.a.MAX_PARALLEL_IMAGE_REQUESTS},a.getRTLTextPluginStatus=function(){return ci().getRTLTextPluginStatus()},a.getVersion=function(){return cp},a.getWorkerCount=function(){return gn.workerCount},a.getWorkerUrl=function(){return o.a.WORKER_URL},a.importScriptInWorkers=function(E){return Gt().broadcast("IS",E)},a.prewarm=function(){Qe().acquire(_n)},a.setMaxParallelImageRequests=function(E){o.a.MAX_PARALLEL_IMAGE_REQUESTS=E},a.setRTLTextPlugin=function(E,l){return ci().setRTLTextPlugin(E,l)},a.setWorkerCount=function(E){gn.workerCount=E},a.setWorkerUrl=function(E){o.a.WORKER_URL=E}});var s=n;return s})})(DE);var E5=DE.exports;const pm=k5(E5);function IE(t,e,n){if(t!==null)for(var r,i,s,a,o,p,g,y=0,v=0,k,T=t.type,D=T==="FeatureCollection",N=T==="Feature",B=D?t.features.length:1,L=0;L<B;L++){g=D?t.features[L].geometry:N?t.geometry:t,k=g?g.type==="GeometryCollection":!1,o=k?g.geometries.length:1;for(var U=0;U<o;U++){var Z=0,Y=0;if(a=k?g.geometries[U]:g,a!==null){p=a.coordinates;var he=a.type;switch(y=0,he){case null:break;case"Point":if(e(p,v,L,Z,Y)===!1)return!1;v++,Z++;break;case"LineString":case"MultiPoint":for(r=0;r<p.length;r++){if(e(p[r],v,L,Z,Y)===!1)return!1;v++,he==="MultiPoint"&&Z++}he==="LineString"&&Z++;break;case"Polygon":case"MultiLineString":for(r=0;r<p.length;r++){for(i=0;i<p[r].length-y;i++){if(e(p[r][i],v,L,Z,Y)===!1)return!1;v++}he==="MultiLineString"&&Z++,he==="Polygon"&&Y++}he==="Polygon"&&Z++;break;case"MultiPolygon":for(r=0;r<p.length;r++){for(Y=0,i=0;i<p[r].length;i++){for(s=0;s<p[r][i].length-y;s++){if(e(p[r][i][s],v,L,Z,Y)===!1)return!1;v++}Y++}Z++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(IE(a.geometries[r],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function S5(t,e={}){if(t.bbox!=null&&e.recompute!==!0)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return IE(t,r=>{n[0]>r[0]&&(n[0]=r[0]),n[1]>r[1]&&(n[1]=r[1]),n[2]<r[0]&&(n[2]=r[0]),n[3]<r[1]&&(n[3]=r[1])}),n}function C5(t,e,n={}){const r={type:"Feature"};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties={},r.geometry=t,r}function PE(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}const T5={},A5={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-x"};function M5(t,e,n,r,i,s){return d.openBlock(),d.createElementBlock("svg",A5,e[0]||(e[0]=[d.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),d.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),d.createElementVNode("path",{d:"M6 6l12 12"},null,-1)]))}const D5=He(T5,[["render",M5]]);function I5(t){const e=[{type:"fill",minzoom:t.pointZoom||0,paint:{"fill-color":t.color||"#ccc","fill-outline-color":t.stroke||"#blue","fill-opacity":t.opacity||1}}];return t.pointZoom&&e.push({type:"circle",maxzoom:t.pointZoom,paint:{"circle-color":t.color||"#ccc","circle-stroke-color":t.stroke||"#ccc","circle-stroke-width":t.width||1,"circle-opacity":t.opacity||1}}),t.label&&e.push({type:"symbol",layout:{"text-field":["get",t.label],"text-font":["Open Sans Regular"],"text-size":12,"text-anchor":"center"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.5}}),e}function P5(t){const e=[{type:"line",paint:{"line-color":t.color||"#ccc","line-opacity":t.opacity||1}}];return t.label&&e.push({type:"symbol",layout:{"text-field":["get",t.label],"text-font":["Open Sans Regular"],"text-size":12,"symbol-placement":"line-center"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.5}}),e}function N5(t){const e=[{type:"circle",maxzoom:t.icon&&+t.iconZoom||22,paint:{"circle-radius":t.radius||6,"circle-stroke-color":t.stroke||"#ccc","circle-stroke-width":t.width||1,"circle-color":t.color||"blue","circle-opacity":t.opacity||1}}];return t!=null&&t.clusterZoom&&(e.push({type:"circle",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#51bbd6",100,"#f1f075",750,"#f28cb1"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}}),e.push({type:"symbol",filter:["has","point_count"],layout:{"text-field":["get","point_count"],"text-font":["Open Sans Regular"],"text-size":12}})),t.icon&&e.push({type:"symbol",minzoom:+t.iconZoom||16,layout:{"icon-image":t.icon,"icon-allow-overlap":!0}}),t.label&&e.push({type:"symbol",layout:{"text-field":["get",t.label],"text-font":["Open Sans Regular"],"text-size":12,"text-anchor":"top"},paint:{"text-color":"#000","text-halo-color":"#fff","text-halo-width":1.5}}),e}function R5(t){if(!t)return null;const e=t.type||"point";return e==="polygon"?I5(t):e==="line"?P5(t):N5(t)}const O5=["#69D2E7","yellow","#FE4365","#125B9A","#41B3A2","#D7C3F1","#F1D3CE"],B5=["ma-star","ma-water","ma-swimming","fa-home","fa-search","fa-trash","fa-check"],NE={};async function RE(t,e){const n=await fetch(`/api/gis-layer/${t}/${e}`),{rows:r}=await n.json();return r}async function mb(t,e,n,r){if(!t)return null;const i=JSON.parse(JSON.stringify(t)),s=i.colorAttr?await RE(e,i.colorAttr):null;s==null||s.forEach((o,p)=>{var g,y;o.color=o.color||((g=i.colorSet)==null?void 0:g[o.id])||((y=i.colorSet)==null?void 0:y[p])||O5[p],o.icon=i.icon?i.icon.split("+")[0]+"+"+o.color.replace("#","")+".png":null});const a=i.iconAttr?await RE(e,i.iconAttr):null;if(a==null||a.forEach((o,p)=>{var T,D,N,B;const g=o.icon||((T=i.iconSet)==null?void 0:T[o.id])||((D=i.iconPattern)==null?void 0:D.replace("{id}",o.id))||((N=i.iconSet)==null?void 0:N[p])||(i.iconPrefix?null:B5[p]);if(!g)return;const y=o.color||((B=i.color)==null?void 0:B.replace("#",""))||"red",[v="pin6",k="m"]=i.icon?i.icon.split("-"):[];o.icon=i.iconPrefix||g!=null&&g.includes("/")?(i.iconPrefix||"")+g:`${v}-${k}-${g}+${y}.png`}),i.colorAttr&&s){const o=["match",["get",i.colorAttr]];s.forEach(p=>{o.push(p.id),o.push(p.color)}),o.push(i.color||"gray"),i.color=o}if(i.icon&&i.iconAttr&&a){const o=["match",["get",i.iconAttr]];a.filter(p=>p.icon).forEach(({id:p,icon:g})=>{if(i.colorAttr&&s){o.push(p);const y=["match",["get",i.colorAttr]];s.forEach(v=>{y.push(v.id);const k=g.split("+")[0]+"+"+v.color.replace("#","")+".png";y.push(k),_d(k,n)}),y.push(i.icon),o.push(y)}else o.push(p),o.push(g),_d(g,n)}),o.push((i.iconPrefix||"")+i.icon),_d((i.iconPrefix||"")+i.icon,n),console.log(o),i.icon=o}else if(i.icon&&i.colorAttr&&s){const o=["match",["get",i.colorAttr]];s.forEach(p=>{o.push(p.id),o.push(p.icon),_d(p.icon,n)}),o.push(i.icon),_d(i.icon,n),i.icon=o}else i.icon&&await _d(i.icon,n);return i.stroke=["case",["boolean",["feature-state","selected"],!1],"#000000",i.stroke||"#000000"],R5(i)}async function _d(t="pin4-sm-mi-plumber+f45942.png",e=null){if(NE[t])return null;NE[t]=!0;const n=await(e==null?void 0:e.loadImage(t!=null&&t.includes("/")?t:`/api/marker_icon/${t.replace(".png","")}.png`));e==null||e.addImage(t,n.data)}const V5={data(){return{layerList:[],activeLayer:""}},computed:{interactiveSources(){return this.layerList.filter(t=>t==null?void 0:t.interactive).map(t=>t.id)}},methods:{moveLayer(t,e=this.map){e.getStyle().layers.forEach(n=>{n.id.match(t)&&e.moveLayer(n.id)})},async setVisible(t,e=!0,n=this.map){if(!t)return;const r=(t==null?void 0:t.id)||t,i=this.layerList.find(a=>a.id===t)||t;if(!(i!=null&&i.id))throw new Error("MixinError: Layer has no id");const s=n.getStyle().layers.filter(a=>a.id.match(r));s.forEach(a=>{n.setLayoutProperty(a.id,"visibility",e?"visible":"none")}),!s.length&&e&&await this.addLayer(i)},async addLayer(t,e=this==null?void 0:this.map){var i,s;const n=this.layerList.find(a=>a.id===t)||t;!this.map.getStyle()||this.map.getStyle().layers.find(a=>a.id===n.id)||(this.layerList.find(a=>a.id===n.id)||this.layerList.push(n),(n.service==="vtile"||n.service==="vector"||(i=n.url)!=null&&i.includes(".vmt"))&&this.addVtileLayer(n,e),n.service==="geojson"&&this.addGeoJsonLayer(n,e),((s=n.url)!=null&&s.includes(".png")||["tms","raster"].includes(n.service))&&await this.addRasterLayer(n,e))},async addRasterLayer(t,e=this==null?void 0:this.map){e.getSource(t.id)||(await e.addSource(t.id,{type:"raster",tiles:[t==null?void 0:t.url],tileSize:256,...t.bounds?{bounds:t.bounds.map(n=>n-0)}:{},...t!=null&&t.scheme?{scheme:t==null?void 0:t.scheme}:{}}),await e.addLayer({id:t.id,type:"raster",source:t.id,minzoom:0,maxzoom:(t==null?void 0:t.maxzoom)||22}))},async updateStyle(t,e=this==null?void 0:this.map){const n=t.id;e.getStyle().layers.forEach(async i=>{i.source===n&&await e.removeLayer(i.id)}),(await mb(t.style,t.source,e)||t.layers||[]).forEach((i,s)=>{const a={...i,id:`${t.id}-${s}`,source:t.id,"source-layer":i["source-layer"]||t.source||t.id,maxzoom:+i.maxzoom||24,minzoom:+i.minzoom||0};e.addLayer(a)})},async addVtileLayer(t,e=this==null?void 0:this.map){var a;const n=["props","pointZoom","nocache"].filter(o=>t.style[o]).map(o=>{var p;return`&${o}=${(p=t.style)==null?void 0:p[o]}`}),r=new Date().toISOString().split("T")[0],i={type:"vector",tiles:[`${(a=t==null?void 0:t.url)!=null&&a.startsWith("http")?"":window.location.origin}${t==null?void 0:t.url}?dt=${r}${n}`],minzoom:t.minzoom||5,maxzoom:t.maxzoom||24};e.addSource(t.id,i),(t.layers||await mb(t.style,t.source||t.id,e)||[]).forEach((o,p)=>{const g={...o,id:`${t.id}-${p}`,source:t.id,"source-layer":o["source-layer"]||t.source||t.id,maxzoom:+o.maxzoom||24,minzoom:+o.minzoom||0};e.addLayer(g)})},async addGeoJsonLayer(t,e=this.map){var i;const n=t.data||((i=t==null?void 0:t.url)!=null&&i.startsWith("http")?"":window.location.origin)+t.url;e.addSource(t.id,{type:"geojson",data:n}),(await mb(t.style,n.source,e)||t.layers||[]).forEach(s=>{const a={...s,source:t.id,id:s.id||t.id,maxzoom:+s.maxzoom||24,minzoom:+s.minzoom||0,type:s.type||"circle"};e.addLayer(a)})},setLayerData(t,e){this.layerList=this.layerList.map(n=>n.id===t?{...n,...e}:n)},async removeLayer(t,e=this.map){e.getSource(t)&&(await e.getStyle().layers.forEach(async n=>{n.source===t&&await e.removeLayer(n.id)}),await e.removeSource(t))},async setFilter(t,e){const n=this.layerList.find(i=>i.id===t),r=await this.map.getSource(t);if(n.service==="vtile"){await r.setTiles([`${window.location.origin}${n.url}${n.url.includes("?")?"&":"?"}filter=${e}${n.props?`&props=${n.props}`:""}`]);return}n.service},async changeBaseLayer(t){t!==this.activeLayer&&(this.activeLayer&&this.map.setLayoutProperty(this.activeLayer,"visibility","none"),await this.setVisible(this.activeLayer,!1),await this.setVisible(t,!0),this.map.getStyle().layers.forEach(e=>{e.source!==t&&e.type!=="background"&&this.map.moveLayer(e.id)}),this.activeLayer=t)},async refreshLayer(t,e=this.map){await e.getStyle().layers.forEach(n=>{n.source===t&&e.removeLayer(n.id)}),await e.removeSource(t),this.setVisible(t)},addGeom(t,e={}){if(!this.map)return;const n={type:"FeatureCollection",features:[{type:"Feature",geometry:t.geometry,properties:{id:t.id,name:t==null?void 0:t.text}}]};if(this.map.getSource(t.id))this.map.getSource(t.id).setData(n);else{this.map.addSource(t.id,{type:"geojson",data:n});const r=t.geometry.type;let i={};switch(r){case"Point":i={"circle-color":e.color||"#ff0000","circle-radius":e.radius||5,"circle-opacity":e.opacity||1},this.map.addLayer({id:t.id,type:"circle",source:t.id,paint:i});break;case"LineString":i={"line-color":e.color||"#0000ff","line-width":e.width||2,"line-opacity":e.opacity||1},this.map.addLayer({id:t.id,type:"line",source:t.id,paint:i});break;case"Polygon":this.map.addLayer({id:t.id,type:"fill",source:t.id,paint:{"fill-color":e.color||"#00ff00","fill-opacity":e.opacity||.5}}),this.map.addLayer({id:`${t.id}-outline`,type:"line",source:t.id,paint:{"line-color":e.color||"#00ff00","line-width":e.width||2,"line-opacity":.8}});break;default:console.warn(`Unsupported geometry type: ${r}`);return}}},removeGeom(t){this.map&&(this.map.getLayer(t)&&this.map.removeLayer(t),this.map.getLayer(`${t}-outline`)&&this.map.removeLayer(`${t}-outline`),this.map.getSource(t)&&this.map.removeSource(t))}}},{Map:z5}=pm,yr="widget-map-source",L5={mixins:[V5],props:{geometry:{type:Object,default:()=>null},zoom:{type:Number,default:()=>{var t,e;return((e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)==null?void 0:e.zoom)||10}},center:{type:Array,default:()=>{var t,e;return((e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)==null?void 0:e.center)||[30.5,50.45]}},height:{type:String,default:"400px"},layers:{type:Array,default:()=>{var t,e;return((e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)==null?void 0:e.layers)||[]}},card:{type:Boolean,default:!1}},data(){return{cardData:null,cardPosition:{top:"0px",right:"0px",left:"0px"},map:null,mapId:`gis-map-${Math.floor(Math.random()*1e3)}`,isOpen:!1,selectedBaseLayer:"topo100",isGeometryVisible:!0,localLayers:[],idleEventWorked:!1,selectedLayers:[],baseLayers:[{id:"topo100",name:"Карта України",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png"},{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS"},{id:"osmb",name:"Open Street Map",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",service:"TMS"}]}},mounted(){window.addEventListener("resize",this.updateCardPosition),this.updateCardPosition(),this.localLayers=this.layers,this.initMap()},components:{IconClose:D5},beforeUnmount(){window.removeEventListener("resize",this.updateCardPosition)},watch:{selectedLayers:{handler(){this.selectedLayers.forEach(t=>{this.map.getSource(t)&&this.map.getStyle().layers.forEach(n=>{n.source===t&&this.map.moveLayer(n.id)}),[`${yr}-polygon`,`${yr}-polygon-line`,`${yr}-line`,`${yr}-point`].forEach(n=>{this.map.getLayer(n)&&this.map.moveLayer(n)}),this.map.getLayer("selected-feature")&&this.map.moveLayer("selected-feature")})},immediate:!0},geometry(){this.initGeometryLayer()},layers:{handler(t){t&&!this.layers.length&&(this.localLayers=t)},deep:!0,immediate:!0}},methods:{updateCardPosition(){this.$nextTick(()=>{if(this.$refs.relativeContainer){const t=this.$refs.relativeContainer.getBoundingClientRect();this.cardPosition.top=`${t.top+10}`,this.cardPosition.right=`${t.right+10}`,this.cardPosition.left=`${t.left+10}`}})},initMap(){const t={version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=new z5({container:this.mapId,style:t,center:this.center,zoom:this.zoom,interactive:!0}),window==null||window.addEventListener("resize",()=>{this.map.resize()}),this.map.on("load",this.onMapLoad)},async onMapLoad(){var t,e,n,r,i,s,a,o;this.map.resize(),this.map.doubleClickZoom.disable(),(e=(t=Tt==null?void 0:Tt.value)==null?void 0:t.geom)!=null&&e.bounds&&this.map.fitBounds(Tt.value.geom.bounds,{padding:20,duration:0}),(r=(n=Tt==null?void 0:Tt.value)==null?void 0:n.geom)!=null&&r.zoom&&this.map.setZoom(Tt.value.geom.zoom),this.changeBaseLayer(this.getLayerById(this.selectedBaseLayer)),this.localLayers.forEach(async p=>{p.enabled&&(await this.setLayerVisible(p,!0),this.selectedLayers.push(p.id))}),this.geometry&&this.initGeometryLayer(),(s=(i=Tt==null?void 0:Tt.value)==null?void 0:i.geom)!=null&&s.katottg&&await this.createAtuLayer((o=(a=Tt==null?void 0:Tt.value)==null?void 0:a.geom)==null?void 0:o.katottg),this.map.on("idle",()=>{this.idleEventWorked||this.selectedLayers.forEach(p=>{this.map.getSource(p)&&this.map.getStyle().layers.forEach(y=>{y.source===p&&this.map.moveLayer(y.id)}),[`${yr}-polygon`,`${yr}-polygon-line`,`${yr}-line`,`${yr}-point`].forEach(y=>{this.map.getLayer(y)&&this.map.moveLayer(y)})}),this.idleEventWorked=!0}),this.card&&this.map.on("click",async p=>{debugger;const g=this.map.queryRenderedFeatures(p.point);if(!g.length)return;const y=g.filter(v=>!v.source.includes(yr));if(y.length)try{const v=y.map(T=>Ue.get(`/api/gis-format-admin?table=${T.sourceLayer}&id=${T.properties.id}`)),k=await Promise.all(v);this.cardData=k.map(T=>T.data)}catch(v){console.error("Помилка при отриманні даних",v)}})},async createAtuLayer(t){try{const{map:e}=this;if(!e)return;const{data:n}=await Ue.get(`https://data.gki.com.ua/api-user/atu/${t}`);e.addSource("atu",{type:"geojson",data:n}),e.addLayer({id:"atu",type:"line",source:"atu",paint:{"line-color":"#3b82f6","line-width":2}})}catch(e){console.error(e)}},changeBaseLayer(t){const e="base-layer",n="base-layer";if(!this.map.getSource(e))this.map.addSource(e,{type:"raster",tiles:[t.url],tileSize:256}),this.map.addLayer({id:n,type:"raster",source:e});else{const r=this.map.getSource(e);r&&(r.tiles=[t.url],this.map.style.sourceCaches[e].clearTiles(),this.map.style.sourceCaches[e].update(this.map.transform),this.map.triggerRepaint())}},getLayerById(t){return this.baseLayers.find(e=>e.id===t)},initGeometryLayer(){const{map:t}=this;if(!t)return;const e=this.formatGeojson(this.geometry),n=t.getSource(yr);if(this.zoomToGeometry(e),n){n.setData(e);return}t.addSource(yr,{type:"geojson",data:e}),t.addLayer({id:`${yr}-point`,type:"circle",source:yr,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),t.addLayer({id:`${yr}-polygon`,type:"fill",source:yr,layout:{},paint:{"fill-color":"#4b0082","fill-opacity":.3},filter:["==","$type","Polygon"]}),t.addLayer({id:`${yr}-polygon-line`,type:"line",source:yr,layout:{},paint:{"line-color":"#4b0082","line-width":2},filter:["==","$type","Polygon"]}),t.addLayer({id:`${yr}-line`,type:"line",source:yr,layout:{},paint:{"line-color":"#4b0082","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(t){let e=t;const n=t==null?void 0:t.type;if(Array.isArray(t))return PE(t);if(!n)throw new Error("Unknown geometry type!");return n==="FeatureCollection"?t:(n==="Feature"&&(e=[t]),!["FeatureCollection","Feature"].includes(n)&&(e=[C5(t)]),PE(e))},zoomToGeometry(t){const{map:e}=this,n=S5(t);e.fitBounds(n,{zoom:this.zoom,padding:30,duration:0})},toggleGeometryVisibility(){[`${yr}-polygon`,`${yr}-polygon-line`,`${yr}-line`,`${yr}-point`].forEach(e=>{this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility",this.isGeometryVisible?"visible":"none")})},async setLayerVisible(t,e){await this.setVisible(t,e,this.map)},closeCard(){this.cardData=null,this.removeGeom("selected-feature")}}},F5={key:1,class:"bg-white absolute top-[10px] right-[10px] z-20 border rounded-lg cursor-pointer"},$5={class:"flex items-center justify-between p-2 border-b"},j5={class:"flex items-center"},H5=["value","onChange"],U5={class:"ml-2"},W5={key:0,class:"p-2 border-b"},q5={class:"flex items-center"},G5=["value","onChange"],Y5={class:"ml-2"},Z5={key:1,class:"p-2"},X5={class:"flex items-center"},K5=["id"];function J5(t,e,n,r,i,s){var o;const a=d.resolveComponent("IconClose");return d.openBlock(),d.createElementBlock("div",{class:"relative",ref:"relativeContainer",onClick:e[6]||(e[6]=(...p)=>s.updateCardPosition&&s.updateCardPosition(...p))},[d.createTextVNode(d.toDisplayString(n.zoom)+" ",1),i.isOpen?(d.openBlock(),d.createElementBlock("div",F5,[d.createElementVNode("div",$5,[e[7]||(e[7]=d.createElementVNode("div",null,"Шари",-1)),d.createVNode(a,{onClick:e[1]||(e[1]=p=>i.isOpen=!1),class:"w-4 h-4"})]),d.createElementVNode("div",{class:d.normalizeClass(["p-2 border-b",{"border-b":n.geometry}])},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.baseLayers,p=>(d.openBlock(),d.createElementBlock("div",{key:p.id},[d.createElementVNode("label",j5,[d.withDirectives(d.createElementVNode("input",{type:"radio",name:"base-layer",value:p.id,"onUpdate:modelValue":e[2]||(e[2]=g=>i.selectedBaseLayer=g),onChange:g=>s.changeBaseLayer(p)},null,40,H5),[[d.vModelRadio,i.selectedBaseLayer]]),d.createElementVNode("span",U5,d.toDisplayString(p.name),1)])]))),128))],2),(o=i.localLayers)!=null&&o.length?(d.openBlock(),d.createElementBlock("div",W5,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.localLayers,p=>(d.openBlock(),d.createElementBlock("div",{key:p.id},[d.createElementVNode("label",q5,[d.withDirectives(d.createElementVNode("input",{type:"checkbox",value:p.id,"onUpdate:modelValue":e[3]||(e[3]=g=>i.selectedLayers=g),onChange:g=>s.setLayerVisible(p,g.target.checked)},null,40,G5),[[d.vModelCheckbox,i.selectedLayers]]),d.createElementVNode("span",Y5,d.toDisplayString(p.name),1)])]))),128))])):d.createCommentVNode("",!0),n.geometry?(d.openBlock(),d.createElementBlock("div",Z5,[d.createElementVNode("label",X5,[d.withDirectives(d.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":e[4]||(e[4]=p=>i.isGeometryVisible=p),onChange:e[5]||(e[5]=(...p)=>s.toggleGeometryVisibility&&s.toggleGeometryVisibility(...p))},null,544),[[d.vModelCheckbox,i.isGeometryVisible]]),e[8]||(e[8]=d.createElementVNode("span",{class:"ml-2"},"Показати геометрію",-1))])])):d.createCommentVNode("",!0)])):(d.openBlock(),d.createElementBlock("div",{key:0,class:"bg-white absolute top-[10px] right-[10px] z-[1] p-2 border rounded-lg cursor-pointer",onClick:e[0]||(e[0]=p=>i.isOpen=!0)}," Шари ")),d.createElementVNode("div",{id:i.mapId,style:d.normalizeStyle({height:n.height})},null,12,K5),d.renderSlot(t.$slots,"card",{map:i.map,cardData:i.cardData,cardPosition:i.cardPosition,closeCard:s.closeCard})],512)}const gb=He(L5,[["render",J5]]),mt=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),yb=function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY,r=n.indexOf("hidden")!==-1,i=n.indexOf("visible")!==-1;return e&&!r&&!i},mm=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(yb(t)?t:mm(t.parentElement,e))},wo=function(t){var e=new DOMParser().parseFromString(t,"text/html").body;if(e.childElementCount>1){for(var n=document.createElement("div");e.firstChild;)n.appendChild(e.firstChild);return n}return e.firstChild},bb=t=>`${t||""}`.split(" ").filter(e=>!!e),ko=(t,e,n)=>{t&&bb(e).forEach(r=>{t.classList.toggle(r,n||!1)})};let xd=class{constructor(e){Object.defineProperty(this,"pageX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pageY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativePointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=e,this.pageX=e.pageX,this.pageY=e.pageY,this.clientX=e.clientX,this.clientY=e.clientY,this.id=self.Touch&&e instanceof Touch?e.identifier:-1,this.time=Date.now()}};const vd={passive:!1};let Q5=class{constructor(e,{start:n=()=>!0,move:r=()=>{},end:i=()=>{}}){Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"moveCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"currentPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"startPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=e,this.startCallback=n,this.moveCallback=r,this.endCallback=i;for(const s of["onPointerStart","onTouchStart","onMove","onTouchEnd","onPointerEnd","onWindowBlur"])this[s]=this[s].bind(this);this.element.addEventListener("mousedown",this.onPointerStart,vd),this.element.addEventListener("touchstart",this.onTouchStart,vd),this.element.addEventListener("touchmove",this.onMove,vd),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(e){if(!e.buttons||e.button!==0)return;const n=new xd(e);this.currentPointers.some(r=>r.id===n.id)||this.triggerPointerStart(n,e)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(e){for(const n of Array.from(e.changedTouches||[]))this.triggerPointerStart(new xd(n),e);window.addEventListener("blur",this.onWindowBlur)}onMove(e){const n=this.currentPointers.slice(),r="changedTouches"in e?Array.from(e.changedTouches||[]).map(s=>new xd(s)):[new xd(e)],i=[];for(const s of r){const a=this.currentPointers.findIndex(o=>o.id===s.id);a<0||(i.push(s),this.currentPointers[a]=s)}i.length&&this.moveCallback(e,this.currentPointers.slice(),n)}onPointerEnd(e){e.buttons>0&&e.button!==0||(this.triggerPointerEnd(e,new xd(e)),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur))}onTouchEnd(e){for(const n of Array.from(e.changedTouches||[]))this.triggerPointerEnd(e,new xd(n))}triggerPointerStart(e,n){return!!this.startCallback(n,e,this.currentPointers.slice())&&(this.currentPointers.push(e),this.startPointers.push(e),!0)}triggerPointerEnd(e,n){const r=this.currentPointers.findIndex(i=>i.id===n.id);r<0||(this.currentPointers.splice(r,1),this.startPointers.splice(r,1),this.endCallback(e,n,this.currentPointers.slice()))}onWindowBlur(){this.clear()}clear(){for(;this.currentPointers.length;){const e=this.currentPointers[this.currentPointers.length-1];this.currentPointers.splice(this.currentPointers.length-1,1),this.startPointers.splice(this.currentPointers.length-1,1),this.endCallback(new Event("touchend",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY}),e,this.currentPointers.slice())}}stop(){this.element.removeEventListener("mousedown",this.onPointerStart,vd),this.element.removeEventListener("touchstart",this.onTouchStart,vd),this.element.removeEventListener("touchmove",this.onMove,vd),this.element.removeEventListener("touchend",this.onTouchEnd),this.element.removeEventListener("touchcancel",this.onTouchEnd),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur)}};function OE(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function BE(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const _b=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.prototype.toString.call(t)==="[object Object]",Zi=(t,...e)=>{const n=e.length;for(let r=0;r<n;r++){const i=e[r]||{};Object.entries(i).forEach(([s,a])=>{const o=Array.isArray(a)?[]:{};t[s]||Object.assign(t,{[s]:o}),_b(a)?Object.assign(t[s],Zi(o,a)):Array.isArray(a)?Object.assign(t,{[s]:[...a]}):Object.assign(t,{[s]:a})})}return t},xb=function(t,e){return t.split(".").reduce((n,r)=>typeof n=="object"?n[r]:void 0,e)};let gm=class{constructor(e={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(e);for(const n of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))n.startsWith("on")&&typeof this[n]=="function"&&(this[n]=this[n].bind(this))}setOptions(e){this.options=e?Zi({},this.constructor.defaults,e):{};for(const[n,r]of Object.entries(this.option("on")||{}))this.on(n,r)}option(e,...n){let r=xb(e,this.options);return r&&typeof r=="function"&&(r=r.call(this,this,...n)),r}optionFor(e,n,r,...i){let s=xb(n,e);var a;typeof(a=s)!="string"||isNaN(a)||isNaN(parseFloat(a))||(s=parseFloat(s)),s==="true"&&(s=!0),s==="false"&&(s=!1),s&&typeof s=="function"&&(s=s.call(this,this,e,...i));let o=xb(n,this.options);return o&&typeof o=="function"?s=o.call(this,this,e,...i,s):s===void 0&&(s=o),s===void 0?r:s}cn(e){const n=this.options.classes;return n&&n[e]||""}localize(e,n=[]){e=String(e).replace(/\{\{(\w+).?(\w+)?\}\}/g,(r,i,s)=>{let a="";return s?a=this.option(`${i[0]+i.toLowerCase().substring(1)}.l10n.${s}`):i&&(a=this.option(`l10n.${i}`)),a||(a=r),a});for(let r=0;r<n.length;r++)e=e.split(n[r][0]).join(n[r][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(r,i)=>i)}on(e,n){let r=[];typeof e=="string"?r=e.split(" "):Array.isArray(e)&&(r=e),this.events||(this.events=new Map),r.forEach(i=>{let s=this.events.get(i);s||(this.events.set(i,[]),s=[]),s.includes(n)||s.push(n),this.events.set(i,s)})}off(e,n){let r=[];typeof e=="string"?r=e.split(" "):Array.isArray(e)&&(r=e),r.forEach(i=>{const s=this.events.get(i);if(Array.isArray(s)){const a=s.indexOf(n);a>-1&&s.splice(a,1)}})}emit(e,...n){[...this.events.get(e)||[]].forEach(r=>r(this,...n)),e!=="*"&&this.emit("*",e,...n)}};Object.defineProperty(gm,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(gm,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});let vb=class extends gm{constructor(e={}){super(e),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(e={}){const n=new Map;for(const[r,i]of Object.entries(e)){const s=this.option(r),a=this.plugins[r];a||s===!1?a&&s===!1&&(a.detach(),delete this.plugins[r]):n.set(r,new i(this,s||{}))}for(const[r,i]of n)this.plugins[r]=i,i.attach()}detachPlugins(e){e=e||Object.keys(this.plugins);for(const n of e){const r=this.plugins[n];r&&r.detach(),delete this.plugins[n]}return this.emit("detachPlugins"),this}};var Hn;(function(t){t[t.Init=0]="Init",t[t.Error=1]="Error",t[t.Ready=2]="Ready",t[t.Panning=3]="Panning",t[t.Mousemove=4]="Mousemove",t[t.Destroy=5]="Destroy"})(Hn||(Hn={}));const ta=["a","b","c","d","e","f"],VE={PANUP:"Move up",PANDOWN:"Move down",PANLEFT:"Move left",PANRIGHT:"Move right",ZOOMIN:"Zoom in",ZOOMOUT:"Zoom out",TOGGLEZOOM:"Toggle zoom level",TOGGLE1TO1:"Toggle zoom level",ITERATEZOOM:"Toggle zoom level",ROTATECCW:"Rotate counterclockwise",ROTATECW:"Rotate clockwise",FLIPX:"Flip horizontally",FLIPY:"Flip vertically",FITX:"Fit horizontally",FITY:"Fit vertically",RESET:"Reset",TOGGLEFS:"Toggle fullscreen"},e3={content:null,width:"auto",height:"auto",panMode:"drag",touch:!0,dragMinThreshold:3,lockAxis:!1,mouseMoveFactor:1,mouseMoveFriction:.12,zoom:!0,pinchToZoom:!0,panOnlyZoomed:"auto",minScale:1,maxScale:2,friction:.25,dragFriction:.35,decelFriction:.05,click:"toggleZoom",dblClick:!1,wheel:"zoom",wheelLimit:7,spinner:!0,bounds:"auto",infinite:!1,rubberband:!0,bounce:!0,maxVelocity:75,transformParent:!1,classes:{content:"f-panzoom__content",isLoading:"is-loading",canZoomIn:"can-zoom_in",canZoomOut:"can-zoom_out",isDraggable:"is-draggable",isDragging:"is-dragging",inFullscreen:"in-fullscreen",htmlHasFullscreen:"with-panzoom-in-fullscreen"},l10n:VE},zE='<circle cx="25" cy="25" r="20"></circle>',wb='<div class="f-spinner"><svg viewBox="0 0 50 50">'+zE+zE+"</svg></div>",Xi=t=>t&&t!==null&&t instanceof Element&&"nodeType"in t,Ln=(t,e)=>{t&&bb(e).forEach(n=>{t.classList.remove(n)})},Ot=(t,e)=>{t&&bb(e).forEach(n=>{t.classList.add(n)})},ym={a:1,b:0,c:0,d:1,e:0,f:0},t3=1e5,bm=1e4,Vs="mousemove",LE="drag",FE="content",zs="auto";let kb=null,Eb=null,wd=class yN extends vb{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return Eb===null&&(Eb=window.matchMedia("(hover: none)").matches),Eb}get isMobile(){return kb===null&&(kb=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),kb}get panMode(){return this.options.panMode!==Vs||this.isTouchDevice?LE:Vs}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===zs?this.isTouchDevice:e}get isInfinite(){return this.option("infinite")}get angle(){return 180*Math.atan2(this.current.b,this.current.a)/Math.PI||0}get targetAngle(){return 180*Math.atan2(this.target.b,this.target.a)/Math.PI||0}get scale(){const{a:e,b:n}=this.current;return Math.sqrt(e*e+n*n)||1}get targetScale(){const{a:e,b:n}=this.target;return Math.sqrt(e*e+n*n)||1}get minScale(){return this.option("minScale")||1}get fullScale(){const{contentRect:e}=this;return e.fullWidth/e.fitWidth||1}get maxScale(){return this.fullScale*(this.option("maxScale")||1)||1}get coverScale(){const{containerRect:e,contentRect:n}=this,r=Math.max(e.height/n.fitHeight,e.width/n.fitWidth)||1;return Math.min(this.fullScale,r)}get isScaling(){return Math.abs(this.targetScale-this.scale)>1e-5&&!this.isResting}get isContentLoading(){const e=this.content;return!!(e&&e instanceof HTMLImageElement)&&!e.complete}get isResting(){if(this.isBouncingX||this.isBouncingY)return!1;for(const e of ta){const n=e=="e"||e==="f"?1e-4:1e-5;if(Math.abs(this.target[e]-this.current[e])>n)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(e,n={},r={}){var i;if(super(n),Object.defineProperty(this,"pointerTracker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"resizeObserver",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"updateTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"clickTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rAF",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isTicking",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreBounds",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingX",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingY",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"clicks",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"trackingPoints",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pwt",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"cwd",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pmme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"friction",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Hn.Init}),Object.defineProperty(this,"isDragging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"spinner",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"containerRect",{enumerable:!0,configurable:!0,writable:!0,value:{width:0,height:0,innerWidth:0,innerHeight:0}}),Object.defineProperty(this,"contentRect",{enumerable:!0,configurable:!0,writable:!0,value:{top:0,right:0,bottom:0,left:0,fullWidth:0,fullHeight:0,fitWidth:0,fitHeight:0,width:0,height:0}}),Object.defineProperty(this,"dragStart",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,top:0,left:0,time:0}}),Object.defineProperty(this,"dragOffset",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,time:0}}),Object.defineProperty(this,"current",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},ym)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},ym)}),Object.defineProperty(this,"velocity",{enumerable:!0,configurable:!0,writable:!0,value:{a:0,b:0,c:0,d:0,e:0,f:0}}),Object.defineProperty(this,"lockedAxis",{enumerable:!0,configurable:!0,writable:!0,value:!1}),!e)throw new Error("Container Element Not Found");this.container=e,this.initContent(),this.attachPlugins(Object.assign(Object.assign({},yN.Plugins),r)),this.emit("attachPlugins"),this.emit("init");const s=this.content;if(s.addEventListener("load",this.onLoad),s.addEventListener("error",this.onError),this.isContentLoading){if(this.option("spinner")){e.classList.add(this.cn("isLoading"));const a=wo(wb);!e.contains(s)||s.parentElement instanceof HTMLPictureElement?this.spinner=e.appendChild(a):this.spinner=((i=s.parentElement)===null||i===void 0?void 0:i.insertBefore(a,s))||null}this.emit("beforeLoad")}else queueMicrotask(()=>{this.enable()})}initContent(){const{container:e}=this,n=this.cn(FE);let r=this.option(FE)||e.querySelector(`.${n}`);if(r||(r=e.querySelector("img,picture")||e.firstElementChild,r&&Ot(r,n)),r instanceof HTMLPictureElement&&(r=r.querySelector("img")),!r)throw new Error("No content found");this.content=r}onLoad(){const{spinner:e,container:n,state:r}=this;e&&(e.remove(),this.spinner=null),this.option("spinner")&&n.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),r===Hn.Init?this.enable():this.updateMetrics()}onError(){this.state!==Hn.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=Hn.Error,this.emit("error"))}getNextScale(e){const{fullScale:n,targetScale:r,coverScale:i,maxScale:s,minScale:a}=this;let o=a;switch(e){case"toggleMax":o=r-a<.5*(s-a)?s:a;break;case"toggleCover":o=r-a<.5*(i-a)?i:a;break;case"toggleZoom":o=r-a<.5*(n-a)?n:a;break;case"iterateZoom":let p=[1,n,s].sort((y,v)=>y-v),g=p.findIndex(y=>y>r+1e-5);o=p[g]||1}return o}attachObserver(){var e;const n=()=>{const{container:r,containerRect:i}=this;return Math.abs(i.width-r.getBoundingClientRect().width)>.1||Math.abs(i.height-r.getBoundingClientRect().height)>.1};this.resizeObserver||window.ResizeObserver===void 0||(this.resizeObserver=new ResizeObserver(()=>{this.updateTimer||(n()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout(()=>{n()&&this.onResize(),this.updateTimer=null},500))):this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null))})),(e=this.resizeObserver)===null||e===void 0||e.observe(this.container)}detachObserver(){var e;(e=this.resizeObserver)===null||e===void 0||e.disconnect()}attachEvents(){const{container:e}=this;e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("wheel",this.onWheel,{passive:!1}),this.pointerTracker=new Q5(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(Vs,this.onMouseMove)}detachEvents(){var e;const{container:n}=this;n.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),n.removeEventListener("wheel",this.onWheel,{passive:!1}),(e=this.pointerTracker)===null||e===void 0||e.stop(),this.pointerTracker=null,document.removeEventListener(Vs,this.onMouseMove),document.removeEventListener("keydown",this.onKeydown,!0),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}animate(){this.setTargetForce();const e=this.friction,n=this.option("maxVelocity");for(const r of ta)e?(this.velocity[r]*=1-e,n&&!this.isScaling&&(this.velocity[r]=Math.max(Math.min(this.velocity[r],n),-1*n)),this.current[r]+=this.velocity[r]):this.current[r]=this.target[r];this.setTransform(),this.setEdgeForce(),!this.isResting||this.isDragging?this.rAF=requestAnimationFrame(()=>this.animate()):this.stop("current")}setTargetForce(){for(const e of ta)e==="e"&&this.isBouncingX||e==="f"&&this.isBouncingY||(this.velocity[e]=(1/(1-this.friction)-1)*(this.target[e]-this.current[e]))}checkBounds(e=0,n=0){const{current:r}=this,i=r.e+e,s=r.f+n,a=this.getBounds(),{x:o,y:p}=a,g=o.min,y=o.max,v=p.min,k=p.max;let T=0,D=0;return g!==1/0&&i<g?T=g-i:y!==1/0&&i>y&&(T=y-i),v!==1/0&&s<v?D=v-s:k!==1/0&&s>k&&(D=k-s),Math.abs(T)<1e-4&&(T=0),Math.abs(D)<1e-4&&(D=0),Object.assign(Object.assign({},a),{xDiff:T,yDiff:D,inBounds:!T&&!D})}clampTargetBounds(){const{target:e}=this,{x:n,y:r}=this.getBounds();n.min!==1/0&&(e.e=Math.max(e.e,n.min)),n.max!==1/0&&(e.e=Math.min(e.e,n.max)),r.min!==1/0&&(e.f=Math.max(e.f,r.min)),r.max!==1/0&&(e.f=Math.min(e.f,r.max))}calculateContentDim(e=this.current){const{content:n,contentRect:r}=this,{fitWidth:i,fitHeight:s,fullWidth:a,fullHeight:o}=r;let p=a,g=o;if(this.option("zoom")||this.angle!==0){const y=!(n instanceof HTMLImageElement)&&(window.getComputedStyle(n).maxWidth==="none"||window.getComputedStyle(n).maxHeight==="none"),v=y?a:i,k=y?o:s,T=this.getMatrix(e),D=new DOMPoint(0,0).matrixTransform(T),N=new DOMPoint(0+v,0).matrixTransform(T),B=new DOMPoint(0+v,0+k).matrixTransform(T),L=new DOMPoint(0,0+k).matrixTransform(T),U=Math.abs(B.x-D.x),Z=Math.abs(B.y-D.y),Y=Math.abs(L.x-N.x),he=Math.abs(L.y-N.y);p=Math.max(U,Y),g=Math.max(Z,he)}return{contentWidth:p,contentHeight:g}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===Vs||this.targetScale<this.scale)return this.isBouncingX=!1,void(this.isBouncingY=!1);const{target:e}=this,{x:n,y:r,xDiff:i,yDiff:s}=this.checkBounds(),a=this.option("maxVelocity");let o=this.velocity.e,p=this.velocity.f;i!==0?(this.isBouncingX=!0,i*o<=0?o+=.14*i:(o=.14*i,n.min!==1/0&&(this.target.e=Math.max(e.e,n.min)),n.max!==1/0&&(this.target.e=Math.min(e.e,n.max))),a&&(o=Math.max(Math.min(o,a),-1*a))):this.isBouncingX=!1,s!==0?(this.isBouncingY=!0,s*p<=0?p+=.14*s:(p=.14*s,r.min!==1/0&&(this.target.f=Math.max(e.f,r.min)),r.max!==1/0&&(this.target.f=Math.min(e.f,r.max))),a&&(p=Math.max(Math.min(p,a),-1*a))):this.isBouncingY=!1,this.isBouncingX&&(this.velocity.e=o),this.isBouncingY&&(this.velocity.f=p)}enable(){const{content:e}=this,n=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const r of ta)this.current[r]=this.target[r]=n[r];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=Hn.Ready,this.emit("ready")}onClick(e){var n;e.type==="click"&&e.detail===0&&(this.dragOffset.x=0,this.dragOffset.y=0),this.isDragging&&((n=this.pointerTracker)===null||n===void 0||n.clear(),this.trackingPoints=[],this.startDecelAnim());const r=e.target;if(!r||e.defaultPrevented)return;if(r.hasAttribute("disabled"))return e.preventDefault(),void e.stopPropagation();if((()=>{const T=window.getSelection();return T&&T.type==="Range"})()&&!r.closest("button"))return;const i=r.closest("[data-panzoom-action]"),s=r.closest("[data-panzoom-change]"),a=i||s,o=a&&Xi(a)?a.dataset:null;if(o){const T=o.panzoomChange,D=o.panzoomAction;if((T||D)&&e.preventDefault(),T){let N={};try{N=JSON.parse(T)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(N)}if(D)return void(this[D]&&this[D]())}if(Math.abs(this.dragOffset.x)>3||Math.abs(this.dragOffset.y)>3)return e.preventDefault(),void e.stopPropagation();if(r.closest("[data-fancybox]"))return;const p=this.content.getBoundingClientRect(),g=this.dragStart;if(g.time&&!this.canZoomOut()&&(Math.abs(p.x-g.x)>2||Math.abs(p.y-g.y)>2))return;this.dragStart.time=0;const y=T=>{this.option("zoom",e)&&T&&typeof T=="string"&&/(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(T)&&typeof this[T]=="function"&&(e.preventDefault(),this[T]({event:e}))},v=this.option("click",e),k=this.option("dblClick",e);k?(this.clicks++,this.clicks==1&&(this.clickTimer=setTimeout(()=>{this.clicks===1?(this.emit("click",e),!e.defaultPrevented&&v&&y(v)):(this.emit("dblClick",e),e.defaultPrevented||y(k)),this.clicks=0,this.clickTimer=null},350))):(this.emit("click",e),!e.defaultPrevented&&v&&y(v))}addTrackingPoint(e){const n=this.trackingPoints.filter(r=>r.time>Date.now()-100);n.push(e),this.trackingPoints=n}onPointerDown(e,n,r){var i;if(this.option("touch",e)===!1)return!1;this.pwt=0,this.dragOffset={x:0,y:0,time:0},this.trackingPoints=[];const s=this.content.getBoundingClientRect();if(this.dragStart={x:s.x,y:s.y,top:s.top,left:s.left,time:Date.now()},this.clickTimer)return!1;if(this.panMode===Vs&&this.targetScale>1)return e.preventDefault(),e.stopPropagation(),!1;const a=e.composedPath()[0];if(!r.length){if(["TEXTAREA","OPTION","INPUT","SELECT","VIDEO","IFRAME"].includes(a.nodeName)||a.closest("[contenteditable],[data-selectable],[data-draggable],[data-clickable],[data-panzoom-change],[data-panzoom-action]"))return!1;(i=window.getSelection())===null||i===void 0||i.removeAllRanges()}if(e.type==="mousedown")["A","BUTTON"].includes(a.nodeName)||e.preventDefault();else if(Math.abs(this.velocity.a)>.3)return!1;return this.target.e=this.current.e,this.target.f=this.current.f,this.stop(),this.isDragging||(this.isDragging=!0,this.addTrackingPoint(n),this.emit("touchStart",e)),!0}onPointerMove(e,n,r){if(this.option("touch",e)===!1||!this.isDragging||n.length<2&&this.panOnlyZoomed&&mt(this.targetScale)<=mt(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(n[0]);const{content:i}=this,s=BE(r[0],r[1]),a=BE(n[0],n[1]);let o=0,p=0;if(n.length>1){const Z=i.getBoundingClientRect();o=s.clientX-Z.left-.5*Z.width,p=s.clientY-Z.top-.5*Z.height}const g=OE(r[0],r[1]),y=OE(n[0],n[1]);let v=g?y/g:1,k=a.clientX-s.clientX,T=a.clientY-s.clientY;this.dragOffset.x+=k,this.dragOffset.y+=T,this.dragOffset.time=Date.now()-this.dragStart.time;let D=mt(this.targetScale)===mt(this.minScale)&&this.option("lockAxis");if(D&&!this.lockedAxis)if(D==="xy"||D==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const Z=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=Z>45&&Z<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,k=0,T=0}else this.lockedAxis=D;if(mm(e.target,this.content)&&(D="x",this.dragOffset.y=0),D&&D!=="xy"&&this.lockedAxis!==D&&mt(this.targetScale)===mt(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const N=this.checkBounds(k,T);this.option("rubberband")?(this.isInfinite!=="x"&&(N.xDiff>0&&k<0||N.xDiff<0&&k>0)&&(k*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*N.xDiff))),this.isInfinite!=="y"&&(N.yDiff>0&&T<0||N.yDiff<0&&T>0)&&(T*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*N.yDiff)))):(N.xDiff&&(k=0),N.yDiff&&(T=0));const B=this.targetScale,L=this.minScale,U=this.maxScale;B<.5*L&&(v=Math.max(v,L)),B>1.5*U&&(v=Math.min(v,U)),this.lockedAxis==="y"&&mt(B)===mt(L)&&(k=0),this.lockedAxis==="x"&&mt(B)===mt(L)&&(T=0),this.applyChange({originX:o,originY:p,panX:k,panY:T,scale:v,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(e,n,r){if(r.length)return this.dragOffset.x=0,this.dragOffset.y=0,void(this.trackingPoints=[]);this.container.classList.remove(this.cn("isDragging")),this.isDragging&&(this.addTrackingPoint(n),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),mm(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==Hn.Destroy&&(e.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const n=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const Z of ta)this.velocity[Z]=0;this.target.e=this.current.e,this.target.f=this.current.f,Ln(this.container,"is-scaling"),Ln(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:r}=this,i=r[0],s=r[r.length-1];let a=0,o=0,p=0;s&&i&&(a=s.clientX-i.clientX,o=s.clientY-i.clientY,p=s.time-i.time);const g=((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1;g!==1&&(a*=g,o*=g);let y=0,v=0,k=0,T=0,D=this.option("decelFriction");const N=this.targetScale;if(p>0){k=Math.abs(a)>3?a/(p/30):0,T=Math.abs(o)>3?o/(p/30):0;const Z=this.option("maxVelocity");Z&&(k=Math.max(Math.min(k,Z),-1*Z),T=Math.max(Math.min(T,Z),-1*Z))}k&&(y=k/(1/(1-D)-1)),T&&(v=T/(1/(1-D)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&mt(N)===this.minScale)&&(y=k=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&mt(N)===this.minScale)&&(v=T=0);const B=this.dragOffset.x,L=this.dragOffset.y,U=this.option("dragMinThreshold")||0;Math.abs(B)<U&&Math.abs(L)<U&&(y=v=0,k=T=0),(this.option("zoom")&&(N<this.minScale-1e-5||N>this.maxScale+1e-5)||n&&!y&&!v)&&(D=.35),this.applyChange({panX:y,panY:v,friction:D}),this.emit("decel",k,T,B,L)}onWheel(e){var n=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(s,a){return Math.abs(a)>Math.abs(s)?a:s});const r=Math.max(-1,Math.min(1,n));if(this.emit("wheel",e,r),this.panMode===Vs||e.defaultPrevented)return;const i=this.option("wheel");i==="pan"?(e.preventDefault(),this.panOnlyZoomed&&!this.canZoomOut()||this.applyChange({panX:2*-e.deltaX,panY:2*-e.deltaY,bounce:!1})):i==="zoom"&&this.option("zoom")!==!1&&this.zoomWithWheel(e)}onMouseMove(e){this.panWithMouse(e)}onKeydown(e){e.key==="Escape"&&this.toggleFS()}onResize(){this.updateMetrics(),this.checkBounds().inBounds||this.requestTick()}setTransform(){this.emit("beforeTransform");const{current:e,target:n,content:r,contentRect:i}=this,s=Object.assign({},ym);for(const B of ta){const L=B=="e"||B==="f"?bm:t3;s[B]=mt(e[B],L),Math.abs(n[B]-e[B])<(B=="e"||B==="f"?.51:.001)&&(e[B]=n[B])}let{a,b:o,c:p,d:g,e:y,f:v}=s,k=`matrix(${a}, ${o}, ${p}, ${g}, ${y}, ${v})`,T=r.parentElement instanceof HTMLPictureElement?r.parentElement:r;if(this.option("transformParent")&&(T=T.parentElement||T),T.style.transform===k)return;T.style.transform=k;const{contentWidth:D,contentHeight:N}=this.calculateContentDim();i.width=D,i.height=N,this.emit("afterTransform")}updateMetrics(e=!1){var n;if(!this||this.state===Hn.Destroy||this.isContentLoading)return;const r=Math.max(1,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1),{container:i,content:s}=this,a=s instanceof HTMLImageElement,o=i.getBoundingClientRect(),p=getComputedStyle(this.container);let g=o.width*r,y=o.height*r;const v=parseFloat(p.paddingTop)+parseFloat(p.paddingBottom),k=g-(parseFloat(p.paddingLeft)+parseFloat(p.paddingRight)),T=y-v;this.containerRect={width:g,height:y,innerWidth:k,innerHeight:T};const D=parseFloat(s.dataset.width||"")||(qe=>{let fe=0;return fe=qe instanceof HTMLImageElement?qe.naturalWidth:qe instanceof SVGElement?qe.width.baseVal.value:Math.max(qe.offsetWidth,qe.scrollWidth),fe||0})(s),N=parseFloat(s.dataset.height||"")||(qe=>{let fe=0;return fe=qe instanceof HTMLImageElement?qe.naturalHeight:qe instanceof SVGElement?qe.height.baseVal.value:Math.max(qe.offsetHeight,qe.scrollHeight),fe||0})(s);let B=this.option("width",D)||zs,L=this.option("height",N)||zs;const U=B===zs,Z=L===zs;typeof B!="number"&&(B=D),typeof L!="number"&&(L=N),U&&(B=D*(L/N)),Z&&(L=N/(D/B));let Y=s.parentElement instanceof HTMLPictureElement?s.parentElement:s;this.option("transformParent")&&(Y=Y.parentElement||Y);const he=Y.getAttribute("style")||"";Y.style.setProperty("transform","none","important"),a&&(Y.style.width="",Y.style.height=""),Y.offsetHeight;const me=s.getBoundingClientRect();let xe=me.width*r,Re=me.height*r,ke=xe,Oe=Re;xe=Math.min(xe,B),Re=Math.min(Re,L),a?{width:xe,height:Re}=((qe,fe,ht,Mt)=>{const Dt=ht/qe,Bt=Mt/fe,qt=Math.min(Dt,Bt);return{width:qe*=qt,height:fe*=qt}})(B,L,xe,Re):(xe=Math.min(xe,B),Re=Math.min(Re,L));let Le=.5*(Oe-Re),Fe=.5*(ke-xe);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:me.top-o.top+Le,bottom:o.bottom-me.bottom+Le,left:me.left-o.left+Fe,right:o.right-me.right+Fe,fitWidth:xe,fitHeight:Re,width:xe,height:Re,fullWidth:B,fullHeight:L}),Y.style.cssText=he,a&&(Y.style.width=`${xe}px`,Y.style.height=`${Re}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(mt(this.targetScale)<mt(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===Hn.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}calculateBounds(){const{contentWidth:e,contentHeight:n}=this.calculateContentDim(this.target),{targetScale:r,lockedAxis:i}=this,{fitWidth:s,fitHeight:a}=this.contentRect;let o=0,p=0,g=0,y=0;const v=this.option("infinite");if(v===!0||i&&v===i)o=-1/0,g=1/0,p=-1/0,y=1/0;else{let{containerRect:k,contentRect:T}=this,D=mt(s*r,bm),N=mt(a*r,bm),{innerWidth:B,innerHeight:L}=k;if(k.width===D&&(B=k.width),k.width===N&&(L=k.height),e>B){g=.5*(e-B),o=-1*g;let U=.5*(T.right-T.left);o+=U,g+=U}if(s>B&&e<B&&(o-=.5*(s-B),g-=.5*(s-B)),n>L){y=.5*(n-L),p=-1*y;let U=.5*(T.bottom-T.top);p+=U,y+=U}a>L&&n<L&&(o-=.5*(a-L),g-=.5*(a-L))}return{x:{min:o,max:g},y:{min:p,max:y}}}getBounds(){const e=this.option("bounds");return e!==zs?e:this.calculateBounds()}updateControls(){const e=this,n=e.container,{panMode:r,contentRect:i,targetScale:s,minScale:a}=e;let o=a,p=e.option("click")||!1;p&&(o=e.getNextScale(p));let g=e.canZoomIn(),y=e.canZoomOut(),v=r===LE&&!!this.option("touch"),k=y&&v;if(v&&(mt(s)<mt(a)&&!this.panOnlyZoomed&&(k=!0),(mt(i.width,1)>mt(i.fitWidth,1)||mt(i.height,1)>mt(i.fitHeight,1))&&(k=!0)),mt(i.width*s,1)<mt(i.fitWidth,1)&&(k=!1),r===Vs&&(k=!1),ko(n,this.cn("isDraggable"),k),!this.option("zoom"))return;let T=g&&mt(o)>mt(s),D=!T&&!k&&y&&mt(o)<mt(s);ko(n,this.cn("canZoomIn"),T),ko(n,this.cn("canZoomOut"),D);for(const N of n.querySelectorAll("[data-panzoom-action]")){let B=!1,L=!1;switch(N.dataset.panzoomAction){case"zoomIn":g?B=!0:L=!0;break;case"zoomOut":y?B=!0:L=!0;break;case"toggleZoom":case"iterateZoom":g||y?B=!0:L=!0;const U=N.querySelector("g");U&&(U.style.display=g?"":"none")}B?(N.removeAttribute("disabled"),N.removeAttribute("tabindex")):L&&(N.setAttribute("disabled",""),N.setAttribute("tabindex","-1"))}}panTo({x:e=this.target.e,y:n=this.target.f,scale:r=this.targetScale,friction:i=this.option("friction"),angle:s=0,originX:a=0,originY:o=0,flipX:p=!1,flipY:g=!1,ignoreBounds:y=!1}){this.state!==Hn.Destroy&&this.applyChange({panX:e-this.target.e,panY:n-this.target.f,scale:r/this.targetScale,angle:s,originX:a,originY:o,friction:i,flipX:p,flipY:g,ignoreBounds:y})}applyChange({panX:e=0,panY:n=0,scale:r=1,angle:i=0,originX:s=-this.current.e,originY:a=-this.current.f,friction:o=this.option("friction"),flipX:p=!1,flipY:g=!1,ignoreBounds:y=!1,bounce:v=this.option("bounce")}){const k=this.state;if(k===Hn.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=o||0,this.ignoreBounds=y;const{current:T}=this,D=T.e,N=T.f,B=this.getMatrix(this.target);let L=new DOMMatrix().translate(D,N).translate(s,a).translate(e,n);if(this.option("zoom")){if(!y){const U=this.targetScale,Z=this.minScale,Y=this.maxScale;U*r<Z&&(r=Z/U),U*r>Y&&(r=Y/U)}L=L.scale(r)}L=L.translate(-s,-a).translate(-D,-N).multiply(B),i&&(L=L.rotate(i)),p&&(L=L.scale(-1,1)),g&&(L=L.scale(1,-1));for(const U of ta)U!=="e"&&U!=="f"&&(L[U]>this.minScale+1e-5||L[U]<this.minScale-1e-5)?this.target[U]=L[U]:this.target[U]=mt(L[U],bm);(this.targetScale<this.scale||Math.abs(r-1)>.1||this.panMode===Vs||v===!1)&&!y&&this.clampTargetBounds(),k===Hn.Init?this.animate():this.isResting||(this.state=Hn.Panning,this.requestTick())}stop(e=!1){if(this.state===Hn.Init||this.state===Hn.Destroy)return;const n=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const r of ta)this.velocity[r]=0,e==="current"?this.current[r]=this.target[r]:e==="target"&&(this.target[r]=this.current[r]);this.setTransform(),Ln(this.container,"is-scaling"),Ln(this.container,"is-animating"),this.isTicking=!1,this.state=Hn.Ready,n&&(this.emit("endAnimation"),this.updateControls())}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),Ot(this.container,"is-animating"),this.isScaling&&Ot(this.container,"is-scaling")),this.isTicking=!0,this.rAF||(this.rAF=requestAnimationFrame(()=>this.animate()))}panWithMouse(e,n=this.option("mouseMoveFriction")){if(this.pmme=e,this.panMode!==Vs||!e||mt(this.targetScale)<=mt(this.minScale))return;this.emit("mouseMove",e);const{container:r,containerRect:i,contentRect:s}=this,a=i.width,o=i.height,p=r.getBoundingClientRect(),g=(e.clientX||0)-p.left,y=(e.clientY||0)-p.top;let{contentWidth:v,contentHeight:k}=this.calculateContentDim(this.target);const T=this.option("mouseMoveFactor");T>1&&(v!==a&&(v*=T),k!==o&&(k*=T));let D=.5*(v-a)-g/a*100/100*(v-a);D+=.5*(s.right-s.left);let N=.5*(k-o)-y/o*100/100*(k-o);N+=.5*(s.bottom-s.top),this.applyChange({panX:D-this.target.e,panY:N-this.target.f,friction:n})}zoomWithWheel(e){if(this.state===Hn.Destroy||this.state===Hn.Init)return;const n=Date.now();if(n-this.pwt<45)return void e.preventDefault();this.pwt=n;var r=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(g,y){return Math.abs(y)>Math.abs(g)?y:g});const i=Math.max(-1,Math.min(1,r)),{targetScale:s,maxScale:a,minScale:o}=this;let p=s*(100+45*i)/100;mt(p)<mt(o)&&mt(s)<=mt(o)?(this.cwd+=Math.abs(i),p=o):mt(p)>mt(a)&&mt(s)>=mt(a)?(this.cwd+=Math.abs(i),p=a):(this.cwd=0,p=Math.max(Math.min(p,a),o)),this.cwd>this.option("wheelLimit")||(e.preventDefault(),mt(p)!==mt(s)&&this.zoomTo(p,{event:e}))}canZoomIn(){return this.option("zoom")&&(mt(this.contentRect.width,1)<mt(this.contentRect.fitWidth,1)||mt(this.targetScale)<mt(this.maxScale))}canZoomOut(){return this.option("zoom")&&mt(this.targetScale)>mt(this.minScale)}zoomIn(e=1.25,n){this.zoomTo(this.targetScale*e,n)}zoomOut(e=.8,n){this.zoomTo(this.targetScale*e,n)}zoomToFit(e){this.zoomTo("fit",e)}zoomToCover(e){this.zoomTo("cover",e)}zoomToFull(e){this.zoomTo("full",e)}zoomToMax(e){this.zoomTo("max",e)}toggleZoom(e){this.zoomTo(this.getNextScale("toggleZoom"),e)}toggleMax(e){this.zoomTo(this.getNextScale("toggleMax"),e)}toggleCover(e){this.zoomTo(this.getNextScale("toggleCover"),e)}iterateZoom(e){this.zoomTo("next",e)}zoomTo(e=1,{friction:n=zs,originX:r=zs,originY:i=zs,event:s}={}){if(this.isContentLoading||this.state===Hn.Destroy)return;const{targetScale:a,fullScale:o,maxScale:p,coverScale:g}=this;if(this.stop(),this.panMode===Vs&&(s=this.pmme||s),s||r===zs||i===zs){const v=this.content.getBoundingClientRect(),k=this.container.getBoundingClientRect(),T=s?s.clientX:k.left+.5*k.width,D=s?s.clientY:k.top+.5*k.height;r=T-v.left-.5*v.width,i=D-v.top-.5*v.height}let y=1;typeof e=="number"?y=e:e==="full"?y=o:e==="cover"?y=g:e==="max"?y=p:e==="fit"?y=1:e==="next"&&(y=this.getNextScale("iterateZoom")),y=y/a||1,n=n===zs?y>1?.15:.25:n,this.applyChange({scale:y,originX:r,originY:i,friction:n}),s&&this.panMode===Vs&&this.panWithMouse(s,n)}rotateCCW(){this.applyChange({angle:-90})}rotateCW(){this.applyChange({angle:90})}flipX(){this.applyChange({flipX:!0})}flipY(){this.applyChange({flipY:!0})}fitX(){this.stop("target");const{containerRect:e,contentRect:n,target:r}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-r.e,panY:.5*e.height-(n.top+.5*n.fitHeight)-r.f,scale:e.width/n.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:e,contentRect:n,target:r}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-r.e,panY:.5*e.innerHeight-(n.top+.5*n.fitHeight)-r.f,scale:e.height/n.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:e}=this,n=this.cn("inFullscreen"),r=this.cn("htmlHasFullscreen");e.classList.toggle(n);const i=e.classList.contains(n);i?(document.documentElement.classList.add(r),document.addEventListener("keydown",this.onKeydown,!0)):(document.documentElement.classList.remove(r),document.removeEventListener("keydown",this.onKeydown,!0)),this.updateMetrics(),this.emit(i?"enterFS":"exitFS")}getMatrix(e=this.current){const{a:n,b:r,c:i,d:s,e:a,f:o}=e;return new DOMMatrix([n,r,i,s,a,o])}reset(e){if(this.state!==Hn.Init&&this.state!==Hn.Destroy){this.stop("current");for(const n of ta)this.target[n]=ym[n];this.target.a=this.minScale,this.target.d=this.minScale,this.clampTargetBounds(),this.isResting||(this.friction=e===void 0?this.option("friction"):e,this.state=Hn.Panning,this.requestTick())}}destroy(){this.stop(),this.state=Hn.Destroy,this.detachEvents(),this.detachObserver();const{container:e,content:n}=this,r=this.option("classes")||{};for(const i of Object.values(r))e.classList.remove(i+"");n&&(n.removeEventListener("load",this.onLoad),n.removeEventListener("error",this.onError)),this.detachPlugins()}};Object.defineProperty(wd,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:e3}),Object.defineProperty(wd,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const $E=function(t,e){let n=!0;return(...r)=>{n&&(n=!1,t(...r),setTimeout(()=>{n=!0},e))}},jE=(t,e)=>{let n=[];return t.childNodes.forEach(r=>{r.nodeType!==Node.ELEMENT_NODE||e&&!r.matches(e)||n.push(r)}),n},n3={viewport:null,track:null,enabled:!0,slides:[],axis:"x",transition:"fade",preload:1,slidesPerPage:"auto",initialPage:0,friction:.12,Panzoom:{decelFriction:.12},center:!0,infinite:!0,fill:!0,dragFree:!1,adaptiveHeight:!1,direction:"ltr",classes:{container:"f-carousel",viewport:"f-carousel__viewport",track:"f-carousel__track",slide:"f-carousel__slide",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",inTransition:"in-transition",isSelected:"is-selected"},l10n:{NEXT:"Next slide",PREV:"Previous slide",GOTO:"Go to slide #%d"}};var Ar;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"})(Ar||(Ar={}));const Sb=t=>{if(typeof t=="string"||t instanceof HTMLElement)t={html:t};else{const e=t.thumb;e!==void 0&&(typeof e=="string"&&(t.thumbSrc=e),e instanceof HTMLImageElement&&(t.thumbEl=e,t.thumbElSrc=e.src,t.thumbSrc=e.src),delete t.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",customClass:"",index:-1,dim:0,gap:0,pos:0,transition:!1},t)},r3=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);let oo=class extends gm{constructor(e,n){super(n),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}};const i3={classes:{list:"f-carousel__dots",isDynamic:"is-dynamic",hasDots:"has-dots",dot:"f-carousel__dot",isBeforePrev:"is-before-prev",isPrev:"is-prev",isCurrent:"is-current",isNext:"is-next",isAfterNext:"is-after-next"},dotTpl:'<button type="button" data-carousel-page="%i" aria-label="{{GOTO}}"><span class="f-carousel__dot" aria-hidden="true"></span></button>',dynamicFrom:11,maxCount:1/0,minCount:2};let HE=class extends oo{constructor(){super(...arguments),Object.defineProperty(this,"isDynamic",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:null})}onRefresh(){this.refresh()}build(){let e=this.list;if(!e){e=document.createElement("ul"),Ot(e,this.cn("list")),e.setAttribute("role","tablist");const n=this.instance.container;n.appendChild(e),Ot(n,this.cn("hasDots")),this.list=e}return e}refresh(){var e;const n=this.instance.pages.length,r=Math.min(2,this.option("minCount")),i=Math.max(2e3,this.option("maxCount")),s=this.option("dynamicFrom");if(n<r||n>i)return void this.cleanup();const a=typeof s=="number"&&n>5&&n>=s,o=!this.list||this.isDynamic!==a||this.list.children.length!==n;o&&this.cleanup();const p=this.build();if(ko(p,this.cn("isDynamic"),!!a),o)for(let v=0;v<n;v++)p.append(this.createItem(v));let g,y=0;for(const v of[...p.children]){const k=y===this.instance.page;k&&(g=v),ko(v,this.cn("isCurrent"),k),(e=v.children[0])===null||e===void 0||e.setAttribute("aria-selected",k?"true":"false");for(const T of["isBeforePrev","isPrev","isNext","isAfterNext"])Ln(v,this.cn(T));y++}if(g=g||p.firstChild,a&&g){const v=g.previousElementSibling,k=v&&v.previousElementSibling;Ot(v,this.cn("isPrev")),Ot(k,this.cn("isBeforePrev"));const T=g.nextElementSibling,D=T&&T.nextElementSibling;Ot(T,this.cn("isNext")),Ot(D,this.cn("isAfterNext"))}this.isDynamic=a}createItem(e=0){var n;const r=document.createElement("li");r.setAttribute("role","presentation");const i=wo(this.instance.localize(this.option("dotTpl"),[["%d",e+1]]).replace(/\%i/g,e+""));return r.appendChild(i),(n=r.children[0])===null||n===void 0||n.setAttribute("role","tab"),r}cleanup(){this.list&&(this.list.remove(),this.list=null),this.isDynamic=!1,Ln(this.instance.container,this.cn("hasDots"))}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}};Object.defineProperty(HE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:i3});const _m="disabled",xm="next",UE="prev";let WE=class extends oo{constructor(){super(...arguments),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"prev",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"next",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isDom",{enumerable:!0,configurable:!0,writable:!0,value:!1})}onRefresh(){const e=this.instance,n=e.pages.length,r=e.page;if(n<2)return void this.cleanup();this.build();let i=this.prev,s=this.next;i&&s&&(i.removeAttribute(_m),s.removeAttribute(_m),e.isInfinite||(r<=0&&i.setAttribute(_m,""),r>=n-1&&s.setAttribute(_m,"")))}addBtn(e){var n;const r=this.instance,i=document.createElement("button");i.setAttribute("tabindex","0"),i.setAttribute("title",r.localize(`{{${e.toUpperCase()}}}`)),Ot(i,this.cn("button")+" "+this.cn(e===xm?"isNext":"isPrev"));const s=r.isRTL?e===xm?UE:xm:e;var a;return i.innerHTML=r.localize(this.option(`${s}Tpl`)),i.dataset[`carousel${a=e,a?a.match("^[a-z]")?a.charAt(0).toUpperCase()+a.substring(1):a:""}`]="true",(n=this.container)===null||n===void 0||n.appendChild(i),i}build(){const e=this.instance.container,n=this.cn("container");let{container:r,prev:i,next:s}=this;r||(r=e.querySelector("."+n),this.isDom=!!r),r||(r=document.createElement("div"),Ot(r,n),e.appendChild(r)),this.container=r,s||(s=r.querySelector("[data-carousel-next]")),s||(s=this.addBtn(xm)),this.next=s,i||(i=r.querySelector("[data-carousel-prev]")),i||(i=this.addBtn(UE)),this.prev=i}cleanup(){this.isDom||(this.prev&&this.prev.remove(),this.next&&this.next.remove(),this.container&&this.container.remove()),this.prev=null,this.next=null,this.container=null,this.isDom=!1}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}};Object.defineProperty(WE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{classes:{container:"f-carousel__nav",button:"f-button",isNext:"is-next",isPrev:"is-prev"},nextTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>',prevTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>'}});let qE=class extends oo{constructor(){super(...arguments),Object.defineProperty(this,"selectedIndex",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nav",{enumerable:!0,configurable:!0,writable:!0,value:null})}addAsTargetFor(e){this.target=this.instance,this.nav=e,this.attachEvents()}addAsNavFor(e){this.nav=this.instance,this.target=e,this.attachEvents()}attachEvents(){const{nav:e,target:n}=this;e&&n&&(e.options.initialSlide=n.options.initialPage,e.state===Ar.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),n.state===Ar.Ready?this.onTargetReady(n):n.on("ready",this.onTargetReady))}onNavReady(e){e.on("createSlide",this.onNavCreateSlide),e.on("Panzoom.click",this.onNavClick),e.on("Panzoom.touchEnd",this.onNavTouch),this.onTargetChange()}onTargetReady(e){e.on("change",this.onTargetChange),e.on("Panzoom.refresh",this.onTargetChange),this.onTargetChange()}onNavClick(e,n,r){this.onNavTouch(e,e.panzoom,r)}onNavTouch(e,n,r){var i,s;if(Math.abs(n.dragOffset.x)>3||Math.abs(n.dragOffset.y)>3)return;const a=r.target,{nav:o,target:p}=this;if(!o||!p||!a)return;const g=a.closest("[data-index]");if(r.stopPropagation(),r.preventDefault(),!g)return;const y=parseInt(g.dataset.index||"",10)||0,v=p.getPageForSlide(y),k=o.getPageForSlide(y);o.slideTo(k),p.slideTo(v,{friction:((s=(i=this.nav)===null||i===void 0?void 0:i.plugins)===null||s===void 0?void 0:s.Sync.option("friction"))||0}),this.markSelectedSlide(y)}onNavCreateSlide(e,n){n.index===this.selectedIndex&&this.markSelectedSlide(n.index)}onTargetChange(){var e,n;const{target:r,nav:i}=this;if(!r||!i||i.state!==Ar.Ready||r.state!==Ar.Ready)return;const s=(n=(e=r.pages[r.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index,a=i.getPageForSlide(s);this.markSelectedSlide(s),i.slideTo(a,i.prevPage===null&&r.prevPage===null?{friction:0}:void 0)}markSelectedSlide(e){const n=this.nav;n&&n.state===Ar.Ready&&(this.selectedIndex=e,[...n.slides].map(r=>{r.el&&r.el.classList[r.index===e?"add":"remove"]("is-nav-selected")}))}attach(){const e=this;let n=e.options.target,r=e.options.nav;n?e.addAsNavFor(n):r&&e.addAsTargetFor(r)}detach(){const e=this,n=e.nav,r=e.target;n&&(n.off("ready",e.onNavReady),n.off("createSlide",e.onNavCreateSlide),n.off("Panzoom.click",e.onNavClick),n.off("Panzoom.touchEnd",e.onNavTouch)),e.nav=null,r&&(r.off("ready",e.onTargetReady),r.off("refresh",e.onTargetChange),r.off("change",e.onTargetChange)),e.target=null}};Object.defineProperty(qE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const s3={Navigation:WE,Dots:HE,Sync:qE},vm="animationend",GE="isSelected",wm="slide";let kh=class Q1 extends vb{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===Ar.Ready}get isInfinite(){let e=!1;const{contentDim:n,viewportDim:r,pages:i,slides:s}=this,a=s[0];return i.length>=2&&a&&n+a.dim>=r&&(e=this.option("infinite")),e}get isRTL(){return this.option("direction")==="rtl"}get isHorizontal(){return this.option("axis")==="x"}constructor(e,n={},r={}){if(super(),Object.defineProperty(this,"bp",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"lp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userOptions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"userPlugins",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Ar.Init}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevPage",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"viewport",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"track",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"slides",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"panzoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"inTransition",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"contentDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"viewportDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),typeof e=="string"&&(e=document.querySelector(e)),!e||!Xi(e))throw new Error("No Element found");this.container=e,this.slideNext=$E(this.slideNext.bind(this),150),this.slidePrev=$E(this.slidePrev.bind(this),150),this.userOptions=n,this.userPlugins=r,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,n;const r=Zi({},Q1.defaults,this.userOptions);let i="";const s=r.breakpoints;if(s&&_b(s))for(const[a,o]of Object.entries(s))window.matchMedia(a).matches&&_b(o)&&(i+=a,Zi(r,o));i===this.bp&&this.state!==Ar.Init||(this.bp=i,this.state===Ar.Ready&&(r.initialSlide=((n=(e=this.pages[this.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index)||0),this.state!==Ar.Init&&this.destroy(),super.setOptions(r),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=Ar.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},Q1.Plugins),this.userPlugins)),this.emit("attachPlugins"),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=Ar.Ready,this.emit("ready")}initLayout(){const{container:e}=this,n=this.option("classes");Ot(e,this.cn("container")),ko(e,n.isLTR,!this.isRTL),ko(e,n.isRTL,this.isRTL),ko(e,n.isVertical,!this.isHorizontal),ko(e,n.isHorizontal,this.isHorizontal);let r=this.option("viewport")||e.querySelector(`.${n.viewport}`);r||(r=document.createElement("div"),Ot(r,n.viewport),r.append(...jE(e,`.${n.slide}`)),e.prepend(r)),r.addEventListener("scroll",this.onScroll);let i=this.option("track")||e.querySelector(`.${n.track}`);i||(i=document.createElement("div"),Ot(i,n.track),i.append(...Array.from(r.childNodes))),i.setAttribute("aria-live","polite"),r.contains(i)||r.prepend(i),this.viewport=r,this.track=i,this.emit("initLayout")}initSlides(){const{track:e}=this;if(!e)return;const n=[...this.slides],r=[];[...jE(e,`.${this.cn(wm)}`)].forEach(i=>{if(Xi(i)){const s=Sb({el:i,isDom:!0,index:this.slides.length});r.push(s)}});for(let i of[...this.option("slides",[])||[],...n])r.push(Sb(i));this.slides=r;for(let i=0;i<this.slides.length;i++)this.slides[i].index=i;for(const i of r)this.emit("beforeInitSlide",i,i.index),this.emit("initSlide",i,i.index);this.emit("initSlides")}setInitialPage(){const e=this.option("initialSlide");this.page=typeof e=="number"?this.getPageForSlide(e):parseInt(this.option("initialPage",0)+"",10)||0}setInitialPosition(){const{track:e,pages:n,isHorizontal:r}=this;if(!e||!n.length)return;let i=this.page;n[i]||(this.page=i=0);const s=(n[i].pos||0)*(this.isRTL&&r?1:-1),a=r?`${s}px`:"0",o=r?"0":`${s}px`;e.style.transform=`translate3d(${a}, ${o}, 0) scale(1)`,this.option("adaptiveHeight")&&this.setViewportHeight()}initPanzoom(){this.panzoom&&(this.panzoom.destroy(),this.panzoom=null);const e=this.option("Panzoom")||{};this.panzoom=new wd(this.viewport,Zi({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,click:!1,dblClick:!1,touch:n=>!(this.pages.length<2&&!n.options.infinite),bounds:()=>this.getBounds(),maxVelocity:n=>Math.abs(n.target[this.axis]-n.current[this.axis])<2*this.viewportDim?100:0},e)),this.panzoom.on("*",(n,r,...i)=>{this.emit(`Panzoom.${r}`,n,...i)}),this.panzoom.on("decel",this.onDecel),this.panzoom.on("refresh",this.onRefresh),this.panzoom.on("beforeTransform",this.onBeforeTransform),this.panzoom.on("endAnimation",this.onEndAnimation)}attachEvents(){const e=this.container;e&&(e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("slideTo",this.onSlideTo)),window.addEventListener("resize",this.onResize)}createPages(){let e=[];const{contentDim:n,viewportDim:r}=this;let i=this.option("slidesPerPage");i=(i==="auto"||n<=r)&&this.option("fill")!==!1?1/0:parseFloat(i+"");let s=0,a=0,o=0;for(const p of this.slides)(!e.length||a+p.dim-r>.05||o>=i)&&(e.push(r3()),s=e.length-1,a=0,o=0),e[s].slides.push(p),a+=p.dim+p.gap,o++;return e}processPages(){const e=this.pages,{contentDim:n,viewportDim:r,isInfinite:i}=this,s=this.option("center"),a=this.option("fill"),o=a&&s&&n>r&&!i;if(e.forEach((y,v)=>{var k;y.index=v,y.pos=((k=y.slides[0])===null||k===void 0?void 0:k.pos)||0,y.dim=0;for(const[T,D]of y.slides.entries())y.dim+=D.dim,T<y.slides.length-1&&(y.dim+=D.gap);o&&y.pos+.5*y.dim<.5*r?y.pos=0:o&&y.pos+.5*y.dim>=n-.5*r?y.pos=n-r:s&&(y.pos+=-.5*(r-y.dim))}),e.forEach(y=>{a&&!i&&n>r&&(y.pos=Math.max(y.pos,0),y.pos=Math.min(y.pos,n-r)),y.pos=mt(y.pos,1e3),y.dim=mt(y.dim,1e3),Math.abs(y.pos)<=.1&&(y.pos=0)}),i)return e;const p=[];let g;return e.forEach(y=>{const v=Object.assign({},y);g&&v.pos===g.pos?(g.dim+=v.dim,g.slides=[...g.slides,...v.slides]):(v.index=p.length,g=v,p.push(v))}),p}getPageFromIndex(e=0){const n=this.pages.length;let r;return e=parseInt((e||0).toString())||0,r=this.isInfinite?(e%n+n)%n:Math.max(Math.min(e,n-1),0),r}getSlideMetrics(e){var n,r;const i=this.isHorizontal?"width":"height";let s=0,a=0,o=e.el;const p=!(!o||o.parentNode);if(o?s=parseFloat(o.dataset[i]||"")||0:(o=document.createElement("div"),o.style.visibility="hidden",(this.track||document.body).prepend(o)),Ot(o,this.cn(wm)+" "+e.class+" "+e.customClass),s)o.style[i]=`${s}px`,o.style[i==="width"?"height":"width"]="";else{p&&(this.track||document.body).prepend(o),s=o.getBoundingClientRect()[i]*Math.max(1,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1);let y=o[this.isHorizontal?"offsetWidth":"offsetHeight"];y-1>s&&(s=y)}const g=getComputedStyle(o);return g.boxSizing==="content-box"&&(this.isHorizontal?(s+=parseFloat(g.paddingLeft)||0,s+=parseFloat(g.paddingRight)||0):(s+=parseFloat(g.paddingTop)||0,s+=parseFloat(g.paddingBottom)||0)),a=parseFloat(g[this.isHorizontal?"marginRight":"marginBottom"])||0,p?(r=o.parentElement)===null||r===void 0||r.removeChild(o):e.el||o.remove(),{dim:mt(s,1e3),gap:mt(a,1e3)}}getBounds(){const{isInfinite:e,isRTL:n,isHorizontal:r,pages:i}=this;let s={min:0,max:0};if(e)s={min:-1/0,max:1/0};else if(i.length){const a=i[0].pos,o=i[i.length-1].pos;s=n&&r?{min:a,max:o}:{min:-1*o,max:-1*a}}return{x:r?s:{min:0,max:0},y:r?{min:0,max:0}:s}}repositionSlides(){let e,{isHorizontal:n,isRTL:r,isInfinite:i,viewport:s,viewportDim:a,contentDim:o,page:p,pages:g,slides:y,panzoom:v}=this,k=0,T=0,D=0,N=0;v?N=-1*v.current[this.axis]:g[p]&&(N=g[p].pos||0),e=n?r?"right":"left":"top",r&&n&&(N*=-1);for(const Z of y){const Y=Z.el;Y?(e==="top"?(Y.style.right="",Y.style.left=""):Y.style.top="",Z.index!==k?Y.style[e]=T===0?"":`${mt(T,1e3)}px`:Y.style[e]="",D+=Z.dim+Z.gap,k++):T+=Z.dim+Z.gap}if(i&&D&&s){let Z=getComputedStyle(s),Y="padding",he=n?"Right":"Bottom",me=parseFloat(Z[Y+(n?"Left":"Top")]);N-=me,a+=me,a+=parseFloat(Z[Y+he]);for(const xe of y)xe.el&&(mt(xe.pos)<mt(a)&&mt(xe.pos+xe.dim+xe.gap)<mt(N)&&mt(N)>mt(o-a)&&(xe.el.style[e]=`${mt(T+D,1e3)}px`),mt(xe.pos+xe.gap)>=mt(o-a)&&mt(xe.pos)>mt(N+a)&&mt(N)<mt(a)&&(xe.el.style[e]=`-${mt(D,1e3)}px`))}let B,L,U=[...this.inTransition];if(U.length>1&&(B=g[U[0]],L=g[U[1]]),B&&L){let Z=0;for(const Y of y)Y.el?this.inTransition.has(Y.index)&&B.slides.indexOf(Y)<0&&(Y.el.style[e]=`${mt(Z+(B.pos-L.pos),1e3)}px`):Z+=Y.dim+Y.gap}}createSlideEl(e){const{track:n,slides:r}=this;if(!n||!e||e.el&&e.el.parentNode)return;const i=e.el||document.createElement("div");Ot(i,this.cn(wm)),Ot(i,e.class),Ot(i,e.customClass);const s=e.html;s&&(s instanceof HTMLElement?i.appendChild(s):i.innerHTML=e.html+"");const a=[];r.forEach((y,v)=>{y.el&&a.push(v)});const o=e.index;let p=null;a.length&&(p=r[a.reduce((y,v)=>Math.abs(v-o)<Math.abs(y-o)?v:y)]);const g=p&&p.el&&p.el.parentNode?p.index<e.index?p.el.nextSibling:p.el:null;n.insertBefore(i,n.contains(g)?g:null),e.el=i,this.emit("createSlide",e)}removeSlideEl(e,n=!1){const r=e==null?void 0:e.el;if(!r||!r.parentNode)return;const i=this.cn(GE);if(r.classList.contains(i)&&(Ln(r,i),this.emit("unselectSlide",e)),e.isDom&&!n)return r.removeAttribute("aria-hidden"),r.removeAttribute("data-index"),void(r.style.left="");this.emit("removeSlide",e);const s=new CustomEvent(vm);r.dispatchEvent(s),e.el&&(e.el.remove(),e.el=null)}transitionTo(e=0,n=this.option("transition")){var r,i,s,a;if(!n)return!1;const o=this.page,{pages:p,panzoom:g}=this;e=parseInt((e||0).toString())||0;const y=this.getPageFromIndex(e);if(!g||!p[y]||p.length<2||Math.abs((((i=(r=p[o])===null||r===void 0?void 0:r.slides[0])===null||i===void 0?void 0:i.dim)||0)-this.viewportDim)>1)return!1;let v=e>o?1:-1;this.isInfinite&&(o===0&&e===p.length-1&&(v=-1),o===p.length-1&&e===0&&(v=1));const k=p[y].pos*(this.isRTL?1:-1);if(o===y&&Math.abs(k-g.target[this.axis])<1)return!1;this.clearTransitions();const T=g.isResting;Ot(this.container,this.cn("inTransition"));const D=((s=p[o])===null||s===void 0?void 0:s.slides[0])||null,N=((a=p[y])===null||a===void 0?void 0:a.slides[0])||null;this.inTransition.add(N.index),this.createSlideEl(N);let B=D.el,L=N.el;T||n===wm||(n="fadeFast",B=null);const U=this.isRTL?"next":"prev",Z=this.isRTL?"prev":"next";return B&&(this.inTransition.add(D.index),D.transition=n,B.addEventListener(vm,this.onAnimationEnd),B.classList.add(`f-${n}Out`,`to-${v>0?Z:U}`)),L&&(N.transition=n,L.addEventListener(vm,this.onAnimationEnd),L.classList.add(`f-${n}In`,`from-${v>0?U:Z}`)),g.current[this.axis]=k,g.target[this.axis]=k,g.requestTick(),this.onChange(y),!0}manageSlideVisiblity(){const e=new Set,n=new Set,r=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const i of this.slides)r.has(i)?e.add(i):n.add(i);for(const i of this.inTransition)e.add(this.slides[i]);for(const i of e)this.createSlideEl(i),this.lazyLoadSlide(i);for(const i of n)e.has(i)||this.removeSlideEl(i);this.markSelectedSlides(),this.repositionSlides()}markSelectedSlides(){if(!this.pages[this.page]||!this.pages[this.page].slides)return;const e="aria-hidden";let n=this.cn(GE);if(n)for(const r of this.slides){const i=r.el;i&&(i.dataset.index=`${r.index}`,i.classList.contains("f-thumbs__slide")?this.getVisibleSlides(0).has(r)?i.removeAttribute(e):i.setAttribute(e,"true"):this.pages[this.page].slides.includes(r)?(i.classList.contains(n)||(Ot(i,n),this.emit("selectSlide",r)),i.removeAttribute(e)):(i.classList.contains(n)&&(Ln(i,n),this.emit("unselectSlide",r)),i.setAttribute(e,"true")))}}flipInfiniteTrack(){const{axis:e,isHorizontal:n,isInfinite:r,isRTL:i,viewportDim:s,contentDim:a}=this,o=this.panzoom;if(!o||!r)return;let p=o.current[e],g=o.target[e]-p,y=0,v=.5*s;i&&n?(p<-v&&(y=-1,p+=a),p>a-v&&(y=1,p-=a)):(p>v&&(y=1,p-=a),p<-a+v&&(y=-1,p+=a)),y&&(o.current[e]=p,o.target[e]=p+g)}lazyLoadImg(e,n){const r=this,i="f-fadeIn",s="is-preloading";let a=!1,o=null;const p=()=>{a||(a=!0,o&&(o.remove(),o=null),Ln(n,s),n.complete&&(Ot(n,i),setTimeout(()=>{Ln(n,i)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(r.updateMetrics(),r.setViewportHeight()),this.emit("load",e))};Ot(n,s),n.src=n.dataset.lazySrcset||n.dataset.lazySrc||"",delete n.dataset.lazySrc,delete n.dataset.lazySrcset,n.addEventListener("error",()=>{p()}),n.addEventListener("load",()=>{p()}),setTimeout(()=>{const g=n.parentNode;g&&e.el&&(n.complete?p():a||(o=wo(wb),g.insertBefore(o,n)))},300)}lazyLoadSlide(e){const n=e&&e.el;if(!n)return;const r=new Set;let i=Array.from(n.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));n.dataset.lazySrc&&i.push(n),i.map(s=>{s instanceof HTMLImageElement?r.add(s):s instanceof HTMLElement&&s.dataset.lazySrc&&(s.style.backgroundImage=`url('${s.dataset.lazySrc}')`,delete s.dataset.lazySrc)});for(const s of r)this.lazyLoadImg(e,s)}onAnimationEnd(e){var n;const r=e.target,i=r?parseInt(r.dataset.index||"",10)||0:-1,s=this.slides[i],a=e.animationName;if(!r||!s||!a)return;const o=!!this.inTransition.has(i)&&s.transition;o&&a.substring(0,o.length+2)===`f-${o}`&&this.inTransition.delete(i),this.inTransition.size||this.clearTransitions(),i===this.page&&(!((n=this.panzoom)===null||n===void 0)&&n.isResting)&&this.emit("settle")}onDecel(e,n=0,r=0,i=0,s=0){if(this.option("dragFree"))return void this.setPageFromPosition();const{isRTL:a,isHorizontal:o,axis:p,pages:g}=this,y=g.length,v=Math.abs(Math.atan2(r,n)/(Math.PI/180));let k=0;if(k=v>45&&v<135?o?0:r:o?n:0,!y)return;let T=this.page,D=a&&o?1:-1;const N=e.current[p]*D;let{pageIndex:B}=this.getPageFromPosition(N);Math.abs(k)>5?(g[T].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(T=B),T=a&&o?k<0?T-1:T+1:k<0?T+1:T-1):T=i===0&&s===0?T:B,this.slideTo(T,{transition:!1,friction:e.option("decelFriction")})}onClick(e){const n=e.target,r=n&&Xi(n)?n.dataset:null;let i,s;r&&(r.carouselPage!==void 0?(s="slideTo",i=r.carouselPage):r.carouselNext!==void 0?s="slideNext":r.carouselPrev!==void 0&&(s="slidePrev")),s?(e.preventDefault(),e.stopPropagation(),n&&!n.hasAttribute("disabled")&&this[s](i)):this.emit("click",e)}onSlideTo(e){const n=e.detail||0;this.slideTo(this.getPageForSlide(n),{friction:0})}onChange(e,n=0){const r=this.page;this.prevPage=r,this.page=e,this.option("adaptiveHeight")&&this.setViewportHeight(),e!==r&&(this.markSelectedSlides(),this.emit("change",e,r,n))}onRefresh(){let e=this.contentDim,n=this.viewportDim;this.updateMetrics(),this.contentDim===e&&this.viewportDim===n||this.slideTo(this.page,{friction:0,transition:!1})}onScroll(){var e;(e=this.viewport)===null||e===void 0||e.scroll(0,0)}onResize(){this.option("breakpoints")&&this.processOptions()}onBeforeTransform(e){this.lp!==e.current[this.axis]&&(this.flipInfiniteTrack(),this.manageSlideVisiblity()),this.lp=e.current.e}onEndAnimation(){this.inTransition.size||this.emit("settle")}reInit(e=null,n=null){this.destroy(),this.state=Ar.Init,this.prevPage=null,this.userOptions=e||this.userOptions,this.userPlugins=n||this.userPlugins,this.processOptions()}slideTo(e=0,{friction:n=this.option("friction"),transition:r=this.option("transition")}={}){if(this.state===Ar.Destroy)return;e=parseInt((e||0).toString())||0;const i=this.getPageFromIndex(e),{axis:s,isHorizontal:a,isRTL:o,pages:p,panzoom:g}=this,y=p.length,v=o&&a?1:-1;if(!g||!y)return;if(this.page!==i){const T=new Event("beforeChange",{bubbles:!0,cancelable:!0});if(this.emit("beforeChange",T,e),T.defaultPrevented)return}if(this.transitionTo(e,r))return;let k=p[i].pos;if(this.isInfinite){const T=this.contentDim,D=g.target[s]*v;y===2?k+=T*Math.floor(parseFloat(e+"")/2):k=[k,k-T,k+T].reduce(function(N,B){return Math.abs(B-D)<Math.abs(N-D)?B:N})}k*=v,Math.abs(g.target[s]-k)<1||(g.panTo({x:a?k:0,y:a?0:k,friction:n}),this.onChange(i))}slideToClosest(e){if(this.panzoom){const{pageIndex:n}=this.getPageFromPosition();this.slideTo(n,e)}}slideNext(){this.slideTo(this.page+1)}slidePrev(){this.slideTo(this.page-1)}clearTransitions(){this.inTransition.clear(),Ln(this.container,this.cn("inTransition"));const e=["to-prev","to-next","from-prev","from-next"];for(const n of this.slides){const r=n.el;if(r){r.removeEventListener(vm,this.onAnimationEnd),r.classList.remove(...e);const i=n.transition;i&&r.classList.remove(`f-${i}Out`,`f-${i}In`)}}this.manageSlideVisiblity()}addSlide(e,n){var r,i,s,a;const o=this.panzoom,p=((r=this.pages[this.page])===null||r===void 0?void 0:r.pos)||0,g=((i=this.pages[this.page])===null||i===void 0?void 0:i.dim)||0,y=this.contentDim<this.viewportDim;let v=Array.isArray(n)?n:[n];const k=[];for(const T of v)k.push(Sb(T));this.slides.splice(e,0,...k);for(let T=0;T<this.slides.length;T++)this.slides[T].index=T;for(const T of k)this.emit("beforeInitSlide",T,T.index);if(this.page>=e&&(this.page+=k.length),this.updateMetrics(),o){const T=((s=this.pages[this.page])===null||s===void 0?void 0:s.pos)||0,D=((a=this.pages[this.page])===null||a===void 0?void 0:a.dim)||0,N=this.pages.length||1,B=this.isRTL?g-D:D-g,L=this.isRTL?p-T:T-p;y&&N===1?(e<=this.page&&(o.current[this.axis]-=B,o.target[this.axis]-=B),o.panTo({[this.isHorizontal?"x":"y"]:-1*T})):L&&e<=this.page&&(o.target[this.axis]-=L,o.current[this.axis]-=L,o.requestTick())}for(const T of k)this.emit("initSlide",T,T.index)}prependSlide(e){this.addSlide(0,e)}appendSlide(e){this.addSlide(this.slides.length,e)}removeSlide(e){const n=this.slides.length;e=(e%n+n)%n;const r=this.slides[e];if(r){this.removeSlideEl(r,!0),this.slides.splice(e,1);for(let i=0;i<this.slides.length;i++)this.slides[i].index=i;this.updateMetrics(),this.slideTo(this.page,{friction:0,transition:!1}),this.emit("destroySlide",r)}}updateMetrics(){const{panzoom:e,viewport:n,track:r,slides:i,isHorizontal:s,isInfinite:a}=this;if(!r)return;const o=s?"width":"height",p=s?"offsetWidth":"offsetHeight";if(n){let v=Math.max(n[p],mt(n.getBoundingClientRect()[o],1e3)),k=getComputedStyle(n),T="padding",D=s?"Right":"Bottom";v-=parseFloat(k[T+(s?"Left":"Top")])+parseFloat(k[T+D]),this.viewportDim=v}let g,y=0;for(const[v,k]of i.entries()){let T=0,D=0;!k.el&&g?(T=g.dim,D=g.gap):({dim:T,gap:D}=this.getSlideMetrics(k),g=k),T=mt(T,1e3),D=mt(D,1e3),k.dim=T,k.gap=D,k.pos=y,y+=T,(a||v<i.length-1)&&(y+=D)}y=mt(y,1e3),this.contentDim=y,e&&(e.contentRect[o]=y,e.contentRect[s?"fullWidth":"fullHeight"]=y),this.pages=this.createPages(),this.pages=this.processPages(),this.state===Ar.Init&&this.setInitialPage(),this.page=Math.max(0,Math.min(this.page,this.pages.length-1)),this.manageSlideVisiblity(),this.emit("refresh")}getProgress(e,n=!1,r=!1){e===void 0&&(e=this.page);const i=this,s=i.panzoom,a=i.contentDim,o=i.pages[e]||0;if(!o||!s)return e>this.page?-1:1;let p=-1*s.current.e,g=mt((p-o.pos)/(1*o.dim),1e3),y=g,v=g;this.isInfinite&&r!==!0&&(y=mt((p-o.pos+a)/(1*o.dim),1e3),v=mt((p-o.pos-a)/(1*o.dim),1e3));let k=[g,y,v].reduce(function(T,D){return Math.abs(D)<Math.abs(T)?D:T});return n?k:k>1?1:k<-1?-1:k}setViewportHeight(){const{page:e,pages:n,viewport:r,isHorizontal:i}=this;if(!r||!n[e])return;let s=0;i&&this.track&&(this.track.style.height="auto",n[e].slides.forEach(a=>{a.el&&(s=Math.max(s,a.el.offsetHeight))})),r.style.height=s?`${s}px`:""}getPageForSlide(e){for(const n of this.pages)for(const r of n.slides)if(r.index===e)return n.index;return-1}getVisibleSlides(e=0){var n;const r=new Set;let{panzoom:i,contentDim:s,viewportDim:a,pages:o,page:p}=this;if(a){s=s+((n=this.slides[this.slides.length-1])===null||n===void 0?void 0:n.gap)||0;let g=0;g=i&&i.state!==Hn.Init&&i.state!==Hn.Destroy?-1*i.current[this.axis]:o[p]&&o[p].pos||0,this.isInfinite&&(g-=Math.floor(g/s)*s),this.isRTL&&this.isHorizontal&&(g*=-1);const y=g-a*e,v=g+a*(e+1),k=this.isInfinite?[-1,0,1]:[0];for(const T of this.slides)for(const D of k){const N=T.pos+D*s,B=N+T.dim+T.gap;N<v&&B>y&&r.add(T)}}return r}getPageFromPosition(e){const{viewportDim:n,contentDim:r,slides:i,pages:s,panzoom:a}=this,o=s.length,p=i.length,g=i[0],y=i[p-1],v=this.option("center");let k=0,T=0,D=0,N=e===void 0?-1*((a==null?void 0:a.target[this.axis])||0):e;v&&(N+=.5*n),this.isInfinite?(N<g.pos-.5*y.gap&&(N-=r,D=-1),N>y.pos+y.dim+.5*y.gap&&(N-=r,D=1)):N=Math.max(g.pos||0,Math.min(N,y.pos));let B=y,L=i.find(U=>{const Z=U.pos-.5*B.gap,Y=U.pos+U.dim+.5*U.gap;return B=U,N>=Z&&N<Y});return L||(L=y),T=this.getPageForSlide(L.index),k=T+D*o,{page:k,pageIndex:T}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([Ar.Destroy].includes(this.state))return;this.state=Ar.Destroy;const{container:e,viewport:n,track:r,slides:i,panzoom:s}=this,a=this.option("classes");e.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),e.removeEventListener("slideTo",this.onSlideTo),window.removeEventListener("resize",this.onResize),s&&(s.destroy(),this.panzoom=null),i&&i.forEach(p=>{this.removeSlideEl(p)}),this.detachPlugins(),n&&(n.removeEventListener("scroll",this.onScroll),n.offsetParent&&r&&r.offsetParent&&n.replaceWith(...r.childNodes));for(const[p,g]of Object.entries(a))p!=="container"&&g&&e.classList.remove(g);this.track=null,this.viewport=null,this.page=0,this.slides=[];const o=this.events.get("ready");this.events=new Map,o&&this.events.set("ready",o)}};Object.defineProperty(kh,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:wd}),Object.defineProperty(kh,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:n3}),Object.defineProperty(kh,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:s3});const YE=function(t){if(!Xi(t))return 0;const e=window.scrollY,n=window.innerHeight,r=e+n,i=t.getBoundingClientRect(),s=i.y+e,a=i.height,o=s+a;if(e>o||r<s)return 0;if(e<s&&r>o||s<e&&o>r)return 100;let p=a;s<e&&(p-=e-s),o>r&&(p-=o-r);const g=p/n*100;return Math.round(g)},Eh=!(typeof window>"u"||!window.document||!window.document.createElement);let Cb;const Tb=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)","iframe","object","embed","video","audio","[contenteditable]",'[tabindex]:not([tabindex^="-"]):not([disabled]):not([aria-hidden])'].join(","),ZE=t=>{if(t&&Eh){Cb===void 0&&document.createElement("div").focus({get preventScroll(){return Cb=!0,!1}});try{if(Cb)t.focus({preventScroll:!0});else{const e=window.scrollY||document.body.scrollTop,n=window.scrollX||document.body.scrollLeft;t.focus(),document.body.scrollTo({top:e,left:n,behavior:"auto"})}}catch{}}},XE=()=>{const t=document;let e,n="",r="",i="";return t.fullscreenEnabled?(n="requestFullscreen",r="exitFullscreen",i="fullscreenElement"):t.webkitFullscreenEnabled&&(n="webkitRequestFullscreen",r="webkitExitFullscreen",i="webkitFullscreenElement"),n&&(e={request:function(s=t.documentElement){return n==="webkitRequestFullscreen"?s[n](Element.ALLOW_KEYBOARD_INPUT):s[n]()},exit:function(){return t[i]&&t[r]()},isFullscreen:function(){return t[i]}}),e},Ab={animated:!0,autoFocus:!0,backdropClick:"close",Carousel:{classes:{container:"fancybox__carousel",viewport:"fancybox__viewport",track:"fancybox__track",slide:"fancybox__slide"}},closeButton:"auto",closeExisting:!1,commonCaption:!1,compact:()=>window.matchMedia("(max-width: 578px), (max-height: 578px)").matches,contentClick:"toggleZoom",contentDblClick:!1,defaultType:"image",defaultDisplay:"flex",dragToClose:!0,Fullscreen:{autoStart:!1},groupAll:!1,groupAttr:"data-fancybox",hideClass:"f-fadeOut",hideScrollbar:!0,idle:3500,keyboard:{Escape:"close",Delete:"close",Backspace:"close",PageUp:"next",PageDown:"prev",ArrowUp:"prev",ArrowDown:"next",ArrowRight:"next",ArrowLeft:"prev"},l10n:Object.assign(Object.assign({},VE),{CLOSE:"Close",NEXT:"Next",PREV:"Previous",MODAL:"You can close this modal content with the ESC key",ERROR:"Something Went Wrong, Please Try Again Later",IMAGE_ERROR:"Image Not Found",ELEMENT_NOT_FOUND:"HTML Element Not Found",AJAX_NOT_FOUND:"Error Loading AJAX : Not Found",AJAX_FORBIDDEN:"Error Loading AJAX : Forbidden",IFRAME_ERROR:"Error Loading Page",TOGGLE_ZOOM:"Toggle zoom level",TOGGLE_THUMBS:"Toggle thumbnails",TOGGLE_SLIDESHOW:"Toggle slideshow",TOGGLE_FULLSCREEN:"Toggle full-screen mode",DOWNLOAD:"Download"}),parentEl:null,placeFocusBack:!0,showClass:"f-zoomInUp",startIndex:0,tpl:{closeButton:'<button data-fancybox-close class="f-button is-close-btn" title="{{CLOSE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"/></svg></button>',main:`<div class="fancybox__container" role="dialog" aria-modal="true" aria-label="{{MODAL}}" tabindex="-1">
|
621
621
|
<div class="fancybox__backdrop"></div>
|
622
622
|
<div class="fancybox__carousel"></div>
|
623
623
|
<div class="fancybox__footer"></div>
|