@opengis/admin 0.2.92 → 0.2.94

Sign up to get free protection for your applications and to get access to all the features.
@@ -621,7 +621,7 @@ uniform ${$} ${j} u_${G};
621
621
  #endif
622
622
  `}),staticAttributes:b,staticUniforms:D}}class _p{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(l,p,b,_,w,D,P,R,V){this.context=l;let $=this.boundPaintVertexBuffers.length!==_.length;for(let j=0;!$&&j<_.length;j++)this.boundPaintVertexBuffers[j]!==_[j]&&($=!0);!this.vao||this.boundProgram!==p||this.boundLayoutVertexBuffer!==b||$||this.boundIndexBuffer!==w||this.boundVertexOffset!==D||this.boundDynamicVertexBuffer!==P||this.boundDynamicVertexBuffer2!==R||this.boundDynamicVertexBuffer3!==V?this.freshBind(p,b,_,w,D,P,R,V):(l.bindVertexArray.set(this.vao),P&&P.bind(),w&&w.dynamicDraw&&w.bind(),R&&R.bind(),V&&V.bind())}freshBind(l,p,b,_,w,D,P,R){const V=l.numAttributes,$=this.context,j=$.gl;this.vao&&this.destroy(),this.vao=$.createVertexArray(),$.bindVertexArray.set(this.vao),this.boundProgram=l,this.boundLayoutVertexBuffer=p,this.boundPaintVertexBuffers=b,this.boundIndexBuffer=_,this.boundVertexOffset=w,this.boundDynamicVertexBuffer=D,this.boundDynamicVertexBuffer2=P,this.boundDynamicVertexBuffer3=R,p.enableAttributes(j,l);for(const G of b)G.enableAttributes(j,l);D&&D.enableAttributes(j,l),P&&P.enableAttributes(j,l),R&&R.enableAttributes(j,l),p.bind(),p.setVertexAttribPointers(j,l,w);for(const G of b)G.bind(),G.setVertexAttribPointers(j,l,w);D&&(D.bind(),D.setVertexAttribPointers(j,l,w)),_&&_.bind(),P&&(P.bind(),P.setVertexAttribPointers(j,l,w)),R&&(R.bind(),R.setVertexAttribPointers(j,l,w)),$.currentNumAttributes=V}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const xp=(k,l,p,b,_)=>({u_matrix:k,u_texture:0,u_ele_delta:l,u_fog_matrix:p,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 hl(k){const l=[];for(let p=0;p<k.length;p++){if(k[p]===null)continue;const b=k[p].split(" ");l.push(b.pop())}return l}class vp{constructor(l,p,b,_,w,D){const P=l.gl;this.program=P.createProgram();const R=hl(p.staticAttributes),V=b?b.getBinderAttributes():[],$=R.concat(V),j=No.prelude.staticUniforms?hl(No.prelude.staticUniforms):[],G=p.staticUniforms?hl(p.staticUniforms):[],Q=b?b.getBinderUniforms():[],ee=j.concat(G).concat(Q),oe=[];for(const Ee of ee)oe.indexOf(Ee)<0&&oe.push(Ee);const ce=b?b.defines():[];w&&ce.push("#define OVERDRAW_INSPECTOR;"),D&&ce.push("#define TERRAIN3D;");const ue=ce.concat(No.prelude.fragmentSource,p.fragmentSource).join(`
623
623
  `),pe=ce.concat(No.prelude.vertexSource,p.vertexSource).join(`
624
- `),ne=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(ne,ue),P.compileShader(ne),!P.getShaderParameter(ne,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(ne)}`);P.attachShader(this.program,ne);const be=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(be,pe),P.compileShader(be),!P.getShaderParameter(be,P.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${P.getShaderInfoLog(be)}`);P.attachShader(this.program,be),this.attributes={};const _e={};this.numAttributes=$.length;for(let Ee=0;Ee<this.numAttributes;Ee++)$[Ee]&&(P.bindAttribLocation(this.program,Ee,$[Ee]),this.attributes[$[Ee]]=Ee);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(be),P.deleteShader(ne);for(let Ee=0;Ee<oe.length;Ee++){const Be=oe[Ee];if(Be&&!_e[Be]){const He=P.getUniformLocation(this.program,Be);He&&(_e[Be]=He)}}this.fixedUniforms=_(l,_e),this.terrainUniforms=((Ee,Be)=>({u_depth:new o.aH(Ee,Be.u_depth),u_terrain:new o.aH(Ee,Be.u_terrain),u_terrain_dim:new o.aI(Ee,Be.u_terrain_dim),u_terrain_matrix:new o.aJ(Ee,Be.u_terrain_matrix),u_terrain_unpack:new o.aK(Ee,Be.u_terrain_unpack),u_terrain_exaggeration:new o.aI(Ee,Be.u_terrain_exaggeration)}))(l,_e),this.binderUniforms=b?b.getUniforms(l,_e):[]}draw(l,p,b,_,w,D,P,R,V,$,j,G,Q,ee,oe,ce,ue,pe){const ne=l.gl;if(this.failedToCreate)return;if(l.program.set(this.program),l.setDepthMode(b),l.setStencilMode(_),l.setColorMode(w),l.setCullFace(D),R){l.activeTexture.set(ne.TEXTURE2),ne.bindTexture(ne.TEXTURE_2D,R.depthTexture),l.activeTexture.set(ne.TEXTURE3),ne.bindTexture(ne.TEXTURE_2D,R.texture);for(const _e in this.terrainUniforms)this.terrainUniforms[_e].set(R[_e])}for(const _e in this.fixedUniforms)this.fixedUniforms[_e].set(P[_e]);oe&&oe.setUniforms(l,this.binderUniforms,Q,{zoom:ee});let be=0;switch(p){case ne.LINES:be=2;break;case ne.TRIANGLES:be=3;break;case ne.LINE_STRIP:be=1}for(const _e of G.get()){const Ee=_e.vaos||(_e.vaos={});(Ee[V]||(Ee[V]=new _p)).bind(l,this,$,oe?oe.getPaintVertexBuffers():[],j,_e.vertexOffset,ce,ue,pe),ne.drawElements(p,_e.primitiveLength*be,ne.UNSIGNED_SHORT,_e.primitiveOffset*be*2)}}}function ou(k,l,p){const b=1/on(p,1,l.transform.tileZoom),_=Math.pow(2,p.tileID.overscaledZ),w=p.tileSize*Math.pow(2,l.transform.tileZoom)/_,D=w*(p.tileID.canonical.x+p.tileID.wrap*_),P=w*p.tileID.canonical.y;return{u_image:0,u_texsize:p.imageAtlasTexture.size,u_scale:[b,k.fromScale,k.toScale],u_fade:k.t,u_pixel_coord_upper:[D>>16,P>>16],u_pixel_coord_lower:[65535&D,65535&P]}}const Mc=(k,l,p,b)=>{const _=l.style.light,w=_.properties.get("position"),D=[w.x,w.y,w.z],P=function(){var V=new o.A(9);return o.A!=Float32Array&&(V[1]=0,V[2]=0,V[3]=0,V[5]=0,V[6]=0,V[7]=0),V[0]=1,V[4]=1,V[8]=1,V}();_.properties.get("anchor")==="viewport"&&function(V,$){var j=Math.sin($),G=Math.cos($);V[0]=G,V[1]=j,V[2]=0,V[3]=-j,V[4]=G,V[5]=0,V[6]=0,V[7]=0,V[8]=1}(P,-l.transform.angle),function(V,$,j){var G=$[0],Q=$[1],ee=$[2];V[0]=G*j[0]+Q*j[3]+ee*j[6],V[1]=G*j[1]+Q*j[4]+ee*j[7],V[2]=G*j[2]+Q*j[5]+ee*j[8]}(D,D,P);const R=_.properties.get("color");return{u_matrix:k,u_lightpos:D,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[R.r,R.g,R.b],u_vertical_gradient:+p,u_opacity:b}},au=(k,l,p,b,_,w,D)=>o.e(Mc(k,l,p,b),ou(w,l,D),{u_height_factor:-Math.pow(2,_.overscaledZ)/D.tileSize/8}),pl=k=>({u_matrix:k}),ny=(k,l,p,b)=>o.e(pl(k),ou(p,l,b)),Av=(k,l)=>({u_matrix:k,u_world:l}),ry=(k,l,p,b,_)=>o.e(ny(k,l,p,b),{u_world:_}),Mv=(k,l,p,b)=>{const _=k.transform;let w,D;if(b.paint.get("circle-pitch-alignment")==="map"){const P=on(p,1,_.zoom);w=!0,D=[P,P]}else w=!1,D=_.pixelsToGLUnits;return{u_camera_to_center_distance:_.cameraToCenterDistance,u_scale_with_map:+(b.paint.get("circle-pitch-scale")==="map"),u_matrix:k.translatePosMatrix(l.posMatrix,p,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_pitch_with_map:+w,u_device_pixel_ratio:k.pixelRatio,u_extrude_scale:D}},ga=(k,l,p)=>({u_matrix:k,u_inv_matrix:l,u_camera_to_center_distance:p.cameraToCenterDistance,u_viewport_size:[p.width,p.height]}),Dc=(k,l,p=1)=>({u_matrix:k,u_color:l,u_overlay:0,u_overlay_scale:p}),xi=k=>({u_matrix:k}),vi=(k,l,p,b)=>({u_matrix:k,u_extrude_scale:on(l,1,p),u_intensity:b}),lu=(k,l,p,b)=>{const _=o.H();o.aP(_,0,k.width,k.height,0,0,1);const w=k.context.gl;return{u_matrix:_,u_world:[w.drawingBufferWidth,w.drawingBufferHeight],u_image:p,u_color_ramp:b,u_opacity:l.paint.get("heatmap-opacity")}};function cu(k,l){const p=Math.pow(2,l.canonical.z),b=l.canonical.y;return[new o.Z(0,b/p).toLngLat().lat,new o.Z(0,(b+1)/p).toLngLat().lat]}const du=(k,l,p,b)=>{const _=k.transform;return{u_matrix:oy(k,l,p,b),u_ratio:1/on(l,1,_.zoom),u_device_pixel_ratio:k.pixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]]}},iy=(k,l,p,b,_)=>o.e(du(k,l,p,_),{u_image:0,u_image_height:b}),fl=(k,l,p,b,_)=>{const w=k.transform,D=sy(l,w);return{u_matrix:oy(k,l,p,_),u_texsize:l.imageAtlasTexture.size,u_ratio:1/on(l,1,w.zoom),u_device_pixel_ratio:k.pixelRatio,u_image:0,u_scale:[D,b.fromScale,b.toScale],u_fade:b.t,u_units_to_pixels:[1/w.pixelsToGLUnits[0],1/w.pixelsToGLUnits[1]]}},Dv=(k,l,p,b,_,w)=>{const D=k.lineAtlas,P=sy(l,k.transform),R=p.layout.get("line-cap")==="round",V=D.getDash(b.from,R),$=D.getDash(b.to,R),j=V.width*_.fromScale,G=$.width*_.toScale;return o.e(du(k,l,p,w),{u_patternscale_a:[P/j,-V.height/2],u_patternscale_b:[P/G,-$.height/2],u_sdfgamma:D.width/(256*Math.min(j,G)*k.pixelRatio)/2,u_image:0,u_tex_y_a:V.y,u_tex_y_b:$.y,u_mix:_.t})};function sy(k,l){return 1/on(k,1,l.tileZoom)}function oy(k,l,p,b){return k.translatePosMatrix(b?b.posMatrix:l.tileID.posMatrix,l,p.paint.get("line-translate"),p.paint.get("line-translate-anchor"))}const Iv=(k,l,p,b,_)=>{return{u_matrix:k,u_tl_parent:l,u_scale_parent:p,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:(D=_.paint.get("raster-saturation"),D>0?1-1/(1.001-D):-D),u_contrast_factor:(w=_.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:Pv(_.paint.get("raster-hue-rotate"))};var w,D};function Pv(k){k*=Math.PI/180;const l=Math.sin(k),p=Math.cos(k);return[(2*p+1)/3,(-Math.sqrt(3)*l-p+1)/3,(Math.sqrt(3)*l-p+1)/3]}const ay=(k,l,p,b,_,w,D,P,R,V,$,j,G,Q)=>{const ee=D.transform;return{u_is_size_zoom_constant:+(k==="constant"||k==="source"),u_is_size_feature_constant:+(k==="constant"||k==="camera"),u_size_t:l?l.uSizeT:0,u_size:l?l.uSize:0,u_camera_to_center_distance:ee.cameraToCenterDistance,u_pitch:ee.pitch/360*2*Math.PI,u_rotate_symbol:+p,u_aspect_ratio:ee.width/ee.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:R,u_coord_matrix:V,u_is_text:+j,u_pitch_with_map:+b,u_is_along_line:_,u_is_variable_anchor:w,u_texsize:G,u_texture:0,u_translation:$,u_pitched_scale:Q}},Ic=(k,l,p,b,_,w,D,P,R,V,$,j,G,Q,ee)=>{const oe=D.transform;return o.e(ay(k,l,p,b,_,w,D,P,R,V,$,j,G,ee),{u_gamma_scale:b?Math.cos(oe._pitch)*oe.cameraToCenterDistance:1,u_device_pixel_ratio:D.pixelRatio,u_is_halo:+Q})},wp=(k,l,p,b,_,w,D,P,R,V,$,j,G,Q)=>o.e(Ic(k,l,p,b,_,w,D,P,R,V,$,!0,j,!0,Q),{u_texsize_icon:G,u_texture_icon:1}),uu=(k,l,p)=>({u_matrix:k,u_opacity:l,u_color:p}),kp=(k,l,p,b,_,w)=>o.e(function(D,P,R,V){const $=R.imageManager.getPattern(D.from.toString()),j=R.imageManager.getPattern(D.to.toString()),{width:G,height:Q}=R.imageManager.getPixelSize(),ee=Math.pow(2,V.tileID.overscaledZ),oe=V.tileSize*Math.pow(2,R.transform.tileZoom)/ee,ce=oe*(V.tileID.canonical.x+V.tileID.wrap*ee),ue=oe*V.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:[G,Q],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/on(V,1,R.transform.tileZoom),u_pixel_coord_upper:[ce>>16,ue>>16],u_pixel_coord_lower:[65535&ce,65535&ue]}}(b,w,p,_),{u_matrix:k,u_opacity:l}),Ep={fillExtrusion:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_lightpos:new o.aN(k,l.u_lightpos),u_lightintensity:new o.aI(k,l.u_lightintensity),u_lightcolor:new o.aN(k,l.u_lightcolor),u_vertical_gradient:new o.aI(k,l.u_vertical_gradient),u_opacity:new o.aI(k,l.u_opacity)}),fillExtrusionPattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_lightpos:new o.aN(k,l.u_lightpos),u_lightintensity:new o.aI(k,l.u_lightintensity),u_lightcolor:new o.aN(k,l.u_lightcolor),u_vertical_gradient:new o.aI(k,l.u_vertical_gradient),u_height_factor:new o.aI(k,l.u_height_factor),u_image:new o.aH(k,l.u_image),u_texsize:new o.aO(k,l.u_texsize),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade),u_opacity:new o.aI(k,l.u_opacity)}),fill:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix)}),fillPattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_image:new o.aH(k,l.u_image),u_texsize:new o.aO(k,l.u_texsize),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade)}),fillOutline:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_world:new o.aO(k,l.u_world)}),fillOutlinePattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_world:new o.aO(k,l.u_world),u_image:new o.aH(k,l.u_image),u_texsize:new o.aO(k,l.u_texsize),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade)}),circle:(k,l)=>({u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_scale_with_map:new o.aH(k,l.u_scale_with_map),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_extrude_scale:new o.aO(k,l.u_extrude_scale),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_matrix:new o.aJ(k,l.u_matrix)}),collisionBox:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_pixel_extrude_scale:new o.aO(k,l.u_pixel_extrude_scale)}),collisionCircle:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_inv_matrix:new o.aJ(k,l.u_inv_matrix),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_viewport_size:new o.aO(k,l.u_viewport_size)}),debug:(k,l)=>({u_color:new o.aL(k,l.u_color),u_matrix:new o.aJ(k,l.u_matrix),u_overlay:new o.aH(k,l.u_overlay),u_overlay_scale:new o.aI(k,l.u_overlay_scale)}),clippingMask:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix)}),heatmap:(k,l)=>({u_extrude_scale:new o.aI(k,l.u_extrude_scale),u_intensity:new o.aI(k,l.u_intensity),u_matrix:new o.aJ(k,l.u_matrix)}),heatmapTexture:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_world:new o.aO(k,l.u_world),u_image:new o.aH(k,l.u_image),u_color_ramp:new o.aH(k,l.u_color_ramp),u_opacity:new o.aI(k,l.u_opacity)}),hillshade:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_image:new o.aH(k,l.u_image),u_latrange:new o.aO(k,l.u_latrange),u_light:new o.aO(k,l.u_light),u_shadow:new o.aL(k,l.u_shadow),u_highlight:new o.aL(k,l.u_highlight),u_accent:new o.aL(k,l.u_accent)}),hillshadePrepare:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_image:new o.aH(k,l.u_image),u_dimension:new o.aO(k,l.u_dimension),u_zoom:new o.aI(k,l.u_zoom),u_unpack:new o.aK(k,l.u_unpack)}),line:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels)}),lineGradient:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels),u_image:new o.aH(k,l.u_image),u_image_height:new o.aI(k,l.u_image_height)}),linePattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_texsize:new o.aO(k,l.u_texsize),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_image:new o.aH(k,l.u_image),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade)}),lineSDF:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels),u_patternscale_a:new o.aO(k,l.u_patternscale_a),u_patternscale_b:new o.aO(k,l.u_patternscale_b),u_sdfgamma:new o.aI(k,l.u_sdfgamma),u_image:new o.aH(k,l.u_image),u_tex_y_a:new o.aI(k,l.u_tex_y_a),u_tex_y_b:new o.aI(k,l.u_tex_y_b),u_mix:new o.aI(k,l.u_mix)}),raster:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_tl_parent:new o.aO(k,l.u_tl_parent),u_scale_parent:new o.aI(k,l.u_scale_parent),u_buffer_scale:new o.aI(k,l.u_buffer_scale),u_fade_t:new o.aI(k,l.u_fade_t),u_opacity:new o.aI(k,l.u_opacity),u_image0:new o.aH(k,l.u_image0),u_image1:new o.aH(k,l.u_image1),u_brightness_low:new o.aI(k,l.u_brightness_low),u_brightness_high:new o.aI(k,l.u_brightness_high),u_saturation_factor:new o.aI(k,l.u_saturation_factor),u_contrast_factor:new o.aI(k,l.u_contrast_factor),u_spin_weights:new o.aN(k,l.u_spin_weights)}),symbolIcon:(k,l)=>({u_is_size_zoom_constant:new o.aH(k,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(k,l.u_is_size_feature_constant),u_size_t:new o.aI(k,l.u_size_t),u_size:new o.aI(k,l.u_size),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_pitch:new o.aI(k,l.u_pitch),u_rotate_symbol:new o.aH(k,l.u_rotate_symbol),u_aspect_ratio:new o.aI(k,l.u_aspect_ratio),u_fade_change:new o.aI(k,l.u_fade_change),u_matrix:new o.aJ(k,l.u_matrix),u_label_plane_matrix:new o.aJ(k,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(k,l.u_coord_matrix),u_is_text:new o.aH(k,l.u_is_text),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_is_along_line:new o.aH(k,l.u_is_along_line),u_is_variable_anchor:new o.aH(k,l.u_is_variable_anchor),u_texsize:new o.aO(k,l.u_texsize),u_texture:new o.aH(k,l.u_texture),u_translation:new o.aO(k,l.u_translation),u_pitched_scale:new o.aI(k,l.u_pitched_scale)}),symbolSDF:(k,l)=>({u_is_size_zoom_constant:new o.aH(k,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(k,l.u_is_size_feature_constant),u_size_t:new o.aI(k,l.u_size_t),u_size:new o.aI(k,l.u_size),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_pitch:new o.aI(k,l.u_pitch),u_rotate_symbol:new o.aH(k,l.u_rotate_symbol),u_aspect_ratio:new o.aI(k,l.u_aspect_ratio),u_fade_change:new o.aI(k,l.u_fade_change),u_matrix:new o.aJ(k,l.u_matrix),u_label_plane_matrix:new o.aJ(k,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(k,l.u_coord_matrix),u_is_text:new o.aH(k,l.u_is_text),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_is_along_line:new o.aH(k,l.u_is_along_line),u_is_variable_anchor:new o.aH(k,l.u_is_variable_anchor),u_texsize:new o.aO(k,l.u_texsize),u_texture:new o.aH(k,l.u_texture),u_gamma_scale:new o.aI(k,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_is_halo:new o.aH(k,l.u_is_halo),u_translation:new o.aO(k,l.u_translation),u_pitched_scale:new o.aI(k,l.u_pitched_scale)}),symbolTextAndIcon:(k,l)=>({u_is_size_zoom_constant:new o.aH(k,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(k,l.u_is_size_feature_constant),u_size_t:new o.aI(k,l.u_size_t),u_size:new o.aI(k,l.u_size),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_pitch:new o.aI(k,l.u_pitch),u_rotate_symbol:new o.aH(k,l.u_rotate_symbol),u_aspect_ratio:new o.aI(k,l.u_aspect_ratio),u_fade_change:new o.aI(k,l.u_fade_change),u_matrix:new o.aJ(k,l.u_matrix),u_label_plane_matrix:new o.aJ(k,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(k,l.u_coord_matrix),u_is_text:new o.aH(k,l.u_is_text),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_is_along_line:new o.aH(k,l.u_is_along_line),u_is_variable_anchor:new o.aH(k,l.u_is_variable_anchor),u_texsize:new o.aO(k,l.u_texsize),u_texsize_icon:new o.aO(k,l.u_texsize_icon),u_texture:new o.aH(k,l.u_texture),u_texture_icon:new o.aH(k,l.u_texture_icon),u_gamma_scale:new o.aI(k,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_is_halo:new o.aH(k,l.u_is_halo),u_translation:new o.aO(k,l.u_translation),u_pitched_scale:new o.aI(k,l.u_pitched_scale)}),background:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_opacity:new o.aI(k,l.u_opacity),u_color:new o.aL(k,l.u_color)}),backgroundPattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_opacity:new o.aI(k,l.u_opacity),u_image:new o.aH(k,l.u_image),u_pattern_tl_a:new o.aO(k,l.u_pattern_tl_a),u_pattern_br_a:new o.aO(k,l.u_pattern_br_a),u_pattern_tl_b:new o.aO(k,l.u_pattern_tl_b),u_pattern_br_b:new o.aO(k,l.u_pattern_br_b),u_texsize:new o.aO(k,l.u_texsize),u_mix:new o.aI(k,l.u_mix),u_pattern_size_a:new o.aO(k,l.u_pattern_size_a),u_pattern_size_b:new o.aO(k,l.u_pattern_size_b),u_scale_a:new o.aI(k,l.u_scale_a),u_scale_b:new o.aI(k,l.u_scale_b),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aI(k,l.u_tile_units_to_pixels)}),terrain:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_texture:new o.aH(k,l.u_texture),u_ele_delta:new o.aI(k,l.u_ele_delta),u_fog_matrix:new o.aJ(k,l.u_fog_matrix),u_fog_color:new o.aL(k,l.u_fog_color),u_fog_ground_blend:new o.aI(k,l.u_fog_ground_blend),u_fog_ground_blend_opacity:new o.aI(k,l.u_fog_ground_blend_opacity),u_horizon_color:new o.aL(k,l.u_horizon_color),u_horizon_fog_blend:new o.aI(k,l.u_horizon_fog_blend)}),terrainDepth:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ele_delta:new o.aI(k,l.u_ele_delta)}),terrainCoords:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_texture:new o.aH(k,l.u_texture),u_terrain_coords_id:new o.aI(k,l.u_terrain_coords_id),u_ele_delta:new o.aI(k,l.u_ele_delta)}),sky:(k,l)=>({u_sky_color:new o.aL(k,l.u_sky_color),u_horizon_color:new o.aL(k,l.u_horizon_color),u_horizon:new o.aI(k,l.u_horizon),u_sky_horizon_blend:new o.aI(k,l.u_sky_horizon_blend)})};class Gs{constructor(l,p,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,p.arrayBuffer,this.dynamicDraw?_.DYNAMIC_DRAW:_.STATIC_DRAW),this.dynamicDraw||delete p.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(l){const p=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),p.bufferSubData(p.ELEMENT_ARRAY_BUFFER,0,l.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Rv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Sp{constructor(l,p,b,_){this.length=p.length,this.attributes=b,this.itemSize=p.bytesPerElement,this.dynamicDraw=_,this.context=l;const w=l.gl;this.buffer=w.createBuffer(),l.bindVertexBuffer.set(this.buffer),w.bufferData(w.ARRAY_BUFFER,p.arrayBuffer,this.dynamicDraw?w.DYNAMIC_DRAW:w.STATIC_DRAW),this.dynamicDraw||delete p.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 p=this.context.gl;this.bind(),p.bufferSubData(p.ARRAY_BUFFER,0,l.arrayBuffer)}enableAttributes(l,p){for(let b=0;b<this.attributes.length;b++){const _=p.attributes[this.attributes[b].name];_!==void 0&&l.enableVertexAttribArray(_)}}setVertexAttribPointers(l,p,b){for(let _=0;_<this.attributes.length;_++){const w=this.attributes[_],D=p.attributes[w.name];D!==void 0&&l.vertexAttribPointer(D,w.components,l[Rv[w.type]],!1,this.itemSize,w.offset+this.itemSize*(b||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ya=new WeakMap;function Oo(k){var l;if(ya.has(k))return ya.get(k);{const p=(l=k.getParameter(k.VERSION))===null||l===void 0?void 0:l.startsWith("WebGL 2.0");return ya.set(k,p),p}}class Sn{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 hu extends Sn{getDefault(){return o.aM.transparent}set(l){const p=this.current;(l.r!==p.r||l.g!==p.g||l.b!==p.b||l.a!==p.a||this.dirty)&&(this.gl.clearColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class Nv extends Sn{getDefault(){return 1}set(l){(l!==this.current||this.dirty)&&(this.gl.clearDepth(l),this.current=l,this.dirty=!1)}}class ml extends Sn{getDefault(){return 0}set(l){(l!==this.current||this.dirty)&&(this.gl.clearStencil(l),this.current=l,this.dirty=!1)}}class Ov extends Sn{getDefault(){return[!0,!0,!0,!0]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||l[2]!==p[2]||l[3]!==p[3]||this.dirty)&&(this.gl.colorMask(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class ly extends Sn{getDefault(){return!0}set(l){(l!==this.current||this.dirty)&&(this.gl.depthMask(l),this.current=l,this.dirty=!1)}}class Bv extends Sn{getDefault(){return 255}set(l){(l!==this.current||this.dirty)&&(this.gl.stencilMask(l),this.current=l,this.dirty=!1)}}class cy extends Sn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(l){const p=this.current;(l.func!==p.func||l.ref!==p.ref||l.mask!==p.mask||this.dirty)&&(this.gl.stencilFunc(l.func,l.ref,l.mask),this.current=l,this.dirty=!1)}}class Cp extends Sn{getDefault(){const l=this.gl;return[l.KEEP,l.KEEP,l.KEEP]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||l[2]!==p[2]||this.dirty)&&(this.gl.stencilOp(l[0],l[1],l[2]),this.current=l,this.dirty=!1)}}class dy extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.STENCIL_TEST):p.disable(p.STENCIL_TEST),this.current=l,this.dirty=!1}}class uy extends Sn{getDefault(){return[0,1]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||this.dirty)&&(this.gl.depthRange(l[0],l[1]),this.current=l,this.dirty=!1)}}class hy extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.DEPTH_TEST):p.disable(p.DEPTH_TEST),this.current=l,this.dirty=!1}}class py extends Sn{getDefault(){return this.gl.LESS}set(l){(l!==this.current||this.dirty)&&(this.gl.depthFunc(l),this.current=l,this.dirty=!1)}}class ba extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.BLEND):p.disable(p.BLEND),this.current=l,this.dirty=!1}}class fy extends Sn{getDefault(){const l=this.gl;return[l.ONE,l.ZERO]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||this.dirty)&&(this.gl.blendFunc(l[0],l[1]),this.current=l,this.dirty=!1)}}class zv extends Sn{getDefault(){return o.aM.transparent}set(l){const p=this.current;(l.r!==p.r||l.g!==p.g||l.b!==p.b||l.a!==p.a||this.dirty)&&(this.gl.blendColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class my extends Sn{getDefault(){return this.gl.FUNC_ADD}set(l){(l!==this.current||this.dirty)&&(this.gl.blendEquation(l),this.current=l,this.dirty=!1)}}class Pc extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.CULL_FACE):p.disable(p.CULL_FACE),this.current=l,this.dirty=!1}}class Vv extends Sn{getDefault(){return this.gl.BACK}set(l){(l!==this.current||this.dirty)&&(this.gl.cullFace(l),this.current=l,this.dirty=!1)}}class pu extends Sn{getDefault(){return this.gl.CCW}set(l){(l!==this.current||this.dirty)&&(this.gl.frontFace(l),this.current=l,this.dirty=!1)}}class Lv extends Sn{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}}class Fv extends Sn{getDefault(){return this.gl.TEXTURE0}set(l){(l!==this.current||this.dirty)&&(this.gl.activeTexture(l),this.current=l,this.dirty=!1)}}class gy extends Sn{getDefault(){const l=this.gl;return[0,0,l.drawingBufferWidth,l.drawingBufferHeight]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||l[2]!==p[2]||l[3]!==p[3]||this.dirty)&&(this.gl.viewport(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class yy extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindFramebuffer(p.FRAMEBUFFER,l),this.current=l,this.dirty=!1}}class by extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindRenderbuffer(p.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Tp extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindTexture(p.TEXTURE_2D,l),this.current=l,this.dirty=!1}}class _y extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindBuffer(p.ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class fu extends Sn{getDefault(){return null}set(l){const p=this.gl;p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class uo extends Sn{getDefault(){return null}set(l){var p;if(l===this.current&&!this.dirty)return;const b=this.gl;Oo(b)?b.bindVertexArray(l):(p=b.getExtension("OES_vertex_array_object"))===null||p===void 0||p.bindVertexArrayOES(l),this.current=l,this.dirty=!1}}class Ap extends Sn{getDefault(){return 4}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.pixelStorei(p.UNPACK_ALIGNMENT,l),this.current=l,this.dirty=!1}}class Mp extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),this.current=l,this.dirty=!1}}class Dp extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,l),this.current=l,this.dirty=!1}}class mu extends Sn{constructor(l,p){super(l),this.context=l,this.parent=p}getDefault(){return null}}class Ip extends mu{setDirty(){this.dirty=!0}set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const p=this.gl;p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,l,0),this.current=l,this.dirty=!1}}class _a extends mu{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const p=this.gl;p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_ATTACHMENT,p.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Pp extends mu{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const p=this.gl;p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_STENCIL_ATTACHMENT,p.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class $v{constructor(l,p,b,_,w){this.context=l,this.width=p,this.height=b;const D=l.gl,P=this.framebuffer=D.createFramebuffer();if(this.colorAttachment=new Ip(l,P),_)this.depthAttachment=w?new Pp(l,P):new _a(l,P);else if(w)throw new Error("Stencil cannot be set without depth");if(D.checkFramebufferStatus(D.FRAMEBUFFER)!==D.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const l=this.context.gl,p=this.colorAttachment.get();if(p&&l.deleteTexture(p),this.depthAttachment){const b=this.depthAttachment.get();b&&l.deleteRenderbuffer(b)}l.deleteFramebuffer(this.framebuffer)}}class dr{constructor(l,p,b){this.blendFunction=l,this.blendColor=p,this.mask=b}}dr.Replace=[1,0],dr.disabled=new dr(dr.Replace,o.aM.transparent,[!1,!1,!1,!1]),dr.unblended=new dr(dr.Replace,o.aM.transparent,[!0,!0,!0,!0]),dr.alphaBlended=new dr([1,771],o.aM.transparent,[!0,!0,!0,!0]);class jv{constructor(l){var p,b;if(this.gl=l,this.clearColor=new hu(this),this.clearDepth=new Nv(this),this.clearStencil=new ml(this),this.colorMask=new Ov(this),this.depthMask=new ly(this),this.stencilMask=new Bv(this),this.stencilFunc=new cy(this),this.stencilOp=new Cp(this),this.stencilTest=new dy(this),this.depthRange=new uy(this),this.depthTest=new hy(this),this.depthFunc=new py(this),this.blend=new ba(this),this.blendFunc=new fy(this),this.blendColor=new zv(this),this.blendEquation=new my(this),this.cullFace=new Pc(this),this.cullFaceSide=new Vv(this),this.frontFace=new pu(this),this.program=new Lv(this),this.activeTexture=new Fv(this),this.viewport=new gy(this),this.bindFramebuffer=new yy(this),this.bindRenderbuffer=new by(this),this.bindTexture=new Tp(this),this.bindVertexBuffer=new _y(this),this.bindElementBuffer=new fu(this),this.bindVertexArray=new uo(this),this.pixelStoreUnpack=new Ap(this),this.pixelStoreUnpackPremultiplyAlpha=new Mp(this),this.pixelStoreUnpackFlipY=new Dp(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),Oo(l)){this.HALF_FLOAT=l.HALF_FLOAT;const _=l.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(p=l.RGBA16F)!==null&&p!==void 0?p:_==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,p){return new Gs(this,l,p)}createVertexBuffer(l,p,b){return new Sp(this,l,p,b)}createRenderbuffer(l,p,b){const _=this.gl,w=_.createRenderbuffer();return this.bindRenderbuffer.set(w),_.renderbufferStorage(_.RENDERBUFFER,l,p,b),this.bindRenderbuffer.set(null),w}createFramebuffer(l,p,b,_){return new $v(this,l,p,b,_)}clear({color:l,depth:p,stencil:b}){const _=this.gl;let w=0;l&&(w|=_.COLOR_BUFFER_BIT,this.clearColor.set(l),this.colorMask.set([!0,!0,!0,!0])),p!==void 0&&(w|=_.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(p),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,dr.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 Oo(this.gl)?this.gl.createVertexArray():(l=this.gl.getExtension("OES_vertex_array_object"))===null||l===void 0?void 0:l.createVertexArrayOES()}deleteVertexArray(l){var p;return Oo(this.gl)?this.gl.deleteVertexArray(l):(p=this.gl.getExtension("OES_vertex_array_object"))===null||p===void 0?void 0:p.deleteVertexArrayOES(l)}unbindVAO(){this.bindVertexArray.set(null)}}class en{constructor(l,p,b){this.func=l,this.mask=p,this.range=b}}en.ReadOnly=!1,en.ReadWrite=!0,en.disabled=new en(519,en.ReadOnly,[0,1]);const gu=7680;class $n{constructor(l,p,b,_,w,D){this.test=l,this.ref=p,this.mask=b,this.fail=_,this.depthFail=w,this.pass=D}}$n.disabled=new $n({func:519,mask:0},0,0,gu,gu,gu);class On{constructor(l,p,b){this.enable=l,this.mode=p,this.frontFace=b}}let xa;function Rc(k,l,p,b,_){const w=k.context,D=w.gl,P=k.useProgram("collisionBox"),R=[];let V=0,$=0;for(let ue=0;ue<b.length;ue++){const pe=b[ue],ne=l.getTile(pe).getBucket(p);if(!ne)continue;const be=_?ne.textCollisionBox:ne.iconCollisionBox,_e=ne.collisionCircleArray;if(_e.length>0){const Ee=o.H();o.aQ(Ee,ne.placementInvProjMatrix,k.transform.glCoordMatrix),o.aQ(Ee,Ee,ne.placementViewportMatrix),R.push({circleArray:_e,circleOffset:$,transform:pe.posMatrix,invTransform:Ee,coord:pe}),V+=_e.length/4,$=V}be&&P.draw(w,D.LINES,en.disabled,$n.disabled,k.colorModeForRenderPass(),On.disabled,{u_matrix:pe.posMatrix,u_pixel_extrude_scale:[1/(j=k.transform).width,1/j.height]},k.style.map.terrain&&k.style.map.terrain.getTerrainData(pe),p.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,null,k.transform.zoom,null,null,be.collisionVertexBuffer)}var j;if(!_||!R.length)return;const G=k.useProgram("collisionCircle"),Q=new o.aR;Q.resize(4*V),Q._trim();let ee=0;for(const ue of R)for(let pe=0;pe<ue.circleArray.length/4;pe++){const ne=4*pe,be=ue.circleArray[ne+0],_e=ue.circleArray[ne+1],Ee=ue.circleArray[ne+2],Be=ue.circleArray[ne+3];Q.emplace(ee++,be,_e,Ee,Be,0),Q.emplace(ee++,be,_e,Ee,Be,1),Q.emplace(ee++,be,_e,Ee,Be,2),Q.emplace(ee++,be,_e,Ee,Be,3)}(!xa||xa.length<2*V)&&(xa=function(ue){const pe=2*ue,ne=new o.aT;ne.resize(pe),ne._trim();for(let be=0;be<pe;be++){const _e=6*be;ne.uint16[_e+0]=4*be+0,ne.uint16[_e+1]=4*be+1,ne.uint16[_e+2]=4*be+2,ne.uint16[_e+3]=4*be+2,ne.uint16[_e+4]=4*be+3,ne.uint16[_e+5]=4*be+0}return ne}(V));const oe=w.createIndexBuffer(xa,!0),ce=w.createVertexBuffer(Q,o.aS.members,!0);for(const ue of R){const pe=ga(ue.transform,ue.invTransform,k.transform);G.draw(w,D.TRIANGLES,en.disabled,$n.disabled,k.colorModeForRenderPass(),On.disabled,pe,k.style.map.terrain&&k.style.map.terrain.getTerrainData(ue.coord),p.id,ce,oe,o.a0.simpleSegment(0,2*ue.circleOffset,ue.circleArray.length,ue.circleArray.length/2),null,k.transform.zoom,null,null,null)}ce.destroy(),oe.destroy()}On.disabled=new On(!1,1029,2305),On.backCCW=new On(!0,1029,2305);const Nc=o.an(new Float32Array(16));function Rp(k,l,p,b,_,w){const{horizontalAlign:D,verticalAlign:P}=o.au(k);return new o.P((-(D-.5)*l/_+b[0])*w,(-(P-.5)*p/_+b[1])*w)}function va(k,l,p,b,_,w){const D=l.tileAnchorPoint.add(new o.P(l.translation[0],l.translation[1]));if(l.pitchWithMap){let P=b.mult(w);p||(P=P.rotate(-_));const R=D.add(P);return ae(R.x,R.y,l.labelPlaneMatrix,l.getElevation).point}if(p){const P=Pe(l.tileAnchorPoint.x+1,l.tileAnchorPoint.y,l).point.sub(k),R=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return k.add(b.rotate(R))}return k.add(b)}function gl(k,l,p,b,_,w,D,P,R,V,$,j,G,Q){const ee=k.text.placedSymbolArray,oe=k.text.dynamicLayoutVertexArray,ce=k.icon.dynamicLayoutVertexArray,ue={};oe.clear();for(let pe=0;pe<ee.length;pe++){const ne=ee.get(pe),be=ne.hidden||!ne.crossTileID||k.allowVerticalPlacement&&!ne.placedOrientation?null:b[ne.crossTileID];if(be){const _e=new o.P(ne.anchorX,ne.anchorY),Ee={getElevation:Q,width:_.width,height:_.height,labelPlaneMatrix:w,lineVertexArray:null,pitchWithMap:p,projection:$,projectionCache:null,tileAnchorPoint:_e,translation:j,unwrappedTileID:G},Be=p?ae(_e.x,_e.y,D,Q):Pe(_e.x,_e.y,Ee),He=W(_.cameraToCenterDistance,Be.signedDistanceFromCamera);let nt=o.ai(k.textSizeData,R,ne)*He/o.ap;p&&(nt*=k.tilePixelRatio/P);const{width:ct,height:Xe,anchor:Ze,textOffset:_t,textBoxScale:Vt}=be,Je=Rp(Ze,ct,Xe,_t,Vt,nt),ot=$.getPitchedTextCorrection(_,_e.add(new o.P(j[0],j[1])),G),Bt=va(Be.point,Ee,l,Je,_.angle,ot),Gn=k.allowVerticalPlacement&&ne.placedOrientation===o.ah.vertical?Math.PI/2:0;for(let Gt=0;Gt<ne.numGlyphs;Gt++)o.aj(oe,Bt,Gn);V&&ne.associatedIconIndex>=0&&(ue[ne.associatedIconIndex]={shiftedAnchor:Bt,angle:Gn})}else At(ne.numGlyphs,oe)}if(V){ce.clear();const pe=k.icon.placedSymbolArray;for(let ne=0;ne<pe.length;ne++){const be=pe.get(ne);if(be.hidden)At(be.numGlyphs,ce);else{const _e=ue[ne];if(_e)for(let Ee=0;Ee<be.numGlyphs;Ee++)o.aj(ce,_e.shiftedAnchor,_e.angle);else At(be.numGlyphs,ce)}}k.icon.dynamicLayoutVertexBuffer.updateData(ce)}k.text.dynamicLayoutVertexBuffer.updateData(oe)}function rs(k,l,p){return p.iconsInText&&l?"symbolTextAndIcon":k?"symbolSDF":"symbolIcon"}function Np(k,l,p,b,_,w,D,P,R,V,$,j){const G=k.context,Q=G.gl,ee=k.transform,oe=fa(),ce=P==="map",ue=R==="map",pe=P!=="viewport"&&p.layout.get("symbol-placement")!=="point",ne=ce&&!ue&&!pe,be=!ue&&pe,_e=!p.layout.get("symbol-sort-key").isConstant();let Ee=!1;const Be=k.depthModeForSublayer(0,en.ReadOnly),He=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),nt=[],ct=oe.getCircleRadiusCorrection(ee);for(const Xe of b){const Ze=l.getTile(Xe),_t=Ze.getBucket(p);if(!_t)continue;const Vt=_?_t.text:_t.icon;if(!Vt||!Vt.segments.get().length||!Vt.hasVisibleVertices)continue;const Je=Vt.programConfigurations.get(p.id),ot=_||_t.sdfIcons,Bt=_?_t.textSizeData:_t.iconSizeData,Gn=ue||ee.pitch!==0,Gt=k.useProgram(rs(ot,_,_t),Je),an=o.ag(Bt,ee.zoom),Yn=k.style.map.terrain&&k.style.map.terrain.getTerrainData(Xe);let Gr,Ss,Zn,wi,ci=[0,0],Yr=null;if(_)Ss=Ze.glyphAtlasTexture,Zn=Q.LINEAR,Gr=Ze.glyphAtlasTexture.size,_t.iconsInText&&(ci=Ze.imageAtlasTexture.size,Yr=Ze.imageAtlasTexture,wi=Gn||k.options.rotating||k.options.zooming||Bt.kind==="composite"||Bt.kind==="camera"?Q.LINEAR:Q.NEAREST);else{const un=p.layout.get("icon-size").constantOr(0)!==1||_t.iconsNeedLinear;Ss=Ze.imageAtlasTexture,Zn=ot||k.options.rotating||k.options.zooming||un||Gn?Q.LINEAR:Q.NEAREST,Gr=Ze.imageAtlasTexture.size}const di=on(Ze,1,k.transform.zoom),Xs=be?Xe.posMatrix:Nc,Pl=ai(Xs,ue,ce,k.transform,di),Ou=Bi(Xs,ue,ce,k.transform,di),Rl=Bi(Xe.posMatrix,ue,ce,k.transform,di),as=oe.translatePosition(k.transform,Ze,w,D),Bu=He&&_t.hasTextData(),of=p.layout.get("icon-text-fit")!=="none"&&Bu&&_t.hasIconData();if(pe){const un=k.style.map.terrain?(Nl,Ol)=>k.style.map.terrain.getElevation(Xe,Nl,Ol):null,Ca=p.layout.get("text-rotation-alignment")==="map";K(_t,Xe.posMatrix,k,_,Pl,Rl,ue,V,Ca,oe,Xe.toUnwrapped(),ee.width,ee.height,as,un)}const ls=Xe.posMatrix,cs=_&&He||of,Bo=pe||cs?Nc:Pl,Cs=Ou,Br=ot&&p.paint.get(_?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Zr;Zr=ot?_t.iconsInText?wp(Bt.kind,an,ne,ue,pe,cs,k,ls,Bo,Cs,as,Gr,ci,ct):Ic(Bt.kind,an,ne,ue,pe,cs,k,ls,Bo,Cs,as,_,Gr,!0,ct):ay(Bt.kind,an,ne,ue,pe,cs,k,ls,Bo,Cs,as,_,Gr,ct);const ji={program:Gt,buffers:Vt,uniformValues:Zr,atlasTexture:Ss,atlasTextureIcon:Yr,atlasInterpolation:Zn,atlasInterpolationIcon:wi,isSDF:ot,hasHalo:Br};if(_e&&_t.canOverlap){Ee=!0;const un=Vt.segments.get();for(const Ca of un)nt.push({segments:new o.a0([Ca]),sortKey:Ca.sortKey,state:ji,terrainData:Yn})}else nt.push({segments:Vt.segments,sortKey:0,state:ji,terrainData:Yn})}Ee&&nt.sort((Xe,Ze)=>Xe.sortKey-Ze.sortKey);for(const Xe of nt){const Ze=Xe.state;if(G.activeTexture.set(Q.TEXTURE0),Ze.atlasTexture.bind(Ze.atlasInterpolation,Q.CLAMP_TO_EDGE),Ze.atlasTextureIcon&&(G.activeTexture.set(Q.TEXTURE1),Ze.atlasTextureIcon&&Ze.atlasTextureIcon.bind(Ze.atlasInterpolationIcon,Q.CLAMP_TO_EDGE)),Ze.isSDF){const _t=Ze.uniformValues;Ze.hasHalo&&(_t.u_is_halo=1,Op(Ze.buffers,Xe.segments,p,k,Ze.program,Be,$,j,_t,Xe.terrainData)),_t.u_is_halo=0}Op(Ze.buffers,Xe.segments,p,k,Ze.program,Be,$,j,Ze.uniformValues,Xe.terrainData)}}function Op(k,l,p,b,_,w,D,P,R,V){const $=b.context;_.draw($,$.gl.TRIANGLES,w,D,P,On.disabled,R,V,p.id,k.layoutVertexBuffer,k.indexBuffer,l,p.paint,b.transform.zoom,k.programConfigurations.get(p.id),k.dynamicLayoutVertexBuffer,k.opacityVertexBuffer)}function Bp(k,l,p,b){const _=k.context,w=_.gl,D=$n.disabled,P=new dr([w.ONE,w.ONE],o.aM.transparent,[!0,!0,!0,!0]),R=l.getBucket(p);if(!R)return;const V=b.key;let $=p.heatmapFbos.get(V);$||($=Oc(_,l.tileSize,l.tileSize),p.heatmapFbos.set(V,$)),_.bindFramebuffer.set($.framebuffer),_.viewport.set([0,0,l.tileSize,l.tileSize]),_.clear({color:o.aM.transparent});const j=R.programConfigurations.get(p.id),G=k.useProgram("heatmap",j),Q=k.style.map.terrain.getTerrainData(b);G.draw(_,w.TRIANGLES,en.disabled,D,P,On.disabled,vi(b.posMatrix,l,k.transform.zoom,p.paint.get("heatmap-intensity")),Q,p.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,p.paint,k.transform.zoom,j)}function wa(k,l,p){const b=k.context,_=b.gl;b.setColorMode(k.colorModeForRenderPass());const w=Bc(b,l),D=p.key,P=l.heatmapFbos.get(D);P&&(b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,P.colorAttachment.get()),b.activeTexture.set(_.TEXTURE1),w.bind(_.LINEAR,_.CLAMP_TO_EDGE),k.useProgram("heatmapTexture").draw(b,_.TRIANGLES,en.disabled,$n.disabled,k.colorModeForRenderPass(),On.disabled,lu(k,l,0,1),null,l.id,k.rasterBoundsBuffer,k.quadTriangleIndexBuffer,k.rasterBoundsSegments,l.paint,k.transform.zoom),P.destroy(),l.heatmapFbos.delete(D))}function Oc(k,l,p){var b,_;const w=k.gl,D=w.createTexture();w.bindTexture(w.TEXTURE_2D,D),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=k.HALF_FLOAT)!==null&&b!==void 0?b:w.UNSIGNED_BYTE,R=(_=k.RGBA16F)!==null&&_!==void 0?_:w.RGBA;w.texImage2D(w.TEXTURE_2D,0,R,l,p,0,w.RGBA,P,null);const V=k.createFramebuffer(l,p,!1,!1);return V.colorAttachment.set(D),V}function Bc(k,l){return l.colorRampTexture||(l.colorRampTexture=new Qe(k,l.colorRamp,k.gl.RGBA)),l.colorRampTexture}function yl(k,l,p,b,_){if(!p||!b||!b.imageAtlas)return;const w=b.imageAtlas.patternPositions;let D=w[p.to.toString()],P=w[p.from.toString()];if(!D&&P&&(D=P),!P&&D&&(P=D),!D||!P){const R=_.getPaintProperty(l);D=w[R],P=w[R]}D&&P&&k.setConstantPatternPositions(D,P)}function zc(k,l,p,b,_,w,D){const P=k.context.gl,R="fill-pattern",V=p.paint.get(R),$=V&&V.constantOr(1),j=p.getCrossfadeParameters();let G,Q,ee,oe,ce;D?(Q=$&&!p.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",G=P.LINES):(Q=$?"fillPattern":"fill",G=P.TRIANGLES);const ue=V.constantOr(null);for(const pe of b){const ne=l.getTile(pe);if($&&!ne.patternsLoaded())continue;const be=ne.getBucket(p);if(!be)continue;const _e=be.programConfigurations.get(p.id),Ee=k.useProgram(Q,_e),Be=k.style.map.terrain&&k.style.map.terrain.getTerrainData(pe);$&&(k.context.activeTexture.set(P.TEXTURE0),ne.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),_e.updatePaintBuffers(j)),yl(_e,R,ue,ne,p);const He=Be?pe:null,nt=k.translatePosMatrix(He?He.posMatrix:pe.posMatrix,ne,p.paint.get("fill-translate"),p.paint.get("fill-translate-anchor"));if(D){oe=be.indexBuffer2,ce=be.segments2;const ct=[P.drawingBufferWidth,P.drawingBufferHeight];ee=Q==="fillOutlinePattern"&&$?ry(nt,k,j,ne,ct):Av(nt,ct)}else oe=be.indexBuffer,ce=be.segments,ee=$?ny(nt,k,j,ne):pl(nt);Ee.draw(k.context,G,_,k.stencilModeForClipping(pe),w,On.disabled,ee,Be,p.id,be.layoutVertexBuffer,oe,ce,p.paint,k.transform.zoom,_e)}}function yu(k,l,p,b,_,w,D){const P=k.context,R=P.gl,V="fill-extrusion-pattern",$=p.paint.get(V),j=$.constantOr(1),G=p.getCrossfadeParameters(),Q=p.paint.get("fill-extrusion-opacity"),ee=$.constantOr(null);for(const oe of b){const ce=l.getTile(oe),ue=ce.getBucket(p);if(!ue)continue;const pe=k.style.map.terrain&&k.style.map.terrain.getTerrainData(oe),ne=ue.programConfigurations.get(p.id),be=k.useProgram(j?"fillExtrusionPattern":"fillExtrusion",ne);j&&(k.context.activeTexture.set(R.TEXTURE0),ce.imageAtlasTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),ne.updatePaintBuffers(G)),yl(ne,V,ee,ce,p);const _e=k.translatePosMatrix(oe.posMatrix,ce,p.paint.get("fill-extrusion-translate"),p.paint.get("fill-extrusion-translate-anchor")),Ee=p.paint.get("fill-extrusion-vertical-gradient"),Be=j?au(_e,k,Ee,Q,oe,G,ce):Mc(_e,k,Ee,Q);be.draw(P,P.gl.TRIANGLES,_,w,D,On.backCCW,Be,pe,p.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segments,p.paint,k.transform.zoom,ne,k.style.map.terrain&&ue.centroidVertexBuffer)}}function bl(k,l,p,b,_,w,D){const P=k.context,R=P.gl,V=p.fbo;if(!V)return;const $=k.useProgram("hillshade"),j=k.style.map.terrain&&k.style.map.terrain.getTerrainData(l);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,V.colorAttachment.get()),$.draw(P,R.TRIANGLES,_,w,D,On.disabled,((G,Q,ee,oe)=>{const ce=ee.paint.get("hillshade-shadow-color"),ue=ee.paint.get("hillshade-highlight-color"),pe=ee.paint.get("hillshade-accent-color");let ne=ee.paint.get("hillshade-illumination-direction")*(Math.PI/180);ee.paint.get("hillshade-illumination-anchor")==="viewport"&&(ne-=G.transform.angle);const be=!G.options.moving;return{u_matrix:oe?oe.posMatrix:G.transform.calculatePosMatrix(Q.tileID.toUnwrapped(),be),u_image:0,u_latrange:cu(0,Q.tileID),u_light:[ee.paint.get("hillshade-exaggeration"),ne],u_shadow:ce,u_highlight:ue,u_accent:pe}})(k,p,b,j?l:null),j,b.id,k.rasterBoundsBuffer,k.quadTriangleIndexBuffer,k.rasterBoundsSegments)}function _l(k,l,p,b,_,w){const D=k.context,P=D.gl,R=l.dem;if(R&&R.data){const V=R.dim,$=R.stride,j=R.getPixels();if(D.activeTexture.set(P.TEXTURE1),D.pixelStoreUnpackPremultiplyAlpha.set(!1),l.demTexture=l.demTexture||k.getTileTexture($),l.demTexture){const Q=l.demTexture;Q.update(j,{premultiply:!1}),Q.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else l.demTexture=new Qe(D,j,P.RGBA,{premultiply:!1}),l.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);D.activeTexture.set(P.TEXTURE0);let G=l.fbo;if(!G){const Q=new Qe(D,{width:V,height:V,data:null},P.RGBA);Q.bind(P.LINEAR,P.CLAMP_TO_EDGE),G=l.fbo=D.createFramebuffer(V,V,!0,!1),G.colorAttachment.set(Q.texture)}D.bindFramebuffer.set(G.framebuffer),D.viewport.set([0,0,V,V]),k.useProgram("hillshadePrepare").draw(D,P.TRIANGLES,b,_,w,On.disabled,((Q,ee)=>{const oe=ee.stride,ce=o.H();return o.aP(ce,0,o.X,-o.X,0,0,1),o.J(ce,ce,[0,-o.X,0]),{u_matrix:ce,u_image:1,u_dimension:[oe,oe],u_zoom:Q.overscaledZ,u_unpack:ee.getUnpackVector()}})(l.tileID,R),null,p.id,k.rasterBoundsBuffer,k.quadTriangleIndexBuffer,k.rasterBoundsSegments),l.needsHillshadePrepare=!1}}function xy(k,l,p,b,_,w){const D=b.paint.get("raster-fade-duration");if(!w&&D>0){const P=v.now(),R=(P-k.timeAdded)/D,V=l?(P-l.timeAdded)/D:-1,$=p.getSource(),j=_.coveringZoomLevel({tileSize:$.tileSize,roundZoom:$.roundZoom}),G=!l||Math.abs(l.tileID.overscaledZ-j)>Math.abs(k.tileID.overscaledZ-j),Q=G&&k.refreshedUponExpiration?1:o.ac(G?R:1-V,0,1);return k.refreshedUponExpiration&&R>=1&&(k.refreshedUponExpiration=!1),l?{opacity:1,mix:1-Q}:{opacity:Q,mix:0}}return{opacity:1,mix:0}}const zp=new o.aM(1,0,0,1),bn=new o.aM(0,1,0,1),bu=new o.aM(0,0,1,1),Hv=new o.aM(1,0,1,1),vy=new o.aM(0,1,1,1);function xl(k,l,p,b){_u(k,0,l+p/2,k.transform.width,p,b)}function wy(k,l,p,b){_u(k,l-p/2,0,p,k.transform.height,b)}function _u(k,l,p,b,_,w){const D=k.context,P=D.gl;P.enable(P.SCISSOR_TEST),P.scissor(l*k.pixelRatio,p*k.pixelRatio,b*k.pixelRatio,_*k.pixelRatio),D.clear({color:w}),P.disable(P.SCISSOR_TEST)}function ky(k,l,p){const b=k.context,_=b.gl,w=p.posMatrix,D=k.useProgram("debug"),P=en.disabled,R=$n.disabled,V=k.colorModeForRenderPass(),$="$debug",j=k.style.map.terrain&&k.style.map.terrain.getTerrainData(p);b.activeTexture.set(_.TEXTURE0);const G=l.getTileByID(p.key).latestRawTileData,Q=Math.floor((G&&G.byteLength||0)/1024),ee=l.getTile(p).tileSize,oe=512/Math.min(ee,512)*(p.overscaledZ/k.transform.zoom)*.5;let ce=p.canonical.toString();p.overscaledZ!==p.canonical.z&&(ce+=` => ${p.overscaledZ}`),function(ue,pe){ue.initDebugOverlayCanvas();const ne=ue.debugOverlayCanvas,be=ue.context.gl,_e=ue.debugOverlayCanvas.getContext("2d");_e.clearRect(0,0,ne.width,ne.height),_e.shadowColor="white",_e.shadowBlur=2,_e.lineWidth=1.5,_e.strokeStyle="white",_e.textBaseline="top",_e.font="bold 36px Open Sans, sans-serif",_e.fillText(pe,5,5),_e.strokeText(pe,5,5),ue.debugOverlayTexture.update(ne),ue.debugOverlayTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE)}(k,`${ce} ${Q}kB`),D.draw(b,_.TRIANGLES,P,R,dr.alphaBlended,On.disabled,Dc(w,o.aM.transparent,oe),null,$,k.debugBuffer,k.quadTriangleIndexBuffer,k.debugSegments),D.draw(b,_.LINE_STRIP,P,R,V,On.disabled,Dc(w,o.aM.red),j,$,k.debugBuffer,k.tileBorderIndexBuffer,k.debugSegments)}function Ey(k,l,p){const b=k.context,_=b.gl,w=k.colorModeForRenderPass(),D=new en(_.LEQUAL,en.ReadWrite,k.depthRangeFor3D),P=k.useProgram("terrain"),R=l.getTerrainMesh();b.bindFramebuffer.set(null),b.viewport.set([0,0,k.width,k.height]);for(const V of p){const $=k.renderToTexture.getTexture(V),j=l.getTerrainData(V.tileID);b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,$.texture);const G=k.transform.calculatePosMatrix(V.tileID.toUnwrapped()),Q=l.getMeshFrameDelta(k.transform.zoom),ee=k.transform.calculateFogMatrix(V.tileID.toUnwrapped()),oe=xp(G,Q,ee,k.style.sky,k.transform.pitch);P.draw(b,_.TRIANGLES,D,$n.disabled,w,On.backCCW,oe,j,"terrain",R.vertexBuffer,R.indexBuffer,R.segments)}}class xu{constructor(l,p,b){this.vertexBuffer=l,this.indexBuffer=p,this.segments=b}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class vu{constructor(l,p){this.context=new jv(l),this.transform=p,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ve.maxUnderzooming+Ve.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new bp}resize(l,p,b){if(this.width=Math.floor(l*b),this.height=Math.floor(p*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,p=new o.aX;p.emplaceBack(0,0),p.emplaceBack(o.X,0),p.emplaceBack(0,o.X),p.emplaceBack(o.X,o.X),this.tileExtentBuffer=l.createVertexBuffer(p,ma.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,ma.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(_,Nr.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,ma.members),this.viewportSegments=o.a0.simpleSegment(0,0,4,2);const D=new o.aZ;D.emplaceBack(0),D.emplaceBack(1),D.emplaceBack(3),D.emplaceBack(2),D.emplaceBack(0),this.tileBorderIndexBuffer=l.createIndexBuffer(D);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 $n({func:R.ALWAYS,mask:0},0,255,R.ZERO,R.ZERO,R.ZERO)}clearStencil(){const l=this.context,p=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,[p.drawingBufferWidth,p.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(l,p.TRIANGLES,en.disabled,this.stencilClearMode,dr.disabled,On.disabled,xi(b),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(l,p){if(this.currentStencilSource===l.source||!l.isTileClipped()||!p||!p.length)return;this.currentStencilSource=l.source;const b=this.context,_=b.gl;this.nextStencilID+p.length>256&&this.clearStencil(),b.setColorMode(dr.disabled),b.setDepthMode(en.disabled);const w=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const D of p){const P=this._tileClippingMaskIDs[D.key]=this.nextStencilID++,R=this.style.map.terrain&&this.style.map.terrain.getTerrainData(D);w.draw(b,_.TRIANGLES,en.disabled,new $n({func:_.ALWAYS,mask:0},P,255,_.KEEP,_.KEEP,_.REPLACE),dr.disabled,On.disabled,xi(D.posMatrix),R,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const l=this.nextStencilID++,p=this.context.gl;return new $n({func:p.NOTEQUAL,mask:255},l,255,p.KEEP,p.KEEP,p.REPLACE)}stencilModeForClipping(l){const p=this.context.gl;return new $n({func:p.EQUAL,mask:255},this._tileClippingMaskIDs[l.key],0,p.KEEP,p.KEEP,p.REPLACE)}stencilConfigForOverlap(l){const p=this.context.gl,b=l.sort((D,P)=>P.overscaledZ-D.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 D={};for(let P=0;P<w;P++)D[P+_]=new $n({func:p.GEQUAL,mask:255},P+this.nextStencilID,255,p.KEEP,p.KEEP,p.REPLACE);return this.nextStencilID+=w,[D,b]}return[{[_]:$n.disabled},b]}colorModeForRenderPass(){const l=this.context.gl;return this._showOverdrawInspector?new dr([l.CONSTANT_COLOR,l.ONE],new o.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?dr.unblended:dr.alphaBlended}depthModeForSublayer(l,p,b){if(!this.opaquePassEnabledForLayer())return en.disabled;const _=1-((1+this.currentLayer)*this.numSublayers+l)*this.depthEpsilon;return new en(b||this.context.gl.LEQUAL,p,[_,_])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(l,p){this.style=l,this.options=p,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={},D={},P={};for(const R in _){const V=_[R];V.used&&V.prepare(this.context),w[R]=V.getVisibleCoordinates(),D[R]=w[R].slice().reverse(),P[R]=V.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 V=this.style._layers[R];if(!V.hasOffscreenPass()||V.isHidden(this.transform.zoom))continue;const $=D[V.source];(V.type==="custom"||$.length)&&this.renderLayer(this,_[V.source],V,$)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:p.showOverdrawInspector?o.aM.black:o.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(R,V){const $=R.context,j=$.gl,G=((ue,pe,ne)=>({u_sky_color:ue.properties.get("sky-color"),u_horizon_color:ue.properties.get("horizon-color"),u_horizon:(pe.height/2+pe.getHorizon())*ne,u_sky_horizon_blend:ue.properties.get("sky-horizon-blend")*pe.height/2*ne}))(V,R.style.map.transform,R.pixelRatio),Q=new en(j.LEQUAL,en.ReadWrite,[0,1]),ee=$n.disabled,oe=R.colorModeForRenderPass(),ce=R.useProgram("sky");if(!V.mesh){const ue=new o.aX;ue.emplaceBack(-1,-1),ue.emplaceBack(1,-1),ue.emplaceBack(1,1),ue.emplaceBack(-1,1);const pe=new o.aY;pe.emplaceBack(0,1,2),pe.emplaceBack(0,2,3),V.mesh=new xu($.createVertexBuffer(ue,ma.members),$.createIndexBuffer(pe),o.a0.simpleSegment(0,0,ue.length,pe.length))}ce.draw($,j.TRIANGLES,Q,ee,oe,On.disabled,G,void 0,"sky",V.mesh.vertexBuffer,V.mesh.indexBuffer,V.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=p.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]],V=_[R.source],$=w[R.source];this._renderTileClippingMasks(R,$),this.renderLayer(this,V,R,$)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<b.length;this.currentLayer++){const R=this.style._layers[b[this.currentLayer]],V=_[R.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(R))continue;const $=(R.type==="symbol"?P:D)[R.source];this._renderTileClippingMasks(R,w[R.source]),this.renderLayer(this,V,R,$)}if(this.options.showTileBoundaries){const R=function(V,$){let j=null;const G=Object.values(V._layers).flatMap(ce=>ce.source&&!ce.isHidden($)?[V.sourceCaches[ce.source]]:[]),Q=G.filter(ce=>ce.getSource().type==="vector"),ee=G.filter(ce=>ce.getSource().type!=="vector"),oe=ce=>{(!j||j.getSource().maxzoom<ce.getSource().maxzoom)&&(j=ce)};return Q.forEach(ce=>oe(ce)),j||ee.forEach(ce=>oe(ce)),j}(this.style,this.transform.zoom);R&&function(V,$,j){for(let G=0;G<j.length;G++)ky(V,$,j[G])}(this,R,R.getVisibleCoordinates())}this.options.showPadding&&function(R){const V=R.transform.padding;xl(R,R.transform.height-(V.top||0),3,zp),xl(R,V.bottom||0,3,bn),wy(R,V.left||0,3,bu),wy(R,R.transform.width-(V.right||0),3,Hv);const $=R.transform.centerPoint;(function(j,G,Q,ee){_u(j,G-1,Q-10,2,20,ee),_u(j,G-10,Q-1,20,2,ee)})(R,$.x,R.transform.height-$.y,vy)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(l){if(!this.style||!this.style.map||!this.style.map.terrain)return;const p=this.terrainFacilitator.matrix,b=this.transform.modelViewProjectionMatrix;let _=this.terrainFacilitator.dirty;_||(_=l?!o.a_(p,b):!o.a$(p,b)),_||(_=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),_&&(o.b0(p,b),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(w,D){const P=w.context,R=P.gl,V=dr.unblended,$=new en(R.LEQUAL,en.ReadWrite,[0,1]),j=D.getTerrainMesh(),G=D.sourceCache.getRenderableTiles(),Q=w.useProgram("terrainDepth");P.bindFramebuffer.set(D.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1});for(const ee of G){const oe=D.getTerrainData(ee.tileID),ce={u_matrix:w.transform.calculatePosMatrix(ee.tileID.toUnwrapped()),u_ele_delta:D.getMeshFrameDelta(w.transform.zoom)};Q.draw(P,R.TRIANGLES,$,$n.disabled,V,On.backCCW,ce,oe,"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,D){const P=w.context,R=P.gl,V=dr.unblended,$=new en(R.LEQUAL,en.ReadWrite,[0,1]),j=D.getTerrainMesh(),G=D.getCoordsTexture(),Q=D.sourceCache.getRenderableTiles(),ee=w.useProgram("terrainCoords");P.bindFramebuffer.set(D.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1}),D.coordsIndex=[];for(const oe of Q){const ce=D.getTerrainData(oe.tileID);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,G.texture);const ue={u_matrix:w.transform.calculatePosMatrix(oe.tileID.toUnwrapped()),u_terrain_coords_id:(255-D.coordsIndex.length)/255,u_texture:0,u_ele_delta:D.getMeshFrameDelta(w.transform.zoom)};ee.draw(P,R.TRIANGLES,$,$n.disabled,V,On.backCCW,ue,ce,"terrain",j.vertexBuffer,j.indexBuffer,j.segments),D.coordsIndex.push(oe.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,w.width,w.height])}(this,this.style.map.terrain))}renderLayer(l,p,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,D,P,R,V){if(w.renderPass!=="translucent")return;const $=$n.disabled,j=w.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(G,Q,ee,oe,ce,ue,pe,ne,be){const _e=Q.transform,Ee=fa(),Be=ce==="map",He=ue==="map";for(const nt of G){const ct=oe.getTile(nt),Xe=ct.getBucket(ee);if(!Xe||!Xe.text||!Xe.text.segments.get().length)continue;const Ze=o.ag(Xe.textSizeData,_e.zoom),_t=on(ct,1,Q.transform.zoom),Vt=ai(nt.posMatrix,He,Be,Q.transform,_t),Je=ee.layout.get("icon-text-fit")!=="none"&&Xe.hasIconData();if(Ze){const ot=Math.pow(2,_e.zoom-ct.tileID.overscaledZ),Bt=Q.style.map.terrain?(Gt,an)=>Q.style.map.terrain.getElevation(nt,Gt,an):null,Gn=Ee.translatePosition(_e,ct,pe,ne);gl(Xe,Be,He,be,_e,Vt,nt.posMatrix,ot,Ze,Je,Ee,Gn,nt.toUnwrapped(),Bt)}}}(R,w,P,D,P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),V),P.paint.get("icon-opacity").constantOr(1)!==0&&Np(w,D,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&&Np(w,D,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),D.map.showCollisionBoxes&&(Rc(w,D,P,R,!0),Rc(w,D,P,R,!1))})(l,p,b,_,this.style.placement.variableOffsets);break;case"circle":(function(w,D,P,R){if(w.renderPass!=="translucent")return;const V=P.paint.get("circle-opacity"),$=P.paint.get("circle-stroke-width"),j=P.paint.get("circle-stroke-opacity"),G=!P.layout.get("circle-sort-key").isConstant();if(V.constantOr(1)===0&&($.constantOr(1)===0||j.constantOr(1)===0))return;const Q=w.context,ee=Q.gl,oe=w.depthModeForSublayer(0,en.ReadOnly),ce=$n.disabled,ue=w.colorModeForRenderPass(),pe=[];for(let ne=0;ne<R.length;ne++){const be=R[ne],_e=D.getTile(be),Ee=_e.getBucket(P);if(!Ee)continue;const Be=Ee.programConfigurations.get(P.id),He=w.useProgram("circle",Be),nt=Ee.layoutVertexBuffer,ct=Ee.indexBuffer,Xe=w.style.map.terrain&&w.style.map.terrain.getTerrainData(be),Ze={programConfiguration:Be,program:He,layoutVertexBuffer:nt,indexBuffer:ct,uniformValues:Mv(w,be,_e,P),terrainData:Xe};if(G){const _t=Ee.segments.get();for(const Vt of _t)pe.push({segments:new o.a0([Vt]),sortKey:Vt.sortKey,state:Ze})}else pe.push({segments:Ee.segments,sortKey:0,state:Ze})}G&&pe.sort((ne,be)=>ne.sortKey-be.sortKey);for(const ne of pe){const{programConfiguration:be,program:_e,layoutVertexBuffer:Ee,indexBuffer:Be,uniformValues:He,terrainData:nt}=ne.state;_e.draw(Q,ee.TRIANGLES,oe,ce,ue,On.disabled,He,nt,P.id,Ee,Be,ne.segments,P.paint,w.transform.zoom,be)}})(l,p,b,_);break;case"heatmap":(function(w,D,P,R){if(P.paint.get("heatmap-opacity")===0)return;const V=w.context;if(w.style.map.terrain){for(const $ of R){const j=D.getTile($);D.hasRenderableParent($)||(w.renderPass==="offscreen"?Bp(w,j,P,$):w.renderPass==="translucent"&&wa(w,P,$))}V.viewport.set([0,0,w.width,w.height])}else w.renderPass==="offscreen"?function($,j,G,Q){const ee=$.context,oe=ee.gl,ce=$n.disabled,ue=new dr([oe.ONE,oe.ONE],o.aM.transparent,[!0,!0,!0,!0]);(function(pe,ne,be){const _e=pe.gl;pe.activeTexture.set(_e.TEXTURE1),pe.viewport.set([0,0,ne.width/4,ne.height/4]);let Ee=be.heatmapFbos.get(o.aU);Ee?(_e.bindTexture(_e.TEXTURE_2D,Ee.colorAttachment.get()),pe.bindFramebuffer.set(Ee.framebuffer)):(Ee=Oc(pe,ne.width/4,ne.height/4),be.heatmapFbos.set(o.aU,Ee))})(ee,$,G),ee.clear({color:o.aM.transparent});for(let pe=0;pe<Q.length;pe++){const ne=Q[pe];if(j.hasRenderableParent(ne))continue;const be=j.getTile(ne),_e=be.getBucket(G);if(!_e)continue;const Ee=_e.programConfigurations.get(G.id),Be=$.useProgram("heatmap",Ee),{zoom:He}=$.transform;Be.draw(ee,oe.TRIANGLES,en.disabled,ce,ue,On.disabled,vi(ne.posMatrix,be,He,G.paint.get("heatmap-intensity")),null,G.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,G.paint,$.transform.zoom,Ee)}ee.viewport.set([0,0,$.width,$.height])}(w,D,P,R):w.renderPass==="translucent"&&function($,j){const G=$.context,Q=G.gl;G.setColorMode($.colorModeForRenderPass());const ee=j.heatmapFbos.get(o.aU);ee&&(G.activeTexture.set(Q.TEXTURE0),Q.bindTexture(Q.TEXTURE_2D,ee.colorAttachment.get()),G.activeTexture.set(Q.TEXTURE1),Bc(G,j).bind(Q.LINEAR,Q.CLAMP_TO_EDGE),$.useProgram("heatmapTexture").draw(G,Q.TRIANGLES,en.disabled,$n.disabled,$.colorModeForRenderPass(),On.disabled,lu($,j,0,1),null,j.id,$.viewportBuffer,$.quadTriangleIndexBuffer,$.viewportSegments,j.paint,$.transform.zoom))}(w,P)})(l,p,b,_);break;case"line":(function(w,D,P,R){if(w.renderPass!=="translucent")return;const V=P.paint.get("line-opacity"),$=P.paint.get("line-width");if(V.constantOr(1)===0||$.constantOr(1)===0)return;const j=w.depthModeForSublayer(0,en.ReadOnly),G=w.colorModeForRenderPass(),Q=P.paint.get("line-dasharray"),ee=P.paint.get("line-pattern"),oe=ee.constantOr(1),ce=P.paint.get("line-gradient"),ue=P.getCrossfadeParameters(),pe=oe?"linePattern":Q?"lineSDF":ce?"lineGradient":"line",ne=w.context,be=ne.gl;let _e=!0;for(const Ee of R){const Be=D.getTile(Ee);if(oe&&!Be.patternsLoaded())continue;const He=Be.getBucket(P);if(!He)continue;const nt=He.programConfigurations.get(P.id),ct=w.context.program.get(),Xe=w.useProgram(pe,nt),Ze=_e||Xe.program!==ct,_t=w.style.map.terrain&&w.style.map.terrain.getTerrainData(Ee),Vt=ee.constantOr(null);if(Vt&&Be.imageAtlas){const Bt=Be.imageAtlas,Gn=Bt.patternPositions[Vt.to.toString()],Gt=Bt.patternPositions[Vt.from.toString()];Gn&&Gt&&nt.setConstantPatternPositions(Gn,Gt)}const Je=_t?Ee:null,ot=oe?fl(w,Be,P,ue,Je):Q?Dv(w,Be,P,Q,ue,Je):ce?iy(w,Be,P,He.lineClipsArray.length,Je):du(w,Be,P,Je);if(oe)ne.activeTexture.set(be.TEXTURE0),Be.imageAtlasTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE),nt.updatePaintBuffers(ue);else if(Q&&(Ze||w.lineAtlas.dirty))ne.activeTexture.set(be.TEXTURE0),w.lineAtlas.bind(ne);else if(ce){const Bt=He.gradients[P.id];let Gn=Bt.texture;if(P.gradientVersion!==Bt.version){let Gt=256;if(P.stepInterpolant){const an=D.getSource().maxzoom,Yn=Ee.canonical.z===an?Math.ceil(1<<w.transform.maxZoom-Ee.canonical.z):1;Gt=o.ac(o.aV(He.maxLineLength/o.X*1024*Yn),256,ne.maxTextureSize)}Bt.gradient=o.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:Gt,image:Bt.gradient||void 0,clips:He.lineClipsArray}),Bt.texture?Bt.texture.update(Bt.gradient):Bt.texture=new Qe(ne,Bt.gradient,be.RGBA),Bt.version=P.gradientVersion,Gn=Bt.texture}ne.activeTexture.set(be.TEXTURE0),Gn.bind(P.stepInterpolant?be.NEAREST:be.LINEAR,be.CLAMP_TO_EDGE)}Xe.draw(ne,be.TRIANGLES,j,w.stencilModeForClipping(Ee),G,On.disabled,ot,_t,P.id,He.layoutVertexBuffer,He.indexBuffer,He.segments,P.paint,w.transform.zoom,nt,He.layoutVertexBuffer2),_e=!1}})(l,p,b,_);break;case"fill":(function(w,D,P,R){const V=P.paint.get("fill-color"),$=P.paint.get("fill-opacity");if($.constantOr(1)===0)return;const j=w.colorModeForRenderPass(),G=P.paint.get("fill-pattern"),Q=w.opaquePassEnabledForLayer()&&!G.constantOr(1)&&V.constantOr(o.aM.transparent).a===1&&$.constantOr(0)===1?"opaque":"translucent";if(w.renderPass===Q){const ee=w.depthModeForSublayer(1,w.renderPass==="opaque"?en.ReadWrite:en.ReadOnly);zc(w,D,P,R,ee,j,!1)}if(w.renderPass==="translucent"&&P.paint.get("fill-antialias")){const ee=w.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,en.ReadOnly);zc(w,D,P,R,ee,j,!0)}})(l,p,b,_);break;case"fill-extrusion":(function(w,D,P,R){const V=P.paint.get("fill-extrusion-opacity");if(V!==0&&w.renderPass==="translucent"){const $=new en(w.context.gl.LEQUAL,en.ReadWrite,w.depthRangeFor3D);if(V!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))yu(w,D,P,R,$,$n.disabled,dr.disabled),yu(w,D,P,R,$,w.stencilModeFor3D(),w.colorModeForRenderPass());else{const j=w.colorModeForRenderPass();yu(w,D,P,R,$,$n.disabled,j)}}})(l,p,b,_);break;case"hillshade":(function(w,D,P,R){if(w.renderPass!=="offscreen"&&w.renderPass!=="translucent")return;const V=w.context,$=w.depthModeForSublayer(0,en.ReadOnly),j=w.colorModeForRenderPass(),[G,Q]=w.renderPass==="translucent"?w.stencilConfigForOverlap(R):[{},R];for(const ee of Q){const oe=D.getTile(ee);oe.needsHillshadePrepare!==void 0&&oe.needsHillshadePrepare&&w.renderPass==="offscreen"?_l(w,oe,P,$,$n.disabled,j):w.renderPass==="translucent"&&bl(w,ee,oe,P,$,G[ee.overscaledZ],j)}V.viewport.set([0,0,w.width,w.height])})(l,p,b,_);break;case"raster":(function(w,D,P,R){if(w.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!R.length)return;const V=w.context,$=V.gl,j=D.getSource(),G=w.useProgram("raster"),Q=w.colorModeForRenderPass(),[ee,oe]=j instanceof gr?[{},R]:w.stencilConfigForOverlap(R),ce=oe[oe.length-1].overscaledZ,ue=!w.options.moving;for(const pe of oe){const ne=w.depthModeForSublayer(pe.overscaledZ-ce,P.paint.get("raster-opacity")===1?en.ReadWrite:en.ReadOnly,$.LESS),be=D.getTile(pe);be.registerFadeDuration(P.paint.get("raster-fade-duration"));const _e=D.findLoadedParent(pe,0),Ee=D.findLoadedSibling(pe),Be=xy(be,_e||Ee||null,D,P,w.transform,w.style.map.terrain);let He,nt;const ct=P.paint.get("raster-resampling")==="nearest"?$.NEAREST:$.LINEAR;V.activeTexture.set($.TEXTURE0),be.texture.bind(ct,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),V.activeTexture.set($.TEXTURE1),_e?(_e.texture.bind(ct,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),He=Math.pow(2,_e.tileID.overscaledZ-be.tileID.overscaledZ),nt=[be.tileID.canonical.x*He%1,be.tileID.canonical.y*He%1]):be.texture.bind(ct,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),be.texture.useMipmap&&V.extTextureFilterAnisotropic&&w.transform.pitch>20&&$.texParameterf($.TEXTURE_2D,V.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,V.extTextureFilterAnisotropicMax);const Xe=w.style.map.terrain&&w.style.map.terrain.getTerrainData(pe),Ze=Xe?pe:null,_t=Ze?Ze.posMatrix:w.transform.calculatePosMatrix(pe.toUnwrapped(),ue),Vt=Iv(_t,nt||[0,0],He||1,Be,P);j instanceof gr?G.draw(V,$.TRIANGLES,ne,$n.disabled,Q,On.disabled,Vt,Xe,P.id,j.boundsBuffer,w.quadTriangleIndexBuffer,j.boundsSegments):G.draw(V,$.TRIANGLES,ne,ee[pe.overscaledZ],Q,On.disabled,Vt,Xe,P.id,w.rasterBoundsBuffer,w.quadTriangleIndexBuffer,w.rasterBoundsSegments)}})(l,p,b,_);break;case"background":(function(w,D,P,R){const V=P.paint.get("background-color"),$=P.paint.get("background-opacity");if($===0)return;const j=w.context,G=j.gl,Q=w.transform,ee=Q.tileSize,oe=P.paint.get("background-pattern");if(w.isPatternMissing(oe))return;const ce=!oe&&V.a===1&&$===1&&w.opaquePassEnabledForLayer()?"opaque":"translucent";if(w.renderPass!==ce)return;const ue=$n.disabled,pe=w.depthModeForSublayer(0,ce==="opaque"?en.ReadWrite:en.ReadOnly),ne=w.colorModeForRenderPass(),be=w.useProgram(oe?"backgroundPattern":"background"),_e=R||Q.coveringTiles({tileSize:ee,terrain:w.style.map.terrain});oe&&(j.activeTexture.set(G.TEXTURE0),w.imageManager.bind(w.context));const Ee=P.getCrossfadeParameters();for(const Be of _e){const He=R?Be.posMatrix:w.transform.calculatePosMatrix(Be.toUnwrapped()),nt=oe?kp(He,$,w,oe,{tileID:Be,tileSize:ee},Ee):uu(He,$,V),ct=w.style.map.terrain&&w.style.map.terrain.getTerrainData(Be);be.draw(j,G.TRIANGLES,pe,ue,ne,On.disabled,nt,ct,P.id,w.tileExtentBuffer,w.quadTriangleIndexBuffer,w.tileExtentSegments)}})(l,0,b,_);break;case"custom":(function(w,D,P){const R=w.context,V=P.implementation;if(w.renderPass==="offscreen"){const $=V.prerender;$&&(w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),$.call(V,R.gl,w.transform.customLayerMatrix()),R.setDirty(),w.setBaseState())}else if(w.renderPass==="translucent"){w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),R.setStencilMode($n.disabled);const $=V.renderingMode==="3d"?new en(w.context.gl.LEQUAL,en.ReadWrite,w.depthRangeFor3D):w.depthModeForSublayer(0,en.ReadOnly);R.setDepthMode($),V.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,p,b,_,w){if(!b[0]&&!b[1])return l;const D=w?_==="map"?this.transform.angle:0:_==="viewport"?-this.transform.angle:0;if(D){const V=Math.sin(D),$=Math.cos(D);b=[b[0]*$-b[1]*V,b[0]*V+b[1]*$]}const P=[w?b[0]:on(p,b[0],this.transform.zoom),w?b[1]:on(p,b[1],this.transform.zoom),0],R=new Float32Array(16);return o.J(R,l,P),R}saveTileTexture(l){const p=this._tileTextures[l.size[0]];p?p.push(l):this._tileTextures[l.size[0]]=[l]}getTileTexture(l){const p=this._tileTextures[l];return p&&p.length>0?p.pop():null}isPatternMissing(l){if(!l)return!1;if(!l.from||!l.to)return!0;const p=this.imageManager.getPattern(l.from.toString()),b=this.imageManager.getPattern(l.to.toString());return!p||!b}useProgram(l,p){this.cache=this.cache||{};const b=l+(p?p.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[b]||(this.cache[b]=new vp(this.context,No[l],p,Ep[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 Qe(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:l,drawingBufferHeight:p}=this.context.gl;return this.width!==l||this.height!==p}}class vl{constructor(l,p){this.points=l,this.planes=p}static fromInvProjectionMatrix(l,p,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]/p*_;return o.b1(P,P,[R,R,1/P[3],R])}),D=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const R=function(G,Q){var ee=Q[0],oe=Q[1],ce=Q[2],ue=ee*ee+oe*oe+ce*ce;return ue>0&&(ue=1/Math.sqrt(ue)),G[0]=Q[0]*ue,G[1]=Q[1]*ue,G[2]=Q[2]*ue,G}([],function(G,Q,ee){var oe=Q[0],ce=Q[1],ue=Q[2],pe=ee[0],ne=ee[1],be=ee[2];return G[0]=ce*be-ue*ne,G[1]=ue*pe-oe*be,G[2]=oe*ne-ce*pe,G}([],Te([],w[P[0]],w[P[1]]),Te([],w[P[2]],w[P[1]]))),V=-(($=R)[0]*(j=w[P[1]])[0]+$[1]*j[1]+$[2]*j[2]);var $,j;return R.concat(V)});return new vl(w,D)}}class wl{constructor(l,p){this.min=l,this.max=p,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 p=[l%2==0,l<2],b=Se(this.min),_=Se(this.max);for(let w=0;w<p.length;w++)b[w]=p[w]?this.min[w]:this.center[w],_[w]=p[w]?this.center[w]:this.max[w];return _[2]=this.max[2],new wl(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 p=[[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 D=0;for(let P=0;P<p.length;P++)o.b2(w,p[P])>=0&&D++;if(D===0)return 0;D!==p.length&&(b=!1)}if(b)return 2;for(let _=0;_<3;_++){let w=Number.MAX_VALUE,D=-Number.MAX_VALUE;for(let P=0;P<l.points.length;P++){const R=l.points[P][_]-this.min[_];w=Math.min(w,R),D=Math.max(D,R)}if(D<0||w>this.max[_]-this.min[_])return 0}return 1}}class kl{constructor(l=0,p=0,b=0,_=0){if(isNaN(l)||l<0||isNaN(p)||p<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=p,this.left=b,this.right=_}interpolate(l,p,b){return p.top!=null&&l.top!=null&&(this.top=o.y.number(l.top,p.top,b)),p.bottom!=null&&l.bottom!=null&&(this.bottom=o.y.number(l.bottom,p.bottom,b)),p.left!=null&&l.left!=null&&(this.left=o.y.number(l.left,p.left,b)),p.right!=null&&l.right!=null&&(this.right=o.y.number(l.right,p.right,b)),this}getCenter(l,p){const b=o.ac((this.left+l-this.right)/2,0,l),_=o.ac((this.top+p-this.bottom)/2,0,p);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 kl(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Vp=85.051129;class El{constructor(l,p,b,_,w){this.tileSize=512,this._renderWorldCopies=w===void 0||!!w,this._minZoom=l||0,this._maxZoom=p||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 kl,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const l=new El(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 p=-o.b3(l,-180,180)*Math.PI/180;this.angle!==p&&(this._unmodified=!1,this.angle=p,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 D=_[0],P=_[1],R=_[2],V=_[3],$=Math.sin(w),j=Math.cos(w);b[0]=D*j+R*$,b[1]=P*j+V*$,b[2]=D*-$+R*j,b[3]=P*-$+V*j}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(l){const p=o.ac(l,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==p&&(this._unmodified=!1,this._pitch=p,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 p=Math.min(Math.max(l,this.minZoom),this.maxZoom);this._zoom!==p&&(this._unmodified=!1,this._zoom=p,this.tileZoom=Math.max(0,Math.floor(p)),this.scale=this.zoomScale(p),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,p,b){this._unmodified=!1,this._edgeInsets.interpolate(l,p,b),this._constrain(),this._calcMatrices()}coveringZoomLevel(l){const p=(l.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/l.tileSize));return Math.max(0,p)}getVisibleUnwrappedCoordinates(l){const p=[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)),D=this.pointCoordinate(new o.P(0,this.height)),P=Math.floor(Math.min(b.x,_.x,w.x,D.x)),R=Math.floor(Math.max(b.x,_.x,w.x,D.x)),V=1;for(let $=P-V;$<=R+V;$++)$!==0&&p.push(new o.b4($,l))}return p}coveringTiles(l){var p,b;let _=this.coveringZoomLevel(l);const w=_;if(l.minzoom!==void 0&&_<l.minzoom)return[];l.maxzoom!==void 0&&_>l.maxzoom&&(_=l.maxzoom);const D=this.pointCoordinate(this.getCameraPoint()),P=o.Z.fromLngLat(this.center),R=Math.pow(2,_),V=[R*D.x,R*D.y,0],$=[R*P.x,R*P.y,0],j=vl.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,_);let G=l.minzoom||0;!l.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(G=_);const Q=l.terrain?2/Math.min(this.tileSize,l.tileSize)*this.tileSize:3,ee=ne=>({aabb:new wl([ne*R,0,0],[(ne+1)*R,R,0]),zoom:0,x:0,y:0,wrap:ne,fullyVisible:!1}),oe=[],ce=[],ue=_,pe=l.reparseOverscaled?w:_;if(this._renderWorldCopies)for(let ne=1;ne<=3;ne++)oe.push(ee(-ne)),oe.push(ee(ne));for(oe.push(ee(0));oe.length>0;){const ne=oe.pop(),be=ne.x,_e=ne.y;let Ee=ne.fullyVisible;if(!Ee){const Xe=ne.aabb.intersects(j);if(Xe===0)continue;Ee=Xe===2}const Be=l.terrain?V:$,He=ne.aabb.distanceX(Be),nt=ne.aabb.distanceY(Be),ct=Math.max(Math.abs(He),Math.abs(nt));if(ne.zoom===ue||ct>Q+(1<<ue-ne.zoom)-2&&ne.zoom>=G){const Xe=ue-ne.zoom,Ze=V[0]-.5-(be<<Xe),_t=V[1]-.5-(_e<<Xe);ce.push({tileID:new o.S(ne.zoom===ue?pe:ne.zoom,ne.wrap,ne.zoom,be,_e),distanceSq:Ne([$[0]-.5-be,$[1]-.5-_e]),tileDistanceToCamera:Math.sqrt(Ze*Ze+_t*_t)})}else for(let Xe=0;Xe<4;Xe++){const Ze=(be<<1)+Xe%2,_t=(_e<<1)+(Xe>>1),Vt=ne.zoom+1;let Je=ne.aabb.quadrant(Xe);if(l.terrain){const ot=new o.S(Vt,ne.wrap,Vt,Ze,_t),Bt=l.terrain.getMinMaxElevation(ot),Gn=(p=Bt.minElevation)!==null&&p!==void 0?p:this.elevation,Gt=(b=Bt.maxElevation)!==null&&b!==void 0?b:this.elevation;Je=new wl([Je.min[0],Je.min[1],Gn],[Je.max[0],Je.max[1],Gt])}oe.push({aabb:Je,zoom:Vt,x:Ze,y:_t,wrap:ne.wrap,fullyVisible:Ee})}}return ce.sort((ne,be)=>ne.distanceSq-be.distanceSq).map(ne=>ne.tileID)}resize(l,p){this.width=l,this.height=p,this.pixelsToGLUnits=[2/l,-2/p],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 p=o.ac(l.lat,-85.051129,Vp);return new o.P(o.O(l.lng)*this.worldSize,o.Q(p)*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 p=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 D=b+p-w,P=Math.cos(this._pitch)*this.cameraToCenterDistance/D/o.b5(1,_.lat),R=this.scaleZoom(P/this.tileSize);this._elevation=w,this._center=_,this.zoom=R}setLocationAtPoint(l,p){const b=this.pointCoordinate(p),_=this.pointCoordinate(this.centerPoint),w=this.locationCoordinate(l),D=new o.Z(w.x-(b.x-_.x),w.y-(b.y-_.y));this.center=this.coordinateLocation(D),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(l,p){return p?this.coordinatePoint(this.locationCoordinate(l),p.getElevationForLngLatZoom(l,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(l))}pointLocation(l,p){return this.coordinateLocation(this.pointCoordinate(l,p))}locationCoordinate(l){return o.Z.fromLngLat(l)}coordinateLocation(l){return l&&l.toLngLat()}pointCoordinate(l,p){if(p){const G=p.pointCoordinate(l);if(G!=null)return G}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],D=_[3],P=b[1]/w,R=_[1]/D,V=b[2]/w,$=_[2]/D,j=V===$?0:(0-V)/($-V);return new o.Z(o.y.number(b[0]/w,_[0]/D,j)/this.worldSize,o.y.number(P,R,j)/this.worldSize)}coordinatePoint(l,p=0,b=this.pixelMatrix){const _=[l.x*this.worldSize,l.y*this.worldSize,p,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 Ce().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 Ce([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,Vp])}calculateTileMatrix(l){const p=l.canonical,b=this.worldSize/this.zoomScale(p.z),_=p.x+Math.pow(2,p.z)*l.wrap,w=o.an(new Float64Array(16));return o.J(w,w,[_*b,p.y*b,0]),o.K(w,w,[b/o.X,b/o.X,1]),w}calculatePosMatrix(l,p=!1){const b=l.key,_=p?this._alignedPosMatrixCache:this._posMatrixCache;if(_[b])return _[b];const w=this.calculateTileMatrix(l);return o.L(w,p?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,w),_[b]=new Float32Array(w),_[b]}calculateFogMatrix(l){const p=l.key,b=this._fogMatrixCache;if(b[p])return b[p];const _=this.calculateTileMatrix(l);return o.L(_,this.fogMatrix,_),b[p]=new Float32Array(_),b[p]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(l,p){p=o.ac(+p,this.minZoom,this.maxZoom);const b={center:new o.N(l.lng,l.lat),zoom:p};let _=this.lngRange;if(!this._renderWorldCopies&&_===null){const ne=179.9999999999;_=[-ne,ne]}const w=this.tileSize*this.zoomScale(b.zoom);let D=0,P=w,R=0,V=w,$=0,j=0;const{x:G,y:Q}=this.size;if(this.latRange){const ne=this.latRange;D=o.Q(ne[1])*w,P=o.Q(ne[0])*w,P-D<Q&&($=Q/(P-D))}_&&(R=o.b3(o.O(_[0])*w,0,w),V=o.b3(o.O(_[1])*w,0,w),V<R&&(V+=w),V-R<G&&(j=G/(V-R)));const{x:ee,y:oe}=this.project.call({worldSize:w},l);let ce,ue;const pe=Math.max(j||0,$||0);if(pe){const ne=new o.P(j?(V+R)/2:ee,$?(P+D)/2:oe);return b.center=this.unproject.call({worldSize:w},ne).wrap(),b.zoom+=this.scaleZoom(pe),b}if(this.latRange){const ne=Q/2;oe-ne<D&&(ue=D+ne),oe+ne>P&&(ue=P-ne)}if(_){const ne=(R+V)/2;let be=ee;this._renderWorldCopies&&(be=o.b3(ee,ne-w/2,ne+w/2));const _e=G/2;be-_e<R&&(ce=R+_e),be+_e>V&&(ce=V-_e)}if(ce!==void 0||ue!==void 0){const ne=new o.P(ce??ee,ue??oe);b.center=this.unproject.call({worldSize:w},ne).wrap()}return b}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const l=this._unmodified,{center:p,zoom:b}=this.getConstrained(this.center,this.zoom);this.center=p,this.zoom=b,this._unmodified=l,this._constraining=!1}_calcMatrices(){if(!this.height)return;const l=this.centerOffset,p=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),D=Math.min(this.elevation,this.minElevationForCurrentTile),P=w-D*this._pixelPerMeter/Math.cos(this._pitch),R=D<0?P:w,V=Math.PI/2+this._pitch,$=this._fov*(.5+l.y/this.height),j=Math.sin($)*R/Math.sin(o.ac(Math.PI-V-$,.01,Math.PI-.01)),G=this.getHorizon(),Q=2*Math.atan(G/this.cameraToCenterDistance)*(.5+l.y/(2*G)),ee=Math.sin(Q)*R/Math.sin(o.ac(Math.PI-V-Q,.01,Math.PI-.01)),oe=Math.min(j,ee);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*oe+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(_,_,[-p,-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,[-p,-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 ce=this.width%2/2,ue=this.height%2/2,pe=Math.cos(this.angle),ne=Math.sin(this.angle),be=p-Math.round(p)+pe*ce+ne*ue,_e=b-Math.round(b)+pe*ue+ne*ce,Ee=new Float64Array(_);if(o.J(Ee,Ee,[be>.5?be-1:be,_e>.5?_e-1:_e,0]),this.alignedModelViewProjectionMatrix=Ee,_=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)),p=[l.x*this.worldSize,l.y*this.worldSize,0,1];return o.af(p,p,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 p=this.getCameraPoint();if(l.length===1)return[l[0],p];{let b=p.x,_=p.y,w=p.x,D=p.y;for(const P of l)b=Math.min(b,P.x),_=Math.min(_,P.y),w=Math.max(w,P.x),D=Math.max(D,P.y);return[new o.P(b,_),new o.P(w,_),new o.P(w,D),new o.P(b,D),new o.P(b,_)]}}lngLatToCameraDepth(l,p){const b=this.locationCoordinate(l),_=[b.x*this.worldSize,b.y*this.worldSize,p,1];return o.af(_,_,this.modelViewProjectionMatrix),_[2]/_[3]}}function Vc(k,l){let p,b=!1,_=null,w=null;const D=()=>{_=null,b&&(k.apply(w,p),_=setTimeout(D,l),b=!1)};return(...P)=>(b=!0,w=this,p=P,_||D(),_)}class wu{constructor(l){this._getCurrentHash=()=>{const p=window.location.hash.replace("#","");if(this._hashName){let b;return p.split("&").map(_=>_.split("=")).forEach(_=>{_[0]===this._hashName&&(b=_)}),(b&&b[1]||"").split("/")}return p.split("/")},this._onHashChange=()=>{const p=this._getCurrentHash();if(p.length>=3&&!p.some(b=>isNaN(b))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(p[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+p[2],+p[1]],zoom:+p[0],bearing:b,pitch:+(p[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const p=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,p)},this._removeHash=()=>{const p=this._getCurrentHash();if(p.length===0)return;const b=p.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 D=window.location.href.replace(/(#.+)?$/,w);D=D.replace("&&","&"),window.history.replaceState(window.history.state,null,D)},this._updateHash=Vc(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 p=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,_),D=Math.round(p.lng*w)/w,P=Math.round(p.lat*w)/w,R=this._map.getBearing(),V=this._map.getPitch();let $="";if($+=l?`/${D}/${P}/${b}`:`${b}/${P}/${D}`,(R||V)&&($+="/"+Math.round(10*R)/10),V&&($+=`/${Math.round(V)}`),this._hashName){const j=this._hashName;let G=!1;const Q=window.location.hash.slice(1).split("&").map(ee=>{const oe=ee.split("=")[0];return oe===j?(G=!0,`${oe}=${$}`):ee}).filter(ee=>ee);return G||Q.push(`${j}=${$}`),`#${Q.join("&")}`}return`#${$}`}}const ku={linearity:.3,easing:o.b8(0,0,.3,1)},Lp=o.e({deceleration:2500,maxSpeed:1400},ku),Uv=o.e({deceleration:20,maxSpeed:1400},ku),Sy=o.e({deceleration:1e3,maxSpeed:360},ku),Eu=o.e({deceleration:1e3,maxSpeed:90},ku);class Fp{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,p=v.now();for(;l.length>0&&p-l[0].time>160;)l.shift()}_onMoveEnd(l){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const p={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)p.zoom+=w.zoomDelta||0,p.bearing+=w.bearingDelta||0,p.pitch+=w.pitchDelta||0,w.panDelta&&p.pan._add(w.panDelta),w.around&&(p.around=w.around),w.pinchAround&&(p.pinchAround=w.pinchAround);const b=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(p.pan.mag()){const w=Fc(p.pan.mag(),b,o.e({},Lp,l||{}));_.offset=p.pan.mult(w.amount/p.pan.mag()),_.center=this._map.transform.center,Lc(_,w)}if(p.zoom){const w=Fc(p.zoom,b,Uv);_.zoom=this._map.transform.zoom+w.amount,Lc(_,w)}if(p.bearing){const w=Fc(p.bearing,b,Sy);_.bearing=this._map.transform.bearing+o.ac(w.amount,-179,179),Lc(_,w)}if(p.pitch){const w=Fc(p.pitch,b,Eu);_.pitch=this._map.transform.pitch+w.amount,Lc(_,w)}if(_.zoom||_.bearing){const w=p.pinchAround===void 0?p.around:p.pinchAround;_.around=w?this._map.unproject(w):this._map.getCenter()}return this.clear(),o.e(_,{noMoveStart:!0})}}function Lc(k,l){(!k.duration||k.duration<l.duration)&&(k.duration=l.duration,k.easing=l.easing)}function Fc(k,l,p){const{maxSpeed:b,linearity:_,deceleration:w}=p,D=o.ac(k*_/(l/1e3),-b,b),P=Math.abs(D)/(w*_);return{easing:p.easing,duration:1e3*P,amount:D*(P/2)}}class qr extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,p,b,_={}){const w=E.mousePos(p.getCanvas(),b),D=p.unproject(w);super(l,o.e({point:w,lngLat:D,originalEvent:b},_)),this._defaultPrevented=!1,this.target=p}}class ka extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,p,b){const _=l==="touchend"?b.changedTouches:b.touches,w=E.touchPos(p.getCanvasContainer(),_),D=w.map(R=>p.unproject(R)),P=w.reduce((R,V,$,j)=>R.add(V.div(j.length)),new o.P(0,0));super(l,{points:w,point:P,lngLats:D,lngLat:p.unproject(P),originalEvent:b}),this._defaultPrevented=!1}}class Cy extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,p,b){super(l,{originalEvent:b}),this._defaultPrevented=!1}}class Ty{constructor(l,p){this._map=l,this._clickTolerance=p.clickTolerance}reset(){delete this._mousedownPos}wheel(l){return this._firePreventable(new Cy(l.type,this._map,l))}mousedown(l,p){return this._mousedownPos=p,this._firePreventable(new qr(l.type,this._map,l))}mouseup(l){this._map.fire(new qr(l.type,this._map,l))}click(l,p){this._mousedownPos&&this._mousedownPos.dist(p)>=this._clickTolerance||this._map.fire(new qr(l.type,this._map,l))}dblclick(l){return this._firePreventable(new qr(l.type,this._map,l))}mouseover(l){this._map.fire(new qr(l.type,this._map,l))}mouseout(l){this._map.fire(new qr(l.type,this._map,l))}touchstart(l){return this._firePreventable(new ka(l.type,this._map,l))}touchmove(l){this._map.fire(new ka(l.type,this._map,l))}touchend(l){this._map.fire(new ka(l.type,this._map,l))}touchcancel(l){this._map.fire(new ka(l.type,this._map,l))}_firePreventable(l){if(this._map.fire(l),l.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ur{constructor(l){this._map=l}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(l){this._map.fire(new qr(l.type,this._map,l))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new qr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(l){this._delayContextMenu?this._contextMenuEvent=l:this._ignoreContextMenu||this._map.fire(new qr(l.type,this._map,l)),this._map.listens("contextmenu")&&l.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ks{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 Fi{constructor(l,p){this._map=l,this._tr=new ks(l),this._el=l.getCanvasContainer(),this._container=l.getContainer(),this._clickTolerance=p.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(l,p){this.isEnabled()&&l.shiftKey&&l.button===0&&(E.disableDrag(),this._startPos=this._lastPos=p,this._active=!0)}mousemoveWindow(l,p){if(!this._active)return;const b=p;if(this._lastPos.equals(b)||!this._box&&b.dist(this._startPos)<this._clickTolerance)return;const _=this._startPos;this._lastPos=b,this._box||(this._box=E.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",l));const w=Math.min(_.x,b.x),D=Math.max(_.x,b.x),P=Math.min(_.y,b.y),R=Math.max(_.y,b.y);E.setTransform(this._box,`translate(${w}px,${P}px)`),this._box.style.width=D-w+"px",this._box.style.height=R-P+"px"}mouseupWindow(l,p){if(!this._active||l.button!==0)return;const b=this._startPos,_=p;if(this.reset(),E.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&&(E.remove(this._box),this._box=null),E.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(l,p){return this._map.fire(new o.k(l,{originalEvent:p}))}}function $c(k,l){if(k.length!==l.length)throw new Error(`The number of touches and points are not equal - touches ${k.length}, points ${l.length}`);const p={};for(let b=0;b<k.length;b++)p[k[b].identifier]=l[b];return p}class $p{constructor(l){this.reset(),this.numTouches=l.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(l,p,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 D of _)w._add(D);return w.div(_.length)}(p),this.touches=$c(b,p)))}touchmove(l,p,b){if(this.aborted||!this.centroid)return;const _=$c(b,p);for(const w in this.touches){const D=_[w];(!D||D.dist(this.touches[w])>30)&&(this.aborted=!0)}}touchend(l,p,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 Su{constructor(l){this.singleTap=new $p(l),this.numTaps=l.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(l,p,b){this.singleTap.touchstart(l,p,b)}touchmove(l,p,b){this.singleTap.touchmove(l,p,b)}touchend(l,p,b){const _=this.singleTap.touchend(l,p,b);if(_){const w=l.timeStamp-this.lastTime<500,D=!this.lastTap||this.lastTap.dist(_)<30;if(w&&D||this.reset(),this.count++,this.lastTime=l.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Sl{constructor(l){this._tr=new ks(l),this._zoomIn=new Su({numTouches:1,numTaps:2}),this._zoomOut=new Su({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(l,p,b){this._zoomIn.touchstart(l,p,b),this._zoomOut.touchstart(l,p,b)}touchmove(l,p,b){this._zoomIn.touchmove(l,p,b),this._zoomOut.touchmove(l,p,b)}touchend(l,p,b){const _=this._zoomIn.touchend(l,p,b),w=this._zoomOut.touchend(l,p,b),D=this._tr;return _?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:D.zoom+1,around:D.unproject(_)},{originalEvent:l})}):w?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:D.zoom-1,around:D.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 ho{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 p=this._moveFunction(...l);if(p.bearingDelta||p.pitchDelta||p.around||p.panDelta)return this._active=!0,p}dragStart(l,p){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(l)&&(this._moveStateManager.startMove(l),this._lastPoint=p.length?p[0]:p,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(l,p){if(!this.isEnabled())return;const b=this._lastPoint;if(!b)return;if(l.preventDefault(),!this._moveStateManager.isValidMoveEvent(l))return void this.reset(l);const _=p.length?p[0]:p;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&&E.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 jp={0:1,2:2};class Cu{constructor(l){this._correctEvent=l.checkCorrectEvent}startMove(l){const p=E.mouseButton(l);this._eventButton=p}endMove(l){delete this._eventButton}isValidStartEvent(l){return this._correctEvent(l)}isValidMoveEvent(l){return!function(p,b){const _=jp[b];return p.buttons===void 0||(p.buttons&_)!==_}(l,this._eventButton)}isValidEndEvent(l){return E.mouseButton(l)===this._eventButton}}class Hp{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 Tu=k=>{k.mousedown=k.dragStart,k.mousemoveWindow=k.dragMove,k.mouseup=k.dragEnd,k.contextmenu=l=>{l.preventDefault()}},Up=({enable:k,clickTolerance:l,bearingDegreesPerPixelMoved:p=.8})=>{const b=new Cu({checkCorrectEvent:_=>E.mouseButton(_)===0&&_.ctrlKey||E.mouseButton(_)===2});return new ho({clickTolerance:l,move:(_,w)=>({bearingDelta:(w.x-_.x)*p}),moveStateManager:b,enable:k,assignEvents:Tu})},Wp=({enable:k,clickTolerance:l,pitchDegreesPerPixelMoved:p=-.5})=>{const b=new Cu({checkCorrectEvent:_=>E.mouseButton(_)===0&&_.ctrlKey||E.mouseButton(_)===2});return new ho({clickTolerance:l,move:(_,w)=>({pitchDelta:(w.y-_.y)*p}),moveStateManager:b,enable:k,assignEvents:Tu})};class Ea{constructor(l,p){this._clickTolerance=l.clickTolerance||1,this._map=p,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,p,b){return this._calculateTransform(l,p,b)}touchmove(l,p,b){if(this._active){if(!this._shouldBePrevented(b.length))return l.preventDefault(),this._calculateTransform(l,p,b);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",l)}}touchend(l,p,b){this._calculateTransform(l,p,b),this._active&&this._shouldBePrevented(b.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(l,p,b){b.length>0&&(this._active=!0);const _=$c(b,p),w=new o.P(0,0),D=new o.P(0,0);let P=0;for(const V in _){const $=_[V],j=this._touches[V];j&&(w._add($),D._add($.sub(j)),P++,_[V]=$)}if(this._touches=_,this._shouldBePrevented(P)||!D.mag())return;const R=D.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 Au{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(l,p,b){this._firstTwoTouches||b.length<2||(this._firstTwoTouches=[b[0].identifier,b[1].identifier],this._start([p[0],p[1]]))}touchmove(l,p,b){if(!this._firstTwoTouches)return;l.preventDefault();const[_,w]=this._firstTwoTouches,D=jc(b,p,_),P=jc(b,p,w);if(!D||!P)return;const R=this._aroundCenter?null:D.add(P).div(2);return this._move([D,P],R,l)}touchend(l,p,b){if(!this._firstTwoTouches)return;const[_,w]=this._firstTwoTouches,D=jc(b,p,_),P=jc(b,p,w);D&&P||(this._active&&E.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 jc(k,l,p){for(let b=0;b<k.length;b++)if(k[b].identifier===p)return l[b]}function qp(k,l){return Math.log(k/l)/Math.LN2}class Gp extends Au{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(l){this._startDistance=this._distance=l[0].dist(l[1])}_move(l,p){const b=this._distance;if(this._distance=l[0].dist(l[1]),this._active||!(Math.abs(qp(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:qp(this._distance,b),pinchAround:p}}}function Yp(k,l){return 180*k.angleWith(l)/Math.PI}class Zp extends Au{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,p,b){const _=this._vector;if(this._vector=l[0].sub(l[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Yp(this._vector,_),pinchAround:p}}_isBelowThreshold(l){this._minDiameter=Math.min(this._minDiameter,l.mag());const p=25/(Math.PI*this._minDiameter)*360,b=Yp(l,this._startVector);return Math.abs(b)<p}}function Mu(k){return Math.abs(k.y)>Math.abs(k.x)}class Cl extends Au{constructor(l){super(),this._currentTouchCount=0,this._map=l}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(l,p,b){super.touchstart(l,p,b),this._currentTouchCount=b.length}_start(l){this._lastPoints=l,Mu(l[0].sub(l[1]))&&(this._valid=!1)}_move(l,p,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,p,b){if(this._valid!==void 0)return this._valid;const _=l.mag()>=2,w=p.mag()>=2;if(!_&&!w)return;if(!_||!w)return this._firstMove===void 0&&(this._firstMove=b),b-this._firstMove<100&&void 0;const D=l.y>0==p.y>0;return Mu(l)&&Mu(p)&&D}}const Ay={panStep:100,bearingStep:15,pitchStep:10};class is{constructor(l){this._tr=new ks(l);const p=Ay;this._panStep=p.panStep,this._bearingStep=p.bearingStep,this._pitchStep=p.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(l){if(l.altKey||l.ctrlKey||l.metaKey)return;let p=0,b=0,_=0,w=0,D=0;switch(l.keyCode){case 61:case 107:case 171:case 187:p=1;break;case 189:case 109:case 173:p=-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(),D=-1);break;case 40:l.shiftKey?_=-1:(l.preventDefault(),D=1);break;default:return}return this._rotationDisabled&&(b=0,_=0),{cameraAnimation:P=>{const R=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:Ys,zoom:p?Math.round(R.zoom)+p*(l.shiftKey?2:1):R.zoom,bearing:R.bearing+b*this._bearingStep,pitch:R.pitch+_*this._pitchStep,offset:[-w*this._panStep,-D*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 Ys(k){return k*(2-k)}const Xp=4.000244140625;class Es{constructor(l,p){this._onTimeout=b=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(b)},this._map=l,this._tr=new ks(l),this._triggerRenderFrame=p,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 p=l.deltaMode===WheelEvent.DOM_DELTA_LINE?40*l.deltaY:l.deltaY;const b=v.now(),_=b-(this._lastWheelEventTime||0);this._lastWheelEventTime=b,p!==0&&p%Xp==0?this._type="wheel":p!==0&&Math.abs(p)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=p,this._timeout=setTimeout(this._onTimeout,40,l)):this._type||(this._type=Math.abs(_*p)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,p+=this._lastValue)),l.shiftKey&&p&&(p/=4),this._type&&(this._lastWheelEvent=l,this._delta-=p,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 p=E.mousePos(this._map.getCanvas(),l),b=this._tr;this._around=p.y>b.transform.height/2-b.transform.getHorizon()?o.N.convert(this._aroundCenter?b.center:b.unproject(p)):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)>Xp?this._wheelZoomRate:this._defaultZoomRate;let V=2/(1+Math.exp(-Math.abs(this._delta*R)));this._delta<0&&V!==0&&(V=1/V);const $=typeof this._targetZoom=="number"?l.zoomScale(this._targetZoom):l.scale;this._targetZoom=Math.min(l.maxZoom,Math.max(l.minZoom,l.scaleZoom($*V))),this._type==="wheel"&&(this._startZoom=l.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const p=typeof this._targetZoom=="number"?this._targetZoom:l.zoom,b=this._startZoom,_=this._easing;let w,D=!1;const P=v.now()-this._lastWheelEventTime;if(this._type==="wheel"&&b&&_&&P){const R=Math.min(P/200,1),V=_(R);w=o.y.number(b,p,V),R<1?this._frameId||(this._frameId=!0):D=!0}else w=p,D=!0;return this._active=!0,D&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!D,zoomDelta:w-l.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(l){let p=o.b9;if(this._prevEase){const b=this._prevEase,_=(v.now()-b.start)/b.duration,w=b.easing(_+.01)-b.easing(_),D=.27/Math.sqrt(w*w+1e-4)*.01,P=Math.sqrt(.0729-D*D);p=o.b8(D,P,.25,1)}return this._prevEase={start:v.now(),duration:l,easing:p},p}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Sa{constructor(l,p){this._clickZoom=l,this._tapZoom=p}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 Wv{constructor(l){this._tr=new ks(l),this.reset()}reset(){this._active=!1}dblclick(l,p){return l.preventDefault(),{cameraAnimation:b=>{b.easeTo({duration:300,zoom:this._tr.zoom+(l.shiftKey?-1:1),around:this._tr.unproject(p)},{originalEvent:l})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qv{constructor(){this._tap=new Su({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,p,b){if(!this._swipePoint)if(this._tapTime){const _=p[0],w=l.timeStamp-this._tapTime<500,D=this._tapPoint.dist(_)<30;w&&D?b.length>0&&(this._swipePoint=_,this._swipeTouch=b[0].identifier):this.reset()}else this._tap.touchstart(l,p,b)}touchmove(l,p,b){if(this._tapTime){if(this._swipePoint){if(b[0].identifier!==this._swipeTouch)return;const _=p[0],w=_.y-this._swipePoint.y;return this._swipePoint=_,l.preventDefault(),this._active=!0,{zoomDelta:w/128}}}else this._tap.touchmove(l,p,b)}touchend(l,p,b){if(this._tapTime)this._swipePoint&&b.length===0&&this.reset();else{const _=this._tap.touchend(l,p,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 My{constructor(l,p,b){this._el=l,this._mousePan=p,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 Dy{constructor(l,p,b){this._pitchWithRotate=l.pitchWithRotate,this._mouseRotate=p,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 Kp{constructor(l,p,b,_){this._el=l,this._touchZoom=p,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 Tl{constructor(l,p){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=l,this._options=p,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=E.create("div","maplibregl-cooperative-gesture-screen",l);let p=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(p=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const b=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),_=document.createElement("div");_.className="maplibregl-desktop-message",_.textContent=p,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&&(E.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,p){this._enabled&&(this._map.fire(new o.k("cooperativegestureprevented",{gestureType:l,originalEvent:p})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const ss=k=>k.zoom||k.drag||k.pitch||k.rotate;class pt extends o.k{}function Du(k){return k.panDelta&&k.panDelta.mag()||k.zoomDelta||k.bearingDelta||k.pitchDelta}class Jp{constructor(l,p){this.handleWindowEvent=_=>{this.handleEvent(_,`${_.type}Window`)},this.handleEvent=(_,w)=>{if(_.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const D=_.type==="renderFrame"?void 0:_,P={needsRenderFrame:!1},R={},V={},$=_.touches,j=$?this._getMapTouches($):void 0,G=j?E.touchPos(this._map.getCanvas(),j):E.mousePos(this._map.getCanvas(),_);for(const{handlerName:oe,handler:ce,allowed:ue}of this._handlers){if(!ce.isEnabled())continue;let pe;this._blockedByActive(V,ue,oe)?ce.reset():ce[w||_.type]&&(pe=ce[w||_.type](_,G,j),this.mergeHandlerResult(P,R,pe,oe,D),pe&&pe.needsRenderFrame&&this._triggerRenderFrame()),(pe||ce.isActive())&&(V[oe]=ce)}const Q={};for(const oe in this._previousActiveHandlers)V[oe]||(Q[oe]=D);this._previousActiveHandlers=V,(Object.keys(Q).length||Du(P))&&(this._changes.push([P,R,Q]),this._triggerRenderFrame()),(Object.keys(V).length||Du(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ee}=P;ee&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ee(this._map))},this._map=l,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Fp(l),this._bearingSnap=p.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(p);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,D]of this._listeners)E.addEventListener(_,w,_===document?this.handleWindowEvent:this.handleEvent,D)}destroy(){for(const[l,p,b]of this._listeners)E.removeEventListener(l,p,l===document?this.handleWindowEvent:this.handleEvent,b)}_addDefaultHandlers(l){const p=this._map,b=p.getCanvasContainer();this._add("mapEvent",new Ty(p,l));const _=p.boxZoom=new Fi(p,l);this._add("boxZoom",_),l.interactive&&l.boxZoom&&_.enable();const w=p.cooperativeGestures=new Tl(p,l.cooperativeGestures);this._add("cooperativeGestures",w),l.cooperativeGestures&&w.enable();const D=new Sl(p),P=new Wv(p);p.doubleClickZoom=new Sa(P,D),this._add("tapZoom",D),this._add("clickZoom",P),l.interactive&&l.doubleClickZoom&&p.doubleClickZoom.enable();const R=new qv;this._add("tapDragZoom",R);const V=p.touchPitch=new Cl(p);this._add("touchPitch",V),l.interactive&&l.touchPitch&&p.touchPitch.enable(l.touchPitch);const $=Up(l),j=Wp(l);p.dragRotate=new Dy(l,$,j),this._add("mouseRotate",$,["mousePitch"]),this._add("mousePitch",j,["mouseRotate"]),l.interactive&&l.dragRotate&&p.dragRotate.enable();const G=(({enable:pe,clickTolerance:ne})=>{const be=new Cu({checkCorrectEvent:_e=>E.mouseButton(_e)===0&&!_e.ctrlKey});return new ho({clickTolerance:ne,move:(_e,Ee)=>({around:Ee,panDelta:Ee.sub(_e)}),activateOnStart:!0,moveStateManager:be,enable:pe,assignEvents:Tu})})(l),Q=new Ea(l,p);p.dragPan=new My(b,G,Q),this._add("mousePan",G),this._add("touchPan",Q,["touchZoom","touchRotate"]),l.interactive&&l.dragPan&&p.dragPan.enable(l.dragPan);const ee=new Zp,oe=new Gp;p.touchZoomRotate=new Kp(b,oe,ee,R),this._add("touchRotate",ee,["touchPan","touchZoom"]),this._add("touchZoom",oe,["touchPan","touchRotate"]),l.interactive&&l.touchZoomRotate&&p.touchZoomRotate.enable(l.touchZoomRotate);const ce=p.scrollZoom=new Es(p,()=>this._triggerRenderFrame());this._add("scrollZoom",ce,["mousePan"]),l.interactive&&l.scrollZoom&&p.scrollZoom.enable(l.scrollZoom);const ue=p.keyboard=new is(p);this._add("keyboard",ue),l.interactive&&l.keyboard&&p.keyboard.enable(),this._add("blockableMapEvent",new ur(p))}_add(l,p,b){this._handlers.push({handlerName:l,handler:p,allowed:b}),this._handlersById[l]=p}stop(l){if(!this._updatingCamera){for(const{handler:p}of this._handlers)p.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,p,b){for(const _ in l)if(_!==b&&(!p||p.indexOf(_)<0))return!0;return!1}_getMapTouches(l){const p=[];for(const b of l)this._el.contains(b.target)&&p.push(b);return p}mergeHandlerResult(l,p,b,_,w){if(!b)return;o.e(l,b);const D={handlerName:_,originalEvent:b.originalEvent||w};b.zoomDelta!==void 0&&(p.zoom=D),b.panDelta!==void 0&&(p.drag=D),b.pitchDelta!==void 0&&(p.pitch=D),b.bearingDelta!==void 0&&(p.rotate=D)}_applyChanges(){const l={},p={},b={};for(const[_,w,D]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(p,w),o.e(b,D);this._updateMapTransform(l,p,b),this._changes=[]}_updateMapTransform(l,p,b){const _=this._map,w=_._getTransformForUpdate(),D=_.terrain;if(!(Du(l)||D&&this._terrainMovement))return this._fireEvents(p,b,!0);let{panDelta:P,zoomDelta:R,bearingDelta:V,pitchDelta:$,around:j,pinchAround:G}=l;G!==void 0&&(j=G),_._stop(!0),j=j||_.transform.centerPoint;const Q=w.pointLocation(P?j.sub(P):j);V&&(w.bearing+=V),$&&(w.pitch+=$),R&&(w.zoom+=R),D?this._terrainMovement||!p.drag&&!p.zoom?p.drag&&this._terrainMovement?w.center=w.pointLocation(w.centerPoint.sub(P)):w.setLocationAtPoint(Q,j):(this._terrainMovement=!0,this._map._elevationFreeze=!0,w.setLocationAtPoint(Q,j)):w.setLocationAtPoint(Q,j),_._applyUpdatedTransform(w),this._map._update(),l.noInertia||this._inertia.record(l),this._fireEvents(p,b,!0)}_fireEvents(l,p,b){const _=ss(this._eventsInProgress),w=ss(l),D={};for(const j in l){const{originalEvent:G}=l[j];this._eventsInProgress[j]||(D[`${j}start`]=G),this._eventsInProgress[j]=l[j]}!_&&w&&this._fireEvent("movestart",w.originalEvent);for(const j in D)this._fireEvent(j,D[j]);w&&this._fireEvent("move",w.originalEvent);for(const j in l){const{originalEvent:G}=l[j];this._fireEvent(j,G)}const P={};let R;for(const j in this._eventsInProgress){const{handlerName:G,originalEvent:Q}=this._eventsInProgress[j];this._handlersById[G].isActive()||(delete this._eventsInProgress[j],R=p[G]||Q,P[`${j}end`]=R)}for(const j in P)this._fireEvent(j,P[j]);const V=ss(this._eventsInProgress),$=(_||w)&&!V;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),G=Q=>Q!==0&&-this._bearingSnap<Q&&Q<this._bearingSnap;!j||!j.essential&&v.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:R})),G(this._map.getBearing())&&this._map.resetNorth()):(G(j.bearing||this._map.getBearing())&&(j.bearing=0),j.freezeElevation=!0,this._map.easeTo(j,{originalEvent:R})),this._updatingCamera=!1}}_fireEvent(l,p){this._map.fire(new o.k(l,p?{originalEvent:p}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(l=>{delete this._frameId,this.handleEvent(new pt("renderFrame",{timeStamp:l})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Iy extends o.E{constructor(l,p){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=p.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.N(this.transform.center.lng,this.transform.center.lat)}setCenter(l,p){return this.jumpTo({center:l},p)}panBy(l,p,b){return l=o.P.convert(l).mult(-1),this.panTo(this.transform.center,o.e({offset:l},p),b)}panTo(l,p,b){return this.easeTo(o.e({center:l},p),b)}getZoom(){return this.transform.zoom}setZoom(l,p){return this.jumpTo({zoom:l},p),this}zoomTo(l,p,b){return this.easeTo(o.e({zoom:l},p),b)}zoomIn(l,p){return this.zoomTo(this.getZoom()+1,l,p),this}zoomOut(l,p){return this.zoomTo(this.getZoom()-1,l,p),this}getBearing(){return this.transform.bearing}setBearing(l,p){return this.jumpTo({bearing:l},p),this}getPadding(){return this.transform.padding}setPadding(l,p){return this.jumpTo({padding:l},p),this}rotateTo(l,p,b){return this.easeTo(o.e({bearing:l},p),b)}resetNorth(l,p){return this.rotateTo(0,o.e({duration:1e3},l),p),this}resetNorthPitch(l,p){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},l),p),this}snapToNorth(l,p){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(l,p):this}getPitch(){return this.transform.pitch}setPitch(l,p){return this.jumpTo({pitch:l},p),this}cameraForBounds(l,p){l=Ce.convert(l).adjustAntiMeridian();const b=p&&p.bearing||0;return this._cameraForBoxAndBearing(l.getNorthWest(),l.getSouthEast(),b,p)}_cameraForBoxAndBearing(l,p,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 Xe=_.padding;_.padding={top:Xe,bottom:Xe,right:Xe,left:Xe}}_.padding=o.e(w,_.padding);const D=this.transform,P=D.padding,R=new Ce(l,p),V=D.project(R.getNorthWest()),$=D.project(R.getNorthEast()),j=D.project(R.getSouthEast()),G=D.project(R.getSouthWest()),Q=o.ba(-b),ee=V.rotate(Q),oe=$.rotate(Q),ce=j.rotate(Q),ue=G.rotate(Q),pe=new o.P(Math.max(ee.x,oe.x,ue.x,ce.x),Math.max(ee.y,oe.y,ue.y,ce.y)),ne=new o.P(Math.min(ee.x,oe.x,ue.x,ce.x),Math.min(ee.y,oe.y,ue.y,ce.y)),be=pe.sub(ne),_e=(D.width-(P.left+P.right+_.padding.left+_.padding.right))/be.x,Ee=(D.height-(P.top+P.bottom+_.padding.top+_.padding.bottom))/be.y;if(Ee<0||_e<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const Be=Math.min(D.scaleZoom(D.scale*Math.min(_e,Ee)),_.maxZoom),He=o.P.convert(_.offset),nt=new o.P((_.padding.left-_.padding.right)/2,(_.padding.top-_.padding.bottom)/2).rotate(o.ba(b)),ct=He.add(nt).mult(D.scale/D.zoomScale(Be));return{center:D.unproject(V.add(j).div(2).sub(ct)),zoom:Be,bearing:b}}fitBounds(l,p,b){return this._fitInternal(this.cameraForBounds(l,p),p,b)}fitScreenCoordinates(l,p,b,_,w){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(l)),this.transform.pointLocation(o.P.convert(p)),b,_),_,w)}_fitInternal(l,p,b){return l?(delete(p=o.e(l,p)).padding,p.linear?this.easeTo(p,b):this.flyTo(p,b)):this}jumpTo(l,p){this.stop();const b=this._getTransformForUpdate();let _=!1,w=!1,D=!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&&(D=!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",p)).fire(new o.k("move",p)),_&&this.fire(new o.k("zoomstart",p)).fire(new o.k("zoom",p)).fire(new o.k("zoomend",p)),w&&this.fire(new o.k("rotatestart",p)).fire(new o.k("rotate",p)).fire(new o.k("rotateend",p)),D&&this.fire(new o.k("pitchstart",p)).fire(new o.k("pitch",p)).fire(new o.k("pitchend",p)),this.fire(new o.k("moveend",p))}calculateCameraOptionsFromTo(l,p,b,_=0){const w=o.Z.fromLngLat(l,p),D=o.Z.fromLngLat(b,_),P=D.x-w.x,R=D.y-w.y,V=D.z-w.z,$=Math.hypot(P,R,V);if($===0)throw new Error("Can't calculate camera options with same From and To");const j=Math.hypot(P,R),G=this.transform.scaleZoom(this.transform.cameraToCenterDistance/$/this.transform.tileSize),Q=180*Math.atan2(P,-R)/Math.PI;let ee=180*Math.acos(j/$)/Math.PI;return ee=V<0?90-ee:90+ee,{center:D.toLngLat(),zoom:G,pitch:ee,bearing:Q}}easeTo(l,p){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,D=_.bearing,P=_.pitch,R=_.padding,V="bearing"in l?this._normalizeBearing(l.bearing,D):D,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,G=o.P.convert(l.offset);let Q=_.centerPoint.add(G);const ee=_.pointLocation(Q),{center:oe,zoom:ce}=_.getConstrained(o.N.convert(l.center||ee),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(oe,_);const ue=_.project(ee),pe=_.project(oe).sub(ue),ne=_.zoomScale(ce-w);let be,_e;l.around&&(be=o.N.convert(l.around),_e=_.locationPoint(be));const Ee={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||ce!==w,this._rotating=this._rotating||D!==V,this._pitching=this._pitching||$!==P,this._padding=!_.isPaddingEqual(j),this._easeId=l.easeId,this._prepareEase(p,l.noMoveStart,Ee),this.terrain&&this._prepareElevation(oe),this._ease(Be=>{if(this._zooming&&(_.zoom=o.y.number(w,ce,Be)),this._rotating&&(_.bearing=o.y.number(D,V,Be)),this._pitching&&(_.pitch=o.y.number(P,$,Be)),this._padding&&(_.interpolatePadding(R,j,Be),Q=_.centerPoint.add(G)),this.terrain&&!l.freezeElevation&&this._updateElevation(Be),be)_.setLocationAtPoint(be,_e);else{const He=_.zoomScale(_.zoom-w),nt=ce>w?Math.min(2,ne):Math.max(.5,ne),ct=Math.pow(nt,1-Be),Xe=_.unproject(ue.add(pe.mult(Be*ct)).mult(He));_.setLocationAtPoint(_.renderWorldCopies?Xe.wrap():Xe,Q)}this._applyUpdatedTransform(_),this._fireMoveEvents(p)},Be=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(p,Be)},l),this}_prepareEase(l,p,b={}){this._moving=!0,p||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 p=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(l<1&&p!==this._elevationTarget){const b=this._elevationTarget-this._elevationStart;this._elevationStart+=l*(b-(p-(b*l+this._elevationStart))/(1-l)),this._elevationTarget=p}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 p=l.getCameraPosition(),b=this.terrain.getElevationForLngLatZoom(p.lngLat,l.zoom);if(p.altitude<b){const _=this.calculateCameraOptionsFromTo(p.lngLat,b,l.center,l.elevation);return{pitch:_.pitch,zoom:_.zoom}}return{}}_applyUpdatedTransform(l){const p=[];if(this.terrain&&p.push(_=>this._elevateCameraIfInsideTerrain(_)),this.transformCameraUpdate&&p.push(_=>this.transformCameraUpdate(_)),!p.length)return;const b=l.clone();for(const _ of p){const w=b.clone(),{center:D,zoom:P,pitch:R,bearing:V,elevation:$}=_(w);D&&(w.center=D),P!==void 0&&(w.zoom=P),R!==void 0&&(w.pitch=R),V!==void 0&&(w.bearing=V),$!==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,p){if(this._easeId&&p&&this._easeId===p)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,p){var b;if(!l.essential&&v.prefersReducedMotion){const ot=o.M(l,["center","zoom","bearing","pitch","around"]);return this.jumpTo(ot,p)}this.stop(),l=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b9},l);const _=this._getTransformForUpdate(),w=_.zoom,D=_.bearing,P=_.pitch,R=_.padding,V="bearing"in l?this._normalizeBearing(l.bearing,D):D,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,G=o.P.convert(l.offset);let Q=_.centerPoint.add(G);const ee=_.pointLocation(Q),{center:oe,zoom:ce}=_.getConstrained(o.N.convert(l.center||ee),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(oe,_);const ue=_.zoomScale(ce-w),pe=_.project(ee),ne=_.project(oe).sub(pe);let be=l.curve;const _e=Math.max(_.width,_.height),Ee=_e/ue,Be=ne.mag();if("minZoom"in l){const ot=o.ac(Math.min(l.minZoom,w,ce),_.minZoom,_.maxZoom),Bt=_e/_.zoomScale(ot-w);be=Math.sqrt(Bt/Be*2)}const He=be*be;function nt(ot){const Bt=(Ee*Ee-_e*_e+(ot?-1:1)*He*He*Be*Be)/(2*(ot?Ee:_e)*He*Be);return Math.log(Math.sqrt(Bt*Bt+1)-Bt)}function ct(ot){return(Math.exp(ot)-Math.exp(-ot))/2}function Xe(ot){return(Math.exp(ot)+Math.exp(-ot))/2}const Ze=nt(!1);let _t=function(ot){return Xe(Ze)/Xe(Ze+be*ot)},Vt=function(ot){return _e*((Xe(Ze)*(ct(Bt=Ze+be*ot)/Xe(Bt))-ct(Ze))/He)/Be;var Bt},Je=(nt(!0)-Ze)/be;if(Math.abs(Be)<1e-6||!isFinite(Je)){if(Math.abs(_e-Ee)<1e-6)return this.easeTo(l,p);const ot=Ee<_e?-1:1;Je=Math.abs(Math.log(Ee/_e))/be,Vt=()=>0,_t=Bt=>Math.exp(ot*be*Bt)}return l.duration="duration"in l?+l.duration:1e3*Je/("screenSpeed"in l?+l.screenSpeed/be:+l.speed),l.maxDuration&&l.duration>l.maxDuration&&(l.duration=0),this._zooming=!0,this._rotating=D!==V,this._pitching=$!==P,this._padding=!_.isPaddingEqual(j),this._prepareEase(p,!1),this.terrain&&this._prepareElevation(oe),this._ease(ot=>{const Bt=ot*Je,Gn=1/_t(Bt);_.zoom=ot===1?ce:w+_.scaleZoom(Gn),this._rotating&&(_.bearing=o.y.number(D,V,ot)),this._pitching&&(_.pitch=o.y.number(P,$,ot)),this._padding&&(_.interpolatePadding(R,j,ot),Q=_.centerPoint.add(G)),this.terrain&&!l.freezeElevation&&this._updateElevation(ot);const Gt=ot===1?oe:_.unproject(pe.add(ne.mult(Vt(Bt))).mult(Gn));_.setLocationAtPoint(_.renderWorldCopies?Gt.wrap():Gt,Q),this._applyUpdatedTransform(_),this._fireMoveEvents(p)},()=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(p)},l),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(l,p){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,p)}return l||(b=this.handlers)===null||b===void 0||b.stop(!1),this}_ease(l,p,b){b.animate===!1||b.duration===0?(l(1),p()):(this._easeStart=v.now(),this._easeOptions=b,this._onEaseFrame=l,this._onEaseEnd=p,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(l,p){l=o.b3(l,-180,180);const b=Math.abs(l-p);return Math.abs(l-360-p)<b&&(l-=360),Math.abs(l+360-p)<b&&(l+=360),l}_normalizeCenter(l,p){if(!p.renderWorldCopies||p.lngRange)return;const b=l.lng-p.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 Al={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ml{constructor(l=Al){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=p=>{!p||p.sourceDataType!=="metadata"&&p.sourceDataType!=="visibility"&&p.dataType!=="style"&&p.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=E.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=E.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=E.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(){E.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,p){const b=this._map._getUIString(`AttributionControl.${p}`);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 p=this._map.style.sourceCaches;for(const _ in p){const w=p[_];if(w.used||w.usedForTerrain){const D=w.getSource();D.attribution&&l.indexOf(D.attribution)<0&&l.push(D.attribution)}}l=l.filter(_=>String(_).trim()),l.sort((_,w)=>_.length-w.length),l=l.filter((_,w)=>{for(let D=w+1;D<l.length;D++)if(l[D].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 Qp{constructor(l={}){this._updateCompact=()=>{const p=this._container.children;if(p.length){const b=p[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=E.create("div","maplibregl-ctrl");const p=E.create("a","maplibregl-ctrl-logo");return p.target="_blank",p.rel="noopener nofollow",p.href="https://maplibre.org/",p.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),p.setAttribute("rel","noopener nofollow"),this._container.appendChild(p),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){E.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class dn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(l){const p=++this._id;return this._queue.push({callback:l,id:p,cancelled:!1}),p}remove(l){const p=this._currentlyRunning,b=p?this._queue.concat(p):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 p=this._currentlyRunning=this._queue;this._queue=[];for(const b of p)if(!b.cancelled&&(b.callback(l),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var ef=o.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Gv 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,p){this.sourceCache.update(l,p),this._renderableTilesKeys=[];const b={};for(const _ of l.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:p}))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 Oi(_,this.tileSize));for(const _ in this._tiles)b[_]||delete this._tiles[_]}freeRtt(l){for(const p in this._tiles){const b=this._tiles[p];(!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 p={};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),p[b]=w}else if(_.canonical.isChildOf(l.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const D=_.canonical.z-l.canonical.z,P=_.canonical.x-(_.canonical.x>>D<<D),R=_.canonical.y-(_.canonical.y>>D<<D),V=o.X>>D;o.aP(w.posMatrix,0,V,0,V,0,1),o.J(w.posMatrix,w.posMatrix,[-P*V,-R*V,0]),p[b]=w}else if(l.canonical.isChildOf(_.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const D=l.canonical.z-_.canonical.z,P=l.canonical.x-(l.canonical.x>>D<<D),R=l.canonical.y-(l.canonical.y>>D<<D),V=o.X>>D;o.aP(w.posMatrix,0,o.X,0,o.X,0,1),o.J(w.posMatrix,w.posMatrix,[P*V,R*V,0]),o.K(w.posMatrix,w.posMatrix,[1/2**D,1/2**D,0]),p[b]=w}}return p}getSourceTile(l,p){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)&&p)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(p=>p.timeAdded>=l)}}class tf{constructor(l,p,b){this.painter=l,this.sourceCache=new Gv(p),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,p,b,_=o.X){var w;if(!(p>=0&&p<_&&b>=0&&b<_))return 0;const D=this.getTerrainData(l),P=(w=D.tile)===null||w===void 0?void 0:w.dem;if(!P)return 0;const R=function(ee,oe,ce){var ue=oe[0],pe=oe[1];return ee[0]=ce[0]*ue+ce[4]*pe+ce[12],ee[1]=ce[1]*ue+ce[5]*pe+ce[13],ee}([],[p/_*o.X,b/_*o.X],D.u_terrain_matrix),V=[R[0]*P.dim,R[1]*P.dim],$=Math.floor(V[0]),j=Math.floor(V[1]),G=V[0]-$,Q=V[1]-j;return P.get($,j)*(1-G)*(1-Q)+P.get($+1,j)*G*(1-Q)+P.get($,j+1)*(1-G)*Q+P.get($+1,j+1)*G*Q}getElevationForLngLatZoom(l,p){if(!o.bb(p,l.wrap()))return 0;const{tileID:b,mercatorX:_,mercatorY:w}=this._getOverscaledTileIDFromLngLatZoom(l,p);return this.getElevation(b,_%o.X,w%o.X,o.X)}getElevation(l,p,b,_=o.X){return this.getDEMElevation(l,p,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 Qe(_,w,_.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Qe(_,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 p=this.sourceCache.getSourceTile(l,!0);if(p&&p.dem&&(!p.demTexture||p.needsTerrainPrepare)){const _=this.painter.context;p.demTexture=this.painter.getTileTexture(p.dem.stride),p.demTexture?p.demTexture.update(p.dem.getPixels(),{premultiply:!1}):p.demTexture=new Qe(_,p.dem.getPixels(),_.gl.RGBA,{premultiply:!1}),p.demTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),p.needsTerrainPrepare=!1}const b=p&&p+p.tileID.key+l.key;if(b&&!this._demMatrixCache[b]){const _=this.sourceCache.sourceCache._source.maxzoom;let w=l.canonical.z-p.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 D=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,[D*o.X,P*o.X,0]),this._demMatrixCache[l.key]={matrix:R,coord:l}}return{u_depth:2,u_terrain:3,u_terrain_dim:p&&p.dem&&p.dem.dim||1,u_terrain_matrix:b?this._demMatrixCache[l.key].matrix:this._emptyDemMatrix,u_terrain_unpack:p&&p.dem&&p.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(p&&p.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:p}}getFramebuffer(l){const p=this.painter,b=p.width/devicePixelRatio,_=p.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 Qe(p.context,{width:b,height:_,data:null},p.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(p.context.gl.NEAREST,p.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Qe(p.context,{width:b,height:_,data:null},p.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(p.context.gl.NEAREST,p.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=p.context.createFramebuffer(b,_,!0,!1),this._fbo.depthAttachment.set(p.context.createRenderbuffer(p.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 p=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let w=0,D=0;w<this._coordsTextureSize;w++)for(let P=0;P<this._coordsTextureSize;P++,D+=4)p[D+0]=255&P,p[D+1]=255&w,p[D+2]=P>>8<<4|w>>8,p[D+3]=0;const b=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(p.buffer)),_=new Qe(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 p=new Uint8Array(4),b=this.painter.context,_=b.gl,w=Math.round(l.x*this.painter.pixelRatio/devicePixelRatio),D=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-D-1,1,1,_.RGBA,_.UNSIGNED_BYTE,p),b.bindFramebuffer.set(null);const R=p[0]+(p[2]>>4<<8),V=p[1]+((15&p[2])<<8),$=this.coordsIndex[255-p[3]],j=$&&this.sourceCache.getTileByID($);if(!j)return null;const G=this._coordsTextureSize,Q=(1<<j.tileID.canonical.z)*G;return new o.Z((j.tileID.canonical.x*G+R)/Q+j.tileID.wrap,(j.tileID.canonical.y*G+V)/Q,this.getElevation(j.tileID,R,V,G))}depthAtPoint(l){const p=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,p),b.bindFramebuffer.set(null),(p[0]/16777216+p[1]/65536+p[2]/256+p[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const l=this.painter.context,p=new o.bd,b=new o.aY,_=this.meshSize,w=o.X/_,D=_*_;for(let j=0;j<=_;j++)for(let G=0;G<=_;G++)p.emplaceBack(G*w,j*w,0);for(let j=0;j<D;j+=_+1)for(let G=0;G<_;G++)b.emplaceBack(G+j,_+G+j+1,_+G+j+2),b.emplaceBack(G+j,_+G+j+2,G+j+1);const P=p.length,R=P+2*(_+1);for(const j of[0,1])for(let G=0;G<=_;G++)for(const Q of[0,1])p.emplaceBack(G*w,j*o.X,Q);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 V=p.length,$=V+2*(_+1);for(const j of[0,1])for(let G=0;G<=_;G++)for(const Q of[0,1])p.emplaceBack(j*o.X,G*w,Q);for(let j=0;j<2*_;j+=2)b.emplaceBack(V+j,V+j+1,V+j+3),b.emplaceBack(V+j,V+j+3,V+j+2),b.emplaceBack($+j,$+j+3,$+j+1),b.emplaceBack($+j,$+j+2,$+j+3);return this._mesh=new xu(l.createVertexBuffer(p,ef.members),l.createIndexBuffer(b),o.a0.simpleSegment(0,0,p.length,b.length)),this._mesh}getMeshFrameDelta(l){return 2*Math.PI*o.be/Math.pow(2,l)/5}getMinTileElevationForLngLatZoom(l,p){var b;const{tileID:_}=this._getOverscaledTileIDFromLngLatZoom(l,p);return(b=this.getMinMaxElevation(_).minElevation)!==null&&b!==void 0?b:0}getMinMaxElevation(l){const p=this.getTerrainData(l).tile,b={minElevation:null,maxElevation:null};return p&&p.dem&&(b.minElevation=p.dem.min*this.exaggeration,b.maxElevation=p.dem.max*this.exaggeration),b}_getOverscaledTileIDFromLngLatZoom(l,p){const b=o.Z.fromLngLat(l.wrap()),_=(1<<p)*o.X,w=b.x*_,D=b.y*_,P=Math.floor(w/o.X),R=Math.floor(D/o.X);return{tileID:new o.S(p,0,p,P,R),mercatorX:w,mercatorY:D}}}class Yv{constructor(l,p,b){this._context=l,this._size=p,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 p=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),b=new Qe(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),p.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),p.colorAttachment.set(b.texture),{id:l,fbo:p,texture:b,stamp:-1,inUse:!1}}getObjectForId(l){return this._objects[l]}useObject(l){l.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(p=>l.id!==p),this._recentlyUsed.push(l.id)}stampObject(l){l.stamp=++this._stamp}getOrCreateFreeObject(){for(const p of this._recentlyUsed)if(!this._objects[p].inUse)return this._objects[p];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 Dl={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Py{constructor(l,p){this.painter=l,this.terrain=p,this.pool=new Yv(l.context,30,p.sourceCache.tileSize*p.qualityFactor)}destruct(){this.pool.destruct()}getTexture(l){return this.pool.getObjectForId(l.rtt[this._stacks.length-1].id).texture}prepareForRender(l,p){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=l._order.filter(b=>!l._layers[b].isHidden(p)),this._coordsDescendingInv={};for(const b in l.sourceCaches){this._coordsDescendingInv[b]={};const _=l.sourceCaches[b].getVisibleCoordinates();for(const w of _){const D=this.terrain.sourceCache.getTerrainCoords(w);for(const P in D)this._coordsDescendingInv[b][P]||(this._coordsDescendingInv[b][P]=[]),this._coordsDescendingInv[b][P].push(D[P])}}this._coordsDescendingInvStr={};for(const b of l._order){const _=l._layers[b],w=_.source;if(Dl[_.type]&&!this._coordsDescendingInvStr[w]){this._coordsDescendingInvStr[w]={};for(const D in this._coordsDescendingInv[w])this._coordsDescendingInvStr[w][D]=this._coordsDescendingInv[w][D].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 p=l.type,b=this.painter,_=this._renderableLayerIds[this._renderableLayerIds.length-1]===l.id;if(Dl[p]&&(this._prevType&&Dl[this._prevType]||this._stacks.push([]),this._prevType=p,this._stacks[this._stacks.length-1].push(l.id),!_))return!0;if(Dl[this._prevType]||Dl[p]&&_){this._prevType=p;const w=this._stacks.length-1,D=this._stacks[w]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(Ey(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[w]){const V=this.pool.getObjectForId(P.rtt[w].id);if(V.stamp===P.rtt[w].stamp){this.pool.useObject(V);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 V=0;V<D.length;V++){const $=b.style._layers[D[V]],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 Ey(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Dl[p]}return!1}}const nf={"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"},Ry=f,Zv={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Al,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},rf=k=>{k.touchstart=k.dragStart,k.touchmoveWindow=k.dragMove,k.touchend=k.dragEnd},Xv={showCompass:!0,showZoom:!0,visualizePitch:!1};class Kv{constructor(l,p,b=!1){this.mousedown=D=>{this.startMouse(o.e({},D,{ctrlKey:!0,preventDefault:()=>D.preventDefault()}),E.mousePos(this.element,D)),E.addEventListener(window,"mousemove",this.mousemove),E.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=D=>{this.moveMouse(D,E.mousePos(this.element,D))},this.mouseup=D=>{this.mouseRotate.dragEnd(D),this.mousePitch&&this.mousePitch.dragEnd(D),this.offTemp()},this.touchstart=D=>{D.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=E.touchPos(this.element,D.targetTouches)[0],this.startTouch(D,this._startPos),E.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),E.addEventListener(window,"touchend",this.touchend))},this.touchmove=D=>{D.targetTouches.length!==1?this.reset():(this._lastPos=E.touchPos(this.element,D.targetTouches)[0],this.moveTouch(D,this._lastPos))},this.touchend=D=>{D.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=p,this.mouseRotate=Up({clickTolerance:_,enable:!0}),this.touchRotate=(({enable:D,clickTolerance:P,bearingDegreesPerPixelMoved:R=.8})=>{const V=new Hp;return new ho({clickTolerance:P,move:($,j)=>({bearingDelta:(j.x-$.x)*R}),moveStateManager:V,enable:D,assignEvents:rf})})({clickTolerance:_,enable:!0}),this.map=l,b&&(this.mousePitch=Wp({clickTolerance:w,enable:!0}),this.touchPitch=(({enable:D,clickTolerance:P,pitchDegreesPerPixelMoved:R=-.5})=>{const V=new Hp;return new ho({clickTolerance:P,move:($,j)=>({pitchDelta:(j.y-$.y)*R}),moveStateManager:V,enable:D,assignEvents:rf})})({clickTolerance:w,enable:!0})),E.addEventListener(p,"mousedown",this.mousedown),E.addEventListener(p,"touchstart",this.touchstart,{passive:!1}),E.addEventListener(p,"touchcancel",this.reset)}startMouse(l,p){this.mouseRotate.dragStart(l,p),this.mousePitch&&this.mousePitch.dragStart(l,p),E.disableDrag()}startTouch(l,p){this.touchRotate.dragStart(l,p),this.touchPitch&&this.touchPitch.dragStart(l,p),E.disableDrag()}moveMouse(l,p){const b=this.map,{bearingDelta:_}=this.mouseRotate.dragMove(l,p)||{};if(_&&b.setBearing(b.getBearing()+_),this.mousePitch){const{pitchDelta:w}=this.mousePitch.dragMove(l,p)||{};w&&b.setPitch(b.getPitch()+w)}}moveTouch(l,p){const b=this.map,{bearingDelta:_}=this.touchRotate.dragMove(l,p)||{};if(_&&b.setBearing(b.getBearing()+_),this.touchPitch){const{pitchDelta:w}=this.touchPitch.dragMove(l,p)||{};w&&b.setPitch(b.getPitch()+w)}}off(){const l=this.element;E.removeEventListener(l,"mousedown",this.mousedown),E.removeEventListener(l,"touchstart",this.touchstart,{passive:!1}),E.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),E.removeEventListener(window,"touchend",this.touchend),E.removeEventListener(l,"touchcancel",this.reset),this.offTemp()}offTemp(){E.enableDrag(),E.removeEventListener(window,"mousemove",this.mousemove),E.removeEventListener(window,"mouseup",this.mouseup),E.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),E.removeEventListener(window,"touchend",this.touchend)}}let $i;function qn(k,l,p){const b=new o.N(k.lng,k.lat);if(k=new o.N(k.lng,k.lat),l){const _=new o.N(k.lng-360,k.lat),w=new o.N(k.lng+360,k.lat),D=p.locationPoint(k).distSqr(l);p.locationPoint(_).distSqr(l)<D?k=_:p.locationPoint(w).distSqr(l)<D&&(k=w)}for(;Math.abs(k.lng-p.center.lng)>180;){const _=p.locationPoint(k);if(_.x>=0&&_.y>=0&&_.x<=p.width&&_.y<=p.height)break;k.lng>p.center.lng?k.lng-=360:k.lng+=360}return k.lng!==b.lng&&p.locationPoint(k).y>p.height/2-p.getHorizon()?k:b}const Il={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 Iu(k,l,p){const b=k.classList;for(const _ in Il)b.remove(`maplibregl-${p}-anchor-${_}`);b.add(`maplibregl-${p}-anchor-${l}`)}class Pu extends o.E{constructor(l){if(super(),this._onKeyPress=p=>{const b=p.code,_=p.charCode||p.keyCode;b!=="Space"&&b!=="Enter"&&_!==32&&_!==13||this.togglePopup()},this._onMapClick=p=>{const b=p.originalEvent.target,_=this._element;this._popup&&(b===_||_.contains(b))&&this.togglePopup()},this._update=p=>{var b;if(!this._map)return;const _=this._map.loaded()&&!this._map.isMoving();((p==null?void 0:p.type)==="terrain"||(p==null?void 0:p.type)==="render"&&!_)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?qn(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 D="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?D="rotateX(0deg)":this._pitchAlignment==="map"&&(D=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||p&&p.type!=="moveend"||(this._pos=this._pos.round()),E.setTransform(this._element,`${Il[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${D} ${w}`),v.frameAsync(new AbortController).then(()=>{this._updateOpacity(p&&p.type==="moveend")}).catch(()=>{})},this._onMove=p=>{if(!this._isDragging){const b=this._clickTolerance||this._map._clickTolerance;this._isDragging=p.point.dist(this._pointerdownPos)>=b}this._isDragging&&(this._pos=p.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=p=>{this._element.contains(p.originalEvent.target)&&(p.preventDefault(),this._positionDelta=p.point.sub(this._pos).add(this._offset),this._pointerdownPos=p.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=E.create("div");const p=E.createNS("http://www.w3.org/2000/svg","svg"),b=41,_=27;p.setAttributeNS(null,"display","block"),p.setAttributeNS(null,"height",`${b}px`),p.setAttributeNS(null,"width",`${_}px`),p.setAttributeNS(null,"viewBox",`0 0 ${_} ${b}`);const w=E.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 D=E.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"fill-rule","nonzero");const P=E.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 ue of R){const pe=E.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",ue.rx),pe.setAttributeNS(null,"ry",ue.ry),P.appendChild(pe)}const V=E.createNS("http://www.w3.org/2000/svg","g");V.setAttributeNS(null,"fill",this._color);const $=E.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"),V.appendChild($);const j=E.createNS("http://www.w3.org/2000/svg","g");j.setAttributeNS(null,"opacity","0.25"),j.setAttributeNS(null,"fill","#000000");const G=E.createNS("http://www.w3.org/2000/svg","path");G.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),j.appendChild(G);const Q=E.createNS("http://www.w3.org/2000/svg","g");Q.setAttributeNS(null,"transform","translate(6.0, 7.0)"),Q.setAttributeNS(null,"fill","#FFFFFF");const ee=E.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"transform","translate(8.0, 8.0)");const oe=E.createNS("http://www.w3.org/2000/svg","circle");oe.setAttributeNS(null,"fill","#000000"),oe.setAttributeNS(null,"opacity","0.25"),oe.setAttributeNS(null,"cx","5.5"),oe.setAttributeNS(null,"cy","5.5"),oe.setAttributeNS(null,"r","5.4999962");const ce=E.createNS("http://www.w3.org/2000/svg","circle");ce.setAttributeNS(null,"fill","#FFFFFF"),ce.setAttributeNS(null,"cx","5.5"),ce.setAttributeNS(null,"cy","5.5"),ce.setAttributeNS(null,"r","5.4999962"),ee.appendChild(oe),ee.appendChild(ce),D.appendChild(P),D.appendChild(V),D.appendChild(j),D.appendChild(Q),D.appendChild(ee),p.appendChild(D),p.setAttributeNS(null,"height",b*this._scale+"px"),p.setAttributeNS(null,"width",_*this._scale+"px"),this._element.appendChild(p),this._offset=o.P.convert(l&&l.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",p=>{p.preventDefault()}),this._element.addEventListener("mousedown",p=>{p.preventDefault()}),Iu(this._element,this._anchor,"marker"),l&&l.className)for(const p of l.className.split(" "))this._element.classList.add(p);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),E.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 p,b;if(!(!((p=this._map)===null||p===void 0)&&p.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),D=_.terrain.getElevationForLngLatZoom(this._lngLat,_.transform.tileZoom);if(_.transform.lngLatToCameraDepth(this._lngLat,D)-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,V=_.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),$=_.transform.lngLatToCameraDepth(this._lngLat,D+R)-V>.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,p){return l===void 0&&p===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),l!==void 0&&(this._opacity=l),p!==void 0&&(this._opacityWhenCovered=p),this._map&&this._updateOpacity(!0),this}}const Ny={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Hc=0,Uc=!1;const Zs={maxWidth:100,unit:"metric"};function Wc(k,l,p){const b=p&&p.maxWidth||100,_=k._container.clientHeight/2,w=k.unproject([0,_]),D=k.unproject([b,_]),P=w.distanceTo(D);if(p&&p.unit==="imperial"){const R=3.2808*P;R>5280?bt(l,b,R/5280,k._getUIString("ScaleControl.Miles")):bt(l,b,R,k._getUIString("ScaleControl.Feet"))}else p&&p.unit==="nautical"?bt(l,b,P/1852,k._getUIString("ScaleControl.NauticalMiles")):P>=1e3?bt(l,b,P/1e3,k._getUIString("ScaleControl.Kilometers")):bt(l,b,P,k._getUIString("ScaleControl.Meters"))}function bt(k,l,p,b){const _=function(w){const D=Math.pow(10,`${Math.floor(w)}`.length-1);let P=w/D;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(R){const V=Math.pow(10,Math.ceil(-Math.log(R)/Math.LN10));return Math.round(R*V)/V}(P),D*P}(p);k.style.width=l*(_/p)+"px",k.innerHTML=`${_}&nbsp;${b}`}const Dt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Ru=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Nu(k){if(k){if(typeof k=="number"){const l=Math.round(Math.abs(k)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,k),"top-left":new o.P(l,l),"top-right":new o.P(-l,l),bottom:new o.P(0,-k),"bottom-left":new o.P(l,-l),"bottom-right":new o.P(-l,-l),left:new o.P(k,0),right:new o.P(-k,0)}}if(k instanceof o.P||Array.isArray(k)){const l=o.P.convert(k);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(k.center||[0,0]),top:o.P.convert(k.top||[0,0]),"top-left":o.P.convert(k["top-left"]||[0,0]),"top-right":o.P.convert(k["top-right"]||[0,0]),bottom:o.P.convert(k.bottom||[0,0]),"bottom-left":o.P.convert(k["bottom-left"]||[0,0]),"bottom-right":o.P.convert(k["bottom-right"]||[0,0]),left:o.P.convert(k.left||[0,0]),right:o.P.convert(k.right||[0,0])}}return Nu(new o.P(0,0))}const sf=f;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=Ml,a.BoxZoomHandler=Fi,a.CanvasSource=yr,a.CooperativeGesturesHandler=Tl,a.DoubleClickZoomHandler=Sa,a.DragPanHandler=My,a.DragRotateHandler=Dy,a.EdgeInsets=kl,a.FullscreenControl=class extends o.E{constructor(k={}){super(),this._onFullscreenChange=()=>{var l;let p=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((l=p==null?void 0:p.shadowRoot)===null||l===void 0)&&l.fullscreenElement;)p=p.shadowRoot.fullscreenElement;p===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,k&&k.container&&(k.container instanceof HTMLElement?this._container=k.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(k){return this._map=k,this._container||(this._container=this._map.getContainer()),this._controlContainer=E.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){E.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const k=this._fullscreenButton=E.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);E.create("span","maplibregl-ctrl-icon",k).setAttribute("aria-hidden","true"),k.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const k=this._getTitle();this._fullscreenButton.setAttribute("aria-label",k),this._fullscreenButton.title=k}_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=Wr,a.GeolocateControl=class extends o.E{constructor(k){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 p=new o.N(l.coords.longitude,l.coords.latitude),b=l.coords.accuracy,_=this._map.getBearing(),w=o.e({bearing:_},this.options.fitBoundsOptions),D=Ce.fromLngLat(p,b);this._map.fitBounds(D,w,{geolocateSource:!0})},this._updateMarker=l=>{if(l){const p=new o.N(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(p).addTo(this._map),this._userLocationDotMarker.setLngLat(p).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 p=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=p,this._geolocateButton.setAttribute("aria-label",p),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&Uc)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=E.create("button","maplibregl-ctrl-geolocate",this._container),E.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 p=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=p,this._geolocateButton.setAttribute("aria-label",p)}else{const p=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=p,this._geolocateButton.setAttribute("aria-label",p)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=E.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Pu({element:this._dotElement}),this._circleElement=E.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Pu({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",p=>{p.geolocateSource||this._watchState!=="ACTIVE_LOCK"||p.originalEvent&&p.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({},Ny,k)}onAdd(k){return this._map=k,this._container=E.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return o._(this,arguments,void 0,function*(l=!1){if($i!==void 0&&!l)return $i;if(window.navigator.permissions===void 0)return $i=!!window.navigator.geolocation,$i;try{$i=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{$i=!!window.navigator.geolocation}return $i})}().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(),E.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Hc=0,Uc=!1}_isOutOfMapMaxBounds(k){const l=this._map.getMaxBounds(),p=k.coords;return l&&(p.longitude<l.getWest()||p.longitude>l.getEast()||p.latitude<l.getSouth()||p.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 k=this._map.getBounds(),l=k.getSouthEast(),p=k.getNorthEast(),b=l.distanceTo(p),_=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":Hc--,Uc=!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 k;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Hc++,Hc>1?(k={maximumAge:6e5,timeout:0},Uc=!0):(k=this.options.positionOptions,Uc=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,k)}}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=wu,a.ImageSource=gr,a.KeyboardHandler=is,a.LngLatBounds=Ce,a.LogoControl=Qp,a.Map=class extends Iy{constructor(k){o.bf.mark(o.bg.create);const l=Object.assign(Object.assign({},Zv),k);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 El(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),{bearingSnap:l.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new dn,this._controls=[],this._mapId=o.a4(),this._contextLost=p=>{p.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:p}))},this._contextRestored=p=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:p}))},this._onMapScroll=p=>{if(p.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({},nf),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=te.addThrottleControl(()=>this.isMoving()),this._requestManager=new X(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 p=!1;const b=Vc(_=>{this._trackResize&&!this._removed&&(this.resize(_),this.redraw())},50);this._resizeObserver=new ResizeObserver(_=>{p?b(_):p=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Jp(this,l),this._hash=l.hash&&new wu(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 Ml(typeof l.attributionControl=="boolean"?void 0:l.attributionControl)),l.maplibreLogo&&this.addControl(new Qp,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",p=>{this._update(p.dataType==="style"),this.fire(new o.k(`${p.dataType}data`,p))}),this.on("dataloading",p=>{this.fire(new o.k(`${p.dataType}dataloading`,p))}),this.on("dataabort",p=>{this.fire(new o.k("sourcedataabort",p))})}_getMapId(){return this._mapId}addControl(k,l){if(l===void 0&&(l=k.getDefaultPosition?k.getDefaultPosition():"top-right"),!k||!k.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 p=k.onAdd(this);this._controls.push(k);const b=this._controlPositions[l];return l.indexOf("bottom")!==-1?b.insertBefore(p,b.firstChild):b.appendChild(p),this}removeControl(k){if(!k||!k.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(k);return l>-1&&this._controls.splice(l,1),k.onRemove(this),this}hasControl(k){return this._controls.indexOf(k)>-1}calculateCameraOptionsFromTo(k,l,p,b){return b==null&&this.terrain&&(b=this.terrain.getElevationForLngLatZoom(p,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(k,l,p,b)}resize(k){var l;const p=this._containerDimensions(),b=p[0],_=p[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 D=!this._moving;return D&&(this.stop(),this.fire(new o.k("movestart",k)).fire(new o.k("move",k))),this.fire(new o.k("resize",k)),D&&this.fire(new o.k("moveend",k)),this}_getClampedPixelRatio(k,l){const{0:p,1:b}=this._maxCanvasSize,_=this.getPixelRatio(),w=k*_,D=l*_;return Math.min(w>p?p/w:1,D>b?b/D:1)*_}getPixelRatio(){var k;return(k=this._overridePixelRatio)!==null&&k!==void 0?k:devicePixelRatio}setPixelRatio(k){this._overridePixelRatio=k,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(k){return this.transform.setMaxBounds(Ce.convert(k)),this._update()}setMinZoom(k){if((k=k??-2)>=-2&&k<=this.transform.maxZoom)return this.transform.minZoom=k,this._update(),this.getZoom()<k&&this.setZoom(k),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(k){if((k=k??22)>=this.transform.minZoom)return this.transform.maxZoom=k,this._update(),this.getZoom()>k&&this.setZoom(k),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(k){if((k=k??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(k>=0&&k<=this.transform.maxPitch)return this.transform.minPitch=k,this._update(),this.getPitch()<k&&this.setPitch(k),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(k){if((k=k??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(k>=this.transform.minPitch)return this.transform.maxPitch=k,this._update(),this.getPitch()>k&&this.setPitch(k),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(k){return this.transform.renderWorldCopies=k,this._update()}project(k){return this.transform.locationPoint(o.N.convert(k),this.style&&this.terrain)}unproject(k){return this.transform.pointLocation(o.P.convert(k),this.terrain)}isMoving(){var k;return this._moving||((k=this.handlers)===null||k===void 0?void 0:k.isMoving())}isZooming(){var k;return this._zooming||((k=this.handlers)===null||k===void 0?void 0:k.isZooming())}isRotating(){var k;return this._rotating||((k=this.handlers)===null||k===void 0?void 0:k.isRotating())}_createDelegatedListener(k,l,p){if(k==="mouseenter"||k==="mouseover"){let b=!1;return{layers:l,listener:p,delegates:{mousemove:w=>{const D=l.filter(R=>this.getLayer(R)),P=D.length!==0?this.queryRenderedFeatures(w.point,{layers:D}):[];P.length?b||(b=!0,p.call(this,new qr(k,this,w.originalEvent,{features:P}))):b=!1},mouseout:()=>{b=!1}}}}if(k==="mouseleave"||k==="mouseout"){let b=!1;return{layers:l,listener:p,delegates:{mousemove:D=>{const P=l.filter(R=>this.getLayer(R));(P.length!==0?this.queryRenderedFeatures(D.point,{layers:P}):[]).length?b=!0:b&&(b=!1,p.call(this,new qr(k,this,D.originalEvent)))},mouseout:D=>{b&&(b=!1,p.call(this,new qr(k,this,D.originalEvent)))}}}}{const b=_=>{const w=l.filter(P=>this.getLayer(P)),D=w.length!==0?this.queryRenderedFeatures(_.point,{layers:w}):[];D.length&&(_.features=D,p.call(this,_),delete _.features)};return{layers:l,listener:p,delegates:{[k]:b}}}}_saveDelegatedListener(k,l){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[k]=this._delegatedListeners[k]||[],this._delegatedListeners[k].push(l)}_removeDelegatedListener(k,l,p){if(!this._delegatedListeners||!this._delegatedListeners[k])return;const b=this._delegatedListeners[k];for(let _=0;_<b.length;_++){const w=b[_];if(w.listener===p&&w.layers.length===l.length&&w.layers.every(D=>l.includes(D))){for(const D in w.delegates)this.off(D,w.delegates[D]);return void b.splice(_,1)}}}on(k,l,p){if(p===void 0)return super.on(k,l);const b=this._createDelegatedListener(k,typeof l=="string"?[l]:l,p);this._saveDelegatedListener(k,b);for(const _ in b.delegates)this.on(_,b.delegates[_]);return this}once(k,l,p){if(p===void 0)return super.once(k,l);const b=typeof l=="string"?[l]:l,_=this._createDelegatedListener(k,b,p);for(const w in _.delegates){const D=_.delegates[w];_.delegates[w]=(...P)=>{this._removeDelegatedListener(k,b,p),D(...P)}}this._saveDelegatedListener(k,_);for(const w in _.delegates)this.once(w,_.delegates[w]);return this}off(k,l,p){return p===void 0?super.off(k,l):(this._removeDelegatedListener(k,typeof l=="string"?[l]:l,p),this)}queryRenderedFeatures(k,l){if(!this.style)return[];let p;const b=k instanceof o.P||Array.isArray(k),_=b?k:[[0,0],[this.transform.width,this.transform.height]];if(l=l||(b?{}:k)||{},_ instanceof o.P||typeof _[0]=="number")p=[o.P.convert(_)];else{const w=o.P.convert(_[0]),D=o.P.convert(_[1]);p=[w,new o.P(D.x,w.y),D,new o.P(w.x,D.y),w]}return this.style.queryRenderedFeatures(p,l,this.transform)}querySourceFeatures(k,l){return this.style.querySourceFeatures(k,l)}setStyle(k,l){return(l=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},l)).diff!==!1&&l.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&k?(this._diffStyle(k,l),this):(this._localIdeographFontFamily=l.localIdeographFontFamily,this._updateStyle(k,l))}setTransformRequest(k){return this._requestManager.setTransformRequest(k),this}_getUIString(k){const l=this._locale[k];if(l==null)throw new Error(`Missing UI string '${k}'`);return l}_updateStyle(k,l){if(l.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(k,l));const p=this.style&&l.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!k)),k?(this.style=new su(this,l||{}),this.style.setEventedParent(this,{style:this.style}),typeof k=="string"?this.style.loadURL(k,l,p):this.style.loadJSON(k,l,p),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new su(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(k,l){if(typeof k=="string"){const p=this._requestManager.transformRequest(k,"Style");o.h(p,new AbortController).then(b=>{this._updateDiff(b.data,l)}).catch(b=>{b&&this.fire(new o.j(b))})}else typeof k=="object"&&this._updateDiff(k,l)}_updateDiff(k,l){try{this.style.setState(k,l)&&this._update(!0)}catch(p){o.w(`Unable to perform style diff: ${p.message||p.error||p}. Rebuilding the style from scratch.`),this._updateStyle(k,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(k,l){return this._lazyInitEmptyStyle(),this.style.addSource(k,l),this._update(!0)}isSourceLoaded(k){const l=this.style&&this.style.sourceCaches[k];if(l!==void 0)return l.loaded();this.fire(new o.j(new Error(`There is no source with ID '${k}'`)))}setTerrain(k){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),k){const l=this.style.sourceCaches[k.source];if(!l)throw new Error(`cannot load terrain, because there exists no source with ID: ${k.source}`);this.terrain===null&&l.reload();for(const p in this.style._layers){const b=this.style._layers[p];b.type==="hillshade"&&b.source===k.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 tf(this.painter,l,k),this.painter.renderToTexture=new Py(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=p=>{p.dataType==="style"?this.terrain.sourceCache.freeRtt():p.dataType==="source"&&p.tile&&(p.sourceId!==k.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(p.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:k})),this}getTerrain(){var k,l;return(l=(k=this.terrain)===null||k===void 0?void 0:k.options)!==null&&l!==void 0?l:null}areTilesLoaded(){const k=this.style&&this.style.sourceCaches;for(const l in k){const p=k[l]._tiles;for(const b in p){const _=p[b];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}removeSource(k){return this.style.removeSource(k),this._update(!0)}getSource(k){return this.style.getSource(k)}addImage(k,l,p={}){const{pixelRatio:b=1,sdf:_=!1,stretchX:w,stretchY:D,content:P,textFitWidth:R,textFitHeight:V}=p;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:G}=l,Q=l;return this.style.addImage(k,{data:new o.R({width:$,height:j},new Uint8Array(G)),pixelRatio:b,stretchX:w,stretchY:D,content:P,textFitWidth:R,textFitHeight:V,sdf:_,version:0,userImage:Q}),Q.onAdd&&Q.onAdd(this,k),this}}{const{width:$,height:j,data:G}=v.getImageData(l);this.style.addImage(k,{data:new o.R({width:$,height:j},G),pixelRatio:b,stretchX:w,stretchY:D,content:P,textFitWidth:R,textFitHeight:V,sdf:_,version:0})}}updateImage(k,l){const p=this.style.getImage(k);if(!p)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:D}=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(_!==p.data.width||w!==p.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 p.data.replace(D,P),this.style.updateImage(k,p),this}getImage(k){return this.style.getImage(k)}hasImage(k){return k?!!this.style.getImage(k):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(k){this.style.removeImage(k)}loadImage(k){return te.getImage(this._requestManager.transformRequest(k,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(k,l){return this._lazyInitEmptyStyle(),this.style.addLayer(k,l),this._update(!0)}moveLayer(k,l){return this.style.moveLayer(k,l),this._update(!0)}removeLayer(k){return this.style.removeLayer(k),this._update(!0)}getLayer(k){return this.style.getLayer(k)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(k,l,p){return this.style.setLayerZoomRange(k,l,p),this._update(!0)}setFilter(k,l,p={}){return this.style.setFilter(k,l,p),this._update(!0)}getFilter(k){return this.style.getFilter(k)}setPaintProperty(k,l,p,b={}){return this.style.setPaintProperty(k,l,p,b),this._update(!0)}getPaintProperty(k,l){return this.style.getPaintProperty(k,l)}setLayoutProperty(k,l,p,b={}){return this.style.setLayoutProperty(k,l,p,b),this._update(!0)}getLayoutProperty(k,l){return this.style.getLayoutProperty(k,l)}setGlyphs(k,l={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(k,l),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(k,l,p={}){return this._lazyInitEmptyStyle(),this.style.addSprite(k,l,p,b=>{b||this._update(!0)}),this}removeSprite(k){return this._lazyInitEmptyStyle(),this.style.removeSprite(k),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(k,l={}){return this._lazyInitEmptyStyle(),this.style.setSprite(k,l,p=>{p||this._update(!0)}),this}setLight(k,l={}){return this._lazyInitEmptyStyle(),this.style.setLight(k,l),this._update(!0)}getLight(){return this.style.getLight()}setSky(k){return this._lazyInitEmptyStyle(),this.style.setSky(k),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(k,l){return this.style.setFeatureState(k,l),this._update()}removeFeatureState(k,l){return this.style.removeFeatureState(k,l),this._update()}getFeatureState(k){return this.style.getFeatureState(k)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let k=0,l=0;return this._container&&(k=this._container.clientWidth||400,l=this._container.clientHeight||300),[k,l]}_setupContainer(){const k=this._container;k.classList.add("maplibregl-map");const l=this._canvasContainer=E.create("div","maplibregl-canvas-container",k);this._interactive&&l.classList.add("maplibregl-interactive"),this._canvas=E.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 p=this._containerDimensions(),b=this._getClampedPixelRatio(p[0],p[1]);this._resizeCanvas(p[0],p[1],b);const _=this._controlContainer=E.create("div","maplibregl-control-container",k),w=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(D=>{w[D]=E.create("div",`maplibregl-ctrl-${D} `,_)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(k,l,p){this._canvas.width=Math.floor(p*k),this._canvas.height=Math.floor(p*l),this._canvas.style.width=`${k}px`,this._canvas.style.height=`${l}px`}_setupPainter(){const k={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:k},b&&(l.statusMessage=b.statusMessage,l.type=b.type)},{once:!0});const p=this._canvas.getContext("webgl2",k)||this._canvas.getContext("webgl",k);if(!p){const b="Failed to initialize WebGL";throw l?(l.message=b,new Error(JSON.stringify(l))):new Error(b)}this.painter=new vu(p,this.transform),T.testSupport(p)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(k){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||k,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(k){return this._update(),this._renderTaskQueue.add(k)}_cancelRenderFrame(k){this._renderTaskQueue.remove(k)}_render(k){const l=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(k),this._removed)return;let p=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const _=this.transform.zoom,w=v.now();this.style.zoomHistory.update(_,w);const D=new o.z(_,{now:w,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),P=D.crossFadingFactor();P===1&&P===this._crossFadingFactor||(p=!0,this._crossFadingFactor=P),this.style.update(D)}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()||p)&&(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 k;this._hash&&this._hash.remove();for(const p of this._controls)p.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),te.removeThrottleControl(this._imageQueueHandle),(k=this._resizeObserver)===null||k===void 0||k.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),E.remove(this._canvasContainer),E.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(k=>{o.bf.frame(k),this._frameRequest=null,this._render(k)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(k){this._showTileBoundaries!==k&&(this._showTileBoundaries=k,this._update())}get showPadding(){return!!this._showPadding}set showPadding(k){this._showPadding!==k&&(this._showPadding=k,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(k){this._showCollisionBoxes!==k&&(this._showCollisionBoxes=k,k?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(k){this._showOverdrawInspector!==k&&(this._showOverdrawInspector=k,this._update())}get repaint(){return!!this._repaint}set repaint(k){this._repaint!==k&&(this._repaint=k,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(k){this._vertices=k,this._update()}get version(){return Ry}getCameraTargetElevation(){return this.transform.elevation}},a.MapMouseEvent=qr,a.MapTouchEvent=ka,a.MapWheelEvent=Cy,a.Marker=Pu,a.NavigationControl=class{constructor(k){this._updateZoomButtons=()=>{const l=this._map.getZoom(),p=l===this._map.getMaxZoom(),b=l===this._map.getMinZoom();this._zoomInButton.disabled=p,this._zoomOutButton.disabled=b,this._zoomInButton.setAttribute("aria-disabled",p.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,p)=>{const b=this._map._getUIString(`NavigationControl.${p}`);l.title=b,l.setAttribute("aria-label",b)},this.options=o.e({},Xv,k),this._container=E.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})),E.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})),E.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=E.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(k){return this._map=k,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 Kv(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){E.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(k,l){const p=E.create("button",k,this._container);return p.type="button",p.addEventListener("click",l),p}},a.Popup=class extends o.E{constructor(k){super(),this.remove=()=>(this._content&&E.remove(this._content),this._container&&(E.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 p;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=E.create("div","maplibregl-popup",this._map.getContainer()),this._tip=E.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?qn(this._lngLat,this._flatPos,this._map.transform):(p=this._lngLat)===null||p===void 0?void 0:p.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=Nu(this.options.offset);if(!_){const P=this._container.offsetWidth,R=this._container.offsetHeight;let V;V=b.y+w.bottom.y<R?["top"]:b.y>this._map.transform.height-R?["bottom"]:[],b.x<P/2?V.push("left"):b.x>this._map.transform.width-P/2&&V.push("right"),_=V.length===0?"bottom":V.join("-")}let D=b.add(w[_]);this.options.subpixelPositioning||(D=D.round()),E.setTransform(this._container,`${Il[_]} translate(${D.x}px,${D.y}px)`),Iu(this._container,_,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(Dt),k)}addTo(k){return this._map&&this.remove(),this._map=k,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(k){return this._lngLat=o.N.convert(k),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(k){return this.setDOMContent(document.createTextNode(k))}setHTML(k){const l=document.createDocumentFragment(),p=document.createElement("body");let b;for(p.innerHTML=k;b=p.firstChild,b;)l.appendChild(b);return this.setDOMContent(l)}getMaxWidth(){var k;return(k=this._container)===null||k===void 0?void 0:k.style.maxWidth}setMaxWidth(k){return this.options.maxWidth=k,this._update(),this}setDOMContent(k){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=E.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(k),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(k){return this._container&&this._container.classList.add(k),this}removeClassName(k){return this._container&&this._container.classList.remove(k),this}setOffset(k){return this.options.offset=k,this._update(),this}toggleClassName(k){if(this._container)return this._container.classList.toggle(k)}setSubpixelPositioning(k){this.options.subpixelPositioning=k}_createCloseButton(){this.options.closeButton&&(this._closeButton=E.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const k=this._container.querySelector(Ru);k&&k.focus()}},a.RasterDEMTileSource=tt,a.RasterTileSource=Jt,a.ScaleControl=class{constructor(k){this._onMove=()=>{Wc(this._map,this._container,this.options)},this.setUnit=l=>{this.options.unit=l,Wc(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Zs),k)}getDefaultPosition(){return"bottom-left"}onAdd(k){return this._map=k,this._container=E.create("div","maplibregl-ctrl maplibregl-ctrl-scale",k.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){E.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},a.ScrollZoomHandler=Es,a.Style=su,a.TerrainControl=class{constructor(k){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=k}onAdd(k){return this._map=k,this._container=E.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=E.create("button","maplibregl-ctrl-terrain",this._container),E.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(){E.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},a.TwoFingersTouchPitchHandler=Cl,a.TwoFingersTouchRotateHandler=Zp,a.TwoFingersTouchZoomHandler=Gp,a.TwoFingersTouchZoomRotateHandler=Kp,a.VectorTileSource=Pi,a.VideoSource=ii,a.addSourceType=(k,l)=>o._(void 0,void 0,void 0,function*(){if(Ni(k))throw new Error(`A source type called "${k}" already exists.`);((p,b)=>{Ri[p]=b})(k,l)}),a.clearPrewarmedResources=function(){const k=Me;k&&(k.isPreloaded()&&k.numActive()===1?(k.release(Nn),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 oi().getRTLTextPluginStatus()},a.getVersion=function(){return sf},a.getWorkerCount=function(){return Ln.workerCount},a.getWorkerUrl=function(){return o.a.WORKER_URL},a.importScriptInWorkers=function(k){return Wt().broadcast("IS",k)},a.prewarm=function(){Ke().acquire(Nn)},a.setMaxParallelImageRequests=function(k){o.a.MAX_PARALLEL_IMAGE_REQUESTS=k},a.setRTLTextPlugin=function(k,l){return oi().setRTLTextPlugin(k,l)},a.setWorkerCount=function(k){Ln.workerCount=k},a.setWorkerUrl=function(k){o.a.WORKER_URL=k}});var s=n;return s})})(yE);var n5=yE.exports;const r5=t5(n5);function bE(t,e,n){if(t!==null)for(var r,i,s,a,o,f,g,y=0,v=0,E,T=t.type,M=T==="FeatureCollection",O=T==="Feature",B=M?t.features.length:1,F=0;F<B;F++){g=M?t.features[F].geometry:O?t.geometry:t,E=g?g.type==="GeometryCollection":!1,o=E?g.geometries.length:1;for(var Z=0;Z<o;Z++){var te=0,X=0;if(a=E?g.geometries[Z]:g,a!==null){f=a.coordinates;var Se=a.type;switch(y=0,Se){case null:break;case"Point":if(e(f,v,F,te,X)===!1)return!1;v++,te++;break;case"LineString":case"MultiPoint":for(r=0;r<f.length;r++){if(e(f[r],v,F,te,X)===!1)return!1;v++,Se==="MultiPoint"&&te++}Se==="LineString"&&te++;break;case"Polygon":case"MultiLineString":for(r=0;r<f.length;r++){for(i=0;i<f[r].length-y;i++){if(e(f[r][i],v,F,te,X)===!1)return!1;v++}Se==="MultiLineString"&&te++,Se==="Polygon"&&X++}Se==="Polygon"&&te++;break;case"MultiPolygon":for(r=0;r<f.length;r++){for(X=0,i=0;i<f[r].length;i++){for(s=0;s<f[r][i].length-y;s++){if(e(f[r][i][s],v,F,te,X)===!1)return!1;v++}X++}te++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(bE(a.geometries[r],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i5(t,e={}){if(t.bbox!=null&&e.recompute!==!0)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return bE(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 s5(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 _E(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}const o5={},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 l5(t,e,n,r,i,s){return h.openBlock(),h.createElementBlock("svg",a5,e[0]||(e[0]=[h.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),h.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),h.createElementVNode("path",{d:"M6 6l12 12"},null,-1)]))}const c5=Le(o5,[["render",l5]]);function d5(t){const e=[{type:"fill",minzoom:t.pointZoom||0,paint:{"fill-color":t.color||"#ccc","fill-outline-color":t.color||"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}}),e}function u5(t){return[{type:"line",paint:{"line-color":t.color||"#ccc","line-opacity":t.opacity||1}}]}function h5(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}}),e}function p5(t){if(!t)return null;const e=t.type||"point";return e==="polygon"?d5(t):e==="line"?u5(t):h5(t)}const f5=["#69D2E7","yellow","#FE4365","#125B9A","#41B3A2","#D7C3F1","#F1D3CE"],m5=["ma-star","ma-water","ma-swimming","fa-home","fa-search","fa-trash","fa-check"],xE={};function g5({style:t,colors:e,icons:n,map:r,id:i}){r.legend||Object.assign(r,{legend:{}}),window.map||(window.map=r),Object.assign(r.legend,{[i]:{colors:e,icons:n,color:t.color,type:t.type||"point"}})}async function md(t="pin4-sm-mi-plumber+f45942.png",e=null){if(xE[t])return null;xE[t]=!0;const n=await(e==null?void 0:e.loadImage(t!=null&&t.includes("/")?t:`${e.prefix||"/api"}/marker_icon/${t.replace(".png","")}.png`));return e==null||e.addImage(t,n.data),null}async function vE(t,e){const{data:n}=await qe.get(`/gis-layer/${t}/${e}`);return n.rows}async function pb(t,e,n){if(!t)return null;const r=JSON.parse(JSON.stringify(t)),i=r.colorAttr?await vE(e,r.colorAttr):null;i==null||i.forEach((a,o)=>{var f,g;a.color=a.color||((f=r.colorSet)==null?void 0:f[a.id])||((g=r.colorSet)==null?void 0:g[o])||f5[o],a.icon=r.icon?`${r.icon.split("+")[0]}+${a.color.replace("#","")}.png`:null});const s=r.iconAttr?await vE(e,r.iconAttr):null;if(s==null||s.forEach((a,o)=>{var E,T,M,O;const f=a.icon||((E=r.iconSet)==null?void 0:E[a.id])||((T=r.iconPattern)==null?void 0:T.replace("{id}",a.id))||((M=r.iconSet)==null?void 0:M[o])||(r.iconPrefix?null:m5[o]);if(!f)return;const g=a.color||((O=r.color)==null?void 0:O.replace("#",""))||"red",[y="pin6",v="m"]=r.icon?r.icon.split("-"):[];a.icon=r.iconPrefix||f!=null&&f.includes("/")?(r.iconPrefix||"")+f:`${y}-${v}-${f}+${g}.png`}),r.colorAttr&&i){const a=["match",["get",r.colorAttr]];i.forEach(o=>{a.push(o.id),a.push(o.color)}),a.push(r.color||"gray"),r.color=a}if(r.icon&&r.iconAttr&&s){const a=["match",["get",r.iconAttr]];s.filter(o=>o.icon).forEach(({id:o,icon:f})=>{if(r.colorAttr&&i){a.push(o);const g=["match",["get",r.colorAttr]];i.forEach(y=>{g.push(y.id);const v=`${f.split("+")[0]}+${y.color.replace("#","")}.png`;g.push(v),md(v,n)}),g.push(r.icon),a.push(g)}else a.push(o),a.push(f),md(f,n)}),a.push((r.iconPrefix||"")+r.icon),md((r.iconPrefix||"")+r.icon,n),r.icon=a}else if(r.icon&&r.colorAttr&&i){const a=["match",["get",r.colorAttr]];i.forEach(o=>{a.push(o.id),a.push(o.icon),md(o.icon,n)}),a.push(r.icon),md(r.icon,n),r.icon=a}else r.icon&&await md(r.icon,n);return g5({style:t,colors:i,icons:s,map:n,id:e}),p5(r)}const y5={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"))&&await 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)||(typeof t.bounds=="string"&&Object.assign(t,{bounds:t.bounds.split(",")}),await e.addSource(t.id,{type:"raster",tiles:[`${t==null?void 0:t.url}?dt=${new Date().toISOString().split("T")[0]}`],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{id:n}=t;e.getStyle().layers.forEach(async i=>{i.source===n&&await e.originalRemoveLayer(i.id)}),(await pb(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 s;const n=(t!=null&&t.url.includes("?")?"":"?1")+["clusterZoom","pointZoom"].filter(a=>{var o;return(o=t.style)==null?void 0:o[a]}).map(a=>`&${a}=${t.style[a]}`),r={type:"vector",tiles:[`${(s=t==null?void 0:t.url)!=null&&s.startsWith("http")?"":window.location.origin}${t==null?void 0:t.url}${n}`],minzoom:t.minzoom||5,maxzoom:t.maxzoom||24};e.addSource(t.id,r),(t.layers||await pb(t.style,t.source,e)||[]).forEach((a,o)=>{const f={...a,id:`${t.id}-${o}`,source:t.id,"source-layer":a["source-layer"]||t.source||t.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0};e.addLayer(f)})},async addGeoJsonLayer(t,e=this.map){var i;t!=null&&t.imported&&this.addAllGeometryLayers(t.id);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 pb(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)},addAllGeometryLayers(t){[{id:"points",type:"circle",geometry:"Point"},{id:"lines",type:"line",geometry:"LineString"},{id:"polygons",type:"fill",geometry:"Polygon"}].forEach(n=>{const r=`${t}-${n.id}`;this.map.getLayer(r)||this.map.addLayer({id:r,type:n.type,source:t,paint:this.getPaintProperties(n.type),filter:["==","$type",n.geometry]})})},getPaintProperties(t){return{circle:{"circle-radius":5,"circle-color":"#FF0000"},line:{"line-width":2,"line-color":"#0000FF"},fill:{"fill-color":"#00FF00","fill-opacity":.5}}[t]||{}},async removeLayer(t,e=this.map){e.getSource(t)&&(await e.getStyle().layers.forEach(async n=>{n.source===t&&await e.originalRemoveLayer(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==null?void 0:n.service)==="vtile"){await r.setTiles([`${window.location.origin}${n.url}${n.url.includes("?")?"&":"?"}filter=${e}${n.props?`&props=${n.props}`:""}`]);return}n==null||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.originalRemoveLayer(n.id)}),await e.removeSource(t),this.setVisible(t)}}},{Map:b5}=r5,Sr="widget-map-source",_5={mixins:[y5],props:{geometry:{type:Object,default:()=>null},zoom:{type:Number,default:50},height:{type:String,default:"400px"},layers:{type:Array,default:()=>[]}},computed:{settingLayers(){var t,e;return(e=(t=Cn==null?void 0:Cn.value)==null?void 0:t.geom)==null?void 0:e.layers}},data(){return{map:null,mapId:`gis-map-${Math.floor(Math.random()*1e3)}`,isOpen:!1,selectedBaseLayer:"topo100",isGeometryVisible:!0,localLayers:[],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"},{id:"gsv",name:"Google Street View",url:"https://mt2.google.com/vt/?lyrs=svv|cb_client:apiv3&style=50&x={x}&y={y}&z={z}",service:"TMS"}]}},async mounted(){this.localLayers=this.layers,this.initMap(),setTimeout(()=>{var t,e,n;(n=(e=(t=this.map.getStyle())==null?void 0:t.layers)==null?void 0:e.filter(r=>r.source==Sr))==null||n.forEach(r=>{this.map.moveLayer(r.id)})},300)},components:{IconClose:c5},watch:{geometry(){this.initGeometryLayer()},settingLayers(t){t&&!this.layers.length&&(this.localLayers=t)}},methods:{initMap(){const t={version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=new b5({container:this.mapId,style:t,center:[31.1656,48.3794],zoom:4,interactive:!0}),window==null||window.addEventListener("resize",()=>{this.map.resize()}),this.map.on("load",this.onMapLoad)},async onMapLoad(){this.map.resize(),this.changeBaseLayer(this.baseLayers[0]),this.geometry&&this.initGeometryLayer(),console.log(this.map.getStyle().layers.filter(t=>t.source==Sr))},changeBaseLayer(t){const e="base-layer",n="base-layer";if(!this.map.getSource(e))console.log("Adding new source and layer for base layer:",t.id),this.map.addSource(e,{type:"raster",tiles:[t.url],tileSize:256}),this.map.addLayer({id:n,type:"raster",source:e});else{console.log("Updating existing source for base layer:",t.id);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(Sr);if(this.zoomToGeometry(e),n){n.setData(e);return}t.addSource(Sr,{type:"geojson",data:e}),t.addLayer({id:`${Sr}-point`,type:"circle",source:Sr,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),t.addLayer({id:`${Sr}-polygon`,type:"fill",source:Sr,layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Sr}-polygon-line`,type:"line",source:Sr,layout:{},paint:{"line-color":"#0080ff","line-width":2},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Sr}-line`,type:"line",source:Sr,layout:{},paint:{"line-color":"#0080ff","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(t){let e=t;const n=t==null?void 0:t.type;if(Array.isArray(t))return _E(t);if(!n)throw new Error("Unknown geometry type!");return n==="FeatureCollection"?t:(n==="Feature"&&(e=[t]),!["FeatureCollection","Feature"].includes(n)&&(e=[s5(t)]),_E(e))},zoomToGeometry(t){const{map:e}=this,n=i5(t);e.fitBounds(n,{zoom:this.zoom,padding:30,duration:0})},toggleGeometryVisibility(){[`${Sr}-polygon`,`${Sr}-polygon-line`,`${Sr}-line`,`${Sr}-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),[`${Sr}-polygon`,`${Sr}-polygon-line`,`${Sr}-line`,`${Sr}-point`].forEach(r=>{this.map.getLayer(r)&&(console.log("layerId",r),this.map.moveLayer(r))})}}},x5={class:"relative"},v5={key:1,class:"bg-white absolute top-[10px] right-[10px] z-20 border rounded-lg cursor-pointer"},w5={class:"flex items-center justify-between p-2 border-b"},k5={class:"flex items-center"},E5=["value","onChange"],S5={class:"ml-2"},C5={key:0,class:"p-2 border-b"},T5={class:"flex items-center"},A5=["value","onChange"],M5={class:"ml-2"},D5={key:1,class:"p-2"},I5={class:"flex items-center"},P5=["id"];function R5(t,e,n,r,i,s){var o;const a=h.resolveComponent("IconClose");return h.openBlock(),h.createElementBlock("div",x5,[i.isOpen?(h.openBlock(),h.createElementBlock("div",v5,[h.createElementVNode("div",w5,[e[6]||(e[6]=h.createElementVNode("div",null,"Шари",-1)),h.createVNode(a,{onClick:e[1]||(e[1]=f=>i.isOpen=!1),class:"w-4 h-4"})]),h.createElementVNode("div",{class:h.normalizeClass(["p-2",{"border-b":n.geometry}])},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(i.baseLayers,f=>(h.openBlock(),h.createElementBlock("div",{key:f.id,class:"mb-2"},[h.createElementVNode("label",k5,[h.withDirectives(h.createElementVNode("input",{type:"radio",name:"base-layer",value:f.id,"onUpdate:modelValue":e[2]||(e[2]=g=>i.selectedBaseLayer=g),onChange:g=>s.changeBaseLayer(f)},null,40,E5),[[h.vModelRadio,i.selectedBaseLayer]]),h.createElementVNode("span",S5,h.toDisplayString(f.name),1)])]))),128))],2),(o=i.localLayers)!=null&&o.length?(h.openBlock(),h.createElementBlock("div",C5,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(i.localLayers,f=>(h.openBlock(),h.createElementBlock("div",{key:f.id},[h.createElementVNode("label",T5,[h.withDirectives(h.createElementVNode("input",{type:"checkbox",value:f.id,"onUpdate:modelValue":e[3]||(e[3]=g=>i.selectedLayers=g),onChange:g=>s.setLayerVisible(f,g.target.checked)},null,40,A5),[[h.vModelCheckbox,i.selectedLayers]]),h.createElementVNode("span",M5,h.toDisplayString(f.name),1)])]))),128))])):h.createCommentVNode("",!0),n.geometry?(h.openBlock(),h.createElementBlock("div",D5,[h.createElementVNode("label",I5,[h.withDirectives(h.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":e[4]||(e[4]=f=>i.isGeometryVisible=f),onChange:e[5]||(e[5]=(...f)=>s.toggleGeometryVisibility&&s.toggleGeometryVisibility(...f))},null,544),[[h.vModelCheckbox,i.isGeometryVisible]]),e[7]||(e[7]=h.createElementVNode("span",{class:"ml-2"},"Показати геометрію",-1))])])):h.createCommentVNode("",!0)])):(h.openBlock(),h.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]=f=>i.isOpen=!0)}," Шари ")),h.createElementVNode("div",{id:i.mapId,style:h.normalizeStyle({height:n.height})},null,12,P5)])}const fb=Le(_5,[["render",R5]]),ht=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),mb=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},am=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(mb(t)?t:am(t.parentElement,e))},xo=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},gb=t=>`${t||""}`.split(" ").filter(e=>!!e),vo=(t,e,n)=>{t&&gb(e).forEach(r=>{t.classList.toggle(r,n||!1)})};let gd=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 yd={passive:!1};let N5=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,yd),this.element.addEventListener("touchstart",this.onTouchStart,yd),this.element.addEventListener("touchmove",this.onMove,yd),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(e){if(!e.buttons||e.button!==0)return;const n=new gd(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 gd(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 gd(s)):[new gd(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 gd(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 gd(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,yd),this.element.removeEventListener("touchstart",this.onTouchStart,yd),this.element.removeEventListener("touchmove",this.onMove,yd),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 wE(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function kE(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const yb=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.prototype.toString.call(t)==="[object Object]",Yi=(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}),yb(a)?Object.assign(t[s],Yi(o,a)):Array.isArray(a)?Object.assign(t,{[s]:[...a]}):Object.assign(t,{[s]:a})})}return t},bb=function(t,e){return t.split(".").reduce((n,r)=>typeof n=="object"?n[r]:void 0,e)};let lm=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?Yi({},this.constructor.defaults,e):{};for(const[n,r]of Object.entries(this.option("on")||{}))this.on(n,r)}option(e,...n){let r=bb(e,this.options);return r&&typeof r=="function"&&(r=r.call(this,this,...n)),r}optionFor(e,n,r,...i){let s=bb(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=bb(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(lm,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(lm,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});let _b=class extends lm{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 Vn;(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"})(Vn||(Vn={}));const Qo=["a","b","c","d","e","f"],EE={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"},O5={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:EE},SE='<circle cx="25" cy="25" r="20"></circle>',xb='<div class="f-spinner"><svg viewBox="0 0 50 50">'+SE+SE+"</svg></div>",Zi=t=>t&&t!==null&&t instanceof Element&&"nodeType"in t,Rn=(t,e)=>{t&&gb(e).forEach(n=>{t.classList.remove(n)})},It=(t,e)=>{t&&gb(e).forEach(n=>{t.classList.add(n)})},cm={a:1,b:0,c:0,d:1,e:0,f:0},B5=1e5,dm=1e4,Os="mousemove",CE="drag",TE="content",Bs="auto";let vb=null,wb=null,bd=class QP extends _b{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return wb===null&&(wb=window.matchMedia("(hover: none)").matches),wb}get isMobile(){return vb===null&&(vb=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),vb}get panMode(){return this.options.panMode!==Os||this.isTouchDevice?CE:Os}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===Bs?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 Qo){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:Vn.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({},cm)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},cm)}),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({},QP.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=xo(xb);!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(TE);let r=this.option(TE)||e.querySelector(`.${n}`);if(r||(r=e.querySelector("img,picture")||e.firstElementChild,r&&It(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===Vn.Init?this.enable():this.updateMetrics()}onError(){this.state!==Vn.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=Vn.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 f=[1,n,s].sort((y,v)=>y-v),g=f.findIndex(y=>y>r+1e-5);o=f[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 N5(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(Os,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(Os,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 Qo)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 Qo)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:f}=a,g=o.min,y=o.max,v=f.min,E=f.max;let T=0,M=0;return g!==1/0&&i<g?T=g-i:y!==1/0&&i>y&&(T=y-i),v!==1/0&&s<v?M=v-s:E!==1/0&&s>E&&(M=E-s),Math.abs(T)<1e-4&&(T=0),Math.abs(M)<1e-4&&(M=0),Object.assign(Object.assign({},a),{xDiff:T,yDiff:M,inBounds:!T&&!M})}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 f=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,E=y?o:s,T=this.getMatrix(e),M=new DOMPoint(0,0).matrixTransform(T),O=new DOMPoint(0+v,0).matrixTransform(T),B=new DOMPoint(0+v,0+E).matrixTransform(T),F=new DOMPoint(0,0+E).matrixTransform(T),Z=Math.abs(B.x-M.x),te=Math.abs(B.y-M.y),X=Math.abs(F.x-O.x),Se=Math.abs(F.y-O.y);f=Math.max(Z,X),g=Math.max(te,Se)}return{contentWidth:f,contentHeight:g}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===Os||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,f=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*f<=0?f+=.14*s:(f=.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&&(f=Math.max(Math.min(f,a),-1*a))):this.isBouncingY=!1,this.isBouncingX&&(this.velocity.e=o),this.isBouncingY&&(this.velocity.f=f)}enable(){const{content:e}=this,n=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const r of Qo)this.current[r]=this.target[r]=n[r];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=Vn.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&&Zi(a)?a.dataset:null;if(o){const T=o.panzoomChange,M=o.panzoomAction;if((T||M)&&e.preventDefault(),T){let O={};try{O=JSON.parse(T)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(O)}if(M)return void(this[M]&&this[M]())}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 f=this.content.getBoundingClientRect(),g=this.dragStart;if(g.time&&!this.canZoomOut()&&(Math.abs(f.x-g.x)>2||Math.abs(f.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),E=this.option("dblClick",e);E?(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(E)),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===Os&&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&&ht(this.targetScale)<=ht(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(n[0]);const{content:i}=this,s=kE(r[0],r[1]),a=kE(n[0],n[1]);let o=0,f=0;if(n.length>1){const te=i.getBoundingClientRect();o=s.clientX-te.left-.5*te.width,f=s.clientY-te.top-.5*te.height}const g=wE(r[0],r[1]),y=wE(n[0],n[1]);let v=g?y/g:1,E=a.clientX-s.clientX,T=a.clientY-s.clientY;this.dragOffset.x+=E,this.dragOffset.y+=T,this.dragOffset.time=Date.now()-this.dragStart.time;let M=ht(this.targetScale)===ht(this.minScale)&&this.option("lockAxis");if(M&&!this.lockedAxis)if(M==="xy"||M==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const te=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=te>45&&te<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,E=0,T=0}else this.lockedAxis=M;if(am(e.target,this.content)&&(M="x",this.dragOffset.y=0),M&&M!=="xy"&&this.lockedAxis!==M&&ht(this.targetScale)===ht(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const O=this.checkBounds(E,T);this.option("rubberband")?(this.isInfinite!=="x"&&(O.xDiff>0&&E<0||O.xDiff<0&&E>0)&&(E*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*O.xDiff))),this.isInfinite!=="y"&&(O.yDiff>0&&T<0||O.yDiff<0&&T>0)&&(T*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*O.yDiff)))):(O.xDiff&&(E=0),O.yDiff&&(T=0));const B=this.targetScale,F=this.minScale,Z=this.maxScale;B<.5*F&&(v=Math.max(v,F)),B>1.5*Z&&(v=Math.min(v,Z)),this.lockedAxis==="y"&&ht(B)===ht(F)&&(E=0),this.lockedAxis==="x"&&ht(B)===ht(F)&&(T=0),this.applyChange({originX:o,originY:f,panX:E,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=[]),am(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==Vn.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 te of Qo)this.velocity[te]=0;this.target.e=this.current.e,this.target.f=this.current.f,Rn(this.container,"is-scaling"),Rn(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:r}=this,i=r[0],s=r[r.length-1];let a=0,o=0,f=0;s&&i&&(a=s.clientX-i.clientX,o=s.clientY-i.clientY,f=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,E=0,T=0,M=this.option("decelFriction");const O=this.targetScale;if(f>0){E=Math.abs(a)>3?a/(f/30):0,T=Math.abs(o)>3?o/(f/30):0;const te=this.option("maxVelocity");te&&(E=Math.max(Math.min(E,te),-1*te),T=Math.max(Math.min(T,te),-1*te))}E&&(y=E/(1/(1-M)-1)),T&&(v=T/(1/(1-M)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&ht(O)===this.minScale)&&(y=E=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&ht(O)===this.minScale)&&(v=T=0);const B=this.dragOffset.x,F=this.dragOffset.y,Z=this.option("dragMinThreshold")||0;Math.abs(B)<Z&&Math.abs(F)<Z&&(y=v=0,E=T=0),(this.option("zoom")&&(O<this.minScale-1e-5||O>this.maxScale+1e-5)||n&&!y&&!v)&&(M=.35),this.applyChange({panX:y,panY:v,friction:M}),this.emit("decel",E,T,B,F)}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===Os||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({},cm);for(const B of Qo){const F=B=="e"||B==="f"?dm:B5;s[B]=ht(e[B],F),Math.abs(n[B]-e[B])<(B=="e"||B==="f"?.51:.001)&&(e[B]=n[B])}let{a,b:o,c:f,d:g,e:y,f:v}=s,E=`matrix(${a}, ${o}, ${f}, ${g}, ${y}, ${v})`,T=r.parentElement instanceof HTMLPictureElement?r.parentElement:r;if(this.option("transformParent")&&(T=T.parentElement||T),T.style.transform===E)return;T.style.transform=E;const{contentWidth:M,contentHeight:O}=this.calculateContentDim();i.width=M,i.height=O,this.emit("afterTransform")}updateMetrics(e=!1){var n;if(!this||this.state===Vn.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(),f=getComputedStyle(this.container);let g=o.width*r,y=o.height*r;const v=parseFloat(f.paddingTop)+parseFloat(f.paddingBottom),E=g-(parseFloat(f.paddingLeft)+parseFloat(f.paddingRight)),T=y-v;this.containerRect={width:g,height:y,innerWidth:E,innerHeight:T};const M=parseFloat(s.dataset.width||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalWidth:rt instanceof SVGElement?rt.width.baseVal.value:Math.max(rt.offsetWidth,rt.scrollWidth),Tt||0})(s),O=parseFloat(s.dataset.height||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalHeight:rt instanceof SVGElement?rt.height.baseVal.value:Math.max(rt.offsetHeight,rt.scrollHeight),Tt||0})(s);let B=this.option("width",M)||Bs,F=this.option("height",O)||Bs;const Z=B===Bs,te=F===Bs;typeof B!="number"&&(B=M),typeof F!="number"&&(F=O),Z&&(B=M*(F/O)),te&&(F=O/(M/B));let X=s.parentElement instanceof HTMLPictureElement?s.parentElement:s;this.option("transformParent")&&(X=X.parentElement||X);const Se=X.getAttribute("style")||"";X.style.setProperty("transform","none","important"),a&&(X.style.width="",X.style.height=""),X.offsetHeight;const ge=s.getBoundingClientRect();let Te=ge.width*r,Ne=ge.height*r,se=Te,lt=Ne;Te=Math.min(Te,B),Ne=Math.min(Ne,F),a?{width:Te,height:Ne}=((rt,Tt,jt,Ut)=>{const Ot=jt/rt,Ht=Ut/Tt,ln=Math.min(Ot,Ht);return{width:rt*=ln,height:Tt*=ln}})(B,F,Te,Ne):(Te=Math.min(Te,B),Ne=Math.min(Ne,F));let Qe=.5*(lt-Ne),gt=.5*(se-Te);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:ge.top-o.top+Qe,bottom:o.bottom-ge.bottom+Qe,left:ge.left-o.left+gt,right:o.right-ge.right+gt,fitWidth:Te,fitHeight:Ne,width:Te,height:Ne,fullWidth:B,fullHeight:F}),X.style.cssText=Se,a&&(X.style.width=`${Te}px`,X.style.height=`${Ne}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(ht(this.targetScale)<ht(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===Vn.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,f=0,g=0,y=0;const v=this.option("infinite");if(v===!0||i&&v===i)o=-1/0,g=1/0,f=-1/0,y=1/0;else{let{containerRect:E,contentRect:T}=this,M=ht(s*r,dm),O=ht(a*r,dm),{innerWidth:B,innerHeight:F}=E;if(E.width===M&&(B=E.width),E.width===O&&(F=E.height),e>B){g=.5*(e-B),o=-1*g;let Z=.5*(T.right-T.left);o+=Z,g+=Z}if(s>B&&e<B&&(o-=.5*(s-B),g-=.5*(s-B)),n>F){y=.5*(n-F),f=-1*y;let Z=.5*(T.bottom-T.top);f+=Z,y+=Z}a>F&&n<F&&(o-=.5*(a-F),g-=.5*(a-F))}return{x:{min:o,max:g},y:{min:f,max:y}}}getBounds(){const e=this.option("bounds");return e!==Bs?e:this.calculateBounds()}updateControls(){const e=this,n=e.container,{panMode:r,contentRect:i,targetScale:s,minScale:a}=e;let o=a,f=e.option("click")||!1;f&&(o=e.getNextScale(f));let g=e.canZoomIn(),y=e.canZoomOut(),v=r===CE&&!!this.option("touch"),E=y&&v;if(v&&(ht(s)<ht(a)&&!this.panOnlyZoomed&&(E=!0),(ht(i.width,1)>ht(i.fitWidth,1)||ht(i.height,1)>ht(i.fitHeight,1))&&(E=!0)),ht(i.width*s,1)<ht(i.fitWidth,1)&&(E=!1),r===Os&&(E=!1),vo(n,this.cn("isDraggable"),E),!this.option("zoom"))return;let T=g&&ht(o)>ht(s),M=!T&&!E&&y&&ht(o)<ht(s);vo(n,this.cn("canZoomIn"),T),vo(n,this.cn("canZoomOut"),M);for(const O of n.querySelectorAll("[data-panzoom-action]")){let B=!1,F=!1;switch(O.dataset.panzoomAction){case"zoomIn":g?B=!0:F=!0;break;case"zoomOut":y?B=!0:F=!0;break;case"toggleZoom":case"iterateZoom":g||y?B=!0:F=!0;const Z=O.querySelector("g");Z&&(Z.style.display=g?"":"none")}B?(O.removeAttribute("disabled"),O.removeAttribute("tabindex")):F&&(O.setAttribute("disabled",""),O.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:f=!1,flipY:g=!1,ignoreBounds:y=!1}){this.state!==Vn.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:f,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:f=!1,flipY:g=!1,ignoreBounds:y=!1,bounce:v=this.option("bounce")}){const E=this.state;if(E===Vn.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=o||0,this.ignoreBounds=y;const{current:T}=this,M=T.e,O=T.f,B=this.getMatrix(this.target);let F=new DOMMatrix().translate(M,O).translate(s,a).translate(e,n);if(this.option("zoom")){if(!y){const Z=this.targetScale,te=this.minScale,X=this.maxScale;Z*r<te&&(r=te/Z),Z*r>X&&(r=X/Z)}F=F.scale(r)}F=F.translate(-s,-a).translate(-M,-O).multiply(B),i&&(F=F.rotate(i)),f&&(F=F.scale(-1,1)),g&&(F=F.scale(1,-1));for(const Z of Qo)Z!=="e"&&Z!=="f"&&(F[Z]>this.minScale+1e-5||F[Z]<this.minScale-1e-5)?this.target[Z]=F[Z]:this.target[Z]=ht(F[Z],dm);(this.targetScale<this.scale||Math.abs(r-1)>.1||this.panMode===Os||v===!1)&&!y&&this.clampTargetBounds(),E===Vn.Init?this.animate():this.isResting||(this.state=Vn.Panning,this.requestTick())}stop(e=!1){if(this.state===Vn.Init||this.state===Vn.Destroy)return;const n=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const r of Qo)this.velocity[r]=0,e==="current"?this.current[r]=this.target[r]:e==="target"&&(this.target[r]=this.current[r]);this.setTransform(),Rn(this.container,"is-scaling"),Rn(this.container,"is-animating"),this.isTicking=!1,this.state=Vn.Ready,n&&(this.emit("endAnimation"),this.updateControls())}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),It(this.container,"is-animating"),this.isScaling&&It(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!==Os||!e||ht(this.targetScale)<=ht(this.minScale))return;this.emit("mouseMove",e);const{container:r,containerRect:i,contentRect:s}=this,a=i.width,o=i.height,f=r.getBoundingClientRect(),g=(e.clientX||0)-f.left,y=(e.clientY||0)-f.top;let{contentWidth:v,contentHeight:E}=this.calculateContentDim(this.target);const T=this.option("mouseMoveFactor");T>1&&(v!==a&&(v*=T),E!==o&&(E*=T));let M=.5*(v-a)-g/a*100/100*(v-a);M+=.5*(s.right-s.left);let O=.5*(E-o)-y/o*100/100*(E-o);O+=.5*(s.bottom-s.top),this.applyChange({panX:M-this.target.e,panY:O-this.target.f,friction:n})}zoomWithWheel(e){if(this.state===Vn.Destroy||this.state===Vn.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 f=s*(100+45*i)/100;ht(f)<ht(o)&&ht(s)<=ht(o)?(this.cwd+=Math.abs(i),f=o):ht(f)>ht(a)&&ht(s)>=ht(a)?(this.cwd+=Math.abs(i),f=a):(this.cwd=0,f=Math.max(Math.min(f,a),o)),this.cwd>this.option("wheelLimit")||(e.preventDefault(),ht(f)!==ht(s)&&this.zoomTo(f,{event:e}))}canZoomIn(){return this.option("zoom")&&(ht(this.contentRect.width,1)<ht(this.contentRect.fitWidth,1)||ht(this.targetScale)<ht(this.maxScale))}canZoomOut(){return this.option("zoom")&&ht(this.targetScale)>ht(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=Bs,originX:r=Bs,originY:i=Bs,event:s}={}){if(this.isContentLoading||this.state===Vn.Destroy)return;const{targetScale:a,fullScale:o,maxScale:f,coverScale:g}=this;if(this.stop(),this.panMode===Os&&(s=this.pmme||s),s||r===Bs||i===Bs){const v=this.content.getBoundingClientRect(),E=this.container.getBoundingClientRect(),T=s?s.clientX:E.left+.5*E.width,M=s?s.clientY:E.top+.5*E.height;r=T-v.left-.5*v.width,i=M-v.top-.5*v.height}let y=1;typeof e=="number"?y=e:e==="full"?y=o:e==="cover"?y=g:e==="max"?y=f:e==="fit"?y=1:e==="next"&&(y=this.getNextScale("iterateZoom")),y=y/a||1,n=n===Bs?y>1?.15:.25:n,this.applyChange({scale:y,originX:r,originY:i,friction:n}),s&&this.panMode===Os&&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!==Vn.Init&&this.state!==Vn.Destroy){this.stop("current");for(const n of Qo)this.target[n]=cm[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=Vn.Panning,this.requestTick())}}destroy(){this.stop(),this.state=Vn.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(bd,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:O5}),Object.defineProperty(bd,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const AE=function(t,e){let n=!0;return(...r)=>{n&&(n=!1,t(...r),setTimeout(()=>{n=!0},e))}},ME=(t,e)=>{let n=[];return t.childNodes.forEach(r=>{r.nodeType!==Node.ELEMENT_NODE||e&&!r.matches(e)||n.push(r)}),n},z5={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 Cr;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"})(Cr||(Cr={}));const kb=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)},V5=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);let io=class extends lm{constructor(e,n){super(n),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}};const L5={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 DE=class extends io{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"),It(e,this.cn("list")),e.setAttribute("role","tablist");const n=this.instance.container;n.appendChild(e),It(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 f=this.build();if(vo(f,this.cn("isDynamic"),!!a),o)for(let v=0;v<n;v++)f.append(this.createItem(v));let g,y=0;for(const v of[...f.children]){const E=y===this.instance.page;E&&(g=v),vo(v,this.cn("isCurrent"),E),(e=v.children[0])===null||e===void 0||e.setAttribute("aria-selected",E?"true":"false");for(const T of["isBeforePrev","isPrev","isNext","isAfterNext"])Rn(v,this.cn(T));y++}if(g=g||f.firstChild,a&&g){const v=g.previousElementSibling,E=v&&v.previousElementSibling;It(v,this.cn("isPrev")),It(E,this.cn("isBeforePrev"));const T=g.nextElementSibling,M=T&&T.nextElementSibling;It(T,this.cn("isNext")),It(M,this.cn("isAfterNext"))}this.isDynamic=a}createItem(e=0){var n;const r=document.createElement("li");r.setAttribute("role","presentation");const i=xo(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,Rn(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(DE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:L5});const um="disabled",hm="next",IE="prev";let PE=class extends io{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(um),s.removeAttribute(um),e.isInfinite||(r<=0&&i.setAttribute(um,""),r>=n-1&&s.setAttribute(um,"")))}addBtn(e){var n;const r=this.instance,i=document.createElement("button");i.setAttribute("tabindex","0"),i.setAttribute("title",r.localize(`{{${e.toUpperCase()}}}`)),It(i,this.cn("button")+" "+this.cn(e===hm?"isNext":"isPrev"));const s=r.isRTL?e===hm?IE:hm: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"),It(r,n),e.appendChild(r)),this.container=r,s||(s=r.querySelector("[data-carousel-next]")),s||(s=this.addBtn(hm)),this.next=s,i||(i=r.querySelector("[data-carousel-prev]")),i||(i=this.addBtn(IE)),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(PE,"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 RE=class extends io{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===Cr.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),n.state===Cr.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:f}=this;if(!o||!f||!a)return;const g=a.closest("[data-index]");if(r.stopPropagation(),r.preventDefault(),!g)return;const y=parseInt(g.dataset.index||"",10)||0,v=f.getPageForSlide(y),E=o.getPageForSlide(y);o.slideTo(E),f.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!==Cr.Ready||r.state!==Cr.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===Cr.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(RE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const F5={Navigation:PE,Dots:DE,Sync:RE},pm="animationend",NE="isSelected",fm="slide";let bh=class $1 extends _b{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===Cr.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:Cr.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||!Zi(e))throw new Error("No Element found");this.container=e,this.slideNext=AE(this.slideNext.bind(this),150),this.slidePrev=AE(this.slidePrev.bind(this),150),this.userOptions=n,this.userPlugins=r,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,n;const r=Yi({},$1.defaults,this.userOptions);let i="";const s=r.breakpoints;if(s&&yb(s))for(const[a,o]of Object.entries(s))window.matchMedia(a).matches&&yb(o)&&(i+=a,Yi(r,o));i===this.bp&&this.state!==Cr.Init||(this.bp=i,this.state===Cr.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!==Cr.Init&&this.destroy(),super.setOptions(r),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=Cr.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},$1.Plugins),this.userPlugins)),this.emit("attachPlugins"),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=Cr.Ready,this.emit("ready")}initLayout(){const{container:e}=this,n=this.option("classes");It(e,this.cn("container")),vo(e,n.isLTR,!this.isRTL),vo(e,n.isRTL,this.isRTL),vo(e,n.isVertical,!this.isHorizontal),vo(e,n.isHorizontal,this.isHorizontal);let r=this.option("viewport")||e.querySelector(`.${n.viewport}`);r||(r=document.createElement("div"),It(r,n.viewport),r.append(...ME(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"),It(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=[];[...ME(e,`.${this.cn(fm)}`)].forEach(i=>{if(Zi(i)){const s=kb({el:i,isDom:!0,index:this.slides.length});r.push(s)}});for(let i of[...this.option("slides",[])||[],...n])r.push(kb(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 bd(this.viewport,Yi({},{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 f of this.slides)(!e.length||a+f.dim-r>.05||o>=i)&&(e.push(V5()),s=e.length-1,a=0,o=0),e[s].slides.push(f),a+=f.dim+f.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 E;y.index=v,y.pos=((E=y.slides[0])===null||E===void 0?void 0:E.pos)||0,y.dim=0;for(const[T,M]of y.slides.entries())y.dim+=M.dim,T<y.slides.length-1&&(y.dim+=M.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=ht(y.pos,1e3),y.dim=ht(y.dim,1e3),Math.abs(y.pos)<=.1&&(y.pos=0)}),i)return e;const f=[];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=f.length,g=v,f.push(v))}),f}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 f=!(!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)),It(o,this.cn(fm)+" "+e.class+" "+e.customClass),s)o.style[i]=`${s}px`,o.style[i==="width"?"height":"width"]="";else{f&&(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,f?(r=o.parentElement)===null||r===void 0||r.removeChild(o):e.el||o.remove(),{dim:ht(s,1e3),gap:ht(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:f,pages:g,slides:y,panzoom:v}=this,E=0,T=0,M=0,O=0;v?O=-1*v.current[this.axis]:g[f]&&(O=g[f].pos||0),e=n?r?"right":"left":"top",r&&n&&(O*=-1);for(const te of y){const X=te.el;X?(e==="top"?(X.style.right="",X.style.left=""):X.style.top="",te.index!==E?X.style[e]=T===0?"":`${ht(T,1e3)}px`:X.style[e]="",M+=te.dim+te.gap,E++):T+=te.dim+te.gap}if(i&&M&&s){let te=getComputedStyle(s),X="padding",Se=n?"Right":"Bottom",ge=parseFloat(te[X+(n?"Left":"Top")]);O-=ge,a+=ge,a+=parseFloat(te[X+Se]);for(const Te of y)Te.el&&(ht(Te.pos)<ht(a)&&ht(Te.pos+Te.dim+Te.gap)<ht(O)&&ht(O)>ht(o-a)&&(Te.el.style[e]=`${ht(T+M,1e3)}px`),ht(Te.pos+Te.gap)>=ht(o-a)&&ht(Te.pos)>ht(O+a)&&ht(O)<ht(a)&&(Te.el.style[e]=`-${ht(M,1e3)}px`))}let B,F,Z=[...this.inTransition];if(Z.length>1&&(B=g[Z[0]],F=g[Z[1]]),B&&F){let te=0;for(const X of y)X.el?this.inTransition.has(X.index)&&B.slides.indexOf(X)<0&&(X.el.style[e]=`${ht(te+(B.pos-F.pos),1e3)}px`):te+=X.dim+X.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");It(i,this.cn(fm)),It(i,e.class),It(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 f=null;a.length&&(f=r[a.reduce((y,v)=>Math.abs(v-o)<Math.abs(y-o)?v:y)]);const g=f&&f.el&&f.el.parentNode?f.index<e.index?f.el.nextSibling:f.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(NE);if(r.classList.contains(i)&&(Rn(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(pm);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:f,panzoom:g}=this;e=parseInt((e||0).toString())||0;const y=this.getPageFromIndex(e);if(!g||!f[y]||f.length<2||Math.abs((((i=(r=f[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===f.length-1&&(v=-1),o===f.length-1&&e===0&&(v=1));const E=f[y].pos*(this.isRTL?1:-1);if(o===y&&Math.abs(E-g.target[this.axis])<1)return!1;this.clearTransitions();const T=g.isResting;It(this.container,this.cn("inTransition"));const M=((s=f[o])===null||s===void 0?void 0:s.slides[0])||null,O=((a=f[y])===null||a===void 0?void 0:a.slides[0])||null;this.inTransition.add(O.index),this.createSlideEl(O);let B=M.el,F=O.el;T||n===fm||(n="fadeFast",B=null);const Z=this.isRTL?"next":"prev",te=this.isRTL?"prev":"next";return B&&(this.inTransition.add(M.index),M.transition=n,B.addEventListener(pm,this.onAnimationEnd),B.classList.add(`f-${n}Out`,`to-${v>0?te:Z}`)),F&&(O.transition=n,F.addEventListener(pm,this.onAnimationEnd),F.classList.add(`f-${n}In`,`from-${v>0?Z:te}`)),g.current[this.axis]=E,g.target[this.axis]=E,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(NE);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)||(It(i,n),this.emit("selectSlide",r)),i.removeAttribute(e)):(i.classList.contains(n)&&(Rn(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 f=o.current[e],g=o.target[e]-f,y=0,v=.5*s;i&&n?(f<-v&&(y=-1,f+=a),f>a-v&&(y=1,f-=a)):(f>v&&(y=1,f-=a),f<-a+v&&(y=-1,f+=a)),y&&(o.current[e]=f,o.target[e]=f+g)}lazyLoadImg(e,n){const r=this,i="f-fadeIn",s="is-preloading";let a=!1,o=null;const f=()=>{a||(a=!0,o&&(o.remove(),o=null),Rn(n,s),n.complete&&(It(n,i),setTimeout(()=>{Rn(n,i)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(r.updateMetrics(),r.setViewportHeight()),this.emit("load",e))};It(n,s),n.src=n.dataset.lazySrcset||n.dataset.lazySrc||"",delete n.dataset.lazySrc,delete n.dataset.lazySrcset,n.addEventListener("error",()=>{f()}),n.addEventListener("load",()=>{f()}),setTimeout(()=>{const g=n.parentNode;g&&e.el&&(n.complete?f():a||(o=xo(xb),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:f,pages:g}=this,y=g.length,v=Math.abs(Math.atan2(r,n)/(Math.PI/180));let E=0;if(E=v>45&&v<135?o?0:r:o?n:0,!y)return;let T=this.page,M=a&&o?1:-1;const O=e.current[f]*M;let{pageIndex:B}=this.getPageFromPosition(O);Math.abs(E)>5?(g[T].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(T=B),T=a&&o?E<0?T-1:T+1:E<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&&Zi(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=Cr.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===Cr.Destroy)return;e=parseInt((e||0).toString())||0;const i=this.getPageFromIndex(e),{axis:s,isHorizontal:a,isRTL:o,pages:f,panzoom:g}=this,y=f.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 E=f[i].pos;if(this.isInfinite){const T=this.contentDim,M=g.target[s]*v;y===2?E+=T*Math.floor(parseFloat(e+"")/2):E=[E,E-T,E+T].reduce(function(O,B){return Math.abs(B-M)<Math.abs(O-M)?B:O})}E*=v,Math.abs(g.target[s]-E)<1||(g.panTo({x:a?E:0,y:a?0:E,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(),Rn(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(pm,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,f=((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 E=[];for(const T of v)E.push(kb(T));this.slides.splice(e,0,...E);for(let T=0;T<this.slides.length;T++)this.slides[T].index=T;for(const T of E)this.emit("beforeInitSlide",T,T.index);if(this.page>=e&&(this.page+=E.length),this.updateMetrics(),o){const T=((s=this.pages[this.page])===null||s===void 0?void 0:s.pos)||0,M=((a=this.pages[this.page])===null||a===void 0?void 0:a.dim)||0,O=this.pages.length||1,B=this.isRTL?g-M:M-g,F=this.isRTL?f-T:T-f;y&&O===1?(e<=this.page&&(o.current[this.axis]-=B,o.target[this.axis]-=B),o.panTo({[this.isHorizontal?"x":"y"]:-1*T})):F&&e<=this.page&&(o.target[this.axis]-=F,o.current[this.axis]-=F,o.requestTick())}for(const T of E)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",f=s?"offsetWidth":"offsetHeight";if(n){let v=Math.max(n[f],ht(n.getBoundingClientRect()[o],1e3)),E=getComputedStyle(n),T="padding",M=s?"Right":"Bottom";v-=parseFloat(E[T+(s?"Left":"Top")])+parseFloat(E[T+M]),this.viewportDim=v}let g,y=0;for(const[v,E]of i.entries()){let T=0,M=0;!E.el&&g?(T=g.dim,M=g.gap):({dim:T,gap:M}=this.getSlideMetrics(E),g=E),T=ht(T,1e3),M=ht(M,1e3),E.dim=T,E.gap=M,E.pos=y,y+=T,(a||v<i.length-1)&&(y+=M)}y=ht(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===Cr.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 f=-1*s.current.e,g=ht((f-o.pos)/(1*o.dim),1e3),y=g,v=g;this.isInfinite&&r!==!0&&(y=ht((f-o.pos+a)/(1*o.dim),1e3),v=ht((f-o.pos-a)/(1*o.dim),1e3));let E=[g,y,v].reduce(function(T,M){return Math.abs(M)<Math.abs(T)?M:T});return n?E:E>1?1:E<-1?-1:E}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:f}=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!==Vn.Init&&i.state!==Vn.Destroy?-1*i.current[this.axis]:o[f]&&o[f].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),E=this.isInfinite?[-1,0,1]:[0];for(const T of this.slides)for(const M of E){const O=T.pos+M*s,B=O+T.dim+T.gap;O<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,f=i.length,g=i[0],y=i[f-1],v=this.option("center");let E=0,T=0,M=0,O=e===void 0?-1*((a==null?void 0:a.target[this.axis])||0):e;v&&(O+=.5*n),this.isInfinite?(O<g.pos-.5*y.gap&&(O-=r,M=-1),O>y.pos+y.dim+.5*y.gap&&(O-=r,M=1)):O=Math.max(g.pos||0,Math.min(O,y.pos));let B=y,F=i.find(Z=>{const te=Z.pos-.5*B.gap,X=Z.pos+Z.dim+.5*Z.gap;return B=Z,O>=te&&O<X});return F||(F=y),T=this.getPageForSlide(F.index),E=T+M*o,{page:E,pageIndex:T}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([Cr.Destroy].includes(this.state))return;this.state=Cr.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(f=>{this.removeSlideEl(f)}),this.detachPlugins(),n&&(n.removeEventListener("scroll",this.onScroll),n.offsetParent&&r&&r.offsetParent&&n.replaceWith(...r.childNodes));for(const[f,g]of Object.entries(a))f!=="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(bh,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:bd}),Object.defineProperty(bh,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:z5}),Object.defineProperty(bh,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:F5});const OE=function(t){if(!Zi(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 f=a;s<e&&(f-=e-s),o>r&&(f-=o-r);const g=f/n*100;return Math.round(g)},_h=!(typeof window>"u"||!window.document||!window.document.createElement);let Eb;const Sb=["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(","),BE=t=>{if(t&&_h){Eb===void 0&&document.createElement("div").focus({get preventScroll(){return Eb=!0,!1}});try{if(Eb)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{}}},zE=()=>{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},Cb={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({},EE),{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">
624
+ `),ne=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(ne,ue),P.compileShader(ne),!P.getShaderParameter(ne,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(ne)}`);P.attachShader(this.program,ne);const be=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(be,pe),P.compileShader(be),!P.getShaderParameter(be,P.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${P.getShaderInfoLog(be)}`);P.attachShader(this.program,be),this.attributes={};const _e={};this.numAttributes=$.length;for(let Ee=0;Ee<this.numAttributes;Ee++)$[Ee]&&(P.bindAttribLocation(this.program,Ee,$[Ee]),this.attributes[$[Ee]]=Ee);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(be),P.deleteShader(ne);for(let Ee=0;Ee<oe.length;Ee++){const Be=oe[Ee];if(Be&&!_e[Be]){const He=P.getUniformLocation(this.program,Be);He&&(_e[Be]=He)}}this.fixedUniforms=_(l,_e),this.terrainUniforms=((Ee,Be)=>({u_depth:new o.aH(Ee,Be.u_depth),u_terrain:new o.aH(Ee,Be.u_terrain),u_terrain_dim:new o.aI(Ee,Be.u_terrain_dim),u_terrain_matrix:new o.aJ(Ee,Be.u_terrain_matrix),u_terrain_unpack:new o.aK(Ee,Be.u_terrain_unpack),u_terrain_exaggeration:new o.aI(Ee,Be.u_terrain_exaggeration)}))(l,_e),this.binderUniforms=b?b.getUniforms(l,_e):[]}draw(l,p,b,_,w,D,P,R,V,$,j,G,Q,ee,oe,ce,ue,pe){const ne=l.gl;if(this.failedToCreate)return;if(l.program.set(this.program),l.setDepthMode(b),l.setStencilMode(_),l.setColorMode(w),l.setCullFace(D),R){l.activeTexture.set(ne.TEXTURE2),ne.bindTexture(ne.TEXTURE_2D,R.depthTexture),l.activeTexture.set(ne.TEXTURE3),ne.bindTexture(ne.TEXTURE_2D,R.texture);for(const _e in this.terrainUniforms)this.terrainUniforms[_e].set(R[_e])}for(const _e in this.fixedUniforms)this.fixedUniforms[_e].set(P[_e]);oe&&oe.setUniforms(l,this.binderUniforms,Q,{zoom:ee});let be=0;switch(p){case ne.LINES:be=2;break;case ne.TRIANGLES:be=3;break;case ne.LINE_STRIP:be=1}for(const _e of G.get()){const Ee=_e.vaos||(_e.vaos={});(Ee[V]||(Ee[V]=new _p)).bind(l,this,$,oe?oe.getPaintVertexBuffers():[],j,_e.vertexOffset,ce,ue,pe),ne.drawElements(p,_e.primitiveLength*be,ne.UNSIGNED_SHORT,_e.primitiveOffset*be*2)}}}function ou(k,l,p){const b=1/on(p,1,l.transform.tileZoom),_=Math.pow(2,p.tileID.overscaledZ),w=p.tileSize*Math.pow(2,l.transform.tileZoom)/_,D=w*(p.tileID.canonical.x+p.tileID.wrap*_),P=w*p.tileID.canonical.y;return{u_image:0,u_texsize:p.imageAtlasTexture.size,u_scale:[b,k.fromScale,k.toScale],u_fade:k.t,u_pixel_coord_upper:[D>>16,P>>16],u_pixel_coord_lower:[65535&D,65535&P]}}const Mc=(k,l,p,b)=>{const _=l.style.light,w=_.properties.get("position"),D=[w.x,w.y,w.z],P=function(){var V=new o.A(9);return o.A!=Float32Array&&(V[1]=0,V[2]=0,V[3]=0,V[5]=0,V[6]=0,V[7]=0),V[0]=1,V[4]=1,V[8]=1,V}();_.properties.get("anchor")==="viewport"&&function(V,$){var j=Math.sin($),G=Math.cos($);V[0]=G,V[1]=j,V[2]=0,V[3]=-j,V[4]=G,V[5]=0,V[6]=0,V[7]=0,V[8]=1}(P,-l.transform.angle),function(V,$,j){var G=$[0],Q=$[1],ee=$[2];V[0]=G*j[0]+Q*j[3]+ee*j[6],V[1]=G*j[1]+Q*j[4]+ee*j[7],V[2]=G*j[2]+Q*j[5]+ee*j[8]}(D,D,P);const R=_.properties.get("color");return{u_matrix:k,u_lightpos:D,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[R.r,R.g,R.b],u_vertical_gradient:+p,u_opacity:b}},au=(k,l,p,b,_,w,D)=>o.e(Mc(k,l,p,b),ou(w,l,D),{u_height_factor:-Math.pow(2,_.overscaledZ)/D.tileSize/8}),pl=k=>({u_matrix:k}),ny=(k,l,p,b)=>o.e(pl(k),ou(p,l,b)),Av=(k,l)=>({u_matrix:k,u_world:l}),ry=(k,l,p,b,_)=>o.e(ny(k,l,p,b),{u_world:_}),Mv=(k,l,p,b)=>{const _=k.transform;let w,D;if(b.paint.get("circle-pitch-alignment")==="map"){const P=on(p,1,_.zoom);w=!0,D=[P,P]}else w=!1,D=_.pixelsToGLUnits;return{u_camera_to_center_distance:_.cameraToCenterDistance,u_scale_with_map:+(b.paint.get("circle-pitch-scale")==="map"),u_matrix:k.translatePosMatrix(l.posMatrix,p,b.paint.get("circle-translate"),b.paint.get("circle-translate-anchor")),u_pitch_with_map:+w,u_device_pixel_ratio:k.pixelRatio,u_extrude_scale:D}},ga=(k,l,p)=>({u_matrix:k,u_inv_matrix:l,u_camera_to_center_distance:p.cameraToCenterDistance,u_viewport_size:[p.width,p.height]}),Dc=(k,l,p=1)=>({u_matrix:k,u_color:l,u_overlay:0,u_overlay_scale:p}),xi=k=>({u_matrix:k}),vi=(k,l,p,b)=>({u_matrix:k,u_extrude_scale:on(l,1,p),u_intensity:b}),lu=(k,l,p,b)=>{const _=o.H();o.aP(_,0,k.width,k.height,0,0,1);const w=k.context.gl;return{u_matrix:_,u_world:[w.drawingBufferWidth,w.drawingBufferHeight],u_image:p,u_color_ramp:b,u_opacity:l.paint.get("heatmap-opacity")}};function cu(k,l){const p=Math.pow(2,l.canonical.z),b=l.canonical.y;return[new o.Z(0,b/p).toLngLat().lat,new o.Z(0,(b+1)/p).toLngLat().lat]}const du=(k,l,p,b)=>{const _=k.transform;return{u_matrix:oy(k,l,p,b),u_ratio:1/on(l,1,_.zoom),u_device_pixel_ratio:k.pixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]]}},iy=(k,l,p,b,_)=>o.e(du(k,l,p,_),{u_image:0,u_image_height:b}),fl=(k,l,p,b,_)=>{const w=k.transform,D=sy(l,w);return{u_matrix:oy(k,l,p,_),u_texsize:l.imageAtlasTexture.size,u_ratio:1/on(l,1,w.zoom),u_device_pixel_ratio:k.pixelRatio,u_image:0,u_scale:[D,b.fromScale,b.toScale],u_fade:b.t,u_units_to_pixels:[1/w.pixelsToGLUnits[0],1/w.pixelsToGLUnits[1]]}},Dv=(k,l,p,b,_,w)=>{const D=k.lineAtlas,P=sy(l,k.transform),R=p.layout.get("line-cap")==="round",V=D.getDash(b.from,R),$=D.getDash(b.to,R),j=V.width*_.fromScale,G=$.width*_.toScale;return o.e(du(k,l,p,w),{u_patternscale_a:[P/j,-V.height/2],u_patternscale_b:[P/G,-$.height/2],u_sdfgamma:D.width/(256*Math.min(j,G)*k.pixelRatio)/2,u_image:0,u_tex_y_a:V.y,u_tex_y_b:$.y,u_mix:_.t})};function sy(k,l){return 1/on(k,1,l.tileZoom)}function oy(k,l,p,b){return k.translatePosMatrix(b?b.posMatrix:l.tileID.posMatrix,l,p.paint.get("line-translate"),p.paint.get("line-translate-anchor"))}const Iv=(k,l,p,b,_)=>{return{u_matrix:k,u_tl_parent:l,u_scale_parent:p,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:(D=_.paint.get("raster-saturation"),D>0?1-1/(1.001-D):-D),u_contrast_factor:(w=_.paint.get("raster-contrast"),w>0?1/(1-w):1+w),u_spin_weights:Pv(_.paint.get("raster-hue-rotate"))};var w,D};function Pv(k){k*=Math.PI/180;const l=Math.sin(k),p=Math.cos(k);return[(2*p+1)/3,(-Math.sqrt(3)*l-p+1)/3,(Math.sqrt(3)*l-p+1)/3]}const ay=(k,l,p,b,_,w,D,P,R,V,$,j,G,Q)=>{const ee=D.transform;return{u_is_size_zoom_constant:+(k==="constant"||k==="source"),u_is_size_feature_constant:+(k==="constant"||k==="camera"),u_size_t:l?l.uSizeT:0,u_size:l?l.uSize:0,u_camera_to_center_distance:ee.cameraToCenterDistance,u_pitch:ee.pitch/360*2*Math.PI,u_rotate_symbol:+p,u_aspect_ratio:ee.width/ee.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:R,u_coord_matrix:V,u_is_text:+j,u_pitch_with_map:+b,u_is_along_line:_,u_is_variable_anchor:w,u_texsize:G,u_texture:0,u_translation:$,u_pitched_scale:Q}},Ic=(k,l,p,b,_,w,D,P,R,V,$,j,G,Q,ee)=>{const oe=D.transform;return o.e(ay(k,l,p,b,_,w,D,P,R,V,$,j,G,ee),{u_gamma_scale:b?Math.cos(oe._pitch)*oe.cameraToCenterDistance:1,u_device_pixel_ratio:D.pixelRatio,u_is_halo:+Q})},wp=(k,l,p,b,_,w,D,P,R,V,$,j,G,Q)=>o.e(Ic(k,l,p,b,_,w,D,P,R,V,$,!0,j,!0,Q),{u_texsize_icon:G,u_texture_icon:1}),uu=(k,l,p)=>({u_matrix:k,u_opacity:l,u_color:p}),kp=(k,l,p,b,_,w)=>o.e(function(D,P,R,V){const $=R.imageManager.getPattern(D.from.toString()),j=R.imageManager.getPattern(D.to.toString()),{width:G,height:Q}=R.imageManager.getPixelSize(),ee=Math.pow(2,V.tileID.overscaledZ),oe=V.tileSize*Math.pow(2,R.transform.tileZoom)/ee,ce=oe*(V.tileID.canonical.x+V.tileID.wrap*ee),ue=oe*V.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:[G,Q],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/on(V,1,R.transform.tileZoom),u_pixel_coord_upper:[ce>>16,ue>>16],u_pixel_coord_lower:[65535&ce,65535&ue]}}(b,w,p,_),{u_matrix:k,u_opacity:l}),Ep={fillExtrusion:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_lightpos:new o.aN(k,l.u_lightpos),u_lightintensity:new o.aI(k,l.u_lightintensity),u_lightcolor:new o.aN(k,l.u_lightcolor),u_vertical_gradient:new o.aI(k,l.u_vertical_gradient),u_opacity:new o.aI(k,l.u_opacity)}),fillExtrusionPattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_lightpos:new o.aN(k,l.u_lightpos),u_lightintensity:new o.aI(k,l.u_lightintensity),u_lightcolor:new o.aN(k,l.u_lightcolor),u_vertical_gradient:new o.aI(k,l.u_vertical_gradient),u_height_factor:new o.aI(k,l.u_height_factor),u_image:new o.aH(k,l.u_image),u_texsize:new o.aO(k,l.u_texsize),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade),u_opacity:new o.aI(k,l.u_opacity)}),fill:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix)}),fillPattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_image:new o.aH(k,l.u_image),u_texsize:new o.aO(k,l.u_texsize),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade)}),fillOutline:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_world:new o.aO(k,l.u_world)}),fillOutlinePattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_world:new o.aO(k,l.u_world),u_image:new o.aH(k,l.u_image),u_texsize:new o.aO(k,l.u_texsize),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade)}),circle:(k,l)=>({u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_scale_with_map:new o.aH(k,l.u_scale_with_map),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_extrude_scale:new o.aO(k,l.u_extrude_scale),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_matrix:new o.aJ(k,l.u_matrix)}),collisionBox:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_pixel_extrude_scale:new o.aO(k,l.u_pixel_extrude_scale)}),collisionCircle:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_inv_matrix:new o.aJ(k,l.u_inv_matrix),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_viewport_size:new o.aO(k,l.u_viewport_size)}),debug:(k,l)=>({u_color:new o.aL(k,l.u_color),u_matrix:new o.aJ(k,l.u_matrix),u_overlay:new o.aH(k,l.u_overlay),u_overlay_scale:new o.aI(k,l.u_overlay_scale)}),clippingMask:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix)}),heatmap:(k,l)=>({u_extrude_scale:new o.aI(k,l.u_extrude_scale),u_intensity:new o.aI(k,l.u_intensity),u_matrix:new o.aJ(k,l.u_matrix)}),heatmapTexture:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_world:new o.aO(k,l.u_world),u_image:new o.aH(k,l.u_image),u_color_ramp:new o.aH(k,l.u_color_ramp),u_opacity:new o.aI(k,l.u_opacity)}),hillshade:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_image:new o.aH(k,l.u_image),u_latrange:new o.aO(k,l.u_latrange),u_light:new o.aO(k,l.u_light),u_shadow:new o.aL(k,l.u_shadow),u_highlight:new o.aL(k,l.u_highlight),u_accent:new o.aL(k,l.u_accent)}),hillshadePrepare:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_image:new o.aH(k,l.u_image),u_dimension:new o.aO(k,l.u_dimension),u_zoom:new o.aI(k,l.u_zoom),u_unpack:new o.aK(k,l.u_unpack)}),line:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels)}),lineGradient:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels),u_image:new o.aH(k,l.u_image),u_image_height:new o.aI(k,l.u_image_height)}),linePattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_texsize:new o.aO(k,l.u_texsize),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_image:new o.aH(k,l.u_image),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels),u_scale:new o.aN(k,l.u_scale),u_fade:new o.aI(k,l.u_fade)}),lineSDF:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ratio:new o.aI(k,l.u_ratio),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_units_to_pixels:new o.aO(k,l.u_units_to_pixels),u_patternscale_a:new o.aO(k,l.u_patternscale_a),u_patternscale_b:new o.aO(k,l.u_patternscale_b),u_sdfgamma:new o.aI(k,l.u_sdfgamma),u_image:new o.aH(k,l.u_image),u_tex_y_a:new o.aI(k,l.u_tex_y_a),u_tex_y_b:new o.aI(k,l.u_tex_y_b),u_mix:new o.aI(k,l.u_mix)}),raster:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_tl_parent:new o.aO(k,l.u_tl_parent),u_scale_parent:new o.aI(k,l.u_scale_parent),u_buffer_scale:new o.aI(k,l.u_buffer_scale),u_fade_t:new o.aI(k,l.u_fade_t),u_opacity:new o.aI(k,l.u_opacity),u_image0:new o.aH(k,l.u_image0),u_image1:new o.aH(k,l.u_image1),u_brightness_low:new o.aI(k,l.u_brightness_low),u_brightness_high:new o.aI(k,l.u_brightness_high),u_saturation_factor:new o.aI(k,l.u_saturation_factor),u_contrast_factor:new o.aI(k,l.u_contrast_factor),u_spin_weights:new o.aN(k,l.u_spin_weights)}),symbolIcon:(k,l)=>({u_is_size_zoom_constant:new o.aH(k,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(k,l.u_is_size_feature_constant),u_size_t:new o.aI(k,l.u_size_t),u_size:new o.aI(k,l.u_size),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_pitch:new o.aI(k,l.u_pitch),u_rotate_symbol:new o.aH(k,l.u_rotate_symbol),u_aspect_ratio:new o.aI(k,l.u_aspect_ratio),u_fade_change:new o.aI(k,l.u_fade_change),u_matrix:new o.aJ(k,l.u_matrix),u_label_plane_matrix:new o.aJ(k,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(k,l.u_coord_matrix),u_is_text:new o.aH(k,l.u_is_text),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_is_along_line:new o.aH(k,l.u_is_along_line),u_is_variable_anchor:new o.aH(k,l.u_is_variable_anchor),u_texsize:new o.aO(k,l.u_texsize),u_texture:new o.aH(k,l.u_texture),u_translation:new o.aO(k,l.u_translation),u_pitched_scale:new o.aI(k,l.u_pitched_scale)}),symbolSDF:(k,l)=>({u_is_size_zoom_constant:new o.aH(k,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(k,l.u_is_size_feature_constant),u_size_t:new o.aI(k,l.u_size_t),u_size:new o.aI(k,l.u_size),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_pitch:new o.aI(k,l.u_pitch),u_rotate_symbol:new o.aH(k,l.u_rotate_symbol),u_aspect_ratio:new o.aI(k,l.u_aspect_ratio),u_fade_change:new o.aI(k,l.u_fade_change),u_matrix:new o.aJ(k,l.u_matrix),u_label_plane_matrix:new o.aJ(k,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(k,l.u_coord_matrix),u_is_text:new o.aH(k,l.u_is_text),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_is_along_line:new o.aH(k,l.u_is_along_line),u_is_variable_anchor:new o.aH(k,l.u_is_variable_anchor),u_texsize:new o.aO(k,l.u_texsize),u_texture:new o.aH(k,l.u_texture),u_gamma_scale:new o.aI(k,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_is_halo:new o.aH(k,l.u_is_halo),u_translation:new o.aO(k,l.u_translation),u_pitched_scale:new o.aI(k,l.u_pitched_scale)}),symbolTextAndIcon:(k,l)=>({u_is_size_zoom_constant:new o.aH(k,l.u_is_size_zoom_constant),u_is_size_feature_constant:new o.aH(k,l.u_is_size_feature_constant),u_size_t:new o.aI(k,l.u_size_t),u_size:new o.aI(k,l.u_size),u_camera_to_center_distance:new o.aI(k,l.u_camera_to_center_distance),u_pitch:new o.aI(k,l.u_pitch),u_rotate_symbol:new o.aH(k,l.u_rotate_symbol),u_aspect_ratio:new o.aI(k,l.u_aspect_ratio),u_fade_change:new o.aI(k,l.u_fade_change),u_matrix:new o.aJ(k,l.u_matrix),u_label_plane_matrix:new o.aJ(k,l.u_label_plane_matrix),u_coord_matrix:new o.aJ(k,l.u_coord_matrix),u_is_text:new o.aH(k,l.u_is_text),u_pitch_with_map:new o.aH(k,l.u_pitch_with_map),u_is_along_line:new o.aH(k,l.u_is_along_line),u_is_variable_anchor:new o.aH(k,l.u_is_variable_anchor),u_texsize:new o.aO(k,l.u_texsize),u_texsize_icon:new o.aO(k,l.u_texsize_icon),u_texture:new o.aH(k,l.u_texture),u_texture_icon:new o.aH(k,l.u_texture_icon),u_gamma_scale:new o.aI(k,l.u_gamma_scale),u_device_pixel_ratio:new o.aI(k,l.u_device_pixel_ratio),u_is_halo:new o.aH(k,l.u_is_halo),u_translation:new o.aO(k,l.u_translation),u_pitched_scale:new o.aI(k,l.u_pitched_scale)}),background:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_opacity:new o.aI(k,l.u_opacity),u_color:new o.aL(k,l.u_color)}),backgroundPattern:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_opacity:new o.aI(k,l.u_opacity),u_image:new o.aH(k,l.u_image),u_pattern_tl_a:new o.aO(k,l.u_pattern_tl_a),u_pattern_br_a:new o.aO(k,l.u_pattern_br_a),u_pattern_tl_b:new o.aO(k,l.u_pattern_tl_b),u_pattern_br_b:new o.aO(k,l.u_pattern_br_b),u_texsize:new o.aO(k,l.u_texsize),u_mix:new o.aI(k,l.u_mix),u_pattern_size_a:new o.aO(k,l.u_pattern_size_a),u_pattern_size_b:new o.aO(k,l.u_pattern_size_b),u_scale_a:new o.aI(k,l.u_scale_a),u_scale_b:new o.aI(k,l.u_scale_b),u_pixel_coord_upper:new o.aO(k,l.u_pixel_coord_upper),u_pixel_coord_lower:new o.aO(k,l.u_pixel_coord_lower),u_tile_units_to_pixels:new o.aI(k,l.u_tile_units_to_pixels)}),terrain:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_texture:new o.aH(k,l.u_texture),u_ele_delta:new o.aI(k,l.u_ele_delta),u_fog_matrix:new o.aJ(k,l.u_fog_matrix),u_fog_color:new o.aL(k,l.u_fog_color),u_fog_ground_blend:new o.aI(k,l.u_fog_ground_blend),u_fog_ground_blend_opacity:new o.aI(k,l.u_fog_ground_blend_opacity),u_horizon_color:new o.aL(k,l.u_horizon_color),u_horizon_fog_blend:new o.aI(k,l.u_horizon_fog_blend)}),terrainDepth:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_ele_delta:new o.aI(k,l.u_ele_delta)}),terrainCoords:(k,l)=>({u_matrix:new o.aJ(k,l.u_matrix),u_texture:new o.aH(k,l.u_texture),u_terrain_coords_id:new o.aI(k,l.u_terrain_coords_id),u_ele_delta:new o.aI(k,l.u_ele_delta)}),sky:(k,l)=>({u_sky_color:new o.aL(k,l.u_sky_color),u_horizon_color:new o.aL(k,l.u_horizon_color),u_horizon:new o.aI(k,l.u_horizon),u_sky_horizon_blend:new o.aI(k,l.u_sky_horizon_blend)})};class Gs{constructor(l,p,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,p.arrayBuffer,this.dynamicDraw?_.DYNAMIC_DRAW:_.STATIC_DRAW),this.dynamicDraw||delete p.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(l){const p=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),p.bufferSubData(p.ELEMENT_ARRAY_BUFFER,0,l.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Rv={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Sp{constructor(l,p,b,_){this.length=p.length,this.attributes=b,this.itemSize=p.bytesPerElement,this.dynamicDraw=_,this.context=l;const w=l.gl;this.buffer=w.createBuffer(),l.bindVertexBuffer.set(this.buffer),w.bufferData(w.ARRAY_BUFFER,p.arrayBuffer,this.dynamicDraw?w.DYNAMIC_DRAW:w.STATIC_DRAW),this.dynamicDraw||delete p.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 p=this.context.gl;this.bind(),p.bufferSubData(p.ARRAY_BUFFER,0,l.arrayBuffer)}enableAttributes(l,p){for(let b=0;b<this.attributes.length;b++){const _=p.attributes[this.attributes[b].name];_!==void 0&&l.enableVertexAttribArray(_)}}setVertexAttribPointers(l,p,b){for(let _=0;_<this.attributes.length;_++){const w=this.attributes[_],D=p.attributes[w.name];D!==void 0&&l.vertexAttribPointer(D,w.components,l[Rv[w.type]],!1,this.itemSize,w.offset+this.itemSize*(b||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const ya=new WeakMap;function Oo(k){var l;if(ya.has(k))return ya.get(k);{const p=(l=k.getParameter(k.VERSION))===null||l===void 0?void 0:l.startsWith("WebGL 2.0");return ya.set(k,p),p}}class Sn{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 hu extends Sn{getDefault(){return o.aM.transparent}set(l){const p=this.current;(l.r!==p.r||l.g!==p.g||l.b!==p.b||l.a!==p.a||this.dirty)&&(this.gl.clearColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class Nv extends Sn{getDefault(){return 1}set(l){(l!==this.current||this.dirty)&&(this.gl.clearDepth(l),this.current=l,this.dirty=!1)}}class ml extends Sn{getDefault(){return 0}set(l){(l!==this.current||this.dirty)&&(this.gl.clearStencil(l),this.current=l,this.dirty=!1)}}class Ov extends Sn{getDefault(){return[!0,!0,!0,!0]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||l[2]!==p[2]||l[3]!==p[3]||this.dirty)&&(this.gl.colorMask(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class ly extends Sn{getDefault(){return!0}set(l){(l!==this.current||this.dirty)&&(this.gl.depthMask(l),this.current=l,this.dirty=!1)}}class Bv extends Sn{getDefault(){return 255}set(l){(l!==this.current||this.dirty)&&(this.gl.stencilMask(l),this.current=l,this.dirty=!1)}}class cy extends Sn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(l){const p=this.current;(l.func!==p.func||l.ref!==p.ref||l.mask!==p.mask||this.dirty)&&(this.gl.stencilFunc(l.func,l.ref,l.mask),this.current=l,this.dirty=!1)}}class Cp extends Sn{getDefault(){const l=this.gl;return[l.KEEP,l.KEEP,l.KEEP]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||l[2]!==p[2]||this.dirty)&&(this.gl.stencilOp(l[0],l[1],l[2]),this.current=l,this.dirty=!1)}}class dy extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.STENCIL_TEST):p.disable(p.STENCIL_TEST),this.current=l,this.dirty=!1}}class uy extends Sn{getDefault(){return[0,1]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||this.dirty)&&(this.gl.depthRange(l[0],l[1]),this.current=l,this.dirty=!1)}}class hy extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.DEPTH_TEST):p.disable(p.DEPTH_TEST),this.current=l,this.dirty=!1}}class py extends Sn{getDefault(){return this.gl.LESS}set(l){(l!==this.current||this.dirty)&&(this.gl.depthFunc(l),this.current=l,this.dirty=!1)}}class ba extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.BLEND):p.disable(p.BLEND),this.current=l,this.dirty=!1}}class fy extends Sn{getDefault(){const l=this.gl;return[l.ONE,l.ZERO]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||this.dirty)&&(this.gl.blendFunc(l[0],l[1]),this.current=l,this.dirty=!1)}}class zv extends Sn{getDefault(){return o.aM.transparent}set(l){const p=this.current;(l.r!==p.r||l.g!==p.g||l.b!==p.b||l.a!==p.a||this.dirty)&&(this.gl.blendColor(l.r,l.g,l.b,l.a),this.current=l,this.dirty=!1)}}class my extends Sn{getDefault(){return this.gl.FUNC_ADD}set(l){(l!==this.current||this.dirty)&&(this.gl.blendEquation(l),this.current=l,this.dirty=!1)}}class Pc extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;l?p.enable(p.CULL_FACE):p.disable(p.CULL_FACE),this.current=l,this.dirty=!1}}class Vv extends Sn{getDefault(){return this.gl.BACK}set(l){(l!==this.current||this.dirty)&&(this.gl.cullFace(l),this.current=l,this.dirty=!1)}}class pu extends Sn{getDefault(){return this.gl.CCW}set(l){(l!==this.current||this.dirty)&&(this.gl.frontFace(l),this.current=l,this.dirty=!1)}}class Lv extends Sn{getDefault(){return null}set(l){(l!==this.current||this.dirty)&&(this.gl.useProgram(l),this.current=l,this.dirty=!1)}}class Fv extends Sn{getDefault(){return this.gl.TEXTURE0}set(l){(l!==this.current||this.dirty)&&(this.gl.activeTexture(l),this.current=l,this.dirty=!1)}}class gy extends Sn{getDefault(){const l=this.gl;return[0,0,l.drawingBufferWidth,l.drawingBufferHeight]}set(l){const p=this.current;(l[0]!==p[0]||l[1]!==p[1]||l[2]!==p[2]||l[3]!==p[3]||this.dirty)&&(this.gl.viewport(l[0],l[1],l[2],l[3]),this.current=l,this.dirty=!1)}}class yy extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindFramebuffer(p.FRAMEBUFFER,l),this.current=l,this.dirty=!1}}class by extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindRenderbuffer(p.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Tp extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindTexture(p.TEXTURE_2D,l),this.current=l,this.dirty=!1}}class _y extends Sn{getDefault(){return null}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.bindBuffer(p.ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class fu extends Sn{getDefault(){return null}set(l){const p=this.gl;p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,l),this.current=l,this.dirty=!1}}class uo extends Sn{getDefault(){return null}set(l){var p;if(l===this.current&&!this.dirty)return;const b=this.gl;Oo(b)?b.bindVertexArray(l):(p=b.getExtension("OES_vertex_array_object"))===null||p===void 0||p.bindVertexArrayOES(l),this.current=l,this.dirty=!1}}class Ap extends Sn{getDefault(){return 4}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.pixelStorei(p.UNPACK_ALIGNMENT,l),this.current=l,this.dirty=!1}}class Mp extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.pixelStorei(p.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l),this.current=l,this.dirty=!1}}class Dp extends Sn{getDefault(){return!1}set(l){if(l===this.current&&!this.dirty)return;const p=this.gl;p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,l),this.current=l,this.dirty=!1}}class mu extends Sn{constructor(l,p){super(l),this.context=l,this.parent=p}getDefault(){return null}}class Ip extends mu{setDirty(){this.dirty=!0}set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const p=this.gl;p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_2D,l,0),this.current=l,this.dirty=!1}}class _a extends mu{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const p=this.gl;p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_ATTACHMENT,p.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class Pp extends mu{set(l){if(l===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const p=this.gl;p.framebufferRenderbuffer(p.FRAMEBUFFER,p.DEPTH_STENCIL_ATTACHMENT,p.RENDERBUFFER,l),this.current=l,this.dirty=!1}}class $v{constructor(l,p,b,_,w){this.context=l,this.width=p,this.height=b;const D=l.gl,P=this.framebuffer=D.createFramebuffer();if(this.colorAttachment=new Ip(l,P),_)this.depthAttachment=w?new Pp(l,P):new _a(l,P);else if(w)throw new Error("Stencil cannot be set without depth");if(D.checkFramebufferStatus(D.FRAMEBUFFER)!==D.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const l=this.context.gl,p=this.colorAttachment.get();if(p&&l.deleteTexture(p),this.depthAttachment){const b=this.depthAttachment.get();b&&l.deleteRenderbuffer(b)}l.deleteFramebuffer(this.framebuffer)}}class dr{constructor(l,p,b){this.blendFunction=l,this.blendColor=p,this.mask=b}}dr.Replace=[1,0],dr.disabled=new dr(dr.Replace,o.aM.transparent,[!1,!1,!1,!1]),dr.unblended=new dr(dr.Replace,o.aM.transparent,[!0,!0,!0,!0]),dr.alphaBlended=new dr([1,771],o.aM.transparent,[!0,!0,!0,!0]);class jv{constructor(l){var p,b;if(this.gl=l,this.clearColor=new hu(this),this.clearDepth=new Nv(this),this.clearStencil=new ml(this),this.colorMask=new Ov(this),this.depthMask=new ly(this),this.stencilMask=new Bv(this),this.stencilFunc=new cy(this),this.stencilOp=new Cp(this),this.stencilTest=new dy(this),this.depthRange=new uy(this),this.depthTest=new hy(this),this.depthFunc=new py(this),this.blend=new ba(this),this.blendFunc=new fy(this),this.blendColor=new zv(this),this.blendEquation=new my(this),this.cullFace=new Pc(this),this.cullFaceSide=new Vv(this),this.frontFace=new pu(this),this.program=new Lv(this),this.activeTexture=new Fv(this),this.viewport=new gy(this),this.bindFramebuffer=new yy(this),this.bindRenderbuffer=new by(this),this.bindTexture=new Tp(this),this.bindVertexBuffer=new _y(this),this.bindElementBuffer=new fu(this),this.bindVertexArray=new uo(this),this.pixelStoreUnpack=new Ap(this),this.pixelStoreUnpackPremultiplyAlpha=new Mp(this),this.pixelStoreUnpackFlipY=new Dp(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),Oo(l)){this.HALF_FLOAT=l.HALF_FLOAT;const _=l.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(p=l.RGBA16F)!==null&&p!==void 0?p:_==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,p){return new Gs(this,l,p)}createVertexBuffer(l,p,b){return new Sp(this,l,p,b)}createRenderbuffer(l,p,b){const _=this.gl,w=_.createRenderbuffer();return this.bindRenderbuffer.set(w),_.renderbufferStorage(_.RENDERBUFFER,l,p,b),this.bindRenderbuffer.set(null),w}createFramebuffer(l,p,b,_){return new $v(this,l,p,b,_)}clear({color:l,depth:p,stencil:b}){const _=this.gl;let w=0;l&&(w|=_.COLOR_BUFFER_BIT,this.clearColor.set(l),this.colorMask.set([!0,!0,!0,!0])),p!==void 0&&(w|=_.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(p),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,dr.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 Oo(this.gl)?this.gl.createVertexArray():(l=this.gl.getExtension("OES_vertex_array_object"))===null||l===void 0?void 0:l.createVertexArrayOES()}deleteVertexArray(l){var p;return Oo(this.gl)?this.gl.deleteVertexArray(l):(p=this.gl.getExtension("OES_vertex_array_object"))===null||p===void 0?void 0:p.deleteVertexArrayOES(l)}unbindVAO(){this.bindVertexArray.set(null)}}class en{constructor(l,p,b){this.func=l,this.mask=p,this.range=b}}en.ReadOnly=!1,en.ReadWrite=!0,en.disabled=new en(519,en.ReadOnly,[0,1]);const gu=7680;class $n{constructor(l,p,b,_,w,D){this.test=l,this.ref=p,this.mask=b,this.fail=_,this.depthFail=w,this.pass=D}}$n.disabled=new $n({func:519,mask:0},0,0,gu,gu,gu);class On{constructor(l,p,b){this.enable=l,this.mode=p,this.frontFace=b}}let xa;function Rc(k,l,p,b,_){const w=k.context,D=w.gl,P=k.useProgram("collisionBox"),R=[];let V=0,$=0;for(let ue=0;ue<b.length;ue++){const pe=b[ue],ne=l.getTile(pe).getBucket(p);if(!ne)continue;const be=_?ne.textCollisionBox:ne.iconCollisionBox,_e=ne.collisionCircleArray;if(_e.length>0){const Ee=o.H();o.aQ(Ee,ne.placementInvProjMatrix,k.transform.glCoordMatrix),o.aQ(Ee,Ee,ne.placementViewportMatrix),R.push({circleArray:_e,circleOffset:$,transform:pe.posMatrix,invTransform:Ee,coord:pe}),V+=_e.length/4,$=V}be&&P.draw(w,D.LINES,en.disabled,$n.disabled,k.colorModeForRenderPass(),On.disabled,{u_matrix:pe.posMatrix,u_pixel_extrude_scale:[1/(j=k.transform).width,1/j.height]},k.style.map.terrain&&k.style.map.terrain.getTerrainData(pe),p.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,null,k.transform.zoom,null,null,be.collisionVertexBuffer)}var j;if(!_||!R.length)return;const G=k.useProgram("collisionCircle"),Q=new o.aR;Q.resize(4*V),Q._trim();let ee=0;for(const ue of R)for(let pe=0;pe<ue.circleArray.length/4;pe++){const ne=4*pe,be=ue.circleArray[ne+0],_e=ue.circleArray[ne+1],Ee=ue.circleArray[ne+2],Be=ue.circleArray[ne+3];Q.emplace(ee++,be,_e,Ee,Be,0),Q.emplace(ee++,be,_e,Ee,Be,1),Q.emplace(ee++,be,_e,Ee,Be,2),Q.emplace(ee++,be,_e,Ee,Be,3)}(!xa||xa.length<2*V)&&(xa=function(ue){const pe=2*ue,ne=new o.aT;ne.resize(pe),ne._trim();for(let be=0;be<pe;be++){const _e=6*be;ne.uint16[_e+0]=4*be+0,ne.uint16[_e+1]=4*be+1,ne.uint16[_e+2]=4*be+2,ne.uint16[_e+3]=4*be+2,ne.uint16[_e+4]=4*be+3,ne.uint16[_e+5]=4*be+0}return ne}(V));const oe=w.createIndexBuffer(xa,!0),ce=w.createVertexBuffer(Q,o.aS.members,!0);for(const ue of R){const pe=ga(ue.transform,ue.invTransform,k.transform);G.draw(w,D.TRIANGLES,en.disabled,$n.disabled,k.colorModeForRenderPass(),On.disabled,pe,k.style.map.terrain&&k.style.map.terrain.getTerrainData(ue.coord),p.id,ce,oe,o.a0.simpleSegment(0,2*ue.circleOffset,ue.circleArray.length,ue.circleArray.length/2),null,k.transform.zoom,null,null,null)}ce.destroy(),oe.destroy()}On.disabled=new On(!1,1029,2305),On.backCCW=new On(!0,1029,2305);const Nc=o.an(new Float32Array(16));function Rp(k,l,p,b,_,w){const{horizontalAlign:D,verticalAlign:P}=o.au(k);return new o.P((-(D-.5)*l/_+b[0])*w,(-(P-.5)*p/_+b[1])*w)}function va(k,l,p,b,_,w){const D=l.tileAnchorPoint.add(new o.P(l.translation[0],l.translation[1]));if(l.pitchWithMap){let P=b.mult(w);p||(P=P.rotate(-_));const R=D.add(P);return ae(R.x,R.y,l.labelPlaneMatrix,l.getElevation).point}if(p){const P=Pe(l.tileAnchorPoint.x+1,l.tileAnchorPoint.y,l).point.sub(k),R=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return k.add(b.rotate(R))}return k.add(b)}function gl(k,l,p,b,_,w,D,P,R,V,$,j,G,Q){const ee=k.text.placedSymbolArray,oe=k.text.dynamicLayoutVertexArray,ce=k.icon.dynamicLayoutVertexArray,ue={};oe.clear();for(let pe=0;pe<ee.length;pe++){const ne=ee.get(pe),be=ne.hidden||!ne.crossTileID||k.allowVerticalPlacement&&!ne.placedOrientation?null:b[ne.crossTileID];if(be){const _e=new o.P(ne.anchorX,ne.anchorY),Ee={getElevation:Q,width:_.width,height:_.height,labelPlaneMatrix:w,lineVertexArray:null,pitchWithMap:p,projection:$,projectionCache:null,tileAnchorPoint:_e,translation:j,unwrappedTileID:G},Be=p?ae(_e.x,_e.y,D,Q):Pe(_e.x,_e.y,Ee),He=W(_.cameraToCenterDistance,Be.signedDistanceFromCamera);let nt=o.ai(k.textSizeData,R,ne)*He/o.ap;p&&(nt*=k.tilePixelRatio/P);const{width:ct,height:Xe,anchor:Ze,textOffset:_t,textBoxScale:Vt}=be,Je=Rp(Ze,ct,Xe,_t,Vt,nt),ot=$.getPitchedTextCorrection(_,_e.add(new o.P(j[0],j[1])),G),Bt=va(Be.point,Ee,l,Je,_.angle,ot),Gn=k.allowVerticalPlacement&&ne.placedOrientation===o.ah.vertical?Math.PI/2:0;for(let Gt=0;Gt<ne.numGlyphs;Gt++)o.aj(oe,Bt,Gn);V&&ne.associatedIconIndex>=0&&(ue[ne.associatedIconIndex]={shiftedAnchor:Bt,angle:Gn})}else At(ne.numGlyphs,oe)}if(V){ce.clear();const pe=k.icon.placedSymbolArray;for(let ne=0;ne<pe.length;ne++){const be=pe.get(ne);if(be.hidden)At(be.numGlyphs,ce);else{const _e=ue[ne];if(_e)for(let Ee=0;Ee<be.numGlyphs;Ee++)o.aj(ce,_e.shiftedAnchor,_e.angle);else At(be.numGlyphs,ce)}}k.icon.dynamicLayoutVertexBuffer.updateData(ce)}k.text.dynamicLayoutVertexBuffer.updateData(oe)}function rs(k,l,p){return p.iconsInText&&l?"symbolTextAndIcon":k?"symbolSDF":"symbolIcon"}function Np(k,l,p,b,_,w,D,P,R,V,$,j){const G=k.context,Q=G.gl,ee=k.transform,oe=fa(),ce=P==="map",ue=R==="map",pe=P!=="viewport"&&p.layout.get("symbol-placement")!=="point",ne=ce&&!ue&&!pe,be=!ue&&pe,_e=!p.layout.get("symbol-sort-key").isConstant();let Ee=!1;const Be=k.depthModeForSublayer(0,en.ReadOnly),He=p._unevaluatedLayout.hasValue("text-variable-anchor")||p._unevaluatedLayout.hasValue("text-variable-anchor-offset"),nt=[],ct=oe.getCircleRadiusCorrection(ee);for(const Xe of b){const Ze=l.getTile(Xe),_t=Ze.getBucket(p);if(!_t)continue;const Vt=_?_t.text:_t.icon;if(!Vt||!Vt.segments.get().length||!Vt.hasVisibleVertices)continue;const Je=Vt.programConfigurations.get(p.id),ot=_||_t.sdfIcons,Bt=_?_t.textSizeData:_t.iconSizeData,Gn=ue||ee.pitch!==0,Gt=k.useProgram(rs(ot,_,_t),Je),an=o.ag(Bt,ee.zoom),Yn=k.style.map.terrain&&k.style.map.terrain.getTerrainData(Xe);let Gr,Ss,Zn,wi,ci=[0,0],Yr=null;if(_)Ss=Ze.glyphAtlasTexture,Zn=Q.LINEAR,Gr=Ze.glyphAtlasTexture.size,_t.iconsInText&&(ci=Ze.imageAtlasTexture.size,Yr=Ze.imageAtlasTexture,wi=Gn||k.options.rotating||k.options.zooming||Bt.kind==="composite"||Bt.kind==="camera"?Q.LINEAR:Q.NEAREST);else{const un=p.layout.get("icon-size").constantOr(0)!==1||_t.iconsNeedLinear;Ss=Ze.imageAtlasTexture,Zn=ot||k.options.rotating||k.options.zooming||un||Gn?Q.LINEAR:Q.NEAREST,Gr=Ze.imageAtlasTexture.size}const di=on(Ze,1,k.transform.zoom),Xs=be?Xe.posMatrix:Nc,Pl=ai(Xs,ue,ce,k.transform,di),Ou=Bi(Xs,ue,ce,k.transform,di),Rl=Bi(Xe.posMatrix,ue,ce,k.transform,di),as=oe.translatePosition(k.transform,Ze,w,D),Bu=He&&_t.hasTextData(),of=p.layout.get("icon-text-fit")!=="none"&&Bu&&_t.hasIconData();if(pe){const un=k.style.map.terrain?(Nl,Ol)=>k.style.map.terrain.getElevation(Xe,Nl,Ol):null,Ca=p.layout.get("text-rotation-alignment")==="map";K(_t,Xe.posMatrix,k,_,Pl,Rl,ue,V,Ca,oe,Xe.toUnwrapped(),ee.width,ee.height,as,un)}const ls=Xe.posMatrix,cs=_&&He||of,Bo=pe||cs?Nc:Pl,Cs=Ou,Br=ot&&p.paint.get(_?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Zr;Zr=ot?_t.iconsInText?wp(Bt.kind,an,ne,ue,pe,cs,k,ls,Bo,Cs,as,Gr,ci,ct):Ic(Bt.kind,an,ne,ue,pe,cs,k,ls,Bo,Cs,as,_,Gr,!0,ct):ay(Bt.kind,an,ne,ue,pe,cs,k,ls,Bo,Cs,as,_,Gr,ct);const ji={program:Gt,buffers:Vt,uniformValues:Zr,atlasTexture:Ss,atlasTextureIcon:Yr,atlasInterpolation:Zn,atlasInterpolationIcon:wi,isSDF:ot,hasHalo:Br};if(_e&&_t.canOverlap){Ee=!0;const un=Vt.segments.get();for(const Ca of un)nt.push({segments:new o.a0([Ca]),sortKey:Ca.sortKey,state:ji,terrainData:Yn})}else nt.push({segments:Vt.segments,sortKey:0,state:ji,terrainData:Yn})}Ee&&nt.sort((Xe,Ze)=>Xe.sortKey-Ze.sortKey);for(const Xe of nt){const Ze=Xe.state;if(G.activeTexture.set(Q.TEXTURE0),Ze.atlasTexture.bind(Ze.atlasInterpolation,Q.CLAMP_TO_EDGE),Ze.atlasTextureIcon&&(G.activeTexture.set(Q.TEXTURE1),Ze.atlasTextureIcon&&Ze.atlasTextureIcon.bind(Ze.atlasInterpolationIcon,Q.CLAMP_TO_EDGE)),Ze.isSDF){const _t=Ze.uniformValues;Ze.hasHalo&&(_t.u_is_halo=1,Op(Ze.buffers,Xe.segments,p,k,Ze.program,Be,$,j,_t,Xe.terrainData)),_t.u_is_halo=0}Op(Ze.buffers,Xe.segments,p,k,Ze.program,Be,$,j,Ze.uniformValues,Xe.terrainData)}}function Op(k,l,p,b,_,w,D,P,R,V){const $=b.context;_.draw($,$.gl.TRIANGLES,w,D,P,On.disabled,R,V,p.id,k.layoutVertexBuffer,k.indexBuffer,l,p.paint,b.transform.zoom,k.programConfigurations.get(p.id),k.dynamicLayoutVertexBuffer,k.opacityVertexBuffer)}function Bp(k,l,p,b){const _=k.context,w=_.gl,D=$n.disabled,P=new dr([w.ONE,w.ONE],o.aM.transparent,[!0,!0,!0,!0]),R=l.getBucket(p);if(!R)return;const V=b.key;let $=p.heatmapFbos.get(V);$||($=Oc(_,l.tileSize,l.tileSize),p.heatmapFbos.set(V,$)),_.bindFramebuffer.set($.framebuffer),_.viewport.set([0,0,l.tileSize,l.tileSize]),_.clear({color:o.aM.transparent});const j=R.programConfigurations.get(p.id),G=k.useProgram("heatmap",j),Q=k.style.map.terrain.getTerrainData(b);G.draw(_,w.TRIANGLES,en.disabled,D,P,On.disabled,vi(b.posMatrix,l,k.transform.zoom,p.paint.get("heatmap-intensity")),Q,p.id,R.layoutVertexBuffer,R.indexBuffer,R.segments,p.paint,k.transform.zoom,j)}function wa(k,l,p){const b=k.context,_=b.gl;b.setColorMode(k.colorModeForRenderPass());const w=Bc(b,l),D=p.key,P=l.heatmapFbos.get(D);P&&(b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,P.colorAttachment.get()),b.activeTexture.set(_.TEXTURE1),w.bind(_.LINEAR,_.CLAMP_TO_EDGE),k.useProgram("heatmapTexture").draw(b,_.TRIANGLES,en.disabled,$n.disabled,k.colorModeForRenderPass(),On.disabled,lu(k,l,0,1),null,l.id,k.rasterBoundsBuffer,k.quadTriangleIndexBuffer,k.rasterBoundsSegments,l.paint,k.transform.zoom),P.destroy(),l.heatmapFbos.delete(D))}function Oc(k,l,p){var b,_;const w=k.gl,D=w.createTexture();w.bindTexture(w.TEXTURE_2D,D),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=k.HALF_FLOAT)!==null&&b!==void 0?b:w.UNSIGNED_BYTE,R=(_=k.RGBA16F)!==null&&_!==void 0?_:w.RGBA;w.texImage2D(w.TEXTURE_2D,0,R,l,p,0,w.RGBA,P,null);const V=k.createFramebuffer(l,p,!1,!1);return V.colorAttachment.set(D),V}function Bc(k,l){return l.colorRampTexture||(l.colorRampTexture=new Qe(k,l.colorRamp,k.gl.RGBA)),l.colorRampTexture}function yl(k,l,p,b,_){if(!p||!b||!b.imageAtlas)return;const w=b.imageAtlas.patternPositions;let D=w[p.to.toString()],P=w[p.from.toString()];if(!D&&P&&(D=P),!P&&D&&(P=D),!D||!P){const R=_.getPaintProperty(l);D=w[R],P=w[R]}D&&P&&k.setConstantPatternPositions(D,P)}function zc(k,l,p,b,_,w,D){const P=k.context.gl,R="fill-pattern",V=p.paint.get(R),$=V&&V.constantOr(1),j=p.getCrossfadeParameters();let G,Q,ee,oe,ce;D?(Q=$&&!p.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",G=P.LINES):(Q=$?"fillPattern":"fill",G=P.TRIANGLES);const ue=V.constantOr(null);for(const pe of b){const ne=l.getTile(pe);if($&&!ne.patternsLoaded())continue;const be=ne.getBucket(p);if(!be)continue;const _e=be.programConfigurations.get(p.id),Ee=k.useProgram(Q,_e),Be=k.style.map.terrain&&k.style.map.terrain.getTerrainData(pe);$&&(k.context.activeTexture.set(P.TEXTURE0),ne.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),_e.updatePaintBuffers(j)),yl(_e,R,ue,ne,p);const He=Be?pe:null,nt=k.translatePosMatrix(He?He.posMatrix:pe.posMatrix,ne,p.paint.get("fill-translate"),p.paint.get("fill-translate-anchor"));if(D){oe=be.indexBuffer2,ce=be.segments2;const ct=[P.drawingBufferWidth,P.drawingBufferHeight];ee=Q==="fillOutlinePattern"&&$?ry(nt,k,j,ne,ct):Av(nt,ct)}else oe=be.indexBuffer,ce=be.segments,ee=$?ny(nt,k,j,ne):pl(nt);Ee.draw(k.context,G,_,k.stencilModeForClipping(pe),w,On.disabled,ee,Be,p.id,be.layoutVertexBuffer,oe,ce,p.paint,k.transform.zoom,_e)}}function yu(k,l,p,b,_,w,D){const P=k.context,R=P.gl,V="fill-extrusion-pattern",$=p.paint.get(V),j=$.constantOr(1),G=p.getCrossfadeParameters(),Q=p.paint.get("fill-extrusion-opacity"),ee=$.constantOr(null);for(const oe of b){const ce=l.getTile(oe),ue=ce.getBucket(p);if(!ue)continue;const pe=k.style.map.terrain&&k.style.map.terrain.getTerrainData(oe),ne=ue.programConfigurations.get(p.id),be=k.useProgram(j?"fillExtrusionPattern":"fillExtrusion",ne);j&&(k.context.activeTexture.set(R.TEXTURE0),ce.imageAtlasTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),ne.updatePaintBuffers(G)),yl(ne,V,ee,ce,p);const _e=k.translatePosMatrix(oe.posMatrix,ce,p.paint.get("fill-extrusion-translate"),p.paint.get("fill-extrusion-translate-anchor")),Ee=p.paint.get("fill-extrusion-vertical-gradient"),Be=j?au(_e,k,Ee,Q,oe,G,ce):Mc(_e,k,Ee,Q);be.draw(P,P.gl.TRIANGLES,_,w,D,On.backCCW,Be,pe,p.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segments,p.paint,k.transform.zoom,ne,k.style.map.terrain&&ue.centroidVertexBuffer)}}function bl(k,l,p,b,_,w,D){const P=k.context,R=P.gl,V=p.fbo;if(!V)return;const $=k.useProgram("hillshade"),j=k.style.map.terrain&&k.style.map.terrain.getTerrainData(l);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,V.colorAttachment.get()),$.draw(P,R.TRIANGLES,_,w,D,On.disabled,((G,Q,ee,oe)=>{const ce=ee.paint.get("hillshade-shadow-color"),ue=ee.paint.get("hillshade-highlight-color"),pe=ee.paint.get("hillshade-accent-color");let ne=ee.paint.get("hillshade-illumination-direction")*(Math.PI/180);ee.paint.get("hillshade-illumination-anchor")==="viewport"&&(ne-=G.transform.angle);const be=!G.options.moving;return{u_matrix:oe?oe.posMatrix:G.transform.calculatePosMatrix(Q.tileID.toUnwrapped(),be),u_image:0,u_latrange:cu(0,Q.tileID),u_light:[ee.paint.get("hillshade-exaggeration"),ne],u_shadow:ce,u_highlight:ue,u_accent:pe}})(k,p,b,j?l:null),j,b.id,k.rasterBoundsBuffer,k.quadTriangleIndexBuffer,k.rasterBoundsSegments)}function _l(k,l,p,b,_,w){const D=k.context,P=D.gl,R=l.dem;if(R&&R.data){const V=R.dim,$=R.stride,j=R.getPixels();if(D.activeTexture.set(P.TEXTURE1),D.pixelStoreUnpackPremultiplyAlpha.set(!1),l.demTexture=l.demTexture||k.getTileTexture($),l.demTexture){const Q=l.demTexture;Q.update(j,{premultiply:!1}),Q.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else l.demTexture=new Qe(D,j,P.RGBA,{premultiply:!1}),l.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);D.activeTexture.set(P.TEXTURE0);let G=l.fbo;if(!G){const Q=new Qe(D,{width:V,height:V,data:null},P.RGBA);Q.bind(P.LINEAR,P.CLAMP_TO_EDGE),G=l.fbo=D.createFramebuffer(V,V,!0,!1),G.colorAttachment.set(Q.texture)}D.bindFramebuffer.set(G.framebuffer),D.viewport.set([0,0,V,V]),k.useProgram("hillshadePrepare").draw(D,P.TRIANGLES,b,_,w,On.disabled,((Q,ee)=>{const oe=ee.stride,ce=o.H();return o.aP(ce,0,o.X,-o.X,0,0,1),o.J(ce,ce,[0,-o.X,0]),{u_matrix:ce,u_image:1,u_dimension:[oe,oe],u_zoom:Q.overscaledZ,u_unpack:ee.getUnpackVector()}})(l.tileID,R),null,p.id,k.rasterBoundsBuffer,k.quadTriangleIndexBuffer,k.rasterBoundsSegments),l.needsHillshadePrepare=!1}}function xy(k,l,p,b,_,w){const D=b.paint.get("raster-fade-duration");if(!w&&D>0){const P=v.now(),R=(P-k.timeAdded)/D,V=l?(P-l.timeAdded)/D:-1,$=p.getSource(),j=_.coveringZoomLevel({tileSize:$.tileSize,roundZoom:$.roundZoom}),G=!l||Math.abs(l.tileID.overscaledZ-j)>Math.abs(k.tileID.overscaledZ-j),Q=G&&k.refreshedUponExpiration?1:o.ac(G?R:1-V,0,1);return k.refreshedUponExpiration&&R>=1&&(k.refreshedUponExpiration=!1),l?{opacity:1,mix:1-Q}:{opacity:Q,mix:0}}return{opacity:1,mix:0}}const zp=new o.aM(1,0,0,1),bn=new o.aM(0,1,0,1),bu=new o.aM(0,0,1,1),Hv=new o.aM(1,0,1,1),vy=new o.aM(0,1,1,1);function xl(k,l,p,b){_u(k,0,l+p/2,k.transform.width,p,b)}function wy(k,l,p,b){_u(k,l-p/2,0,p,k.transform.height,b)}function _u(k,l,p,b,_,w){const D=k.context,P=D.gl;P.enable(P.SCISSOR_TEST),P.scissor(l*k.pixelRatio,p*k.pixelRatio,b*k.pixelRatio,_*k.pixelRatio),D.clear({color:w}),P.disable(P.SCISSOR_TEST)}function ky(k,l,p){const b=k.context,_=b.gl,w=p.posMatrix,D=k.useProgram("debug"),P=en.disabled,R=$n.disabled,V=k.colorModeForRenderPass(),$="$debug",j=k.style.map.terrain&&k.style.map.terrain.getTerrainData(p);b.activeTexture.set(_.TEXTURE0);const G=l.getTileByID(p.key).latestRawTileData,Q=Math.floor((G&&G.byteLength||0)/1024),ee=l.getTile(p).tileSize,oe=512/Math.min(ee,512)*(p.overscaledZ/k.transform.zoom)*.5;let ce=p.canonical.toString();p.overscaledZ!==p.canonical.z&&(ce+=` => ${p.overscaledZ}`),function(ue,pe){ue.initDebugOverlayCanvas();const ne=ue.debugOverlayCanvas,be=ue.context.gl,_e=ue.debugOverlayCanvas.getContext("2d");_e.clearRect(0,0,ne.width,ne.height),_e.shadowColor="white",_e.shadowBlur=2,_e.lineWidth=1.5,_e.strokeStyle="white",_e.textBaseline="top",_e.font="bold 36px Open Sans, sans-serif",_e.fillText(pe,5,5),_e.strokeText(pe,5,5),ue.debugOverlayTexture.update(ne),ue.debugOverlayTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE)}(k,`${ce} ${Q}kB`),D.draw(b,_.TRIANGLES,P,R,dr.alphaBlended,On.disabled,Dc(w,o.aM.transparent,oe),null,$,k.debugBuffer,k.quadTriangleIndexBuffer,k.debugSegments),D.draw(b,_.LINE_STRIP,P,R,V,On.disabled,Dc(w,o.aM.red),j,$,k.debugBuffer,k.tileBorderIndexBuffer,k.debugSegments)}function Ey(k,l,p){const b=k.context,_=b.gl,w=k.colorModeForRenderPass(),D=new en(_.LEQUAL,en.ReadWrite,k.depthRangeFor3D),P=k.useProgram("terrain"),R=l.getTerrainMesh();b.bindFramebuffer.set(null),b.viewport.set([0,0,k.width,k.height]);for(const V of p){const $=k.renderToTexture.getTexture(V),j=l.getTerrainData(V.tileID);b.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,$.texture);const G=k.transform.calculatePosMatrix(V.tileID.toUnwrapped()),Q=l.getMeshFrameDelta(k.transform.zoom),ee=k.transform.calculateFogMatrix(V.tileID.toUnwrapped()),oe=xp(G,Q,ee,k.style.sky,k.transform.pitch);P.draw(b,_.TRIANGLES,D,$n.disabled,w,On.backCCW,oe,j,"terrain",R.vertexBuffer,R.indexBuffer,R.segments)}}class xu{constructor(l,p,b){this.vertexBuffer=l,this.indexBuffer=p,this.segments=b}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class vu{constructor(l,p){this.context=new jv(l),this.transform=p,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:o.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Ve.maxUnderzooming+Ve.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new bp}resize(l,p,b){if(this.width=Math.floor(l*b),this.height=Math.floor(p*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,p=new o.aX;p.emplaceBack(0,0),p.emplaceBack(o.X,0),p.emplaceBack(0,o.X),p.emplaceBack(o.X,o.X),this.tileExtentBuffer=l.createVertexBuffer(p,ma.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,ma.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(_,Nr.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,ma.members),this.viewportSegments=o.a0.simpleSegment(0,0,4,2);const D=new o.aZ;D.emplaceBack(0),D.emplaceBack(1),D.emplaceBack(3),D.emplaceBack(2),D.emplaceBack(0),this.tileBorderIndexBuffer=l.createIndexBuffer(D);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 $n({func:R.ALWAYS,mask:0},0,255,R.ZERO,R.ZERO,R.ZERO)}clearStencil(){const l=this.context,p=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,[p.drawingBufferWidth,p.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(l,p.TRIANGLES,en.disabled,this.stencilClearMode,dr.disabled,On.disabled,xi(b),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(l,p){if(this.currentStencilSource===l.source||!l.isTileClipped()||!p||!p.length)return;this.currentStencilSource=l.source;const b=this.context,_=b.gl;this.nextStencilID+p.length>256&&this.clearStencil(),b.setColorMode(dr.disabled),b.setDepthMode(en.disabled);const w=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const D of p){const P=this._tileClippingMaskIDs[D.key]=this.nextStencilID++,R=this.style.map.terrain&&this.style.map.terrain.getTerrainData(D);w.draw(b,_.TRIANGLES,en.disabled,new $n({func:_.ALWAYS,mask:0},P,255,_.KEEP,_.KEEP,_.REPLACE),dr.disabled,On.disabled,xi(D.posMatrix),R,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const l=this.nextStencilID++,p=this.context.gl;return new $n({func:p.NOTEQUAL,mask:255},l,255,p.KEEP,p.KEEP,p.REPLACE)}stencilModeForClipping(l){const p=this.context.gl;return new $n({func:p.EQUAL,mask:255},this._tileClippingMaskIDs[l.key],0,p.KEEP,p.KEEP,p.REPLACE)}stencilConfigForOverlap(l){const p=this.context.gl,b=l.sort((D,P)=>P.overscaledZ-D.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 D={};for(let P=0;P<w;P++)D[P+_]=new $n({func:p.GEQUAL,mask:255},P+this.nextStencilID,255,p.KEEP,p.KEEP,p.REPLACE);return this.nextStencilID+=w,[D,b]}return[{[_]:$n.disabled},b]}colorModeForRenderPass(){const l=this.context.gl;return this._showOverdrawInspector?new dr([l.CONSTANT_COLOR,l.ONE],new o.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?dr.unblended:dr.alphaBlended}depthModeForSublayer(l,p,b){if(!this.opaquePassEnabledForLayer())return en.disabled;const _=1-((1+this.currentLayer)*this.numSublayers+l)*this.depthEpsilon;return new en(b||this.context.gl.LEQUAL,p,[_,_])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(l,p){this.style=l,this.options=p,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={},D={},P={};for(const R in _){const V=_[R];V.used&&V.prepare(this.context),w[R]=V.getVisibleCoordinates(),D[R]=w[R].slice().reverse(),P[R]=V.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 V=this.style._layers[R];if(!V.hasOffscreenPass()||V.isHidden(this.transform.zoom))continue;const $=D[V.source];(V.type==="custom"||$.length)&&this.renderLayer(this,_[V.source],V,$)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:p.showOverdrawInspector?o.aM.black:o.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(R,V){const $=R.context,j=$.gl,G=((ue,pe,ne)=>({u_sky_color:ue.properties.get("sky-color"),u_horizon_color:ue.properties.get("horizon-color"),u_horizon:(pe.height/2+pe.getHorizon())*ne,u_sky_horizon_blend:ue.properties.get("sky-horizon-blend")*pe.height/2*ne}))(V,R.style.map.transform,R.pixelRatio),Q=new en(j.LEQUAL,en.ReadWrite,[0,1]),ee=$n.disabled,oe=R.colorModeForRenderPass(),ce=R.useProgram("sky");if(!V.mesh){const ue=new o.aX;ue.emplaceBack(-1,-1),ue.emplaceBack(1,-1),ue.emplaceBack(1,1),ue.emplaceBack(-1,1);const pe=new o.aY;pe.emplaceBack(0,1,2),pe.emplaceBack(0,2,3),V.mesh=new xu($.createVertexBuffer(ue,ma.members),$.createIndexBuffer(pe),o.a0.simpleSegment(0,0,ue.length,pe.length))}ce.draw($,j.TRIANGLES,Q,ee,oe,On.disabled,G,void 0,"sky",V.mesh.vertexBuffer,V.mesh.indexBuffer,V.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=p.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]],V=_[R.source],$=w[R.source];this._renderTileClippingMasks(R,$),this.renderLayer(this,V,R,$)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<b.length;this.currentLayer++){const R=this.style._layers[b[this.currentLayer]],V=_[R.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(R))continue;const $=(R.type==="symbol"?P:D)[R.source];this._renderTileClippingMasks(R,w[R.source]),this.renderLayer(this,V,R,$)}if(this.options.showTileBoundaries){const R=function(V,$){let j=null;const G=Object.values(V._layers).flatMap(ce=>ce.source&&!ce.isHidden($)?[V.sourceCaches[ce.source]]:[]),Q=G.filter(ce=>ce.getSource().type==="vector"),ee=G.filter(ce=>ce.getSource().type!=="vector"),oe=ce=>{(!j||j.getSource().maxzoom<ce.getSource().maxzoom)&&(j=ce)};return Q.forEach(ce=>oe(ce)),j||ee.forEach(ce=>oe(ce)),j}(this.style,this.transform.zoom);R&&function(V,$,j){for(let G=0;G<j.length;G++)ky(V,$,j[G])}(this,R,R.getVisibleCoordinates())}this.options.showPadding&&function(R){const V=R.transform.padding;xl(R,R.transform.height-(V.top||0),3,zp),xl(R,V.bottom||0,3,bn),wy(R,V.left||0,3,bu),wy(R,R.transform.width-(V.right||0),3,Hv);const $=R.transform.centerPoint;(function(j,G,Q,ee){_u(j,G-1,Q-10,2,20,ee),_u(j,G-10,Q-1,20,2,ee)})(R,$.x,R.transform.height-$.y,vy)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(l){if(!this.style||!this.style.map||!this.style.map.terrain)return;const p=this.terrainFacilitator.matrix,b=this.transform.modelViewProjectionMatrix;let _=this.terrainFacilitator.dirty;_||(_=l?!o.a_(p,b):!o.a$(p,b)),_||(_=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),_&&(o.b0(p,b),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(w,D){const P=w.context,R=P.gl,V=dr.unblended,$=new en(R.LEQUAL,en.ReadWrite,[0,1]),j=D.getTerrainMesh(),G=D.sourceCache.getRenderableTiles(),Q=w.useProgram("terrainDepth");P.bindFramebuffer.set(D.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1});for(const ee of G){const oe=D.getTerrainData(ee.tileID),ce={u_matrix:w.transform.calculatePosMatrix(ee.tileID.toUnwrapped()),u_ele_delta:D.getMeshFrameDelta(w.transform.zoom)};Q.draw(P,R.TRIANGLES,$,$n.disabled,V,On.backCCW,ce,oe,"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,D){const P=w.context,R=P.gl,V=dr.unblended,$=new en(R.LEQUAL,en.ReadWrite,[0,1]),j=D.getTerrainMesh(),G=D.getCoordsTexture(),Q=D.sourceCache.getRenderableTiles(),ee=w.useProgram("terrainCoords");P.bindFramebuffer.set(D.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,w.width/devicePixelRatio,w.height/devicePixelRatio]),P.clear({color:o.aM.transparent,depth:1}),D.coordsIndex=[];for(const oe of Q){const ce=D.getTerrainData(oe.tileID);P.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,G.texture);const ue={u_matrix:w.transform.calculatePosMatrix(oe.tileID.toUnwrapped()),u_terrain_coords_id:(255-D.coordsIndex.length)/255,u_texture:0,u_ele_delta:D.getMeshFrameDelta(w.transform.zoom)};ee.draw(P,R.TRIANGLES,$,$n.disabled,V,On.backCCW,ue,ce,"terrain",j.vertexBuffer,j.indexBuffer,j.segments),D.coordsIndex.push(oe.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,w.width,w.height])}(this,this.style.map.terrain))}renderLayer(l,p,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,D,P,R,V){if(w.renderPass!=="translucent")return;const $=$n.disabled,j=w.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(G,Q,ee,oe,ce,ue,pe,ne,be){const _e=Q.transform,Ee=fa(),Be=ce==="map",He=ue==="map";for(const nt of G){const ct=oe.getTile(nt),Xe=ct.getBucket(ee);if(!Xe||!Xe.text||!Xe.text.segments.get().length)continue;const Ze=o.ag(Xe.textSizeData,_e.zoom),_t=on(ct,1,Q.transform.zoom),Vt=ai(nt.posMatrix,He,Be,Q.transform,_t),Je=ee.layout.get("icon-text-fit")!=="none"&&Xe.hasIconData();if(Ze){const ot=Math.pow(2,_e.zoom-ct.tileID.overscaledZ),Bt=Q.style.map.terrain?(Gt,an)=>Q.style.map.terrain.getElevation(nt,Gt,an):null,Gn=Ee.translatePosition(_e,ct,pe,ne);gl(Xe,Be,He,be,_e,Vt,nt.posMatrix,ot,Ze,Je,Ee,Gn,nt.toUnwrapped(),Bt)}}}(R,w,P,D,P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),V),P.paint.get("icon-opacity").constantOr(1)!==0&&Np(w,D,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&&Np(w,D,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),D.map.showCollisionBoxes&&(Rc(w,D,P,R,!0),Rc(w,D,P,R,!1))})(l,p,b,_,this.style.placement.variableOffsets);break;case"circle":(function(w,D,P,R){if(w.renderPass!=="translucent")return;const V=P.paint.get("circle-opacity"),$=P.paint.get("circle-stroke-width"),j=P.paint.get("circle-stroke-opacity"),G=!P.layout.get("circle-sort-key").isConstant();if(V.constantOr(1)===0&&($.constantOr(1)===0||j.constantOr(1)===0))return;const Q=w.context,ee=Q.gl,oe=w.depthModeForSublayer(0,en.ReadOnly),ce=$n.disabled,ue=w.colorModeForRenderPass(),pe=[];for(let ne=0;ne<R.length;ne++){const be=R[ne],_e=D.getTile(be),Ee=_e.getBucket(P);if(!Ee)continue;const Be=Ee.programConfigurations.get(P.id),He=w.useProgram("circle",Be),nt=Ee.layoutVertexBuffer,ct=Ee.indexBuffer,Xe=w.style.map.terrain&&w.style.map.terrain.getTerrainData(be),Ze={programConfiguration:Be,program:He,layoutVertexBuffer:nt,indexBuffer:ct,uniformValues:Mv(w,be,_e,P),terrainData:Xe};if(G){const _t=Ee.segments.get();for(const Vt of _t)pe.push({segments:new o.a0([Vt]),sortKey:Vt.sortKey,state:Ze})}else pe.push({segments:Ee.segments,sortKey:0,state:Ze})}G&&pe.sort((ne,be)=>ne.sortKey-be.sortKey);for(const ne of pe){const{programConfiguration:be,program:_e,layoutVertexBuffer:Ee,indexBuffer:Be,uniformValues:He,terrainData:nt}=ne.state;_e.draw(Q,ee.TRIANGLES,oe,ce,ue,On.disabled,He,nt,P.id,Ee,Be,ne.segments,P.paint,w.transform.zoom,be)}})(l,p,b,_);break;case"heatmap":(function(w,D,P,R){if(P.paint.get("heatmap-opacity")===0)return;const V=w.context;if(w.style.map.terrain){for(const $ of R){const j=D.getTile($);D.hasRenderableParent($)||(w.renderPass==="offscreen"?Bp(w,j,P,$):w.renderPass==="translucent"&&wa(w,P,$))}V.viewport.set([0,0,w.width,w.height])}else w.renderPass==="offscreen"?function($,j,G,Q){const ee=$.context,oe=ee.gl,ce=$n.disabled,ue=new dr([oe.ONE,oe.ONE],o.aM.transparent,[!0,!0,!0,!0]);(function(pe,ne,be){const _e=pe.gl;pe.activeTexture.set(_e.TEXTURE1),pe.viewport.set([0,0,ne.width/4,ne.height/4]);let Ee=be.heatmapFbos.get(o.aU);Ee?(_e.bindTexture(_e.TEXTURE_2D,Ee.colorAttachment.get()),pe.bindFramebuffer.set(Ee.framebuffer)):(Ee=Oc(pe,ne.width/4,ne.height/4),be.heatmapFbos.set(o.aU,Ee))})(ee,$,G),ee.clear({color:o.aM.transparent});for(let pe=0;pe<Q.length;pe++){const ne=Q[pe];if(j.hasRenderableParent(ne))continue;const be=j.getTile(ne),_e=be.getBucket(G);if(!_e)continue;const Ee=_e.programConfigurations.get(G.id),Be=$.useProgram("heatmap",Ee),{zoom:He}=$.transform;Be.draw(ee,oe.TRIANGLES,en.disabled,ce,ue,On.disabled,vi(ne.posMatrix,be,He,G.paint.get("heatmap-intensity")),null,G.id,_e.layoutVertexBuffer,_e.indexBuffer,_e.segments,G.paint,$.transform.zoom,Ee)}ee.viewport.set([0,0,$.width,$.height])}(w,D,P,R):w.renderPass==="translucent"&&function($,j){const G=$.context,Q=G.gl;G.setColorMode($.colorModeForRenderPass());const ee=j.heatmapFbos.get(o.aU);ee&&(G.activeTexture.set(Q.TEXTURE0),Q.bindTexture(Q.TEXTURE_2D,ee.colorAttachment.get()),G.activeTexture.set(Q.TEXTURE1),Bc(G,j).bind(Q.LINEAR,Q.CLAMP_TO_EDGE),$.useProgram("heatmapTexture").draw(G,Q.TRIANGLES,en.disabled,$n.disabled,$.colorModeForRenderPass(),On.disabled,lu($,j,0,1),null,j.id,$.viewportBuffer,$.quadTriangleIndexBuffer,$.viewportSegments,j.paint,$.transform.zoom))}(w,P)})(l,p,b,_);break;case"line":(function(w,D,P,R){if(w.renderPass!=="translucent")return;const V=P.paint.get("line-opacity"),$=P.paint.get("line-width");if(V.constantOr(1)===0||$.constantOr(1)===0)return;const j=w.depthModeForSublayer(0,en.ReadOnly),G=w.colorModeForRenderPass(),Q=P.paint.get("line-dasharray"),ee=P.paint.get("line-pattern"),oe=ee.constantOr(1),ce=P.paint.get("line-gradient"),ue=P.getCrossfadeParameters(),pe=oe?"linePattern":Q?"lineSDF":ce?"lineGradient":"line",ne=w.context,be=ne.gl;let _e=!0;for(const Ee of R){const Be=D.getTile(Ee);if(oe&&!Be.patternsLoaded())continue;const He=Be.getBucket(P);if(!He)continue;const nt=He.programConfigurations.get(P.id),ct=w.context.program.get(),Xe=w.useProgram(pe,nt),Ze=_e||Xe.program!==ct,_t=w.style.map.terrain&&w.style.map.terrain.getTerrainData(Ee),Vt=ee.constantOr(null);if(Vt&&Be.imageAtlas){const Bt=Be.imageAtlas,Gn=Bt.patternPositions[Vt.to.toString()],Gt=Bt.patternPositions[Vt.from.toString()];Gn&&Gt&&nt.setConstantPatternPositions(Gn,Gt)}const Je=_t?Ee:null,ot=oe?fl(w,Be,P,ue,Je):Q?Dv(w,Be,P,Q,ue,Je):ce?iy(w,Be,P,He.lineClipsArray.length,Je):du(w,Be,P,Je);if(oe)ne.activeTexture.set(be.TEXTURE0),Be.imageAtlasTexture.bind(be.LINEAR,be.CLAMP_TO_EDGE),nt.updatePaintBuffers(ue);else if(Q&&(Ze||w.lineAtlas.dirty))ne.activeTexture.set(be.TEXTURE0),w.lineAtlas.bind(ne);else if(ce){const Bt=He.gradients[P.id];let Gn=Bt.texture;if(P.gradientVersion!==Bt.version){let Gt=256;if(P.stepInterpolant){const an=D.getSource().maxzoom,Yn=Ee.canonical.z===an?Math.ceil(1<<w.transform.maxZoom-Ee.canonical.z):1;Gt=o.ac(o.aV(He.maxLineLength/o.X*1024*Yn),256,ne.maxTextureSize)}Bt.gradient=o.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:Gt,image:Bt.gradient||void 0,clips:He.lineClipsArray}),Bt.texture?Bt.texture.update(Bt.gradient):Bt.texture=new Qe(ne,Bt.gradient,be.RGBA),Bt.version=P.gradientVersion,Gn=Bt.texture}ne.activeTexture.set(be.TEXTURE0),Gn.bind(P.stepInterpolant?be.NEAREST:be.LINEAR,be.CLAMP_TO_EDGE)}Xe.draw(ne,be.TRIANGLES,j,w.stencilModeForClipping(Ee),G,On.disabled,ot,_t,P.id,He.layoutVertexBuffer,He.indexBuffer,He.segments,P.paint,w.transform.zoom,nt,He.layoutVertexBuffer2),_e=!1}})(l,p,b,_);break;case"fill":(function(w,D,P,R){const V=P.paint.get("fill-color"),$=P.paint.get("fill-opacity");if($.constantOr(1)===0)return;const j=w.colorModeForRenderPass(),G=P.paint.get("fill-pattern"),Q=w.opaquePassEnabledForLayer()&&!G.constantOr(1)&&V.constantOr(o.aM.transparent).a===1&&$.constantOr(0)===1?"opaque":"translucent";if(w.renderPass===Q){const ee=w.depthModeForSublayer(1,w.renderPass==="opaque"?en.ReadWrite:en.ReadOnly);zc(w,D,P,R,ee,j,!1)}if(w.renderPass==="translucent"&&P.paint.get("fill-antialias")){const ee=w.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,en.ReadOnly);zc(w,D,P,R,ee,j,!0)}})(l,p,b,_);break;case"fill-extrusion":(function(w,D,P,R){const V=P.paint.get("fill-extrusion-opacity");if(V!==0&&w.renderPass==="translucent"){const $=new en(w.context.gl.LEQUAL,en.ReadWrite,w.depthRangeFor3D);if(V!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))yu(w,D,P,R,$,$n.disabled,dr.disabled),yu(w,D,P,R,$,w.stencilModeFor3D(),w.colorModeForRenderPass());else{const j=w.colorModeForRenderPass();yu(w,D,P,R,$,$n.disabled,j)}}})(l,p,b,_);break;case"hillshade":(function(w,D,P,R){if(w.renderPass!=="offscreen"&&w.renderPass!=="translucent")return;const V=w.context,$=w.depthModeForSublayer(0,en.ReadOnly),j=w.colorModeForRenderPass(),[G,Q]=w.renderPass==="translucent"?w.stencilConfigForOverlap(R):[{},R];for(const ee of Q){const oe=D.getTile(ee);oe.needsHillshadePrepare!==void 0&&oe.needsHillshadePrepare&&w.renderPass==="offscreen"?_l(w,oe,P,$,$n.disabled,j):w.renderPass==="translucent"&&bl(w,ee,oe,P,$,G[ee.overscaledZ],j)}V.viewport.set([0,0,w.width,w.height])})(l,p,b,_);break;case"raster":(function(w,D,P,R){if(w.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!R.length)return;const V=w.context,$=V.gl,j=D.getSource(),G=w.useProgram("raster"),Q=w.colorModeForRenderPass(),[ee,oe]=j instanceof gr?[{},R]:w.stencilConfigForOverlap(R),ce=oe[oe.length-1].overscaledZ,ue=!w.options.moving;for(const pe of oe){const ne=w.depthModeForSublayer(pe.overscaledZ-ce,P.paint.get("raster-opacity")===1?en.ReadWrite:en.ReadOnly,$.LESS),be=D.getTile(pe);be.registerFadeDuration(P.paint.get("raster-fade-duration"));const _e=D.findLoadedParent(pe,0),Ee=D.findLoadedSibling(pe),Be=xy(be,_e||Ee||null,D,P,w.transform,w.style.map.terrain);let He,nt;const ct=P.paint.get("raster-resampling")==="nearest"?$.NEAREST:$.LINEAR;V.activeTexture.set($.TEXTURE0),be.texture.bind(ct,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),V.activeTexture.set($.TEXTURE1),_e?(_e.texture.bind(ct,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),He=Math.pow(2,_e.tileID.overscaledZ-be.tileID.overscaledZ),nt=[be.tileID.canonical.x*He%1,be.tileID.canonical.y*He%1]):be.texture.bind(ct,$.CLAMP_TO_EDGE,$.LINEAR_MIPMAP_NEAREST),be.texture.useMipmap&&V.extTextureFilterAnisotropic&&w.transform.pitch>20&&$.texParameterf($.TEXTURE_2D,V.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,V.extTextureFilterAnisotropicMax);const Xe=w.style.map.terrain&&w.style.map.terrain.getTerrainData(pe),Ze=Xe?pe:null,_t=Ze?Ze.posMatrix:w.transform.calculatePosMatrix(pe.toUnwrapped(),ue),Vt=Iv(_t,nt||[0,0],He||1,Be,P);j instanceof gr?G.draw(V,$.TRIANGLES,ne,$n.disabled,Q,On.disabled,Vt,Xe,P.id,j.boundsBuffer,w.quadTriangleIndexBuffer,j.boundsSegments):G.draw(V,$.TRIANGLES,ne,ee[pe.overscaledZ],Q,On.disabled,Vt,Xe,P.id,w.rasterBoundsBuffer,w.quadTriangleIndexBuffer,w.rasterBoundsSegments)}})(l,p,b,_);break;case"background":(function(w,D,P,R){const V=P.paint.get("background-color"),$=P.paint.get("background-opacity");if($===0)return;const j=w.context,G=j.gl,Q=w.transform,ee=Q.tileSize,oe=P.paint.get("background-pattern");if(w.isPatternMissing(oe))return;const ce=!oe&&V.a===1&&$===1&&w.opaquePassEnabledForLayer()?"opaque":"translucent";if(w.renderPass!==ce)return;const ue=$n.disabled,pe=w.depthModeForSublayer(0,ce==="opaque"?en.ReadWrite:en.ReadOnly),ne=w.colorModeForRenderPass(),be=w.useProgram(oe?"backgroundPattern":"background"),_e=R||Q.coveringTiles({tileSize:ee,terrain:w.style.map.terrain});oe&&(j.activeTexture.set(G.TEXTURE0),w.imageManager.bind(w.context));const Ee=P.getCrossfadeParameters();for(const Be of _e){const He=R?Be.posMatrix:w.transform.calculatePosMatrix(Be.toUnwrapped()),nt=oe?kp(He,$,w,oe,{tileID:Be,tileSize:ee},Ee):uu(He,$,V),ct=w.style.map.terrain&&w.style.map.terrain.getTerrainData(Be);be.draw(j,G.TRIANGLES,pe,ue,ne,On.disabled,nt,ct,P.id,w.tileExtentBuffer,w.quadTriangleIndexBuffer,w.tileExtentSegments)}})(l,0,b,_);break;case"custom":(function(w,D,P){const R=w.context,V=P.implementation;if(w.renderPass==="offscreen"){const $=V.prerender;$&&(w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),$.call(V,R.gl,w.transform.customLayerMatrix()),R.setDirty(),w.setBaseState())}else if(w.renderPass==="translucent"){w.setCustomLayerDefaults(),R.setColorMode(w.colorModeForRenderPass()),R.setStencilMode($n.disabled);const $=V.renderingMode==="3d"?new en(w.context.gl.LEQUAL,en.ReadWrite,w.depthRangeFor3D):w.depthModeForSublayer(0,en.ReadOnly);R.setDepthMode($),V.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,p,b,_,w){if(!b[0]&&!b[1])return l;const D=w?_==="map"?this.transform.angle:0:_==="viewport"?-this.transform.angle:0;if(D){const V=Math.sin(D),$=Math.cos(D);b=[b[0]*$-b[1]*V,b[0]*V+b[1]*$]}const P=[w?b[0]:on(p,b[0],this.transform.zoom),w?b[1]:on(p,b[1],this.transform.zoom),0],R=new Float32Array(16);return o.J(R,l,P),R}saveTileTexture(l){const p=this._tileTextures[l.size[0]];p?p.push(l):this._tileTextures[l.size[0]]=[l]}getTileTexture(l){const p=this._tileTextures[l];return p&&p.length>0?p.pop():null}isPatternMissing(l){if(!l)return!1;if(!l.from||!l.to)return!0;const p=this.imageManager.getPattern(l.from.toString()),b=this.imageManager.getPattern(l.to.toString());return!p||!b}useProgram(l,p){this.cache=this.cache||{};const b=l+(p?p.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[b]||(this.cache[b]=new vp(this.context,No[l],p,Ep[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 Qe(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:l,drawingBufferHeight:p}=this.context.gl;return this.width!==l||this.height!==p}}class vl{constructor(l,p){this.points=l,this.planes=p}static fromInvProjectionMatrix(l,p,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]/p*_;return o.b1(P,P,[R,R,1/P[3],R])}),D=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const R=function(G,Q){var ee=Q[0],oe=Q[1],ce=Q[2],ue=ee*ee+oe*oe+ce*ce;return ue>0&&(ue=1/Math.sqrt(ue)),G[0]=Q[0]*ue,G[1]=Q[1]*ue,G[2]=Q[2]*ue,G}([],function(G,Q,ee){var oe=Q[0],ce=Q[1],ue=Q[2],pe=ee[0],ne=ee[1],be=ee[2];return G[0]=ce*be-ue*ne,G[1]=ue*pe-oe*be,G[2]=oe*ne-ce*pe,G}([],Te([],w[P[0]],w[P[1]]),Te([],w[P[2]],w[P[1]]))),V=-(($=R)[0]*(j=w[P[1]])[0]+$[1]*j[1]+$[2]*j[2]);var $,j;return R.concat(V)});return new vl(w,D)}}class wl{constructor(l,p){this.min=l,this.max=p,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 p=[l%2==0,l<2],b=Se(this.min),_=Se(this.max);for(let w=0;w<p.length;w++)b[w]=p[w]?this.min[w]:this.center[w],_[w]=p[w]?this.center[w]:this.max[w];return _[2]=this.max[2],new wl(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 p=[[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 D=0;for(let P=0;P<p.length;P++)o.b2(w,p[P])>=0&&D++;if(D===0)return 0;D!==p.length&&(b=!1)}if(b)return 2;for(let _=0;_<3;_++){let w=Number.MAX_VALUE,D=-Number.MAX_VALUE;for(let P=0;P<l.points.length;P++){const R=l.points[P][_]-this.min[_];w=Math.min(w,R),D=Math.max(D,R)}if(D<0||w>this.max[_]-this.min[_])return 0}return 1}}class kl{constructor(l=0,p=0,b=0,_=0){if(isNaN(l)||l<0||isNaN(p)||p<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=p,this.left=b,this.right=_}interpolate(l,p,b){return p.top!=null&&l.top!=null&&(this.top=o.y.number(l.top,p.top,b)),p.bottom!=null&&l.bottom!=null&&(this.bottom=o.y.number(l.bottom,p.bottom,b)),p.left!=null&&l.left!=null&&(this.left=o.y.number(l.left,p.left,b)),p.right!=null&&l.right!=null&&(this.right=o.y.number(l.right,p.right,b)),this}getCenter(l,p){const b=o.ac((this.left+l-this.right)/2,0,l),_=o.ac((this.top+p-this.bottom)/2,0,p);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 kl(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const Vp=85.051129;class El{constructor(l,p,b,_,w){this.tileSize=512,this._renderWorldCopies=w===void 0||!!w,this._minZoom=l||0,this._maxZoom=p||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 kl,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const l=new El(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 p=-o.b3(l,-180,180)*Math.PI/180;this.angle!==p&&(this._unmodified=!1,this.angle=p,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 D=_[0],P=_[1],R=_[2],V=_[3],$=Math.sin(w),j=Math.cos(w);b[0]=D*j+R*$,b[1]=P*j+V*$,b[2]=D*-$+R*j,b[3]=P*-$+V*j}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(l){const p=o.ac(l,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==p&&(this._unmodified=!1,this._pitch=p,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 p=Math.min(Math.max(l,this.minZoom),this.maxZoom);this._zoom!==p&&(this._unmodified=!1,this._zoom=p,this.tileZoom=Math.max(0,Math.floor(p)),this.scale=this.zoomScale(p),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,p,b){this._unmodified=!1,this._edgeInsets.interpolate(l,p,b),this._constrain(),this._calcMatrices()}coveringZoomLevel(l){const p=(l.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/l.tileSize));return Math.max(0,p)}getVisibleUnwrappedCoordinates(l){const p=[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)),D=this.pointCoordinate(new o.P(0,this.height)),P=Math.floor(Math.min(b.x,_.x,w.x,D.x)),R=Math.floor(Math.max(b.x,_.x,w.x,D.x)),V=1;for(let $=P-V;$<=R+V;$++)$!==0&&p.push(new o.b4($,l))}return p}coveringTiles(l){var p,b;let _=this.coveringZoomLevel(l);const w=_;if(l.minzoom!==void 0&&_<l.minzoom)return[];l.maxzoom!==void 0&&_>l.maxzoom&&(_=l.maxzoom);const D=this.pointCoordinate(this.getCameraPoint()),P=o.Z.fromLngLat(this.center),R=Math.pow(2,_),V=[R*D.x,R*D.y,0],$=[R*P.x,R*P.y,0],j=vl.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,_);let G=l.minzoom||0;!l.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(G=_);const Q=l.terrain?2/Math.min(this.tileSize,l.tileSize)*this.tileSize:3,ee=ne=>({aabb:new wl([ne*R,0,0],[(ne+1)*R,R,0]),zoom:0,x:0,y:0,wrap:ne,fullyVisible:!1}),oe=[],ce=[],ue=_,pe=l.reparseOverscaled?w:_;if(this._renderWorldCopies)for(let ne=1;ne<=3;ne++)oe.push(ee(-ne)),oe.push(ee(ne));for(oe.push(ee(0));oe.length>0;){const ne=oe.pop(),be=ne.x,_e=ne.y;let Ee=ne.fullyVisible;if(!Ee){const Xe=ne.aabb.intersects(j);if(Xe===0)continue;Ee=Xe===2}const Be=l.terrain?V:$,He=ne.aabb.distanceX(Be),nt=ne.aabb.distanceY(Be),ct=Math.max(Math.abs(He),Math.abs(nt));if(ne.zoom===ue||ct>Q+(1<<ue-ne.zoom)-2&&ne.zoom>=G){const Xe=ue-ne.zoom,Ze=V[0]-.5-(be<<Xe),_t=V[1]-.5-(_e<<Xe);ce.push({tileID:new o.S(ne.zoom===ue?pe:ne.zoom,ne.wrap,ne.zoom,be,_e),distanceSq:Ne([$[0]-.5-be,$[1]-.5-_e]),tileDistanceToCamera:Math.sqrt(Ze*Ze+_t*_t)})}else for(let Xe=0;Xe<4;Xe++){const Ze=(be<<1)+Xe%2,_t=(_e<<1)+(Xe>>1),Vt=ne.zoom+1;let Je=ne.aabb.quadrant(Xe);if(l.terrain){const ot=new o.S(Vt,ne.wrap,Vt,Ze,_t),Bt=l.terrain.getMinMaxElevation(ot),Gn=(p=Bt.minElevation)!==null&&p!==void 0?p:this.elevation,Gt=(b=Bt.maxElevation)!==null&&b!==void 0?b:this.elevation;Je=new wl([Je.min[0],Je.min[1],Gn],[Je.max[0],Je.max[1],Gt])}oe.push({aabb:Je,zoom:Vt,x:Ze,y:_t,wrap:ne.wrap,fullyVisible:Ee})}}return ce.sort((ne,be)=>ne.distanceSq-be.distanceSq).map(ne=>ne.tileID)}resize(l,p){this.width=l,this.height=p,this.pixelsToGLUnits=[2/l,-2/p],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 p=o.ac(l.lat,-85.051129,Vp);return new o.P(o.O(l.lng)*this.worldSize,o.Q(p)*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 p=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 D=b+p-w,P=Math.cos(this._pitch)*this.cameraToCenterDistance/D/o.b5(1,_.lat),R=this.scaleZoom(P/this.tileSize);this._elevation=w,this._center=_,this.zoom=R}setLocationAtPoint(l,p){const b=this.pointCoordinate(p),_=this.pointCoordinate(this.centerPoint),w=this.locationCoordinate(l),D=new o.Z(w.x-(b.x-_.x),w.y-(b.y-_.y));this.center=this.coordinateLocation(D),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(l,p){return p?this.coordinatePoint(this.locationCoordinate(l),p.getElevationForLngLatZoom(l,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(l))}pointLocation(l,p){return this.coordinateLocation(this.pointCoordinate(l,p))}locationCoordinate(l){return o.Z.fromLngLat(l)}coordinateLocation(l){return l&&l.toLngLat()}pointCoordinate(l,p){if(p){const G=p.pointCoordinate(l);if(G!=null)return G}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],D=_[3],P=b[1]/w,R=_[1]/D,V=b[2]/w,$=_[2]/D,j=V===$?0:(0-V)/($-V);return new o.Z(o.y.number(b[0]/w,_[0]/D,j)/this.worldSize,o.y.number(P,R,j)/this.worldSize)}coordinatePoint(l,p=0,b=this.pixelMatrix){const _=[l.x*this.worldSize,l.y*this.worldSize,p,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 Ce().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 Ce([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,Vp])}calculateTileMatrix(l){const p=l.canonical,b=this.worldSize/this.zoomScale(p.z),_=p.x+Math.pow(2,p.z)*l.wrap,w=o.an(new Float64Array(16));return o.J(w,w,[_*b,p.y*b,0]),o.K(w,w,[b/o.X,b/o.X,1]),w}calculatePosMatrix(l,p=!1){const b=l.key,_=p?this._alignedPosMatrixCache:this._posMatrixCache;if(_[b])return _[b];const w=this.calculateTileMatrix(l);return o.L(w,p?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,w),_[b]=new Float32Array(w),_[b]}calculateFogMatrix(l){const p=l.key,b=this._fogMatrixCache;if(b[p])return b[p];const _=this.calculateTileMatrix(l);return o.L(_,this.fogMatrix,_),b[p]=new Float32Array(_),b[p]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(l,p){p=o.ac(+p,this.minZoom,this.maxZoom);const b={center:new o.N(l.lng,l.lat),zoom:p};let _=this.lngRange;if(!this._renderWorldCopies&&_===null){const ne=179.9999999999;_=[-ne,ne]}const w=this.tileSize*this.zoomScale(b.zoom);let D=0,P=w,R=0,V=w,$=0,j=0;const{x:G,y:Q}=this.size;if(this.latRange){const ne=this.latRange;D=o.Q(ne[1])*w,P=o.Q(ne[0])*w,P-D<Q&&($=Q/(P-D))}_&&(R=o.b3(o.O(_[0])*w,0,w),V=o.b3(o.O(_[1])*w,0,w),V<R&&(V+=w),V-R<G&&(j=G/(V-R)));const{x:ee,y:oe}=this.project.call({worldSize:w},l);let ce,ue;const pe=Math.max(j||0,$||0);if(pe){const ne=new o.P(j?(V+R)/2:ee,$?(P+D)/2:oe);return b.center=this.unproject.call({worldSize:w},ne).wrap(),b.zoom+=this.scaleZoom(pe),b}if(this.latRange){const ne=Q/2;oe-ne<D&&(ue=D+ne),oe+ne>P&&(ue=P-ne)}if(_){const ne=(R+V)/2;let be=ee;this._renderWorldCopies&&(be=o.b3(ee,ne-w/2,ne+w/2));const _e=G/2;be-_e<R&&(ce=R+_e),be+_e>V&&(ce=V-_e)}if(ce!==void 0||ue!==void 0){const ne=new o.P(ce??ee,ue??oe);b.center=this.unproject.call({worldSize:w},ne).wrap()}return b}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const l=this._unmodified,{center:p,zoom:b}=this.getConstrained(this.center,this.zoom);this.center=p,this.zoom=b,this._unmodified=l,this._constraining=!1}_calcMatrices(){if(!this.height)return;const l=this.centerOffset,p=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),D=Math.min(this.elevation,this.minElevationForCurrentTile),P=w-D*this._pixelPerMeter/Math.cos(this._pitch),R=D<0?P:w,V=Math.PI/2+this._pitch,$=this._fov*(.5+l.y/this.height),j=Math.sin($)*R/Math.sin(o.ac(Math.PI-V-$,.01,Math.PI-.01)),G=this.getHorizon(),Q=2*Math.atan(G/this.cameraToCenterDistance)*(.5+l.y/(2*G)),ee=Math.sin(Q)*R/Math.sin(o.ac(Math.PI-V-Q,.01,Math.PI-.01)),oe=Math.min(j,ee);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*oe+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(_,_,[-p,-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,[-p,-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 ce=this.width%2/2,ue=this.height%2/2,pe=Math.cos(this.angle),ne=Math.sin(this.angle),be=p-Math.round(p)+pe*ce+ne*ue,_e=b-Math.round(b)+pe*ue+ne*ce,Ee=new Float64Array(_);if(o.J(Ee,Ee,[be>.5?be-1:be,_e>.5?_e-1:_e,0]),this.alignedModelViewProjectionMatrix=Ee,_=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)),p=[l.x*this.worldSize,l.y*this.worldSize,0,1];return o.af(p,p,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 p=this.getCameraPoint();if(l.length===1)return[l[0],p];{let b=p.x,_=p.y,w=p.x,D=p.y;for(const P of l)b=Math.min(b,P.x),_=Math.min(_,P.y),w=Math.max(w,P.x),D=Math.max(D,P.y);return[new o.P(b,_),new o.P(w,_),new o.P(w,D),new o.P(b,D),new o.P(b,_)]}}lngLatToCameraDepth(l,p){const b=this.locationCoordinate(l),_=[b.x*this.worldSize,b.y*this.worldSize,p,1];return o.af(_,_,this.modelViewProjectionMatrix),_[2]/_[3]}}function Vc(k,l){let p,b=!1,_=null,w=null;const D=()=>{_=null,b&&(k.apply(w,p),_=setTimeout(D,l),b=!1)};return(...P)=>(b=!0,w=this,p=P,_||D(),_)}class wu{constructor(l){this._getCurrentHash=()=>{const p=window.location.hash.replace("#","");if(this._hashName){let b;return p.split("&").map(_=>_.split("=")).forEach(_=>{_[0]===this._hashName&&(b=_)}),(b&&b[1]||"").split("/")}return p.split("/")},this._onHashChange=()=>{const p=this._getCurrentHash();if(p.length>=3&&!p.some(b=>isNaN(b))){const b=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(p[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+p[2],+p[1]],zoom:+p[0],bearing:b,pitch:+(p[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const p=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,p)},this._removeHash=()=>{const p=this._getCurrentHash();if(p.length===0)return;const b=p.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 D=window.location.href.replace(/(#.+)?$/,w);D=D.replace("&&","&"),window.history.replaceState(window.history.state,null,D)},this._updateHash=Vc(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 p=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,_),D=Math.round(p.lng*w)/w,P=Math.round(p.lat*w)/w,R=this._map.getBearing(),V=this._map.getPitch();let $="";if($+=l?`/${D}/${P}/${b}`:`${b}/${P}/${D}`,(R||V)&&($+="/"+Math.round(10*R)/10),V&&($+=`/${Math.round(V)}`),this._hashName){const j=this._hashName;let G=!1;const Q=window.location.hash.slice(1).split("&").map(ee=>{const oe=ee.split("=")[0];return oe===j?(G=!0,`${oe}=${$}`):ee}).filter(ee=>ee);return G||Q.push(`${j}=${$}`),`#${Q.join("&")}`}return`#${$}`}}const ku={linearity:.3,easing:o.b8(0,0,.3,1)},Lp=o.e({deceleration:2500,maxSpeed:1400},ku),Uv=o.e({deceleration:20,maxSpeed:1400},ku),Sy=o.e({deceleration:1e3,maxSpeed:360},ku),Eu=o.e({deceleration:1e3,maxSpeed:90},ku);class Fp{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,p=v.now();for(;l.length>0&&p-l[0].time>160;)l.shift()}_onMoveEnd(l){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const p={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)p.zoom+=w.zoomDelta||0,p.bearing+=w.bearingDelta||0,p.pitch+=w.pitchDelta||0,w.panDelta&&p.pan._add(w.panDelta),w.around&&(p.around=w.around),w.pinchAround&&(p.pinchAround=w.pinchAround);const b=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(p.pan.mag()){const w=Fc(p.pan.mag(),b,o.e({},Lp,l||{}));_.offset=p.pan.mult(w.amount/p.pan.mag()),_.center=this._map.transform.center,Lc(_,w)}if(p.zoom){const w=Fc(p.zoom,b,Uv);_.zoom=this._map.transform.zoom+w.amount,Lc(_,w)}if(p.bearing){const w=Fc(p.bearing,b,Sy);_.bearing=this._map.transform.bearing+o.ac(w.amount,-179,179),Lc(_,w)}if(p.pitch){const w=Fc(p.pitch,b,Eu);_.pitch=this._map.transform.pitch+w.amount,Lc(_,w)}if(_.zoom||_.bearing){const w=p.pinchAround===void 0?p.around:p.pinchAround;_.around=w?this._map.unproject(w):this._map.getCenter()}return this.clear(),o.e(_,{noMoveStart:!0})}}function Lc(k,l){(!k.duration||k.duration<l.duration)&&(k.duration=l.duration,k.easing=l.easing)}function Fc(k,l,p){const{maxSpeed:b,linearity:_,deceleration:w}=p,D=o.ac(k*_/(l/1e3),-b,b),P=Math.abs(D)/(w*_);return{easing:p.easing,duration:1e3*P,amount:D*(P/2)}}class qr extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,p,b,_={}){const w=E.mousePos(p.getCanvas(),b),D=p.unproject(w);super(l,o.e({point:w,lngLat:D,originalEvent:b},_)),this._defaultPrevented=!1,this.target=p}}class ka extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,p,b){const _=l==="touchend"?b.changedTouches:b.touches,w=E.touchPos(p.getCanvasContainer(),_),D=w.map(R=>p.unproject(R)),P=w.reduce((R,V,$,j)=>R.add(V.div(j.length)),new o.P(0,0));super(l,{points:w,point:P,lngLats:D,lngLat:p.unproject(P),originalEvent:b}),this._defaultPrevented=!1}}class Cy extends o.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(l,p,b){super(l,{originalEvent:b}),this._defaultPrevented=!1}}class Ty{constructor(l,p){this._map=l,this._clickTolerance=p.clickTolerance}reset(){delete this._mousedownPos}wheel(l){return this._firePreventable(new Cy(l.type,this._map,l))}mousedown(l,p){return this._mousedownPos=p,this._firePreventable(new qr(l.type,this._map,l))}mouseup(l){this._map.fire(new qr(l.type,this._map,l))}click(l,p){this._mousedownPos&&this._mousedownPos.dist(p)>=this._clickTolerance||this._map.fire(new qr(l.type,this._map,l))}dblclick(l){return this._firePreventable(new qr(l.type,this._map,l))}mouseover(l){this._map.fire(new qr(l.type,this._map,l))}mouseout(l){this._map.fire(new qr(l.type,this._map,l))}touchstart(l){return this._firePreventable(new ka(l.type,this._map,l))}touchmove(l){this._map.fire(new ka(l.type,this._map,l))}touchend(l){this._map.fire(new ka(l.type,this._map,l))}touchcancel(l){this._map.fire(new ka(l.type,this._map,l))}_firePreventable(l){if(this._map.fire(l),l.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ur{constructor(l){this._map=l}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(l){this._map.fire(new qr(l.type,this._map,l))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new qr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(l){this._delayContextMenu?this._contextMenuEvent=l:this._ignoreContextMenu||this._map.fire(new qr(l.type,this._map,l)),this._map.listens("contextmenu")&&l.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ks{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 Fi{constructor(l,p){this._map=l,this._tr=new ks(l),this._el=l.getCanvasContainer(),this._container=l.getContainer(),this._clickTolerance=p.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(l,p){this.isEnabled()&&l.shiftKey&&l.button===0&&(E.disableDrag(),this._startPos=this._lastPos=p,this._active=!0)}mousemoveWindow(l,p){if(!this._active)return;const b=p;if(this._lastPos.equals(b)||!this._box&&b.dist(this._startPos)<this._clickTolerance)return;const _=this._startPos;this._lastPos=b,this._box||(this._box=E.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",l));const w=Math.min(_.x,b.x),D=Math.max(_.x,b.x),P=Math.min(_.y,b.y),R=Math.max(_.y,b.y);E.setTransform(this._box,`translate(${w}px,${P}px)`),this._box.style.width=D-w+"px",this._box.style.height=R-P+"px"}mouseupWindow(l,p){if(!this._active||l.button!==0)return;const b=this._startPos,_=p;if(this.reset(),E.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&&(E.remove(this._box),this._box=null),E.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(l,p){return this._map.fire(new o.k(l,{originalEvent:p}))}}function $c(k,l){if(k.length!==l.length)throw new Error(`The number of touches and points are not equal - touches ${k.length}, points ${l.length}`);const p={};for(let b=0;b<k.length;b++)p[k[b].identifier]=l[b];return p}class $p{constructor(l){this.reset(),this.numTouches=l.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(l,p,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 D of _)w._add(D);return w.div(_.length)}(p),this.touches=$c(b,p)))}touchmove(l,p,b){if(this.aborted||!this.centroid)return;const _=$c(b,p);for(const w in this.touches){const D=_[w];(!D||D.dist(this.touches[w])>30)&&(this.aborted=!0)}}touchend(l,p,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 Su{constructor(l){this.singleTap=new $p(l),this.numTaps=l.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(l,p,b){this.singleTap.touchstart(l,p,b)}touchmove(l,p,b){this.singleTap.touchmove(l,p,b)}touchend(l,p,b){const _=this.singleTap.touchend(l,p,b);if(_){const w=l.timeStamp-this.lastTime<500,D=!this.lastTap||this.lastTap.dist(_)<30;if(w&&D||this.reset(),this.count++,this.lastTime=l.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Sl{constructor(l){this._tr=new ks(l),this._zoomIn=new Su({numTouches:1,numTaps:2}),this._zoomOut=new Su({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(l,p,b){this._zoomIn.touchstart(l,p,b),this._zoomOut.touchstart(l,p,b)}touchmove(l,p,b){this._zoomIn.touchmove(l,p,b),this._zoomOut.touchmove(l,p,b)}touchend(l,p,b){const _=this._zoomIn.touchend(l,p,b),w=this._zoomOut.touchend(l,p,b),D=this._tr;return _?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:D.zoom+1,around:D.unproject(_)},{originalEvent:l})}):w?(this._active=!0,l.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:D.zoom-1,around:D.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 ho{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 p=this._moveFunction(...l);if(p.bearingDelta||p.pitchDelta||p.around||p.panDelta)return this._active=!0,p}dragStart(l,p){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(l)&&(this._moveStateManager.startMove(l),this._lastPoint=p.length?p[0]:p,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(l,p){if(!this.isEnabled())return;const b=this._lastPoint;if(!b)return;if(l.preventDefault(),!this._moveStateManager.isValidMoveEvent(l))return void this.reset(l);const _=p.length?p[0]:p;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&&E.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 jp={0:1,2:2};class Cu{constructor(l){this._correctEvent=l.checkCorrectEvent}startMove(l){const p=E.mouseButton(l);this._eventButton=p}endMove(l){delete this._eventButton}isValidStartEvent(l){return this._correctEvent(l)}isValidMoveEvent(l){return!function(p,b){const _=jp[b];return p.buttons===void 0||(p.buttons&_)!==_}(l,this._eventButton)}isValidEndEvent(l){return E.mouseButton(l)===this._eventButton}}class Hp{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 Tu=k=>{k.mousedown=k.dragStart,k.mousemoveWindow=k.dragMove,k.mouseup=k.dragEnd,k.contextmenu=l=>{l.preventDefault()}},Up=({enable:k,clickTolerance:l,bearingDegreesPerPixelMoved:p=.8})=>{const b=new Cu({checkCorrectEvent:_=>E.mouseButton(_)===0&&_.ctrlKey||E.mouseButton(_)===2});return new ho({clickTolerance:l,move:(_,w)=>({bearingDelta:(w.x-_.x)*p}),moveStateManager:b,enable:k,assignEvents:Tu})},Wp=({enable:k,clickTolerance:l,pitchDegreesPerPixelMoved:p=-.5})=>{const b=new Cu({checkCorrectEvent:_=>E.mouseButton(_)===0&&_.ctrlKey||E.mouseButton(_)===2});return new ho({clickTolerance:l,move:(_,w)=>({pitchDelta:(w.y-_.y)*p}),moveStateManager:b,enable:k,assignEvents:Tu})};class Ea{constructor(l,p){this._clickTolerance=l.clickTolerance||1,this._map=p,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,p,b){return this._calculateTransform(l,p,b)}touchmove(l,p,b){if(this._active){if(!this._shouldBePrevented(b.length))return l.preventDefault(),this._calculateTransform(l,p,b);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",l)}}touchend(l,p,b){this._calculateTransform(l,p,b),this._active&&this._shouldBePrevented(b.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(l,p,b){b.length>0&&(this._active=!0);const _=$c(b,p),w=new o.P(0,0),D=new o.P(0,0);let P=0;for(const V in _){const $=_[V],j=this._touches[V];j&&(w._add($),D._add($.sub(j)),P++,_[V]=$)}if(this._touches=_,this._shouldBePrevented(P)||!D.mag())return;const R=D.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 Au{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(l,p,b){this._firstTwoTouches||b.length<2||(this._firstTwoTouches=[b[0].identifier,b[1].identifier],this._start([p[0],p[1]]))}touchmove(l,p,b){if(!this._firstTwoTouches)return;l.preventDefault();const[_,w]=this._firstTwoTouches,D=jc(b,p,_),P=jc(b,p,w);if(!D||!P)return;const R=this._aroundCenter?null:D.add(P).div(2);return this._move([D,P],R,l)}touchend(l,p,b){if(!this._firstTwoTouches)return;const[_,w]=this._firstTwoTouches,D=jc(b,p,_),P=jc(b,p,w);D&&P||(this._active&&E.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 jc(k,l,p){for(let b=0;b<k.length;b++)if(k[b].identifier===p)return l[b]}function qp(k,l){return Math.log(k/l)/Math.LN2}class Gp extends Au{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(l){this._startDistance=this._distance=l[0].dist(l[1])}_move(l,p){const b=this._distance;if(this._distance=l[0].dist(l[1]),this._active||!(Math.abs(qp(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:qp(this._distance,b),pinchAround:p}}}function Yp(k,l){return 180*k.angleWith(l)/Math.PI}class Zp extends Au{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,p,b){const _=this._vector;if(this._vector=l[0].sub(l[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Yp(this._vector,_),pinchAround:p}}_isBelowThreshold(l){this._minDiameter=Math.min(this._minDiameter,l.mag());const p=25/(Math.PI*this._minDiameter)*360,b=Yp(l,this._startVector);return Math.abs(b)<p}}function Mu(k){return Math.abs(k.y)>Math.abs(k.x)}class Cl extends Au{constructor(l){super(),this._currentTouchCount=0,this._map=l}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(l,p,b){super.touchstart(l,p,b),this._currentTouchCount=b.length}_start(l){this._lastPoints=l,Mu(l[0].sub(l[1]))&&(this._valid=!1)}_move(l,p,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,p,b){if(this._valid!==void 0)return this._valid;const _=l.mag()>=2,w=p.mag()>=2;if(!_&&!w)return;if(!_||!w)return this._firstMove===void 0&&(this._firstMove=b),b-this._firstMove<100&&void 0;const D=l.y>0==p.y>0;return Mu(l)&&Mu(p)&&D}}const Ay={panStep:100,bearingStep:15,pitchStep:10};class is{constructor(l){this._tr=new ks(l);const p=Ay;this._panStep=p.panStep,this._bearingStep=p.bearingStep,this._pitchStep=p.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(l){if(l.altKey||l.ctrlKey||l.metaKey)return;let p=0,b=0,_=0,w=0,D=0;switch(l.keyCode){case 61:case 107:case 171:case 187:p=1;break;case 189:case 109:case 173:p=-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(),D=-1);break;case 40:l.shiftKey?_=-1:(l.preventDefault(),D=1);break;default:return}return this._rotationDisabled&&(b=0,_=0),{cameraAnimation:P=>{const R=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:Ys,zoom:p?Math.round(R.zoom)+p*(l.shiftKey?2:1):R.zoom,bearing:R.bearing+b*this._bearingStep,pitch:R.pitch+_*this._pitchStep,offset:[-w*this._panStep,-D*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 Ys(k){return k*(2-k)}const Xp=4.000244140625;class Es{constructor(l,p){this._onTimeout=b=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(b)},this._map=l,this._tr=new ks(l),this._triggerRenderFrame=p,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 p=l.deltaMode===WheelEvent.DOM_DELTA_LINE?40*l.deltaY:l.deltaY;const b=v.now(),_=b-(this._lastWheelEventTime||0);this._lastWheelEventTime=b,p!==0&&p%Xp==0?this._type="wheel":p!==0&&Math.abs(p)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=p,this._timeout=setTimeout(this._onTimeout,40,l)):this._type||(this._type=Math.abs(_*p)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,p+=this._lastValue)),l.shiftKey&&p&&(p/=4),this._type&&(this._lastWheelEvent=l,this._delta-=p,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 p=E.mousePos(this._map.getCanvas(),l),b=this._tr;this._around=p.y>b.transform.height/2-b.transform.getHorizon()?o.N.convert(this._aroundCenter?b.center:b.unproject(p)):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)>Xp?this._wheelZoomRate:this._defaultZoomRate;let V=2/(1+Math.exp(-Math.abs(this._delta*R)));this._delta<0&&V!==0&&(V=1/V);const $=typeof this._targetZoom=="number"?l.zoomScale(this._targetZoom):l.scale;this._targetZoom=Math.min(l.maxZoom,Math.max(l.minZoom,l.scaleZoom($*V))),this._type==="wheel"&&(this._startZoom=l.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const p=typeof this._targetZoom=="number"?this._targetZoom:l.zoom,b=this._startZoom,_=this._easing;let w,D=!1;const P=v.now()-this._lastWheelEventTime;if(this._type==="wheel"&&b&&_&&P){const R=Math.min(P/200,1),V=_(R);w=o.y.number(b,p,V),R<1?this._frameId||(this._frameId=!0):D=!0}else w=p,D=!0;return this._active=!0,D&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!D,zoomDelta:w-l.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(l){let p=o.b9;if(this._prevEase){const b=this._prevEase,_=(v.now()-b.start)/b.duration,w=b.easing(_+.01)-b.easing(_),D=.27/Math.sqrt(w*w+1e-4)*.01,P=Math.sqrt(.0729-D*D);p=o.b8(D,P,.25,1)}return this._prevEase={start:v.now(),duration:l,easing:p},p}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Sa{constructor(l,p){this._clickZoom=l,this._tapZoom=p}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 Wv{constructor(l){this._tr=new ks(l),this.reset()}reset(){this._active=!1}dblclick(l,p){return l.preventDefault(),{cameraAnimation:b=>{b.easeTo({duration:300,zoom:this._tr.zoom+(l.shiftKey?-1:1),around:this._tr.unproject(p)},{originalEvent:l})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qv{constructor(){this._tap=new Su({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,p,b){if(!this._swipePoint)if(this._tapTime){const _=p[0],w=l.timeStamp-this._tapTime<500,D=this._tapPoint.dist(_)<30;w&&D?b.length>0&&(this._swipePoint=_,this._swipeTouch=b[0].identifier):this.reset()}else this._tap.touchstart(l,p,b)}touchmove(l,p,b){if(this._tapTime){if(this._swipePoint){if(b[0].identifier!==this._swipeTouch)return;const _=p[0],w=_.y-this._swipePoint.y;return this._swipePoint=_,l.preventDefault(),this._active=!0,{zoomDelta:w/128}}}else this._tap.touchmove(l,p,b)}touchend(l,p,b){if(this._tapTime)this._swipePoint&&b.length===0&&this.reset();else{const _=this._tap.touchend(l,p,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 My{constructor(l,p,b){this._el=l,this._mousePan=p,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 Dy{constructor(l,p,b){this._pitchWithRotate=l.pitchWithRotate,this._mouseRotate=p,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 Kp{constructor(l,p,b,_){this._el=l,this._touchZoom=p,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 Tl{constructor(l,p){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=l,this._options=p,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=E.create("div","maplibregl-cooperative-gesture-screen",l);let p=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(p=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const b=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),_=document.createElement("div");_.className="maplibregl-desktop-message",_.textContent=p,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&&(E.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,p){this._enabled&&(this._map.fire(new o.k("cooperativegestureprevented",{gestureType:l,originalEvent:p})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const ss=k=>k.zoom||k.drag||k.pitch||k.rotate;class pt extends o.k{}function Du(k){return k.panDelta&&k.panDelta.mag()||k.zoomDelta||k.bearingDelta||k.pitchDelta}class Jp{constructor(l,p){this.handleWindowEvent=_=>{this.handleEvent(_,`${_.type}Window`)},this.handleEvent=(_,w)=>{if(_.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const D=_.type==="renderFrame"?void 0:_,P={needsRenderFrame:!1},R={},V={},$=_.touches,j=$?this._getMapTouches($):void 0,G=j?E.touchPos(this._map.getCanvas(),j):E.mousePos(this._map.getCanvas(),_);for(const{handlerName:oe,handler:ce,allowed:ue}of this._handlers){if(!ce.isEnabled())continue;let pe;this._blockedByActive(V,ue,oe)?ce.reset():ce[w||_.type]&&(pe=ce[w||_.type](_,G,j),this.mergeHandlerResult(P,R,pe,oe,D),pe&&pe.needsRenderFrame&&this._triggerRenderFrame()),(pe||ce.isActive())&&(V[oe]=ce)}const Q={};for(const oe in this._previousActiveHandlers)V[oe]||(Q[oe]=D);this._previousActiveHandlers=V,(Object.keys(Q).length||Du(P))&&(this._changes.push([P,R,Q]),this._triggerRenderFrame()),(Object.keys(V).length||Du(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ee}=P;ee&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ee(this._map))},this._map=l,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Fp(l),this._bearingSnap=p.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(p);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,D]of this._listeners)E.addEventListener(_,w,_===document?this.handleWindowEvent:this.handleEvent,D)}destroy(){for(const[l,p,b]of this._listeners)E.removeEventListener(l,p,l===document?this.handleWindowEvent:this.handleEvent,b)}_addDefaultHandlers(l){const p=this._map,b=p.getCanvasContainer();this._add("mapEvent",new Ty(p,l));const _=p.boxZoom=new Fi(p,l);this._add("boxZoom",_),l.interactive&&l.boxZoom&&_.enable();const w=p.cooperativeGestures=new Tl(p,l.cooperativeGestures);this._add("cooperativeGestures",w),l.cooperativeGestures&&w.enable();const D=new Sl(p),P=new Wv(p);p.doubleClickZoom=new Sa(P,D),this._add("tapZoom",D),this._add("clickZoom",P),l.interactive&&l.doubleClickZoom&&p.doubleClickZoom.enable();const R=new qv;this._add("tapDragZoom",R);const V=p.touchPitch=new Cl(p);this._add("touchPitch",V),l.interactive&&l.touchPitch&&p.touchPitch.enable(l.touchPitch);const $=Up(l),j=Wp(l);p.dragRotate=new Dy(l,$,j),this._add("mouseRotate",$,["mousePitch"]),this._add("mousePitch",j,["mouseRotate"]),l.interactive&&l.dragRotate&&p.dragRotate.enable();const G=(({enable:pe,clickTolerance:ne})=>{const be=new Cu({checkCorrectEvent:_e=>E.mouseButton(_e)===0&&!_e.ctrlKey});return new ho({clickTolerance:ne,move:(_e,Ee)=>({around:Ee,panDelta:Ee.sub(_e)}),activateOnStart:!0,moveStateManager:be,enable:pe,assignEvents:Tu})})(l),Q=new Ea(l,p);p.dragPan=new My(b,G,Q),this._add("mousePan",G),this._add("touchPan",Q,["touchZoom","touchRotate"]),l.interactive&&l.dragPan&&p.dragPan.enable(l.dragPan);const ee=new Zp,oe=new Gp;p.touchZoomRotate=new Kp(b,oe,ee,R),this._add("touchRotate",ee,["touchPan","touchZoom"]),this._add("touchZoom",oe,["touchPan","touchRotate"]),l.interactive&&l.touchZoomRotate&&p.touchZoomRotate.enable(l.touchZoomRotate);const ce=p.scrollZoom=new Es(p,()=>this._triggerRenderFrame());this._add("scrollZoom",ce,["mousePan"]),l.interactive&&l.scrollZoom&&p.scrollZoom.enable(l.scrollZoom);const ue=p.keyboard=new is(p);this._add("keyboard",ue),l.interactive&&l.keyboard&&p.keyboard.enable(),this._add("blockableMapEvent",new ur(p))}_add(l,p,b){this._handlers.push({handlerName:l,handler:p,allowed:b}),this._handlersById[l]=p}stop(l){if(!this._updatingCamera){for(const{handler:p}of this._handlers)p.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,p,b){for(const _ in l)if(_!==b&&(!p||p.indexOf(_)<0))return!0;return!1}_getMapTouches(l){const p=[];for(const b of l)this._el.contains(b.target)&&p.push(b);return p}mergeHandlerResult(l,p,b,_,w){if(!b)return;o.e(l,b);const D={handlerName:_,originalEvent:b.originalEvent||w};b.zoomDelta!==void 0&&(p.zoom=D),b.panDelta!==void 0&&(p.drag=D),b.pitchDelta!==void 0&&(p.pitch=D),b.bearingDelta!==void 0&&(p.rotate=D)}_applyChanges(){const l={},p={},b={};for(const[_,w,D]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(p,w),o.e(b,D);this._updateMapTransform(l,p,b),this._changes=[]}_updateMapTransform(l,p,b){const _=this._map,w=_._getTransformForUpdate(),D=_.terrain;if(!(Du(l)||D&&this._terrainMovement))return this._fireEvents(p,b,!0);let{panDelta:P,zoomDelta:R,bearingDelta:V,pitchDelta:$,around:j,pinchAround:G}=l;G!==void 0&&(j=G),_._stop(!0),j=j||_.transform.centerPoint;const Q=w.pointLocation(P?j.sub(P):j);V&&(w.bearing+=V),$&&(w.pitch+=$),R&&(w.zoom+=R),D?this._terrainMovement||!p.drag&&!p.zoom?p.drag&&this._terrainMovement?w.center=w.pointLocation(w.centerPoint.sub(P)):w.setLocationAtPoint(Q,j):(this._terrainMovement=!0,this._map._elevationFreeze=!0,w.setLocationAtPoint(Q,j)):w.setLocationAtPoint(Q,j),_._applyUpdatedTransform(w),this._map._update(),l.noInertia||this._inertia.record(l),this._fireEvents(p,b,!0)}_fireEvents(l,p,b){const _=ss(this._eventsInProgress),w=ss(l),D={};for(const j in l){const{originalEvent:G}=l[j];this._eventsInProgress[j]||(D[`${j}start`]=G),this._eventsInProgress[j]=l[j]}!_&&w&&this._fireEvent("movestart",w.originalEvent);for(const j in D)this._fireEvent(j,D[j]);w&&this._fireEvent("move",w.originalEvent);for(const j in l){const{originalEvent:G}=l[j];this._fireEvent(j,G)}const P={};let R;for(const j in this._eventsInProgress){const{handlerName:G,originalEvent:Q}=this._eventsInProgress[j];this._handlersById[G].isActive()||(delete this._eventsInProgress[j],R=p[G]||Q,P[`${j}end`]=R)}for(const j in P)this._fireEvent(j,P[j]);const V=ss(this._eventsInProgress),$=(_||w)&&!V;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),G=Q=>Q!==0&&-this._bearingSnap<Q&&Q<this._bearingSnap;!j||!j.essential&&v.prefersReducedMotion?(this._map.fire(new o.k("moveend",{originalEvent:R})),G(this._map.getBearing())&&this._map.resetNorth()):(G(j.bearing||this._map.getBearing())&&(j.bearing=0),j.freezeElevation=!0,this._map.easeTo(j,{originalEvent:R})),this._updatingCamera=!1}}_fireEvent(l,p){this._map.fire(new o.k(l,p?{originalEvent:p}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(l=>{delete this._frameId,this.handleEvent(new pt("renderFrame",{timeStamp:l})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Iy extends o.E{constructor(l,p){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=p.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new o.N(this.transform.center.lng,this.transform.center.lat)}setCenter(l,p){return this.jumpTo({center:l},p)}panBy(l,p,b){return l=o.P.convert(l).mult(-1),this.panTo(this.transform.center,o.e({offset:l},p),b)}panTo(l,p,b){return this.easeTo(o.e({center:l},p),b)}getZoom(){return this.transform.zoom}setZoom(l,p){return this.jumpTo({zoom:l},p),this}zoomTo(l,p,b){return this.easeTo(o.e({zoom:l},p),b)}zoomIn(l,p){return this.zoomTo(this.getZoom()+1,l,p),this}zoomOut(l,p){return this.zoomTo(this.getZoom()-1,l,p),this}getBearing(){return this.transform.bearing}setBearing(l,p){return this.jumpTo({bearing:l},p),this}getPadding(){return this.transform.padding}setPadding(l,p){return this.jumpTo({padding:l},p),this}rotateTo(l,p,b){return this.easeTo(o.e({bearing:l},p),b)}resetNorth(l,p){return this.rotateTo(0,o.e({duration:1e3},l),p),this}resetNorthPitch(l,p){return this.easeTo(o.e({bearing:0,pitch:0,duration:1e3},l),p),this}snapToNorth(l,p){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(l,p):this}getPitch(){return this.transform.pitch}setPitch(l,p){return this.jumpTo({pitch:l},p),this}cameraForBounds(l,p){l=Ce.convert(l).adjustAntiMeridian();const b=p&&p.bearing||0;return this._cameraForBoxAndBearing(l.getNorthWest(),l.getSouthEast(),b,p)}_cameraForBoxAndBearing(l,p,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 Xe=_.padding;_.padding={top:Xe,bottom:Xe,right:Xe,left:Xe}}_.padding=o.e(w,_.padding);const D=this.transform,P=D.padding,R=new Ce(l,p),V=D.project(R.getNorthWest()),$=D.project(R.getNorthEast()),j=D.project(R.getSouthEast()),G=D.project(R.getSouthWest()),Q=o.ba(-b),ee=V.rotate(Q),oe=$.rotate(Q),ce=j.rotate(Q),ue=G.rotate(Q),pe=new o.P(Math.max(ee.x,oe.x,ue.x,ce.x),Math.max(ee.y,oe.y,ue.y,ce.y)),ne=new o.P(Math.min(ee.x,oe.x,ue.x,ce.x),Math.min(ee.y,oe.y,ue.y,ce.y)),be=pe.sub(ne),_e=(D.width-(P.left+P.right+_.padding.left+_.padding.right))/be.x,Ee=(D.height-(P.top+P.bottom+_.padding.top+_.padding.bottom))/be.y;if(Ee<0||_e<0)return void o.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const Be=Math.min(D.scaleZoom(D.scale*Math.min(_e,Ee)),_.maxZoom),He=o.P.convert(_.offset),nt=new o.P((_.padding.left-_.padding.right)/2,(_.padding.top-_.padding.bottom)/2).rotate(o.ba(b)),ct=He.add(nt).mult(D.scale/D.zoomScale(Be));return{center:D.unproject(V.add(j).div(2).sub(ct)),zoom:Be,bearing:b}}fitBounds(l,p,b){return this._fitInternal(this.cameraForBounds(l,p),p,b)}fitScreenCoordinates(l,p,b,_,w){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(o.P.convert(l)),this.transform.pointLocation(o.P.convert(p)),b,_),_,w)}_fitInternal(l,p,b){return l?(delete(p=o.e(l,p)).padding,p.linear?this.easeTo(p,b):this.flyTo(p,b)):this}jumpTo(l,p){this.stop();const b=this._getTransformForUpdate();let _=!1,w=!1,D=!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&&(D=!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",p)).fire(new o.k("move",p)),_&&this.fire(new o.k("zoomstart",p)).fire(new o.k("zoom",p)).fire(new o.k("zoomend",p)),w&&this.fire(new o.k("rotatestart",p)).fire(new o.k("rotate",p)).fire(new o.k("rotateend",p)),D&&this.fire(new o.k("pitchstart",p)).fire(new o.k("pitch",p)).fire(new o.k("pitchend",p)),this.fire(new o.k("moveend",p))}calculateCameraOptionsFromTo(l,p,b,_=0){const w=o.Z.fromLngLat(l,p),D=o.Z.fromLngLat(b,_),P=D.x-w.x,R=D.y-w.y,V=D.z-w.z,$=Math.hypot(P,R,V);if($===0)throw new Error("Can't calculate camera options with same From and To");const j=Math.hypot(P,R),G=this.transform.scaleZoom(this.transform.cameraToCenterDistance/$/this.transform.tileSize),Q=180*Math.atan2(P,-R)/Math.PI;let ee=180*Math.acos(j/$)/Math.PI;return ee=V<0?90-ee:90+ee,{center:D.toLngLat(),zoom:G,pitch:ee,bearing:Q}}easeTo(l,p){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,D=_.bearing,P=_.pitch,R=_.padding,V="bearing"in l?this._normalizeBearing(l.bearing,D):D,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,G=o.P.convert(l.offset);let Q=_.centerPoint.add(G);const ee=_.pointLocation(Q),{center:oe,zoom:ce}=_.getConstrained(o.N.convert(l.center||ee),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(oe,_);const ue=_.project(ee),pe=_.project(oe).sub(ue),ne=_.zoomScale(ce-w);let be,_e;l.around&&(be=o.N.convert(l.around),_e=_.locationPoint(be));const Ee={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||ce!==w,this._rotating=this._rotating||D!==V,this._pitching=this._pitching||$!==P,this._padding=!_.isPaddingEqual(j),this._easeId=l.easeId,this._prepareEase(p,l.noMoveStart,Ee),this.terrain&&this._prepareElevation(oe),this._ease(Be=>{if(this._zooming&&(_.zoom=o.y.number(w,ce,Be)),this._rotating&&(_.bearing=o.y.number(D,V,Be)),this._pitching&&(_.pitch=o.y.number(P,$,Be)),this._padding&&(_.interpolatePadding(R,j,Be),Q=_.centerPoint.add(G)),this.terrain&&!l.freezeElevation&&this._updateElevation(Be),be)_.setLocationAtPoint(be,_e);else{const He=_.zoomScale(_.zoom-w),nt=ce>w?Math.min(2,ne):Math.max(.5,ne),ct=Math.pow(nt,1-Be),Xe=_.unproject(ue.add(pe.mult(Be*ct)).mult(He));_.setLocationAtPoint(_.renderWorldCopies?Xe.wrap():Xe,Q)}this._applyUpdatedTransform(_),this._fireMoveEvents(p)},Be=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(p,Be)},l),this}_prepareEase(l,p,b={}){this._moving=!0,p||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 p=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(l<1&&p!==this._elevationTarget){const b=this._elevationTarget-this._elevationStart;this._elevationStart+=l*(b-(p-(b*l+this._elevationStart))/(1-l)),this._elevationTarget=p}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 p=l.getCameraPosition(),b=this.terrain.getElevationForLngLatZoom(p.lngLat,l.zoom);if(p.altitude<b){const _=this.calculateCameraOptionsFromTo(p.lngLat,b,l.center,l.elevation);return{pitch:_.pitch,zoom:_.zoom}}return{}}_applyUpdatedTransform(l){const p=[];if(this.terrain&&p.push(_=>this._elevateCameraIfInsideTerrain(_)),this.transformCameraUpdate&&p.push(_=>this.transformCameraUpdate(_)),!p.length)return;const b=l.clone();for(const _ of p){const w=b.clone(),{center:D,zoom:P,pitch:R,bearing:V,elevation:$}=_(w);D&&(w.center=D),P!==void 0&&(w.zoom=P),R!==void 0&&(w.pitch=R),V!==void 0&&(w.bearing=V),$!==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,p){if(this._easeId&&p&&this._easeId===p)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,p){var b;if(!l.essential&&v.prefersReducedMotion){const ot=o.M(l,["center","zoom","bearing","pitch","around"]);return this.jumpTo(ot,p)}this.stop(),l=o.e({offset:[0,0],speed:1.2,curve:1.42,easing:o.b9},l);const _=this._getTransformForUpdate(),w=_.zoom,D=_.bearing,P=_.pitch,R=_.padding,V="bearing"in l?this._normalizeBearing(l.bearing,D):D,$="pitch"in l?+l.pitch:P,j="padding"in l?l.padding:_.padding,G=o.P.convert(l.offset);let Q=_.centerPoint.add(G);const ee=_.pointLocation(Q),{center:oe,zoom:ce}=_.getConstrained(o.N.convert(l.center||ee),(b=l.zoom)!==null&&b!==void 0?b:w);this._normalizeCenter(oe,_);const ue=_.zoomScale(ce-w),pe=_.project(ee),ne=_.project(oe).sub(pe);let be=l.curve;const _e=Math.max(_.width,_.height),Ee=_e/ue,Be=ne.mag();if("minZoom"in l){const ot=o.ac(Math.min(l.minZoom,w,ce),_.minZoom,_.maxZoom),Bt=_e/_.zoomScale(ot-w);be=Math.sqrt(Bt/Be*2)}const He=be*be;function nt(ot){const Bt=(Ee*Ee-_e*_e+(ot?-1:1)*He*He*Be*Be)/(2*(ot?Ee:_e)*He*Be);return Math.log(Math.sqrt(Bt*Bt+1)-Bt)}function ct(ot){return(Math.exp(ot)-Math.exp(-ot))/2}function Xe(ot){return(Math.exp(ot)+Math.exp(-ot))/2}const Ze=nt(!1);let _t=function(ot){return Xe(Ze)/Xe(Ze+be*ot)},Vt=function(ot){return _e*((Xe(Ze)*(ct(Bt=Ze+be*ot)/Xe(Bt))-ct(Ze))/He)/Be;var Bt},Je=(nt(!0)-Ze)/be;if(Math.abs(Be)<1e-6||!isFinite(Je)){if(Math.abs(_e-Ee)<1e-6)return this.easeTo(l,p);const ot=Ee<_e?-1:1;Je=Math.abs(Math.log(Ee/_e))/be,Vt=()=>0,_t=Bt=>Math.exp(ot*be*Bt)}return l.duration="duration"in l?+l.duration:1e3*Je/("screenSpeed"in l?+l.screenSpeed/be:+l.speed),l.maxDuration&&l.duration>l.maxDuration&&(l.duration=0),this._zooming=!0,this._rotating=D!==V,this._pitching=$!==P,this._padding=!_.isPaddingEqual(j),this._prepareEase(p,!1),this.terrain&&this._prepareElevation(oe),this._ease(ot=>{const Bt=ot*Je,Gn=1/_t(Bt);_.zoom=ot===1?ce:w+_.scaleZoom(Gn),this._rotating&&(_.bearing=o.y.number(D,V,ot)),this._pitching&&(_.pitch=o.y.number(P,$,ot)),this._padding&&(_.interpolatePadding(R,j,ot),Q=_.centerPoint.add(G)),this.terrain&&!l.freezeElevation&&this._updateElevation(ot);const Gt=ot===1?oe:_.unproject(pe.add(ne.mult(Vt(Bt))).mult(Gn));_.setLocationAtPoint(_.renderWorldCopies?Gt.wrap():Gt,Q),this._applyUpdatedTransform(_),this._fireMoveEvents(p)},()=>{this.terrain&&l.freezeElevation&&this._finalizeElevation(),this._afterEase(p)},l),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(l,p){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,p)}return l||(b=this.handlers)===null||b===void 0||b.stop(!1),this}_ease(l,p,b){b.animate===!1||b.duration===0?(l(1),p()):(this._easeStart=v.now(),this._easeOptions=b,this._onEaseFrame=l,this._onEaseEnd=p,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(l,p){l=o.b3(l,-180,180);const b=Math.abs(l-p);return Math.abs(l-360-p)<b&&(l-=360),Math.abs(l+360-p)<b&&(l+=360),l}_normalizeCenter(l,p){if(!p.renderWorldCopies||p.lngRange)return;const b=l.lng-p.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 Al={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ml{constructor(l=Al){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=p=>{!p||p.sourceDataType!=="metadata"&&p.sourceDataType!=="visibility"&&p.dataType!=="style"&&p.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=E.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=E.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=E.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(){E.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,p){const b=this._map._getUIString(`AttributionControl.${p}`);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 p=this._map.style.sourceCaches;for(const _ in p){const w=p[_];if(w.used||w.usedForTerrain){const D=w.getSource();D.attribution&&l.indexOf(D.attribution)<0&&l.push(D.attribution)}}l=l.filter(_=>String(_).trim()),l.sort((_,w)=>_.length-w.length),l=l.filter((_,w)=>{for(let D=w+1;D<l.length;D++)if(l[D].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 Qp{constructor(l={}){this._updateCompact=()=>{const p=this._container.children;if(p.length){const b=p[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=E.create("div","maplibregl-ctrl");const p=E.create("a","maplibregl-ctrl-logo");return p.target="_blank",p.rel="noopener nofollow",p.href="https://maplibre.org/",p.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),p.setAttribute("rel","noopener nofollow"),this._container.appendChild(p),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){E.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class dn{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(l){const p=++this._id;return this._queue.push({callback:l,id:p,cancelled:!1}),p}remove(l){const p=this._currentlyRunning,b=p?this._queue.concat(p):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 p=this._currentlyRunning=this._queue;this._queue=[];for(const b of p)if(!b.cancelled&&(b.callback(l),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var ef=o.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Gv 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,p){this.sourceCache.update(l,p),this._renderableTilesKeys=[];const b={};for(const _ of l.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:p}))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 Oi(_,this.tileSize));for(const _ in this._tiles)b[_]||delete this._tiles[_]}freeRtt(l){for(const p in this._tiles){const b=this._tiles[p];(!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 p={};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),p[b]=w}else if(_.canonical.isChildOf(l.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const D=_.canonical.z-l.canonical.z,P=_.canonical.x-(_.canonical.x>>D<<D),R=_.canonical.y-(_.canonical.y>>D<<D),V=o.X>>D;o.aP(w.posMatrix,0,V,0,V,0,1),o.J(w.posMatrix,w.posMatrix,[-P*V,-R*V,0]),p[b]=w}else if(l.canonical.isChildOf(_.canonical)){const w=l.clone();w.posMatrix=new Float64Array(16);const D=l.canonical.z-_.canonical.z,P=l.canonical.x-(l.canonical.x>>D<<D),R=l.canonical.y-(l.canonical.y>>D<<D),V=o.X>>D;o.aP(w.posMatrix,0,o.X,0,o.X,0,1),o.J(w.posMatrix,w.posMatrix,[P*V,R*V,0]),o.K(w.posMatrix,w.posMatrix,[1/2**D,1/2**D,0]),p[b]=w}}return p}getSourceTile(l,p){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)&&p)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(p=>p.timeAdded>=l)}}class tf{constructor(l,p,b){this.painter=l,this.sourceCache=new Gv(p),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,p,b,_=o.X){var w;if(!(p>=0&&p<_&&b>=0&&b<_))return 0;const D=this.getTerrainData(l),P=(w=D.tile)===null||w===void 0?void 0:w.dem;if(!P)return 0;const R=function(ee,oe,ce){var ue=oe[0],pe=oe[1];return ee[0]=ce[0]*ue+ce[4]*pe+ce[12],ee[1]=ce[1]*ue+ce[5]*pe+ce[13],ee}([],[p/_*o.X,b/_*o.X],D.u_terrain_matrix),V=[R[0]*P.dim,R[1]*P.dim],$=Math.floor(V[0]),j=Math.floor(V[1]),G=V[0]-$,Q=V[1]-j;return P.get($,j)*(1-G)*(1-Q)+P.get($+1,j)*G*(1-Q)+P.get($,j+1)*(1-G)*Q+P.get($+1,j+1)*G*Q}getElevationForLngLatZoom(l,p){if(!o.bb(p,l.wrap()))return 0;const{tileID:b,mercatorX:_,mercatorY:w}=this._getOverscaledTileIDFromLngLatZoom(l,p);return this.getElevation(b,_%o.X,w%o.X,o.X)}getElevation(l,p,b,_=o.X){return this.getDEMElevation(l,p,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 Qe(_,w,_.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Qe(_,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 p=this.sourceCache.getSourceTile(l,!0);if(p&&p.dem&&(!p.demTexture||p.needsTerrainPrepare)){const _=this.painter.context;p.demTexture=this.painter.getTileTexture(p.dem.stride),p.demTexture?p.demTexture.update(p.dem.getPixels(),{premultiply:!1}):p.demTexture=new Qe(_,p.dem.getPixels(),_.gl.RGBA,{premultiply:!1}),p.demTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),p.needsTerrainPrepare=!1}const b=p&&p+p.tileID.key+l.key;if(b&&!this._demMatrixCache[b]){const _=this.sourceCache.sourceCache._source.maxzoom;let w=l.canonical.z-p.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 D=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,[D*o.X,P*o.X,0]),this._demMatrixCache[l.key]={matrix:R,coord:l}}return{u_depth:2,u_terrain:3,u_terrain_dim:p&&p.dem&&p.dem.dim||1,u_terrain_matrix:b?this._demMatrixCache[l.key].matrix:this._emptyDemMatrix,u_terrain_unpack:p&&p.dem&&p.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(p&&p.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:p}}getFramebuffer(l){const p=this.painter,b=p.width/devicePixelRatio,_=p.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 Qe(p.context,{width:b,height:_,data:null},p.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(p.context.gl.NEAREST,p.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Qe(p.context,{width:b,height:_,data:null},p.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(p.context.gl.NEAREST,p.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=p.context.createFramebuffer(b,_,!0,!1),this._fbo.depthAttachment.set(p.context.createRenderbuffer(p.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 p=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let w=0,D=0;w<this._coordsTextureSize;w++)for(let P=0;P<this._coordsTextureSize;P++,D+=4)p[D+0]=255&P,p[D+1]=255&w,p[D+2]=P>>8<<4|w>>8,p[D+3]=0;const b=new o.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(p.buffer)),_=new Qe(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 p=new Uint8Array(4),b=this.painter.context,_=b.gl,w=Math.round(l.x*this.painter.pixelRatio/devicePixelRatio),D=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-D-1,1,1,_.RGBA,_.UNSIGNED_BYTE,p),b.bindFramebuffer.set(null);const R=p[0]+(p[2]>>4<<8),V=p[1]+((15&p[2])<<8),$=this.coordsIndex[255-p[3]],j=$&&this.sourceCache.getTileByID($);if(!j)return null;const G=this._coordsTextureSize,Q=(1<<j.tileID.canonical.z)*G;return new o.Z((j.tileID.canonical.x*G+R)/Q+j.tileID.wrap,(j.tileID.canonical.y*G+V)/Q,this.getElevation(j.tileID,R,V,G))}depthAtPoint(l){const p=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,p),b.bindFramebuffer.set(null),(p[0]/16777216+p[1]/65536+p[2]/256+p[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const l=this.painter.context,p=new o.bd,b=new o.aY,_=this.meshSize,w=o.X/_,D=_*_;for(let j=0;j<=_;j++)for(let G=0;G<=_;G++)p.emplaceBack(G*w,j*w,0);for(let j=0;j<D;j+=_+1)for(let G=0;G<_;G++)b.emplaceBack(G+j,_+G+j+1,_+G+j+2),b.emplaceBack(G+j,_+G+j+2,G+j+1);const P=p.length,R=P+2*(_+1);for(const j of[0,1])for(let G=0;G<=_;G++)for(const Q of[0,1])p.emplaceBack(G*w,j*o.X,Q);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 V=p.length,$=V+2*(_+1);for(const j of[0,1])for(let G=0;G<=_;G++)for(const Q of[0,1])p.emplaceBack(j*o.X,G*w,Q);for(let j=0;j<2*_;j+=2)b.emplaceBack(V+j,V+j+1,V+j+3),b.emplaceBack(V+j,V+j+3,V+j+2),b.emplaceBack($+j,$+j+3,$+j+1),b.emplaceBack($+j,$+j+2,$+j+3);return this._mesh=new xu(l.createVertexBuffer(p,ef.members),l.createIndexBuffer(b),o.a0.simpleSegment(0,0,p.length,b.length)),this._mesh}getMeshFrameDelta(l){return 2*Math.PI*o.be/Math.pow(2,l)/5}getMinTileElevationForLngLatZoom(l,p){var b;const{tileID:_}=this._getOverscaledTileIDFromLngLatZoom(l,p);return(b=this.getMinMaxElevation(_).minElevation)!==null&&b!==void 0?b:0}getMinMaxElevation(l){const p=this.getTerrainData(l).tile,b={minElevation:null,maxElevation:null};return p&&p.dem&&(b.minElevation=p.dem.min*this.exaggeration,b.maxElevation=p.dem.max*this.exaggeration),b}_getOverscaledTileIDFromLngLatZoom(l,p){const b=o.Z.fromLngLat(l.wrap()),_=(1<<p)*o.X,w=b.x*_,D=b.y*_,P=Math.floor(w/o.X),R=Math.floor(D/o.X);return{tileID:new o.S(p,0,p,P,R),mercatorX:w,mercatorY:D}}}class Yv{constructor(l,p,b){this._context=l,this._size=p,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 p=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),b=new Qe(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),p.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),p.colorAttachment.set(b.texture),{id:l,fbo:p,texture:b,stamp:-1,inUse:!1}}getObjectForId(l){return this._objects[l]}useObject(l){l.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(p=>l.id!==p),this._recentlyUsed.push(l.id)}stampObject(l){l.stamp=++this._stamp}getOrCreateFreeObject(){for(const p of this._recentlyUsed)if(!this._objects[p].inUse)return this._objects[p];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 Dl={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Py{constructor(l,p){this.painter=l,this.terrain=p,this.pool=new Yv(l.context,30,p.sourceCache.tileSize*p.qualityFactor)}destruct(){this.pool.destruct()}getTexture(l){return this.pool.getObjectForId(l.rtt[this._stacks.length-1].id).texture}prepareForRender(l,p){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=l._order.filter(b=>!l._layers[b].isHidden(p)),this._coordsDescendingInv={};for(const b in l.sourceCaches){this._coordsDescendingInv[b]={};const _=l.sourceCaches[b].getVisibleCoordinates();for(const w of _){const D=this.terrain.sourceCache.getTerrainCoords(w);for(const P in D)this._coordsDescendingInv[b][P]||(this._coordsDescendingInv[b][P]=[]),this._coordsDescendingInv[b][P].push(D[P])}}this._coordsDescendingInvStr={};for(const b of l._order){const _=l._layers[b],w=_.source;if(Dl[_.type]&&!this._coordsDescendingInvStr[w]){this._coordsDescendingInvStr[w]={};for(const D in this._coordsDescendingInv[w])this._coordsDescendingInvStr[w][D]=this._coordsDescendingInv[w][D].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 p=l.type,b=this.painter,_=this._renderableLayerIds[this._renderableLayerIds.length-1]===l.id;if(Dl[p]&&(this._prevType&&Dl[this._prevType]||this._stacks.push([]),this._prevType=p,this._stacks[this._stacks.length-1].push(l.id),!_))return!0;if(Dl[this._prevType]||Dl[p]&&_){this._prevType=p;const w=this._stacks.length-1,D=this._stacks[w]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(Ey(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[w]){const V=this.pool.getObjectForId(P.rtt[w].id);if(V.stamp===P.rtt[w].stamp){this.pool.useObject(V);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 V=0;V<D.length;V++){const $=b.style._layers[D[V]],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 Ey(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Dl[p]}return!1}}const nf={"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"},Ry=f,Zv={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Al,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},rf=k=>{k.touchstart=k.dragStart,k.touchmoveWindow=k.dragMove,k.touchend=k.dragEnd},Xv={showCompass:!0,showZoom:!0,visualizePitch:!1};class Kv{constructor(l,p,b=!1){this.mousedown=D=>{this.startMouse(o.e({},D,{ctrlKey:!0,preventDefault:()=>D.preventDefault()}),E.mousePos(this.element,D)),E.addEventListener(window,"mousemove",this.mousemove),E.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=D=>{this.moveMouse(D,E.mousePos(this.element,D))},this.mouseup=D=>{this.mouseRotate.dragEnd(D),this.mousePitch&&this.mousePitch.dragEnd(D),this.offTemp()},this.touchstart=D=>{D.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=E.touchPos(this.element,D.targetTouches)[0],this.startTouch(D,this._startPos),E.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),E.addEventListener(window,"touchend",this.touchend))},this.touchmove=D=>{D.targetTouches.length!==1?this.reset():(this._lastPos=E.touchPos(this.element,D.targetTouches)[0],this.moveTouch(D,this._lastPos))},this.touchend=D=>{D.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=p,this.mouseRotate=Up({clickTolerance:_,enable:!0}),this.touchRotate=(({enable:D,clickTolerance:P,bearingDegreesPerPixelMoved:R=.8})=>{const V=new Hp;return new ho({clickTolerance:P,move:($,j)=>({bearingDelta:(j.x-$.x)*R}),moveStateManager:V,enable:D,assignEvents:rf})})({clickTolerance:_,enable:!0}),this.map=l,b&&(this.mousePitch=Wp({clickTolerance:w,enable:!0}),this.touchPitch=(({enable:D,clickTolerance:P,pitchDegreesPerPixelMoved:R=-.5})=>{const V=new Hp;return new ho({clickTolerance:P,move:($,j)=>({pitchDelta:(j.y-$.y)*R}),moveStateManager:V,enable:D,assignEvents:rf})})({clickTolerance:w,enable:!0})),E.addEventListener(p,"mousedown",this.mousedown),E.addEventListener(p,"touchstart",this.touchstart,{passive:!1}),E.addEventListener(p,"touchcancel",this.reset)}startMouse(l,p){this.mouseRotate.dragStart(l,p),this.mousePitch&&this.mousePitch.dragStart(l,p),E.disableDrag()}startTouch(l,p){this.touchRotate.dragStart(l,p),this.touchPitch&&this.touchPitch.dragStart(l,p),E.disableDrag()}moveMouse(l,p){const b=this.map,{bearingDelta:_}=this.mouseRotate.dragMove(l,p)||{};if(_&&b.setBearing(b.getBearing()+_),this.mousePitch){const{pitchDelta:w}=this.mousePitch.dragMove(l,p)||{};w&&b.setPitch(b.getPitch()+w)}}moveTouch(l,p){const b=this.map,{bearingDelta:_}=this.touchRotate.dragMove(l,p)||{};if(_&&b.setBearing(b.getBearing()+_),this.touchPitch){const{pitchDelta:w}=this.touchPitch.dragMove(l,p)||{};w&&b.setPitch(b.getPitch()+w)}}off(){const l=this.element;E.removeEventListener(l,"mousedown",this.mousedown),E.removeEventListener(l,"touchstart",this.touchstart,{passive:!1}),E.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),E.removeEventListener(window,"touchend",this.touchend),E.removeEventListener(l,"touchcancel",this.reset),this.offTemp()}offTemp(){E.enableDrag(),E.removeEventListener(window,"mousemove",this.mousemove),E.removeEventListener(window,"mouseup",this.mouseup),E.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),E.removeEventListener(window,"touchend",this.touchend)}}let $i;function qn(k,l,p){const b=new o.N(k.lng,k.lat);if(k=new o.N(k.lng,k.lat),l){const _=new o.N(k.lng-360,k.lat),w=new o.N(k.lng+360,k.lat),D=p.locationPoint(k).distSqr(l);p.locationPoint(_).distSqr(l)<D?k=_:p.locationPoint(w).distSqr(l)<D&&(k=w)}for(;Math.abs(k.lng-p.center.lng)>180;){const _=p.locationPoint(k);if(_.x>=0&&_.y>=0&&_.x<=p.width&&_.y<=p.height)break;k.lng>p.center.lng?k.lng-=360:k.lng+=360}return k.lng!==b.lng&&p.locationPoint(k).y>p.height/2-p.getHorizon()?k:b}const Il={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 Iu(k,l,p){const b=k.classList;for(const _ in Il)b.remove(`maplibregl-${p}-anchor-${_}`);b.add(`maplibregl-${p}-anchor-${l}`)}class Pu extends o.E{constructor(l){if(super(),this._onKeyPress=p=>{const b=p.code,_=p.charCode||p.keyCode;b!=="Space"&&b!=="Enter"&&_!==32&&_!==13||this.togglePopup()},this._onMapClick=p=>{const b=p.originalEvent.target,_=this._element;this._popup&&(b===_||_.contains(b))&&this.togglePopup()},this._update=p=>{var b;if(!this._map)return;const _=this._map.loaded()&&!this._map.isMoving();((p==null?void 0:p.type)==="terrain"||(p==null?void 0:p.type)==="render"&&!_)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?qn(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 D="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?D="rotateX(0deg)":this._pitchAlignment==="map"&&(D=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||p&&p.type!=="moveend"||(this._pos=this._pos.round()),E.setTransform(this._element,`${Il[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${D} ${w}`),v.frameAsync(new AbortController).then(()=>{this._updateOpacity(p&&p.type==="moveend")}).catch(()=>{})},this._onMove=p=>{if(!this._isDragging){const b=this._clickTolerance||this._map._clickTolerance;this._isDragging=p.point.dist(this._pointerdownPos)>=b}this._isDragging&&(this._pos=p.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=p=>{this._element.contains(p.originalEvent.target)&&(p.preventDefault(),this._positionDelta=p.point.sub(this._pos).add(this._offset),this._pointerdownPos=p.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=E.create("div");const p=E.createNS("http://www.w3.org/2000/svg","svg"),b=41,_=27;p.setAttributeNS(null,"display","block"),p.setAttributeNS(null,"height",`${b}px`),p.setAttributeNS(null,"width",`${_}px`),p.setAttributeNS(null,"viewBox",`0 0 ${_} ${b}`);const w=E.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 D=E.createNS("http://www.w3.org/2000/svg","g");D.setAttributeNS(null,"fill-rule","nonzero");const P=E.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 ue of R){const pe=E.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",ue.rx),pe.setAttributeNS(null,"ry",ue.ry),P.appendChild(pe)}const V=E.createNS("http://www.w3.org/2000/svg","g");V.setAttributeNS(null,"fill",this._color);const $=E.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"),V.appendChild($);const j=E.createNS("http://www.w3.org/2000/svg","g");j.setAttributeNS(null,"opacity","0.25"),j.setAttributeNS(null,"fill","#000000");const G=E.createNS("http://www.w3.org/2000/svg","path");G.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),j.appendChild(G);const Q=E.createNS("http://www.w3.org/2000/svg","g");Q.setAttributeNS(null,"transform","translate(6.0, 7.0)"),Q.setAttributeNS(null,"fill","#FFFFFF");const ee=E.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"transform","translate(8.0, 8.0)");const oe=E.createNS("http://www.w3.org/2000/svg","circle");oe.setAttributeNS(null,"fill","#000000"),oe.setAttributeNS(null,"opacity","0.25"),oe.setAttributeNS(null,"cx","5.5"),oe.setAttributeNS(null,"cy","5.5"),oe.setAttributeNS(null,"r","5.4999962");const ce=E.createNS("http://www.w3.org/2000/svg","circle");ce.setAttributeNS(null,"fill","#FFFFFF"),ce.setAttributeNS(null,"cx","5.5"),ce.setAttributeNS(null,"cy","5.5"),ce.setAttributeNS(null,"r","5.4999962"),ee.appendChild(oe),ee.appendChild(ce),D.appendChild(P),D.appendChild(V),D.appendChild(j),D.appendChild(Q),D.appendChild(ee),p.appendChild(D),p.setAttributeNS(null,"height",b*this._scale+"px"),p.setAttributeNS(null,"width",_*this._scale+"px"),this._element.appendChild(p),this._offset=o.P.convert(l&&l.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",p=>{p.preventDefault()}),this._element.addEventListener("mousedown",p=>{p.preventDefault()}),Iu(this._element,this._anchor,"marker"),l&&l.className)for(const p of l.className.split(" "))this._element.classList.add(p);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),E.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 p,b;if(!(!((p=this._map)===null||p===void 0)&&p.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),D=_.terrain.getElevationForLngLatZoom(this._lngLat,_.transform.tileZoom);if(_.transform.lngLatToCameraDepth(this._lngLat,D)-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,V=_.terrain.depthAtPoint(new o.P(this._pos.x,this._pos.y-this._offset.y)),$=_.transform.lngLatToCameraDepth(this._lngLat,D+R)-V>.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,p){return l===void 0&&p===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),l!==void 0&&(this._opacity=l),p!==void 0&&(this._opacityWhenCovered=p),this._map&&this._updateOpacity(!0),this}}const Ny={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Hc=0,Uc=!1;const Zs={maxWidth:100,unit:"metric"};function Wc(k,l,p){const b=p&&p.maxWidth||100,_=k._container.clientHeight/2,w=k.unproject([0,_]),D=k.unproject([b,_]),P=w.distanceTo(D);if(p&&p.unit==="imperial"){const R=3.2808*P;R>5280?bt(l,b,R/5280,k._getUIString("ScaleControl.Miles")):bt(l,b,R,k._getUIString("ScaleControl.Feet"))}else p&&p.unit==="nautical"?bt(l,b,P/1852,k._getUIString("ScaleControl.NauticalMiles")):P>=1e3?bt(l,b,P/1e3,k._getUIString("ScaleControl.Kilometers")):bt(l,b,P,k._getUIString("ScaleControl.Meters"))}function bt(k,l,p,b){const _=function(w){const D=Math.pow(10,`${Math.floor(w)}`.length-1);let P=w/D;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(R){const V=Math.pow(10,Math.ceil(-Math.log(R)/Math.LN10));return Math.round(R*V)/V}(P),D*P}(p);k.style.width=l*(_/p)+"px",k.innerHTML=`${_}&nbsp;${b}`}const Dt={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Ru=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Nu(k){if(k){if(typeof k=="number"){const l=Math.round(Math.abs(k)/Math.SQRT2);return{center:new o.P(0,0),top:new o.P(0,k),"top-left":new o.P(l,l),"top-right":new o.P(-l,l),bottom:new o.P(0,-k),"bottom-left":new o.P(l,-l),"bottom-right":new o.P(-l,-l),left:new o.P(k,0),right:new o.P(-k,0)}}if(k instanceof o.P||Array.isArray(k)){const l=o.P.convert(k);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(k.center||[0,0]),top:o.P.convert(k.top||[0,0]),"top-left":o.P.convert(k["top-left"]||[0,0]),"top-right":o.P.convert(k["top-right"]||[0,0]),bottom:o.P.convert(k.bottom||[0,0]),"bottom-left":o.P.convert(k["bottom-left"]||[0,0]),"bottom-right":o.P.convert(k["bottom-right"]||[0,0]),left:o.P.convert(k.left||[0,0]),right:o.P.convert(k.right||[0,0])}}return Nu(new o.P(0,0))}const sf=f;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=Ml,a.BoxZoomHandler=Fi,a.CanvasSource=yr,a.CooperativeGesturesHandler=Tl,a.DoubleClickZoomHandler=Sa,a.DragPanHandler=My,a.DragRotateHandler=Dy,a.EdgeInsets=kl,a.FullscreenControl=class extends o.E{constructor(k={}){super(),this._onFullscreenChange=()=>{var l;let p=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((l=p==null?void 0:p.shadowRoot)===null||l===void 0)&&l.fullscreenElement;)p=p.shadowRoot.fullscreenElement;p===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,k&&k.container&&(k.container instanceof HTMLElement?this._container=k.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(k){return this._map=k,this._container||(this._container=this._map.getContainer()),this._controlContainer=E.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){E.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const k=this._fullscreenButton=E.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);E.create("span","maplibregl-ctrl-icon",k).setAttribute("aria-hidden","true"),k.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const k=this._getTitle();this._fullscreenButton.setAttribute("aria-label",k),this._fullscreenButton.title=k}_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=Wr,a.GeolocateControl=class extends o.E{constructor(k){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 p=new o.N(l.coords.longitude,l.coords.latitude),b=l.coords.accuracy,_=this._map.getBearing(),w=o.e({bearing:_},this.options.fitBoundsOptions),D=Ce.fromLngLat(p,b);this._map.fitBounds(D,w,{geolocateSource:!0})},this._updateMarker=l=>{if(l){const p=new o.N(l.coords.longitude,l.coords.latitude);this._accuracyCircleMarker.setLngLat(p).addTo(this._map),this._userLocationDotMarker.setLngLat(p).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 p=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=p,this._geolocateButton.setAttribute("aria-label",p),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(l.code===3&&Uc)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=E.create("button","maplibregl-ctrl-geolocate",this._container),E.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 p=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=p,this._geolocateButton.setAttribute("aria-label",p)}else{const p=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=p,this._geolocateButton.setAttribute("aria-label",p)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=E.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Pu({element:this._dotElement}),this._circleElement=E.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Pu({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",p=>{p.geolocateSource||this._watchState!=="ACTIVE_LOCK"||p.originalEvent&&p.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({},Ny,k)}onAdd(k){return this._map=k,this._container=E.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return o._(this,arguments,void 0,function*(l=!1){if($i!==void 0&&!l)return $i;if(window.navigator.permissions===void 0)return $i=!!window.navigator.geolocation,$i;try{$i=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{$i=!!window.navigator.geolocation}return $i})}().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(),E.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Hc=0,Uc=!1}_isOutOfMapMaxBounds(k){const l=this._map.getMaxBounds(),p=k.coords;return l&&(p.longitude<l.getWest()||p.longitude>l.getEast()||p.latitude<l.getSouth()||p.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 k=this._map.getBounds(),l=k.getSouthEast(),p=k.getNorthEast(),b=l.distanceTo(p),_=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":Hc--,Uc=!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 k;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Hc++,Hc>1?(k={maximumAge:6e5,timeout:0},Uc=!0):(k=this.options.positionOptions,Uc=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,k)}}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=wu,a.ImageSource=gr,a.KeyboardHandler=is,a.LngLatBounds=Ce,a.LogoControl=Qp,a.Map=class extends Iy{constructor(k){o.bf.mark(o.bg.create);const l=Object.assign(Object.assign({},Zv),k);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 El(l.minZoom,l.maxZoom,l.minPitch,l.maxPitch,l.renderWorldCopies),{bearingSnap:l.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new dn,this._controls=[],this._mapId=o.a4(),this._contextLost=p=>{p.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new o.k("webglcontextlost",{originalEvent:p}))},this._contextRestored=p=>{this._setupPainter(),this.resize(),this._update(),this.fire(new o.k("webglcontextrestored",{originalEvent:p}))},this._onMapScroll=p=>{if(p.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({},nf),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=te.addThrottleControl(()=>this.isMoving()),this._requestManager=new X(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 p=!1;const b=Vc(_=>{this._trackResize&&!this._removed&&(this.resize(_),this.redraw())},50);this._resizeObserver=new ResizeObserver(_=>{p?b(_):p=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Jp(this,l),this._hash=l.hash&&new wu(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 Ml(typeof l.attributionControl=="boolean"?void 0:l.attributionControl)),l.maplibreLogo&&this.addControl(new Qp,l.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",p=>{this._update(p.dataType==="style"),this.fire(new o.k(`${p.dataType}data`,p))}),this.on("dataloading",p=>{this.fire(new o.k(`${p.dataType}dataloading`,p))}),this.on("dataabort",p=>{this.fire(new o.k("sourcedataabort",p))})}_getMapId(){return this._mapId}addControl(k,l){if(l===void 0&&(l=k.getDefaultPosition?k.getDefaultPosition():"top-right"),!k||!k.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 p=k.onAdd(this);this._controls.push(k);const b=this._controlPositions[l];return l.indexOf("bottom")!==-1?b.insertBefore(p,b.firstChild):b.appendChild(p),this}removeControl(k){if(!k||!k.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(k);return l>-1&&this._controls.splice(l,1),k.onRemove(this),this}hasControl(k){return this._controls.indexOf(k)>-1}calculateCameraOptionsFromTo(k,l,p,b){return b==null&&this.terrain&&(b=this.terrain.getElevationForLngLatZoom(p,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(k,l,p,b)}resize(k){var l;const p=this._containerDimensions(),b=p[0],_=p[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 D=!this._moving;return D&&(this.stop(),this.fire(new o.k("movestart",k)).fire(new o.k("move",k))),this.fire(new o.k("resize",k)),D&&this.fire(new o.k("moveend",k)),this}_getClampedPixelRatio(k,l){const{0:p,1:b}=this._maxCanvasSize,_=this.getPixelRatio(),w=k*_,D=l*_;return Math.min(w>p?p/w:1,D>b?b/D:1)*_}getPixelRatio(){var k;return(k=this._overridePixelRatio)!==null&&k!==void 0?k:devicePixelRatio}setPixelRatio(k){this._overridePixelRatio=k,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(k){return this.transform.setMaxBounds(Ce.convert(k)),this._update()}setMinZoom(k){if((k=k??-2)>=-2&&k<=this.transform.maxZoom)return this.transform.minZoom=k,this._update(),this.getZoom()<k&&this.setZoom(k),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(k){if((k=k??22)>=this.transform.minZoom)return this.transform.maxZoom=k,this._update(),this.getZoom()>k&&this.setZoom(k),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(k){if((k=k??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(k>=0&&k<=this.transform.maxPitch)return this.transform.minPitch=k,this._update(),this.getPitch()<k&&this.setPitch(k),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(k){if((k=k??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(k>=this.transform.minPitch)return this.transform.maxPitch=k,this._update(),this.getPitch()>k&&this.setPitch(k),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(k){return this.transform.renderWorldCopies=k,this._update()}project(k){return this.transform.locationPoint(o.N.convert(k),this.style&&this.terrain)}unproject(k){return this.transform.pointLocation(o.P.convert(k),this.terrain)}isMoving(){var k;return this._moving||((k=this.handlers)===null||k===void 0?void 0:k.isMoving())}isZooming(){var k;return this._zooming||((k=this.handlers)===null||k===void 0?void 0:k.isZooming())}isRotating(){var k;return this._rotating||((k=this.handlers)===null||k===void 0?void 0:k.isRotating())}_createDelegatedListener(k,l,p){if(k==="mouseenter"||k==="mouseover"){let b=!1;return{layers:l,listener:p,delegates:{mousemove:w=>{const D=l.filter(R=>this.getLayer(R)),P=D.length!==0?this.queryRenderedFeatures(w.point,{layers:D}):[];P.length?b||(b=!0,p.call(this,new qr(k,this,w.originalEvent,{features:P}))):b=!1},mouseout:()=>{b=!1}}}}if(k==="mouseleave"||k==="mouseout"){let b=!1;return{layers:l,listener:p,delegates:{mousemove:D=>{const P=l.filter(R=>this.getLayer(R));(P.length!==0?this.queryRenderedFeatures(D.point,{layers:P}):[]).length?b=!0:b&&(b=!1,p.call(this,new qr(k,this,D.originalEvent)))},mouseout:D=>{b&&(b=!1,p.call(this,new qr(k,this,D.originalEvent)))}}}}{const b=_=>{const w=l.filter(P=>this.getLayer(P)),D=w.length!==0?this.queryRenderedFeatures(_.point,{layers:w}):[];D.length&&(_.features=D,p.call(this,_),delete _.features)};return{layers:l,listener:p,delegates:{[k]:b}}}}_saveDelegatedListener(k,l){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[k]=this._delegatedListeners[k]||[],this._delegatedListeners[k].push(l)}_removeDelegatedListener(k,l,p){if(!this._delegatedListeners||!this._delegatedListeners[k])return;const b=this._delegatedListeners[k];for(let _=0;_<b.length;_++){const w=b[_];if(w.listener===p&&w.layers.length===l.length&&w.layers.every(D=>l.includes(D))){for(const D in w.delegates)this.off(D,w.delegates[D]);return void b.splice(_,1)}}}on(k,l,p){if(p===void 0)return super.on(k,l);const b=this._createDelegatedListener(k,typeof l=="string"?[l]:l,p);this._saveDelegatedListener(k,b);for(const _ in b.delegates)this.on(_,b.delegates[_]);return this}once(k,l,p){if(p===void 0)return super.once(k,l);const b=typeof l=="string"?[l]:l,_=this._createDelegatedListener(k,b,p);for(const w in _.delegates){const D=_.delegates[w];_.delegates[w]=(...P)=>{this._removeDelegatedListener(k,b,p),D(...P)}}this._saveDelegatedListener(k,_);for(const w in _.delegates)this.once(w,_.delegates[w]);return this}off(k,l,p){return p===void 0?super.off(k,l):(this._removeDelegatedListener(k,typeof l=="string"?[l]:l,p),this)}queryRenderedFeatures(k,l){if(!this.style)return[];let p;const b=k instanceof o.P||Array.isArray(k),_=b?k:[[0,0],[this.transform.width,this.transform.height]];if(l=l||(b?{}:k)||{},_ instanceof o.P||typeof _[0]=="number")p=[o.P.convert(_)];else{const w=o.P.convert(_[0]),D=o.P.convert(_[1]);p=[w,new o.P(D.x,w.y),D,new o.P(w.x,D.y),w]}return this.style.queryRenderedFeatures(p,l,this.transform)}querySourceFeatures(k,l){return this.style.querySourceFeatures(k,l)}setStyle(k,l){return(l=o.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},l)).diff!==!1&&l.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&k?(this._diffStyle(k,l),this):(this._localIdeographFontFamily=l.localIdeographFontFamily,this._updateStyle(k,l))}setTransformRequest(k){return this._requestManager.setTransformRequest(k),this}_getUIString(k){const l=this._locale[k];if(l==null)throw new Error(`Missing UI string '${k}'`);return l}_updateStyle(k,l){if(l.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(k,l));const p=this.style&&l.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!k)),k?(this.style=new su(this,l||{}),this.style.setEventedParent(this,{style:this.style}),typeof k=="string"?this.style.loadURL(k,l,p):this.style.loadJSON(k,l,p),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new su(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(k,l){if(typeof k=="string"){const p=this._requestManager.transformRequest(k,"Style");o.h(p,new AbortController).then(b=>{this._updateDiff(b.data,l)}).catch(b=>{b&&this.fire(new o.j(b))})}else typeof k=="object"&&this._updateDiff(k,l)}_updateDiff(k,l){try{this.style.setState(k,l)&&this._update(!0)}catch(p){o.w(`Unable to perform style diff: ${p.message||p.error||p}. Rebuilding the style from scratch.`),this._updateStyle(k,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(k,l){return this._lazyInitEmptyStyle(),this.style.addSource(k,l),this._update(!0)}isSourceLoaded(k){const l=this.style&&this.style.sourceCaches[k];if(l!==void 0)return l.loaded();this.fire(new o.j(new Error(`There is no source with ID '${k}'`)))}setTerrain(k){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),k){const l=this.style.sourceCaches[k.source];if(!l)throw new Error(`cannot load terrain, because there exists no source with ID: ${k.source}`);this.terrain===null&&l.reload();for(const p in this.style._layers){const b=this.style._layers[p];b.type==="hillshade"&&b.source===k.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 tf(this.painter,l,k),this.painter.renderToTexture=new Py(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=p=>{p.dataType==="style"?this.terrain.sourceCache.freeRtt():p.dataType==="source"&&p.tile&&(p.sourceId!==k.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(p.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:k})),this}getTerrain(){var k,l;return(l=(k=this.terrain)===null||k===void 0?void 0:k.options)!==null&&l!==void 0?l:null}areTilesLoaded(){const k=this.style&&this.style.sourceCaches;for(const l in k){const p=k[l]._tiles;for(const b in p){const _=p[b];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}removeSource(k){return this.style.removeSource(k),this._update(!0)}getSource(k){return this.style.getSource(k)}addImage(k,l,p={}){const{pixelRatio:b=1,sdf:_=!1,stretchX:w,stretchY:D,content:P,textFitWidth:R,textFitHeight:V}=p;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:G}=l,Q=l;return this.style.addImage(k,{data:new o.R({width:$,height:j},new Uint8Array(G)),pixelRatio:b,stretchX:w,stretchY:D,content:P,textFitWidth:R,textFitHeight:V,sdf:_,version:0,userImage:Q}),Q.onAdd&&Q.onAdd(this,k),this}}{const{width:$,height:j,data:G}=v.getImageData(l);this.style.addImage(k,{data:new o.R({width:$,height:j},G),pixelRatio:b,stretchX:w,stretchY:D,content:P,textFitWidth:R,textFitHeight:V,sdf:_,version:0})}}updateImage(k,l){const p=this.style.getImage(k);if(!p)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:D}=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(_!==p.data.width||w!==p.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 p.data.replace(D,P),this.style.updateImage(k,p),this}getImage(k){return this.style.getImage(k)}hasImage(k){return k?!!this.style.getImage(k):(this.fire(new o.j(new Error("Missing required image id"))),!1)}removeImage(k){this.style.removeImage(k)}loadImage(k){return te.getImage(this._requestManager.transformRequest(k,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(k,l){return this._lazyInitEmptyStyle(),this.style.addLayer(k,l),this._update(!0)}moveLayer(k,l){return this.style.moveLayer(k,l),this._update(!0)}removeLayer(k){return this.style.removeLayer(k),this._update(!0)}getLayer(k){return this.style.getLayer(k)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(k,l,p){return this.style.setLayerZoomRange(k,l,p),this._update(!0)}setFilter(k,l,p={}){return this.style.setFilter(k,l,p),this._update(!0)}getFilter(k){return this.style.getFilter(k)}setPaintProperty(k,l,p,b={}){return this.style.setPaintProperty(k,l,p,b),this._update(!0)}getPaintProperty(k,l){return this.style.getPaintProperty(k,l)}setLayoutProperty(k,l,p,b={}){return this.style.setLayoutProperty(k,l,p,b),this._update(!0)}getLayoutProperty(k,l){return this.style.getLayoutProperty(k,l)}setGlyphs(k,l={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(k,l),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(k,l,p={}){return this._lazyInitEmptyStyle(),this.style.addSprite(k,l,p,b=>{b||this._update(!0)}),this}removeSprite(k){return this._lazyInitEmptyStyle(),this.style.removeSprite(k),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(k,l={}){return this._lazyInitEmptyStyle(),this.style.setSprite(k,l,p=>{p||this._update(!0)}),this}setLight(k,l={}){return this._lazyInitEmptyStyle(),this.style.setLight(k,l),this._update(!0)}getLight(){return this.style.getLight()}setSky(k){return this._lazyInitEmptyStyle(),this.style.setSky(k),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(k,l){return this.style.setFeatureState(k,l),this._update()}removeFeatureState(k,l){return this.style.removeFeatureState(k,l),this._update()}getFeatureState(k){return this.style.getFeatureState(k)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let k=0,l=0;return this._container&&(k=this._container.clientWidth||400,l=this._container.clientHeight||300),[k,l]}_setupContainer(){const k=this._container;k.classList.add("maplibregl-map");const l=this._canvasContainer=E.create("div","maplibregl-canvas-container",k);this._interactive&&l.classList.add("maplibregl-interactive"),this._canvas=E.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 p=this._containerDimensions(),b=this._getClampedPixelRatio(p[0],p[1]);this._resizeCanvas(p[0],p[1],b);const _=this._controlContainer=E.create("div","maplibregl-control-container",k),w=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(D=>{w[D]=E.create("div",`maplibregl-ctrl-${D} `,_)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(k,l,p){this._canvas.width=Math.floor(p*k),this._canvas.height=Math.floor(p*l),this._canvas.style.width=`${k}px`,this._canvas.style.height=`${l}px`}_setupPainter(){const k={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:k},b&&(l.statusMessage=b.statusMessage,l.type=b.type)},{once:!0});const p=this._canvas.getContext("webgl2",k)||this._canvas.getContext("webgl",k);if(!p){const b="Failed to initialize WebGL";throw l?(l.message=b,new Error(JSON.stringify(l))):new Error(b)}this.painter=new vu(p,this.transform),T.testSupport(p)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(k){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||k,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(k){return this._update(),this._renderTaskQueue.add(k)}_cancelRenderFrame(k){this._renderTaskQueue.remove(k)}_render(k){const l=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(k),this._removed)return;let p=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const _=this.transform.zoom,w=v.now();this.style.zoomHistory.update(_,w);const D=new o.z(_,{now:w,fadeDuration:l,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),P=D.crossFadingFactor();P===1&&P===this._crossFadingFactor||(p=!0,this._crossFadingFactor=P),this.style.update(D)}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()||p)&&(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 k;this._hash&&this._hash.remove();for(const p of this._controls)p.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),te.removeThrottleControl(this._imageQueueHandle),(k=this._resizeObserver)===null||k===void 0||k.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),E.remove(this._canvasContainer),E.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(k=>{o.bf.frame(k),this._frameRequest=null,this._render(k)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(k){this._showTileBoundaries!==k&&(this._showTileBoundaries=k,this._update())}get showPadding(){return!!this._showPadding}set showPadding(k){this._showPadding!==k&&(this._showPadding=k,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(k){this._showCollisionBoxes!==k&&(this._showCollisionBoxes=k,k?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(k){this._showOverdrawInspector!==k&&(this._showOverdrawInspector=k,this._update())}get repaint(){return!!this._repaint}set repaint(k){this._repaint!==k&&(this._repaint=k,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(k){this._vertices=k,this._update()}get version(){return Ry}getCameraTargetElevation(){return this.transform.elevation}},a.MapMouseEvent=qr,a.MapTouchEvent=ka,a.MapWheelEvent=Cy,a.Marker=Pu,a.NavigationControl=class{constructor(k){this._updateZoomButtons=()=>{const l=this._map.getZoom(),p=l===this._map.getMaxZoom(),b=l===this._map.getMinZoom();this._zoomInButton.disabled=p,this._zoomOutButton.disabled=b,this._zoomInButton.setAttribute("aria-disabled",p.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,p)=>{const b=this._map._getUIString(`NavigationControl.${p}`);l.title=b,l.setAttribute("aria-label",b)},this.options=o.e({},Xv,k),this._container=E.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})),E.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})),E.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=E.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(k){return this._map=k,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 Kv(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){E.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(k,l){const p=E.create("button",k,this._container);return p.type="button",p.addEventListener("click",l),p}},a.Popup=class extends o.E{constructor(k){super(),this.remove=()=>(this._content&&E.remove(this._content),this._container&&(E.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 p;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=E.create("div","maplibregl-popup",this._map.getContainer()),this._tip=E.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?qn(this._lngLat,this._flatPos,this._map.transform):(p=this._lngLat)===null||p===void 0?void 0:p.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=Nu(this.options.offset);if(!_){const P=this._container.offsetWidth,R=this._container.offsetHeight;let V;V=b.y+w.bottom.y<R?["top"]:b.y>this._map.transform.height-R?["bottom"]:[],b.x<P/2?V.push("left"):b.x>this._map.transform.width-P/2&&V.push("right"),_=V.length===0?"bottom":V.join("-")}let D=b.add(w[_]);this.options.subpixelPositioning||(D=D.round()),E.setTransform(this._container,`${Il[_]} translate(${D.x}px,${D.y}px)`),Iu(this._container,_,"popup")},this._onClose=()=>{this.remove()},this.options=o.e(Object.create(Dt),k)}addTo(k){return this._map&&this.remove(),this._map=k,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(k){return this._lngLat=o.N.convert(k),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(k){return this.setDOMContent(document.createTextNode(k))}setHTML(k){const l=document.createDocumentFragment(),p=document.createElement("body");let b;for(p.innerHTML=k;b=p.firstChild,b;)l.appendChild(b);return this.setDOMContent(l)}getMaxWidth(){var k;return(k=this._container)===null||k===void 0?void 0:k.style.maxWidth}setMaxWidth(k){return this.options.maxWidth=k,this._update(),this}setDOMContent(k){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=E.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(k),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(k){return this._container&&this._container.classList.add(k),this}removeClassName(k){return this._container&&this._container.classList.remove(k),this}setOffset(k){return this.options.offset=k,this._update(),this}toggleClassName(k){if(this._container)return this._container.classList.toggle(k)}setSubpixelPositioning(k){this.options.subpixelPositioning=k}_createCloseButton(){this.options.closeButton&&(this._closeButton=E.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const k=this._container.querySelector(Ru);k&&k.focus()}},a.RasterDEMTileSource=tt,a.RasterTileSource=Jt,a.ScaleControl=class{constructor(k){this._onMove=()=>{Wc(this._map,this._container,this.options)},this.setUnit=l=>{this.options.unit=l,Wc(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Zs),k)}getDefaultPosition(){return"bottom-left"}onAdd(k){return this._map=k,this._container=E.create("div","maplibregl-ctrl maplibregl-ctrl-scale",k.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){E.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},a.ScrollZoomHandler=Es,a.Style=su,a.TerrainControl=class{constructor(k){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=k}onAdd(k){return this._map=k,this._container=E.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=E.create("button","maplibregl-ctrl-terrain",this._container),E.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(){E.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},a.TwoFingersTouchPitchHandler=Cl,a.TwoFingersTouchRotateHandler=Zp,a.TwoFingersTouchZoomHandler=Gp,a.TwoFingersTouchZoomRotateHandler=Kp,a.VectorTileSource=Pi,a.VideoSource=ii,a.addSourceType=(k,l)=>o._(void 0,void 0,void 0,function*(){if(Ni(k))throw new Error(`A source type called "${k}" already exists.`);((p,b)=>{Ri[p]=b})(k,l)}),a.clearPrewarmedResources=function(){const k=Me;k&&(k.isPreloaded()&&k.numActive()===1?(k.release(Nn),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 oi().getRTLTextPluginStatus()},a.getVersion=function(){return sf},a.getWorkerCount=function(){return Ln.workerCount},a.getWorkerUrl=function(){return o.a.WORKER_URL},a.importScriptInWorkers=function(k){return Wt().broadcast("IS",k)},a.prewarm=function(){Ke().acquire(Nn)},a.setMaxParallelImageRequests=function(k){o.a.MAX_PARALLEL_IMAGE_REQUESTS=k},a.setRTLTextPlugin=function(k,l){return oi().setRTLTextPlugin(k,l)},a.setWorkerCount=function(k){Ln.workerCount=k},a.setWorkerUrl=function(k){o.a.WORKER_URL=k}});var s=n;return s})})(yE);var n5=yE.exports;const r5=t5(n5);function bE(t,e,n){if(t!==null)for(var r,i,s,a,o,f,g,y=0,v=0,E,T=t.type,M=T==="FeatureCollection",O=T==="Feature",B=M?t.features.length:1,F=0;F<B;F++){g=M?t.features[F].geometry:O?t.geometry:t,E=g?g.type==="GeometryCollection":!1,o=E?g.geometries.length:1;for(var Z=0;Z<o;Z++){var te=0,X=0;if(a=E?g.geometries[Z]:g,a!==null){f=a.coordinates;var Se=a.type;switch(y=0,Se){case null:break;case"Point":if(e(f,v,F,te,X)===!1)return!1;v++,te++;break;case"LineString":case"MultiPoint":for(r=0;r<f.length;r++){if(e(f[r],v,F,te,X)===!1)return!1;v++,Se==="MultiPoint"&&te++}Se==="LineString"&&te++;break;case"Polygon":case"MultiLineString":for(r=0;r<f.length;r++){for(i=0;i<f[r].length-y;i++){if(e(f[r][i],v,F,te,X)===!1)return!1;v++}Se==="MultiLineString"&&te++,Se==="Polygon"&&X++}Se==="Polygon"&&te++;break;case"MultiPolygon":for(r=0;r<f.length;r++){for(X=0,i=0;i<f[r].length;i++){for(s=0;s<f[r][i].length-y;s++){if(e(f[r][i][s],v,F,te,X)===!1)return!1;v++}X++}te++}break;case"GeometryCollection":for(r=0;r<a.geometries.length;r++)if(bE(a.geometries[r],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function i5(t,e={}){if(t.bbox!=null&&e.recompute!==!0)return t.bbox;const n=[1/0,1/0,-1/0,-1/0];return bE(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 s5(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 _E(t,e={}){const n={type:"FeatureCollection"};return e.id&&(n.id=e.id),e.bbox&&(n.bbox=e.bbox),n.features=t,n}const o5={},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 l5(t,e,n,r,i,s){return h.openBlock(),h.createElementBlock("svg",a5,e[0]||(e[0]=[h.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),h.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),h.createElementVNode("path",{d:"M6 6l12 12"},null,-1)]))}const c5=Le(o5,[["render",l5]]);function d5(t){const e=[{type:"fill",minzoom:t.pointZoom||0,paint:{"fill-color":t.color||"#ccc","fill-outline-color":t.color||"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}}),e}function u5(t){return[{type:"line",paint:{"line-color":t.color||"#ccc","line-opacity":t.opacity||1}}]}function h5(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}}),e}function p5(t){if(!t)return null;const e=t.type||"point";return e==="polygon"?d5(t):e==="line"?u5(t):h5(t)}const f5=["#69D2E7","yellow","#FE4365","#125B9A","#41B3A2","#D7C3F1","#F1D3CE"],m5=["ma-star","ma-water","ma-swimming","fa-home","fa-search","fa-trash","fa-check"],xE={};function g5({style:t,colors:e,icons:n,map:r,id:i}){r.legend||Object.assign(r,{legend:{}}),window.map||(window.map=r),Object.assign(r.legend,{[i]:{colors:e,icons:n,color:t.color,type:t.type||"point"}})}async function md(t="pin4-sm-mi-plumber+f45942.png",e=null){if(xE[t])return null;xE[t]=!0;const n=await(e==null?void 0:e.loadImage(t!=null&&t.includes("/")?t:`${e.prefix||"/api"}/marker_icon/${t.replace(".png","")}.png`));return e==null||e.addImage(t,n.data),null}async function vE(t,e){const{data:n}=await qe.get(`/gis-layer/${t}/${e}`);return n.rows}async function pb(t,e,n){if(!t)return null;const r=JSON.parse(JSON.stringify(t)),i=r.colorAttr?await vE(e,r.colorAttr):null;i==null||i.forEach((a,o)=>{var f,g;a.color=a.color||((f=r.colorSet)==null?void 0:f[a.id])||((g=r.colorSet)==null?void 0:g[o])||f5[o],a.icon=r.icon?`${r.icon.split("+")[0]}+${a.color.replace("#","")}.png`:null});const s=r.iconAttr?await vE(e,r.iconAttr):null;if(s==null||s.forEach((a,o)=>{var E,T,M,O;const f=a.icon||((E=r.iconSet)==null?void 0:E[a.id])||((T=r.iconPattern)==null?void 0:T.replace("{id}",a.id))||((M=r.iconSet)==null?void 0:M[o])||(r.iconPrefix?null:m5[o]);if(!f)return;const g=a.color||((O=r.color)==null?void 0:O.replace("#",""))||"red",[y="pin6",v="m"]=r.icon?r.icon.split("-"):[];a.icon=r.iconPrefix||f!=null&&f.includes("/")?(r.iconPrefix||"")+f:`${y}-${v}-${f}+${g}.png`}),r.colorAttr&&i){const a=["match",["get",r.colorAttr]];i.forEach(o=>{a.push(o.id),a.push(o.color)}),a.push(r.color||"gray"),r.color=a}if(r.icon&&r.iconAttr&&s){const a=["match",["get",r.iconAttr]];s.filter(o=>o.icon).forEach(({id:o,icon:f})=>{if(r.colorAttr&&i){a.push(o);const g=["match",["get",r.colorAttr]];i.forEach(y=>{g.push(y.id);const v=`${f.split("+")[0]}+${y.color.replace("#","")}.png`;g.push(v),md(v,n)}),g.push(r.icon),a.push(g)}else a.push(o),a.push(f),md(f,n)}),a.push((r.iconPrefix||"")+r.icon),md((r.iconPrefix||"")+r.icon,n),r.icon=a}else if(r.icon&&r.colorAttr&&i){const a=["match",["get",r.colorAttr]];i.forEach(o=>{a.push(o.id),a.push(o.icon),md(o.icon,n)}),a.push(r.icon),md(r.icon,n),r.icon=a}else r.icon&&await md(r.icon,n);return g5({style:t,colors:i,icons:s,map:n,id:e}),p5(r)}const y5={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"))&&await 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)||(typeof t.bounds=="string"&&Object.assign(t,{bounds:t.bounds.split(",")}),await e.addSource(t.id,{type:"raster",tiles:[`${t==null?void 0:t.url}?dt=${new Date().toISOString().split("T")[0]}`],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{id:n}=t;e.getStyle().layers.forEach(async i=>{i.source===n&&await e.originalRemoveLayer(i.id)}),(await pb(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 s;const n=(t!=null&&t.url.includes("?")?"":"?1")+["clusterZoom","pointZoom"].filter(a=>{var o;return(o=t.style)==null?void 0:o[a]}).map(a=>`&${a}=${t.style[a]}`),r={type:"vector",tiles:[`${(s=t==null?void 0:t.url)!=null&&s.startsWith("http")?"":window.location.origin}${t==null?void 0:t.url}${n}`],minzoom:t.minzoom||5,maxzoom:t.maxzoom||24};e.addSource(t.id,r),(t.layers||await pb(t.style,t.source,e)||[]).forEach((a,o)=>{const f={...a,id:`${t.id}-${o}`,source:t.id,"source-layer":a["source-layer"]||t.source||t.id,maxzoom:+a.maxzoom||24,minzoom:+a.minzoom||0};e.addLayer(f)})},async addGeoJsonLayer(t,e=this.map){var i;t!=null&&t.imported&&this.addAllGeometryLayers(t.id);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 pb(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)},addAllGeometryLayers(t){[{id:"points",type:"circle",geometry:"Point"},{id:"lines",type:"line",geometry:"LineString"},{id:"polygons",type:"fill",geometry:"Polygon"}].forEach(n=>{const r=`${t}-${n.id}`;this.map.getLayer(r)||this.map.addLayer({id:r,type:n.type,source:t,paint:this.getPaintProperties(n.type),filter:["==","$type",n.geometry]})})},getPaintProperties(t){return{circle:{"circle-radius":5,"circle-color":"#FF0000"},line:{"line-width":2,"line-color":"#0000FF"},fill:{"fill-color":"#00FF00","fill-opacity":.5}}[t]||{}},async removeLayer(t,e=this.map){e.getSource(t)&&(await e.getStyle().layers.forEach(async n=>{n.source===t&&await e.originalRemoveLayer(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==null?void 0:n.service)==="vtile"){await r.setTiles([`${window.location.origin}${n.url}${n.url.includes("?")?"&":"?"}filter=${e}${n.props?`&props=${n.props}`:""}`]);return}n==null||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.originalRemoveLayer(n.id)}),await e.removeSource(t),this.setVisible(t)}}},{Map:b5}=r5,Sr="widget-map-source",_5={mixins:[y5],props:{geometry:{type:Object,default:()=>null},zoom:{type:Number,default:50},height:{type:String,default:"400px"},layers:{type:Array,default:()=>[]}},computed:{settingLayers(){var t,e;return(e=(t=Cn==null?void 0:Cn.value)==null?void 0:t.geom)==null?void 0:e.layers}},data(){return{map:null,mapId:`gis-map-${Math.floor(Math.random()*1e3)}`,isOpen:!1,selectedBaseLayer:"topo100",isGeometryVisible:!0,localLayers:[],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"},{id:"gsv",name:"Google Street View",url:"https://mt2.google.com/vt/?lyrs=svv|cb_client:apiv3&style=50&x={x}&y={y}&z={z}",service:"TMS"}]}},async mounted(){this.settingLayers.length||(this.localLayers=this.layers),this.initMap(),setTimeout(()=>{var t,e,n;(n=(e=(t=this.map.getStyle())==null?void 0:t.layers)==null?void 0:e.filter(r=>r.source==Sr))==null||n.forEach(r=>{this.map.moveLayer(r.id)})},300)},components:{IconClose:c5},watch:{geometry(){this.initGeometryLayer()},settingLayers:{handler(t){t&&!this.layers.length&&(this.localLayers=t)},deep:!0,immediate:!0}},methods:{initMap(){const t={version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[]};this.map=new b5({container:this.mapId,style:t,center:[31.1656,48.3794],zoom:4,interactive:!0}),window==null||window.addEventListener("resize",()=>{this.map.resize()}),this.map.on("load",this.onMapLoad)},async onMapLoad(){this.map.resize(),this.changeBaseLayer(this.baseLayers[0]),this.geometry&&this.initGeometryLayer(),console.log(this.map.getStyle().layers.filter(t=>t.source==Sr))},changeBaseLayer(t){const e="base-layer",n="base-layer";if(!this.map.getSource(e))console.log("Adding new source and layer for base layer:",t.id),this.map.addSource(e,{type:"raster",tiles:[t.url],tileSize:256}),this.map.addLayer({id:n,type:"raster",source:e});else{console.log("Updating existing source for base layer:",t.id);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(Sr);if(this.zoomToGeometry(e),n){n.setData(e);return}t.addSource(Sr,{type:"geojson",data:e}),t.addLayer({id:`${Sr}-point`,type:"circle",source:Sr,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),t.addLayer({id:`${Sr}-polygon`,type:"fill",source:Sr,layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Sr}-polygon-line`,type:"line",source:Sr,layout:{},paint:{"line-color":"#0080ff","line-width":2},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Sr}-line`,type:"line",source:Sr,layout:{},paint:{"line-color":"#0080ff","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(t){let e=t;const n=t==null?void 0:t.type;if(Array.isArray(t))return _E(t);if(!n)throw new Error("Unknown geometry type!");return n==="FeatureCollection"?t:(n==="Feature"&&(e=[t]),!["FeatureCollection","Feature"].includes(n)&&(e=[s5(t)]),_E(e))},zoomToGeometry(t){const{map:e}=this,n=i5(t);e.fitBounds(n,{zoom:this.zoom,padding:30,duration:0})},toggleGeometryVisibility(){[`${Sr}-polygon`,`${Sr}-polygon-line`,`${Sr}-line`,`${Sr}-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),[`${Sr}-polygon`,`${Sr}-polygon-line`,`${Sr}-line`,`${Sr}-point`].forEach(r=>{this.map.getLayer(r)&&(console.log("layerId",r),this.map.moveLayer(r))})}}},x5={class:"relative"},v5={key:1,class:"bg-white absolute top-[10px] right-[10px] z-20 border rounded-lg cursor-pointer"},w5={class:"flex items-center justify-between p-2 border-b"},k5={class:"flex items-center"},E5=["value","onChange"],S5={class:"ml-2"},C5={key:0,class:"p-2 border-b"},T5={class:"flex items-center"},A5=["value","onChange"],M5={class:"ml-2"},D5={key:1,class:"p-2"},I5={class:"flex items-center"},P5=["id"];function R5(t,e,n,r,i,s){var o;const a=h.resolveComponent("IconClose");return h.openBlock(),h.createElementBlock("div",x5,[i.isOpen?(h.openBlock(),h.createElementBlock("div",v5,[h.createElementVNode("div",w5,[e[6]||(e[6]=h.createElementVNode("div",null,"Шари",-1)),h.createVNode(a,{onClick:e[1]||(e[1]=f=>i.isOpen=!1),class:"w-4 h-4"})]),h.createElementVNode("div",{class:h.normalizeClass(["p-2 border-b",{"border-b":n.geometry}])},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(i.baseLayers,f=>(h.openBlock(),h.createElementBlock("div",{key:f.id},[h.createElementVNode("label",k5,[h.withDirectives(h.createElementVNode("input",{type:"radio",name:"base-layer",value:f.id,"onUpdate:modelValue":e[2]||(e[2]=g=>i.selectedBaseLayer=g),onChange:g=>s.changeBaseLayer(f)},null,40,E5),[[h.vModelRadio,i.selectedBaseLayer]]),h.createElementVNode("span",S5,h.toDisplayString(f.name),1)])]))),128))],2),(o=i.localLayers)!=null&&o.length?(h.openBlock(),h.createElementBlock("div",C5,[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(i.localLayers,f=>(h.openBlock(),h.createElementBlock("div",{key:f.id},[h.createElementVNode("label",T5,[h.withDirectives(h.createElementVNode("input",{type:"checkbox",value:f.id,"onUpdate:modelValue":e[3]||(e[3]=g=>i.selectedLayers=g),onChange:g=>s.setLayerVisible(f,g.target.checked)},null,40,A5),[[h.vModelCheckbox,i.selectedLayers]]),h.createElementVNode("span",M5,h.toDisplayString(f.name),1)])]))),128))])):h.createCommentVNode("",!0),n.geometry?(h.openBlock(),h.createElementBlock("div",D5,[h.createElementVNode("label",I5,[h.withDirectives(h.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":e[4]||(e[4]=f=>i.isGeometryVisible=f),onChange:e[5]||(e[5]=(...f)=>s.toggleGeometryVisibility&&s.toggleGeometryVisibility(...f))},null,544),[[h.vModelCheckbox,i.isGeometryVisible]]),e[7]||(e[7]=h.createElementVNode("span",{class:"ml-2"},"Показати геометрію",-1))])])):h.createCommentVNode("",!0)])):(h.openBlock(),h.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]=f=>i.isOpen=!0)}," Шари ")),h.createElementVNode("div",{id:i.mapId,style:h.normalizeStyle({height:n.height})},null,12,P5)])}const fb=Le(_5,[["render",R5]]),ht=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),mb=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},am=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(mb(t)?t:am(t.parentElement,e))},xo=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},gb=t=>`${t||""}`.split(" ").filter(e=>!!e),vo=(t,e,n)=>{t&&gb(e).forEach(r=>{t.classList.toggle(r,n||!1)})};let gd=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 yd={passive:!1};let N5=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,yd),this.element.addEventListener("touchstart",this.onTouchStart,yd),this.element.addEventListener("touchmove",this.onMove,yd),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(e){if(!e.buttons||e.button!==0)return;const n=new gd(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 gd(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 gd(s)):[new gd(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 gd(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 gd(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,yd),this.element.removeEventListener("touchstart",this.onTouchStart,yd),this.element.removeEventListener("touchmove",this.onMove,yd),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 wE(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function kE(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const yb=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.prototype.toString.call(t)==="[object Object]",Yi=(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}),yb(a)?Object.assign(t[s],Yi(o,a)):Array.isArray(a)?Object.assign(t,{[s]:[...a]}):Object.assign(t,{[s]:a})})}return t},bb=function(t,e){return t.split(".").reduce((n,r)=>typeof n=="object"?n[r]:void 0,e)};let lm=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?Yi({},this.constructor.defaults,e):{};for(const[n,r]of Object.entries(this.option("on")||{}))this.on(n,r)}option(e,...n){let r=bb(e,this.options);return r&&typeof r=="function"&&(r=r.call(this,this,...n)),r}optionFor(e,n,r,...i){let s=bb(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=bb(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(lm,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(lm,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});let _b=class extends lm{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 Vn;(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"})(Vn||(Vn={}));const Qo=["a","b","c","d","e","f"],EE={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"},O5={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:EE},SE='<circle cx="25" cy="25" r="20"></circle>',xb='<div class="f-spinner"><svg viewBox="0 0 50 50">'+SE+SE+"</svg></div>",Zi=t=>t&&t!==null&&t instanceof Element&&"nodeType"in t,Rn=(t,e)=>{t&&gb(e).forEach(n=>{t.classList.remove(n)})},It=(t,e)=>{t&&gb(e).forEach(n=>{t.classList.add(n)})},cm={a:1,b:0,c:0,d:1,e:0,f:0},B5=1e5,dm=1e4,Os="mousemove",CE="drag",TE="content",Bs="auto";let vb=null,wb=null,bd=class QP extends _b{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return wb===null&&(wb=window.matchMedia("(hover: none)").matches),wb}get isMobile(){return vb===null&&(vb=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),vb}get panMode(){return this.options.panMode!==Os||this.isTouchDevice?CE:Os}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===Bs?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 Qo){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:Vn.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({},cm)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},cm)}),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({},QP.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=xo(xb);!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(TE);let r=this.option(TE)||e.querySelector(`.${n}`);if(r||(r=e.querySelector("img,picture")||e.firstElementChild,r&&It(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===Vn.Init?this.enable():this.updateMetrics()}onError(){this.state!==Vn.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=Vn.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 f=[1,n,s].sort((y,v)=>y-v),g=f.findIndex(y=>y>r+1e-5);o=f[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 N5(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(Os,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(Os,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 Qo)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 Qo)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:f}=a,g=o.min,y=o.max,v=f.min,E=f.max;let T=0,M=0;return g!==1/0&&i<g?T=g-i:y!==1/0&&i>y&&(T=y-i),v!==1/0&&s<v?M=v-s:E!==1/0&&s>E&&(M=E-s),Math.abs(T)<1e-4&&(T=0),Math.abs(M)<1e-4&&(M=0),Object.assign(Object.assign({},a),{xDiff:T,yDiff:M,inBounds:!T&&!M})}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 f=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,E=y?o:s,T=this.getMatrix(e),M=new DOMPoint(0,0).matrixTransform(T),O=new DOMPoint(0+v,0).matrixTransform(T),B=new DOMPoint(0+v,0+E).matrixTransform(T),F=new DOMPoint(0,0+E).matrixTransform(T),Z=Math.abs(B.x-M.x),te=Math.abs(B.y-M.y),X=Math.abs(F.x-O.x),Se=Math.abs(F.y-O.y);f=Math.max(Z,X),g=Math.max(te,Se)}return{contentWidth:f,contentHeight:g}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===Os||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,f=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*f<=0?f+=.14*s:(f=.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&&(f=Math.max(Math.min(f,a),-1*a))):this.isBouncingY=!1,this.isBouncingX&&(this.velocity.e=o),this.isBouncingY&&(this.velocity.f=f)}enable(){const{content:e}=this,n=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const r of Qo)this.current[r]=this.target[r]=n[r];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=Vn.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&&Zi(a)?a.dataset:null;if(o){const T=o.panzoomChange,M=o.panzoomAction;if((T||M)&&e.preventDefault(),T){let O={};try{O=JSON.parse(T)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(O)}if(M)return void(this[M]&&this[M]())}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 f=this.content.getBoundingClientRect(),g=this.dragStart;if(g.time&&!this.canZoomOut()&&(Math.abs(f.x-g.x)>2||Math.abs(f.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),E=this.option("dblClick",e);E?(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(E)),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===Os&&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&&ht(this.targetScale)<=ht(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(n[0]);const{content:i}=this,s=kE(r[0],r[1]),a=kE(n[0],n[1]);let o=0,f=0;if(n.length>1){const te=i.getBoundingClientRect();o=s.clientX-te.left-.5*te.width,f=s.clientY-te.top-.5*te.height}const g=wE(r[0],r[1]),y=wE(n[0],n[1]);let v=g?y/g:1,E=a.clientX-s.clientX,T=a.clientY-s.clientY;this.dragOffset.x+=E,this.dragOffset.y+=T,this.dragOffset.time=Date.now()-this.dragStart.time;let M=ht(this.targetScale)===ht(this.minScale)&&this.option("lockAxis");if(M&&!this.lockedAxis)if(M==="xy"||M==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const te=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=te>45&&te<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,E=0,T=0}else this.lockedAxis=M;if(am(e.target,this.content)&&(M="x",this.dragOffset.y=0),M&&M!=="xy"&&this.lockedAxis!==M&&ht(this.targetScale)===ht(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const O=this.checkBounds(E,T);this.option("rubberband")?(this.isInfinite!=="x"&&(O.xDiff>0&&E<0||O.xDiff<0&&E>0)&&(E*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*O.xDiff))),this.isInfinite!=="y"&&(O.yDiff>0&&T<0||O.yDiff<0&&T>0)&&(T*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*O.yDiff)))):(O.xDiff&&(E=0),O.yDiff&&(T=0));const B=this.targetScale,F=this.minScale,Z=this.maxScale;B<.5*F&&(v=Math.max(v,F)),B>1.5*Z&&(v=Math.min(v,Z)),this.lockedAxis==="y"&&ht(B)===ht(F)&&(E=0),this.lockedAxis==="x"&&ht(B)===ht(F)&&(T=0),this.applyChange({originX:o,originY:f,panX:E,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=[]),am(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==Vn.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 te of Qo)this.velocity[te]=0;this.target.e=this.current.e,this.target.f=this.current.f,Rn(this.container,"is-scaling"),Rn(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:r}=this,i=r[0],s=r[r.length-1];let a=0,o=0,f=0;s&&i&&(a=s.clientX-i.clientX,o=s.clientY-i.clientY,f=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,E=0,T=0,M=this.option("decelFriction");const O=this.targetScale;if(f>0){E=Math.abs(a)>3?a/(f/30):0,T=Math.abs(o)>3?o/(f/30):0;const te=this.option("maxVelocity");te&&(E=Math.max(Math.min(E,te),-1*te),T=Math.max(Math.min(T,te),-1*te))}E&&(y=E/(1/(1-M)-1)),T&&(v=T/(1/(1-M)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&ht(O)===this.minScale)&&(y=E=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&ht(O)===this.minScale)&&(v=T=0);const B=this.dragOffset.x,F=this.dragOffset.y,Z=this.option("dragMinThreshold")||0;Math.abs(B)<Z&&Math.abs(F)<Z&&(y=v=0,E=T=0),(this.option("zoom")&&(O<this.minScale-1e-5||O>this.maxScale+1e-5)||n&&!y&&!v)&&(M=.35),this.applyChange({panX:y,panY:v,friction:M}),this.emit("decel",E,T,B,F)}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===Os||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({},cm);for(const B of Qo){const F=B=="e"||B==="f"?dm:B5;s[B]=ht(e[B],F),Math.abs(n[B]-e[B])<(B=="e"||B==="f"?.51:.001)&&(e[B]=n[B])}let{a,b:o,c:f,d:g,e:y,f:v}=s,E=`matrix(${a}, ${o}, ${f}, ${g}, ${y}, ${v})`,T=r.parentElement instanceof HTMLPictureElement?r.parentElement:r;if(this.option("transformParent")&&(T=T.parentElement||T),T.style.transform===E)return;T.style.transform=E;const{contentWidth:M,contentHeight:O}=this.calculateContentDim();i.width=M,i.height=O,this.emit("afterTransform")}updateMetrics(e=!1){var n;if(!this||this.state===Vn.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(),f=getComputedStyle(this.container);let g=o.width*r,y=o.height*r;const v=parseFloat(f.paddingTop)+parseFloat(f.paddingBottom),E=g-(parseFloat(f.paddingLeft)+parseFloat(f.paddingRight)),T=y-v;this.containerRect={width:g,height:y,innerWidth:E,innerHeight:T};const M=parseFloat(s.dataset.width||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalWidth:rt instanceof SVGElement?rt.width.baseVal.value:Math.max(rt.offsetWidth,rt.scrollWidth),Tt||0})(s),O=parseFloat(s.dataset.height||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalHeight:rt instanceof SVGElement?rt.height.baseVal.value:Math.max(rt.offsetHeight,rt.scrollHeight),Tt||0})(s);let B=this.option("width",M)||Bs,F=this.option("height",O)||Bs;const Z=B===Bs,te=F===Bs;typeof B!="number"&&(B=M),typeof F!="number"&&(F=O),Z&&(B=M*(F/O)),te&&(F=O/(M/B));let X=s.parentElement instanceof HTMLPictureElement?s.parentElement:s;this.option("transformParent")&&(X=X.parentElement||X);const Se=X.getAttribute("style")||"";X.style.setProperty("transform","none","important"),a&&(X.style.width="",X.style.height=""),X.offsetHeight;const ge=s.getBoundingClientRect();let Te=ge.width*r,Ne=ge.height*r,se=Te,lt=Ne;Te=Math.min(Te,B),Ne=Math.min(Ne,F),a?{width:Te,height:Ne}=((rt,Tt,jt,Ut)=>{const Ot=jt/rt,Ht=Ut/Tt,ln=Math.min(Ot,Ht);return{width:rt*=ln,height:Tt*=ln}})(B,F,Te,Ne):(Te=Math.min(Te,B),Ne=Math.min(Ne,F));let Qe=.5*(lt-Ne),gt=.5*(se-Te);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:ge.top-o.top+Qe,bottom:o.bottom-ge.bottom+Qe,left:ge.left-o.left+gt,right:o.right-ge.right+gt,fitWidth:Te,fitHeight:Ne,width:Te,height:Ne,fullWidth:B,fullHeight:F}),X.style.cssText=Se,a&&(X.style.width=`${Te}px`,X.style.height=`${Ne}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(ht(this.targetScale)<ht(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===Vn.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,f=0,g=0,y=0;const v=this.option("infinite");if(v===!0||i&&v===i)o=-1/0,g=1/0,f=-1/0,y=1/0;else{let{containerRect:E,contentRect:T}=this,M=ht(s*r,dm),O=ht(a*r,dm),{innerWidth:B,innerHeight:F}=E;if(E.width===M&&(B=E.width),E.width===O&&(F=E.height),e>B){g=.5*(e-B),o=-1*g;let Z=.5*(T.right-T.left);o+=Z,g+=Z}if(s>B&&e<B&&(o-=.5*(s-B),g-=.5*(s-B)),n>F){y=.5*(n-F),f=-1*y;let Z=.5*(T.bottom-T.top);f+=Z,y+=Z}a>F&&n<F&&(o-=.5*(a-F),g-=.5*(a-F))}return{x:{min:o,max:g},y:{min:f,max:y}}}getBounds(){const e=this.option("bounds");return e!==Bs?e:this.calculateBounds()}updateControls(){const e=this,n=e.container,{panMode:r,contentRect:i,targetScale:s,minScale:a}=e;let o=a,f=e.option("click")||!1;f&&(o=e.getNextScale(f));let g=e.canZoomIn(),y=e.canZoomOut(),v=r===CE&&!!this.option("touch"),E=y&&v;if(v&&(ht(s)<ht(a)&&!this.panOnlyZoomed&&(E=!0),(ht(i.width,1)>ht(i.fitWidth,1)||ht(i.height,1)>ht(i.fitHeight,1))&&(E=!0)),ht(i.width*s,1)<ht(i.fitWidth,1)&&(E=!1),r===Os&&(E=!1),vo(n,this.cn("isDraggable"),E),!this.option("zoom"))return;let T=g&&ht(o)>ht(s),M=!T&&!E&&y&&ht(o)<ht(s);vo(n,this.cn("canZoomIn"),T),vo(n,this.cn("canZoomOut"),M);for(const O of n.querySelectorAll("[data-panzoom-action]")){let B=!1,F=!1;switch(O.dataset.panzoomAction){case"zoomIn":g?B=!0:F=!0;break;case"zoomOut":y?B=!0:F=!0;break;case"toggleZoom":case"iterateZoom":g||y?B=!0:F=!0;const Z=O.querySelector("g");Z&&(Z.style.display=g?"":"none")}B?(O.removeAttribute("disabled"),O.removeAttribute("tabindex")):F&&(O.setAttribute("disabled",""),O.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:f=!1,flipY:g=!1,ignoreBounds:y=!1}){this.state!==Vn.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:f,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:f=!1,flipY:g=!1,ignoreBounds:y=!1,bounce:v=this.option("bounce")}){const E=this.state;if(E===Vn.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=o||0,this.ignoreBounds=y;const{current:T}=this,M=T.e,O=T.f,B=this.getMatrix(this.target);let F=new DOMMatrix().translate(M,O).translate(s,a).translate(e,n);if(this.option("zoom")){if(!y){const Z=this.targetScale,te=this.minScale,X=this.maxScale;Z*r<te&&(r=te/Z),Z*r>X&&(r=X/Z)}F=F.scale(r)}F=F.translate(-s,-a).translate(-M,-O).multiply(B),i&&(F=F.rotate(i)),f&&(F=F.scale(-1,1)),g&&(F=F.scale(1,-1));for(const Z of Qo)Z!=="e"&&Z!=="f"&&(F[Z]>this.minScale+1e-5||F[Z]<this.minScale-1e-5)?this.target[Z]=F[Z]:this.target[Z]=ht(F[Z],dm);(this.targetScale<this.scale||Math.abs(r-1)>.1||this.panMode===Os||v===!1)&&!y&&this.clampTargetBounds(),E===Vn.Init?this.animate():this.isResting||(this.state=Vn.Panning,this.requestTick())}stop(e=!1){if(this.state===Vn.Init||this.state===Vn.Destroy)return;const n=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const r of Qo)this.velocity[r]=0,e==="current"?this.current[r]=this.target[r]:e==="target"&&(this.target[r]=this.current[r]);this.setTransform(),Rn(this.container,"is-scaling"),Rn(this.container,"is-animating"),this.isTicking=!1,this.state=Vn.Ready,n&&(this.emit("endAnimation"),this.updateControls())}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),It(this.container,"is-animating"),this.isScaling&&It(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!==Os||!e||ht(this.targetScale)<=ht(this.minScale))return;this.emit("mouseMove",e);const{container:r,containerRect:i,contentRect:s}=this,a=i.width,o=i.height,f=r.getBoundingClientRect(),g=(e.clientX||0)-f.left,y=(e.clientY||0)-f.top;let{contentWidth:v,contentHeight:E}=this.calculateContentDim(this.target);const T=this.option("mouseMoveFactor");T>1&&(v!==a&&(v*=T),E!==o&&(E*=T));let M=.5*(v-a)-g/a*100/100*(v-a);M+=.5*(s.right-s.left);let O=.5*(E-o)-y/o*100/100*(E-o);O+=.5*(s.bottom-s.top),this.applyChange({panX:M-this.target.e,panY:O-this.target.f,friction:n})}zoomWithWheel(e){if(this.state===Vn.Destroy||this.state===Vn.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 f=s*(100+45*i)/100;ht(f)<ht(o)&&ht(s)<=ht(o)?(this.cwd+=Math.abs(i),f=o):ht(f)>ht(a)&&ht(s)>=ht(a)?(this.cwd+=Math.abs(i),f=a):(this.cwd=0,f=Math.max(Math.min(f,a),o)),this.cwd>this.option("wheelLimit")||(e.preventDefault(),ht(f)!==ht(s)&&this.zoomTo(f,{event:e}))}canZoomIn(){return this.option("zoom")&&(ht(this.contentRect.width,1)<ht(this.contentRect.fitWidth,1)||ht(this.targetScale)<ht(this.maxScale))}canZoomOut(){return this.option("zoom")&&ht(this.targetScale)>ht(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=Bs,originX:r=Bs,originY:i=Bs,event:s}={}){if(this.isContentLoading||this.state===Vn.Destroy)return;const{targetScale:a,fullScale:o,maxScale:f,coverScale:g}=this;if(this.stop(),this.panMode===Os&&(s=this.pmme||s),s||r===Bs||i===Bs){const v=this.content.getBoundingClientRect(),E=this.container.getBoundingClientRect(),T=s?s.clientX:E.left+.5*E.width,M=s?s.clientY:E.top+.5*E.height;r=T-v.left-.5*v.width,i=M-v.top-.5*v.height}let y=1;typeof e=="number"?y=e:e==="full"?y=o:e==="cover"?y=g:e==="max"?y=f:e==="fit"?y=1:e==="next"&&(y=this.getNextScale("iterateZoom")),y=y/a||1,n=n===Bs?y>1?.15:.25:n,this.applyChange({scale:y,originX:r,originY:i,friction:n}),s&&this.panMode===Os&&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!==Vn.Init&&this.state!==Vn.Destroy){this.stop("current");for(const n of Qo)this.target[n]=cm[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=Vn.Panning,this.requestTick())}}destroy(){this.stop(),this.state=Vn.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(bd,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:O5}),Object.defineProperty(bd,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const AE=function(t,e){let n=!0;return(...r)=>{n&&(n=!1,t(...r),setTimeout(()=>{n=!0},e))}},ME=(t,e)=>{let n=[];return t.childNodes.forEach(r=>{r.nodeType!==Node.ELEMENT_NODE||e&&!r.matches(e)||n.push(r)}),n},z5={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 Cr;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"})(Cr||(Cr={}));const kb=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)},V5=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);let io=class extends lm{constructor(e,n){super(n),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}};const L5={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 DE=class extends io{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"),It(e,this.cn("list")),e.setAttribute("role","tablist");const n=this.instance.container;n.appendChild(e),It(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 f=this.build();if(vo(f,this.cn("isDynamic"),!!a),o)for(let v=0;v<n;v++)f.append(this.createItem(v));let g,y=0;for(const v of[...f.children]){const E=y===this.instance.page;E&&(g=v),vo(v,this.cn("isCurrent"),E),(e=v.children[0])===null||e===void 0||e.setAttribute("aria-selected",E?"true":"false");for(const T of["isBeforePrev","isPrev","isNext","isAfterNext"])Rn(v,this.cn(T));y++}if(g=g||f.firstChild,a&&g){const v=g.previousElementSibling,E=v&&v.previousElementSibling;It(v,this.cn("isPrev")),It(E,this.cn("isBeforePrev"));const T=g.nextElementSibling,M=T&&T.nextElementSibling;It(T,this.cn("isNext")),It(M,this.cn("isAfterNext"))}this.isDynamic=a}createItem(e=0){var n;const r=document.createElement("li");r.setAttribute("role","presentation");const i=xo(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,Rn(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(DE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:L5});const um="disabled",hm="next",IE="prev";let PE=class extends io{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(um),s.removeAttribute(um),e.isInfinite||(r<=0&&i.setAttribute(um,""),r>=n-1&&s.setAttribute(um,"")))}addBtn(e){var n;const r=this.instance,i=document.createElement("button");i.setAttribute("tabindex","0"),i.setAttribute("title",r.localize(`{{${e.toUpperCase()}}}`)),It(i,this.cn("button")+" "+this.cn(e===hm?"isNext":"isPrev"));const s=r.isRTL?e===hm?IE:hm: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"),It(r,n),e.appendChild(r)),this.container=r,s||(s=r.querySelector("[data-carousel-next]")),s||(s=this.addBtn(hm)),this.next=s,i||(i=r.querySelector("[data-carousel-prev]")),i||(i=this.addBtn(IE)),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(PE,"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 RE=class extends io{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===Cr.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),n.state===Cr.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:f}=this;if(!o||!f||!a)return;const g=a.closest("[data-index]");if(r.stopPropagation(),r.preventDefault(),!g)return;const y=parseInt(g.dataset.index||"",10)||0,v=f.getPageForSlide(y),E=o.getPageForSlide(y);o.slideTo(E),f.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!==Cr.Ready||r.state!==Cr.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===Cr.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(RE,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const F5={Navigation:PE,Dots:DE,Sync:RE},pm="animationend",NE="isSelected",fm="slide";let bh=class $1 extends _b{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===Cr.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:Cr.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||!Zi(e))throw new Error("No Element found");this.container=e,this.slideNext=AE(this.slideNext.bind(this),150),this.slidePrev=AE(this.slidePrev.bind(this),150),this.userOptions=n,this.userPlugins=r,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,n;const r=Yi({},$1.defaults,this.userOptions);let i="";const s=r.breakpoints;if(s&&yb(s))for(const[a,o]of Object.entries(s))window.matchMedia(a).matches&&yb(o)&&(i+=a,Yi(r,o));i===this.bp&&this.state!==Cr.Init||(this.bp=i,this.state===Cr.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!==Cr.Init&&this.destroy(),super.setOptions(r),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=Cr.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},$1.Plugins),this.userPlugins)),this.emit("attachPlugins"),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=Cr.Ready,this.emit("ready")}initLayout(){const{container:e}=this,n=this.option("classes");It(e,this.cn("container")),vo(e,n.isLTR,!this.isRTL),vo(e,n.isRTL,this.isRTL),vo(e,n.isVertical,!this.isHorizontal),vo(e,n.isHorizontal,this.isHorizontal);let r=this.option("viewport")||e.querySelector(`.${n.viewport}`);r||(r=document.createElement("div"),It(r,n.viewport),r.append(...ME(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"),It(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=[];[...ME(e,`.${this.cn(fm)}`)].forEach(i=>{if(Zi(i)){const s=kb({el:i,isDom:!0,index:this.slides.length});r.push(s)}});for(let i of[...this.option("slides",[])||[],...n])r.push(kb(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 bd(this.viewport,Yi({},{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 f of this.slides)(!e.length||a+f.dim-r>.05||o>=i)&&(e.push(V5()),s=e.length-1,a=0,o=0),e[s].slides.push(f),a+=f.dim+f.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 E;y.index=v,y.pos=((E=y.slides[0])===null||E===void 0?void 0:E.pos)||0,y.dim=0;for(const[T,M]of y.slides.entries())y.dim+=M.dim,T<y.slides.length-1&&(y.dim+=M.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=ht(y.pos,1e3),y.dim=ht(y.dim,1e3),Math.abs(y.pos)<=.1&&(y.pos=0)}),i)return e;const f=[];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=f.length,g=v,f.push(v))}),f}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 f=!(!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)),It(o,this.cn(fm)+" "+e.class+" "+e.customClass),s)o.style[i]=`${s}px`,o.style[i==="width"?"height":"width"]="";else{f&&(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,f?(r=o.parentElement)===null||r===void 0||r.removeChild(o):e.el||o.remove(),{dim:ht(s,1e3),gap:ht(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:f,pages:g,slides:y,panzoom:v}=this,E=0,T=0,M=0,O=0;v?O=-1*v.current[this.axis]:g[f]&&(O=g[f].pos||0),e=n?r?"right":"left":"top",r&&n&&(O*=-1);for(const te of y){const X=te.el;X?(e==="top"?(X.style.right="",X.style.left=""):X.style.top="",te.index!==E?X.style[e]=T===0?"":`${ht(T,1e3)}px`:X.style[e]="",M+=te.dim+te.gap,E++):T+=te.dim+te.gap}if(i&&M&&s){let te=getComputedStyle(s),X="padding",Se=n?"Right":"Bottom",ge=parseFloat(te[X+(n?"Left":"Top")]);O-=ge,a+=ge,a+=parseFloat(te[X+Se]);for(const Te of y)Te.el&&(ht(Te.pos)<ht(a)&&ht(Te.pos+Te.dim+Te.gap)<ht(O)&&ht(O)>ht(o-a)&&(Te.el.style[e]=`${ht(T+M,1e3)}px`),ht(Te.pos+Te.gap)>=ht(o-a)&&ht(Te.pos)>ht(O+a)&&ht(O)<ht(a)&&(Te.el.style[e]=`-${ht(M,1e3)}px`))}let B,F,Z=[...this.inTransition];if(Z.length>1&&(B=g[Z[0]],F=g[Z[1]]),B&&F){let te=0;for(const X of y)X.el?this.inTransition.has(X.index)&&B.slides.indexOf(X)<0&&(X.el.style[e]=`${ht(te+(B.pos-F.pos),1e3)}px`):te+=X.dim+X.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");It(i,this.cn(fm)),It(i,e.class),It(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 f=null;a.length&&(f=r[a.reduce((y,v)=>Math.abs(v-o)<Math.abs(y-o)?v:y)]);const g=f&&f.el&&f.el.parentNode?f.index<e.index?f.el.nextSibling:f.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(NE);if(r.classList.contains(i)&&(Rn(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(pm);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:f,panzoom:g}=this;e=parseInt((e||0).toString())||0;const y=this.getPageFromIndex(e);if(!g||!f[y]||f.length<2||Math.abs((((i=(r=f[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===f.length-1&&(v=-1),o===f.length-1&&e===0&&(v=1));const E=f[y].pos*(this.isRTL?1:-1);if(o===y&&Math.abs(E-g.target[this.axis])<1)return!1;this.clearTransitions();const T=g.isResting;It(this.container,this.cn("inTransition"));const M=((s=f[o])===null||s===void 0?void 0:s.slides[0])||null,O=((a=f[y])===null||a===void 0?void 0:a.slides[0])||null;this.inTransition.add(O.index),this.createSlideEl(O);let B=M.el,F=O.el;T||n===fm||(n="fadeFast",B=null);const Z=this.isRTL?"next":"prev",te=this.isRTL?"prev":"next";return B&&(this.inTransition.add(M.index),M.transition=n,B.addEventListener(pm,this.onAnimationEnd),B.classList.add(`f-${n}Out`,`to-${v>0?te:Z}`)),F&&(O.transition=n,F.addEventListener(pm,this.onAnimationEnd),F.classList.add(`f-${n}In`,`from-${v>0?Z:te}`)),g.current[this.axis]=E,g.target[this.axis]=E,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(NE);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)||(It(i,n),this.emit("selectSlide",r)),i.removeAttribute(e)):(i.classList.contains(n)&&(Rn(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 f=o.current[e],g=o.target[e]-f,y=0,v=.5*s;i&&n?(f<-v&&(y=-1,f+=a),f>a-v&&(y=1,f-=a)):(f>v&&(y=1,f-=a),f<-a+v&&(y=-1,f+=a)),y&&(o.current[e]=f,o.target[e]=f+g)}lazyLoadImg(e,n){const r=this,i="f-fadeIn",s="is-preloading";let a=!1,o=null;const f=()=>{a||(a=!0,o&&(o.remove(),o=null),Rn(n,s),n.complete&&(It(n,i),setTimeout(()=>{Rn(n,i)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(r.updateMetrics(),r.setViewportHeight()),this.emit("load",e))};It(n,s),n.src=n.dataset.lazySrcset||n.dataset.lazySrc||"",delete n.dataset.lazySrc,delete n.dataset.lazySrcset,n.addEventListener("error",()=>{f()}),n.addEventListener("load",()=>{f()}),setTimeout(()=>{const g=n.parentNode;g&&e.el&&(n.complete?f():a||(o=xo(xb),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:f,pages:g}=this,y=g.length,v=Math.abs(Math.atan2(r,n)/(Math.PI/180));let E=0;if(E=v>45&&v<135?o?0:r:o?n:0,!y)return;let T=this.page,M=a&&o?1:-1;const O=e.current[f]*M;let{pageIndex:B}=this.getPageFromPosition(O);Math.abs(E)>5?(g[T].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(T=B),T=a&&o?E<0?T-1:T+1:E<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&&Zi(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=Cr.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===Cr.Destroy)return;e=parseInt((e||0).toString())||0;const i=this.getPageFromIndex(e),{axis:s,isHorizontal:a,isRTL:o,pages:f,panzoom:g}=this,y=f.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 E=f[i].pos;if(this.isInfinite){const T=this.contentDim,M=g.target[s]*v;y===2?E+=T*Math.floor(parseFloat(e+"")/2):E=[E,E-T,E+T].reduce(function(O,B){return Math.abs(B-M)<Math.abs(O-M)?B:O})}E*=v,Math.abs(g.target[s]-E)<1||(g.panTo({x:a?E:0,y:a?0:E,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(),Rn(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(pm,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,f=((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 E=[];for(const T of v)E.push(kb(T));this.slides.splice(e,0,...E);for(let T=0;T<this.slides.length;T++)this.slides[T].index=T;for(const T of E)this.emit("beforeInitSlide",T,T.index);if(this.page>=e&&(this.page+=E.length),this.updateMetrics(),o){const T=((s=this.pages[this.page])===null||s===void 0?void 0:s.pos)||0,M=((a=this.pages[this.page])===null||a===void 0?void 0:a.dim)||0,O=this.pages.length||1,B=this.isRTL?g-M:M-g,F=this.isRTL?f-T:T-f;y&&O===1?(e<=this.page&&(o.current[this.axis]-=B,o.target[this.axis]-=B),o.panTo({[this.isHorizontal?"x":"y"]:-1*T})):F&&e<=this.page&&(o.target[this.axis]-=F,o.current[this.axis]-=F,o.requestTick())}for(const T of E)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",f=s?"offsetWidth":"offsetHeight";if(n){let v=Math.max(n[f],ht(n.getBoundingClientRect()[o],1e3)),E=getComputedStyle(n),T="padding",M=s?"Right":"Bottom";v-=parseFloat(E[T+(s?"Left":"Top")])+parseFloat(E[T+M]),this.viewportDim=v}let g,y=0;for(const[v,E]of i.entries()){let T=0,M=0;!E.el&&g?(T=g.dim,M=g.gap):({dim:T,gap:M}=this.getSlideMetrics(E),g=E),T=ht(T,1e3),M=ht(M,1e3),E.dim=T,E.gap=M,E.pos=y,y+=T,(a||v<i.length-1)&&(y+=M)}y=ht(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===Cr.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 f=-1*s.current.e,g=ht((f-o.pos)/(1*o.dim),1e3),y=g,v=g;this.isInfinite&&r!==!0&&(y=ht((f-o.pos+a)/(1*o.dim),1e3),v=ht((f-o.pos-a)/(1*o.dim),1e3));let E=[g,y,v].reduce(function(T,M){return Math.abs(M)<Math.abs(T)?M:T});return n?E:E>1?1:E<-1?-1:E}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:f}=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!==Vn.Init&&i.state!==Vn.Destroy?-1*i.current[this.axis]:o[f]&&o[f].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),E=this.isInfinite?[-1,0,1]:[0];for(const T of this.slides)for(const M of E){const O=T.pos+M*s,B=O+T.dim+T.gap;O<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,f=i.length,g=i[0],y=i[f-1],v=this.option("center");let E=0,T=0,M=0,O=e===void 0?-1*((a==null?void 0:a.target[this.axis])||0):e;v&&(O+=.5*n),this.isInfinite?(O<g.pos-.5*y.gap&&(O-=r,M=-1),O>y.pos+y.dim+.5*y.gap&&(O-=r,M=1)):O=Math.max(g.pos||0,Math.min(O,y.pos));let B=y,F=i.find(Z=>{const te=Z.pos-.5*B.gap,X=Z.pos+Z.dim+.5*Z.gap;return B=Z,O>=te&&O<X});return F||(F=y),T=this.getPageForSlide(F.index),E=T+M*o,{page:E,pageIndex:T}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([Cr.Destroy].includes(this.state))return;this.state=Cr.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(f=>{this.removeSlideEl(f)}),this.detachPlugins(),n&&(n.removeEventListener("scroll",this.onScroll),n.offsetParent&&r&&r.offsetParent&&n.replaceWith(...r.childNodes));for(const[f,g]of Object.entries(a))f!=="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(bh,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:bd}),Object.defineProperty(bh,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:z5}),Object.defineProperty(bh,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:F5});const OE=function(t){if(!Zi(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 f=a;s<e&&(f-=e-s),o>r&&(f-=o-r);const g=f/n*100;return Math.round(g)},_h=!(typeof window>"u"||!window.document||!window.document.createElement);let Eb;const Sb=["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(","),BE=t=>{if(t&&_h){Eb===void 0&&document.createElement("div").focus({get preventScroll(){return Eb=!0,!1}});try{if(Eb)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{}}},zE=()=>{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},Cb={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({},EE),{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">
625
625
  <div class="fancybox__backdrop"></div>
626
626
  <div class="fancybox__carousel"></div>
627
627
  <div class="fancybox__footer"></div>