@mapcreator/sdk 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/favicon-32x32.png +0 -0
- package/dist/mapcreator-sdk.js +4 -4
- package/dist/mapcreator-sdk.umd.cjs +3 -3
- package/dist/report.html +4950 -0
- package/package.json +2 -1
|
@@ -686,7 +686,7 @@ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matr
|
|
|
686
686
|
);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}`,`in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}`),sky:jt(`uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}`,`in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}`)};function jt(e,t){let n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),i=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),a=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=a?a.concat(i):i,s={};return{fragmentSource:e=e.replace(n,((e,t,n,r,i)=>(s[i]=!0,t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nin ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = u_${i};\n#endif\n`))),vertexSource:t=t.replace(n,((e,t,n,r,i)=>{let a=r===`float`?`vec2`:`vec4`,o=i.match(/color/)?`color`:a;return s[i]?t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\nout ${n} ${r} ${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:t===`define`?`\n#ifndef HAS_UNIFORM_u_${i}\nuniform lowp float u_${i}_t;\nin ${n} ${a} a_${i};\n#else\nuniform ${n} ${r} u_${i};\n#endif\n`:o===`vec4`?`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = a_${i};\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${i}\n ${n} ${r} ${i} = unpack_mix_${o}(a_${i}, u_${i}_t);\n#else\n ${n} ${r} ${i} = u_${i};\n#endif\n`})),staticAttributes:r,staticUniforms:o}}class Mt{constructor(e,t,n){this.vertexBuffer=e,this.indexBuffer=t,this.segments=n}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Nt=t.aJ([{name:`a_pos`,type:`Int16`,components:2}]);let Pt=`#define PROJECTION_MERCATOR`,U=`mercator`;class Ft{constructor(){this._cachedMesh=null}get name(){return`mercator`}get useSubdivision(){return!1}get shaderVariantName(){return U}get shaderDefine(){return Pt}get shaderPreludeCode(){return At.projectionMercator}get vertexShaderPreludeCode(){return At.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aK.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,n,r,i,a){if(this._cachedMesh)return this._cachedMesh;let o=new t.aL;o.emplaceBack(0,0),o.emplaceBack(t.ah,0),o.emplaceBack(0,t.ah),o.emplaceBack(t.ah,t.ah);let s=e.createVertexBuffer(o,Nt.members),c=t.aM.simpleSegment(0,0,4,2),l=new t.aN;return l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this._cachedMesh=new Mt(s,e.createIndexBuffer(l),c),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class It{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw Error(`Invalid value for edge-insets, top, bottom, left and right must all be numbers`);this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(e,n,r){return n.top!=null&&e.top!=null&&(this.top=t.C.number(e.top,n.top,r)),n.bottom!=null&&e.bottom!=null&&(this.bottom=t.C.number(e.bottom,n.bottom,r)),n.left!=null&&e.left!=null&&(this.left=t.C.number(e.left,n.left,r)),n.right!=null&&e.right!=null&&(this.right=t.C.number(e.right,n.right,r)),this}getCenter(e,n){let r=t.L((this.left+e-this.right)/2,0,e),i=t.L((this.top+n-this.bottom)/2,0,n);return new t.P(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new It(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Lt(e,t){if(!e.renderWorldCopies||e.lngRange)return;let n=t.lng-e.center.lng;t.lng+=n>180?-360:n<-180?360:0}function Rt(e){return Math.max(0,Math.floor(e))}class zt{constructor(e,n,r,i,a,o){this._callbacks=e,this._tileSize=512,this._renderWorldCopies=o===void 0||!!o,this._minZoom=n||0,this._maxZoom=r||22,this._minPitch=i??0,this._maxPitch=a??60,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.aa(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Rt(this._zoom),this._scale=t.aw(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new It,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0,this._detailLevel=0,this._rasterAlignment=!0}apply(e,n,r){this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Rt(this._zoom),this._scale=t.aw(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new It(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,this._detailLevel=e.detailLevel,n&&this._constrain(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.getConstrained(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){e===void 0?e=!0:e===null&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){let n=t.aO(e,-180,180)*Math.PI/180;var i,a,o,s,c,l,u,d,f;this._bearingInRadians!==n&&(this._unmodified=!1,this._bearingInRadians=n,this._calcMatrices(),this._rotationMatrix=r(),i=this._rotationMatrix,o=-this._bearingInRadians,s=(a=this._rotationMatrix)[0],c=a[1],l=a[2],u=a[3],d=Math.sin(o),f=Math.cos(o),i[0]=s*f+l*d,i[1]=c*f+u*d,i[2]=s*-d+l*f,i[3]=c*-d+u*f)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){let n=t.L(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==n&&(this._unmodified=!1,this._pitchInRadians=n,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){let t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aP(this._fovInRadians)}setFov(e){e=t.L(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.av(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){let n=this.getConstrained(this._center,e).zoom;this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this._tileZoom=Math.max(0,Math.floor(n)),this._scale=t.aw(n),this._constrain(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this._constrain(),this._calcMatrices())}get detailLevel(){return this._detailLevel}setDetailLevel(e){if((e=Math.round(t.L(e,-3,3)))===this._detailLevel)return;let n=this._detailLevel;this._detailLevel=e,this.setZoom(this.zoom+this.detailLevel-n)}get rasterAlignment(){return this._rasterAlignment}setRasterAlignment(e){this._rasterAlignment=e}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,n){this._unmodified=!1,this._edgeInsets.interpolate(e,t,n),this._constrain(),this._calcMatrices()}resize(e,t,n=!0){this._width=e,this._height=t,n&&this._constrain(),this._calcMatrices()}getMaxBounds(){return this._latRange&&this._latRange.length===2&&this._lngRange&&this._lngRange.length===2?new I([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this._constrain()):(this._lngRange=null,this._latRange=[-t.ax,t.ax])}getConstrained(e,t){return this._callbacks.getConstrained(e,t)}getCameraQueryGeometry(e,n){if(n.length===1)return[n[0],e];{let{minX:r,minY:i,maxX:a,maxY:o}=t.a2.fromPoints(n).extend(e);return[new t.P(r,i),new t.P(a,i),new t.P(a,o),new t.P(r,o),new t.P(r,i)]}}_constrain(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let e=this._unmodified,{center:t,zoom:n}=this.getConstrained(this.center,this.zoom);this.setCenter(t),this.setZoom(n),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.a4(new Float64Array(16));t.N(e,e,[this._width/2,-this._height/2,1]),t.a5(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.a4(new Float64Array(16)),t.N(e,e,[1,-1,1]),t.a5(e,e,[-1,-1,0]),t.N(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height*2**this._detailLevel}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,n,r,i){let a=r===void 0?this.bearing:r,o=i=i===void 0?this.pitch:i,s=t.aj.fromLngLat(e,n),c=-Math.cos(t.av(o)),l=Math.sin(t.av(o)),u=l*Math.sin(t.av(a)),d=-l*Math.cos(t.av(a)),f=this.elevation,p=n-f,m;c*p>=0||Math.abs(c)<.1?(m=1e4,f=n+m*c):m=-p/c;let h,g,_=t.aQ(1,s.y),v=0;do{if(v+=1,v>10)break;g=m/_,h=new t.aj(s.x+u*g,s.y+d*g),_=1/h.meterInMercatorCoordinateUnits()}while(Math.abs(m-g*_)>1e-12);return{center:h.toLngLat(),elevation:f,zoom:t.az(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;let n=t.ay(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/n,i=t.aj.fromLngLat(this.center,this.elevation),a=H(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;let o=this.calculateCenterFromCameraLngLatAlt(a.toLngLat(),t.aQ(a.z,i.y),this.bearing,this.pitch);this._elevation=o.elevation,this._center=o.center,this.setZoom(o.zoom)}getCameraPoint(){let e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){let e=t.ay(1,this.center.lat)*this.worldSize;return H(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];let n=e.canonical.z>=0?1<<e.canonical.z:2**e.canonical.z;return[e.canonical.x/n,e.canonical.y/n,1/n/t.ah,1/n/t.ah]}}class Bt{constructor(e,n){this.min=e,this.max=n,this.center=t.aR([],t.aS([],this.min,this.max),.5)}quadrant(e){let n=[e%2==0,e<2],r=t.aT(this.min),i=t.aT(this.max);for(let e=0;e<n.length;e++)r[e]=n[e]?this.min[e]:this.center[e],i[e]=n[e]?this.center[e]:this.max[e];return i[2]=this.max[2],new Bt(r,i)}distanceX(e){return Math.max(Math.min(this.max[0],e[0]),this.min[0])-e[0]}distanceY(e){return Math.max(Math.min(this.max[1],e[1]),this.min[1])-e[1]}intersectsFrustum(e){let t=!0;for(let n=0;n<e.planes.length;n++){let r=this.intersectsPlane(e.planes[n]);if(r===0)return 0;r===1&&(t=!1)}return t?2:e.aabb.min[0]>this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]<this.min[0]||e.aabb.max[1]<this.min[1]||e.aabb.max[2]<this.min[2]?0:1}intersectsPlane(e){let t=e[3],n=e[3];for(let r=0;r<3;r++)e[r]>0?(t+=e[r]*this.min[r],n+=e[r]*this.max[r]):(n+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:n<0?0:1}}class Vt{distanceToTile2d(e,t,n,r){let i=r.distanceX([e,t]),a=r.distanceY([e,t]);return Math.hypot(i,a)}getWrap(e,t,n){return n}getTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.ag(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}let s=1<<e.z;return new Bt([n+e.x/s,e.y/s,a],[n+(e.x+1)/s,(e.y+1)/s,o])}allowVariableZoom(e,n){let r=e.fov*(Math.abs(Math.cos(e.rollInRadians))*e.height+Math.abs(Math.sin(e.rollInRadians))*e.width)/e.height,i=t.L(78.5-r/2,0,60);return!!n.terrain||e.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}}class Ht{constructor(e,t,n){this.points=e,this.planes=t,this.aabb=n}static fromInvProjectionMatrix(e,n=1,r=0,i,a){let o=a?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],s=2**r,c=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((r=>function(e,n,r,i){let a=t.$([],e,n),o=1/a[3]/r*i;return t.aY(a,a,[o,o,1/a[3],o])}(r,e,n,s)));i&&function(e,n,r,i){let a=i?4:0,o=i?0:4,s=0,c=[],l=[];for(let n=0;n<4;n++){let r=t.aU([],e[n+o],e[n+a]),i=t.aZ(r);t.aR(r,r,1/i),c.push(i),l.push(r)}for(let n=0;n<4;n++){let i=t.a_(e[n+a],l[n],r);s=i!==null&&i>=0?Math.max(s,i):Math.max(s,c[n])}let u=function(e,n){let r=t.aU([],e[n[0]],e[n[1]]),i=t.aU([],e[n[2]],e[n[1]]),a=[0,0,0,0];return t.aV(a,t.aW([],r,i)),a[3]=-t.aX(a,e[n[0]]),a}(e,n),d=function(e,n){let r=t.a$(e),i=t.b0([],e,1/r),a=t.aU([],n,t.aR([],i,t.aX(n,i))),o=t.a$(a);if(o>0){let e=Math.sqrt(1-i[3]*i[3]),r=t.aR([],i,-i[3]),s=t.aS([],r,t.aR([],a,e/o));return t.b1(n,s)}return null}(r,u);if(d!==null){let e=d/t.aX(l[0],u);s=Math.min(s,e)}for(let t=0;t<4;t++){let n=Math.min(s,c[t]);e[t+o]=[e[t+a][0]+l[t][0]*n,e[t+a][1]+l[t][1]*n,e[t+a][2]+l[t][2]*n,1]}}(c,o[0],i,a);let l=o.map((e=>{let n=t.aU([],c[e[0]],c[e[1]]),r=t.aU([],c[e[2]],c[e[1]]),i=t.aV([],t.aW([],n,r)),a=-t.aX(i,c[e[1]]);return i.concat(a)})),u=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];for(let e of c)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),d[t]=Math.max(d[t],e[t]);return new Ht(c,l,new Bt(u,d))}}class Ut{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(e){this._helper.setDetailLevel(e)}setRasterAlignment(e){this._helper.setRasterAlignment(e)}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){return this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e,t,n,r,i){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this._helper=new zt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)},e,t,n,r,i),this._coveringTilesDetailsProvider=new Vt}clone(){let e=new Ut;return e.apply(this),e}apply(e,t,n){this._helper.apply(e,t,n)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){let n=[new t.b2(0,e)];if(this._helper._renderWorldCopies){let r=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),a=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),s=Math.floor(Math.min(r.x,i.x,a.x,o.x)),c=Math.floor(Math.max(r.x,i.x,a.x,o.x));for(let r=s-1;r<=c+1;r++)r!==0&&n.push(new t.b2(r,e))}return n}getCameraFrustum(){return Ht.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){let t=this.screenPointToLocation(this.centerPoint,e),n=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(n)}setLocationAtPoint(e,n){let r=t.ay(this.elevation,this.center.lat),i=this.screenPointToMercatorCoordinateAtZ(n,r),a=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),o=t.aj.fromLngLat(e),s=new t.aj(o.x-(i.x-a.x),o.y-(i.y-a.y));this.setCenter(s?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,n){return n?this.coordinatePoint(t.aj.fromLngLat(e),n.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.aj.fromLngLat(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){let n=t.pointCoordinate(e);if(n!=null)return n}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,n){let r=n||0,i=[e.x,e.y,0,1],a=[e.x,e.y,1,1];t.$(i,i,this._pixelMatrixInverse),t.$(a,a,this._pixelMatrixInverse);let o=i[3],s=a[3],c=i[1]/o,l=a[1]/s,u=i[2]/o,d=a[2]/s,f=u===d?0:(r-u)/(d-u);return new t.aj(t.C.number(i[0]/o,a[0]/s,f)/this.worldSize,t.C.number(c,l,f)/this.worldSize,r)}screenPointToMercatorCoordinateClamped(e){let n=[e.x,e.y,0,1],r=[e.x,e.y,1,1];t.$(n,n,this._pixelMatrixInverse),t.$(r,r,this._pixelMatrixInverse);let i=n[3],a=r[3],o=n[1]/i,s=r[1]/a,c=n[2]/i,l=r[2]/a,u=c===l?0:(0-c)/(l-c);return u<0&&(u=1-u),new t.aj(t.C.number(n[0]/i,r[0]/a,u)/this.worldSize,t.L(t.C.number(o,s,u)/this.worldSize,0,1),0)}coordinatePoint(e,n=0,r=this._pixelMatrix){let i=[e.x*this.worldSize,e.y*this.worldSize,n,1];return t.$(i,i,r),new t.P(i[0]/i[3],i[1]/i[3])}getBounds(){let e=Math.max(0,this._helper._height/2-Xe(this));return new I().extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?t.pointCoordinate(e)!=null:e.y>this.height/2-Xe(this)}calculatePosMatrix(e,n=!1,r){let i=e.key??t.b3(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a.has(i)){let e=a.get(i);return r?e.f32:e.f64}let o=Ze(e,this.worldSize);t.a8(o,n?this._alignedProjMatrix:this._viewProjMatrix,o);let s={f64:o,f32:new Float32Array(o)};return a.set(i,s),r?s.f32:s.f64}calculateFogMatrix(e){let n=e.key,r=this._fogMatrixCacheF32;if(r.has(n))return r.get(n);let i=Ze(e,this.worldSize);return t.a8(i,this._fogMatrix,i),r.set(n,new Float32Array(i)),r.get(n)}getConstrained(e,n){n=t.L(+n,this.minZoom,this.maxZoom);let r={center:new t.aa(e.lng,e.lat),zoom:n},i=this._helper._lngRange;if(!this._helper._renderWorldCopies&&i===null){let e=179.9999999999;i=[-e,e]}let a=this.tileSize*t.aw(r.zoom),o=0,s=a,c=0,l=a,u=0,d=0,{x:f,y:p}=this.size;if(this._helper._latRange){let e=this._helper._latRange;o=t.ab(e[1])*a,s=t.ab(e[0])*a,s-o<p&&(u=p/(s-o))}i&&(c=t.aO(t.ac(i[0])*a,0,a),l=t.aO(t.ac(i[1])*a,0,a),l<c&&(l+=a),l-c<f&&(d=f/(l-c)));let{x:m,y:h}=V(a,e),g,_,v=Math.max(d||0,u||0);if(v)return r.center=Ye(a,new t.P(d?(l+c)/2:m,u?(s+o)/2:h)).wrap(),r.zoom+=t.az(v),r;if(this._helper._latRange){let e=p/2;h-e<o&&(_=o+e),h+e>s&&(_=s-e)}if(i){let e=(c+l)/2,n=m;this._helper._renderWorldCopies&&(n=t.aO(m,e-a/2,e+a/2));let r=f/2;n-r<c&&(g=c+r),n+r>l&&(g=l-r)}return(g!==void 0||_!==void 0)&&(r.center=Ye(a,new t.P(g??m,_??h)).wrap()),r}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}_calculateNearFarZIfNeeded(e,n,r){if(!this._helper.autoCalculateNearFarZ)return;let i=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),a=e-i*this._helper._pixelPerMeter/Math.cos(n),o=i<0?a:e,s=Math.PI/2+this.pitchInRadians,c=t.av(this.fov)*(Math.abs(Math.cos(t.av(this.roll)))*this.height+Math.abs(Math.sin(t.av(this.roll)))*this.width)/this.height*(.5+r.y/this.height),l=Math.sin(c)*o/Math.sin(t.L(Math.PI-s-c,.01,Math.PI-.01)),u=Xe(this),d=Math.atan(u/this._helper.cameraToCenterDistance),f=t.av(.75),p=d>f?2*d*(.5+r.y/(2*u)):f,m=Math.sin(p)*o/Math.sin(t.L(Math.PI-s-p,.01,Math.PI-.01)),h=Math.min(l,m);this._helper._farZ=1.01*(Math.cos(Math.PI/2-n)*h+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;let e=this.centerOffset,n=V(this.worldSize,this.center),r=n.x,i=n.y;this._helper._pixelPerMeter=t.ay(1,this.center.lat)*this.worldSize;let a=t.av(Math.min(this.pitch,B)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(a)),s;this._calculateNearFarZIfNeeded(o,a,e),s=new Float64Array(16),t.b4(s,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.S(this._invProjMatrix,s),s[8]=2*-e.x/this._helper._width,s[9]=2*e.y/this._helper._height,this._projectionMatrix=t.b5(s),t.N(s,s,[1,-1,1]),t.a5(s,s,[0,0,-this._helper.cameraToCenterDistance]),t.b6(s,s,-this.rollInRadians),t.b7(s,s,this.pitchInRadians),t.b6(s,s,-this.bearingInRadians),t.a5(s,s,[-r,-i,0]),this._mercatorMatrix=t.N([],s,[this.worldSize,this.worldSize,this.worldSize]),t.N(s,s,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.a8(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),t.a5(s,s,[0,0,-this.elevation]),this._viewProjMatrix=s,this._invViewProjMatrix=t.S([],s);let c=[0,0,-1,1];if(t.$(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=new Float64Array(16),t.b4(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.N(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.a5(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.b6(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.b7(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.b6(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.a5(this._fogMatrix,this._fogMatrix,[-r,-i,0]),t.N(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.a5(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.a8(new Float64Array(16),this.clipSpaceToPixelsMatrix,s),this._helper.rasterAlignment){let e=this._helper._width%2/2,n=this._helper._height%2/2,a=Math.cos(this.bearingInRadians),o=Math.sin(-this.bearingInRadians),c=r-Math.round(r)+a*e+o*n,l=i-Math.round(i)+a*n+o*e,u=new Float64Array(s);t.a5(u,u,[c>.5?c-1:c,l>.5?l-1:l,0]),this._alignedProjMatrix=u,s=t.S(new Float64Array(16),this._pixelMatrix)}else this._alignedProjMatrix=new Float64Array(s);if(!s)throw Error(`failed to invert matrix`);this._pixelMatrixInverse=s,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let e=this.screenPointToMercatorCoordinate(new t.P(0,0)),n=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.$(n,n,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){let e=t.ay(1,this.center.lat)*this.worldSize;return H(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,n){let r=t.aj.fromLngLat(e),i=[r.x*this.worldSize,r.y*this.worldSize,n,1];return t.$(i,i,this._viewProjMatrix),i[2]/i[3]}getProjectionData(e){let{overscaledTileID:n,aligned:r,applyTerrainMatrix:i}=e,a=this._helper.getMercatorTileCoordinates(n),o=n?this.calculatePosMatrix(n,r,!0):null,s;return s=n&&n.terrainRttPosMatrix32f&&i?n.terrainRttPosMatrix32f:o||t.b8(),{mainMatrix:s,tileMercatorCoords:a,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:s}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,n){return 1}transformLightDirection(e){return t.aT(e)}getRayDirectionFromPixel(e){throw Error(`Not implemented.`)}projectTileCoordinates(e,n,r,i){let a=this.calculatePosMatrix(r),o;i?(o=[e,n,i(e,n),1],t.$(o,o,a)):(o=[e,n,0,1],Ee(o,o,a));let s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}populateCache(e){for(let t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,n){let r=t.aj.fromLngLat(e,n),i=r.meterInMercatorCoordinateUnits(),a=t.b9();return t.a5(a,a,[r.x,r.y,r.z]),t.b6(a,a,Math.PI),t.b7(a,a,Math.PI/2),t.N(a,a,[-i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=new t.ag(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:n,applyGlobeMatrix:e}),i=Ze(n,this.worldSize);t.a8(i,this._viewProjMatrix,i),r.tileMercatorCoords=[0,0,1,1];let a=[t.ah,t.ah,this.worldSize/this._helper.pixelsPerMeter],o=t.ba();return t.N(o,i,a),r.fallbackMatrix=o,r.mainMatrix=o,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function Wt(){t.w(`Map cannot fit within canvas with the given bounds, padding, and/or offset.`)}function Gt(e){if(e.useSlerp)if(e.k<1){let n=t.bb(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.bb(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),i=new Float64Array(4);t.bc(i,n,r,e.k);let a=t.bd(i);e.tr.setRoll(a.roll),e.tr.setPitch(a.pitch),e.tr.setBearing(a.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.C.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.C.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.C.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Kt(e,n,r,i,a){let o=a.padding,s=V(a.worldSize,r.getNorthWest()),c=V(a.worldSize,r.getNorthEast()),l=V(a.worldSize,r.getSouthEast()),u=V(a.worldSize,r.getSouthWest()),d=t.av(-i),f=s.rotate(d),p=c.rotate(d),m=l.rotate(d),h=u.rotate(d),g=new t.P(Math.max(f.x,p.x,h.x,m.x),Math.max(f.y,p.y,h.y,m.y)),_=new t.P(Math.min(f.x,p.x,h.x,m.x),Math.min(f.y,p.y,h.y,m.y)),v=g.sub(_),y=(a.width-(o.left+o.right+n.left+n.right))/v.x,b=(a.height-(o.top+o.bottom+n.top+n.bottom))/v.y;if(b<0||y<0)return void Wt();let x=Math.min(t.az(a.scale*Math.min(y,b)),e.maxZoom),S=t.P.convert(e.offset),C=new t.P((n.left-n.right)/2,(n.top-n.bottom)/2).rotate(t.av(i)),w=S.add(C).mult(a.scale/t.aw(x));return{center:Ye(a.worldSize,s.add(l).div(2).sub(w)),zoom:x,bearing:i}}class qt{get useGlobeControls(){return!1}handlePanInertia(e,t){return{easingOffset:e,easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,n){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(n,e.around)}cameraForBoxAndBearing(e,t,n,r,i){return Kt(e,t,n,r,i)}handleJumpToCenterZoom(e,n){e.zoom!==(n.zoom===void 0?e.zoom:+n.zoom)&&e.setZoom(+n.zoom),n.center!==void 0&&e.setCenter(t.aa.convert(n.center))}handleEaseTo(e,n){let r=e.zoom,i=e.padding,a={roll:e.roll,pitch:e.pitch,bearing:e.bearing},o={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},s=n.zoom!==void 0,c=!e.isPaddingEqual(n.padding),l=!1,u=s?+n.zoom:e.zoom,d=e.centerPoint.add(n.offsetAsPoint),f=e.screenPointToLocation(d),{center:p,zoom:m}=e.getConstrained(t.aa.convert(n.center||f),u??r);Lt(e,p);let h=V(e.worldSize,f),g=V(e.worldSize,p).sub(h),_=t.aw(m-r);return l=m!==r,{easeFunc:s=>{if(l&&e.setZoom(t.C.number(r,m,s)),t.be(a,o)||Gt({startEulerAngles:a,endEulerAngles:o,tr:e,k:s,useSlerp:a.roll!=o.roll}),c&&(e.interpolatePadding(i,n.padding,s),d=e.centerPoint.add(n.offsetAsPoint)),n.around)e.setLocationAtPoint(n.around,n.aroundPoint);else{let n=t.aw(e.zoom-r),i=(m>r?Math.min(2,_):Math.max(.5,_))**(1-s),a=Ye(e.worldSize,h.add(g.mult(s*i)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?a.wrap():a,d)}},isZooming:l,elevationCenter:p}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.zoom,a=e.getConstrained(t.aa.convert(n.center||n.locationAtOffset),r?+n.zoom:i),o=a.center,s=a.zoom;Lt(e,o);let c=V(e.worldSize,n.locationAtOffset),l=V(e.worldSize,o).sub(c),u=l.mag(),d=t.aw(s-i),f;if(n.minZoom!==void 0){let r=Math.min(+n.minZoom,i,s),a=e.getConstrained(o,r).zoom;f=t.aw(a-i)}return{easeFunc:(n,r,a,u)=>{e.setZoom(n===1?s:i+t.az(r));let d=n===1?o:Ye(e.worldSize,c.add(l.mult(a)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?d.wrap():d,u)},scaleOfZoom:d,targetCenter:o,scaleOfMinZoom:f,pixelPathLength:u}}}class Jt{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}Jt.Replace=[1,0],Jt.disabled=new Jt(Jt.Replace,t.bf.transparent,[!1,!1,!1,!1]),Jt.unblended=new Jt(Jt.Replace,t.bf.transparent,[!0,!0,!0,!0]),Jt.alphaBlended=new Jt([1,771],t.bf.transparent,[!0,!0,!0,!0]);let Yt=2305;class W{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}W.disabled=new W(!1,1029,Yt),W.backCCW=new W(!0,1029,Yt),W.frontCCW=new W(!0,1028,Yt);class G{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}G.ReadOnly=!1,G.ReadWrite=!0,G.disabled=new G(519,G.ReadOnly,[0,1]);let Xt=7680;class K{constructor(e,t,n,r,i,a){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=a}}K.disabled=new K({func:519,mask:0},0,0,Xt,Xt,Xt);let Zt=new WeakMap;function Qt(e){if(Zt.has(e))return Zt.get(e);{let t=e.getParameter(e.VERSION)?.startsWith(`WebGL 2.0`);return Zt.set(e,t),t}}class $t{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;let n=e.context,r=n.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;let i=new t.aL;i.emplaceBack(-1,-1),i.emplaceBack(2,-1),i.emplaceBack(-1,2);let a=new t.aN;a.emplaceBack(0,1,2),this._fullscreenTriangle=new Mt(n.createVertexBuffer(i,Nt.members),n.createIndexBuffer(a),t.aM.simpleSegment(0,0,i.length,a.length)),this._resultBuffer=new Uint8Array(4),n.activeTexture.set(r.TEXTURE1);let o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=n.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),Qt(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){let e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){let n=this._updateCount;return this._readbackQueue?n>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():n>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){let e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,n){let r=this._cachedRenderContext.context,i=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.bf.transparent}),this._cachedRenderContext.useProgram(`projectionErrorMeasurement`).draw(r,i.TRIANGLES,G.disabled,K.disabled,Jt.unblended,W.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,n),null,null,`$clipping`,this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Qt(i)){i.bindBuffer(i.PIXEL_PACK_BUFFER,this._pbo),i.readBuffer(i.COLOR_ATTACHMENT0),i.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),i.bindBuffer(i.PIXEL_PACK_BUFFER,null);let e=i.fenceSync(i.SYNC_GPU_COMMANDS_COMPLETE,0);i.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){let e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Qt(e)){let n=e.clientWaitSync(this._readbackQueue.sync,0,0);if(n===e.WAIT_FAILED)return t.w(`WebGL2 clientWaitSync failed.`),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(n===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=$t._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}let en=t.ah/128;function tn(e,n){let r=e.granularity===void 0?1:Math.max(e.granularity,1),i=r+(e.generateBorders?2:0),a=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),o=i+1,s=a+1,c=e.generateBorders?-1:0,l=e.generateBorders||e.extendToNorthPole?-1:0,u=r+(e.generateBorders?1:0),d=r+(e.generateBorders||e.extendToSouthPole?1:0),f=o*s,p=i*a*6,m=o*s>65536;if(m&&n===`16bit`)throw Error(`Granularity is too large and meshes would not fit inside 16 bit vertex indices.`);let h=m||n===`32bit`,g=new Int16Array(2*f),_=0;for(let n=l;n<=d;n++)for(let i=c;i<=u;i++){let a=i/r*t.ah;i===-1&&(a=-en),i===r+1&&(a=t.ah+en);let o=n/r*t.ah;n===-1&&(o=e.extendToNorthPole?t.bh:-en),n===r+1&&(o=e.extendToSouthPole?t.bi:t.ah+en),g[_++]=a,g[_++]=o}let v=h?new Uint32Array(p):new Uint16Array(p),y=0;for(let e=0;e<a;e++)for(let t=0;t<i;t++){let n=t+1+e*o,r=t+(e+1)*o,i=t+1+(e+1)*o;v[y++]=t+e*o,v[y++]=r,v[y++]=n,v[y++]=n,v[y++]=r,v[y++]=i}return{vertices:g.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:h}}let nn=new t.aK({fill:new t.bj(128,2),line:new t.bj(512,0),tile:new t.bj(128,32),stencil:new t.bj(128,1),circle:3});class rn{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return`vertical-perspective`}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return`globe`}get shaderDefine(){return`#define GLOBE`}get shaderPreludeCode(){return At.projectionGlobe}get vertexShaderPreludeCode(){return At.projectionMercator.vertexSource}get subdivisionGranularity(){return nn}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(e){this._errorMeasurement||=new $t(e);let n=t.ab(this._errorQueryLatitudeDegrees),r=2*Math.atan(Math.exp(Math.PI-n*Math.PI*2))-.5*Math.PI,i=this._errorMeasurement.updateErrorLoop(n,r),a=o.now();i!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=i,this._errorMeasurementLastChangeTime=a);let s=Math.min(Math.max((a-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=t.bk(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,t.bl(s))}_getMeshKey(e){return`${e.granularity.toString(36)}_${e.generateBorders?`b`:``}${e.extendToNorthPole?`n`:``}${e.extendToSouthPole?`s`:``}`}getMeshFromTileID(e,t,n,r,i){let a=(i===`stencil`?nn.stencil:nn.tile).getGranularityForZoomLevel(t.z);return this._getMesh(e,{granularity:a,generateBorders:n,extendToNorthPole:t.y===0&&r,extendToSouthPole:t.y===(1<<t.z)-1&&r})}_getMesh(e,n){let r=this._getMeshKey(n);if(r in this._tileMeshCache)return this._tileMeshCache[r];let i=function(e,n){let r=tn(n,`16bit`),i=t.aL.deserialize({arrayBuffer:r.vertices,length:r.vertices.byteLength/2/2}),a=t.aN.deserialize({arrayBuffer:r.indices,length:r.indices.byteLength/2/3});return new Mt(e.createVertexBuffer(i,Nt.members),e.createIndexBuffer(a),t.aM.simpleSegment(0,0,i.length,a.length))}(e,n);return this._tileMeshCache[r]=i,i}recalculate(e){}hasTransition(){let e=o.now(),t=!1;return t||=(e-this._errorMeasurementLastChangeTime)/1e3<.7,t||=this._errorMeasurement&&this._errorMeasurement.awaitingQuery,t}setErrorQueryLatitudeDegrees(e){this._errorQueryLatitudeDegrees=e}}let an=new t.r({type:new t.D(t.v.projection.type)});class on extends t.E{constructor(e){super(),this._transitionable=new t.t(an),this.setProjection(e),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new t.F(0)),this._mercatorProjection=new Ft,this._verticalPerspectiveProjection=new rn}get transitionState(){let e=this.properties.get(`type`);if(typeof e==`string`&&e===`mercator`)return 0;if(typeof e==`string`&&e===`vertical-perspective`)return 1;if(e instanceof t.bm){if(e.from===`vertical-perspective`&&e.to===`mercator`)return 1-e.transition;if(e.from===`mercator`&&e.to===`vertical-perspective`)return e.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return`globe`}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,n,r,i){return this.currentProjection.getMeshFromTileID(e,t,n,r,i)}setProjection(e){this._transitionable.setValue(`type`,e?.type||`mercator`)}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function sn(e){let t=un(e.worldSize,e.center.lat);return 2*Math.PI*t}function cn(e,n,r,i,a){let o=1/(1<<a),s=n/t.ah*o+i*o,c=t.bo((e/t.ah*o+r*o)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-s*Math.PI*2))-.5*Math.PI,u=Math.cos(l),d=new Float64Array(3);return d[0]=Math.sin(c)*u,d[1]=Math.sin(l),d[2]=Math.cos(c)*u,d}function ln(e){return function(e,t){let n=Math.cos(t),r=new Float64Array(3);return r[0]=Math.sin(e)*n,r[1]=Math.sin(t),r[2]=Math.cos(e)*n,r}(e.lng*Math.PI/180,e.lat*Math.PI/180)}function un(e,t){return e/(2*Math.PI)/Math.cos(t*Math.PI/180)}function dn(e){let n=Math.asin(e[1])/Math.PI*180,r=Math.sqrt(e[0]*e[0]+e[2]*e[2]);if(r>1e-6){let i=e[0]/r,a=Math.acos(e[2]/r),o=(i>0?a:-a)/Math.PI*180;return new t.aa(t.aO(o,-180,180),n)}return new t.aa(0,n)}function fn(e){return Math.cos(e*Math.PI/180)}function pn(e,n){let r=fn(e),i=fn(n);return t.az(i/r)}function mn(e,n){let r=e.rotate(n.bearingInRadians),i=n.zoom+pn(n.center.lat,0),a=t.bk(1/fn(n.center.lat),1/fn(Math.min(Math.abs(n.center.lat),60)),t.bn(i,7,3,0,1)),o=360/sn({worldSize:n.worldSize,center:{lat:n.center.lat}});return new t.aa(n.center.lng-r.x*o*a,t.L(n.center.lat+r.y*o,-t.ax,t.ax))}function hn(e){let t=.5*e,n=Math.sin(t),r=Math.cos(t);return Math.log(n+r)-Math.log(r-n)}function gn(e,n,r,i){let a=e.lat+r*i;if(Math.abs(r)>1){let o=(Math.sign(e.lat+r)===Math.sign(e.lat)?Math.abs(e.lat):-Math.abs(e.lat))*Math.PI/180,s=Math.abs(e.lat+r)*Math.PI/180,c=hn(o+i*(s-o)),l=hn(o),u=hn(s);return new t.aa(e.lng+n*((c-l)/(u-l)),a)}return new t.aa(e.lng+n*i,a)}class _n{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;let e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,n,r){let i=`${e.z}_${e.x}_${e.y}_${r?.terrain?`t`:``}`,a=this._cache.get(i);if(a)return a;let o=this._cachePrevious.get(i);if(o)return this._cache.set(i,o),o;let s=this._boundingVolumeFactory(e,t,n,r);return this._cache.set(i,s),this._hadAnyChanges=!0,s}}class vn{constructor(e,t,n,r){this.min=n,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){let n=[];for(let r=0;r<8;r++)n.push([1&~r?e[0]:t[0],(r>>1&1)==1?t[1]:e[1],(r>>2&1)==1?t[2]:e[2]]);return new vn(n,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,n,r){let i=t.br([],r[0],r[1],r[2]),a=t.bs([],[n[0],0,0],i),o=t.bs([],[0,n[1],0],i),s=t.bs([],[0,0,n[2]],i),c=[...e],l=[...e];for(let t=0;t<8;t++)for(let n=0;n<3;n++){let r=e[n]+a[n]*(1&~t?-1:1)+o[n]*((t>>1&1)==1?1:-1)+s[n]*((t>>2&1)==1?1:-1);c[n]=Math.min(c[n],r),l[n]=Math.max(l[n],r)}let u=[];for(let n=0;n<8;n++){let r=[...e];t.aS(r,r,t.aR([],a,1&~n?-1:1)),t.aS(r,r,t.aR([],o,(n>>1&1)==1?1:-1)),t.aS(r,r,t.aR([],s,(n>>2&1)==1?1:-1)),u.push(r)}return new vn(u,[[...a,-t.aX(a,u[0])],[...o,-t.aX(o,u[0])],[...s,-t.aX(s,u[0])],[-a[0],-a[1],-a[2],-t.aX(a,u[7])],[-o[0],-o[1],-o[2],-t.aX(o,u[7])],[-s[0],-s[1],-s[2],-t.aX(s,u[7])]],c,l)}intersectsFrustum(e){let t=!0,n=this.points.length,r=this.planes.length,i=e.planes.length,a=e.points.length;for(let r=0;r<i;r++){let i=e.planes[r],a=0;for(let e=0;e<n;e++){let t=this.points[e];i[0]*t[0]+i[1]*t[1]+i[2]*t[2]+i[3]>=0&&a++}if(a===0)return 0;a<n&&(t=!1)}if(t)return 2;for(let t=0;t<r;t++){let n=this.planes[t],r=0;for(let t=0;t<a;t++){let i=e.points[t];n[0]*i[0]+n[1]*i[1]+n[2]*i[2]+n[3]>=0&&r++}if(r===0)return 0}return 1}intersectsPlane(e){let t=this.points.length,n=0;for(let r=0;r<t;r++){let t=this.points[r];e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0&&n++}return n===t?2:n===0?0:1}}function yn(e,t,n){let r=e-t;return r<0?-r:Math.max(0,r-n)}function bn(e,t,n,r,i){let a=e-n,o;return o=a<0?Math.min(-a,1+a-i):a>1?Math.min(Math.max(a-i,0),1-a):0,Math.max(o,yn(t,r,i))}class xn{constructor(){this._boundingVolumeCache=new _n(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,n,r){let i=1<<n.z,a=1/i,o=n.x/i,s=n.y/i,c=2;return c=Math.min(c,bn(e,t,o,s,a)),c=Math.min(c,bn(e,t,o+.5,-s-a,a)),c=Math.min(c,bn(e,t,o+.5,2-s-a,a)),c}getWrap(e,t,n){let r=1<<t.z,i=1/r,a=t.x/r,o=yn(e.x,a,i),s=yn(e.x,a-1,i),c=yn(e.x,a+1,i),l=Math.min(o,s,c);return l===c?1:l===s?-1:0}allowVariableZoom(e,t){return nt(e,t)>4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,n,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,n,r)}_computeTileBoundingVolume(e,n,r,i){let a=0,o=0;if(i?.terrain){let s=new t.ag(e.z,n,e.z,e.x,e.y),c=i.terrain.getMinMaxElevation(s);a=c.minElevation??Math.min(0,r),o=c.maxElevation??Math.max(0,r)}if(a/=t.bu,o/=t.bu,a+=1,o+=1,e.z<=0)return vn.fromAabb([-o,-o,-o],[o,o,o]);if(e.z===1)return vn.fromAabb([e.x===0?-o:0,e.y===0?0:-o,-o],[e.x===0?0:o,e.y===0?o:0,o]);{let n=[cn(0,0,e.x,e.y,e.z),cn(t.ah,0,e.x,e.y,e.z),cn(t.ah,t.ah,e.x,e.y,e.z),cn(0,t.ah,e.x,e.y,e.z)],r=[];for(let e of n)r.push(t.aR([],e,o));if(o!==a)for(let e of n)r.push(t.aR([],e,a));e.y===0&&r.push([0,1,0]),e.y===(1<<e.z)-1&&r.push([0,-1,0]);let i=[1,1,1],s=[-1,-1,-1];for(let e of r)for(let t=0;t<3;t++)i[t]=Math.min(i[t],e[t]),s[t]=Math.max(s[t],e[t]);let c=cn(t.ah/2,t.ah/2,e.x,e.y,e.z),l=t.aW([],[0,1,0],c);t.aV(l,l);let u=t.aW([],c,l);t.aV(u,u);let d=t.aW([],n[2],n[1]);t.aV(d,d);let f=t.aW([],n[0],n[3]);t.aV(f,f),r.push(t.aR([],c,o)),e.y>=(1<<e.z)/2&&r.push(t.aR([],cn(t.ah/2,0,e.x,e.y,e.z),o)),e.y<(1<<e.z)/2&&r.push(t.aR([],cn(t.ah/2,t.ah,e.x,e.y,e.z),o));let p=Sn(c,r),m=Sn(u,r),h=[-c[0],-c[1],-c[2],p.max],g=[c[0],c[1],c[2],-p.min],_=[-u[0],-u[1],-u[2],m.max],v=[u[0],u[1],u[2],-m.min],y=[...d,0],b=[...f,0],x=[];return e.y===0?x.push(t.bt(b,y,h),t.bt(b,y,g)):x.push(t.bt(_,y,h),t.bt(_,y,g),t.bt(_,b,h),t.bt(_,b,g)),e.y===(1<<e.z)-1?x.push(t.bt(b,y,h),t.bt(b,y,g)):x.push(t.bt(v,y,h),t.bt(v,y,g),t.bt(v,b,h),t.bt(v,b,g)),new vn(x,[h,g,_,v,y,b],i,s)}}}function Sn(e,n){let r=1/0,i=-1/0;for(let a of n){let n=t.aX(e,a);r=Math.min(r,n),i=Math.max(i,n)}return{min:r,max:i}}class Cn{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(e){this._helper.setDetailLevel(e)}setRasterAlignment(e){this._helper.setRasterAlignment(e)}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){return this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t){this._helper.resize(e,t)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e){}constructor(){this._cachedClippingPlane=t.bv(),this._projectionMatrix=t.b9(),this._globeViewProjMatrix32f=t.b8(),this._globeViewProjMatrixNoCorrection=t.b9(),this._globeViewProjMatrixNoCorrectionInverted=t.b9(),this._globeProjMatrixInverted=t.b9(),this._cameraPosition=t.bp(),this._globeLatitudeErrorCorrectionRadians=0,this._helper=new zt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._coveringTilesDetailsProvider=new xn}clone(){let e=new Cn;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let e=t.bp();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){let{overscaledTileID:t,applyGlobeMatrix:n}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:n?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){let n=this.pitchInRadians,r=this.cameraToCenterDistance/e,i=Math.sin(n)*r,a=Math.cos(n)*r+1,o=1/Math.sqrt(i*i+a*a)*1,s=-i,c=a,l=Math.sqrt(s*s+c*c);s/=l,c/=l;let u=[0,s,c];t.bw(u,u,[0,0,0],-this.bearingInRadians),t.bx(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.by(u,u,[0,0,0],this.center.lng*Math.PI/180);let d=1/t.aZ(u);return t.aR(u,u,d),[...u,-o*d]}isLocationOccluded(e){return!this.isSurfacePointVisible(ln(e))}transformLightDirection(e){let n=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,i=Math.cos(r),a=[Math.sin(n)*i,Math.sin(r),Math.cos(n)*i],o=[a[2],0,-a[0]],s=[0,0,0];t.aW(s,o,a),t.aV(o,o),t.aV(s,s);let c=[0,0,0];return t.aV(c,[o[0]*e[0]+s[0]*e[1]+a[0]*e[2],o[1]*e[0]+s[1]*e[1]+a[1]*e[2],o[2]*e[0]+s[2]*e[1]+a[2]*e[2]]),c}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,n,r){let i=function(e,n,r){let i=1/(1<<r.z);return new t.aj(e/t.ah*i+r.x*i,n/t.ah*i+r.y*i)}(e,n,r.canonical),a=(o=i.y,[t.bo(i.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(a[1])}projectTileCoordinates(e,n,r,i){let a=r.canonical,o=cn(e,n,a.x,a.y,a.z),s=1+(i?i(e,n):0)/t.bu,c=[o[0]*s,o[1]*s,o[2]*s,1];t.$(c,c,this._globeViewProjMatrixNoCorrection);let l=this._cachedClippingPlane,u=l[0]*o[0]+l[1]*o[1]+l[2]*o[2]+l[3]<0;return{point:new t.P(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:u}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;let e=un(this.worldSize,this.center.lat),n=t.ba(),r=t.ba();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),t.b4(n,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;n[8]=2*-i.x/this._helper._width,n[9]=2*i.y/this._helper._height,this._projectionMatrix=t.b5(n),this._globeProjMatrixInverted=t.ba(),t.S(this._globeProjMatrixInverted,n),t.a5(n,n,[0,0,-this.cameraToCenterDistance]),t.b6(n,n,this.rollInRadians),t.b7(n,n,-this.pitchInRadians),t.b6(n,n,this.bearingInRadians),t.a5(n,n,[0,0,-e]);let a=t.bp();a[0]=e,a[1]=e,a[2]=e,t.b7(r,n,this.center.lat*Math.PI/180),t.bz(r,r,-this.center.lng*Math.PI/180),t.N(r,r,a),this._globeViewProjMatrixNoCorrection=r,t.b7(n,n,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),t.bz(n,n,-this.center.lng*Math.PI/180),t.N(n,n,a),this._globeViewProjMatrix32f=new Float32Array(n),this._globeViewProjMatrixNoCorrectionInverted=t.ba(),t.S(this._globeViewProjMatrixNoCorrectionInverted,r);let o=t.bp();this._cameraPosition=t.bp(),this._cameraPosition[2]=this.cameraToCenterDistance/e,t.bw(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),t.bx(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),t.bw(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),t.aS(this._cameraPosition,this._cameraPosition,[0,0,1]),t.bx(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),t.by(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let s=t.b5(this._globeViewProjMatrixNoCorrectionInverted);t.N(s,s,[1,1,-1]),this._cachedFrustum=Ht.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(e){t.w(`calculateFogMatrix is not supported on globe projection.`);let n=t.ba();return t.a4(n),n}getVisibleUnwrappedCoordinates(e){return[new t.b2(0,e)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){e&&t.w(`terrain is not fully supported on vertical perspective projection.`),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,n){if(!this._globeViewProjMatrixNoCorrection)return 1;let r=ln(e);t.aR(r,r,1+n/t.bu);let i=t.bv();return t.$(i,[r[0],r[1],r[2],1],this._globeViewProjMatrixNoCorrection),i[2]/i[3]}populateCache(e){}getBounds(){let e=.5*this.width,n=.5*this.height,r=[new t.P(0,0),new t.P(e,0),new t.P(this.width,0),new t.P(this.width,n),new t.P(this.width,this.height),new t.P(e,this.height),new t.P(0,this.height),new t.P(0,n)],i=[];for(let e of r)i.push(this.unprojectScreenPoint(e));let a=0,o=0,s=0,c=0,l=this.center;for(let e of i){let n=t.bA(l.lng,e.lng),r=t.bA(l.lat,e.lat);n<o&&(o=n),n>a&&(a=n),r<c&&(c=r),r>s&&(s=r)}let u=[l.lng+o,l.lat+c,l.lng+a,l.lat+s];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new I(u)}getConstrained(e,n){let r=t.L(e.lat,-t.ax,t.ax),i=t.L(+n,this.minZoom+pn(0,r),this.maxZoom);return{center:new t.aa(e.lng,r),zoom:i}}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,n){let r=ln(this.unprojectScreenPoint(n)),i=ln(e),a=t.bp();t.bB(a);let o=t.bp();t.by(o,r,a,-this.center.lng*Math.PI/180),t.bx(o,o,a,this.center.lat*Math.PI/180);let s=i[0]*i[0]+i[2]*i[2],c=o[0]*o[0];if(s<c)return;let l=Math.sqrt(s-c),u=-l,d=t.bC(i[0],i[2],o[0],l),f=t.bC(i[0],i[2],o[0],u),p=t.bp();t.by(p,i,a,-d);let m=t.bC(p[1],p[2],o[1],o[2]),h=t.bp();t.by(h,i,a,-f);let g=t.bC(h[1],h[2],o[1],o[2]),_=.5*Math.PI,v=m>=-_&&m<=_,y=g>=-_&&g<=_,b,x;if(v&&y){let e=this.center.lng*Math.PI/180,n=this.center.lat*Math.PI/180;t.bD(d,e)+t.bD(m,n)<t.bD(f,e)+t.bD(g,n)?(b=d,x=m):(b=f,x=g)}else if(v)b=d,x=m;else{if(!y)return;b=f,x=g}let S=b/Math.PI*180,C=x/Math.PI*180,w=this.center.lat;this.setCenter(new t.aa(S,t.L(C,-90,90))),this.setZoom(this.zoom+pn(w,this.center.lat))}locationToScreenPoint(e,n){let r=ln(e);if(n){let i=n.getElevationForLngLatZoom(e,this._helper._tileZoom);t.aR(r,r,1+i/t.bu)}return this._projectSurfacePointToScreen(r)}_projectSurfacePointToScreen(e){let n=t.bv();return t.$(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],new t.P((.5*n[0]+.5)*this.width,(.5*-n[1]+.5)*this.height)}screenPointToMercatorCoordinate(e,n){if(n){let t=n.pointCoordinate(e);if(t)return t}return t.aj.fromLngLat(this.unprojectScreenPoint(e))}screenPointToLocation(e,t){return this.screenPointToMercatorCoordinate(e,t)?.toLngLat()}isPointOnMapSurface(e,t){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e);return!!this.rayPlanetIntersection(n,r)}getRayDirectionFromPixel(e){let n=t.bv();n[0]=e.x/this.width*2-1,n[1]=-1*(e.y/this.height*2-1),n[2]=1,n[3]=1,t.$(n,n,this._globeViewProjMatrixNoCorrectionInverted),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3];let r=t.bp();r[0]=n[0]-this._cameraPosition[0],r[1]=n[1]-this._cameraPosition[1],r[2]=n[2]-this._cameraPosition[2];let i=t.bp();return t.aV(i,r),i}isSurfacePointVisible(e){let t=this._cachedClippingPlane;return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;let n=t.bv();return t.$(n,[...e,1],this._globeViewProjMatrixNoCorrection),n[0]/=n[3],n[1]/=n[3],n[2]/=n[3],n[0]>-1&&n[0]<1&&n[1]>-1&&n[1]<1&&n[2]>-1&&n[2]<1}rayPlanetIntersection(e,n){let r=t.aX(e,n),i=t.bp(),a=t.bp();t.aR(a,n,r),t.aU(i,e,a);let o=1-t.aX(i,i);if(o<0)return null;let s=t.aX(e,e)-1,c=-r+(r<0?1:-1)*Math.sqrt(o),l=s/c,u=c;return{tMin:Math.min(l,u),tMax:Math.max(l,u)}}unprojectScreenPoint(e){let n=this._cameraPosition,r=this.getRayDirectionFromPixel(e),i=this.rayPlanetIntersection(n,r);if(i){let e=t.bp();t.aS(e,n,[r[0]*i.tMin,r[1]*i.tMin,r[2]*i.tMin]);let a=t.bp();return t.aV(a,e),dn(a)}let a=this._cachedClippingPlane,o=a[0]*r[0]+a[1]*r[1]+a[2]*r[2],s=-t.b1(a,n)/o,c=t.bp();if(s>0)t.aS(c,n,[r[0]*s,r[1]*s,r[2]*s]);else{let e=t.bp();t.aS(e,n,[2*r[0],2*r[1],2*r[2]]);let i=t.b1(this._cachedClippingPlane,e);t.aU(c,e,[this._cachedClippingPlane[0]*i,this._cachedClippingPlane[1]*i,this._cachedClippingPlane[2]*i])}let l=function(e){let n=t.bp();return n[0]=e[0]*-e[3],n[1]=e[1]*-e[3],n[2]=e[2]*-e[3],{center:n,radius:Math.sqrt(1-e[3]*e[3])}}(a);return dn(function(e,n,r){let i=t.bp();t.aU(i,r,e);let a=t.bp();return t.bq(a,e,i,n/t.a$(i)),a}(l.center,l.radius,c))}getMatrixForModel(e,n){let r=t.aa.convert(e),i=1/t.bu,a=t.b9();return t.bz(a,a,r.lng/180*Math.PI),t.b7(a,a,-r.lat/180*Math.PI),t.a5(a,a,[0,0,1+n/t.bu]),t.b7(a,a,.5*Math.PI),t.N(a,a,[i,i,i]),a}getProjectionDataForCustomLayer(e=!0){let n=this.getProjectionData({overscaledTileID:new t.ag(0,0,0,0,0),applyGlobeMatrix:e});return n.tileMercatorCoords=[0,0,1,1],n}getFastPathSimpleProjectionMatrix(e){}}class wn{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setDetailLevel(e){this._helper.setDetailLevel(e)}setRasterAlignment(e){this._helper.setRasterAlignment(e)}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,n){return this._helper.interpolatePadding(e,t,n)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,n=!0){this._helper.resize(e,t,n)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get detailLevel(){return this._helper.detailLevel}get rasterAlignment(){return this._helper.rasterAlignment}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this._helper=new zt({calcMatrices:()=>{this._calcMatrices()},getConstrained:(e,t)=>this.getConstrained(e,t)}),this._globeness=1,this._mercatorTransform=new Ut,this._verticalPerspectiveTransform=new Cn}clone(){let e=new wn;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){let t=this._mercatorTransform.getProjectionData(e),n=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?n.mainMatrix:t.mainMatrix,clippingPlane:n.clippingPlane,tileMercatorCoords:n.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bk(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bk(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,n,r){let i=this._mercatorTransform.getPitchedTextCorrection(e,n,r),a=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,n,r);return t.bk(i,a,this._globeness)}projectTileCoordinates(e,t,n,r){return this.currentTransform.projectTileCoordinates(e,t,n,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}getConstrained(e,t){return this.currentTransform.getConstrained(e,t)}calculateCenterFromCameraLngLatAlt(e,t,n,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,n,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){let t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;let n=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return n.fallbackMatrix=t.mainMatrix,n}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Tn{get useGlobeControls(){return!0}handlePanInertia(e,n){let r=mn(e,n);return Math.abs(r.lng-n.center.lng)>180&&(r.lng=n.center.lng+179.5*Math.sign(r.lng-n.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,n){let r=e.around,i=n.screenPointToLocation(r);e.bearingDelta&&n.setBearing(n.bearing+e.bearingDelta),e.pitchDelta&&n.setPitch(n.pitch+e.pitchDelta),e.rollDelta&&n.setRoll(n.roll+e.rollDelta);let a=n.zoom;e.zoomDelta&&n.setZoom(n.zoom+e.zoomDelta);let o=n.zoom-a;if(o===0)return;let s=t.bA(n.center.lng,i.lng),c=s/(Math.abs(s/180)+1),l=t.bA(n.center.lat,i.lat),u=n.getRayDirectionFromPixel(r),d=n.cameraPosition,f=-1*t.aX(d,u),p=t.bp();t.aS(p,d,[u[0]*f,u[1]*f,u[2]*f]);let m=t.aZ(p)-1,h=Math.exp(.5*-Math.max(m-.3,0)),g=un(n.worldSize,n.center.lat)/Math.min(n.width,n.height),_=t.bn(g,.9,.5,1,.25),v=(1-t.aw(-o))*Math.min(h,_),y=n.center.lat,b=n.zoom,x=new t.aa(n.center.lng+c*v,t.L(n.center.lat+l*v,-t.ax,t.ax));n.setLocationAtPoint(i,r);let S=n.center,C=t.bn(Math.abs(s),45,85,0,1),w=t.bn(g,.75,.35,0,1),T=Math.max(C,w)**.25,E=t.bA(S.lng,x.lng),D=t.bA(S.lat,x.lat);n.setCenter(new t.aa(S.lng+E*T,S.lat+D*T).wrap()),n.setZoom(b+pn(y,n.center.lat))}handleMapControlsPan(e,t,n){if(!e.panDelta)return;let r=t.center.lat,i=t.zoom;t.setCenter(mn(e.panDelta,t).wrap()),t.setZoom(i+pn(r,t.center.lat))}cameraForBoxAndBearing(e,n,r,i,a){let o=Kt(e,n,r,i,a),s=n.left/a.width*2-1,c=(a.width-n.right)/a.width*2-1,l=n.top/a.height*-2+1,u=(a.height-n.bottom)/a.height*-2+1,d=t.bA(r.getWest(),r.getEast())<0,f=d?r.getEast():r.getWest(),p=d?r.getWest():r.getEast(),m=Math.max(r.getNorth(),r.getSouth()),h=Math.min(r.getNorth(),r.getSouth()),g=f+.5*t.bA(f,p),_=m+.5*t.bA(m,h),v=a.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);let y=v.modelViewProjectionMatrix,b=[ln(r.getNorthWest()),ln(r.getNorthEast()),ln(r.getSouthWest()),ln(r.getSouthEast()),ln(new t.aa(p,_)),ln(new t.aa(f,_)),ln(new t.aa(g,m)),ln(new t.aa(g,h))],x=ln(o.center),S=1/0;for(let e of b)s<0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`x`,s))),c>0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`x`,c))),l>0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`y`,l))),u<0&&(S=Tn.getLesserNonNegativeNonNull(S,Tn.solveVectorScale(e,x,y,`y`,u)));if(Number.isFinite(S)&&S!==0)return o.zoom=v.zoom+t.az(S),o;Wt()}handleJumpToCenterZoom(e,n){let r=e.center.lat,i=e.getConstrained(n.center?t.aa.convert(n.center):e.center,e.zoom).center;e.setCenter(i.wrap());let a=n.zoom===void 0?e.zoom+pn(r,i.lat):+n.zoom;e.zoom!==a&&e.setZoom(a)}handleEaseTo(e,n){let r=e.zoom,i=e.center,a=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:n.roll===void 0?e.roll:n.roll,pitch:n.pitch===void 0?e.pitch:n.pitch,bearing:n.bearing===void 0?e.bearing:n.bearing},c=n.zoom!==void 0,l=!e.isPaddingEqual(n.padding),u=!1,d=n.center?t.aa.convert(n.center):i,f=e.getConstrained(d,r).center;Lt(e,f);let p=e.clone();p.setCenter(f),p.setZoom(c?+n.zoom:r+pn(i.lat,d.lat)),p.setBearing(n.bearing);let m=new t.P(t.L(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.L(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(f,m);let h=(n.offset&&n.offsetAsPoint.mag())>0?p.center:f,g=c?+n.zoom:r+pn(i.lat,h.lat),_=r+pn(i.lat,0),v=g+pn(h.lat,0),y=t.bA(i.lng,h.lng),b=t.bA(i.lat,h.lat),x=t.aw(v-_);return u=g!==r,{easeFunc:r=>{if(t.be(o,s)||Gt({startEulerAngles:o,endEulerAngles:s,tr:e,k:r,useSlerp:o.roll!=s.roll}),l&&e.interpolatePadding(a,n.padding,r),n.around)t.w(`Easing around a point is not supported under globe projection.`),e.setLocationAtPoint(n.around,n.aroundPoint);else{let t=gn(i,y,b,r*(v>_?Math.min(2,x):Math.max(.5,x))**(1-r));e.setCenter(t.wrap())}if(u){let n=t.C.number(_,v,r)+pn(0,e.center.lat);e.setZoom(n)}},isZooming:u,elevationCenter:h}}handleFlyTo(e,n){let r=n.zoom!==void 0,i=e.center,a=e.zoom,o=e.padding,s=!e.isPaddingEqual(n.padding),c=e.getConstrained(t.aa.convert(n.center||n.locationAtOffset),a).center,l=r?+n.zoom:e.zoom+pn(e.center.lat,c.lat),u=e.clone();u.setCenter(c),u.setZoom(l),u.setBearing(n.bearing);let d=new t.P(t.L(e.centerPoint.x+n.offsetAsPoint.x,0,e.width),t.L(e.centerPoint.y+n.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(c,d);let f=u.center;Lt(e,f);let p=function(e,n,r){let i=ln(n),a=ln(r),o=t.aX(i,a),s=Math.acos(o),c=sn(e);return s/(2*Math.PI)*c}(e,i,f),m=a+pn(i.lat,0),h=l+pn(f.lat,0),g=t.aw(h-m),_;if(typeof n.minZoom==`number`){let r=+n.minZoom+pn(f.lat,0),i=Math.min(r,m,h)+pn(0,f.lat),a=e.getConstrained(f,i).zoom+pn(f.lat,0);_=t.aw(a-m)}let v=t.bA(i.lng,f.lng),y=t.bA(i.lat,f.lat);return{easeFunc:(r,a,c,u)=>{let d=gn(i,v,y,c);s&&e.interpolatePadding(o,n.padding,r);let p=r===1?f:d;e.setCenter(p.wrap());let h=m+t.az(a);e.setZoom(r===1?l:h+pn(0,p.lat))},scaleOfZoom:g,targetCenter:f,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,n,r,i){let a=r===`x`?[n[0],n[4],n[8],n[12]]:[n[1],n[5],n[9],n[13]],o=[n[3],n[7],n[11],n[15]],s=e[0]*a[0]+e[1]*a[1]+e[2]*a[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=t[0]*a[0]+t[1]*a[1]+t[2]*a[2],u=t[0]*o[0]+t[1]*o[1]+t[2]*o[2];return l+i*c===s+i*u||o[3]*(s-l)+a[3]*(u-c)+s*u==l*c?null:(l+a[3]-i*u-i*o[3])/(l-s-i*u+i*c)}static getLesserNonNegativeNonNull(e,t){return t!==null&&t>=0&&t<e?t:e}}class En{constructor(e){this._globe=e,this._mercatorCameraHelper=new qt,this._verticalPerspectiveCameraHelper=new Tn}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(e,t){return this.currentHelper.handlePanInertia(e,t)}handleMapControlsRollPitchBearingZoom(e,t){return this.currentHelper.handleMapControlsRollPitchBearingZoom(e,t)}handleMapControlsPan(e,t,n){this.currentHelper.handleMapControlsPan(e,t,n)}cameraForBoxAndBearing(e,t,n,r,i){return this.currentHelper.cameraForBoxAndBearing(e,t,n,r,i)}handleJumpToCenterZoom(e,t){this.currentHelper.handleJumpToCenterZoom(e,t)}handleEaseTo(e,t){return this.currentHelper.handleEaseTo(e,t)}handleFlyTo(e,t){return this.currentHelper.handleFlyTo(e,t)}}let Dn=(e,n)=>t.y(e,n&&n.filter((e=>e.identifier!==`source.canvas`))),On=t.bE();class kn extends t.E{constructor(e,n={}){super(),this._rtlPluginLoaded=()=>{for(let e in this.sourceCaches){let t=this.sourceCaches[e].getSource().type;t!==`vector`&&t!==`geojson`||this.sourceCaches[e].reload()}},this.map=e,this.dispatcher=new F(te(),e._getMapId()),this.dispatcher.registerMessageHandler(`GG`,((e,t)=>this.getGlyphs(e,t))),this.dispatcher.registerMessageHandler(`GI`,((e,t)=>this.getImages(e,t))),this.imageManager=new b,this.imageManager.setEventedParent(this);let r=e._container?.lang||typeof document<`u`&&document.documentElement?.lang||void 0;this.glyphManager=new w(e._requestManager,n.localIdeographFontFamily,r),this.lineAtlas=new A(256,512),this.crossTileSymbolIndex=new Ot,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new t.bF,this._loaded=!1,this._availableImages=[],this._labelFreeAreas=[],this._globalState={},this._resetUpdates(),this.dispatcher.broadcast(`SR`,t.bG()),Ke().on(We,this._rtlPluginLoaded),this.on(`data`,(e=>{if(e.dataType!==`source`||e.sourceDataType!==`metadata`)return;let t=this.sourceCaches[e.sourceId];if(!t)return;let n=t.getSource();if(n&&n.vectorLayerIds)for(let e in this._layers){let t=this._layers[e];t.source===n.id&&this._validateLayer(t)}}))}setGlobalStateProperty(e,n){this._checkLoaded();let r=n===null?this.stylesheet.state?.[e]?.default??null:n;if(t.bH(r,this._globalState[e]))return this;this._globalState[e]=r,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();let n=[];for(let r in e)!t.bH(this._globalState[r],e[r].default)&&(n.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(n)}_applyGlobalStateChanges(e){if(e.length===0)return;let t=new Set;for(let n in this._layers){let r=this._layers[n],i=r.getLayoutAffectingGlobalStateRefs(),a=r.getPaintAffectingGlobalStateRefs();for(let n of e)if(i.has(n)&&t.add(r.source),a.has(n))for(let{name:e,value:t}of a.get(n))this._updatePaintProperty(r,e,t)}for(let e in this.sourceCaches)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,n={},r){this.fire(new t.l(`dataloading`,{dataType:`style`})),n.validate=typeof n.validate!=`boolean`||n.validate;let i=this.map._requestManager.transformRequest(e,`Style`);this._loadStyleRequest=new AbortController;let a=this._loadStyleRequest;t.j(i,this._loadStyleRequest).then((e=>{this._loadStyleRequest=null,this._load(e.data,n,r)})).catch((e=>{this._loadStyleRequest=null,e&&!a.signal.aborted&&this.fire(new t.k(e))}))}loadJSON(e,n={},r){this.fire(new t.l(`dataloading`,{dataType:`style`})),this._frameRequest=new AbortController,o.frameAsync(this._frameRequest).then((()=>{this._frameRequest=null,n.validate=!1!==n.validate,this._load(e,n,r)})).catch((()=>{}))}loadEmpty(){this.fire(new t.l(`dataloading`,{dataType:`style`})),this._load(On,{validate:!1})}_load(e,n,r){let i=n.transformStyle?n.transformStyle(r,e):e;if(!n.validate||!Dn(this,t.z(i))){i=Object.assign({},i),this._loaded=!0,this.stylesheet=i;for(let e in i.sources)this.addSource(e,i.sources[e],{validate:!1});i.sprite?this._loadSprite(i.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(i.glyphs),this._createLayers(),this.light=new D(this.stylesheet.light),this._setProjectionInternal(this.stylesheet.projection?.type||`mercator`),this.sky=new k(this.stylesheet.sky),this.map.setTerrain(this.stylesheet.terrain??null),this.setGlobalState(this.stylesheet.state??null),this.fire(new t.l(`data`,{dataType:`style`})),this.fire(new t.l(`style.load`))}}_createLayers(){let e=t.bI(this.stylesheet.layers);this.dispatcher.broadcast(`SL`,e),this._order=e.map((e=>e.id)),this._layers={},this._serializedLayers=null;for(let n of e){let e=t.bJ(n);e.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=e}}_loadSprite(e,n=!1,r=void 0){let i;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,v(e,this.map._requestManager,this.map.getPixelRatio()*this.map.getScale(),this._spriteRequest).then((e=>{if(this._spriteRequest=null,e)for(let t in e){this._spritesImagesIds[t]=[];let r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter((t=>!(t in e))):[];for(let e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(let r in e[t]){let i=t===`default`?r:`${t}:${r}`;this._spritesImagesIds[t].push(i),i in this.imageManager.images?this.imageManager.updateImage(i,e[t][r],!1):this.imageManager.addImage(i,e[t][r]),n&&(this._changedImages[i]=!0)}}})).catch((e=>{this._spriteRequest=null,i=e,this.fire(new t.k(i))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`})),r&&r(i)}))}_unloadSprite(){for(let e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`}))}_validateLayer(e){let n=this.sourceCaches[e.source];if(!n)return;let r=e.sourceLayer;if(!r)return;let i=n.getSource();(i.type===`geojson`||i.vectorLayerIds&&i.vectorLayerIds.indexOf(r)===-1)&&this.fire(new t.k(Error(`Source layer "${r}" does not exist on source "${i.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let e in this.sourceCaches)if(!this.sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,n=!1){let r=this._serializedAllLayers();if(!e||e.length===0)return Object.values(n?t.bK(r):r);let i=[];for(let a of e)if(r[a]){let e=n?t.bK(r[a]):r[a];i.push(e)}return i}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};let t=Object.keys(this._layers);for(let n of t){let t=this._layers[n];t.type!==`custom`&&(e[n]=t.serialize())}return e}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let e in this.sourceCaches)if(this.sourceCaches[e].hasTransition())return!0;for(let e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error(`Style is not done loading.`)}update(e){if(!this._loaded)return;let n=this._changed;if(n){let t=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(t.length||n.length)&&this._updateWorkerLayers(t,n);for(let e in this._updatedSources){let t=this._updatedSources[e];if(t===`reload`)this._reloadSource(e);else{if(t!==`clear`)throw Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}let r={};for(let e in this.sourceCaches){let t=this.sourceCaches[e];r[e]=t.used,t.used=!1}for(let t of this._order){let n=this._layers[t];n.recalculate(e,this._availableImages),!n.isHidden(e.zoom)&&n.source&&(this.sourceCaches[n.source].used=!0)}for(let e in r){let n=this.sourceCaches[e];!!r[e]!=!!n.used&&n.fire(new t.l(`data`,{sourceDataType:`visibility`,dataType:`source`,sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,n&&this.fire(new t.l(`data`,{dataType:`style`}))}_updateTilesForChangedImages(){let e=Object.keys(this._changedImages);if(e.length){for(let t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies([`icons`,`patterns`],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let e in this.sourceCaches)this.sourceCaches[e].reloadTilesForDependencies([`glyphs`],[``]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast(`UL`,{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,n={}){var r;this._checkLoaded();let i=this.serialize();if(e=n.transformStyle?n.transformStyle(i,e):e,((r=n.validate)==null||r)&&Dn(this,t.z(e)))return!1;(e=t.bK(e)).layers=t.bI(e.layers);let a=t.bL(i,e),o=this._getOperationsToPerform(a);if(o.unimplemented.length>0)throw Error(`Unimplemented: ${o.unimplemented.join(`, `)}.`);if(o.operations.length===0)return!1;for(let e of o.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){let t=[],n=[];for(let r of e)switch(r.command){case`setCenter`:case`setZoom`:case`setBearing`:case`setPitch`:case`setRoll`:continue;case`addLayer`:t.push((()=>this.addLayer.apply(this,r.args)));break;case`removeLayer`:t.push((()=>this.removeLayer.apply(this,r.args)));break;case`setPaintProperty`:t.push((()=>this.setPaintProperty.apply(this,r.args)));break;case`setLayoutProperty`:t.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case`setFilter`:t.push((()=>this.setFilter.apply(this,r.args)));break;case`addSource`:t.push((()=>this.addSource.apply(this,r.args)));break;case`removeSource`:t.push((()=>this.removeSource.apply(this,r.args)));break;case`setLayerZoomRange`:t.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case`setLight`:t.push((()=>this.setLight.apply(this,r.args)));break;case`setGeoJSONSourceData`:t.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case`setGlyphs`:t.push((()=>this.setGlyphs.apply(this,r.args)));break;case`setSprite`:t.push((()=>this.setSprite.apply(this,r.args)));break;case`setTerrain`:t.push((()=>this.map.setTerrain.apply(this,r.args)));break;case`setSky`:t.push((()=>this.setSky.apply(this,r.args)));break;case`setProjection`:this.setProjection.apply(this,r.args);break;case`setGlobalState`:t.push((()=>this.setGlobalState.apply(this,r.args)));break;case`setTransition`:t.push((()=>{}));break;default:n.push(r.command)}return{operations:t,unimplemented:n}}addImage(e,n){if(this.getImage(e))return this.fire(new t.k(Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,n),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`}))}addImages(e){for(let t in e)this.getImage(t)&&this.imageManager.removeImage(t),this.imageManager.addImage(t,e[t]),this._changedImages[t]=!0;return this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`})),this}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,n,r={}){if(this._checkLoaded(),this.sourceCaches[e]!==void 0)throw Error(`Source "${e}" already exists.`);if(!n.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(`, `)}.`);if([`vector`,`raster`,`geojson`,`video`,`image`].indexOf(n.type)>=0&&this._validate(t.z.source,`sources.${e}`,n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);let i=this.sourceCaches[e]=new at(e,n,this.dispatcher);i.style=this,i.setEventedParent(this,(()=>({isSourceLoaded:i.loaded(),source:i.serialize(),sourceId:e}))),i.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw Error(`There is no source with this ID`);for(let n in this._layers)if(this._layers[n].source===e)return this.fire(new t.k(Error(`Source "${e}" cannot be removed while layer "${n}" is using it.`)));let n=this.sourceCaches[e];delete this.sourceCaches[e],delete this._updatedSources[e],n.fire(new t.l(`data`,{sourceDataType:`metadata`,dataType:`source`,sourceId:e})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),this.sourceCaches[e]===void 0)throw Error(`There is no source with this ID=${e}`);let n=this.sourceCaches[e].getSource();if(n.type!==`geojson`)throw Error(`geojsonSource.type is ${n.type}, which is !== 'geojson`);n.setData(t),this._changed=!0}getSource(e){return this.sourceCaches[e]&&this.sourceCaches[e].getSource()}addLayer(e,n,r={}){this._checkLoaded();let i=e.id;if(this.getLayer(i))return void this.fire(new t.k(Error(`Layer "${i}" already exists on this map.`)));let a;if(e.type===`custom`){if(Dn(this,t.bM(e)))return;a=t.bJ(e)}else{if(`source`in e&&typeof e.source==`object`&&(this.addSource(i,e.source),e=t.bK(e),e=t.e(e,{source:i})),this._validate(t.z.layer,`layers.${i}`,e,{arrayIndex:-1},r))return;a=t.bJ(e),this._validateLayer(a),a.setEventedParent(this,{layer:{id:i}})}let o=n?this._order.indexOf(n):this._order.length;if(n&&o===-1)this.fire(new t.k(Error(`Cannot add layer "${i}" before non-existing layer "${n}".`)));else{if(this._order.splice(o,0,i),this._layerOrderChanged=!0,this._layers[i]=a,this._removedLayers[i]&&a.source&&a.type!==`custom`){let e=this._removedLayers[i];delete this._removedLayers[i],e.type===a.type?(this._updatedSources[a.source]=`reload`,this.sourceCaches[a.source].pause()):this._updatedSources[a.source]=`clear`}this._updateLayer(a),a.onAdd&&a.onAdd(this.map)}}moveLayer(e,n){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===n)return;let r=this._order.indexOf(e);this._order.splice(r,1);let i=n?this._order.indexOf(n):this._order.length;n&&i===-1?this.fire(new t.k(Error(`Cannot move layer "${e}" before non-existing layer "${n}".`))):(this._order.splice(i,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();let n=this._layers[e];if(!n)return void this.fire(new t.k(Error(`Cannot remove non-existing layer "${e}".`)));n.setEventedParent(null);let r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=n,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],n.onRemove&&n.onRemove(this.map)}getLayer(e){return this._layers[e]}setLayersOrder(e){this._checkLoaded(),this._order=e.filter((e=>this._layers[e]!==void 0)),this._layerOrderChanged=!0}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,n,r){this._checkLoaded();let i=this.getLayer(e);i?i.minzoom===n&&i.maxzoom===r||(n!=null&&(i.minzoom=n),r!=null&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new t.k(Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,n,r={}){this._checkLoaded();let i=this.getLayer(e);if(i){if(!t.bH(i.filter,n))return n==null?(i.setFilter(void 0),void this._updateLayer(i)):void(this._validate(t.z.filter,`layers.${i.id}.filter`,n,null,r)||(i.setFilter(t.bK(n)),this._updateLayer(i)))}else this.fire(new t.k(Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bK(this.getLayer(e).filter)}setLayoutProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bH(a.getLayoutProperty(n),r)||(a.setLayoutProperty(n,r,i),this._updateLayer(a)):this.fire(new t.k(Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,n){let r=this.getLayer(e);if(r)return r.getLayoutProperty(n);this.fire(new t.k(Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,n,r,i={}){this._checkLoaded();let a=this.getLayer(e);a?t.bH(a.getPaintProperty(n),r)||this._updatePaintProperty(a,n,r,i):this.fire(new t.k(Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,t,n,r={}){e.setPaintProperty(t,n,r)&&this._updateLayer(e),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,n){this._checkLoaded();let r=e.source,i=e.sourceLayer,a=this.sourceCaches[r];if(a===void 0)return void this.fire(new t.k(Error(`The source '${r}' does not exist in the map's style.`)));let o=a.getSource().type;o===`geojson`&&i?this.fire(new t.k(Error(`GeoJSON sources cannot have a sourceLayer parameter.`))):o!==`vector`||i?(e.id===void 0&&this.fire(new t.k(Error(`The feature id parameter must be provided.`))),a.setFeatureState(i,e.id,n)):this.fire(new t.k(Error(`The sourceLayer parameter must be provided for vector source types.`)))}removeFeatureState(e,n){this._checkLoaded();let r=e.source,i=this.sourceCaches[r];if(i===void 0)return void this.fire(new t.k(Error(`The source '${r}' does not exist in the map's style.`)));let a=i.getSource().type,o=a===`vector`?e.sourceLayer:void 0;a!==`vector`||o?n&&typeof e.id!=`string`&&typeof e.id!=`number`?this.fire(new t.k(Error(`A feature id is required to remove its specific state property.`))):i.removeFeatureState(o,e.id,n):this.fire(new t.k(Error(`The sourceLayer parameter must be provided for vector source types.`)))}getFeatureState(e){this._checkLoaded();let n=e.source,r=e.sourceLayer,i=this.sourceCaches[n];if(i!==void 0)return i.getSource().type!==`vector`||r?(e.id===void 0&&this.fire(new t.k(Error(`The feature id parameter must be provided.`))),i.getFeatureState(r,e.id)):void this.fire(new t.k(Error(`The sourceLayer parameter must be provided for vector source types.`)));this.fire(new t.k(Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;let e=t.bN(this.sourceCaches,(e=>e.serialize())),n=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,i=this.stylesheet;return t.bO({version:i.version,name:i.name,metadata:i.metadata,light:i.light,sky:i.sky,center:i.center,zoom:i.zoom,bearing:i.bearing,pitch:i.pitch,sprite:i.sprite,glyphs:i.glyphs,transition:i.transition,projection:i.projection,sources:e,layers:n,terrain:r},(e=>e!==void 0))}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&this.sourceCaches[e.source].getSource().type!==`raster`&&(this._updatedSources[e.source]=`reload`,this.sourceCaches[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){let t=e=>this._layers[e].type===`fill-extrusion`,n={},r=[];for(let i=this._order.length-1;i>=0;i--){let a=this._order[i];if(t(a)){n[a]=i;for(let t of e){let e=t[a];if(e)for(let t of e)r.push(t)}}}r.sort(((e,t)=>t.intersectionZ-e.intersectionZ));let i=[];for(let a=this._order.length-1;a>=0;a--){let o=this._order[a];if(t(o))for(let e=r.length-1;e>=0;e--){let t=r[e].feature;if(n[t.layer.id]<a)break;i.push(t),r.pop()}else for(let t of e){let e=t[o];if(e)for(let t of e)i.push(t.feature)}}return i}queryRenderedFeatures(e,n,r){n&&n.filter&&this._validate(t.z.filter,`queryRenderedFeatures.filter`,n.filter,null,n);let i={};if(n&&n.layers){if(!(Array.isArray(n.layers)||n.layers instanceof Set))return this.fire(new t.k(Error(`parameters.layers must be an Array or a Set of strings`))),[];for(let e of n.layers){let n=this._layers[e];if(!n)return this.fire(new t.k(Error(`The layer '${e}' does not exist in the map's style and cannot be queried for features.`))),[];i[n.source]=!0}}let a=[];n.availableImages=this._availableImages;let o=this._serializedAllLayers(),s=n.layers instanceof Set?n.layers:Array.isArray(n.layers)?new Set(n.layers):null,c=Object.assign(Object.assign({},n),{layers:s});for(let t in this.sourceCaches)n.layers&&!i[t]||a.push(ke(this.sourceCaches[t],this._layers,o,e,c,r,this.map.terrain?(e,t,n)=>this.map.terrain.getElevation(e,t,n):void 0));return this.placement&&a.push(function(e,t,n,r,i,a,o){let s={},c=a.queryRenderedSymbols(r),l=[];for(let e of Object.keys(c).map(Number))l.push(o[e]);l.sort(Ae);for(let r of l){let a=r.featureIndex.lookupSymbolFeatures(c[r.bucketInstanceId],t,r.bucketIndex,r.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(let t in a){let i=s[t]=s[t]||[],o=a[t];o.sort(((e,t)=>{let n=r.featureSortOrder;if(n){let r=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-r}return t.featureIndex-e.featureIndex}));for(let a of o)i.push(a),Me(n[e[t].source],r,a)}}return function(e,t,n){for(let r in e)for(let i of e[r])je(i,n[t[r].source]);return e}(s,e,n)}(this._layers,o,this.sourceCaches,e,c,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(a)}querySourceFeatures(e,n){n&&n.filter&&this._validate(t.z.filter,`querySourceFeatures.filter`,n.filter,null,n);let r=this.sourceCaches[e];return r?function(e,t){let n=e.getRenderableIds().map((t=>e.getTileByID(t))),r=[],i={};for(let e=0;e<n.length;e++){let a=n[e],o=a.tileID.canonical.key;i[o]||(i[o]=!0,a.querySourceFeatures(r,t))}return r}(r,n):[]}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();let r=this.light.getLight(),i=!1;for(let n in e)if(!t.bH(e[n],r[n])){i=!0;break}if(!i)return;let a={now:o.now(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(e,n),this.light.updateTransitions(a)}getProjection(){return this.stylesheet?.projection}setProjection(e){if(this._checkLoaded(),this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this.stylesheet.projection=e,this._setProjectionInternal(e.type)}getSky(){return this.stylesheet?.sky}setSky(e,n={}){this._checkLoaded();let r=this.getSky(),i=!1;if(!e&&!r)return;if(e&&!r)i=!0;else if(!e&&r)i=!0;else for(let n in e)if(!t.bH(e[n],r[n])){i=!0;break}if(!i)return;let a={now:o.now(),transition:t.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=e,this.sky.setSky(e,n),this.sky.updateTransitions(a)}_setProjectionInternal(e){let n=function(e){if(Array.isArray(e)){let t=new on({type:e});return{projection:t,transform:new wn,cameraHelper:new En(t)}}switch(e){case`mercator`:return{projection:new Ft,transform:new Ut,cameraHelper:new qt};case`globe`:{let e=new on({type:[`interpolate`,[`linear`],[`zoom`],11,`vertical-perspective`,12,`mercator`]});return{projection:e,transform:new wn,cameraHelper:new En(e)}}case`vertical-perspective`:return{projection:new rn,transform:new Cn,cameraHelper:new Tn};default:return t.w(`Unknown projection name: ${e}. Falling back to mercator projection.`),{projection:new Ft,transform:new Ut,cameraHelper:new qt}}}(e);this.projection=n.projection,this.map.migrateProjection(n.transform,n.cameraHelper);for(let e in this.sourceCaches)this.sourceCaches[e].reload()}_validate(e,n,r,i,a={}){return(!a||!1!==a.validate)&&Dn(this,e.call(t.z,t.e({key:n,style:this.serialize(),value:r,styleSpec:t.v},i)))}_remove(e=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),Ke().off(We,this._rtlPluginLoaded);for(let e in this._layers)this._layers[e].setEventedParent(null);for(let e in this.sourceCaches){let t=this.sourceCaches[e];t.setEventedParent(null),t.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),e&&this.dispatcher.broadcast(`RM`,void 0),this.dispatcher.remove(e)}_clearSource(e){this.sourceCaches[e].clearTiles()}_reloadSource(e){this.sourceCaches[e].resume(),this.sourceCaches[e].reload()}_updateSources(e){for(let t in this.sourceCaches)this.sourceCaches[t].update(e,this.map.terrain)}_generateCollisionBoxes(){for(let e in this.sourceCaches)this._reloadSource(e)}_updatePlacement(e,t,n,r,i=!1){let a=!1,s=!1,c={};for(let t of this._order){let n=this._layers[t];if(n.type!==`symbol`)continue;if(!c[n.source]){let e=this.sourceCaches[n.source];c[n.source]=e.getRenderableIds(!0).map((t=>e.getTileByID(t))).sort(((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1)))}let r=this.crossTileSymbolIndex.addLayer(n,c[n.source],e.center.lng);a||=r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((i=i||this._layerOrderChanged||n===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(o.now(),e.zoom))&&(this.pauseablePlacement=new Ct(e,this.map.terrain,this._order,i,t,n,r,this.placement,this._labelFreeAreas,this.map.getScale()),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,c),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(o.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(let e of this._order){let t=this._layers[e];t.type===`symbol`&&this.placement.updateLayerOpacities(t,c[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(o.now())}_releaseSymbolFadeTiles(){for(let e in this.sourceCaches)this.sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();let t=this.sourceCaches[n.source];return t&&t.setDependencies(n.tileID.key,n.type,n.icons),e}))}getGlyphs(e,n){return t._(this,void 0,void 0,(function*(){let e=yield this.glyphManager.getGlyphs(n.stacks),t=this.sourceCaches[n.source];return t&&t.setDependencies(n.tileID.key,n.type,[``]),e}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,n={}){this._checkLoaded(),e&&this._validate(t.z.glyphs,`glyphs`,e,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}addSprite(e,n,r={},i){this._checkLoaded();let a=[{id:e,url:n}],o=[...g(this.stylesheet.sprite),...a];this._validate(t.z.sprite,`sprite`,o,null,r)||(this.stylesheet.sprite=o,this._loadSprite(a,!0,i))}removeSprite(e){this._checkLoaded();let n=g(this.stylesheet.sprite);if(n.find((t=>t.id===e))){if(this._spritesImagesIds[e])for(let t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;n.splice(n.findIndex((t=>t.id===e)),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast(`SI`,this._availableImages),this.fire(new t.l(`data`,{dataType:`style`}))}else this.fire(new t.k(Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return g(this.stylesheet.sprite)}setSprite(e,n={},r){this._checkLoaded(),e&&this._validate(t.z.sprite,`sprite`,e,null,n)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}setLabelFreeAreas(e){return!t.bP(e,this._labelFreeAreas)&&(this._labelFreeAreas=e,!0)}}var An=t.aJ([{name:`a_pos`,type:`Int16`,components:2},{name:`a_texture_pos`,type:`Int16`,components:2}]);class jn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,n,r,i,a,o,s,c){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e<r.length;e++)this.boundPaintVertexBuffers[e]!==r[e]&&(l=!0);!this.vao||this.boundProgram!==t||this.boundLayoutVertexBuffer!==n||l||this.boundIndexBuffer!==i||this.boundVertexOffset!==a||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==s||this.boundDynamicVertexBuffer3!==c?this.freshBind(t,n,r,i,a,o,s,c):(e.bindVertexArray.set(this.vao),o&&o.bind(),i&&i.dynamicDraw&&i.bind(),s&&s.bind(),c&&c.bind())}freshBind(e,t,n,r,i,a,o,s){let c=e.numAttributes,l=this.context,u=l.gl;this.vao&&this.destroy(),this.vao=l.createVertexArray(),l.bindVertexArray.set(this.vao),this.boundProgram=e,this.boundLayoutVertexBuffer=t,this.boundPaintVertexBuffers=n,this.boundIndexBuffer=r,this.boundVertexOffset=i,this.boundDynamicVertexBuffer=a,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=s,t.enableAttributes(u,e);for(let t of n)t.enableAttributes(u,e);a&&a.enableAttributes(u,e),o&&o.enableAttributes(u,e),s&&s.enableAttributes(u,e),t.bind(),t.setVertexAttribPointers(u,e,i);for(let t of n)t.bind(),t.setVertexAttribPointers(u,e,i);a&&(a.bind(),a.setVertexAttribPointers(u,e,i)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(u,e,i)),s&&(s.bind(),s.setVertexAttribPointers(u,e,i)),l.currentNumAttributes=c}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}}let Mn=(e,n,r,i,a)=>({u_texture:0,u_ele_delta:e,u_fog_matrix:n,u_fog_color:r?r.properties.get(`fog-color`):t.bf.white,u_fog_ground_blend:r?r.properties.get(`fog-ground-blend`):1,u_fog_ground_blend_opacity:a?0:r?r.calculateFogBlendOpacity(i):0,u_horizon_color:r?r.properties.get(`horizon-color`):t.bf.white,u_horizon_fog_blend:r?r.properties.get(`horizon-fog-blend`):1,u_is_globe_mode:a?1:0}),Nn={mainMatrix:`u_projection_matrix`,tileMercatorCoords:`u_projection_tile_mercator_coords`,clippingPlane:`u_projection_clipping_plane`,projectionTransition:`u_projection_transition`,fallbackMatrix:`u_projection_fallback_matrix`};function Pn(e){let t=[];for(let n=0;n<e.length;n++){if(e[n]===null)continue;let r=e[n].split(` `);t.push(r.pop())}return t}class Fn{constructor(e,n,r,i,a,o,s,c,l=[]){let u=e.gl;this.program=u.createProgram();let d=Pn(n.staticAttributes),f=r?r.getBinderAttributes():[],p=d.concat(f),m=At.prelude.staticUniforms?Pn(At.prelude.staticUniforms):[],h=s.staticUniforms?Pn(s.staticUniforms):[],g=n.staticUniforms?Pn(n.staticUniforms):[],_=r?r.getBinderUniforms():[],v=m.concat(h).concat(g).concat(_),y=[];for(let e of v)y.indexOf(e)<0&&y.push(e);let b=r?r.defines():[];Qt(u)&&b.unshift(`#version 300 es`),a&&b.push(`#define OVERDRAW_INSPECTOR;`),o&&b.push(`#define TERRAIN3D;`),c&&b.push(c),l&&b.push(...l);let x=b.concat(At.prelude.fragmentSource,s.fragmentSource,n.fragmentSource).join(`
|
|
687
687
|
`),S=b.concat(At.prelude.vertexSource,s.vertexSource,n.vertexSource).join(`
|
|
688
688
|
`);Qt(u)||(x=function(e){return e.replace(/\bin\s/g,`varying `).replace(`out highp vec4 fragColor;`,``).replace(/fragColor/g,`gl_FragColor`).replace(/texture\(/g,`texture2D(`)}(x),S=function(e){return e.replace(/\bin\s/g,`attribute `).replace(/\bout\s/g,`varying `).replace(/texture\(/g,`texture2D(`)}(S));let C=u.createShader(u.FRAGMENT_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(C,x),u.compileShader(C),!u.getShaderParameter(C,u.COMPILE_STATUS))throw Error(`Could not compile fragment shader: ${u.getShaderInfoLog(C)}`);u.attachShader(this.program,C);let w=u.createShader(u.VERTEX_SHADER);if(u.isContextLost())return void(this.failedToCreate=!0);if(u.shaderSource(w,S),u.compileShader(w),!u.getShaderParameter(w,u.COMPILE_STATUS))throw Error(`Could not compile vertex shader: ${u.getShaderInfoLog(w)}`);u.attachShader(this.program,w),this.attributes={};let T={};this.numAttributes=p.length;for(let e=0;e<this.numAttributes;e++)p[e]&&(u.bindAttribLocation(this.program,e,p[e]),this.attributes[p[e]]=e);if(u.linkProgram(this.program),!u.getProgramParameter(this.program,u.LINK_STATUS))throw Error(`Program failed to link: ${u.getProgramInfoLog(this.program)}`);u.deleteShader(w),u.deleteShader(C);for(let e=0;e<y.length;e++){let t=y[e];if(t&&!T[t]){let e=u.getUniformLocation(this.program,t);e&&(T[t]=e)}}this.fixedUniforms=i(e,T),this.terrainUniforms=((e,n)=>({u_depth:new t.bQ(e,n.u_depth),u_terrain:new t.bQ(e,n.u_terrain),u_terrain_dim:new t.bg(e,n.u_terrain_dim),u_terrain_matrix:new t.bS(e,n.u_terrain_matrix),u_terrain_unpack:new t.bT(e,n.u_terrain_unpack),u_terrain_exaggeration:new t.bg(e,n.u_terrain_exaggeration)}))(e,T),this.projectionUniforms=((e,n)=>({u_projection_matrix:new t.bS(e,n.u_projection_matrix),u_projection_tile_mercator_coords:new t.bT(e,n.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.bT(e,n.u_projection_clipping_plane),u_projection_transition:new t.bg(e,n.u_projection_transition),u_projection_fallback_matrix:new t.bS(e,n.u_projection_fallback_matrix)}))(e,T),this.binderUniforms=r?r.getUniforms(e,T):[]}draw(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(a),s){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,s.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,s.texture);for(let e in this.terrainUniforms)this.terrainUniforms[e].set(s[e])}if(c)for(let e in c)this.projectionUniforms[Nn[e]].set(c[e]);if(o)for(let e in this.fixedUniforms)this.fixedUniforms[e].set(o[e]);h&&h.setUniforms(e,this.binderUniforms,p,{zoom:m});let b=0;switch(t){case y.LINES:b=2;break;case y.TRIANGLES:b=3;break;case y.LINE_STRIP:b=1}for(let n of f.get()){let r=n.vaos||={};(r[l]||(r[l]=new jn)).bind(e,this,u,h?h.getPaintVertexBuffers():[],d,n.vertexOffset,g,_,v),y.drawElements(t,n.primitiveLength*b,y.UNSIGNED_SHORT,n.primitiveOffset*b*2)}}}function In(e,n,r){let i=1/t.aC(r,1,n.transform.tileZoom,n.transform.detailLevel),a=2**r.tileID.overscaledZ,o=r.tileSize*2**n.transform.tileZoom/a,s=o*(r.tileID.canonical.x+r.tileID.wrap*a),c=o*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[i,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[s>>16,c>>16],u_pixel_coord_lower:[65535&s,65535&c]}}let Ln=(e,n,r,i)=>{let a=e.style.light,o=a.properties.get(`position`),s=[o.x,o.y,o.z],c=t.bW();a.properties.get(`anchor`)===`viewport`&&t.bX(c,e.transform.bearingInRadians),t.bY(s,s,c);let l=e.transform.transformLightDirection(s),u=a.properties.get(`color`);return{u_lightpos:s,u_lightpos_globe:l,u_lightintensity:a.properties.get(`intensity`),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+n,u_opacity:r,u_fill_translate:i}},Rn=(e,n,r,i,a,o,s)=>t.e(Ln(e,n,r,i),In(o,e,s),{u_height_factor:-(2**a.overscaledZ)/s.tileSize/8}),zn=(e,n,r,i)=>t.e(In(n,e,r),{u_fill_translate:i}),Bn=(e,t)=>({u_world:e,u_fill_translate:t}),Vn=(e,n,r,i,a)=>t.e(zn(e,n,r,a),{u_world:i}),Hn=(e,n,r,i,a)=>{let o=e.transform,s,c,l=0;if(r.paint.get(`circle-pitch-alignment`)===`map`){let e=t.aC(n,1,o.zoom,o.detailLevel);s=!0,c=[e,e],l=e/(t.ah*2**n.tileID.overscaledZ)*2*Math.PI*a}else s=!1,c=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+(r.paint.get(`circle-pitch-scale`)===`map`),u_pitch_with_map:+s,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:c,u_globe_extrude_scale:l,u_translate:i}},Un=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Wn=e=>({u_viewport_size:[e.width,e.height]}),Gn=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),Kn=(e,n,r,i,a)=>{let o=t.aC(e,1,n,r)/(t.ah*2**e.tileID.overscaledZ)*2*Math.PI*a;return{u_extrude_scale:t.aC(e,1,n,r),u_intensity:i,u_globe_extrude_scale:o}},qn=(e,n,r,i)=>{let a=t.M();t.bZ(a,0,e.width,e.height,0,0,1);let o=e.context.gl;return{u_matrix:a,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:r,u_color_ramp:i,u_opacity:n.paint.get(`heatmap-opacity`)}},Jn=(e,t,n)=>{let r=n.paint.get(`hillshade-accent-color`),i;switch(n.paint.get(`hillshade-method`)){case`basic`:i=4;break;case`combined`:i=1;break;case`igor`:i=2;break;case`multidirectional`:i=3;break;default:i=0}let a=n.getIlluminationProperties();for(let t=0;t<a.directionRadians.length;t++)n.paint.get(`hillshade-illumination-anchor`)===`viewport`&&(a.directionRadians[t]+=e.transform.bearingInRadians);return{u_image:0,u_latrange:Xn(0,t.tileID),u_exaggeration:n.paint.get(`hillshade-exaggeration`),u_altitudes:a.altitudeRadians,u_azimuths:a.directionRadians,u_accent:r,u_method:i,u_highlights:a.highlightColor,u_shadows:a.shadowColor}},Yn=(e,n)=>{let r=n.stride,i=t.M();return t.bZ(i,0,t.ah,-t.ah,0,0,1),t.a5(i,i,[0,-t.ah,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:n.getUnpackVector()}};function Xn(e,n){let r=2**n.canonical.z,i=n.canonical.y;return[new t.aj(0,i/r).toLngLat().lat,new t.aj(0,(i+1)/r).toLngLat().lat]}let Zn=(e,t,n=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:n,u_opacity:e.paint.get(`color-relief-opacity`)}),Qn=(e,n,r,i)=>{let a=e.transform;return{u_translation:rr(e,n,r),u_ratio:i/t.aC(n,1,a.zoom,a.detailLevel),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},$n=(e,n,r,i,a)=>t.e(Qn(e,n,r,i),{u_image:0,u_image_height:a}),er=(e,n,r,i,a)=>{let o=e.transform,s=nr(n,o);return{u_translation:rr(e,n,r),u_texsize:n.imageAtlasTexture.size,u_ratio:i/t.aC(n,1,o.zoom,o.detailLevel),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[s,a.fromScale,a.toScale],u_fade:a.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},tr=(e,n,r,i,a,o)=>{let s=e.lineAtlas,c=nr(n,e.transform),l=r.layout.get(`line-cap`)===`round`,u=s.getDash(a.from,l),d=s.getDash(a.to,l),f=u.width*o.fromScale,p=d.width*o.toScale;return t.e(Qn(e,n,r,i),{u_patternscale_a:[c/f,-u.height/2],u_patternscale_b:[c/p,-d.height/2],u_sdfgamma:s.width/(256*Math.min(f,p)*e.pixelRatio)/2,u_image:0,u_tex_y_a:u.y,u_tex_y_b:d.y,u_mix:o.t})};function nr(e,n){return 1/t.aC(e,1,n.tileZoom,n.detailLevel)}function rr(e,n,r){return t.aD(e.transform,n,r.paint.get(`line-translate`),r.paint.get(`line-translate-anchor`))}let ir=(e,t,n,r,i)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get(`raster-opacity`),u_image0:0,u_image1:1,u_brightness_low:r.paint.get(`raster-brightness-min`),u_brightness_high:r.paint.get(`raster-brightness-max`),u_saturation_factor:(o=r.paint.get(`raster-saturation`),o>0?1-1/(1.001-o):-o),u_contrast_factor:(a=r.paint.get(`raster-contrast`),a>0?1/(1-a):1+a),u_spin_weights:ar(r.paint.get(`raster-hue-rotate`)),u_coords_top:[i[0].x,i[0].y,i[1].x,i[1].y],u_coords_bottom:[i[3].x,i[3].y,i[2].x,i[2].y]};var a,o};function ar(e){e*=Math.PI/180;let t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}let or=(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{let p=o.transform;return{u_is_size_zoom_constant:+(e===`constant`||e===`source`),u_is_size_feature_constant:+(e===`constant`||e===`camera`),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:p.width/p.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:s,u_coord_matrix:c,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:i,u_is_variable_anchor:a,u_texsize:d,u_texture:0,u_translation:l,u_pitched_scale:f}},sr=(e,n,r,i,a,o,s,c,l,u,d,f,p,m)=>{let h=s.transform;return t.e(or(e,n,r,i,a,o,s,c,l,u,d,f,m),{u_gamma_scale:i?Math.cos(h.pitch*Math.PI/180)*h.cameraToCenterDistance:1,u_device_pixel_ratio:s.pixelRatio,u_is_halo:1})},cr=(e,n,r,i,a,o,s,c,l,u,d,f,p)=>t.e(sr(e,n,r,i,a,o,s,c,l,u,!0,d,0,p),{u_texsize_icon:f,u_texture_icon:1}),lr=(e,t)=>({u_opacity:e,u_color:t}),ur=(e,n,r,i,a)=>t.e(function(e,n,r,i){let a=r.imageManager.getPattern(e.from.toString()),o=r.imageManager.getPattern(e.to.toString()),{width:s,height:c}=r.imageManager.getPixelSize(),l=2**i.tileID.overscaledZ,u=i.tileSize*2**r.transform.tileZoom/l,d=u*(i.tileID.canonical.x+i.tileID.wrap*l),f=u*i.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:a.tl,u_pattern_br_a:a.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[s,c],u_mix:n.t,u_pattern_size_a:a.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:n.fromScale,u_scale_b:n.toScale,u_tile_units_to_pixels:1/t.aC(i,1,r.transform.tileZoom,r.transform.detailLevel),u_pixel_coord_upper:[d>>16,f>>16],u_pixel_coord_lower:[65535&d,65535&f]}}(r,a,n,i),{u_opacity:e}),dr=(e,t)=>{},fr={fillExtrusion:(e,n)=>({u_lightpos:new t.bU(e,n.u_lightpos),u_lightpos_globe:new t.bU(e,n.u_lightpos_globe),u_lightintensity:new t.bg(e,n.u_lightintensity),u_lightcolor:new t.bU(e,n.u_lightcolor),u_vertical_gradient:new t.bg(e,n.u_vertical_gradient),u_opacity:new t.bg(e,n.u_opacity),u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillExtrusionPattern:(e,n)=>({u_lightpos:new t.bU(e,n.u_lightpos),u_lightpos_globe:new t.bU(e,n.u_lightpos_globe),u_lightintensity:new t.bg(e,n.u_lightintensity),u_lightcolor:new t.bU(e,n.u_lightcolor),u_vertical_gradient:new t.bg(e,n.u_vertical_gradient),u_height_factor:new t.bg(e,n.u_height_factor),u_opacity:new t.bg(e,n.u_opacity),u_fill_translate:new t.bV(e,n.u_fill_translate),u_image:new t.bQ(e,n.u_image),u_texsize:new t.bV(e,n.u_texsize),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade)}),fill:(e,n)=>({u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillPattern:(e,n)=>({u_image:new t.bQ(e,n.u_image),u_texsize:new t.bV(e,n.u_texsize),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade),u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillOutline:(e,n)=>({u_world:new t.bV(e,n.u_world),u_fill_translate:new t.bV(e,n.u_fill_translate)}),fillOutlinePattern:(e,n)=>({u_world:new t.bV(e,n.u_world),u_image:new t.bQ(e,n.u_image),u_texsize:new t.bV(e,n.u_texsize),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade),u_fill_translate:new t.bV(e,n.u_fill_translate)}),circle:(e,n)=>({u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_scale_with_map:new t.bQ(e,n.u_scale_with_map),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_extrude_scale:new t.bV(e,n.u_extrude_scale),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_globe_extrude_scale:new t.bg(e,n.u_globe_extrude_scale),u_translate:new t.bV(e,n.u_translate)}),collisionBox:(e,n)=>({u_pixel_extrude_scale:new t.bV(e,n.u_pixel_extrude_scale)}),collisionCircle:(e,n)=>({u_viewport_size:new t.bV(e,n.u_viewport_size)}),debug:(e,n)=>({u_color:new t.bR(e,n.u_color),u_overlay:new t.bQ(e,n.u_overlay),u_overlay_scale:new t.bg(e,n.u_overlay_scale)}),depth:dr,clippingMask:dr,heatmap:(e,n)=>({u_extrude_scale:new t.bg(e,n.u_extrude_scale),u_intensity:new t.bg(e,n.u_intensity),u_globe_extrude_scale:new t.bg(e,n.u_globe_extrude_scale)}),heatmapTexture:(e,n)=>({u_matrix:new t.bS(e,n.u_matrix),u_world:new t.bV(e,n.u_world),u_image:new t.bQ(e,n.u_image),u_color_ramp:new t.bQ(e,n.u_color_ramp),u_opacity:new t.bg(e,n.u_opacity)}),hillshade:(e,n)=>({u_image:new t.bQ(e,n.u_image),u_latrange:new t.bV(e,n.u_latrange),u_exaggeration:new t.bg(e,n.u_exaggeration),u_altitudes:new t.b$(e,n.u_altitudes),u_azimuths:new t.b$(e,n.u_azimuths),u_accent:new t.bR(e,n.u_accent),u_method:new t.bQ(e,n.u_method),u_shadows:new t.b_(e,n.u_shadows),u_highlights:new t.b_(e,n.u_highlights)}),hillshadePrepare:(e,n)=>({u_matrix:new t.bS(e,n.u_matrix),u_image:new t.bQ(e,n.u_image),u_dimension:new t.bV(e,n.u_dimension),u_zoom:new t.bg(e,n.u_zoom),u_unpack:new t.bT(e,n.u_unpack)}),colorRelief:(e,n)=>({u_image:new t.bQ(e,n.u_image),u_unpack:new t.bT(e,n.u_unpack),u_dimension:new t.bV(e,n.u_dimension),u_elevation_stops:new t.bQ(e,n.u_elevation_stops),u_color_stops:new t.bQ(e,n.u_color_stops),u_color_ramp_size:new t.bQ(e,n.u_color_ramp_size),u_opacity:new t.bg(e,n.u_opacity)}),line:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels)}),lineGradient:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels),u_image:new t.bQ(e,n.u_image),u_image_height:new t.bg(e,n.u_image_height)}),linePattern:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_texsize:new t.bV(e,n.u_texsize),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_image:new t.bQ(e,n.u_image),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels),u_scale:new t.bU(e,n.u_scale),u_fade:new t.bg(e,n.u_fade)}),lineSDF:(e,n)=>({u_translation:new t.bV(e,n.u_translation),u_ratio:new t.bg(e,n.u_ratio),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_units_to_pixels:new t.bV(e,n.u_units_to_pixels),u_patternscale_a:new t.bV(e,n.u_patternscale_a),u_patternscale_b:new t.bV(e,n.u_patternscale_b),u_sdfgamma:new t.bg(e,n.u_sdfgamma),u_image:new t.bQ(e,n.u_image),u_tex_y_a:new t.bg(e,n.u_tex_y_a),u_tex_y_b:new t.bg(e,n.u_tex_y_b),u_mix:new t.bg(e,n.u_mix)}),raster:(e,n)=>({u_tl_parent:new t.bV(e,n.u_tl_parent),u_scale_parent:new t.bg(e,n.u_scale_parent),u_buffer_scale:new t.bg(e,n.u_buffer_scale),u_fade_t:new t.bg(e,n.u_fade_t),u_opacity:new t.bg(e,n.u_opacity),u_image0:new t.bQ(e,n.u_image0),u_image1:new t.bQ(e,n.u_image1),u_brightness_low:new t.bg(e,n.u_brightness_low),u_brightness_high:new t.bg(e,n.u_brightness_high),u_saturation_factor:new t.bg(e,n.u_saturation_factor),u_contrast_factor:new t.bg(e,n.u_contrast_factor),u_spin_weights:new t.bU(e,n.u_spin_weights),u_coords_top:new t.bT(e,n.u_coords_top),u_coords_bottom:new t.bT(e,n.u_coords_bottom)}),symbolIcon:(e,n)=>({u_is_size_zoom_constant:new t.bQ(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bQ(e,n.u_is_size_feature_constant),u_size_t:new t.bg(e,n.u_size_t),u_size:new t.bg(e,n.u_size),u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_pitch:new t.bg(e,n.u_pitch),u_rotate_symbol:new t.bQ(e,n.u_rotate_symbol),u_aspect_ratio:new t.bg(e,n.u_aspect_ratio),u_fade_change:new t.bg(e,n.u_fade_change),u_label_plane_matrix:new t.bS(e,n.u_label_plane_matrix),u_coord_matrix:new t.bS(e,n.u_coord_matrix),u_is_text:new t.bQ(e,n.u_is_text),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_is_along_line:new t.bQ(e,n.u_is_along_line),u_is_variable_anchor:new t.bQ(e,n.u_is_variable_anchor),u_texsize:new t.bV(e,n.u_texsize),u_texture:new t.bQ(e,n.u_texture),u_translation:new t.bV(e,n.u_translation),u_pitched_scale:new t.bg(e,n.u_pitched_scale)}),symbolSDF:(e,n)=>({u_is_size_zoom_constant:new t.bQ(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bQ(e,n.u_is_size_feature_constant),u_size_t:new t.bg(e,n.u_size_t),u_size:new t.bg(e,n.u_size),u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_pitch:new t.bg(e,n.u_pitch),u_rotate_symbol:new t.bQ(e,n.u_rotate_symbol),u_aspect_ratio:new t.bg(e,n.u_aspect_ratio),u_fade_change:new t.bg(e,n.u_fade_change),u_label_plane_matrix:new t.bS(e,n.u_label_plane_matrix),u_coord_matrix:new t.bS(e,n.u_coord_matrix),u_is_text:new t.bQ(e,n.u_is_text),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_is_along_line:new t.bQ(e,n.u_is_along_line),u_is_variable_anchor:new t.bQ(e,n.u_is_variable_anchor),u_texsize:new t.bV(e,n.u_texsize),u_texture:new t.bQ(e,n.u_texture),u_gamma_scale:new t.bg(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_is_halo:new t.bQ(e,n.u_is_halo),u_translation:new t.bV(e,n.u_translation),u_pitched_scale:new t.bg(e,n.u_pitched_scale)}),symbolTextAndIcon:(e,n)=>({u_is_size_zoom_constant:new t.bQ(e,n.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bQ(e,n.u_is_size_feature_constant),u_size_t:new t.bg(e,n.u_size_t),u_size:new t.bg(e,n.u_size),u_camera_to_center_distance:new t.bg(e,n.u_camera_to_center_distance),u_pitch:new t.bg(e,n.u_pitch),u_rotate_symbol:new t.bQ(e,n.u_rotate_symbol),u_aspect_ratio:new t.bg(e,n.u_aspect_ratio),u_fade_change:new t.bg(e,n.u_fade_change),u_label_plane_matrix:new t.bS(e,n.u_label_plane_matrix),u_coord_matrix:new t.bS(e,n.u_coord_matrix),u_is_text:new t.bQ(e,n.u_is_text),u_pitch_with_map:new t.bQ(e,n.u_pitch_with_map),u_is_along_line:new t.bQ(e,n.u_is_along_line),u_is_variable_anchor:new t.bQ(e,n.u_is_variable_anchor),u_texsize:new t.bV(e,n.u_texsize),u_texsize_icon:new t.bV(e,n.u_texsize_icon),u_texture:new t.bQ(e,n.u_texture),u_texture_icon:new t.bQ(e,n.u_texture_icon),u_gamma_scale:new t.bg(e,n.u_gamma_scale),u_device_pixel_ratio:new t.bg(e,n.u_device_pixel_ratio),u_is_halo:new t.bQ(e,n.u_is_halo),u_translation:new t.bV(e,n.u_translation),u_pitched_scale:new t.bg(e,n.u_pitched_scale)}),background:(e,n)=>({u_opacity:new t.bg(e,n.u_opacity),u_color:new t.bR(e,n.u_color)}),backgroundPattern:(e,n)=>({u_opacity:new t.bg(e,n.u_opacity),u_image:new t.bQ(e,n.u_image),u_pattern_tl_a:new t.bV(e,n.u_pattern_tl_a),u_pattern_br_a:new t.bV(e,n.u_pattern_br_a),u_pattern_tl_b:new t.bV(e,n.u_pattern_tl_b),u_pattern_br_b:new t.bV(e,n.u_pattern_br_b),u_texsize:new t.bV(e,n.u_texsize),u_mix:new t.bg(e,n.u_mix),u_pattern_size_a:new t.bV(e,n.u_pattern_size_a),u_pattern_size_b:new t.bV(e,n.u_pattern_size_b),u_scale_a:new t.bg(e,n.u_scale_a),u_scale_b:new t.bg(e,n.u_scale_b),u_pixel_coord_upper:new t.bV(e,n.u_pixel_coord_upper),u_pixel_coord_lower:new t.bV(e,n.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bg(e,n.u_tile_units_to_pixels)}),terrain:(e,n)=>({u_texture:new t.bQ(e,n.u_texture),u_ele_delta:new t.bg(e,n.u_ele_delta),u_fog_matrix:new t.bS(e,n.u_fog_matrix),u_fog_color:new t.bR(e,n.u_fog_color),u_fog_ground_blend:new t.bg(e,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bg(e,n.u_fog_ground_blend_opacity),u_horizon_color:new t.bR(e,n.u_horizon_color),u_horizon_fog_blend:new t.bg(e,n.u_horizon_fog_blend),u_is_globe_mode:new t.bg(e,n.u_is_globe_mode)}),terrainDepth:(e,n)=>({u_ele_delta:new t.bg(e,n.u_ele_delta)}),terrainCoords:(e,n)=>({u_texture:new t.bQ(e,n.u_texture),u_terrain_coords_id:new t.bg(e,n.u_terrain_coords_id),u_ele_delta:new t.bg(e,n.u_ele_delta)}),projectionErrorMeasurement:(e,n)=>({u_input:new t.bg(e,n.u_input),u_output_expected:new t.bg(e,n.u_output_expected)}),atmosphere:(e,n)=>({u_sun_pos:new t.bU(e,n.u_sun_pos),u_atmosphere_blend:new t.bg(e,n.u_atmosphere_blend),u_globe_position:new t.bU(e,n.u_globe_position),u_globe_radius:new t.bg(e,n.u_globe_radius),u_inv_proj_matrix:new t.bS(e,n.u_inv_proj_matrix)}),sky:(e,n)=>({u_sky_color:new t.bR(e,n.u_sky_color),u_horizon_color:new t.bR(e,n.u_horizon_color),u_horizon:new t.bV(e,n.u_horizon),u_horizon_normal:new t.bV(e,n.u_horizon_normal),u_sky_horizon_blend:new t.bg(e,n.u_sky_horizon_blend),u_sky_blend:new t.bg(e,n.u_sky_blend)})};class pr{constructor(e,t,n){this.context=e;let r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!n,this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){let t=this.context.gl;if(!this.dynamicDraw)throw Error(`Attempted to update data while not in dynamic mode.`);this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let mr={Int8:`BYTE`,Uint8:`UNSIGNED_BYTE`,Int16:`SHORT`,Uint16:`UNSIGNED_SHORT`,Int32:`INT`,Uint32:`UNSIGNED_INT`,Float32:`FLOAT`};class hr{constructor(e,t,n,r){this.length=t.length,this.attributes=n,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;let i=e.gl;this.buffer=i.createBuffer(),e.bindVertexBuffer.set(this.buffer),i.bufferData(i.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?i.DYNAMIC_DRAW:i.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);let t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let n=0;n<this.attributes.length;n++){let r=t.attributes[this.attributes[n].name];r!==void 0&&e.enableVertexAttribArray(r)}}setVertexAttribPointers(e,t,n){for(let r=0;r<this.attributes.length;r++){let i=this.attributes[r],a=t.attributes[i.name];a!==void 0&&e.vertexAttribPointer(a,i.components,e[mr[i.type]],!1,this.itemSize,i.offset+this.itemSize*(n||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class gr{constructor(e){this.gl=e.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(e){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class _r extends gr{getDefault(){return t.bf.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.clearColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class vr extends gr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class yr extends gr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class br extends gr{getDefault(){return[!0,!0,!0,!0]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.colorMask(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class xr extends gr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class Sr extends gr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class Cr extends gr{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(e){let t=this.current;(e.func!==t.func||e.ref!==t.ref||e.mask!==t.mask||this.dirty)&&(this.gl.stencilFunc(e.func,e.ref,e.mask),this.current=e,this.dirty=!1)}}class wr extends gr{getDefault(){let e=this.gl;return[e.KEEP,e.KEEP,e.KEEP]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||this.dirty)&&(this.gl.stencilOp(e[0],e[1],e[2]),this.current=e,this.dirty=!1)}}class Tr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.STENCIL_TEST):t.disable(t.STENCIL_TEST),this.current=e,this.dirty=!1}}class Er extends gr{getDefault(){return[0,1]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.depthRange(e[0],e[1]),this.current=e,this.dirty=!1)}}class Dr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.DEPTH_TEST):t.disable(t.DEPTH_TEST),this.current=e,this.dirty=!1}}class Or extends gr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class kr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.BLEND):t.disable(t.BLEND),this.current=e,this.dirty=!1}}class Ar extends gr{getDefault(){let e=this.gl;return[e.ONE,e.ZERO]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||this.dirty)&&(this.gl.blendFunc(e[0],e[1]),this.current=e,this.dirty=!1)}}class jr extends gr{getDefault(){return t.bf.transparent}set(e){let t=this.current;(e.r!==t.r||e.g!==t.g||e.b!==t.b||e.a!==t.a||this.dirty)&&(this.gl.blendColor(e.r,e.g,e.b,e.a),this.current=e,this.dirty=!1)}}class Mr extends gr{getDefault(){return this.gl.FUNC_ADD}set(e){(e!==this.current||this.dirty)&&(this.gl.blendEquation(e),this.current=e,this.dirty=!1)}}class Nr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;e?t.enable(t.CULL_FACE):t.disable(t.CULL_FACE),this.current=e,this.dirty=!1}}class Pr extends gr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class Fr extends gr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}class Ir extends gr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}}class Lr extends gr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class Rr extends gr{getDefault(){let e=this.gl;return[0,0,e.drawingBufferWidth,e.drawingBufferHeight]}set(e){let t=this.current;(e[0]!==t[0]||e[1]!==t[1]||e[2]!==t[2]||e[3]!==t[3]||this.dirty)&&(this.gl.viewport(e[0],e[1],e[2],e[3]),this.current=e,this.dirty=!1)}}class zr extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindFramebuffer(t.FRAMEBUFFER,e),this.current=e,this.dirty=!1}}class Br extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindRenderbuffer(t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Vr extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindTexture(t.TEXTURE_2D,e),this.current=e,this.dirty=!1}}class Hr extends gr{getDefault(){return null}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.bindBuffer(t.ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ur extends gr{getDefault(){return null}set(e){let t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Wr extends gr{getDefault(){return null}set(e){var t;if(e===this.current&&!this.dirty)return;let n=this.gl;Qt(n)?n.bindVertexArray(e):(t=n.getExtension(`OES_vertex_array_object`))==null||t.bindVertexArrayOES(e),this.current=e,this.dirty=!1}}class Gr extends gr{getDefault(){return 4}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_ALIGNMENT,e),this.current=e,this.dirty=!1}}class Kr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e),this.current=e,this.dirty=!1}}class qr extends gr{getDefault(){return!1}set(e){if(e===this.current&&!this.dirty)return;let t=this.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,e),this.current=e,this.dirty=!1}}class Jr extends gr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class q extends Jr{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class Yr extends Jr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}class Xr extends Jr{set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let t=this.gl;t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,e),this.current=e,this.dirty=!1}}let Zr=`Framebuffer is not complete`;class Qr{constructor(e,t,n,r,i){this.context=e,this.width=t,this.height=n;let a=e.gl,o=this.framebuffer=a.createFramebuffer();if(this.colorAttachment=new q(e,o),r)this.depthAttachment=i?new Xr(e,o):new Yr(e,o);else if(i)throw Error(`Stencil cannot be set without depth`);if(a.checkFramebufferStatus(a.FRAMEBUFFER)!==a.FRAMEBUFFER_COMPLETE)throw Error(Zr)}destroy(){let e=this.context.gl,t=this.colorAttachment.get();if(t&&e.deleteTexture(t),this.depthAttachment){let t=this.depthAttachment.get();t&&e.deleteRenderbuffer(t)}e.deleteFramebuffer(this.framebuffer)}}class $r{constructor(e){if(this.gl=e,this.clearColor=new _r(this),this.clearDepth=new vr(this),this.clearStencil=new yr(this),this.colorMask=new br(this),this.depthMask=new xr(this),this.stencilMask=new Sr(this),this.stencilFunc=new Cr(this),this.stencilOp=new wr(this),this.stencilTest=new Tr(this),this.depthRange=new Er(this),this.depthTest=new Dr(this),this.depthFunc=new Or(this),this.blend=new kr(this),this.blendFunc=new Ar(this),this.blendColor=new jr(this),this.blendEquation=new Mr(this),this.cullFace=new Nr(this),this.cullFaceSide=new Pr(this),this.frontFace=new Fr(this),this.program=new Ir(this),this.activeTexture=new Lr(this),this.viewport=new Rr(this),this.bindFramebuffer=new zr(this),this.bindRenderbuffer=new Br(this),this.bindTexture=new Vr(this),this.bindVertexBuffer=new Hr(this),this.bindElementBuffer=new Ur(this),this.bindVertexArray=new Wr(this),this.pixelStoreUnpack=new Gr(this),this.pixelStoreUnpackPremultiplyAlpha=new Kr(this),this.pixelStoreUnpackFlipY=new qr(this),this.extTextureFilterAnisotropic=e.getExtension(`EXT_texture_filter_anisotropic`)||e.getExtension(`MOZ_EXT_texture_filter_anisotropic`)||e.getExtension(`WEBKIT_EXT_texture_filter_anisotropic`),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=e.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),Qt(e)){this.HALF_FLOAT=e.HALF_FLOAT;let t=e.getExtension(`EXT_color_buffer_half_float`);this.RGBA16F=e.RGBA16F??t?.RGBA16F_EXT,this.RGB16F=e.RGB16F??t?.RGB16F_EXT,e.getExtension(`EXT_color_buffer_float`)}else e.getExtension(`EXT_color_buffer_half_float`),e.getExtension(`OES_texture_half_float_linear`),this.HALF_FLOAT=e.getExtension(`OES_texture_half_float`)?.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(e,t){return new pr(this,e,t)}createVertexBuffer(e,t,n){return new hr(this,e,t,n)}createRenderbuffer(e,t,n){let r=this.gl,i=r.createRenderbuffer();return this.bindRenderbuffer.set(i),r.renderbufferStorage(r.RENDERBUFFER,e,t,n),this.bindRenderbuffer.set(null),i}createFramebuffer(e,t,n,r){return new Qr(this,e,t,n,r)}clear({color:e,depth:t,stencil:n}){let r=this.gl,i=0;e&&(i|=r.COLOR_BUFFER_BIT,this.clearColor.set(e),this.colorMask.set([!0,!0,!0,!0])),t!==void 0&&(i|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),n!==void 0&&(i|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(n),this.stencilMask.set(255)),r.clear(i)}setCullFace(e){!1===e.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(e.mode),this.frontFace.set(e.frontFace))}setDepthMode(e){e.func!==this.gl.ALWAYS||e.mask?(this.depthTest.set(!0),this.depthFunc.set(e.func),this.depthMask.set(e.mask),this.depthRange.set(e.range)):this.depthTest.set(!1)}setStencilMode(e){e.test.func!==this.gl.ALWAYS||e.mask?(this.stencilTest.set(!0),this.stencilMask.set(e.mask),this.stencilOp.set([e.fail,e.depthFail,e.pass]),this.stencilFunc.set({func:e.test.func,ref:e.ref,mask:e.test.mask})):this.stencilTest.set(!1)}setColorMode(e){t.bH(e.blendFunction,Jt.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(e.blendFunction),this.blendColor.set(e.blendColor)),this.colorMask.set(e.mask)}createVertexArray(){return Qt(this.gl)?this.gl.createVertexArray():this.gl.getExtension(`OES_vertex_array_object`)?.createVertexArrayOES()}deleteVertexArray(e){return Qt(this.gl)?this.gl.deleteVertexArray(e):this.gl.getExtension(`OES_vertex_array_object`)?.deleteVertexArrayOES(e)}unbindVAO(){this.bindVertexArray.set(null)}}let ei;function ti(e,n,r,i,a){let o=e.context,s=e.transform,c=o.gl,l=e.useProgram(`collisionBox`),u=[],d=0,f=0;for(let t=0;t<i.length;t++){let p=i[t],m=n.getTile(p).getBucket(r);if(!m)continue;let h=a?m.textCollisionBox:m.iconCollisionBox,g=m.collisionCircleArray;g.length>0&&(u.push({circleArray:g,circleOffset:f,coord:p}),d+=g.length/4,f=d),h&&l.draw(o,c.LINES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,Un(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),s.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,null,e.transform.zoom,null,null,h.collisionVertexBuffer)}if(!a||!u.length)return;let p=e.useProgram(`collisionCircle`),m=new t.c0;m.resize(4*d),m._trim();let h=0;for(let e of u)for(let t=0;t<e.circleArray.length/4;t++){let n=4*t,r=e.circleArray[n+0],i=e.circleArray[n+1],a=e.circleArray[n+2],o=e.circleArray[n+3];m.emplace(h++,r,i,a,o,0),m.emplace(h++,r,i,a,o,1),m.emplace(h++,r,i,a,o,2),m.emplace(h++,r,i,a,o,3)}(!ei||ei.length<2*d)&&(ei=function(e){let n=2*e,r=new t.c2;r.resize(n),r._trim();for(let e=0;e<n;e++){let t=6*e;r.uint16[t+0]=4*e+0,r.uint16[t+1]=4*e+1,r.uint16[t+2]=4*e+2,r.uint16[t+3]=4*e+2,r.uint16[t+4]=4*e+3,r.uint16[t+5]=4*e+0}return r}(d));let g=o.createIndexBuffer(ei,!0),_=o.createVertexBuffer(m,t.c1.members,!0);for(let n of u){let i=Wn(e.transform);p.draw(o,c.TRIANGLES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,i,e.style.map.terrain&&e.style.map.terrain.getTerrainData(n.coord),null,r.id,_,g,t.aM.simpleSegment(0,2*n.circleOffset,n.circleArray.length,n.circleArray.length/2),null,e.transform.zoom,null,null,null)}_.destroy(),g.destroy()}let ni=t.a4(new Float32Array(16));function ri(e,n,r,i,a,o){let{horizontalAlign:s,verticalAlign:c}=t.aH(e);return new t.P((-(s-.5)*n/a+i[0])*o,(-(c-.5)*r/a+i[1])*o)}function ii(e,n,r,i,a,o){let s=n.tileAnchorPoint.add(new t.P(n.translation[0],n.translation[1]));if(n.pitchWithMap){let e=i.mult(o);r||(e=e.rotate(-a));let t=s.add(e);return le(t.x,t.y,n.pitchedLabelPlaneMatrix,n.getElevation).point}if(r){let t=ve(n.tileAnchorPoint.x+1,n.tileAnchorPoint.y,n).point.sub(e),r=Math.atan(t.y/t.x)+(t.x<0?Math.PI:0);return e.add(i.rotate(r))}return e.add(i)}function ai(e,n,r,i,a,o,s,c,l,u,d,f){let p=e.text.placedSymbolArray,m=e.text.dynamicLayoutVertexArray,h=e.icon.dynamicLayoutVertexArray,g={};m.clear();for(let h=0;h<p.length;h++){let _=p.get(h),v=_.hidden||!_.crossTileID||e.allowVerticalPlacement&&!_.placedOrientation?null:i[_.crossTileID];if(v){let i=new t.P(_.anchorX,_.anchorY),p={getElevation:f,width:a.width,height:a.height,pitchedLabelPlaneMatrix:o,pitchWithMap:r,transform:a,tileAnchorPoint:i,translation:u,unwrappedTileID:d},h=r?be(i.x,i.y,p):ve(i.x,i.y,p),y=ue(a.cameraToCenterDistance,h.signedDistanceFromCamera),b=t.Q(e.textSizeData,c,_)*y/t.a7;r&&(b*=e.tilePixelRatio/s);let{width:x,height:S,anchor:C,textOffset:w,textBoxScale:T}=v,E=ri(C,x,S,w,T,b),D=a.getPitchedTextCorrection(i.x+u[0],i.y+u[1],d),O=ii(h.point,p,n,E,-a.bearingInRadians,D),k=e.allowVerticalPlacement&&_.placedOrientation===t.W.vertical?Math.PI/2:0;for(let e=0;e<_.numGlyphs;e++)t.Z(m,O,k);l&&_.associatedIconIndex>=0&&(g[_.associatedIconIndex]={shiftedAnchor:O,angle:k})}else Te(_.numGlyphs,m)}if(l){h.clear();let n=e.icon.placedSymbolArray;for(let e=0;e<n.length;e++){let r=n.get(e);if(r.hidden)Te(r.numGlyphs,h);else{let n=g[e];if(n)for(let e=0;e<r.numGlyphs;e++)t.Z(h,n.shiftedAnchor,n.angle);else Te(r.numGlyphs,h)}}e.icon.dynamicLayoutVertexBuffer.updateData(h)}e.text.dynamicLayoutVertexBuffer.updateData(m)}function oi(e,t,n){return n.iconsInText&&t?`symbolTextAndIcon`:e?`symbolSDF`:`symbolIcon`}function si(e,n,r,i,a,o,s,c,l,u,d,f,p){let m=e.context,h=m.gl,g=e.transform,_=c===`map`,v=l===`map`,y=c!==`viewport`&&r.layout.get(`symbol-placement`)!==`point`,b=_&&!v&&!y,x=!r.layout.get(`symbol-sort-key`).isConstant(),S=!1,C=e.getDepthModeForSublayer(0,G.ReadOnly),w=r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`),T=[],E=g.getCircleRadiusCorrection();for(let c of i){let i=n.getTile(c),l=i.getBucket(r);if(!l)continue;let d=a?l.text:l.icon;if(!d||!d.segments.get().length||!d.hasVisibleVertices)continue;let f=d.programConfigurations.get(r.id),m=a||l.sdfIcons,C=a?l.textSizeData:l.iconSizeData,D=v||g.pitch!==0,O=e.useProgram(oi(m,a,l),f),k=t.O(C,g.zoom),A=e.style.map.terrain&&e.style.map.terrain.getTerrainData(c),j,M,N,P,ee=[0,0],te=null;a?(M=i.glyphAtlasTexture,N=h.LINEAR,j=i.glyphAtlasTexture.size,l.iconsInText&&(ee=i.imageAtlasTexture.size,te=i.imageAtlasTexture,P=D||e.options.rotating||e.options.zooming||C.kind===`composite`||C.kind===`camera`?h.LINEAR:h.NEAREST)):(M=i.imageAtlasTexture,N=m||e.options.rotating||e.options.zooming||!g.rasterAlignment||l.iconsNeedLinear||D?h.LINEAR:h.NEAREST,j=i.imageAtlasTexture.size);let F=t.aC(i,1,e.transform.zoom,e.transform.detailLevel),ne=oe(_,e.transform,F),re=t.M();t.S(re,ne);let ie=se(v,_,e.transform,F),ae=t.aD(g,i,o,s),ce=g.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!p,applyTerrainMatrix:!0}),le=w&&l.hasTextData(),ue=r.layout.get(`icon-text-fit`)!==`none`&&le&&l.hasIconData();if(y){let t=e.style.map.terrain?(t,n)=>e.style.map.terrain.getElevation(c,t,n):null;fe(l,e,a,ne,re,v,u,r.layout.get(`text-rotation-alignment`)===`map`,c.toUnwrapped(),g.width,g.height,ae,t)}let de=a&&w||ue,pe=y||de?ni:v?ne:e.transform.clipSpaceToPixelsMatrix,me=m&&r.paint.get(a?`text-halo-width`:`icon-halo-width`).constantOr(1)!==0,he;he=m?l.iconsInText?cr(C.kind,k,b,v,y,de,e,pe,ie,ae,j,ee,E):sr(C.kind,k,b,v,y,de,e,pe,ie,ae,a,j,0,E):or(C.kind,k,b,v,y,de,e,pe,ie,ae,a,j,E);let ge={program:O,buffers:d,uniformValues:he,projectionData:ce,atlasTexture:M,atlasTextureIcon:te,atlasInterpolation:N,atlasInterpolationIcon:P,isSDF:m,hasHalo:me};if(x&&l.canOverlap){S=!0;let e=d.segments.get();for(let n of e)T.push({segments:new t.aM([n]),sortKey:n.sortKey,state:ge,terrainData:A})}else T.push({segments:d.segments,sortKey:0,state:ge,terrainData:A})}S&&T.sort(((e,t)=>e.sortKey-t.sortKey));for(let t of T){let n=t.state;if(m.activeTexture.set(h.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,h.CLAMP_TO_EDGE),n.atlasTextureIcon&&(m.activeTexture.set(h.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,h.CLAMP_TO_EDGE)),n.isSDF){let i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,ci(n.buffers,t.segments,r,e,n.program,C,d,f,i,n.projectionData,t.terrainData)),i.u_is_halo=0}ci(n.buffers,t.segments,r,e,n.program,C,d,f,n.uniformValues,n.projectionData,t.terrainData)}}function ci(e,t,n,r,i,a,o,s,c,l,u){let d=r.context;i.draw(d,d.gl.TRIANGLES,a,o,s,W.backCCW,c,u,l,n.id,e.layoutVertexBuffer,e.indexBuffer,t,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function li(e,n,r,i,a){let o=e.context,s=o.gl,c=K.disabled,l=new Jt([s.ONE,s.ONE],t.bf.transparent,[!0,!0,!0,!0]),u=n.getBucket(r);if(!u)return;let d=i.key,f=r.heatmapFbos.get(d);f||(f=di(o,n.tileSize,n.tileSize),r.heatmapFbos.set(d,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,n.tileSize,n.tileSize]),o.clear({color:t.bf.transparent});let p=u.programConfigurations.get(r.id),m=e.useProgram(`heatmap`,p,!a),h=e.transform.getProjectionData({overscaledTileID:n.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(i);m.draw(o,s.TRIANGLES,G.disabled,c,l,W.disabled,Kn(n,e.transform.zoom,e.transform.detailLevel,r.paint.get(`heatmap-intensity`),1),g,h,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,p)}function ui(e,t,n,r,i){let a=e.context,o=a.gl,s=e.transform;a.setColorMode(e.colorModeForRenderPass());let c=fi(a,t),l=n.key,u=t.heatmapFbos.get(l);if(!u)return;a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.colorAttachment.get()),a.activeTexture.set(o.TEXTURE1),c.bind(o.LINEAR,o.CLAMP_TO_EDGE);let d=s.getProjectionData({overscaledTileID:n,applyTerrainMatrix:i,applyGlobeMatrix:!r});e.useProgram(`heatmapTexture`).draw(a,o.TRIANGLES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,qn(e,t,0,1),null,d,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,s.zoom),u.destroy(),t.heatmapFbos.delete(l)}function di(e,t,n){let r=e.gl,i=r.createTexture();r.bindTexture(r.TEXTURE_2D,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR);let a=e.HALF_FLOAT??r.UNSIGNED_BYTE,o=e.RGBA16F??r.RGBA;r.texImage2D(r.TEXTURE_2D,0,o,t,n,0,r.RGBA,a,null);let s=e.createFramebuffer(t,n,!1,!1);return s.colorAttachment.set(i),s}function fi(e,n){return n.colorRampTexture||=new t.T(e,n.colorRamp,e.gl.RGBA),n.colorRampTexture}function pi(e,t,n,r,i){if(!n||!r||!r.imageAtlas)return;let a=r.imageAtlas.patternPositions,o=a[n.to.toString()],s=a[n.from.toString()];if(!o&&s&&(o=s),!s&&o&&(s=o),!o||!s){let e=i.getPaintProperty(t);o=a[e],s=a[e]}o&&s&&e.setConstantPatternPositions(o,s)}function mi(e,n,r,i,a,o,s,c){let l=e.context.gl,u=`fill-pattern`,d=r.paint.get(u),f=d&&d.constantOr(1),p=r.getCrossfadeParameters(),m,h,g,_,v,y=e.transform,b=r.paint.get(`fill-translate`),x=r.paint.get(`fill-translate-anchor`);s?(h=f&&!r.getPaintProperty(`fill-outline-color`)?`fillOutlinePattern`:`fillOutline`,m=l.LINES):(h=f?`fillPattern`:`fill`,m=l.TRIANGLES);let S=d.constantOr(null);for(let d of i){let i=n.getTile(d);if(f&&!i.patternsLoaded())continue;let C=i.getBucket(r);if(!C)continue;let w=C.programConfigurations.get(r.id),T=e.useProgram(h,w),E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(d);f&&(e.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),w.updatePaintBuffers(p)),pi(w,u,S,i,r);let D=y.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),O=t.aD(y,i,b,x);if(s){_=C.indexBuffer2,v=C.segments2;let t=[l.drawingBufferWidth,l.drawingBufferHeight];g=h===`fillOutlinePattern`&&f?Vn(e,p,i,t,O):Bn(t,O)}else _=C.indexBuffer,v=C.segments,g=f?zn(e,p,i,O):{u_fill_translate:O};let k=e.stencilModeForClipping(d);T.draw(e.context,m,a,k,o,W.backCCW,g,E,D,r.id,C.layoutVertexBuffer,_,v,r.paint,e.transform.zoom,w)}}function hi(e,n,r,i,a,o,s,c){let l=e.context,u=l.gl,d=`fill-extrusion-pattern`,f=r.paint.get(d),p=f.constantOr(1),m=r.getCrossfadeParameters(),h=r.paint.get(`fill-extrusion-opacity`),g=f.constantOr(null),_=e.transform;for(let f of i){let i=n.getTile(f),v=i.getBucket(r);if(!v)continue;let y=e.style.map.terrain&&e.style.map.terrain.getTerrainData(f),b=v.programConfigurations.get(r.id),x=e.useProgram(p?`fillExtrusionPattern`:`fillExtrusion`,b);p&&(e.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(m));let S=_.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!c,applyTerrainMatrix:!0});pi(b,d,g,i,r);let C=t.aD(_,i,r.paint.get(`fill-extrusion-translate`),r.paint.get(`fill-extrusion-translate-anchor`)),w=r.paint.get(`fill-extrusion-vertical-gradient`),T=p?Rn(e,w,h,C,f,m,i):Ln(e,w,h,C);x.draw(l,l.gl.TRIANGLES,a,o,s,W.backCCW,T,y,S,r.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,r.paint,e.transform.zoom,b,e.style.map.terrain&&v.centroidVertexBuffer)}}function gi(e,t,n,r,i,a,o,s,c){let l=e.style.projection,u=e.context,d=e.transform,f=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${n.paint.get(`hillshade-highlight-color`).values.length}`],m=e.useProgram(`hillshade`,null,!1,p),h=!e.options.moving;for(let p of r){let r=t.getTile(p),g=r.fbo;if(!g)continue;let _=l.getMeshFromTileID(u,p.canonical,s,!0,`raster`),v=e.style.map.terrain?.getTerrainData(p);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,g.colorAttachment.get());let y=d.getProjectionData({overscaledTileID:p,aligned:h,applyGlobeMatrix:!c,applyTerrainMatrix:!0});m.draw(u,f.TRIANGLES,a,i[p.overscaledZ],o,W.backCCW,Jn(e,r,n),v,y,n.id,_.vertexBuffer,_.indexBuffer,_.segments)}}function _i(e,n,r,i,a,o,s,c,l){let u=e.style.projection,d=e.context,f=e.transform,p=d.gl,m=e.useProgram(`colorRelief`),h=!e.options.moving,g=!0,_=0;for(let v of i){let i=n.getTile(v),y=i.dem;if(g){let e=p.getParameter(p.MAX_TEXTURE_SIZE),{elevationTexture:t,colorTexture:n}=r.getColorRampTextures(d,e,y.getUnpackVector());d.activeTexture.set(p.TEXTURE1),t.bind(p.NEAREST,p.CLAMP_TO_EDGE),d.activeTexture.set(p.TEXTURE4),n.bind(p.LINEAR,p.CLAMP_TO_EDGE),g=!1,_=t.size[0]}if(!y||!y.data)continue;let b=y.stride,x=y.getPixels();if(d.activeTexture.set(p.TEXTURE0),d.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(b),i.demTexture){let e=i.demTexture;e.update(x,{premultiply:!1}),e.bind(p.LINEAR,p.CLAMP_TO_EDGE)}else i.demTexture=new t.T(d,x,p.RGBA,{premultiply:!1}),i.demTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE);let S=u.getMeshFromTileID(d,v.canonical,c,!0,`raster`),C=e.style.map.terrain?.getTerrainData(v),w=f.getProjectionData({overscaledTileID:v,aligned:h,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(d,p.TRIANGLES,o,a[v.overscaledZ],s,W.backCCW,Zn(r,i.dem,_),C,w,r.id,S.vertexBuffer,S.indexBuffer,S.segments)}}let vi=[new t.P(0,0),new t.P(t.ah,0),new t.P(t.ah,t.ah),new t.P(0,t.ah)];function yi(e,t,n,r,i,a,o,s,c=!1,l=!1){let u=r[r.length-1].overscaledZ,d=e.context,f=d.gl,p=e.useProgram(`raster`),m=e.transform,h=e.style.projection,g=e.colorModeForRenderPass(),_=!e.options.moving;for(let v of r){let r=e.getDepthModeForSublayer(v.overscaledZ-u,n.paint.get(`raster-opacity`)===1?G.ReadWrite:G.ReadOnly,f.LESS),y=t.getTile(v);y.registerFadeDuration(n.paint.get(`raster-fade-duration`));let b=t.findLoadedParent(v,0),x=t.findLoadedSibling(v),S=bi(y,b||x||null,t,n,e.transform,e.style.map.terrain),C,w,T=n.paint.get(`raster-resampling`)===`nearest`?f.NEAREST:f.LINEAR;d.activeTexture.set(f.TEXTURE0),y.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),d.activeTexture.set(f.TEXTURE1),b?(b.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),C=2**(b.tileID.overscaledZ-y.tileID.overscaledZ),w=[y.tileID.canonical.x*C%1,y.tileID.canonical.y*C%1]):y.texture.bind(T,f.CLAMP_TO_EDGE,f.LINEAR_MIPMAP_NEAREST),y.texture.useMipmap&&d.extTextureFilterAnisotropic&&e.transform.pitch>20&&f.texParameterf(f.TEXTURE_2D,d.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,d.extTextureFilterAnisotropicMax);let E=e.style.map.terrain&&e.style.map.terrain.getTerrainData(v),D=m.getProjectionData({overscaledTileID:v,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),O=ir(w||[0,0],C||1,S,n,s),k=h.getMeshFromTileID(d,v.canonical,a,o,`raster`);p.draw(d,f.TRIANGLES,r,i?i[v.overscaledZ]:K.disabled,g,c?W.frontCCW:W.backCCW,O,E,D,n.id,k.vertexBuffer,k.indexBuffer,k.segments)}}function bi(e,n,r,i,a,s){let c=i.paint.get(`raster-fade-duration`);if(!s&&c>0){let i=o.now(),s=(i-e.timeAdded)/c,l=n?(i-n.timeAdded)/c:-1,u=r.getSource(),d=nt(a,{tileSize:u.tileSize,roundZoom:u.roundZoom}),f=!n||Math.abs(n.tileID.overscaledZ-d)>Math.abs(e.tileID.overscaledZ-d),p=f&&e.refreshedUponExpiration?1:t.L(f?s:1-l,0,1);return e.refreshedUponExpiration&&s>=1&&(e.refreshedUponExpiration=!1),n?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}let xi=new t.bf(1,0,0,1),Si=new t.bf(0,1,0,1),Ci=new t.bf(0,0,1,1),wi=new t.bf(1,0,1,1),Ti=new t.bf(0,1,1,1);function Ei(e,t,n,r){Oi(e,0,t+n/2,e.transform.width,n,r)}function Di(e,t,n,r){Oi(e,t-n/2,0,n,e.transform.height,r)}function Oi(e,t,n,r,i,a){let o=e.context,s=o.gl;s.enable(s.SCISSOR_TEST),s.scissor(t*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio,i*e.pixelRatio),o.clear({color:a}),s.disable(s.SCISSOR_TEST)}function ki(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`debug`),s=G.disabled,c=K.disabled,l=e.colorModeForRenderPass(),u=`$debug`,d=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);i.activeTexture.set(a.TEXTURE0);let f=n.getTileByID(r.key).latestRawTileData,p=Math.floor((f&&f.byteLength||0)/1024),m=n.getTile(r).tileSize,h=512/Math.min(m,512)*(r.overscaledZ/e.transform.zoom)*.5,g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();let n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext(`2d`);i.clearRect(0,0,n.width,n.height),i.shadowColor=`white`,i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle=`white`,i.textBaseline=`top`,i.font=`bold 36px Open Sans, sans-serif`,i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);let _=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});o.draw(i,a.TRIANGLES,s,c,Jt.alphaBlended,W.disabled,Gn(t.bf.transparent,h),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),o.draw(i,a.LINE_STRIP,s,c,l,W.disabled,Gn(t.bf.red),d,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function Ai(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=a.gl,s=e.transform,c=e.colorModeForRenderPass(),l=e.getDepthModeFor3D(),u=e.useProgram(`terrain`);a.bindFramebuffer.set(null),a.viewport.set([0,0,e.width,e.height]);for(let r of n){let n=t.getTerrainMesh(r.tileID),d=e.renderToTexture.getTexture(r),f=t.getTerrainData(r.tileID);a.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,d.texture);let p=Mn(t.getMeshFrameDelta(s.zoom),s.calculateFogMatrix(r.tileID.toUnwrapped()),e.style.sky,s.pitch,i),m=s.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(a,o.TRIANGLES,l,K.disabled,c,W.backCCW,p,f,m,`terrain`,n.vertexBuffer,n.indexBuffer,n.segments)}}function ji(e,n){if(!n.mesh){let r=new t.aL;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);let i=new t.aN;i.emplaceBack(0,1,2),i.emplaceBack(0,2,3),n.mesh=new Mt(e.createVertexBuffer(r,Nt.members),e.createIndexBuffer(i),t.aM.simpleSegment(0,0,r.length,i.length))}return n.mesh}class Mi{constructor(e,n){this.context=new $r(e),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.a4(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=at.maxUnderzooming+at.maxOverzooming+1,this.depthEpsilon=1/2**16,this.crossTileSymbolIndex=new Ot}resize(e,t,n,r){if(this.width=Math.floor(e*n),this.height=Math.floor(t*n),this.pixelRatio=n*r,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let e of this.style._order)this.style._layers[e].resize()}setup(){let e=this.context,n=new t.aL;n.emplaceBack(0,0),n.emplaceBack(t.ah,0),n.emplaceBack(0,t.ah),n.emplaceBack(t.ah,t.ah),this.tileExtentBuffer=e.createVertexBuffer(n,Nt.members),this.tileExtentSegments=t.aM.simpleSegment(0,0,4,2);let r=new t.aL;r.emplaceBack(0,0),r.emplaceBack(t.ah,0),r.emplaceBack(0,t.ah),r.emplaceBack(t.ah,t.ah),this.debugBuffer=e.createVertexBuffer(r,Nt.members),this.debugSegments=t.aM.simpleSegment(0,0,4,5);let i=new t.c7;i.emplaceBack(0,0,0,0),i.emplaceBack(t.ah,0,t.ah,0),i.emplaceBack(0,t.ah,0,t.ah),i.emplaceBack(t.ah,t.ah,t.ah,t.ah),this.rasterBoundsBuffer=e.createVertexBuffer(i,An.members),this.rasterBoundsSegments=t.aM.simpleSegment(0,0,4,2);let a=new t.aL;a.emplaceBack(0,0),a.emplaceBack(t.ah,0),a.emplaceBack(0,t.ah),a.emplaceBack(t.ah,t.ah),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(a,Nt.members),this.rasterBoundsSegmentsPosOnly=t.aM.simpleSegment(0,0,4,5);let o=new t.aL;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(o,Nt.members),this.viewportSegments=t.aM.simpleSegment(0,0,4,2);let s=new t.c8;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(s);let c=new t.aN;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(c);let l=this.context.gl;this.stencilClearMode=new K({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new Mt(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let e=this.context,n=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let r=t.M();t.bZ(r,0,this.width,this.height,0,0,1),t.N(r,r,[n.drawingBufferWidth,n.drawingBufferHeight,0]);let i={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram(`clippingMask`,null,!0).draw(e,n.TRIANGLES,G.disabled,this.stencilClearMode,Jt.disabled,W.disabled,null,null,i,`$clipping`,this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,n){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();let r=this.context;r.setColorMode(Jt.disabled),r.setDepthMode(G.disabled);let i={};for(let e of t)i[e.key]=this.nextStencilID++;this._renderTileMasks(i,t,n,!0),this._renderTileMasks(i,t,n,!1),this._tileClippingMaskIDs=i}_renderTileMasks(e,t,n,r){let i=this.context,a=i.gl,o=this.style.projection,s=this.transform,c=this.useProgram(`clippingMask`);for(let l of t){let t=e[l.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(l),d=o.getMeshFromTileID(this.context,l.canonical,r,!0,`stencil`),f=s.getProjectionData({overscaledTileID:l,applyGlobeMatrix:!n,applyTerrainMatrix:!0});c.draw(i,a.TRIANGLES,G.disabled,new K({func:a.ALWAYS,mask:0},t,255,a.KEEP,a.KEEP,a.REPLACE),Jt.disabled,n?W.disabled:W.backCCW,null,u,f,`$clipping`,d.vertexBuffer,d.indexBuffer,d.segments)}}_renderTilesDepthBuffer(){let e=this.context,t=e.gl,n=this.style.projection,r=this.transform,i=this.useProgram(`depth`),a=this.getDepthModeFor3D(),o=rt(r,{tileSize:r.tileSize});for(let s of o){let o=this.style.map.terrain&&this.style.map.terrain.getTerrainData(s),c=n.getMeshFromTileID(this.context,s.canonical,!0,!0,`raster`),l=r.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!0,applyTerrainMatrix:!0});i.draw(e,t.TRIANGLES,a,K.disabled,Jt.disabled,W.backCCW,null,o,l,`$clipping`,c.vertexBuffer,c.indexBuffer,c.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let e=this.nextStencilID++,t=this.context.gl;return new K({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){let t=this.context.gl;return new K({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(i>1){this.currentStencilSource=void 0,this.nextStencilID+i>256&&this.clearStencil();let e={};for(let n=0;n<i;n++)e[n+r]=new K({func:t.GEQUAL,mask:255},n+this.nextStencilID,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID+=i,[e,n]}return[{[r]:K.disabled},n]}stencilConfigForOverlapTwoPass(e){let t=this.context.gl,n=e.sort(((e,t)=>t.overscaledZ-e.overscaledZ)),r=n[n.length-1].overscaledZ,i=n[0].overscaledZ-r+1;if(this.clearStencil(),i>1){let e={},a={};for(let n=0;n<i;n++)e[n+r]=new K({func:t.GREATER,mask:255},i+1+n,255,t.KEEP,t.KEEP,t.REPLACE),a[n+r]=new K({func:t.GREATER,mask:255},1+n,255,t.KEEP,t.KEEP,t.REPLACE);return this.nextStencilID=2*i+1,[e,a,n]}return this.nextStencilID=3,[{[r]:new K({func:t.GREATER,mask:255},2,255,t.KEEP,t.KEEP,t.REPLACE)},{[r]:new K({func:t.GREATER,mask:255},1,255,t.KEEP,t.KEEP,t.REPLACE)},n]}colorModeForRenderPass(){let e=this.context.gl;if(this._showOverdrawInspector){let n=1/8;return new Jt([e.CONSTANT_COLOR,e.ONE],new t.bf(n,n,n,0),[!0,!0,!0,!0])}return this.renderPass===`opaque`?Jt.unblended:Jt.alphaBlended}getDepthModeForSublayer(e,t,n){if(!this.opaquePassEnabledForLayer())return G.disabled;let r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new G(n||this.context.gl.LEQUAL,t,[r,r])}getDepthModeFor3D(){return new G(this.context.gl.LEQUAL,G.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(e,n){var r;this.style=e,this.options=n,this.lineAtlas=e.lineAtlas,this.imageManager=e.imageManager,this.glyphManager=e.glyphManager,this.symbolFadeChange=e.placement.symbolFadeChange(o.now()),this.imageManager.beginFrame();let i=this.style._order,a=this.style.sourceCaches,s={},c={},l={},u={isRenderingToTexture:!1,isRenderingGlobe:e.projection?.transitionState>0};for(let e in a){let t=a[e];t.used&&t.prepare(this.context),s[e]=t.getVisibleCoordinates(!1),c[e]=s[e].slice().reverse(),l[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;e<i.length;e++)if(this.style._layers[i[e]].is3D()){this.opaquePassCutoff=e;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass=`offscreen`;for(let e of i){let t=this.style._layers[e];if(!t.hasOffscreenPass()||t.isHidden(this.transform.zoom))continue;let n=c[t.source];(t.type===`custom`||n.length)&&this.renderLayer(this,a[t.source],t,n,u)}if((r=this.style.projection)==null||r.updateGPUdependent({context:this.context,useProgram:e=>this.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:n.showOverdrawInspector?t.bf.black:t.bf.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){let n=e.context,r=n.gl,i=((e,t,n)=>{let r=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),a=Xe(t),o=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get(`sky-color`),u_horizon_color:e.properties.get(`horizon-color`),u_horizon:[(t.width/2-a*i)*n,(t.height/2+a*r)*n],u_horizon_normal:[-i,r],u_sky_horizon_blend:e.properties.get(`sky-horizon-blend`)*t.height/2*n,u_sky_blend:o}})(t,e.style.map.transform,e.pixelRatio),a=new G(r.LEQUAL,G.ReadWrite,[0,1]),o=K.disabled,s=e.colorModeForRenderPass(),c=e.useProgram(`sky`),l=ji(n,t);c.draw(n,r.TRIANGLES,a,o,s,W.disabled,i,null,void 0,`sky`,l.vertexBuffer,l.indexBuffer,l.segments)}(this,this.style.sky),this._showOverdrawInspector=n.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass=`opaque`,this.currentLayer=i.length-1;this.currentLayer>=0;this.currentLayer--){let e=this.style._layers[i[this.currentLayer]],t=a[e.source],n=s[e.source];this._renderTileClippingMasks(e,n,!1),this.renderLayer(this,t,e,n,u)}this.renderPass=`translucent`;let d=!1;for(this.currentLayer=0;this.currentLayer<i.length;this.currentLayer++){let e=this.style._layers[i[this.currentLayer]],t=a[e.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(e,u))continue;this.opaquePassEnabledForLayer()||d||(d=!0,u.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let n=(e.type===`symbol`?l:c)[e.source];this._renderTileClippingMasks(e,s[e.source],!!this.renderToTexture),this.renderLayer(this,t,e,n,u)}if(u.isRenderingGlobe&&function(e,n,r){let i=e.context,a=i.gl,o=e.useProgram(`atmosphere`),s=new G(a.LEQUAL,G.ReadOnly,[0,1]),c=e.transform,l=function(e,n){let r=e.properties.get(`position`),i=[-r.x,-r.y,-r.z],a=t.a4(new Float64Array(16));return e.properties.get(`anchor`)===`map`&&(t.b6(a,a,n.rollInRadians),t.b7(a,a,-n.pitchInRadians),t.b6(a,a,n.bearingInRadians),t.b7(a,a,n.center.lat*Math.PI/180),t.bz(a,a,-n.center.lng*Math.PI/180)),t.c6(i,i,a),i}(r,e.transform),u=c.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),d=n.properties.get(`atmosphere-blend`)*u.projectionTransition;if(d===0)return;let f=un(c.worldSize,c.center.lat),p=c.inverseProjectionMatrix,m=new Float64Array(4);m[3]=1,t.$(m,m,c.modelViewProjectionMatrix),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1,t.$(m,m,p),m[0]/=m[3],m[1]/=m[3],m[2]/=m[3],m[3]=1;let h=((e,t,n,r,i)=>({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:n,u_globe_radius:r,u_inv_proj_matrix:i}))(l,d,[m[0],m[1],m[2]],f,p),g=ji(i,n);o.draw(i,a.TRIANGLES,s,K.disabled,Jt.alphaBlended,W.disabled,h,null,null,`atmosphere`,g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let e=function(e,t){let n=null,r=Object.values(e._layers).flatMap((n=>n.source&&!n.isHidden(t)?[e.sourceCaches[n.source]]:[])),i=r.filter((e=>e.getSource().type===`vector`)),a=r.filter((e=>e.getSource().type!==`vector`)),o=e=>{(!n||n.getSource().maxzoom<e.getSource().maxzoom)&&(n=e)};return i.forEach((e=>o(e))),n||a.forEach((e=>o(e))),n}(this.style,this.transform.zoom);e&&function(e,t,n){for(let r=0;r<n.length;r++)ki(e,t,n[r])}(this,e,e.getVisibleCoordinates())}this.options.showPadding&&function(e){let t=e.transform.padding;Ei(e,e.transform.height-(t.top||0),3,xi),Ei(e,t.bottom||0,3,Si),Di(e,t.left||0,3,Ci),Di(e,e.transform.width-(t.right||0),3,wi);let n=e.transform.centerPoint;(function(e,t,n,r){Oi(e,t-1,n-10,2,20,r),Oi(e,t-10,n-1,20,2,r)})(e,n.x,e.transform.height-n.y,Ti)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(e){if(!this.style||!this.style.map||!this.style.map.terrain)return;let n=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.dirty;i||=e?!t.c9(n,r):!t.ca(n,r),i||=this.style.map.terrain.sourceCache.anyTilesAfterTime(this.terrainFacilitator.renderTime),i&&(t.cb(n,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(e,n){let r=e.context,i=r.gl,a=e.transform,o=Jt.unblended,s=new G(i.LEQUAL,G.ReadWrite,[0,1]),c=n.sourceCache.getRenderableTiles(),l=e.useProgram(`terrainDepth`);r.bindFramebuffer.set(n.getFramebuffer(`depth`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bf.transparent,depth:1});for(let e of c){let t=n.getTerrainMesh(e.tileID),c=n.getTerrainData(e.tileID),u=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),d={u_ele_delta:n.getMeshFrameDelta(a.zoom)};l.draw(r,i.TRIANGLES,s,K.disabled,o,W.backCCW,d,c,u,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain),function(e,n){let r=e.context,i=r.gl,a=e.transform,o=Jt.unblended,s=new G(i.LEQUAL,G.ReadWrite,[0,1]),c=n.getCoordsTexture(),l=n.sourceCache.getRenderableTiles(),u=e.useProgram(`terrainCoords`);r.bindFramebuffer.set(n.getFramebuffer(`coords`).framebuffer),r.viewport.set([0,0,e.width/devicePixelRatio,e.height/devicePixelRatio]),r.clear({color:t.bf.transparent,depth:1}),n.coordsIndex=[];for(let e of l){let t=n.getTerrainMesh(e.tileID),l=n.getTerrainData(e.tileID);r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,c.texture);let d={u_terrain_coords_id:(255-n.coordsIndex.length)/255,u_texture:0,u_ele_delta:n.getMeshFrameDelta(a.zoom)},f=a.getProjectionData({overscaledTileID:e.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(r,i.TRIANGLES,s,K.disabled,o,W.backCCW,d,l,f,`terrain`,t.vertexBuffer,t.indexBuffer,t.segments),n.coordsIndex.push(e.tileID.key)}r.bindFramebuffer.set(null),r.viewport.set([0,0,e.width,e.height])}(this,this.style.map.terrain))}renderLayer(e,n,r,i,a){r.isHidden(this.transform.zoom)||(r.type===`background`||r.type===`custom`||(i||[]).length)&&(this.id=r.id,t.cc(r)?function(e,n,r,i,a,o){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:s}=o,c=K.disabled,l=e.colorModeForRenderPass();(r._unevaluatedLayout.hasValue(`text-variable-anchor`)||r._unevaluatedLayout.hasValue(`text-variable-anchor-offset`))&&function(e,n,r,i,a,o,s,c,l){let u=n.transform,d=n.style.map.terrain,f=a===`map`,p=o===`map`;for(let a of e){let e=i.getTile(a),o=e.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;let m=t.O(o.textSizeData,u.zoom),h=t.aC(e,1,n.transform.zoom,n.transform.detailLevel),g=oe(f,n.transform,h),_=r.layout.get(`icon-text-fit`)!==`none`&&o.hasIconData();if(m){let n=2**(u.zoom-e.tileID.overscaledZ),r=d?(e,t)=>d.getElevation(a,e,t):null;ai(o,f,p,l,u,g,n,m,_,t.aD(u,e,s,c),a.toUnwrapped(),r)}}}(i,e,r,n,r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),a),r.paint.get(`icon-opacity`).constantOr(1)!==0&&si(e,n,r,i,!1,r.paint.get(`icon-translate`),r.paint.get(`icon-translate-anchor`),r.layout.get(`icon-rotation-alignment`),r.layout.get(`icon-pitch-alignment`),r.layout.get(`icon-keep-upright`),c,l,s),r.paint.get(`text-opacity`).constantOr(1)!==0&&si(e,n,r,i,!0,r.paint.get(`text-translate`),r.paint.get(`text-translate-anchor`),r.layout.get(`text-rotation-alignment`),r.layout.get(`text-pitch-alignment`),r.layout.get(`text-keep-upright`),c,l,s),n.map.showCollisionBoxes&&(ti(e,n,r,i,!0),ti(e,n,r,i,!1))}(e,n,r,i,this.style.placement.variableOffsets,a):t.cd(r)?function(e,n,r,i,a){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`circle-opacity`),c=r.paint.get(`circle-stroke-width`),l=r.paint.get(`circle-stroke-opacity`),u=!r.layout.get(`circle-sort-key`).isConstant();if(s.constantOr(1)===0&&(c.constantOr(1)===0||l.constantOr(1)===0))return;let d=e.context,f=d.gl,p=e.transform,m=e.getDepthModeForSublayer(0,G.ReadOnly),h=K.disabled,g=e.colorModeForRenderPass(),_=[],v=p.getCircleRadiusCorrection();for(let a=0;a<i.length;a++){let s=i[a],c=n.getTile(s),l=c.getBucket(r);if(!l)continue;let d=r.paint.get(`circle-translate`),f=r.paint.get(`circle-translate-anchor`),m=t.aD(p,c,d,f),h=l.programConfigurations.get(r.id),g=e.useProgram(`circle`,h),y=l.layoutVertexBuffer,b=l.indexBuffer,x=e.style.map.terrain&&e.style.map.terrain.getTerrainData(s),S={programConfiguration:h,program:g,layoutVertexBuffer:y,indexBuffer:b,uniformValues:Hn(e,c,r,m,v),terrainData:x,projectionData:p.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!o,applyTerrainMatrix:!0})};if(u){let e=l.segments.get();for(let n of e)_.push({segments:new t.aM([n]),sortKey:n.sortKey,state:S})}else _.push({segments:l.segments,sortKey:0,state:S})}u&&_.sort(((e,t)=>e.sortKey-t.sortKey));for(let t of _){let{programConfiguration:n,program:i,layoutVertexBuffer:a,indexBuffer:o,uniformValues:s,terrainData:c,projectionData:l}=t.state;i.draw(d,f.TRIANGLES,m,h,g,W.backCCW,s,c,l,r.id,a,o,t.segments,r.paint,e.transform.zoom,n)}}(e,n,r,i,a):t.ce(r)?function(e,n,r,i,a){if(r.paint.get(`heatmap-opacity`)===0)return;let o=e.context,{isRenderingToTexture:s,isRenderingGlobe:c}=a;if(e.style.map.terrain){for(let t of i){let i=n.getTile(t);n.hasRenderableParent(t)||(e.renderPass===`offscreen`?li(e,i,r,t,c):e.renderPass===`translucent`&&ui(e,r,t,s,c))}o.viewport.set([0,0,e.width,e.height])}else e.renderPass===`offscreen`?function(e,n,r,i){let a=e.context,o=a.gl,s=e.transform,c=K.disabled,l=new Jt([o.ONE,o.ONE],t.bf.transparent,[!0,!0,!0,!0]);(function(e,n,r){let i=e.gl;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,n.width/4,n.height/4]);let a=r.heatmapFbos.get(t.c3);a?(i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)):(a=di(e,n.width/4,n.height/4),r.heatmapFbos.set(t.c3,a))})(a,e,r),a.clear({color:t.bf.transparent});for(let t=0;t<i.length;t++){let u=i[t];if(n.hasRenderableParent(u))continue;let d=n.getTile(u),f=d.getBucket(r);if(!f)continue;let p=f.programConfigurations.get(r.id),m=e.useProgram(`heatmap`,p),h=s.getProjectionData({overscaledTileID:u,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),g=s.getCircleRadiusCorrection();m.draw(a,o.TRIANGLES,G.disabled,c,l,W.backCCW,Kn(d,s.zoom,s.detailLevel,r.paint.get(`heatmap-intensity`),g),null,h,r.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,r.paint,s.zoom,p)}a.viewport.set([0,0,e.width,e.height])}(e,n,r,i):e.renderPass===`translucent`&&function(e,n){let r=e.context,i=r.gl;r.setColorMode(e.colorModeForRenderPass());let a=n.heatmapFbos.get(t.c3);a&&(r.activeTexture.set(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,a.colorAttachment.get()),r.activeTexture.set(i.TEXTURE1),fi(r,n).bind(i.LINEAR,i.CLAMP_TO_EDGE),e.useProgram(`heatmapTexture`).draw(r,i.TRIANGLES,G.disabled,K.disabled,e.colorModeForRenderPass(),W.disabled,qn(e,n,0,1),null,null,n.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,n.paint,e.transform.zoom))}(e,r)}(e,n,r,i,a):t.cf(r)?function(e,n,r,i,a){if(e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=r.paint.get(`line-opacity`),c=r.paint.get(`line-width`);if(s.constantOr(1)===0||c.constantOr(1)===0)return;let l=e.getDepthModeForSublayer(0,G.ReadOnly),u=e.colorModeForRenderPass(),d=r.paint.get(`line-dasharray`),f=r.paint.get(`line-pattern`),p=f.constantOr(1),m=r.paint.get(`line-gradient`),h=r.getCrossfadeParameters(),g=p?`linePattern`:d?`lineSDF`:m?`lineGradient`:`line`,_=e.context,v=_.gl,y=e.transform,b=!0;for(let a of i){let i=n.getTile(a);if(p&&!i.patternsLoaded())continue;let s=i.getBucket(r);if(!s)continue;let c=s.programConfigurations.get(r.id),x=e.context.program.get(),S=e.useProgram(g,c),C=b||S.program!==x,w=e.style.map.terrain&&e.style.map.terrain.getTerrainData(a),T=f.constantOr(null);if(T&&i.imageAtlas){let e=i.imageAtlas,t=e.patternPositions[T.to.toString()],n=e.patternPositions[T.from.toString()];t&&n&&c.setConstantPatternPositions(t,n)}let E=y.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),D=y.getPixelScale(),O=p?er(e,i,r,D,h):d?tr(e,i,r,D,d,h):m?$n(e,i,r,D,s.lineClipsArray.length):Qn(e,i,r,D);if(p)_.activeTexture.set(v.TEXTURE0),i.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),c.updatePaintBuffers(h);else if(d&&(C||e.lineAtlas.dirty))_.activeTexture.set(v.TEXTURE0),e.lineAtlas.bind(_);else if(m){let i=s.gradients[r.id],o=i.texture;if(r.gradientVersion!==i.version){let c=256;if(r.stepInterpolant){let r=n.getSource().maxzoom,i=a.canonical.z===r?Math.ceil(1<<e.transform.maxZoom-a.canonical.z):1;c=t.L(t.c4(s.maxLineLength/t.ah*1024*i),256,_.maxTextureSize)}i.gradient=t.c5({expression:r.gradientExpression(),evaluationKey:`lineProgress`,resolution:c,image:i.gradient||void 0,clips:s.lineClipsArray}),i.texture?i.texture.update(i.gradient):i.texture=new t.T(_,i.gradient,v.RGBA),i.version=r.gradientVersion,o=i.texture}_.activeTexture.set(v.TEXTURE0),o.bind(r.stepInterpolant?v.NEAREST:v.LINEAR,v.CLAMP_TO_EDGE)}let k=e.stencilModeForClipping(a);S.draw(_,v.TRIANGLES,l,k,u,W.disabled,O,w,E,r.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,r.paint,e.transform.zoom,c,s.layoutVertexBuffer2),b=!1}}(e,n,r,i,a):t.cg(r)?function(e,n,r,i,a){let o=r.paint.get(`fill-color`),s=r.paint.get(`fill-opacity`);if(s.constantOr(1)===0)return;let{isRenderingToTexture:c}=a,l=e.colorModeForRenderPass(),u=r.paint.get(`fill-pattern`),d=e.opaquePassEnabledForLayer()&&!u.constantOr(1)&&o.constantOr(t.bf.transparent).a===1&&s.constantOr(0)===1?`opaque`:`translucent`;e.renderPass===d&&mi(e,n,r,i,e.getDepthModeForSublayer(1,e.renderPass===`opaque`?G.ReadWrite:G.ReadOnly),l,!1,c),e.renderPass===`translucent`&&r.paint.get(`fill-antialias`)&&mi(e,n,r,i,e.getDepthModeForSublayer(r.getPaintProperty(`fill-outline-color`)?2:0,G.ReadOnly),l,!0,c)}(e,n,r,i,a):t.ch(r)?function(e,t,n,r,i){let a=n.paint.get(`fill-extrusion-opacity`);if(a===0)return;let{isRenderingToTexture:o}=i;if(e.renderPass===`translucent`){let i=new G(e.context.gl.LEQUAL,G.ReadWrite,e.depthRangeFor3D);if(a!==1||n.paint.get(`fill-extrusion-pattern`).constantOr(1))hi(e,t,n,r,i,K.disabled,Jt.disabled,o),hi(e,t,n,r,i,e.stencilModeFor3D(),e.colorModeForRenderPass(),o);else{let a=e.colorModeForRenderPass();hi(e,t,n,r,i,K.disabled,a,o)}}}(e,n,r,i,a):t.ci(r)?function(e,n,r,i,a){if(e.renderPass!==`offscreen`&&e.renderPass!==`translucent`)return;let{isRenderingToTexture:o}=a,s=e.context,c=e.style.projection.useSubdivision,l=e.getDepthModeForSublayer(0,G.ReadOnly),u=e.colorModeForRenderPass();if(e.renderPass===`offscreen`)(function(e,n,r,i,a,o,s){let c=e.context,l=c.gl;for(let u of r){let r=n.getTile(u),d=r.dem;if(!d||!d.data||!r.needsHillshadePrepare)continue;let f=d.dim,p=d.stride,m=d.getPixels();if(c.activeTexture.set(l.TEXTURE1),c.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture=r.demTexture||e.getTileTexture(p),r.demTexture){let e=r.demTexture;e.update(m,{premultiply:!1}),e.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else r.demTexture=new t.T(c,m,l.RGBA,{premultiply:!1}),r.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);c.activeTexture.set(l.TEXTURE0);let h=r.fbo;if(!h){let e=new t.T(c,{width:f,height:f,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=r.fbo=c.createFramebuffer(f,f,!0,!1),h.colorAttachment.set(e.texture)}c.bindFramebuffer.set(h.framebuffer),c.viewport.set([0,0,f,f]),e.useProgram(`hillshadePrepare`).draw(c,l.TRIANGLES,a,o,s,W.disabled,Yn(r.tileID,d),null,null,i.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments),r.needsHillshadePrepare=!1}})(e,n,i,r,l,K.disabled,u),s.viewport.set([0,0,e.width,e.height]);else if(e.renderPass===`translucent`)if(c){let[t,a,s]=e.stencilConfigForOverlapTwoPass(i);gi(e,n,r,s,t,l,u,!1,o),gi(e,n,r,s,a,l,u,!0,o)}else{let[t,a]=e.getStencilConfigForOverlapAndUpdateStencilID(i);gi(e,n,r,a,t,l,u,!1,o)}}(e,n,r,i,a):t.cj(r)?function(e,t,n,r,i){if(e.renderPass!==`translucent`||!r.length)return;let{isRenderingToTexture:a}=i,o=e.style.projection.useSubdivision,s=e.getDepthModeForSublayer(0,G.ReadOnly),c=e.colorModeForRenderPass();if(o){let[i,o,l]=e.stencilConfigForOverlapTwoPass(r);_i(e,t,n,l,i,s,c,!1,a),_i(e,t,n,l,o,s,c,!0,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);_i(e,t,n,o,i,s,c,!1,a)}}(e,n,r,i,a):t.ck(r)?function(e,t,n,r,i){if(e.renderPass!==`translucent`||n.paint.get(`raster-opacity`)===0||!r.length)return;let{isRenderingToTexture:a}=i,o=t.getSource(),s=e.style.projection.useSubdivision;if(o instanceof ze)yi(e,t,n,r,null,!1,!1,o.tileCoords,o.flippedWindingOrder,a);else if(s){let[i,o,s]=e.stencilConfigForOverlapTwoPass(r);yi(e,t,n,s,i,!1,!0,vi,!1,a),yi(e,t,n,s,o,!0,!0,vi,!1,a)}else{let[i,o]=e.getStencilConfigForOverlapAndUpdateStencilID(r);yi(e,t,n,o,i,!1,!0,vi,!1,a)}}(e,n,r,i,a):t.cl(r)?function(e,t,n,r,i){let a=n.paint.get(`background-color`),o=n.paint.get(`background-opacity`);if(o===0)return;let{isRenderingToTexture:s}=i,c=e.context,l=c.gl,u=e.style.projection,d=e.transform,f=d.tileSize,p=n.paint.get(`background-pattern`);if(e.isPatternMissing(p))return;let m=!p&&a.a===1&&o===1&&e.opaquePassEnabledForLayer()?`opaque`:`translucent`;if(e.renderPass!==m)return;let h=K.disabled,g=e.getDepthModeForSublayer(0,m===`opaque`?G.ReadWrite:G.ReadOnly),_=e.colorModeForRenderPass(),v=e.useProgram(p?`backgroundPattern`:`background`),y=r||rt(d,{tileSize:f,terrain:e.style.map.terrain});p&&(c.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));let b=n.getCrossfadeParameters();for(let t of y){let r=d.getProjectionData({overscaledTileID:t,applyGlobeMatrix:!s,applyTerrainMatrix:!0}),i=p?ur(o,e,p,{tileID:t,tileSize:f},b):lr(o,a),m=e.style.map.terrain&&e.style.map.terrain.getTerrainData(t),y=u.getMeshFromTileID(c,t.canonical,!1,!0,`raster`);v.draw(c,l.TRIANGLES,g,h,_,W.backCCW,i,m,r,n.id,y.vertexBuffer,y.indexBuffer,y.segments)}}(e,0,r,i,a):t.cm(r)&&function(e,t,n,r){let{isRenderingGlobe:i}=r,a=e.context,o=n.implementation,s=e.style.projection,c=e.transform,l=c.getProjectionDataForCustomLayer(i),u={farZ:c.farZ,nearZ:c.nearZ,fov:c.fov*Math.PI/180,modelViewProjectionMatrix:c.modelViewProjectionMatrix,projectionMatrix:c.projectionMatrix,shaderData:{variantName:s.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${s.shaderPreludeCode.vertexSource}`,define:s.shaderDefine},defaultProjectionData:l},d=o.renderingMode?o.renderingMode:`2d`;if(e.renderPass===`offscreen`){let t=o.prerender;t&&(e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),t.call(o,a.gl,u),a.setDirty(),e.setBaseState())}else if(e.renderPass===`translucent`){e.setCustomLayerDefaults(),a.setColorMode(e.colorModeForRenderPass()),a.setStencilMode(K.disabled);let t=d===`3d`?e.getDepthModeFor3D():e.getDepthModeForSublayer(0,G.ReadOnly);a.setDepthMode(t),o.render(a.gl,u),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(null)}}(e,0,r,a))}saveTileTexture(e){let t=this._tileTextures[e.size[0]];t?t.push(e):this._tileTextures[e.size[0]]=[e]}getTileTexture(e){let t=this._tileTextures[e];return t&&t.length>0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;let t=this.imageManager.getPattern(e.from.toString()),n=this.imageManager.getPattern(e.to.toString());return!t||!n}useProgram(e,t,n=!1,r=[]){this.cache=this.cache||{};let i=!!this.style.map.terrain,a=this.style.projection,o=n?At.projectionMercator:a.shaderPreludeCode,s=n?Pt:a.shaderDefine,c=e+(t?t.cacheKey:``)+`/${n?U:a.shaderVariantName}`+(this._showOverdrawInspector?`/overdraw`:``)+(i?`/terrain`:``)+(r?`/${r.join(`/`)}`:``);return this.cache[c]||(this.cache[c]=new Fn(this.context,At[e],t,fr[e],this._showOverdrawInspector,i,o,s,r)),this.cache[c]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){let e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas??(this.debugOverlayCanvas=document.createElement(`canvas`),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Ni(e,t){let n,r=!1,i=null,a=null,o=()=>{i=null,r&&=(e.apply(a,n),i=setTimeout(o,t),!1)};return(...e)=>(r=!0,a=this,n=e,i||o(),i)}class Pi{constructor(e){this._getCurrentHash=()=>{let e=window.location.hash.replace(`#`,``);if(this._hashName){let t;return e.split(`&`).map((e=>e.split(`=`))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||``).split(`/`)}return e.split(`/`)},this._onHashChange=()=>{let e=this._getCurrentHash();if(!this._isValidHash(e))return!1;let t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{let e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{let e=this._getCurrentHash();if(e.length===0)return;let t=e.join(`/`),n=t;n.split(`&`).length>0&&(n=n.split(`&`)[0]),this._hashName&&(n=`${this._hashName}=${t}`);let r=window.location.hash.replace(n,``);r.startsWith(`#&`)?r=r.slice(0,1)+r.slice(2):r===`#`&&(r=``);let i=window.location.href.replace(/(#.+)?$/,r);i=i.replace(`&&`,`&`),window.history.replaceState(window.history.state,null,i)},this._updateHash=Ni(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener(`hashchange`,this._onHashChange,!1),this._map.on(`moveend`,this._updateHash),this}remove(){return removeEventListener(`hashchange`,this._onHashChange,!1),this._map.off(`moveend`,this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){let t=this._map.getCenter(),n=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),i=Math.round(t.lng*r)/r,a=Math.round(t.lat*r)/r,o=this._map.getBearing(),s=this._map.getPitch(),c=``;if(c+=e?`/${i}/${a}/${n}`:`${n}/${a}/${i}`,(o||s)&&(c+=`/`+Math.round(10*o)/10),s&&(c+=`/${Math.round(s)}`),this._hashName){let e=this._hashName,t=!1,n=window.location.hash.slice(1).split(`&`).map((n=>{let r=n.split(`=`)[0];return r===e?(t=!0,`${r}=${c}`):n})).filter((e=>e));return t||n.push(`${e}=${c}`),`#${n.join(`&`)}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.aa(+e[2],+e[1])}catch{return!1}let n=+e[0],r=+(e[3]||0),i=+(e[4]||0);return n>=this._map.getMinZoom()&&n<=this._map.getMaxZoom()&&r>=-180&&r<=180&&i>=this._map.getMinPitch()&&i<=this._map.getMaxPitch()}}let Fi={linearity:.3,easing:t.cn(0,0,.3,1)},Ii=t.e({deceleration:2500,maxSpeed:1400},Fi),Li=t.e({deceleration:20,maxSpeed:1400},Fi),Ri=t.e({deceleration:1e3,maxSpeed:360},Fi),zi=t.e({deceleration:1e3,maxSpeed:90},Fi),Bi=t.e({deceleration:1e3,maxSpeed:360},Fi);class Vi{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:o.now(),settings:e})}_drainInertiaBuffer(){let e=this._inertiaBuffer,t=o.now();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let n={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,n.roll+=e.rollDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);let r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){let a=Ui(n.pan.mag(),r,t.e({},Ii,e||{})),o=n.pan.mult(a.amount/n.pan.mag()),s=this._map.cameraHelper.handlePanInertia(o,this._map.transform);i.center=s.easingCenter,i.offset=s.easingOffset,Hi(i,a)}if(n.zoom){let e=Ui(n.zoom,r,Li);i.zoom=this._map.transform.zoom+e.amount,Hi(i,e)}if(n.bearing){let e=Ui(n.bearing,r,Ri);i.bearing=this._map.transform.bearing+t.L(e.amount,-179,179),Hi(i,e)}if(n.pitch){let e=Ui(n.pitch,r,zi);i.pitch=this._map.transform.pitch+e.amount,Hi(i,e)}if(n.roll){let e=Ui(n.roll,r,Bi);i.roll=this._map.transform.roll+t.L(e.amount,-179,179),Hi(i,e)}if(i.zoom||i.bearing){let e=n.pinchAround===void 0?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(i,{noMoveStart:!0})}}function Hi(e,t){(!e.duration||e.duration<t.duration)&&(e.duration=t.duration,e.easing=t.easing)}function Ui(e,n,r){let{maxSpeed:i,linearity:a,deceleration:o}=r,s=t.L(e*a/(n/1e3),-i,i),c=Math.abs(s)/(o*a);return{easing:r.easing,duration:1e3*c,amount:c/2*s}}class Wi extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r,i={}){r=r instanceof MouseEvent?r:new MouseEvent(e,r);let a=s.mousePos(n.getCanvas(),r,n.getScale()),o=n.unproject(a);super(e,t.e({point:a,lngLat:o,originalEvent:r},i)),this._defaultPrevented=!1,this.target=n}}class Gi extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,n,r){let i=e===`touchend`?r.changedTouches:r.touches,a=s.touchPos(n.getCanvasContainer(),i,n.getScale()),o=a.map((e=>n.unproject(e))),c=a.reduce(((e,t,n,r)=>e.add(t.div(r.length))),new t.P(0,0));super(e,{points:a,point:c,lngLats:o,lngLat:n.unproject(c),originalEvent:r}),this._defaultPrevented=!1}}class Ki extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class qi{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new Ki(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Wi(e.type,this._map,e))}mouseup(e){this._map.fire(new Wi(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Wi(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Wi(e.type,this._map,e))}mouseover(e){this._map.fire(new Wi(e.type,this._map,e))}mouseout(e){this._map.fire(new Wi(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Gi(e.type,this._map,e))}touchmove(e){this._map.fire(new Gi(e.type,this._map,e))}touchend(e){this._map.fire(new Gi(e.type,this._map,e))}touchcancel(e){this._map.fire(new Gi(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ji{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Wi(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Wi(`contextmenu`,this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Wi(e.type,this._map,e)),this._map.listens(`contextmenu`)&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class J{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class Yi{constructor(e,t){this._map=e,this._tr=new J(e),this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&e.button===0&&(s.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;let n=t;if(this._lastPos.equals(n)||!this._box&&n.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=n,this._box||(this._box=s.create(`div`,`maplibregl-boxzoom`,this._container),this._container.classList.add(`maplibregl-crosshair`),this._fireEvent(`boxzoomstart`,e));let i=Math.min(r.x,n.x),a=Math.max(r.x,n.x),o=Math.min(r.y,n.y),c=Math.max(r.y,n.y);s.setTransform(this._box,`translate(${i}px,${o}px)`),this._box.style.width=a-i+`px`,this._box.style.height=c-o+`px`}mouseupWindow(e,n){if(!this._active||e.button!==0)return;let r=this._startPos,i=n;if(this.reset(),s.suppressClick(),r.x!==i.x||r.y!==i.y)return this._map.fire(new t.l(`boxzoomend`,{originalEvent:e})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._tr.bearing,{linear:!0})};this._fireEvent(`boxzoomcancel`,e)}keydown(e){this._active&&e.keyCode===27&&(this.reset(),this._fireEvent(`boxzoomcancel`,e))}reset(){this._active=!1,this._container.classList.remove(`maplibregl-crosshair`),this._box&&=(s.remove(this._box),null),s.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,n){return this._map.fire(new t.l(e,{originalEvent:n}))}}function Xi(e,t){if(e.length!==t.length)throw Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);let n={};for(let r=0;r<e.length;r++)n[e[r].identifier]=t[r];return n}class Zi{constructor(e){this.reset(),this.numTouches=e.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(e,n,r){(this.centroid||r.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){let n=new t.P(0,0);for(let t of e)n._add(t);return n.div(e.length)}(n),this.touches=Xi(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;let r=Xi(n,t);for(let e in this.touches){let t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),n.length===0){let e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class Qi{constructor(e){this.singleTap=new Zi(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){let r=this.singleTap.touchend(e,t,n);if(r){let t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class $i{constructor(e){this._tr=new J(e),this._zoomIn=new Qi({numTouches:1,numTaps:2}),this._zoomOut=new Qi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){let r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n),a=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom+1,around:a.unproject(r)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:a.zoom-1,around:a.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ea{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){let t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;let n=this._lastPoint;if(!n)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);let r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(n)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(n,r))}dragEnd(e){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(e)&&(this._moved&&s.suppressClick(),this.reset(e))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let ta={0:1,2:2};class na{constructor(e){this._correctEvent=e.checkCorrectEvent}startMove(e){this._eventButton=s.mouseButton(e)}endMove(e){delete this._eventButton}isValidStartEvent(e){return this._correctEvent(e)}isValidMoveEvent(e){return!function(e,t){let n=ta[t];return e.buttons===void 0||(e.buttons&n)!==n}(e,this._eventButton)}isValidEndEvent(e){return s.mouseButton(e)===this._eventButton}}class ra{constructor(){this._firstTouch=void 0}_isOneFingerTouch(e){return e.targetTouches.length===1}_isSameTouchEvent(e){return e.targetTouches[0].identifier===this._firstTouch}startMove(e){this._firstTouch=e.targetTouches[0].identifier}endMove(e){delete this._firstTouch}isValidStartEvent(e){return this._isOneFingerTouch(e)}isValidMoveEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}isValidEndEvent(e){return this._isOneFingerTouch(e)&&this._isSameTouchEvent(e)}}class ia{constructor(e=new na({checkCorrectEvent:()=>!0}),t=new ra){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,n){return e instanceof MouseEvent?t(e):typeof TouchEvent<`u`&&e instanceof TouchEvent?n(e):void 0}startMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.startMove(e)),(e=>this.oneFingerTouchMoveStateManager.startMove(e)))}endMove(e){this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.endMove(e)),(e=>this.oneFingerTouchMoveStateManager.endMove(e)))}isValidStartEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidStartEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e)))}isValidMoveEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidMoveEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e)))}isValidEndEvent(e){return this._executeRelevantHandler(e,(e=>this.mouseMoveStateManager.isValidEndEvent(e)),(e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e)))}}let aa=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class oa{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,n){return this._calculateTransform(e,t,n)}touchmove(e,t,n){if(this._active){if(!this._shouldBePrevented(n.length))return e.preventDefault(),this._calculateTransform(e,t,n);this._map.cooperativeGestures.notifyGestureBlocked(`touch_pan`,e)}}touchend(e,t,n){this._calculateTransform(e,t,n),this._active&&this._shouldBePrevented(n.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,n,r){r.length>0&&(this._active=!0);let i=Xi(r,n),a=new t.P(0,0),o=new t.P(0,0),s=0;for(let e in i){let t=i[e],n=this._touches[e];n&&(a._add(t),o._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,this._shouldBePrevented(s)||!o.mag())return;let c=o.div(s);return this._sum._add(c),this._sum.mag()<this._clickTolerance?void 0:{around:a.div(s),panDelta:c}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class sa{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){if(!this._firstTwoTouches)return;e.preventDefault();let[r,i]=this._firstTwoTouches,a=Y(n,t,r),o=Y(n,t,i);if(!a||!o)return;let s=this._aroundCenter?null:a.add(o).div(2);return this._move([a,o],s,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;let[r,i]=this._firstTwoTouches,a=Y(n,t,r),o=Y(n,t,i);a&&o||(this._active&&s.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Y(e,t,n){for(let r=0;r<e.length;r++)if(e[r].identifier===n)return t[r]}function ca(e,t){return Math.log(e/t)/Math.LN2}class la extends sa{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(e){this._startDistance=this._distance=e[0].dist(e[1])}_move(e,t){let n=this._distance;if(this._distance=e[0].dist(e[1]),this._active||!(Math.abs(ca(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:ca(this._distance,n),pinchAround:t}}}function ua(e,t){return 180*e.angleWith(t)/Math.PI}class da extends sa{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(e){this._startVector=this._vector=e[0].sub(e[1]),this._minDiameter=e[0].dist(e[1])}_move(e,t,n){let r=this._vector;if(this._vector=e[0].sub(e[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:ua(this._vector,r),pinchAround:t}}_isBelowThreshold(e){this._minDiameter=Math.min(this._minDiameter,e.mag());let t=25/(Math.PI*this._minDiameter)*360,n=ua(e,this._startVector);return Math.abs(n)<t}}function fa(e){return Math.abs(e.y)>Math.abs(e.x)}class pa extends sa{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,n){super.touchstart(e,t,n),this._currentTouchCount=n.length}_start(e){this._lastPoints=e,fa(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,n){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=e[0].sub(this._lastPoints[0]),i=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,i,n.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+i.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,n){if(this._valid!==void 0)return this._valid;let r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return this._firstMove===void 0&&(this._firstMove=n),n-this._firstMove<100&&void 0;let a=e.y>0==t.y>0;return fa(e)&&fa(t)&&a}}let X={panStep:100,bearingStep:15,pitchStep:10};class ma{constructor(e){this._tr=new J(e);let t=X;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,a=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),a=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),a=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:o=>{let s=this._tr;o.easeTo({duration:300,easeId:`keyboardHandler`,easing:ha,zoom:t?Math.round(s.zoom)+t*(e.shiftKey?2:1):s.zoom,bearing:s.bearing+n*this._bearingStep,pitch:s.pitch+r*this._pitchStep,offset:[-i*this._panStep,-a*this._panStep],center:s.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function ha(e){return e*(2-e)}let ga=4.000244140625;class _a{constructor(e,t){this._onTimeout=e=>{this._type=`wheel`,this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new J(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&e.around===`center`)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked(`wheel_zoom`,e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY,n=o.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,t!==0&&t%ga==0?this._type=`wheel`:t!==0&&Math.abs(t)<4?this._type=`trackpad`:r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?`trackpad`:`wheel`,this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&=null,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);let n=s.mousePos(this._map.getCanvas(),e,this._map.getScale()),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.aa.convert(r.center)):n,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let e=this._tr.transform;if(typeof this._lastExpectedZoom==`number`){let t=e.zoom-this._lastExpectedZoom;typeof this._startZoom==`number`&&(this._startZoom+=t),typeof this._targetZoom==`number`&&(this._targetZoom+=t)}if(this._delta!==0){let n=this._type===`wheel`&&Math.abs(this._delta)>ga?this._wheelZoomRate:this._defaultZoomRate,r=2/(1+Math.exp(-Math.abs(this._delta*n)));this._delta<0&&r!==0&&(r=1/r);let i=typeof this._targetZoom==`number`?t.aw(this._targetZoom):e.scale;this._targetZoom=e.getConstrained(e.getCameraLngLat(),t.az(i*r)).zoom,this._type===`wheel`&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let n=typeof this._targetZoom==`number`?this._targetZoom:e.zoom,r=this._startZoom,i=this._easing,a,s=!1;if(this._type===`wheel`&&r&&i){let e=o.now()-this._lastWheelEventTime,c=Math.min((e+5)/200,1),l=i(c);a=t.C.number(r,n,l),c<1?this._frameId||=!0:s=!0}else a=n,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=a,{noInertia:!0,needsRenderFrame:!s,zoomDelta:a-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let n=t.cp;if(this._prevEase){let e=this._prevEase,r=(o.now()-e.start)/e.duration,i=e.easing(r+.01)-e.easing(r),a=.27/Math.sqrt(i*i+1e-4)*.01,s=Math.sqrt(.0729-a*a);n=t.cn(a,s,.25,1)}return this._prevEase={start:o.now(),duration:e,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class va{constructor(e,t){this._clickZoom=e,this._tapZoom=t}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 ya{constructor(e){this._tr=new J(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ba{constructor(){this._tap=new Qi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,n){if(!this._swipePoint)if(this._tapTime){let r=t[0],i=e.timeStamp-this._tapTime<500,a=this._tapPoint.dist(r)<30;i&&a?n.length>0&&(this._swipePoint=r,this._swipeTouch=n[0].identifier):this.reset()}else this._tap.touchstart(e,t,n)}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;let r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){if(this._tapTime)this._swipePoint&&n.length===0&&this.reset();else{let r=this._tap.touchend(e,t,n);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class xa{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add(`maplibregl-touch-drag-pan`)}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove(`maplibregl-touch-drag-pan`)}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Sa{constructor(e,t,n,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=n,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Ca{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add(`maplibregl-touch-zoom-rotate`)}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove(`maplibregl-touch-zoom-rotate`)}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class wa{constructor(e,t){this._bypassKey=navigator.userAgent.indexOf(`Mac`)===-1?`ctrlKey`:`metaKey`,this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let e=this._map.getCanvasContainer();e.classList.add(`maplibregl-cooperative-gestures`),this._container=s.create(`div`,`maplibregl-cooperative-gesture-screen`,e);let t=this._map._getUIString(`CooperativeGesturesHandler.WindowsHelpText`);this._bypassKey===`metaKey`&&(t=this._map._getUIString(`CooperativeGesturesHandler.MacHelpText`));let n=this._map._getUIString(`CooperativeGesturesHandler.MobileHelpText`),r=document.createElement(`div`);r.className=`maplibregl-desktop-message`,r.textContent=t,this._container.appendChild(r);let i=document.createElement(`div`);i.className=`maplibregl-mobile-message`,i.textContent=n,this._container.appendChild(i),this._container.setAttribute(`aria-hidden`,`true`)}_destroyUI(){this._container&&(s.remove(this._container),this._map.getCanvasContainer().classList.remove(`maplibregl-cooperative-gestures`)),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,n){this._enabled&&(this._map.fire(new t.l(`cooperativegestureprevented`,{gestureType:e,originalEvent:n})),this._container.classList.add(`maplibregl-show`),setTimeout((()=>{this._container.classList.remove(`maplibregl-show`)}),100))}}let Ta=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Ea extends t.l{}function Da(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Oa{constructor(e,n){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,n)=>{if(e.type===`blur`)return void this.stop(!0);this._updatingCamera=!0;let r=e.type===`renderFrame`?void 0:e,i={needsRenderFrame:!1},a={},o={};for(let{handlerName:c,handler:l,allowed:u}of this._handlers){if(!l.isEnabled())continue;let d;if(this._blockedByActive(o,u,c))l.reset();else if(l[n||e.type]){if(t.cq(e,n||e.type)){let t=s.mousePos(this._map.getCanvas(),e,this._map.getScale());d=l[n||e.type](e,t)}else if(t.cr(e,n||e.type)){let t=this._getMapTouches(e.touches),r=s.touchPos(this._map.getCanvas(),t,this._map.getScale());d=l[n||e.type](e,r,t)}else t.cs(n||e.type)||(d=l[n||e.type](e));this.mergeHandlerResult(i,a,d,c,r),d&&d.needsRenderFrame&&this._triggerRenderFrame()}(d||l.isActive())&&(o[c]=l)}let c={};for(let e in this._previousActiveHandlers)o[e]||(c[e]=r);this._previousActiveHandlers=o,(Object.keys(c).length||Da(i))&&(this._changes.push([i,a,c]),this._triggerRenderFrame()),(Object.keys(o).length||Da(i))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:l}=i;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Vi(e),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);let r=this._el;this._listeners=[[r,`touchstart`,{passive:!0}],[r,`touchmove`,{passive:!1}],[r,`touchend`,void 0],[r,`touchcancel`,void 0],[r,`mousedown`,void 0],[r,`mousemove`,void 0],[r,`mouseup`,void 0],[document,`mousemove`,{capture:!0}],[document,`mouseup`,void 0],[r,`mouseover`,void 0],[r,`mouseout`,void 0],[r,`dblclick`,void 0],[r,`click`,void 0],[r,`keydown`,{capture:!1}],[r,`keyup`,void 0],[r,`wheel`,{passive:!1}],[r,`contextmenu`,void 0],[window,`blur`,void 0]];for(let[e,t,n]of this._listeners)s.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(let[e,t,n]of this._listeners)s.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(e){let n=this._map,r=n.getCanvasContainer();this._add(`mapEvent`,new qi(n,e));let i=n.boxZoom=new Yi(n,e);this._add(`boxZoom`,i),e.interactive&&e.boxZoom&&i.enable();let a=n.cooperativeGestures=new wa(n,e.cooperativeGestures);this._add(`cooperativeGestures`,a),e.cooperativeGestures&&a.enable();let o=new $i(n),c=new ya(n);n.doubleClickZoom=new va(c,o),this._add(`tapZoom`,o),this._add(`clickZoom`,c),e.interactive&&e.doubleClickZoom&&n.doubleClickZoom.enable();let l=new ba;this._add(`tapDragZoom`,l);let u=n.touchPitch=new pa(n);this._add(`touchPitch`,u),e.interactive&&e.touchPitch&&n.touchPitch.enable(e.touchPitch);let d=()=>n.project(n.getCenter()),f=function({enable:e,clickTolerance:n,aroundCenter:r=!0,minPixelCenterThreshold:i=100,rotateDegreesPerPixelMoved:a=.8},o){return new ea({clickTolerance:n,move:(e,n)=>{let s=o();if(r&&Math.abs(s.y-e.y)>i)return{bearingDelta:t.co(new t.P(e.x,n.y),n,s)};let c=(n.x-e.x)*a;return r&&n.y<s.y&&(c=-c),{bearingDelta:c}},moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===0&&e.ctrlKey||s.mouseButton(e)===2&&!e.ctrlKey}),enable:e,assignEvents:aa})}(e,d),p=function({enable:e,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5}){return new ea({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*n}),moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===0&&e.ctrlKey||s.mouseButton(e)===2}),enable:e,assignEvents:aa})}(e),m=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:n=.3},r){return new ea({clickTolerance:t,move:(e,t)=>{let i=r(),a=(t.x-e.x)*n;return t.y<i.y&&(a=-a),{rollDelta:a}},moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===2&&e.ctrlKey}),enable:e,assignEvents:aa})}(e,d);n.dragRotate=new Sa(e,f,p,m),this._add(`mouseRotate`,f,[`mousePitch`]),this._add(`mousePitch`,p,[`mouseRotate`,`mouseRoll`]),this._add(`mouseRoll`,m,[`mousePitch`]),e.interactive&&e.dragRotate&&n.dragRotate.enable();let h=function({enable:e,clickTolerance:t}){return new ea({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:new na({checkCorrectEvent:e=>s.mouseButton(e)===0&&!e.ctrlKey}),enable:e,assignEvents:aa})}(e),g=new oa(e,n);n.dragPan=new xa(r,h,g),this._add(`mousePan`,h),this._add(`touchPan`,g,[`touchZoom`,`touchRotate`]),e.interactive&&e.dragPan&&n.dragPan.enable(e.dragPan);let _=new da,v=new la;n.touchZoomRotate=new Ca(r,v,_,l),this._add(`touchRotate`,_,[`touchPan`,`touchZoom`]),this._add(`touchZoom`,v,[`touchPan`,`touchRotate`]),e.interactive&&e.touchZoomRotate&&n.touchZoomRotate.enable(e.touchZoomRotate);let y=n.scrollZoom=new _a(n,(()=>this._triggerRenderFrame()));this._add(`scrollZoom`,y,[`mousePan`]),e.interactive&&e.scrollZoom&&n.scrollZoom.enable(e.scrollZoom);let b=n.keyboard=new ma(n);this._add(`keyboard`,b),e.interactive&&e.keyboard&&n.keyboard.enable(),this._add(`blockableMapEvent`,new Ji(n))}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(let{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(let{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Ta(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,n){for(let r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}_getMapTouches(e){let t=[];for(let n of e)this._el.contains(n.target)&&t.push(n);return t}mergeHandlerResult(e,n,r,i,a){if(!r)return;t.e(e,r);let o={handlerName:i,originalEvent:r.originalEvent||a};r.zoomDelta!==void 0&&(n.zoom=o),r.panDelta!==void 0&&(n.drag=o),r.rollDelta!==void 0&&(n.roll=o),r.pitchDelta!==void 0&&(n.pitch=o),r.bearingDelta!==void 0&&(n.rotate=o)}_applyChanges(){let e={},n={},r={};for(let[i,a,o]of this._changes)i.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(i.panDelta)),i.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+i.pitchDelta),i.rollDelta&&(e.rollDelta=(e.rollDelta||0)+i.rollDelta),i.around!==void 0&&(e.around=i.around),i.pinchAround!==void 0&&(e.pinchAround=i.pinchAround),i.noInertia&&(e.noInertia=i.noInertia),t.e(n,a),t.e(r,o);this._updateMapTransform(e,n,r),this._changes=[]}_updateMapTransform(e,t,n){let r=this._map,i=r._getTransformForUpdate(),a=r.terrain;if(!(Da(e)||a&&this._terrainMovement))return this._fireEvents(t,n,!0);r._stop(!0);let{panDelta:o,zoomDelta:s,bearingDelta:c,pitchDelta:l,rollDelta:u,around:d,pinchAround:f}=e;f!==void 0&&(d=f),d||=r.transform.centerPoint,a&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let p={panDelta:o,zoomDelta:s,rollDelta:u,pitchDelta:l,bearingDelta:c,around:d};this._map.cameraHelper.useGlobeControls&&!i.isPointOnMapSurface(d)&&(d=i.centerPoint);let m=d.distSqr(i.centerPoint)<.01?i.center:i.screenPointToLocation(o?d.sub(o):d);a?(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,i),this._terrainMovement||!t.drag&&!t.zoom?t.drag&&this._terrainMovement?i.setCenter(i.screenPointToLocation(i.centerPoint.sub(o))):this._map.cameraHelper.handleMapControlsPan(p,i,m):(this._terrainMovement=!0,this._map._elevationFreeze=!0,this._map.cameraHelper.handleMapControlsPan(p,i,m))):(this._map.cameraHelper.handleMapControlsRollPitchBearingZoom(p,i),this._map.cameraHelper.handleMapControlsPan(p,i,m)),r._applyUpdatedTransform(i),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,n,!0)}_fireEvents(e,n,r){let i=Ta(this._eventsInProgress),a=Ta(e),s={};for(let t in e){let{originalEvent:n}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=n),this._eventsInProgress[t]=e[t]}!i&&a&&this._fireEvent(`movestart`,a.originalEvent);for(let e in s)this._fireEvent(e,s[e]);a&&this._fireEvent(`move`,a.originalEvent);for(let t in e){let{originalEvent:n}=e[t];this._fireEvent(t,n)}let c={},l;for(let e in this._eventsInProgress){let{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,c[`${e}end`]=l)}for(let e in c)this._fireEvent(e,c[e]);let u=Ta(this._eventsInProgress),d=(i||a)&&!u;if(d&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(r&&d){this._updatingCamera=!0;let e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>e!==0&&-this._bearingSnap<e&&e<this._bearingSnap;!e||!e.essential&&o.prefersReducedMotion?(this._map.fire(new t.l(`moveend`,{originalEvent:l})),n(this._map.getBearing())&&this._map.resetNorth()):(n(e.bearing||this._map.getBearing())&&(e.bearing=0),e.freezeElevation=!0,this._map.easeTo(e,{originalEvent:l})),this._updatingCamera=!1}}_fireEvent(e,n){this._map.fire(new t.l(e,n?{originalEvent:n}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((e=>{delete this._frameId,this.handleEvent(new Ea(`renderFrame`,{timeStamp:e})),this._applyChanges()}))}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class ka extends t.E{constructor(e,t,n){super(),this._renderFrameCallback=()=>{let e=Math.min((o.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=n.bearingSnap,this.cameraHelper=t,this.on(`moveend`,(()=>{delete this._requestedCameraState}))}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.aa(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,n,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},n),r)}panTo(e,n,r){return this.easeTo(t.e({center:e},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,n,r){return this.easeTo(t.e({zoom:e},n),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,n){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l(`movestart`,n)).fire(new t.l(`move`,n)).fire(new t.l(`moveend`,n))),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(e,n,r){return this.easeTo(t.e({bearing:e},n),r)}resetNorth(e,n){return this.rotateTo(0,t.e({duration:1e3},e),n),this}resetNorthPitch(e,n){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(e,t):this}getPitch(){return this.transform.pitch}setPitch(e,t){return this.jumpTo({pitch:e},t),this}getRoll(){return this.transform.roll}setRoll(e,t){return this.jumpTo({roll:e},t),this}cameraForBounds(e,t){e=I.convert(e).adjustAntiMeridian();let n=t&&t.bearing||0;return this._cameraForBoxAndBearing(e.getNorthWest(),e.getSouthEast(),n,t)}_cameraForBoxAndBearing(e,n,r,i){let a={top:0,bottom:0,right:0,left:0};if(typeof(i=t.e({padding:a,offset:[0,0],maxZoom:this.transform.maxZoom},i)).padding==`number`){let e=i.padding;i.padding={top:e,bottom:e,right:e,left:e}}let o=t.e(a,i.padding);i.padding=o;let s=this.transform,c=new I(e,n);return this.cameraHelper.cameraForBoxAndBearing(i,o,c,r,s)}fitBounds(e,t,n){return this._fitInternal(this.cameraForBounds(e,t),t,n)}fitScreenCoordinates(e,n,r,i,a){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(t.P.convert(e)),this.transform.screenPointToLocation(t.P.convert(n)),r,i),i,a)}_fitInternal(e,n,r){return e?(delete(n=t.e(e,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(e,n){this.stop();let r=this._getTransformForUpdate(),i=!1,a=!1,o=!1,s=r.zoom;this.cameraHelper.handleJumpToCenterZoom(r,e);let c=r.zoom!==s;return`elevation`in e&&r.elevation!==+e.elevation&&r.setElevation(+e.elevation),`bearing`in e&&r.bearing!==+e.bearing&&(i=!0,r.setBearing(+e.bearing)),`pitch`in e&&r.pitch!==+e.pitch&&(a=!0,r.setPitch(+e.pitch)),`roll`in e&&r.roll!==+e.roll&&(o=!0,r.setRoll(+e.roll)),e.padding==null||r.isPaddingEqual(e.padding)||r.setPadding(e.padding),this._applyUpdatedTransform(r),this.fire(new t.l(`movestart`,n)).fire(new t.l(`move`,n)),c&&this.fire(new t.l(`zoomstart`,n)).fire(new t.l(`zoom`,n)).fire(new t.l(`zoomend`,n)),i&&this.fire(new t.l(`rotatestart`,n)).fire(new t.l(`rotate`,n)).fire(new t.l(`rotateend`,n)),a&&this.fire(new t.l(`pitchstart`,n)).fire(new t.l(`pitch`,n)).fire(new t.l(`pitchend`,n)),o&&this.fire(new t.l(`rollstart`,n)).fire(new t.l(`roll`,n)).fire(new t.l(`rollend`,n)),this.fire(new t.l(`moveend`,n))}calculateCameraOptionsFromTo(e,n,r,i=0){let a=t.aj.fromLngLat(e,n),o=t.aj.fromLngLat(r,i),s=o.x-a.x,c=o.y-a.y,l=o.z-a.z,u=Math.hypot(s,c,l);if(u===0)throw Error(`Can't calculate camera options with same From and To`);let d=Math.hypot(s,c),f=t.az(this.transform.cameraToCenterDistance/u/this.transform.tileSize),p=180*Math.atan2(s,-c)/Math.PI,m=180*Math.acos(d/u)/Math.PI;return m=l<0?90-m:90+m,{center:o.toLngLat(),elevation:i,zoom:f,pitch:m,bearing:p}}calculateCameraOptionsFromCameraLngLatAltRotation(e,t,n,r,i){let a=this.transform.calculateCenterFromCameraLngLatAlt(e,t,n,r);return{center:a.center,elevation:a.elevation,zoom:a.zoom,bearing:n,pitch:r,roll:i}}easeTo(e,n){this._stop(!1,e.easeId),(!1===(e=t.e({offset:[0,0],duration:500,easing:t.cp},e)).animate||!e.essential&&o.prefersReducedMotion)&&(e.duration=0);let r=this._getTransformForUpdate(),i=this.getBearing(),a=r.pitch,s=r.roll,c=`bearing`in e?this._normalizeBearing(e.bearing,i):i,l=`pitch`in e?+e.pitch:a,u=`roll`in e?this._normalizeBearing(e.roll,s):s,d=`padding`in e?e.padding:r.padding,f=t.P.convert(e.offset),p,m;e.around&&(p=t.aa.convert(e.around),m=r.locationToScreenPoint(p));let h={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},g=this.cameraHelper.handleEaseTo(r,{bearing:c,pitch:l,roll:u,padding:d,around:p,aroundPoint:m,offsetAsPoint:f,offset:e.offset,zoom:e.zoom,center:e.center});return this._rotating=this._rotating||i!==c,this._pitching=this._pitching||l!==a,this._rolling=this._rolling||u!==s,this._padding=!r.isPaddingEqual(d),this._zooming=this._zooming||g.isZooming,this._easeId=e.easeId,this._prepareEase(n,e.noMoveStart,h),this.terrain&&this._prepareElevation(g.elevationCenter),this._ease((t=>{g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n,t)}),e),this}_prepareEase(e,n,r={}){this._moving=!0,n||r.moving||this.fire(new t.l(`movestart`,e)),this._zooming&&!r.zooming&&this.fire(new t.l(`zoomstart`,e)),this._rotating&&!r.rotating&&this.fire(new t.l(`rotatestart`,e)),this._pitching&&!r.pitching&&this.fire(new t.l(`pitchstart`,e)),this._rolling&&!r.rolling&&this.fire(new t.l(`rollstart`,e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){this._elevationStart!==void 0&&this._elevationCenter!==void 0||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&n!==this._elevationTarget){let t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(n-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=n}this.transform.setElevation(t.C.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};let t=e.getCameraLngLat(),n=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(n<r){let n=this.calculateCameraOptionsFromTo(t,r,e.center,e.elevation);return{pitch:n.pitch,zoom:n.zoom}}return{}}_applyUpdatedTransform(e){let t=[];if(t.push((e=>this._elevateCameraIfInsideTerrain(e))),this.transformCameraUpdate&&t.push((e=>this.transformCameraUpdate(e))),!t.length)return;let n=e.clone();for(let e of t){let t=n.clone(),{center:r,zoom:i,roll:a,pitch:o,bearing:s,elevation:c}=e(t);r&&t.setCenter(r),c!==void 0&&t.setElevation(c),i!==void 0&&t.setZoom(i),a!==void 0&&t.setRoll(a),o!==void 0&&t.setPitch(o),s!==void 0&&t.setBearing(s),n.apply(t)}this.transform.apply(n)}_fireMoveEvents(e){this.fire(new t.l(`move`,e)),this._zooming&&this.fire(new t.l(`zoom`,e)),this._rotating&&this.fire(new t.l(`rotate`,e)),this._pitching&&this.fire(new t.l(`pitch`,e)),this._rolling&&this.fire(new t.l(`roll`,e))}_afterEase(e,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;let r=this._zooming,i=this._rotating,a=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l(`zoomend`,e)),i&&this.fire(new t.l(`rotateend`,e)),a&&this.fire(new t.l(`pitchend`,e)),o&&this.fire(new t.l(`rollend`,e)),this.fire(new t.l(`moveend`,e))}flyTo(e,n){if(!e.essential&&o.prefersReducedMotion){let r=t.a9(e,[`center`,`zoom`,`bearing`,`pitch`,`roll`,`elevation`]);return this.jumpTo(r,n)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cp},e);let r=this._getTransformForUpdate(),i=r.bearing,a=r.pitch,s=r.roll,c=r.padding,l=`bearing`in e?this._normalizeBearing(e.bearing,i):i,u=`pitch`in e?+e.pitch:a,d=`roll`in e?this._normalizeBearing(e.roll,s):s,f=`padding`in e?e.padding:r.padding,p=t.P.convert(e.offset),m=r.centerPoint.add(p),h=r.screenPointToLocation(m),g=this.cameraHelper.handleFlyTo(r,{bearing:l,pitch:u,roll:d,padding:f,locationAtOffset:h,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom}),_=e.curve,v=Math.max(r.width,r.height),y=v/g.scaleOfZoom,b=g.pixelPathLength;typeof g.scaleOfMinZoom==`number`&&(_=Math.sqrt(v/g.scaleOfMinZoom/b*2));let x=_*_;function S(e){let t=(y*y-v*v+(e?-1:1)*x*x*b*b)/(2*(e?y:v)*x*b);return Math.log(Math.sqrt(t*t+1)-t)}function C(e){return(Math.exp(e)-Math.exp(-e))/2}function w(e){return(Math.exp(e)+Math.exp(-e))/2}let T=S(!1),E=function(e){return w(T)/w(T+_*e)},D=function(e){return v*((w(T)*(C(t=T+_*e)/w(t))-C(T))/x)/b;var t},O=(S(!0)-T)/_;if(Math.abs(b)<2e-6||!isFinite(O)){if(Math.abs(v-y)<1e-6)return this.easeTo(e,n);let t=y<v?-1:1;O=Math.abs(Math.log(y/v))/_,D=()=>0,E=e=>Math.exp(t*_*e)}return e.duration=`duration`in e?+e.duration:1e3*O/(`screenSpeed`in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=i!==l,this._pitching=u!==a,this._rolling=d!==s,this._padding=!r.isPaddingEqual(f),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease((o=>{let h=o*O,_=1/E(h),v=D(h);this._rotating&&r.setBearing(t.C.number(i,l,o)),this._pitching&&r.setPitch(t.C.number(a,u,o)),this._rolling&&r.setRoll(t.C.number(s,d,o)),this._padding&&(r.interpolatePadding(c,f,o),m=r.centerPoint.add(p)),g.easeFunc(o,_,v,m),this.terrain&&!e.freezeElevation&&this._updateElevation(o),this._applyUpdatedTransform(r),this._fireMoveEvents(n)}),(()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(n)}),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var n;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||(n=this.handlers)==null||n.stop(!1),this}_ease(e,t,n){!1===n.animate||n.duration===0?(e(1),t()):(this._easeStart=o.now(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,n){e=t.aO(e,-180,180);let r=Math.abs(e-n);return Math.abs(e-360-n)<r&&(e-=360),Math.abs(e+360-n)<r&&(e+=360),e}queryTerrainElevation(e){return this.terrain?this.terrain.getElevationForLngLatZoom(t.aa.convert(e),this.transform.tileZoom):null}}let Aa={compact:!0,customAttribution:void 0};class ja{constructor(e=Aa){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._updateAttributions()):(this._container.classList.add(`maplibregl-compact-show`),this._container.removeAttribute(`open`)))},this._updateData=e=>{!e||e.sourceDataType!==`metadata`&&e.sourceDataType!==`visibility`&&e.dataType!==`style`&&e.type!==`terrain`||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute(`open`,``):this._container.classList.contains(`maplibregl-compact`)||this._container.classList.contains(`maplibregl-attrib-empty`)||(this._container.setAttribute(`open`,``),this._container.classList.add(`maplibregl-compact`,`maplibregl-compact-show`)):(this._container.setAttribute(`open`,``),this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.remove(`maplibregl-compact`,`maplibregl-compact-show`))},this._updateCompactMinimize=()=>{this._container.classList.contains(`maplibregl-compact`)&&this._container.classList.contains(`maplibregl-compact-show`)&&this._container.classList.remove(`maplibregl-compact-show`),this._updateAttributions()},this._extendAttribution=e=>{e.preventDefault(),this._extended=!0,this._updateAttributions()},this._shrinkAttribution=e=>{e.preventDefault(),this._extended=!1,this._updateAttributions()},this.options=e}getDefaultPosition(){return`bottom-right`}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=s.create(`details`,`maplibregl-ctrl maplibregl-ctrl-attrib`),this._compactButton=s.create(`summary`,`maplibregl-ctrl-attrib-button`,this._container),this._compactButton.addEventListener(`click`,this._toggleAttribution),this._extendButton=s.create(`a`,`maplibregl-attrib-others`),this._extendButton.setAttribute(`href`,`#`),this._extendButton.addEventListener(`click`,this._extendAttribution),this._extendButton.innerHTML=`| Show more`,this._shrinkButton=s.create(`a`,`maplibregl-attrib-others`),this._shrinkButton.setAttribute(`href`,`#`),this._shrinkButton.addEventListener(`click`,this._shrinkAttribution),this._shrinkButton.innerHTML=`| Show less`,this._setElementTitle(this._compactButton,`ToggleAttribution`),this._innerContainer=s.create(`div`,`maplibregl-ctrl-attrib-inner`,this._container),this._updateAttributions(),this._updateCompact(),this._map.on(`styledata`,this._updateData),this._map.on(`sourcedata`,this._updateData),this._map.on(`terrain`,this._updateData),this._map.on(`resize`,this._updateCompact),this._map.on(`drag`,this._updateCompactMinimize),this._container}onRemove(){s.remove(this._container),this._map.off(`styledata`,this._updateData),this._map.off(`sourcedata`,this._updateData),this._map.off(`terrain`,this._updateData),this._map.off(`resize`,this._updateCompact),this._map.off(`drag`,this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._extended=void 0,this._extendButton=void 0,this._shrinkButton=void 0,this._fullAttribHTML=void 0,this._displayedAttribHTML=void 0}_setElementTitle(e,t){let n=this._map._getUIString(`AttributionControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map((e=>typeof e==`string`?e:``))):typeof this.options.customAttribution==`string`&&e.push(this.options.customAttribution)),this._map.style.stylesheet){let e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}let t=this._map.style.sourceCaches;for(let n in t){let r=t[n];if(r.used||r.usedForTerrain){let t=r.getSource();if(typeof t.attribution==`string`){let n=t.attribution.split(`|`).map((e=>e.trim()));for(let t of n)e.indexOf(t)<0&&e.push(t)}}}let n=`<a href="https://mapcreator.io" target="_blank">© Mapcreator</a>`;e.indexOf(n)<0&&e.push(n),e=e.filter((e=>String(e).trim())),e.sort(((e,t)=>e.length-t.length)),e=e.filter(((t,n)=>{for(let r=n+1;r<e.length;r++)if(e[r].indexOf(t)>=0)return!1;return!0}));for(let t of[`OpenStreetMap`,`Mapcreator`]){let n=e.findIndex((e=>e.includes(t)));if(n!==-1&&n!==0){let t=e[n];e.splice(n,1),e.unshift(t)}}let r=e.join(` `),i;i=e.length<=2||this._extended?r:e.slice(0,2).join(` `),r===this._fullAttribHTML&&i===this._displayedAttribHTML||(this._fullAttribHTML=r,this._displayedAttribHTML=i,e.length?(this._innerContainer.innerHTML=s.sanitize(i),e.length>2&&(this._innerContainer.innerHTML+=` `,this._innerContainer.appendChild(this._extended?this._shrinkButton:this._extendButton)),this._container.classList.remove(`maplibregl-attrib-empty`)):this._container.classList.add(`maplibregl-attrib-empty`),this._updateCompact(),this._map.fire(`attributionchange`),this._editLink=null)}}class Ma{constructor(e={}){this._updateCompact=()=>{let e=this._container.children;if(e.length){let t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add(`maplibregl-compact`):t.classList.remove(`maplibregl-compact`)}},this.options=e}getDefaultPosition(){return`bottom-left`}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=s.create(`div`,`maplibregl-ctrl`);let t=s.create(`a`,`maplibregl-ctrl-logo`);return t.target=`_blank`,t.rel=`noopener nofollow`,t.href=`https://maplibre.org/`,t.setAttribute(`aria-label`,this._map._getUIString(`LogoControl.Title`)),t.setAttribute(`rel`,`noopener nofollow`),this._container.appendChild(t),this._container.style.display=`block`,this._map.on(`resize`,this._updateCompact),this._updateCompact(),this._container}onRemove(){s.remove(this._container),this._map.off(`resize`,this._updateCompact),this._map=void 0,this._compact=void 0}}class Na{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){let t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){let t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(let t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw Error(`Attempting to run(), but is already running.`);let t=this._currentlyRunning=this._queue;this._queue=[];for(let n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Pa=t.aJ([{name:`a_pos3d`,type:`Int16`,components:3}]);class Fa extends t.E{constructor(e){super(),this._lastTilesetChange=o.now(),this.sourceCache=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(e,n){this.sourceCache.update(e,n),this._renderableTilesKeys=[];let r={};for(let i of rt(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n,calculateTileZoom:this.sourceCache._source.calculateTileZoom}))r[i.key]=!0,this._renderableTilesKeys.push(i.key),this._tiles[i.key]||(i.terrainRttPosMatrix32f=new Float64Array(16),t.bZ(i.terrainRttPosMatrix32f,0,t.ah,t.ah,0,0,1),this._tiles[i.key]=new qe(i,this.tileSize),this._lastTilesetChange=o.now());for(let e in this._tiles)r[e]||delete this._tiles[e]}freeRtt(e){for(let t in this._tiles){let n=this._tiles[t];(!e||n.tileID.equals(e)||n.tileID.isChildOf(e)||e.isChildOf(n.tileID))&&(n.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((e=>this.getTileByID(e)))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){let n={};for(let r of this._renderableTilesKeys){let i=this._tiles[r].tileID,a=e.clone(),o=t.ba();if(i.canonical.equals(e.canonical))t.bZ(o,0,t.ah,t.ah,0,0,1);else if(i.canonical.isChildOf(e.canonical)){let n=i.canonical.z-e.canonical.z,r=i.canonical.x-(i.canonical.x>>n<<n),a=i.canonical.y-(i.canonical.y>>n<<n),s=t.ah>>n;t.bZ(o,0,s,s,0,0,1),t.a5(o,o,[-r*s,-a*s,0])}else{if(!e.canonical.isChildOf(i.canonical))continue;{let n=e.canonical.z-i.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n),a=e.canonical.y-(e.canonical.y>>n<<n),s=t.ah>>n;t.bZ(o,0,t.ah,t.ah,0,0,1),t.a5(o,o,[r*s,a*s,0]),t.N(o,o,[1/2**n,1/2**n,0])}}a.terrainRttPosMatrix32f=new Float32Array(o),n[r]=a}return n}_getTerrainCoordsForTileRanges(e,n){let r={};for(let i of this._renderableTilesKeys){let a=this._tiles[i].tileID;if(!this._isWithinTileRanges(a,n))continue;let o=e.clone(),s=t.ba();if(a.canonical.z===e.canonical.z){let n=e.canonical.x-a.canonical.x,r=e.canonical.y-a.canonical.y;t.bZ(s,0,t.ah,t.ah,0,0,1),t.a5(s,s,[n*t.ah,r*t.ah,0])}else if(a.canonical.z>e.canonical.z){let n=a.canonical.z-e.canonical.z,r=a.canonical.x-(a.canonical.x>>n<<n),i=a.canonical.y-(a.canonical.y>>n<<n),o=e.canonical.x-(a.canonical.x>>n),c=e.canonical.y-(a.canonical.y>>n),l=t.ah>>n;t.bZ(s,0,l,l,0,0,1),t.a5(s,s,[-r*l+o*t.ah,-i*l+c*t.ah,0])}else{let n=e.canonical.z-a.canonical.z,r=e.canonical.x-(e.canonical.x>>n<<n),i=e.canonical.y-(e.canonical.y>>n<<n),o=(e.canonical.x>>n)-a.canonical.x,c=(e.canonical.y>>n)-a.canonical.y,l=t.ah<<n;t.bZ(s,0,l,l,0,0,1),t.a5(s,s,[r*t.ah+o*l,i*t.ah+c*l,0])}o.terrainRttPosMatrix32f=new Float32Array(s),r[i]=o}return r}getSourceTile(e,t){let n=this.sourceCache._source,r=e.overscaledZ-this.deltaZoom;if(r>n.maxzoom&&(r=n.maxzoom),r<n.minzoom)return null;this._sourceTileCache[e.key]||(this._sourceTileCache[e.key]=e.scaledTo(r).key);let i=this.sourceCache.getTileByID(this._sourceTileCache[e.key]);if((!i||!i.dem)&&t)for(;r>=n.minzoom&&(!i||!i.dem);)i=this.sourceCache.getTileByID(e.scaledTo(r--).key);return i}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Z{constructor(e,t,n){this._meshCache={},this.painter=e,this.sourceCache=new Fa(t),this.options=n,this.exaggeration=typeof n.exaggeration==`number`?n.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,n,r,i=t.ah){if(!(n>=0&&n<i&&r>=0&&r<i))return 0;let a=this.getTerrainData(e),o=a.tile?.dem;if(!o)return 0;let s=t.ct([],[n/i*t.ah,r/i*t.ah],a.u_terrain_matrix),c=[s[0]*o.dim,s[1]*o.dim],l=Math.floor(c[0]),u=Math.floor(c[1]),d=c[0]-l,f=c[1]-u;return o.get(l,u)*(1-d)*(1-f)+o.get(l+1,u)*d*(1-f)+o.get(l,u+1)*(1-d)*f+o.get(l+1,u+1)*d*f}getElevationForLngLatZoom(e,n){if(!t.cu(n,e.wrap()))return 0;let{tileID:r,mercatorX:i,mercatorY:a}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getElevation(r,i%t.ah,a%t.ah,t.ah)}getElevation(e,n,r,i=t.ah){return this.getDEMElevation(e,n,r,i)*this.exaggeration}getTerrainData(e){if(!this._emptyDemTexture){let e=this.painter.context,n=new t.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new t.T(e,n,e.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new t.T(e,new t.R({width:1,height:1}),e.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=t.a4([])}let n=this.sourceCache.getSourceTile(e,!0);if(n&&n.dem&&(!n.demTexture||n.needsTerrainPrepare)){let e=this.painter.context;n.demTexture=this.painter.getTileTexture(n.dem.stride),n.demTexture?n.demTexture.update(n.dem.getPixels(),{premultiply:!1}):n.demTexture=new t.T(e,n.dem.getPixels(),e.gl.RGBA,{premultiply:!1}),n.demTexture.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),n.needsTerrainPrepare=!1}let r=n&&n+n.tileID.key+e.key;if(r&&!this._demMatrixCache[r]){let r=this.sourceCache.sourceCache._source.maxzoom,i=e.canonical.z-n.tileID.canonical.z;e.overscaledZ>e.canonical.z&&(e.canonical.z>=r?i=e.canonical.z-r:t.w(`cannot calculate elevation if elevation maxzoom > source.maxzoom`));let a=e.canonical.x-(e.canonical.x>>i<<i),o=e.canonical.y-(e.canonical.y>>i<<i),s=t.cv(new Float64Array(16),[1/(t.ah<<i),1/(t.ah<<i),0]);t.a5(s,s,[a*t.ah,o*t.ah,0]),this._demMatrixCache[e.key]={matrix:s,coord:e}}return{u_depth:2,u_terrain:3,u_terrain_dim:n&&n.dem&&n.dem.dim||1,u_terrain_matrix:r?this._demMatrixCache[e.key].matrix:this._emptyDemMatrix,u_terrain_unpack:n&&n.dem&&n.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(n&&n.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:n}}getFramebuffer(e){let n=this.painter,r=n.width/devicePixelRatio,i=n.height/devicePixelRatio;return!this._fbo||this._fbo.width===r&&this._fbo.height===i||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new t.T(n.context,{width:r,height:i,data:null},n.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(n.context.gl.NEAREST,n.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=n.context.createFramebuffer(r,i,!0,!1),this._fbo.depthAttachment.set(n.context.createRenderbuffer(n.context.gl.DEPTH_COMPONENT16,r,i))),this._fbo.colorAttachment.set(e===`coords`?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let e=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let n=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let e=0,t=0;e<this._coordsTextureSize;e++)for(let r=0;r<this._coordsTextureSize;r++,t+=4)n[t+0]=255&r,n[t+1]=255&e,n[t+2]=r>>8<<4|e>>8,n[t+3]=0;let r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),i=new t.T(e,r,e.gl.RGBA,{premultiply:!1});return i.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=i,i}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);let n=new Uint8Array(4),r=this.painter.context,i=r.gl,a=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),s=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer(`coords`).framebuffer),i.readPixels(a,s-o-1,1,1,i.RGBA,i.UNSIGNED_BYTE,n),r.bindFramebuffer.set(null);let c=n[0]+(n[2]>>4<<8),l=n[1]+((15&n[2])<<8),u=this.coordsIndex[255-n[3]],d=u&&this.sourceCache.getTileByID(u);if(!d)return null;let f=this._coordsTextureSize,p=(1<<d.tileID.canonical.z)*f;return new t.aj((d.tileID.canonical.x*f+c)/p+d.tileID.wrap,(d.tileID.canonical.y*f+l)/p,this.getElevation(d.tileID,c,l,f))}depthAtPoint(e){let t=new Uint8Array(4),n=this.painter.context,r=n.gl;return n.bindFramebuffer.set(this.getFramebuffer(`depth`).framebuffer),r.readPixels(e.x,this.painter.height/devicePixelRatio-e.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,t),n.bindFramebuffer.set(null),(t[0]/16777216+t[1]/65536+t[2]/256+t[3])/256}getTerrainMesh(e){let n=this.painter.style.projection?.transitionState>0,r=n&&e.canonical.y===0,i=n&&e.canonical.y===(1<<e.canonical.z)-1,a=`m_${r?`n`:``}_${i?`s`:``}`;if(this._meshCache[a])return this._meshCache[a];let o=this.painter.context,s=new t.cw,c=new t.aN,l=this.meshSize,u=t.ah/l,d=l*l;for(let e=0;e<=l;e++)for(let t=0;t<=l;t++)s.emplaceBack(t*u,e*u,0);for(let e=0;e<d;e+=l+1)for(let t=0;t<l;t++)c.emplaceBack(t+e,l+t+e+1,l+t+e+2),c.emplaceBack(t+e,l+t+e+2,t+e+1);let f=s.length,p=f+(l+1),m=(l+1)*l,h=r?t.bh:0,g=r?0:1,_=i?t.bi:t.ah,v=i?0:1;for(let e=0;e<=l;e++)s.emplaceBack(e*u,h,g);for(let e=0;e<=l;e++)s.emplaceBack(e*u,_,v);for(let e=0;e<l;e++)c.emplaceBack(m+e,p+e,p+e+1),c.emplaceBack(m+e,p+e+1,m+e+1),c.emplaceBack(0+e,f+e+1,f+e),c.emplaceBack(0+e,0+e+1,f+e+1);let y=s.length,b=y+2*(l+1);for(let e of[0,1])for(let n=0;n<=l;n++)for(let r of[0,1])s.emplaceBack(e*t.ah,n*u,r);for(let e=0;e<2*l;e+=2)c.emplaceBack(y+e,y+e+1,y+e+3),c.emplaceBack(y+e,y+e+3,y+e+2),c.emplaceBack(b+e,b+e+3,b+e+1),c.emplaceBack(b+e,b+e+2,b+e+3);let x=new Mt(o.createVertexBuffer(s,Pa.members),o.createIndexBuffer(c),t.aM.simpleSegment(0,0,s.length,c.length));return this._meshCache[a]=x,x}getMeshFrameDelta(e){return 2*Math.PI*t.bu/2**Math.max(e,0)/5}getMinTileElevationForLngLatZoom(e,n){if(!t.cu(n,e.wrap()))return 0;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(e,n);return this.getMinMaxElevation(r).minElevation??0}getMinMaxElevation(e){let t=this.getTerrainData(e).tile,n={minElevation:null,maxElevation:null};return t&&t.dem&&(n.minElevation=t.dem.min*this.exaggeration,n.maxElevation=t.dem.max*this.exaggeration),n}_getOverscaledTileIDFromLngLatZoom(e,n){let r=t.aj.fromLngLat(e.wrap()),i=(1<<n)*t.ah,a=r.x*i,o=r.y*i,s=Math.floor(a/t.ah),c=Math.floor(o/t.ah);return{tileID:new t.ag(n,0,n,s,c),mercatorX:a,mercatorY:o}}}class Q{constructor(e,t,n){this._context=e,this._size=t,this._tileSize=n,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let e of this._objects)e.texture.destroy(),e.fbo.destroy()}_createObject(e){let n=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),r=new t.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return r.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),n.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),n.colorAttachment.set(r.texture),{id:e,fbo:n,texture:r,stamp:-1,inUse:!1}}getObjectForId(e){return this._objects[e]}useObject(e){e.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((t=>e.id!==t)),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(let e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw Error(`No free RenderPool available, call freeAllObjects() required!`);let e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(let e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((e=>!e.inUse))}}let Ia={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class La{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Q(e.context,30,t.sourceCache.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=e._order.filter((n=>!e._layers[n].isHidden(t))),this._coordsAscending={};for(let t in e.sourceCaches){this._coordsAscending[t]={};let n=e.sourceCaches[t].getVisibleCoordinates(),r=e.sourceCaches[t].getSource(),i=r instanceof ze?r.terrainTileRanges:null;for(let e of n){let n=this.terrain.sourceCache.getTerrainCoords(e,i);for(let e in n)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(n[e])}}this._coordsAscendingStr={};for(let t of e._order){let n=e._layers[t],r=n.source;if(Ia[n.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(let e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map((e=>e.key)).sort().join()}}for(let e of this._renderableTiles)for(let t in this._coordsAscendingStr){let n=this._coordsAscendingStr[t][e.tileID.key];n&&n!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,n){if(e.isHidden(this.painter.transform.zoom))return!1;let r=Object.assign(Object.assign({},n),{isRenderingToTexture:!0}),i=e.type,a=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Ia[i]&&(this._prevType&&Ia[this._prevType]||this._stacks.push([]),this._prevType=i,this._stacks[this._stacks.length-1].push(e.id),!o))return!0;if(Ia[this._prevType]||Ia[i]&&o){this._prevType=i;let e=this._stacks.length-1,n=this._stacks[e]||[];for(let i of this._renderableTiles){if(this.pool.isFull()&&(Ai(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(i),i.rtt[e]){let t=this.pool.getObjectForId(i.rtt[e].id);if(t.stamp===i.rtt[e].stamp){this.pool.useObject(t);continue}}let o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),i.rtt[e]={id:o.id,stamp:o.stamp},a.context.bindFramebuffer.set(o.fbo.framebuffer),a.context.clear({color:t.bf.transparent,stencil:0}),a.currentStencilSource=void 0;for(let e=0;e<n.length;e++){let t=a.style._layers[n[e]],s=t.source?this._coordsAscending[t.source][i.tileID.key]:[i.tileID];a.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),a._renderTileClippingMasks(t,s,!0),a.renderLayer(a,a.style.sourceCaches[t.source],t,s,r),t.source&&(i.rttCoords[t.source]=this._coordsAscendingStr[t.source][i.tileID.key])}}return Ai(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects(),Ia[i]}return!1}}let Ra={"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`,"GlobeControl.Enable":`Enable globe`,"GlobeControl.Disable":`Disable globe`,"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`},za=n,Ba={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Aa,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:`high-performance`,failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 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],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:t.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:`sans-serif`,pitchWithRotate:!0,rollEnabled:!1,validateStyle:!0,maxCanvasSize:[4096,4096],scale:1,cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0},Va={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class Ha{constructor(e,n,r=!1){this.mousedown=e=>{this.startMove(e,s.mousePos(this.element,e,this.map.getScale())),s.addEventListener(window,`mousemove`,this.mousemove),s.addEventListener(window,`mouseup`,this.mouseup)},this.mousemove=e=>{this.move(e,s.mousePos(this.element,e,this.map.getScale()))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{e.targetTouches.length===1?(this._startPos=this._lastPos=s.touchPos(this.element,e.targetTouches,this.map.getScale())[0],this.startMove(e,this._startPos),s.addEventListener(window,`touchmove`,this.touchmove,{passive:!1}),s.addEventListener(window,`touchend`,this.touchend)):this.reset()},this.touchmove=e=>{e.targetTouches.length===1?(this._lastPos=s.touchPos(this.element,e.targetTouches,this.map.getScale())[0],this.move(e,this._lastPos)):this.reset()},this.touchend=e=>{e.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._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=n,this._rotatePitchHandler=new ea({clickTolerance:3,move:(e,i)=>{let a=n.getBoundingClientRect(),o=new t.P((a.bottom-a.top)/2,(a.right-a.left)/2);return{bearingDelta:t.co(new t.P(e.x,i.y),i,o),pitchDelta:r?-.5*(i.y-e.y):void 0}},moveStateManager:new ia,enable:!0,assignEvents:()=>{}}),this.map=e,s.addEventListener(n,`mousedown`,this.mousedown),s.addEventListener(n,`touchstart`,this.touchstart,{passive:!1}),s.addEventListener(n,`touchcancel`,this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),s.disableDrag()}move(e,t){let n=this.map,{bearingDelta:r,pitchDelta:i}=this._rotatePitchHandler.dragMove(e,t)||{};r&&n.setBearing(n.getBearing()+r),i&&n.setPitch(n.getPitch()+i)}off(){let e=this.element;s.removeEventListener(e,`mousedown`,this.mousedown),s.removeEventListener(e,`touchstart`,this.touchstart,{passive:!1}),s.removeEventListener(window,`touchmove`,this.touchmove,{passive:!1}),s.removeEventListener(window,`touchend`,this.touchend),s.removeEventListener(e,`touchcancel`,this.reset),this.offTemp()}offTemp(){s.enableDrag(),s.removeEventListener(window,`mousemove`,this.mousemove),s.removeEventListener(window,`mouseup`,this.mouseup),s.removeEventListener(window,`touchmove`,this.touchmove,{passive:!1}),s.removeEventListener(window,`touchend`,this.touchend)}}let $;function Ua(e,n,r,i=!1){if(i||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return e?.wrap();let a=new t.aa(e.lng,e.lat);if(e=new t.aa(e.lng,e.lat),n){let i=new t.aa(e.lng-360,e.lat),a=new t.aa(e.lng+360,e.lat),o=r.locationToScreenPoint(e).distSqr(n);r.locationToScreenPoint(i).distSqr(n)<o?e=i:r.locationToScreenPoint(a).distSqr(n)<o&&(e=a)}for(;Math.abs(e.lng-r.center.lng)>180;){let t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==a.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:a}let Wa={center:`translate(-50%,-50%)`,top:`translate(-50%,0)`,"top-left":`translate(0,0)`,"top-right":`translate(-100%,0)`,bottom:`translate(-50%,-100%)`,"bottom-left":`translate(0,-100%)`,"bottom-right":`translate(-100%,-100%)`,left:`translate(0,-50%)`,right:`translate(-100%,-50%)`};function Ga(e,t,n){let r=e.classList;for(let e in Wa)r.remove(`maplibregl-${n}-anchor-${e}`);r.add(`maplibregl-${n}-anchor-${t}`)}class Ka extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{let t=e.code,n=e.charCode||e.keyCode;t!==`Space`&&t!==`Enter`&&n!==32&&n!==13||this.togglePopup()},this._onMapClick=e=>{let t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;let t=this._map.loaded()&&!this._map.isMoving();(e?.type===`terrain`||e?.type===`render`&&!t)&&this._map.once(`render`,this._update),this._lngLat=Ua(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let n=``;this._rotationAlignment===`viewport`||this._rotationAlignment===`auto`?n=`rotateZ(${this._rotation}deg)`:this._rotationAlignment===`map`&&(n=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r=``;this._pitchAlignment===`viewport`||this._pitchAlignment===`auto`?r=`rotateX(0deg)`:this._pitchAlignment===`map`&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&e.type!==`moveend`||(this._pos=this._pos.round()),s.setTransform(this._element,`${Wa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${n}`),o.frameAsync(new AbortController).then((()=>{this._updateOpacity(e&&e.type===`moveend`)})).catch((()=>{}))},this._onMove=e=>{if(!this._isDragging){let t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.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 t.l(`dragstart`))),this.fire(new t.l(`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 t.l(`dragend`)),this._state=`inactive`},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state=`pending`,this._map.on(`mousemove`,this._onMove),this._map.on(`touchmove`,this._onMove),this._map.once(`mouseup`,this._onUp),this._map.once(`touchend`,this._onUp))},this._anchor=e&&e.anchor||`center`,this._color=e&&e.color||`#3FB1CE`,this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state=`inactive`,this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||`auto`,this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment!==`auto`?e.pitchAlignment:this._rotationAlignment,this.setOpacity(e?.opacity,e?.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=s.create(`div`);let n=s.createNS(`http://www.w3.org/2000/svg`,`svg`);n.setAttributeNS(null,`display`,`block`),n.setAttributeNS(null,`height`,`41px`),n.setAttributeNS(null,`width`,`27px`),n.setAttributeNS(null,`viewBox`,`0 0 27 41`);let r=s.createNS(`http://www.w3.org/2000/svg`,`g`);r.setAttributeNS(null,`stroke`,`none`),r.setAttributeNS(null,`stroke-width`,`1`),r.setAttributeNS(null,`fill`,`none`),r.setAttributeNS(null,`fill-rule`,`evenodd`);let i=s.createNS(`http://www.w3.org/2000/svg`,`g`);i.setAttributeNS(null,`fill-rule`,`nonzero`);let a=s.createNS(`http://www.w3.org/2000/svg`,`g`);a.setAttributeNS(null,`transform`,`translate(3.0, 29.0)`),a.setAttributeNS(null,`fill`,`#000000`);for(let e of[{rx:`10.5`,ry:`5.25002273`},{rx:`10.5`,ry:`5.25002273`},{rx:`9.5`,ry:`4.77275007`},{rx:`8.5`,ry:`4.29549936`},{rx:`7.5`,ry:`3.81822308`},{rx:`6.5`,ry:`3.34094679`},{rx:`5.5`,ry:`2.86367051`},{rx:`4.5`,ry:`2.38636864`}]){let t=s.createNS(`http://www.w3.org/2000/svg`,`ellipse`);t.setAttributeNS(null,`opacity`,`0.04`),t.setAttributeNS(null,`cx`,`10.5`),t.setAttributeNS(null,`cy`,`5.80029008`),t.setAttributeNS(null,`rx`,e.rx),t.setAttributeNS(null,`ry`,e.ry),a.appendChild(t)}let o=s.createNS(`http://www.w3.org/2000/svg`,`g`);o.setAttributeNS(null,`fill`,this._color);let c=s.createNS(`http://www.w3.org/2000/svg`,`path`);c.setAttributeNS(null,`d`,`M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z`),o.appendChild(c);let l=s.createNS(`http://www.w3.org/2000/svg`,`g`);l.setAttributeNS(null,`opacity`,`0.25`),l.setAttributeNS(null,`fill`,`#000000`);let u=s.createNS(`http://www.w3.org/2000/svg`,`path`);u.setAttributeNS(null,`d`,`M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z`),l.appendChild(u);let d=s.createNS(`http://www.w3.org/2000/svg`,`g`);d.setAttributeNS(null,`transform`,`translate(6.0, 7.0)`),d.setAttributeNS(null,`fill`,`#FFFFFF`);let f=s.createNS(`http://www.w3.org/2000/svg`,`g`);f.setAttributeNS(null,`transform`,`translate(8.0, 8.0)`);let p=s.createNS(`http://www.w3.org/2000/svg`,`circle`);p.setAttributeNS(null,`fill`,`#000000`),p.setAttributeNS(null,`opacity`,`0.25`),p.setAttributeNS(null,`cx`,`5.5`),p.setAttributeNS(null,`cy`,`5.5`),p.setAttributeNS(null,`r`,`5.4999962`);let m=s.createNS(`http://www.w3.org/2000/svg`,`circle`);m.setAttributeNS(null,`fill`,`#FFFFFF`),m.setAttributeNS(null,`cx`,`5.5`),m.setAttributeNS(null,`cy`,`5.5`),m.setAttributeNS(null,`r`,`5.4999962`),f.appendChild(p),f.appendChild(m),i.appendChild(a),i.appendChild(o),i.appendChild(l),i.appendChild(d),i.appendChild(f),n.appendChild(i),n.setAttributeNS(null,`height`,41*this._scale+`px`),n.setAttributeNS(null,`width`,27*this._scale+`px`),this._element.appendChild(n),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add(`maplibregl-marker`),this._element.addEventListener(`dragstart`,(e=>{e.preventDefault()})),this._element.addEventListener(`mousedown`,(e=>{e.preventDefault()})),Ga(this._element,this._anchor,`marker`),e&&e.className)for(let t of e.className.split(` `))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute(`aria-label`)||this._element.setAttribute(`aria-label`,e._getUIString(`Marker.Title`)),e.getCanvasContainer().appendChild(this._element),e.on(`move`,this._update),e.on(`moveend`,this._update),e.on(`terrain`,this._update),e.on(`projectiontransition`,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(`projectiontransition`,this._update),this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler),this._map.off(`mouseup`,this._onUp),this._map.off(`touchend`,this._onUp),this._map.off(`mousemove`,this._onMove),this._map.off(`touchmove`,this._onMove),delete this._map),s.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.aa.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener(`keypress`,this._onKeyPress),this._originalTabIndex||this._element.removeAttribute(`tabindex`)),e){if(!(`offset`in e.options)){let t=38.1,n=13.5,r=13.5/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute(`tabindex`),this._originalTabIndex||this._element.setAttribute(`tabindex`,`0`),this._element.addEventListener(`keypress`,this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){let e=this._popup;return this._element.style.opacity===this._opacityWhenCovered||e&&(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map))),this}_updateOpacity(e=!1){var n;let r=this._map?.terrain,i=this._map.transform.isLocationOccluded(this._lngLat);if(!r||i){let e=i?this._opacityWhenCovered:this._opacity;this._element.style.opacity!==e&&(this._element.style.opacity=e);return}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}let a=this._map,o=a.terrain.depthAtPoint(this._pos),s=a.terrain.getElevationForLngLatZoom(this._lngLat,a.transform.tileZoom);if(a.transform.lngLatToCameraDepth(this._lngLat,s)-o<.006)return void(this._element.style.opacity=this._opacity);let c=-this._offset.y/a.transform.pixelsPerMeter,l=Math.sin(a.getPitch()*Math.PI/180)*c,u=a.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=a.transform.lngLatToCameraDepth(this._lngLat,s+l)-u>.006;(n=this._popup)!=null&&n.isOpen()&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on(`mousedown`,this._addDragHandler),this._map.on(`touchstart`,this._addDragHandler)):(this._map.off(`mousedown`,this._addDragHandler),this._map.off(`touchstart`,this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||`auto`,this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&e!==`auto`?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(this._opacity===void 0||e===void 0&&t===void 0)&&(this._opacity=`1`,this._opacityWhenCovered=`0.2`),e!==void 0&&(this._opacity=e),t!==void 0&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}let qa={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Ja=0,Ya=!1,Xa={maxWidth:100,unit:`metric`};function Za(e,t,n){let r=n&&n.maxWidth||100,i=e._container.clientHeight/2,a=e._container.clientWidth/2,o=e.unproject([a-r/2,i]),s=e.unproject([a+r/2,i]),c=Math.round(e.project(s).x-e.project(o).x),l=Math.min(r,c,e._container.clientWidth),u=o.distanceTo(s);if(n&&n.unit===`imperial`){let n=3.2808*u;n>5280?Qa(t,l,n/5280,e._getUIString(`ScaleControl.Miles`)):Qa(t,l,n,e._getUIString(`ScaleControl.Feet`))}else n&&n.unit===`nautical`?Qa(t,l,u/1852,e._getUIString(`ScaleControl.NauticalMiles`)):u>=1e3?Qa(t,l,u/1e3,e._getUIString(`ScaleControl.Kilometers`)):Qa(t,l,u,e._getUIString(`ScaleControl.Meters`))}function Qa(e,t,n,r){let i=function(e){let t=10**(`${Math.floor(e)}`.length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){let t=10**Math.ceil(-Math.log(e)/Math.LN10);return Math.round(e*t)/t}(n),t*n}(n);e.style.width=i/n*t+`px`,e.innerHTML=`${i} ${r}`}let $a={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:``,maxWidth:`240px`,subpixelPositioning:!1,locationOccludedOpacity:void 0},eo=[`a[href]`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable]:not([contenteditable='false'])`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`].join(`, `);function to(e){if(e){if(typeof e==`number`){let n=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(n,n),"top-right":new t.P(-n,n),bottom:new t.P(0,-e),"bottom-left":new t.P(n,-n),"bottom-right":new t.P(-n,-n),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){let n=t.P.convert(e);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e[`top-left`]||[0,0]),"top-right":t.P.convert(e[`top-right`]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e[`bottom-left`]||[0,0]),"bottom-right":t.P.convert(e[`bottom-right`]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return to(new t.P(0,0))}let no=n;e.AJAXError=t.cB,e.Event=t.l,e.Evented=t.E,e.LngLat=t.aa,e.MercatorCoordinate=t.aj,e.Point=t.P,e.addProtocol=t.cC,e.config=t.a,e.createExpression=t.cE,e.removeProtocol=t.cD,e.AttributionControl=ja,e.BoxZoomHandler=Yi,e.CanvasSource=Ve,e.CooperativeGesturesHandler=wa,e.DoubleClickZoomHandler=va,e.DragPanHandler=xa,e.DragRotateHandler=Sa,e.EdgeInsets=It,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{let e=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;e?.shadowRoot?.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w(`Full screen control 'container' must be a DOM element.`)),`onfullscreenchange`in document?this._fullscreenchange=`fullscreenchange`:`onmozfullscreenchange`in document?this._fullscreenchange=`mozfullscreenchange`:`onwebkitfullscreenchange`in document?this._fullscreenchange=`webkitfullscreenchange`:`onmsfullscreenchange`in document&&(this._fullscreenchange=`MSFullscreenChange`)}onAdd(e){return this._map=e,this._container||=this._map.getContainer(),this._controlContainer=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),this._controlContainer}onRemove(){s.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let e=this._fullscreenButton=s.create(`button`,`maplibregl-ctrl-fullscreen`,this._controlContainer);s.create(`span`,`maplibregl-ctrl-icon`,e).setAttribute(`aria-hidden`,`true`),e.type=`button`,this._updateTitle(),this._fullscreenButton.addEventListener(`click`,this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let e=this._getTitle();this._fullscreenButton.setAttribute(`aria-label`,e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?`FullscreenControl.Exit`:`FullscreenControl.Enter`)}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle(`maplibregl-ctrl-shrink`),this._fullscreenButton.classList.toggle(`maplibregl-ctrl-fullscreen`),this._updateTitle(),this._fullscreen?(this.fire(new t.l(`fullscreenstart`)),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l(`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()}},e.GeoJSONSource=Re,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l(`outofmaxbounds`,e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:this._watchState=`ACTIVE_LOCK`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`BACKGROUND`:case`BACKGROUND_ERROR`:this._watchState=`BACKGROUND`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`);break;default:throw Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!==`OFF`&&this._updateMarker(e),this.options.trackUserLocation&&this._watchState!==`ACTIVE_LOCK`||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove(`maplibregl-user-location-dot-stale`),this.fire(new t.l(`geolocate`,e)),this._finish()}},this._updateCamera=e=>{let n=new t.aa(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,i=this._map.getBearing(),a=t.e({bearing:i},this.options.fitBoundsOptions),o=I.fromLngLat(n,r);this._map.fitBounds(o,a,{geolocateSource:!0})},this._updateMarker=e=>{if(e){let n=new t.aa(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=e=>{if(this._map){if(e.code===1){this._watchState=`OFF`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.disabled=!0;let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(e.code===3&&Ya)return;this.options.trackUserLocation&&this._setErrorState()}this._watchState!==`OFF`&&this.options.showUserLocation&&this._dotElement.classList.add(`maplibregl-user-location-dot-stale`),this.fire(new t.l(`error`,e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener(`contextmenu`,(e=>e.preventDefault())),this._geolocateButton=s.create(`button`,`maplibregl-ctrl-geolocate`,this._container),s.create(`span`,`maplibregl-ctrl-icon`,this._geolocateButton).setAttribute(`aria-hidden`,`true`),this._geolocateButton.type=`button`,this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w(`Geolocation support is not available so the GeolocateControl will be disabled.`);let e=this._map._getUIString(`GeolocateControl.LocationNotAvailable`);this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}else{let e=this._map._getUIString(`GeolocateControl.FindMyLocation`);this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute(`aria-label`,e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute(`aria-pressed`,`false`),this._watchState=`OFF`),this.options.showUserLocation&&(this._dotElement=s.create(`div`,`maplibregl-user-location-dot`),this._userLocationDotMarker=new Ka({element:this._dotElement}),this._circleElement=s.create(`div`,`maplibregl-user-location-accuracy-circle`),this._accuracyCircleMarker=new Ka({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`,(e=>{let n=e?.[0]instanceof ResizeObserverEntry;e.geolocateSource||this._watchState!==`ACTIVE_LOCK`||n||this._map.isZooming()||(this._watchState=`BACKGROUND`,this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this.fire(new t.l(`trackuserlocationend`)),this.fire(new t.l(`userlocationlostfocus`)))}))}},this.options=t.e({},qa,e)}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._setupUI(),function(){return t._(this,arguments,void 0,(function*(e=!1){if($!==void 0&&!e)return $;if(window.navigator.permissions===void 0)return $=!!window.navigator.geolocation,$;try{$=(yield window.navigator.permissions.query({name:`geolocation`})).state!==`denied`}catch{$=!!window.navigator.geolocation}return $}))}().then((e=>this._finishSetupUI(e))),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),s.remove(this._container),this._map.off(`zoom`,this._onZoom),this._map=void 0,Ja=0,Ya=!1}_isOutOfMapMaxBounds(e){let t=this._map.getMaxBounds(),n=e.coords;return t&&(n.longitude<t.getWest()||n.longitude>t.getEast()||n.latitude<t.getSouth()||n.latitude>t.getNorth())}_setErrorState(){switch(this._watchState){case`WAITING_ACTIVE`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`);break;case`ACTIVE_LOCK`:this._watchState=`ACTIVE_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-active`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`BACKGROUND`:this._watchState=`BACKGROUND_ERROR`,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-background`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-background-error`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`);break;case`ACTIVE_ERROR`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){let e=this._map.getBounds(),t=e.getSouthEast(),n=e.getNorthEast(),r=t.distanceTo(n),i=Math.ceil(this._accuracy/(r/this._map._container.clientHeight)*2);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}trigger(){if(!this._setup)return t.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 t.l(`trackuserlocationstart`));break;case`WAITING_ACTIVE`:case`ACTIVE_LOCK`:case`ACTIVE_ERROR`:case`BACKGROUND_ERROR`:Ja--,Ya=!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 t.l(`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 t.l(`trackuserlocationstart`)),this.fire(new t.l(`userlocationfocus`));break;default:throw Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case`WAITING_ACTIVE`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`ACTIVE_LOCK`:this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-active`);break;case`OFF`:break;default:throw Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState===`OFF`&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let e;this._geolocateButton.classList.add(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`true`),Ja++,Ja>1?(e={maximumAge:6e5,timeout:0},Ya=!0):(e=this.options.positionOptions,Ya=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove(`maplibregl-ctrl-geolocate-waiting`),this._geolocateButton.setAttribute(`aria-pressed`,`false`),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{let e=this._map.getProjection()?.type;this._map.setProjection(e!==`mercator`&&e?{type:`mercator`}:{type:`globe`}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{this._globeButton.classList.remove(`maplibregl-ctrl-globe`),this._globeButton.classList.remove(`maplibregl-ctrl-globe-enabled`),this._map.getProjection()?.type===`globe`?(this._globeButton.classList.add(`maplibregl-ctrl-globe-enabled`),this._globeButton.title=this._map._getUIString(`GlobeControl.Disable`)):(this._globeButton.classList.add(`maplibregl-ctrl-globe`),this._globeButton.title=this._map._getUIString(`GlobeControl.Enable`))}}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._globeButton=s.create(`button`,`maplibregl-ctrl-globe`,this._container),s.create(`span`,`maplibregl-ctrl-icon`,this._globeButton).setAttribute(`aria-hidden`,`true`),this._globeButton.type=`button`,this._globeButton.addEventListener(`click`,this._toggleProjection),this._updateGlobeIcon(),this._map.on(`styledata`,this._updateGlobeIcon),this._container}onRemove(){s.remove(this._container),this._map.off(`styledata`,this._updateGlobeIcon),this._globeButton.removeEventListener(`click`,this._toggleProjection),this._map=void 0}},e.Hash=Pi,e.ImageSource=ze,e.KeyboardHandler=ma,e.LngLatBounds=I,e.LogoControl=Ma,e.Map=class extends ka{constructor(e){t.cx.mark(t.cy.create);let n=Object.assign(Object.assign(Object.assign({},Ba),e),{canvasContextAttributes:Object.assign(Object.assign({},Ba.canvasContextAttributes),e.canvasContextAttributes)});if(n.minZoom!=null&&n.maxZoom!=null&&n.minZoom>n.maxZoom)throw Error(`maxZoom must be greater than or equal to minZoom`);if(n.minPitch!=null&&n.maxPitch!=null&&n.minPitch>n.maxPitch)throw Error(`maxPitch must be greater than or equal to minPitch`);if(n.minPitch!=null&&n.minPitch<0)throw Error(`minPitch must be greater than or equal to 0`);if(n.maxPitch!=null&&n.maxPitch>180)throw Error(`maxPitch must be less than or equal to 180`);let r=new Ut,i=new qt;if(n.minZoom!==void 0&&r.setMinZoom(n.minZoom),n.maxZoom!==void 0&&r.setMaxZoom(n.maxZoom),n.minPitch!==void 0&&r.setMinPitch(n.minPitch),n.maxPitch!==void 0&&r.setMaxPitch(n.maxPitch),n.renderWorldCopies!==void 0&&r.setRenderWorldCopies(n.renderWorldCopies),super(r,i,{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Na,this._controls=[],this._mapId=t.ao(),this._contextLost=e=>{e.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.fire(new t.l(`webglcontextlost`,{originalEvent:e}))},this._contextRestored=e=>{this._setupPainter(),this.resize(),this._update(),this.fire(new t.l(`webglcontextrestored`,{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},Ra),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this.transformCameraUpdate=n.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,this._dynamicScale=n.scale,this._imageQueueHandle=m.addThrottleControl((()=>this.isMoving())),this._requestManager=new h(n.transformRequest),typeof n.container==`string`){if(this._container=document.getElementById(n.container),!this._container)throw Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw Error(`Invalid type: 'container' must be a String or HTMLElement.`);this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),this.on(`move`,(()=>this._update(!1))),this.on(`moveend`,(()=>this._update(!1))),this.on(`zoom`,(()=>this._update(!0))),this.on(`terrain`,(()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)})),this.once(`idle`,(()=>{this._idleTriggered=!0})),typeof window<`u`){addEventListener(`online`,this._onWindowOnline,!1);let e=!1,t=Ni((e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())}),50);this._resizeObserver=new ResizeObserver((n=>{e?t(n):e=!0})),this._resizeObserver.observe(this._container)}this.handlers=new Oa(this,n),this._hash=n.hash&&new Pi(typeof n.hash==`string`&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,t.e({},n.fitBoundsOptions,{duration:0}))));let a=typeof n.style==`string`||n.style?.projection?.type!==`globe`;this.resize(null,a),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style?this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}):n.style===null&&this._lazyInitEmptyStyle(),n.attributionControl&&this.addControl(new ja(typeof n.attributionControl==`boolean`?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Ma,n.logoPosition),this.on(`style.load`,(()=>{if(a||this._resizeTransform(),this.transform.unmodified){let e=t.a9(this.style.stylesheet,[`center`,`zoom`,`bearing`,`pitch`,`roll`]);this.jumpTo(e)}})),this.on(`data`,(e=>{this._update(e.dataType===`style`),this.fire(new t.l(`${e.dataType}data`,e))})),this.on(`dataloading`,(e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))})),this.on(`dataabort`,(e=>{this.fire(new t.l(`sourcedataabort`,e))}))}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,n){if(n===void 0&&(n=e.getDefaultPosition?e.getDefaultPosition():`top-right`),!e||!e.onAdd)return this.fire(new t.k(Error(`Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.`)));let r=e.onAdd(this);this._controls.push(e);let i=this._controlPositions[n];return n.indexOf(`bottom`)===-1?i.appendChild(r):i.insertBefore(r,i.firstChild),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(Error(`Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.`)));let n=this._controls.indexOf(e);return n>-1&&this._controls.splice(n,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return rt(this.transform,e)}calculateCameraOptionsFromTo(e,t,n,r){return r==null&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,n,r)}resize(e,n=!0){let[r,i]=this._containerDimensions(),a=this.getScale(),o=this._getClampedPixelRatio(r,i);if(this._resizeCanvas(r,i,o),this.painter.resize(r,i,o,a),this.painter.overLimit()){let e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];let t=this._getClampedPixelRatio(r,i);this._resizeCanvas(r,i,t),this.painter.resize(r,i,t,a)}this._resizeTransform(n);let s=!this._moving;return s&&(this.stop(),this.fire(new t.l(`movestart`,e)).fire(new t.l(`move`,e))),this.fire(new t.l(`resize`,e)),s&&this.fire(new t.l(`moveend`,e)),this}_resizeTransform(e=!0){var t;let[n,r]=this._containerDimensions(),i=this.getScale(),a=n/i,o=r/i;this.transform.resize(a,o,e),(t=this._requestedCameraState)==null||t.resize(a,o,e)}_getClampedPixelRatio(e,t){let{0:n,1:r}=this._maxCanvasSize,i=this.getPixelRatio(),a=e*i,o=t*i;return Math.min(a>n?n/a:1,o>r?r/o:1)*i}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getScale(){return this._dynamicScale}setScale(e){this._dynamicScale=e,this.resize()}getDetailLevel(){return this.transform.detailLevel}setDetailLevel(e){this.transform.setDetailLevel(e),this._update()}getRasterAlignment(){return this.transform.rasterAlignment}setRasterAlignment(e){this.transform.setRasterAlignment(e),this._update()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(I.convert(e)),this._update()}setMinZoom(e){if((e??=-2)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()<e&&this.setZoom(e),this;throw Error(`minZoom must be between -2 and the current maxZoom, inclusive`)}getMinZoom(){return this.transform.minZoom}setMaxZoom(e){if((e??=22)>=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw Error(`maxZoom must be greater than the current minZoom`)}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e??=0)<0)throw Error(`minPitch must be greater than or equal to 0`);if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()<e&&this.setPitch(e),this;throw Error(`minPitch must be between 0 and the current maxPitch, inclusive`)}getMinPitch(){return this.transform.minPitch}setMaxPitch(e){if((e??=60)>180)throw Error(`maxPitch must be less than or equal to 180`);if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw Error(`maxPitch must be greater than the current minPitch`)}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.aa.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}unprojectClamped(e){return this.transform instanceof Ut?this.transform.screenPointToMercatorCoordinateClamped(t.P.convert(e)).toLngLat():this.unproject(e)}projectWithScaleCorrection(e){return this.project(e).mult(this.getScale())}unprojectWithScaleCorrection(e){return this.unproject(t.P.convert(e).div(this.getScale()))}isMoving(){return this._moving||this.handlers?.isMoving()}isZooming(){return this._zooming||this.handlers?.isZooming()}isRotating(){return this._rotating||this.handlers?.isRotating()}_createDelegatedListener(e,t,n){if(e===`mouseenter`||e===`mouseover`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e))),o=a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a});o.length?r||(r=!0,n.call(this,new Wi(e,this,i.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if(e===`mouseleave`||e===`mouseout`){let r=!1;return{layers:t,listener:n,delegates:{mousemove:i=>{let a=t.filter((e=>this.getLayer(e)));(a.length===0?[]:this.queryRenderedFeatures(i.point,{layers:a})).length?r=!0:r&&(r=!1,n.call(this,new Wi(e,this,i.originalEvent)))},mouseout:t=>{r&&(r=!1,n.call(this,new Wi(e,this,t.originalEvent)))}}}}{let r=e=>{let r=t.filter((e=>this.getLayer(e))),i=r.length===0?[]:this.queryRenderedFeatures(e.point,{layers:r});i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:t,listener:n,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,n){if(!this._delegatedListeners||!this._delegatedListeners[e])return;let r=this._delegatedListeners[e];for(let e=0;e<r.length;e++){let i=r[e];if(i.listener===n&&i.layers.length===t.length&&i.layers.every((e=>t.includes(e)))){for(let e in i.delegates)this.off(e,i.delegates[e]);r.splice(e,1);return}}}on(e,t,n){if(n===void 0)return super.on(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);this._saveDelegatedListener(e,i);for(let e in i.delegates)this.on(e,i.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,n)}}}once(e,t,n){if(n===void 0)return super.once(e,t);let r=typeof t==`string`?[t]:t,i=this._createDelegatedListener(e,r,n);for(let t in i.delegates){let a=i.delegates[t];i.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,n),a(...t)}}this._saveDelegatedListener(e,i);for(let e in i.delegates)this.once(e,i.delegates[e]);return this}off(e,t,n){return n===void 0?super.off(e,t):(this._removeDelegatedListener(e,typeof t==`string`?[t]:t,n),this)}queryRenderedFeatures(e,n){if(!this.style)return[];let r,i=e instanceof t.P||Array.isArray(e),a=i?e:[[0,0],[this.transform.width,this.transform.height]];if(n=n||(i?{}:e)||{},a instanceof t.P||typeof a[0]==`number`)r=[t.P.convert(a)];else{let e=t.P.convert(a[0]),n=t.P.convert(a[1]);r=[e,new t.P(n.x,e.y),n,new t.P(e.x,n.y),e]}return this.style.queryRenderedFeatures(r,n,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,n){return!1!==(n=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n)).diff&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(e,n))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){let t=this._locale[e];if(t==null)throw Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once(`style.load`,(()=>this._updateStyle(e,t)));let r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new kn(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof e==`string`?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):((n=this.style?.projection)==null||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new kn(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,n){if(typeof e==`string`){let r=this._requestManager.transformRequest(e,`Style`);t.j(r,new AbortController).then((e=>{this._updateDiff(e.data,n)})).catch((e=>{e&&this.fire(new t.k(e))}))}else typeof e==`object`&&this._updateDiff(e,n)}_updateDiff(e,n){try{this.style.setState(e,n)&&this._update(!0)}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():t.w(`There is no style added to the map.`)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){let n=this.style&&this.style.sourceCaches[e];if(n!==void 0)return n.loaded();this.fire(new t.k(Error(`There is no source with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off(`data`,this._terrainDataCallback),e){let n=this.style.sourceCaches[e.source];if(!n)throw Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);this.terrain===null&&n.reload();for(let n in this.style._layers){let r=this.style._layers[n];r.type===`hillshade`&&r.source===e.source&&t.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.`),r.type===`color-relief`&&r.source===e.source&&t.w(`You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.`)}this.terrain=new Z(this.painter,n,e),this.painter.renderToTexture=new La(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{t.dataType===`style`?this.terrain.sourceCache.freeRtt():t.dataType===`source`&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),t.source?.type===`image`?this.terrain.sourceCache.freeRtt():this.terrain.sourceCache.freeRtt(t.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.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l(`terrain`,{terrain:e})),this}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let e=this.style&&this.style.sourceCaches;for(let t in e){let n=e[t]._tiles;for(let e in n){let t=n[e];if(t.state!==`loaded`&&t.state!==`errored`)return!1}}return!0}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,n){if(n){let r=this.getSource(n);if(!r)throw Error(`There is no source with ID "${n}", cannot set LOD parameters`);r.calculateTileZoom=et(Math.max(1,e),Math.max(1,t))}else for(let n in this.style.sourceCaches)this.style.sourceCaches[n].getSource().calculateTileZoom=et(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,n){let r=this.style.sourceCaches[e];if(!r)throw Error(`There is no source cache with ID "${e}", cannot refresh tile`);n===void 0?r.reload(!0):r.refreshTiles(n.map((e=>new t.al(e.z,e.x,e.y))))}addImage(e,n,r={}){let{pixelRatio:i=1,sdf:a=!1,stretchX:s,stretchY:c,content:l,textFitWidth:u,textFitHeight:d}=r;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||t.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new t.k(Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{let{width:r,height:o,data:f}=n,p=n;return this.style.addImage(e,{data:new t.R({width:r,height:o},new Uint8Array(f)),pixelRatio:i,stretchX:s,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{let{width:r,height:f,data:p}=o.getImageData(n);this.style.addImage(e,{data:new t.R({width:r,height:f},p),pixelRatio:i,stretchX:s,stretchY:c,content:l,textFitWidth:u,textFitHeight:d,sdf:a,version:0})}}updateImage(e,n){let r=this.style.getImage(e);if(!r)return this.fire(new t.k(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:i,height:a,data:s}=n instanceof HTMLImageElement||t.b(n)?o.getImageData(n):n;if(i===void 0||a===void 0)return this.fire(new t.k(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(i!==r.data.width||a!==r.data.height)return this.fire(new t.k(Error(`The width and height of the updated image must be that same as the previous version of the image`)));let c=!(n instanceof HTMLImageElement||t.b(n));return r.data.replace(s,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(Error(`Missing required image id`))),!1)}removeImage(e){this.style.removeImage(e)}addImages(e){this.style.addImages(e)}loadImage(e){return m.getImage(this._requestManager.transformRequest(e,`Image`),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayersOrder(e){return this._lazyInitEmptyStyle(),this.style.setLayersOrder(e),this._update(!0)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,n,(e=>{e||this._update(!0)})),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,(e=>{e||this._update(!0)})),this}loadSprite(e){return v(e,this._requestManager,this.getPixelRatio()*this.getScale(),new AbortController).then((e=>e.default??{}))}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){let e=this._container;e.classList.add(`maplibregl-map`);let t=this._canvasContainer=s.create(`div`,`maplibregl-canvas-container`,e);this._interactive&&t.classList.add(`maplibregl-interactive`),this._canvas=s.create(`canvas`,`maplibregl-canvas`,t),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`);let n=this._containerDimensions(),r=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],r);let i=this._controlContainer=s.create(`div`,`maplibregl-control-container`,e),a=this._controlPositions={};[`top-left`,`top-right`,`bottom-left`,`bottom-right`].forEach((e=>{a[e]=s.create(`div`,`maplibregl-ctrl-${e} `,i)})),this._container.addEventListener(`scroll`,this._onMapScroll,!1)}_resizeCanvas(e,t,n){this._canvas.width=Math.floor(n*e),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0}),t=null;this._canvas.addEventListener(`webglcontextcreationerror`,(n=>{t={requestedAttributes:e},n&&(t.statusMessage=n.statusMessage,t.type=n.type)}),{once:!0});let n=null;if(n=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext(`webgl2`,e)||this._canvas.getContext(`webgl`,e),!n){let e=`Failed to initialize WebGL`;throw t?(t.message=e,Error(JSON.stringify(t))):Error(e)}this.painter=new Mi(n,this.transform),c.testSupport(n)}migrateProjection(e,n){super.migrateProjection(e,n),this.painter.transform=e,this.fire(new t.l(`projectiontransition`,{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var n;let r=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let a=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let e=this.transform.zoom,n=o.now();this.style.zoomHistory.update(e,n);let i=new t.F(e,{now:n,fadeDuration:r,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition(),globalState:this.style.getGlobalState()}),s=i.crossFadingFactor();s===1&&s===this._crossFadingFactor||(a=!0,this._crossFadingFactor=s),this.style.update(i)}let s=this.style.projection?.transitionState>0!==i;(n=this.style.projection)==null||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(this.style.projection?.transitionState,this.style.projection?.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||s)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,r,this._crossSourceCollisions,s),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:r,showPadding:this.showPadding}),this.fire(new t.l(`render`)),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cx.mark(t.cy.load),this.fire(new t.l(`load`))),this.style&&(this.style.hasTransitions()||a)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let c=this._sourcesDirty||this._styleDirty||this._placementDirty;return c||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l(`idle`)),!this._loaded||this._fullyLoaded||c||(this._fullyLoaded=!0,t.cx.mark(t.cy.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(let e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<`u`&&removeEventListener(`online`,this._onWindowOnline,!1),m.removeThrottleControl(this._imageQueueHandle),(e=this._resizeObserver)==null||e.disconnect();let n=this.painter.context.gl.getExtension(`WEBGL_lose_context`);n!=null&&n.loseContext&&n.loseContext(),this._canvas.removeEventListener(`webglcontextrestored`,this._contextRestored,!1),this._canvas.removeEventListener(`webglcontextlost`,this._contextLost,!1),s.remove(this._canvasContainer),s.remove(this._controlContainer),this._container.removeEventListener(`scroll`,this._onMapScroll,!1),this._container.classList.remove(`maplibregl-map`),t.cx.clearMetrics(),this._removed=!0,this.fire(new t.l(`remove`))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,o.frame(this._frameRequest,(e=>{t.cx.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cz(e)&&!function(e){return e.message===Zr}(e))throw e}}),(()=>{})))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return za}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}setLabelFreeAreas(e){this.style.setLabelFreeAreas(e)&&this.triggerRepaint()}getGlyphMap(e,t){let n=this.style.glyphManager,r=new Set;for(let t=0;t<e.length;t++)r.add(e.charCodeAt(t));return n.getGlyphMap(t,Array.from(r))}getLineBreaks(e,n,r,i,a,o=this.getGlyphMap(e,n)){return t.cA(e,n,r,i,a,o).map((({text:e})=>e))}},e.MapMouseEvent=Wi,e.MapTouchEvent=Gi,e.MapWheelEvent=Ki,e.Marker=Ka,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{let e=this._map.getZoom(),t=e===this._map.getMaxZoom(),n=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute(`aria-disabled`,t.toString()),this._zoomOutButton.setAttribute(`aria-disabled`,n.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.cos(this._map.transform.pitchInRadians)**.5}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{let n=this._map._getUIString(`NavigationControl.${t}`);e.title=n,e.setAttribute(`aria-label`,n)},this.options=t.e({},Va,e),this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._container.addEventListener(`contextmenu`,(e=>e.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton(`maplibregl-ctrl-zoom-in`,(e=>this._map.zoomIn({},{originalEvent:e}))),s.create(`span`,`maplibregl-ctrl-icon`,this._zoomInButton).setAttribute(`aria-hidden`,`true`),this._zoomOutButton=this._createButton(`maplibregl-ctrl-zoom-out`,(e=>this._map.zoomOut({},{originalEvent:e}))),s.create(`span`,`maplibregl-ctrl-icon`,this._zoomOutButton).setAttribute(`aria-hidden`,`true`)),this.options.showCompass&&(this._compass=this._createButton(`maplibregl-ctrl-compass`,(e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})),this._compassIcon=s.create(`span`,`maplibregl-ctrl-icon`,this._compass),this._compassIcon.setAttribute(`aria-hidden`,`true`))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,`ZoomIn`),this._setButtonTitle(this._zoomOutButton,`ZoomOut`),this._map.on(`zoom`,this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,`ResetBearing`),this.options.visualizePitch&&this._map.on(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on(`roll`,this._rotateCompassArrow),this._map.on(`rotate`,this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new Ha(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){s.remove(this._container),this.options.showZoom&&this._map.off(`zoom`,this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off(`pitch`,this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off(`roll`,this._rotateCompassArrow),this._map.off(`rotate`,this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){let n=s.create(`button`,e,this._container);return n.type=`button`,n.addEventListener(`click`,t),n}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{this.options.locationOccludedOpacity!==void 0&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:``)},this.remove=()=>(this._content&&s.remove(this._content),this._container&&(s.remove(this._container),delete this._container),this._map&&(this._map.off(`move`,this._update),this._map.off(`move`,this._onClose),this._map.off(`click`,this._onClose),this._map.off(`remove`,this.remove),this._map.off(`mousemove`,this._onMouseMove),this._map.off(`mouseup`,this._onMouseUp),this._map.off(`drag`,this._onDrag),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`),delete this._map,this.fire(new t.l(`close`))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=s.create(`div`,`maplibregl-popup`,this._map.getContainer()),this._tip=s.create(`div`,`maplibregl-popup-tip`,this._container),this._container.appendChild(this._content),this.options.className)for(let e of this.options.className.split(` `))this._container.classList.add(e);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=Ua(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;let t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor,r=to(this.options.offset);if(!n){let e=this._container.offsetWidth,i=this._container.offsetHeight,a;a=t.y+r.bottom.y<i?[`top`]:t.y>this._map.transform.height-i?[`bottom`]:[],t.x<e/2?a.push(`left`):t.x>this._map.transform.width-e/2&&a.push(`right`),n=a.length===0?`bottom`:a.join(`-`)}let i=t.add(r[n]);this.options.subpixelPositioning||(i=i.round()),s.setTransform(this._container,`${Wa[n]} translate(${i.x}px,${i.y}px)`),Ga(this._container,n,`popup`),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create($a),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on(`click`,this._onClose),this.options.closeOnMove&&this._map.on(`move`,this._onClose),this._map.on(`remove`,this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on(`mousemove`,this._onMouseMove),this._map.on(`mouseup`,this._onMouseUp),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)):this._map.on(`move`,this._update),this.fire(new t.l(`open`)),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.aa.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on(`move`,this._update),this._map.off(`mousemove`,this._onMouseMove),this._container&&this._container.classList.remove(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.remove(`maplibregl-track-pointer`)),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off(`move`,this._update),this._map.on(`mousemove`,this._onMouseMove),this._map.on(`drag`,this._onDrag),this._container&&this._container.classList.add(`maplibregl-popup-track-pointer`),this._map._canvasContainer.classList.add(`maplibregl-track-pointer`)),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){let t=document.createDocumentFragment(),n=document.createElement(`body`),r;for(n.innerHTML=e;r=n.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=s.create(`div`,`maplibregl-popup-content`,this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=s.create(`button`,`maplibregl-popup-close-button`,this._content),this._closeButton.type=`button`,this._closeButton.innerHTML=`×`,this._closeButton.addEventListener(`click`,this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let e=this._container.querySelector(eo);e&&e.focus()}},e.RasterDEMTileSource=Le,e.RasterTileSource=L,e.ScaleControl=class{constructor(e){this._onMove=()=>{Za(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,Za(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Xa),e)}getDefaultPosition(){return`bottom-left`}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-scale`,e.getContainer()),this._map.on(`move`,this._onMove),this._onMove(),this._container}onRemove(){s.remove(this._container),this._map.off(`move`,this._onMove),this._map=void 0}},e.ScrollZoomHandler=_a,e.Style=kn,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove(`maplibregl-ctrl-terrain`),this._terrainButton.classList.remove(`maplibregl-ctrl-terrain-enabled`),this._map.terrain?(this._terrainButton.classList.add(`maplibregl-ctrl-terrain-enabled`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Disable`)):(this._terrainButton.classList.add(`maplibregl-ctrl-terrain`),this._terrainButton.title=this._map._getUIString(`TerrainControl.Enable`))},this.options=e}onAdd(e){return this._map=e,this._container=s.create(`div`,`maplibregl-ctrl maplibregl-ctrl-group`),this._terrainButton=s.create(`button`,`maplibregl-ctrl-terrain`,this._container),s.create(`span`,`maplibregl-ctrl-icon`,this._terrainButton).setAttribute(`aria-hidden`,`true`),this._terrainButton.type=`button`,this._terrainButton.addEventListener(`click`,this._toggleTerrain),this._updateTerrainIcon(),this._map.on(`terrain`,this._updateTerrainIcon),this._container}onRemove(){s.remove(this._container),this._map.off(`terrain`,this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=pa,e.TwoFingersTouchRotateHandler=da,e.TwoFingersTouchZoomHandler=la,e.TwoFingersTouchZoomRotateHandler=Ca,e.VectorTileSource=Ie,e.VideoSource=Be,e.addSourceType=(e,n)=>t._(void 0,void 0,void 0,(function*(){if(Ue(e))throw Error(`A source type called "${e}" already exists.`);((e,t)=>{He[e]=t})(e,n)})),e.clearPrewarmedResources=function(){let e=P;e&&(e.isPreloaded()&&e.numActive()===1?(e.release(j),P=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()`))},e.createTileMesh=tn,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return Ke().getRTLTextPluginStatus()},e.getVersion=function(){return no},e.getWorkerCount=function(){return M.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return ne().broadcast(`IS`,e)},e.prewarm=function(){te().acquire(j)},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setRTLTextPlugin=function(e,t){return Ke().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){M.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}})),e}))}))();function n(e,t){for(let n of t.getStyle().layers){if(n.type!==`symbol`||n.id.startsWith(`custom-`)||n.id.startsWith(`gl-`))continue;let i=n.layout&&n.layout[`text-field`];n[`source-layer`]&&Array.isArray(i)&&i[0]===`coalesce`&&!i.find(e=>Array.isArray(e)&&e[1]===`name:abbr`)&&t.setLayoutProperty(n.id,`text-field`,r(n.source,e),{validate:!1})}}function r(e,t){return t!==`en`&&t!==`native`&&(t=o(t,i.TWO)),t===`native`?[`get`,`name`]:e.startsWith(`mc-base`)?[`coalesce`,[`get`,`name:${t}`],[`case`,[`has`,`name_is_latin`],[`get`,`name`],[`get`,`name:en`]]]:[`coalesce`,[`get`,`name:${t}`],[`get`,`name:en`],[`get`,`name`]]}var i=Object.freeze({THREE:`ISO 639-2/B`,API:`ISO 639-2/B`,TWO:`ISO 639-1`,MAPLIBRE_COMPAT:`ISO 639-1`,ENDONYM:`name`,NAME:`name`,LOCALE:`locale`,i18n:`locale`}),a=Object.freeze([{[i.TWO]:`en`,[i.THREE]:`eng`,[i.ENDONYM]:`English`,[i.LOCALE]:`en_GB`},{[i.TWO]:`da`,[i.THREE]:`dan`,[i.ENDONYM]:`Dansk`,[i.LOCALE]:`da_DK`},{[i.TWO]:`nl`,[i.THREE]:`dut`,[i.ENDONYM]:`Nederlands`,[i.LOCALE]:`nl_NL`},{[i.TWO]:`fi`,[i.THREE]:`fin`,[i.ENDONYM]:`Suomi`,[i.LOCALE]:`fi_FI`},{[i.TWO]:`fr`,[i.THREE]:`fre`,[i.ENDONYM]:`Francais`,[i.LOCALE]:`fr_FR`},{[i.TWO]:`de`,[i.THREE]:`ger`,[i.ENDONYM]:`Deutsch`,[i.LOCALE]:`de_DE`},{[i.TWO]:`it`,[i.THREE]:`ita`,[i.ENDONYM]:`Italiano`,[i.LOCALE]:`it_IT`},{[i.TWO]:`no`,[i.THREE]:`nor`,[i.ENDONYM]:`Norsk`,[i.LOCALE]:`nn_NO`},{[i.TWO]:`pl`,[i.THREE]:`pol`,[i.ENDONYM]:`Polski`,[i.LOCALE]:`pl_PL`},{[i.TWO]:`pt`,[i.THREE]:`por`,[i.ENDONYM]:`Portugues`,[i.LOCALE]:`pt_PT`},{[i.TWO]:`es`,[i.THREE]:`spa`,[i.ENDONYM]:`Espanol`,[i.LOCALE]:`es_ES`},{[i.TWO]:`sv`,[i.THREE]:`swe`,[i.ENDONYM]:`Svenska`,[i.LOCALE]:`sv_SE`},{[i.TWO]:`ja`,[i.THREE]:`jpn`,[i.ENDONYM]:`日本語`,[i.LOCALE]:`ja_JP`},{[i.TWO]:`zh`,[i.THREE]:`chi`,[i.ENDONYM]:`汉语`,[i.LOCALE]:`zh_CN`},{[i.TWO]:`ru`,[i.THREE]:`rus`,[i.ENDONYM]:`Русский`,[i.LOCALE]:`ru_RU`},{[i.TWO]:`uk`,[i.THREE]:`ukr`,[i.ENDONYM]:`Украї́нська`,[i.LOCALE]:`uk_UK`},{[i.TWO]:`lv`,[i.THREE]:`lav`,[i.ENDONYM]:`Latviešu valoda`,[i.LOCALE]:`lv-LV`},{[i.TWO]:`kk`,[i.THREE]:`kaz`,[i.ENDONYM]:`қазақша`,[i.LOCALE]:`kk-KZ`},{[i.TWO]:`ar`,[i.THREE]:`ara`,[i.ENDONYM]:`العربية`,[i.LOCALE]:`ar_SA`},{[i.TWO]:`native`,[i.THREE]:`native`,[i.ENDONYM]:`Native`,[i.LOCALE]:`native`}]);function o(e,t=i.MAPLIBRE_COMPAT){return(a.find(t=>Object.values(t).some(t=>t===e))??a[0])[t]}var s=/^\s*[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?\s*$/;function c(e){return e/180*Math.PI}function l(e){return e*180/Math.PI}function u(e,t){let n=Math.PI/180,r=e.lat*n,i=t.lat*n,a=Math.sin(r)*Math.sin(i)+Math.cos(r)*Math.cos(i)*Math.cos((t.lng-e.lng)*n);return 6371e3*Math.acos(Math.min(a,1))}function d(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}function f(e,t){return e.startsWith(`$`)?p(t[e.slice(1)]):e}function p(e){return typeof e==`string`?e:typeof e==`number`?String(e):typeof e==`boolean`?String(e).toUpperCase():typeof e==`object`&&e&&(e.t===`n`||e.t===`d`)?e.w??``:``}function m(e){return typeof e==`string`&&s.test(e)?Number(e):typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:typeof e==`object`&&e&&e.t===`n`?e.v:null}function h(e){return e=e.trim(),/^\$?[\w\-_]+$/.test(e)?e:(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([\w\-_]+)&?/.exec(e)||[])[1]}var g=72;function _(e,t,n){if(e===t)return n;let r={millimeter:1,centimeter:.1,meter:.001,kilometer:1e-6,foot:.00328084,mile:6.21371e-7,nauticalMile:5.39957e-7,inch:.0393701,pixel:.0393701*g,pica:.236222};return n/r[e]*r[t]}function v(e,t,n){return e+(t-e)*n}function y(e,t,n){return(n-e)/(t-e)}function b(e,t,n){return Math.max(Math.min(e,n),t)}function x(e){let t=e.split(``).map(e=>e.charCodeAt(0)).reduce((e,t)=>(e^=t,e+(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24)),2166136261);return t^=t<<3,t+=t>>5,t^=t<<4,t+=t>>17,t^=t<<25,t+=t>>6,`0000000${(t>>>0).toString(16)}`.substr(-8)}function S(e){let t=document.createElement(`div`);t.className=`adornment`;let{svg:n,scale:r=1}=e,i=new DOMParser().parseFromString(n,`image/svg+xml`).querySelector(`svg`);if(i){let e=new RegExp(s.toString().replace(/^\/\^|\$\/$/g,``).replace(/.*/,`^($&)[, ]($&)[, ]($&)[, ]($&)$$`)),n=i.getAttribute(`width`),a=i.getAttribute(`height`);if(n&&a&&s.test(n)&&s.test(a))i.setAttribute(`width`,String(Number(n)*r)),i.setAttribute(`height`,String(Number(a)*r));else{let t=e.exec(i.getAttribute(`viewBox`)),n=t?Number(t[3]):300,a=t?Number(t[4]):150;i.setAttribute(`width`,String(n*r)),i.setAttribute(`height`,String(a*r))}t.appendChild(i)}return t}function C(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function w(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function T(){}var E=.7,D=1/E,O=`\\s*([+-]?\\d+)\\s*`,k=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,A=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,j=/^#([0-9a-f]{3,8})$/,M=RegExp(`^rgb\\(${O},${O},${O}\\)$`),N=RegExp(`^rgb\\(${A},${A},${A}\\)$`),P=RegExp(`^rgba\\(${O},${O},${O},${k}\\)$`),ee=RegExp(`^rgba\\(${A},${A},${A},${k}\\)$`),te=RegExp(`^hsl\\(${k},${A},${A}\\)$`),F=RegExp(`^hsla\\(${k},${A},${A},${k}\\)$`),ne={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};C(T,se,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:re,formatHex:re,formatHex8:ie,formatHsl:ae,formatRgb:oe,toString:oe});function re(){return this.rgb().formatHex()}function ie(){return this.rgb().formatHex8()}function ae(){return be(this).formatHsl()}function oe(){return this.rgb().formatRgb()}function se(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=j.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ce(t):n===3?new fe(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?le(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?le(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=M.exec(e))?new fe(t[1],t[2],t[3],1):(t=N.exec(e))?new fe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=P.exec(e))?le(t[1],t[2],t[3],t[4]):(t=ee.exec(e))?le(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=te.exec(e))?ye(t[1],t[2]/100,t[3]/100,1):(t=F.exec(e))?ye(t[1],t[2]/100,t[3]/100,t[4]):ne.hasOwnProperty(e)?ce(ne[e]):e===`transparent`?new fe(NaN,NaN,NaN,0):null}function ce(e){return new fe(e>>16&255,e>>8&255,e&255,1)}function le(e,t,n,r){return r<=0&&(e=t=n=NaN),new fe(e,t,n,r)}function ue(e){return e instanceof T||(e=se(e)),e?(e=e.rgb(),new fe(e.r,e.g,e.b,e.opacity)):new fe}function de(e,t,n,r){return arguments.length===1?ue(e):new fe(e,t,n,r??1)}function fe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}C(fe,de,w(T,{brighter(e){return e=e==null?D:D**+e,new fe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?E:E**+e,new fe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new fe(_e(this.r),_e(this.g),_e(this.b),ge(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:pe,formatHex:pe,formatHex8:me,formatRgb:he,toString:he}));function pe(){return`#${ve(this.r)}${ve(this.g)}${ve(this.b)}`}function me(){return`#${ve(this.r)}${ve(this.g)}${ve(this.b)}${ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function he(){let e=ge(this.opacity);return`${e===1?`rgb(`:`rgba(`}${_e(this.r)}, ${_e(this.g)}, ${_e(this.b)}${e===1?`)`:`, ${e})`}`}function ge(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function _e(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ve(e){return e=_e(e),(e<16?`0`:``)+e.toString(16)}function ye(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Se(e,t,n,r)}function be(e){if(e instanceof Se)return new Se(e.h,e.s,e.l,e.opacity);if(e instanceof T||(e=se(e)),!e)return new Se;if(e instanceof Se)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Se(o,s,c,e.opacity)}function xe(e,t,n,r){return arguments.length===1?be(e):new Se(e,t,n,r??1)}function Se(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}C(Se,xe,w(T,{brighter(e){return e=e==null?D:D**+e,new Se(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?E:E**+e,new Se(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new fe(Te(e>=240?e-240:e+120,i,r),Te(e,i,r),Te(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Se(Ce(this.h),we(this.s),we(this.l),ge(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=ge(this.opacity);return`${e===1?`hsl(`:`hsla(`}${Ce(this.h)}, ${we(this.s)*100}%, ${we(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function Ce(e){return e=(e||0)%360,e<0?e+360:e}function we(e){return Math.max(0,Math.min(1,e||0))}function Te(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Ee=Math.PI/180,De=180/Math.PI,Oe=18,ke=.96422,Ae=1,je=.82521,Me=4/29,Ne=6/29,Pe=3*Ne*Ne,I=Ne*Ne*Ne;function Fe(e){if(e instanceof L)return new L(e.l,e.a,e.b,e.opacity);if(e instanceof Ue)return We(e);e instanceof fe||(e=ue(e));var t=Be(e.r),n=Be(e.g),r=Be(e.b),i=Le((.2225045*t+.7168786*n+.0606169*r)/Ae),a,o;return t===n&&n===r?a=o=i:(a=Le((.4360747*t+.3850649*n+.1430804*r)/ke),o=Le((.0139322*t+.0971045*n+.7141733*r)/je)),new L(116*i-16,500*(a-i),200*(i-o),e.opacity)}function Ie(e,t,n,r){return arguments.length===1?Fe(e):new L(e,t,n,r??1)}function L(e,t,n,r){this.l=+e,this.a=+t,this.b=+n,this.opacity=+r}C(L,Ie,w(T,{brighter(e){return new L(this.l+Oe*(e??1),this.a,this.b,this.opacity)},darker(e){return new L(this.l-Oe*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=ke*Re(t),e=Ae*Re(e),n=je*Re(n),new fe(ze(3.1338561*t-1.6168667*e-.4906146*n),ze(-.9787684*t+1.9161415*e+.033454*n),ze(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}}));function Le(e){return e>I?e**(1/3):e/Pe+Me}function Re(e){return e>Ne?e*e*e:Pe*(e-Me)}function ze(e){return 255*(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055)}function Be(e){return(e/=255)<=.04045?e/12.92:((e+.055)/1.055)**2.4}function Ve(e){if(e instanceof Ue)return new Ue(e.h,e.c,e.l,e.opacity);if(e instanceof L||(e=Fe(e)),e.a===0&&e.b===0)return new Ue(NaN,0<e.l&&e.l<100?0:NaN,e.l,e.opacity);var t=Math.atan2(e.b,e.a)*De;return new Ue(t<0?t+360:t,Math.sqrt(e.a*e.a+e.b*e.b),e.l,e.opacity)}function He(e,t,n,r){return arguments.length===1?Ve(e):new Ue(e,t,n,r??1)}function Ue(e,t,n,r){this.h=+e,this.c=+t,this.l=+n,this.opacity=+r}function We(e){if(isNaN(e.h))return new L(e.l,0,0,e.opacity);var t=e.h*Ee;return new L(e.l,Math.cos(t)*e.c,Math.sin(t)*e.c,e.opacity)}C(Ue,He,w(T,{brighter(e){return new Ue(this.h,this.c,this.l+Oe*(e??1),this.opacity)},darker(e){return new Ue(this.h,this.c,this.l-Oe*(e??1),this.opacity)},rgb(){return We(this).rgb()}}));var R=e=>()=>e;function Ge(e,t){return function(n){return e+n*t}}function Ke(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function qe(e,t){var n=t-e;return n?Ge(e,n>180||n<-180?n-360*Math.round(n/360):n):R(isNaN(e)?t:e)}function Je(e){return(e=+e)==1?z:function(t,n){return n-t?Ke(t,n,e):R(isNaN(t)?n:t)}}function z(e,t){var n=t-e;return n?Ge(e,n):R(isNaN(e)?t:e)}var B=(function e(t){var n=Je(t);function r(e,t){var r=n((e=de(e)).r,(t=de(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=z(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function V(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function Ye(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Xe(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=it(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function Ze(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function H(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Qe(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=it(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var $e=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,et=new RegExp($e.source,`g`);function tt(e){return function(){return e}}function nt(e){return function(t){return e(t)+``}}function rt(e,t){var n=$e.lastIndex=et.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=$e.exec(e))&&(i=et.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:H(r,i)})),n=et.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?nt(c[0].x):tt(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function it(e,t){var n=typeof t,r;return t==null||n===`boolean`?R(t):(n===`number`?H:n===`string`?(r=se(t))?(t=r,B):rt:t instanceof se?B:t instanceof Date?Ze:Ye(t)?V:Array.isArray(t)?Xe:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?Qe:H)(e,t)}function at(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}function ot(e){return function(t,n){var r=e((t=He(t)).h,(n=He(n)).h),i=z(t.c,n.c),a=z(t.l,n.l),o=z(t.opacity,n.opacity);return function(e){return t.h=r(e),t.c=i(e),t.l=a(e),t.opacity=o(e),t+``}}}var st=ot(qe);function ct(e,t){t===void 0&&(t=e,e=it);for(var n=0,r=t.length-1,i=t[0],a=Array(r<0?0:r);n<r;)a[n]=e(i,i=t[++n]);return function(e){var t=Math.max(0,Math.min(r-1,Math.floor(e*=r)));return a[t](e-t)}}function lt(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e(r/(t-1));return n}function ut(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function dt(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function ft(e){let t,n,r;e.length===2?(t=e===ut||e===dt?e:pt,n=e,r=e):(t=ut,n=(t,n)=>ut(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<0?i=t+1:a=t}while(i<a)}return i}function a(e,r,i=0,a=e.length){if(i<a){if(t(r,r)!==0)return a;do{let t=i+a>>>1;n(e[t],r)<=0?i=t+1:a=t}while(i<a)}return i}function o(e,t,n=0,a=e.length){let o=i(e,t,n,a-1);return o>n&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function pt(){return 0}function mt(e){return e===null?NaN:+e}var ht=ft(ut),gt=ht.right;ht.left,ft(mt).center;function _t(e,t){let n,r;if(t===void 0)for(let t of e)t!=null&&(n===void 0?t>=t&&(n=r=t):(n>t&&(n=t),r<t&&(r=t)));else{let i=-1;for(let a of e)(a=t(a,++i,e))!=null&&(n===void 0?a>=a&&(n=r=a):(n>a&&(n=a),r<a&&(r=a)))}return[n,r]}var vt=class{constructor(){this._partials=new Float64Array(32),this._n=0}add(e){let t=this._partials,n=0;for(let r=0;r<this._n&&r<32;r++){let i=t[r],a=e+i,o=Math.abs(e)<Math.abs(i)?e-(a-i):i-(a-e);o&&(t[n++]=o),e=a}return t[n]=e,this._n=n+1,this}valueOf(){let e=this._partials,t=this._n,n,r,i,a=0;if(t>0){for(a=e[--t];t>0&&(n=a,r=e[--t],a=n+r,i=r-(a-n),!i););t>0&&(i<0&&e[t-1]<0||i>0&&e[t-1]>0)&&(r=i*2,n=a+r,r==n-a&&(a=n))}return a}},yt=class extends Map{constructor(e,t=Ct){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(bt(this,e))}has(e){return super.has(bt(this,e))}set(e,t){return super.set(xt(this,e),t)}delete(e){return super.delete(St(this,e))}};function bt({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function xt({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function St({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Ct(e){return typeof e==`object`&&e?e.valueOf():e}var wt=Math.sqrt(50),Tt=Math.sqrt(10),Et=Math.sqrt(2);function Dt(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=wt?10:a>=Tt?5:a>=Et?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/l<e&&++s,c/l>t&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*l<e&&++s,c*l>t&&--c),c<s&&.5<=n&&n<2?Dt(e,t,n*2):[s,c,l]}function Ot(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];let r=t<e,[i,a,o]=r?Dt(t,e,n):Dt(e,t,n);if(!(a>=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e<s;++e)c[e]=(a-e)/-o;else for(let e=0;e<s;++e)c[e]=(a-e)*o;else if(o<0)for(let e=0;e<s;++e)c[e]=(i+e)/-o;else for(let e=0;e<s;++e)c[e]=(i+e)*o;return c}function kt(e,t,n){return t=+t,e=+e,n=+n,Dt(e,t,n)[2]}function At(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?kt(t,e,n):kt(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function jt(e,t,n=mt){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function*Mt(e){for(let t of e)yield*t}function Nt(e){return Array.from(Mt(e))}function Pt(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r<i;)a[r]=e+r*n;return a}function U(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var Ft=Symbol(`implicit`);function It(){var e=new yt,t=[],n=[],r=Ft;function i(i){let a=e.get(i);if(a===void 0){if(r!==Ft)return r;e.set(i,a=t.push(i)-1)}return n[a%n.length]}return i.domain=function(n){if(!arguments.length)return t.slice();t=[],e=new yt;for(let r of n)e.has(r)||e.set(r,t.push(r)-1);return i},i.range=function(e){return arguments.length?(n=Array.from(e),i):n.slice()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return It(t,n).unknown(r)},U.apply(i,arguments),i}function Lt(e){return function(){return e}}function Rt(e){return+e}var zt=[0,1];function Bt(e){return e}function Vt(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Lt(isNaN(t)?NaN:.5)}function Ht(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function Ut(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=Vt(i,r),a=n(o,a)):(r=Vt(r,i),a=n(a,o)),function(e){return a(r(e))}}function Wt(e,t,n){var r=Math.min(e.length,t.length)-1,i=Array(r),a=Array(r),o=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<r;)i[o]=Vt(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=gt(e,t,1,r)-1;return a[n](i[n](t))}}function Gt(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Kt(){var e=zt,t=zt,n=it,r,i,a,o=Bt,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==Bt&&(o=Ht(e[0],e[n-1])),s=n>2?Wt:Ut,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),H))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,Rt),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=at,u()},d.clamp=function(e){return arguments.length?(o=e?!0:Bt,u()):o!==Bt},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function qt(){return Kt()(Bt,Bt)}function Jt(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function Yt(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function W(e){return e=Yt(Math.abs(e)),e?e[1]:NaN}function G(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function Xt(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var K=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Zt(e){if(!(t=K.exec(e)))throw Error(`invalid format: `+e);var t;return new Qt({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Zt.prototype=Qt.prototype;function Qt(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}Qt.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function $t(e){out:for(var t=e.length,n=1,r=-1,i;n<t;++n)switch(e[n]){case`.`:r=i=n;break;case`0`:r===0&&(r=n),i=n;break;default:if(!+e[n])break out;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var en;function tn(e,t){var n=Yt(e,t);if(!n)return en=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(en=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+Yt(e,Math.max(0,t+a-1))[0]}function nn(e,t){var n=Yt(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var rn={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:Jt,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>nn(e*100,t),r:nn,s:tn,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function an(e){return e}var on=Array.prototype.map,sn=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function cn(e){var t=e.grouping===void 0||e.thousands===void 0?an:G(on.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?an:Xt(on.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=Zt(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):rn[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=rn[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=$t(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&en!==void 0?sn[8+en/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++o<l;)if(p=e.charCodeAt(o),48>p||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T<h?Array(h-T+1).join(u):``;switch(g&&m&&(e=t(E+e,E.length?h-r.length:1/0),E=``),d){case`<`:e=n+e+r+E;break;case`=`:e=n+E+e+r;break;case`^`:e=E.slice(0,T=E.length>>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(W(t)/3)))*3,r=10**-n,i=l((e=Zt(e),e.type=`f`,e),{suffix:sn[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var ln,un,dn;fn({thousands:`,`,grouping:[3],currency:[`$`,``]});function fn(e){return ln=cn(e),un=ln.format,dn=ln.formatPrefix,ln}function pn(e){return Math.max(0,-W(Math.abs(e)))}function mn(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(W(t)/3)))*3-W(Math.abs(e)))}function hn(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,W(t)-W(e))+1}function gn(e,t,n,r){var i=At(e,t,n),a;switch(r=Zt(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=mn(i,o))&&(r.precision=a),dn(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=hn(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=pn(i))&&(r.precision=a-(r.type===`%`)*2);break}return un(r)}function _n(e){var t=e.domain;return e.ticks=function(e){var n=t();return Ot(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return gn(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s<o&&(l=o,o=s,s=l,l=i,i=a,a=l);u-- >0;){if(l=kt(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function vn(){var e=qt();return e.copy=function(){return Gt(e,vn())},U.apply(e,arguments),_n(e)}function yn(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r<i;)n[r-1]=jt(e,r/i);return a}function a(e){return e==null||isNaN(e=+e)?r:t[gt(n,e)]}return a.invertExtent=function(r){var i=t.indexOf(r);return i<0?[NaN,NaN]:[i>0?n[i-1]:e[0],i<n.length?n[i]:e[e.length-1]]},a.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)n!=null&&!isNaN(n=+n)&&e.push(n);return e.sort(ut),i()},a.range=function(e){return arguments.length?(t=Array.from(e),i()):t.slice()},a.unknown=function(e){return arguments.length?(r=e,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return yn().domain(e).range(t).unknown(r)},U.apply(a,arguments)}function bn(){var e=0,t=1,n=1,r=[.5],i=[0,1],a;function o(e){return e!=null&&e<=e?i[gt(r,e,0,n)]:a}function s(){var i=-1;for(r=Array(n);++i<n;)r[i]=((i+1)*t-(i-n)*e)/(n+1);return o}return o.domain=function(n){return arguments.length?([e,t]=n,e=+e,t=+t,s()):[e,t]},o.range=function(e){return arguments.length?(n=(i=Array.from(e)).length-1,s()):i.slice()},o.invertExtent=function(a){var o=i.indexOf(a);return o<0?[NaN,NaN]:o<1?[e,r[0]]:o>=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return bn().domain([e,t]).range(i).unknown(a)},U.apply(_n(o),arguments)}var xn=6371008.8;xn*100,xn*100,360/(2*Math.PI),xn*3.28084,xn*39.37,xn/1e3,xn/1e3,xn/1609.344,xn*1e3,xn*1e3,xn/1852,xn*1.0936;function Sn(e,t,n={}){let r={type:`Feature`};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=t||{},r.geometry=e,r}function Cn(e,t,n={}){for(let t of e){if(t.length<4)throw Error(`Each LinearRing of a Polygon must have 4 or more Positions.`);if(t[t.length-1].length!==t[0].length)throw Error(`First and last Position are not equivalent.`);for(let e=0;e<t[t.length-1].length;e++)if(t[t.length-1][e]!==t[0][e])throw Error(`First and last Position are not equivalent.`)}return Sn({type:`Polygon`,coordinates:e},t,n)}function wn(e,t,n={}){if(e.length<2)throw Error(`coordinates must be an array of two or more positions`);return Sn({type:`LineString`,coordinates:e},t,n)}function Tn(e,t={}){let n={type:`FeatureCollection`};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=e,n}function En(e,t,n={}){return Sn({type:`MultiLineString`,coordinates:e},t,n)}function Dn(e,t,n={}){return Sn({type:`MultiPolygon`,coordinates:e},t,n)}function On(e,t,n){if(e!==null)for(var r,i,a,o,s,c,l,u=0,d=0,f,p=e.type,m=p===`FeatureCollection`,h=p===`Feature`,g=m?e.features.length:1,_=0;_<g;_++){l=m?e.features[_].geometry:h?e.geometry:e,f=l?l.type===`GeometryCollection`:!1,s=f?l.geometries.length:1;for(var v=0;v<s;v++){var y=0,b=0;if(o=f?l.geometries[v]:l,o!==null){c=o.coordinates;var x=o.type;switch(u=n&&(x===`Polygon`||x===`MultiPolygon`)?1:0,x){case null:break;case`Point`:if(t(c,d,_,y,b)===!1)return!1;d++,y++;break;case`LineString`:case`MultiPoint`:for(r=0;r<c.length;r++){if(t(c[r],d,_,y,b)===!1)return!1;d++,x===`MultiPoint`&&y++}x===`LineString`&&y++;break;case`Polygon`:case`MultiLineString`:for(r=0;r<c.length;r++){for(i=0;i<c[r].length-u;i++){if(t(c[r][i],d,_,y,b)===!1)return!1;d++}x===`MultiLineString`&&y++,x===`Polygon`&&b++}x===`Polygon`&&y++;break;case`MultiPolygon`:for(r=0;r<c.length;r++){for(b=0,i=0;i<c[r].length;i++){for(a=0;a<c[r][i].length-u;a++){if(t(c[r][i][a],d,_,y,b)===!1)return!1;d++}b++}y++}break;case`GeometryCollection`:for(r=0;r<o.geometries.length;r++)if(On(o.geometries[r],t,n)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}}}}function kn(e,t){var n,r,i,a,o,s,c,l,u,d,f=0,p=e.type===`FeatureCollection`,m=e.type===`Feature`,h=p?e.features.length:1;for(n=0;n<h;n++){for(s=p?e.features[n].geometry:m?e.geometry:e,l=p?e.features[n].properties:m?e.properties:{},u=p?e.features[n].bbox:m?e.bbox:void 0,d=p?e.features[n].id:m?e.id:void 0,c=s?s.type===`GeometryCollection`:!1,o=c?s.geometries.length:1,i=0;i<o;i++){if(a=c?s.geometries[i]:s,a===null){if(t(null,f,l,u,d)===!1)return!1;continue}switch(a.type){case`Point`:case`LineString`:case`MultiPoint`:case`Polygon`:case`MultiLineString`:case`MultiPolygon`:if(t(a,f,l,u,d)===!1)return!1;break;case`GeometryCollection`:for(r=0;r<a.geometries.length;r++)if(t(a.geometries[r],f,l,u,d)===!1)return!1;break;default:throw Error(`Unknown Geometry Type`)}}f++}}function An(e,t,n){var r=n;return kn(e,function(e,i,a,o,s){r=i===0&&n===void 0?e:t(r,e,i,a,o,s)}),r}function jn(e,t){t||={},t.iterations=t.iterations||1;let{iterations:n}=t,r=[];if(!e)throw Error(`inputPolys is required`);return kn(e,function(e,t,i){if(e.type===`Polygon`){let t=[[]];for(let r=0;r<n;r++){let n=[],i=e;r>0&&(i=Cn(t).geometry),Mn(i,n),t=n.slice(0)}r.push(Cn(t,i))}else if(e.type===`MultiPolygon`){let t=[[[]]];for(let r=0;r<n;r++){let n=[],i=e;r>0&&(i=Dn(t).geometry),Nn(i,n),t=n.slice(0)}r.push(Dn(t,i))}else throw Error(`geometry is invalid, must be Polygon or MultiPolygon`)}),Tn(r)}function Mn(e,t){var n,r;On(e,function(e,i,a,o,s){if(r!==s)t.push([]);else{var c=n[0],l=n[1],u=e[0],d=e[1];t[s].push([.75*c+.25*u,.75*l+.25*d]),t[s].push([.25*c+.75*u,.25*l+.75*d])}n=e,r=s},!1),t.forEach(function(e){e.push(e[0])})}function Nn(e,t){let n,r,i;On(e,function(e,a,o,s,c){if(r!==s)t.push([[]]);else if(i!==c)t[s].push([]);else{var l=n[0],u=n[1],d=e[0],f=e[1];t[s][c].push([.75*l+.25*d,.75*u+.25*f]),t[s][c].push([.25*l+.75*d,.25*u+.75*f])}n=e,r=s,i=c},!1),t.forEach(function(e){e.forEach(function(e){e.push(e[0])})})}function Pn(e){return e.type===`Feature`?e.geometry:e}function Fn(e,t,n){var r=e.length,i=Rn(e[0],t),a=[],o,s,c;let l,u;for(n||=[],o=1;o<r;o++){for(l=e[o-1],u=e[o],s=c=Rn(u,t);;)if(!(i|s)){a.push(l),s===c?o===r-1&&a.push(u):(a.push(u),o<r-1&&(n.push(a),a=[]));break}else if(i&s)break;else i?(l=Ln(l,u,i,t),i=Rn(l,t)):(u=Ln(l,u,s,t),s=Rn(u,t));i=c}return a.length&&n.push(a),n}function In(e,t){var n,r,i,a,o,s,c;for(r=1;r<=8;r*=2){for(n=[],i=e[e.length-1],a=!(Rn(i,t)&r),o=0;o<e.length;o++)s=e[o],c=!(Rn(s,t)&r),c!==a&&n.push(Ln(i,s,r,t)),c&&n.push(s),i=s,a=c;if(e=n,!e.length)break}return n}function Ln(e,t,n,r){return n&8?[e[0]+(t[0]-e[0])*(r[3]-e[1])/(t[1]-e[1]),r[3]]:n&4?[e[0]+(t[0]-e[0])*(r[1]-e[1])/(t[1]-e[1]),r[1]]:n&2?[r[2],e[1]+(t[1]-e[1])*(r[2]-e[0])/(t[0]-e[0])]:n&1?[r[0],e[1]+(t[1]-e[1])*(r[0]-e[0])/(t[0]-e[0])]:null}function Rn(e,t){var n=0;return e[0]<t[0]?n|=1:e[0]>t[2]&&(n|=2),e[1]<t[1]?n|=4:e[1]>t[3]&&(n|=8),n}function zn(e,t){let n=Pn(e),r=n.type,i=e.type===`Feature`?e.properties:{},a=n.coordinates;switch(r){case`LineString`:case`MultiLineString`:{let e=[];return r===`LineString`&&(a=[a]),a.forEach(n=>{Fn(n,t,e)}),e.length===1?wn(e[0],i):En(e,i)}case`Polygon`:return Cn(Bn(a,t),i);case`MultiPolygon`:return Dn(a.map(e=>Bn(e,t)),i);default:throw Error(`geometry `+r+` not supported`)}}function Bn(e,t){let n=[];for(let r of e){let e=In(r,t);e.length>0&&((e[0][0]!==e[e.length-1][0]||e[0][1]!==e[e.length-1][1])&&e.push(e[0]),e.length>=4&&n.push(e))}return n}var Vn=zn;function Hn(e,t){let n=[],r=Math.PI*2/100;for(let i=0;i<100;i++)n.push(Wn(e,t,i*r));if(Gn(e,t)){let e=n[0],t=n[n.length-1],r=(t[0]+e[0]-360)/2,i=(e[1]+t[1])/2;n.push([r,i]),n.push([r,90]),n.push([r+360,90]),n.push([r+360,i])}if(Kn(e,t)){let e=n[49],t=n[50],r=(t[0]+e[0]-360)/2,i=(e[1]+t[1])/2;n.splice(50,0,[r+360,i],[r+360,-90],[r,-90],[r,i])}return n.push(n[0]),n}function Un(e,t,n){let r=[],i=t/100;for(let t=0;t<=100;t++)r.push(Wn(e,t*i,c(n)));return Vn(wn(r),[-1/0,-85.051129,1/0,85.051129]).geometry.coordinates}function Wn(e,t,n){let r=t/6378.1,i=c(e.lng),a=c(e.lat),o=Math.asin(Math.sin(a)*Math.cos(r)+Math.cos(a)*Math.sin(r)*Math.cos(n));return[l(i+Math.atan2(Math.sin(n)*Math.sin(r)*Math.cos(a),Math.cos(r)-Math.sin(a)*Math.sin(o))),l(o)]}function Gn(e,t){return u(e,{lng:0,lat:90})/1e3<t}function Kn(e,t){return u(e,{lng:0,lat:-90})/1e3<t}function qn(e){let{polygonType:t}=e,n=typeof e.anchorPoints?.[0]?.[0]==`number`?[e.anchorPoints]:e.anchorPoints;return t===`smooth`?jn(Cn(n),{iterations:4}).features?.[0]?.geometry?.coordinates??n.slice():n.slice()}function Jn(e,t){return`${e}-${x(`${t.vectorUrl}/${t.sourceLayerId}`)}`}function Yn(e){return`custom-area-${x(e.vectorUrl)}`}function Xn(e,t){return e.reduce((e,n)=>{let r=n.dataBindings?.[t];return typeof r==`object`&&r&&r.t===`n`?e.push(r.v):typeof r==`number`?e.push(r):typeof r==`string`&&r&&e.push(s.test(r)?Number(r):r),e},[])}function Zn(e,t){let n=e.length;if(n<2)return 0;let r=t.projectWithScaleCorrection(e[n-1]),i=t.projectWithScaleCorrection(e[n-2]),a=r.x-i.x,o=i.y-r.y;return(90-180/Math.PI*Math.atan2(o,a)+360)%360}var Qn=[[`#EDF8E9`,`#BAE4B3`,`#74C476`,`#31A354`,`#006D2C`],[`#EFF3FF`,`#BDD7E7`,`#6BAED6`,`#3182BD`,`#08519C`],[`#F0F9E8`,`#BAE4BC`,`#7BCCC4`,`#43A2CA`,`#0868AC`],[`#EDF8FB`,`#B3CDE3`,`#8C96C6`,`#8856A7`,`#810F7C`],[`#FEF0D9`,`#FDCC8A`,`#FC8D59`,`#E34A33`,`#B30000`],[`#FEEBE2`,`#FBB4B9`,`#F768A1`,`#C51B8A`,`#7A0177`],[`#D7191C`,`#FDAE61`,`#FFFFBF`,`#ABDDA4`,`#2B83BA`],[`#7B3294`,`#C2A5CF`,`#F7F7F7`,`#A6DBA0`,`#008837`]],$n=[],er=[/transparent/,/#[0-9a-fA-F]{3,4}/,/#[0-9a-fA-F]{6}/,/#[0-9a-fA-F]{8}/,/rgba?\(\s*(?:(?:\d{1,3}%?|none)\s*,\s*){2}(?:\d{1,3}%?|none)(?:\s*,\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/,/rgba?\(\s*(?:\d{1,3}%?|none)\s+(?:\d{1,3}%?|none)\s+(?:\d{1,3}%?|none)(?:\s*\/\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/,/hsla?\(\s*(?:[+-]?\d*\.?\d+(?:deg|grad|rad|turn)?|none)\s*,\s*(?:\d{1,3}%|none)\s*,\s*(?:\d{1,3}%|none)(?:\s*,\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/,/hsla?\(\s*(?:[+-]?\d*\.?\d+(?:deg|grad|rad|turn)?|none)\s+(?:\d{1,3}%|none)\s+(?:\d{1,3}%|none)(?:\s*\/\s*(?:0|1|0?\.\d+|\d+%|none))?\s*\)/].map(e=>e.toString().replace(/^\/|\/$/g,``)).join(`|`),tr=RegExp(`^\\s*(${er})\\s*$`);function nr(e,t){let[n,r]=_t(e),i=t.length;return Pt(i).map(e=>n+e*(r-n)/(i-1))}var rr={linear:(e,t)=>vn(nr(e,t),t).interpolate(st).nice(4),quantile:(e,t)=>yn(e,t),quantize:(e,t)=>bn(_t(e),t).nice(),categorical:(e,t)=>It(e,t)};function ir(e){if(e.choropleth){let t=ar(e),n=cr(e.fillColor);if(t&&n){let{choropleth:r}=e,i=r.categoricalColors[n],a=r.colorMode===`categorical`?t.map(e=>i.values[e]):or(r.lowerColor,r.upperColor,r.colorMode===`linear`?void 0:r.colorCount);return rr[r.colorMode](t,a)}}}function ar(e){if(e.choropleth){let t=e.fillColor?.match(/\$\{([^}]+)}/)?.[1];if(t){let n=Xn(Object.values(e.models),t);if(!n.length||n.some(e=>typeof e!=`string`||!tr.test(e)))return e.choropleth.colorMode===`categorical`?Array.from(new Set(n)):n}}}function or(e,t,n){let r=Qn.find(n=>n[0]===e&&n[n.length-1]===t)??$n.find(n=>n[0]===e&&n[n.length-1]===t);return r?lt(ct(st,r),n??r.length):lt(st(e,t),n??2)}function sr(e,t){let n=t?Xn(e,t):void 0;return n?.length?n.every(e=>typeof e==`number`)?`number`:n.every(e=>typeof e==`string`&&tr.test(e))?`color`:`string`:void 0}function cr(e){return e?.match(/\$\{([^}]+)}/)?.[1]}function lr(e){let t=Object.create(null);for(let n in e){let r=e[n];t[r]=r in t?null:n}return t}function ur(e,t){let n=t?sr(e,t):void 0;return n!==void 0&&n!==`color`}function dr(){return navigator.userAgent.toLowerCase().indexOf(`mobile`)>=0}function fr(){return window.InstallTrigger!==void 0}(function(){var e=function(e){return e.map(function(e){return{type:e.type,values:Array.prototype.slice.call(e.values)}})},t=function(e){var t=[],n=null,r=null,i=null,a=null;return e.forEach(function(e){var o=e.type;if(o===`M`){var s=e.values[0],c=e.values[1];t.push({type:`M`,values:[s,c]}),i=s,a=c,n=s,r=c}else if(o===`m`){var s=n+e.values[0],c=r+e.values[1];t.push({type:`M`,values:[s,c]}),i=s,a=c,n=s,r=c}else if(o===`L`){var s=e.values[0],c=e.values[1];t.push({type:`L`,values:[s,c]}),n=s,r=c}else if(o===`l`){var s=n+e.values[0],c=r+e.values[1];t.push({type:`L`,values:[s,c]}),n=s,r=c}else if(o===`C`){var l=e.values[0],u=e.values[1],d=e.values[2],f=e.values[3],s=e.values[4],c=e.values[5];t.push({type:`C`,values:[l,u,d,f,s,c]}),n=s,r=c}else if(o===`c`){var l=n+e.values[0],u=r+e.values[1],d=n+e.values[2],f=r+e.values[3],s=n+e.values[4],c=r+e.values[5];t.push({type:`C`,values:[l,u,d,f,s,c]}),n=s,r=c}else if(o===`Q`){var l=e.values[0],u=e.values[1],s=e.values[2],c=e.values[3];t.push({type:`Q`,values:[l,u,s,c]}),n=s,r=c}else if(o===`q`){var l=n+e.values[0],u=r+e.values[1],s=n+e.values[2],c=r+e.values[3];t.push({type:`Q`,values:[l,u,s,c]}),n=s,r=c}else if(o===`A`){var s=e.values[5],c=e.values[6];t.push({type:`A`,values:[e.values[0],e.values[1],e.values[2],e.values[3],e.values[4],s,c]}),n=s,r=c}else if(o===`a`){var s=n+e.values[5],c=r+e.values[6];t.push({type:`A`,values:[e.values[0],e.values[1],e.values[2],e.values[3],e.values[4],s,c]}),n=s,r=c}else if(o===`H`){var s=e.values[0];t.push({type:`H`,values:[s]}),n=s}else if(o===`h`){var s=n+e.values[0];t.push({type:`H`,values:[s]}),n=s}else if(o===`V`){var c=e.values[0];t.push({type:`V`,values:[c]}),r=c}else if(o===`v`){var c=r+e.values[0];t.push({type:`V`,values:[c]}),r=c}else if(o===`S`){var d=e.values[0],f=e.values[1],s=e.values[2],c=e.values[3];t.push({type:`S`,values:[d,f,s,c]}),n=s,r=c}else if(o===`s`){var d=n+e.values[0],f=r+e.values[1],s=n+e.values[2],c=r+e.values[3];t.push({type:`S`,values:[d,f,s,c]}),n=s,r=c}else if(o===`T`){var s=e.values[0],c=e.values[1];t.push({type:`T`,values:[s,c]}),n=s,r=c}else if(o===`t`){var s=n+e.values[0],c=r+e.values[1];t.push({type:`T`,values:[s,c]}),n=s,r=c}else (o===`Z`||o===`z`)&&(t.push({type:`Z`,values:[]}),n=i,r=a)}),t},n=function(e){var t=[],n=null,i=null,a=null,o=null,s=null,c=null,l=null;return e.forEach(function(e){if(e.type===`M`){var u=e.values[0],d=e.values[1];t.push({type:`M`,values:[u,d]}),c=u,l=d,o=u,s=d}else if(e.type===`C`){var f=e.values[0],p=e.values[1],m=e.values[2],h=e.values[3],u=e.values[4],d=e.values[5];t.push({type:`C`,values:[f,p,m,h,u,d]}),i=m,a=h,o=u,s=d}else if(e.type===`L`){var u=e.values[0],d=e.values[1];t.push({type:`L`,values:[u,d]}),o=u,s=d}else if(e.type===`H`){var u=e.values[0];t.push({type:`L`,values:[u,s]}),o=u}else if(e.type===`V`){var d=e.values[0];t.push({type:`L`,values:[o,d]}),s=d}else if(e.type===`S`){var m=e.values[0],h=e.values[1],u=e.values[2],d=e.values[3],g,_;n===`C`||n===`S`?(g=o+(o-i),_=s+(s-a)):(g=o,_=s),t.push({type:`C`,values:[g,_,m,h,u,d]}),i=m,a=h,o=u,s=d}else if(e.type===`T`){var u=e.values[0],d=e.values[1],f,p;n===`Q`||n===`T`?(f=o+(o-i),p=s+(s-a)):(f=o,p=s);var g=o+2*(f-o)/3,_=s+2*(p-s)/3,v=u+2*(f-u)/3,y=d+2*(p-d)/3;t.push({type:`C`,values:[g,_,v,y,u,d]}),i=f,a=p,o=u,s=d}else if(e.type===`Q`){var f=e.values[0],p=e.values[1],u=e.values[2],d=e.values[3],g=o+2*(f-o)/3,_=s+2*(p-s)/3,v=u+2*(f-u)/3,y=d+2*(p-d)/3;t.push({type:`C`,values:[g,_,v,y,u,d]}),i=f,a=p,o=u,s=d}else if(e.type===`A`){var b=Math.abs(e.values[0]),x=Math.abs(e.values[1]),S=e.values[2],C=e.values[3],w=e.values[4],u=e.values[5],d=e.values[6];b===0||x===0?(t.push({type:`C`,values:[o,s,u,d,u,d]}),o=u,s=d):(o!==u||s!==d)&&(r(o,s,u,d,b,x,S,C,w).forEach(function(e){t.push({type:`C`,values:e})}),o=u,s=d)}else e.type===`Z`&&(t.push(e),o=c,s=l);n=e.type}),t},r=function(e,t,n,i,a,o,s,c,l,u){var d=function(e){return Math.PI*e/180},f=function(e,t,n){return{x:e*Math.cos(n)-t*Math.sin(n),y:e*Math.sin(n)+t*Math.cos(n)}},p=d(s),m=[],h,g,_,v;if(u)h=u[0],g=u[1],_=u[2],v=u[3];else{var y=f(e,t,-p);e=y.x,t=y.y;var b=f(n,i,-p);n=b.x,i=b.y;var x=(e-n)/2,S=(t-i)/2,C=x*x/(a*a)+S*S/(o*o);C>1&&(C=Math.sqrt(C),a=C*a,o=C*o);var w=c===l?-1:1,T=a*a,E=o*o,D=T*E-T*S*S-E*x*x,O=T*S*S+E*x*x,k=w*Math.sqrt(Math.abs(D/O));_=k*a*S/o+(e+n)/2,v=k*-o*x/a+(t+i)/2,h=Math.asin(parseFloat(((t-v)/o).toFixed(9))),g=Math.asin(parseFloat(((i-v)/o).toFixed(9))),e<_&&(h=Math.PI-h),n<_&&(g=Math.PI-g),h<0&&(h=Math.PI*2+h),g<0&&(g=Math.PI*2+g),l&&h>g&&(h-=Math.PI*2),!l&&g>h&&(g-=Math.PI*2)}var A=g-h;if(Math.abs(A)>Math.PI*120/180){var j=g,M=n,N=i;g=l&&g>h?h+Math.PI*120/180*1:h+Math.PI*120/180*-1,n=_+a*Math.cos(g),i=v+o*Math.sin(g),m=r(n,i,M,N,a,o,s,0,l,[g,j,_,v])}A=g-h;var P=Math.cos(h),ee=Math.sin(h),te=Math.cos(g),F=Math.sin(g),ne=Math.tan(A/4),re=4/3*a*ne,ie=4/3*o*ne,ae=[e,t],oe=[e+re*ee,t-ie*P],se=[n+re*F,i-ie*te],ce=[n,i];if(oe[0]=2*ae[0]-oe[0],oe[1]=2*ae[1]-oe[1],u)return[oe,se,ce].concat(m);m=[oe,se,ce].concat(m);for(var le=[],ue=0;ue<m.length;ue+=3){var a=f(m[ue][0],m[ue][1],p),o=f(m[ue+1][0],m[ue+1][1],p),de=f(m[ue+2][0],m[ue+2][1],p);le.push([a.x,a.y,o.x,o.y,de.x,de.y])}return le};let i=SVGPathElement.prototype.getPathData!==void 0&&SVGPathElement.prototype.setPathData!==void 0;if(i)try{document.createElementNS(`http://www.w3.org/2000/svg`,`path`).setPathData([{type:`M`,values:[0,0]}])}catch{i=!1}if(i===!1){var a={Z:`Z`,M:`M`,L:`L`,C:`C`,Q:`Q`,A:`A`,H:`H`,V:`V`,S:`S`,T:`T`,z:`Z`,m:`m`,l:`l`,c:`c`,q:`q`,a:`a`,h:`h`,v:`v`,s:`s`,t:`t`},o=function(e){this._string=e,this._currentIndex=0,this._endIndex=this._string.length,this._prevCommand=null,this._skipOptionalSpaces()},s=window.navigator.userAgent.indexOf(`MSIE `)!==-1;o.prototype={parseSegment:function(){var e=this._string[this._currentIndex],t=a[e]?a[e]:null;if(t===null){if(this._prevCommand===null||(t=(e===`+`||e===`-`||e===`.`||e>=`0`&&e<=`9`)&&this._prevCommand!==`Z`?this._prevCommand===`M`?`L`:this._prevCommand===`m`?`l`:this._prevCommand:null,t===null))return null}else this._currentIndex+=1;this._prevCommand=t;var n=null,r=t.toUpperCase();return r===`H`||r===`V`?n=[this._parseNumber()]:r===`M`||r===`L`||r===`T`?n=[this._parseNumber(),this._parseNumber()]:r===`S`||r===`Q`?n=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:r===`C`?n=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseNumber()]:r===`A`?n=[this._parseNumber(),this._parseNumber(),this._parseNumber(),this._parseArcFlag(),this._parseArcFlag(),this._parseNumber(),this._parseNumber()]:r===`Z`&&(this._skipOptionalSpaces(),n=[]),n===null||n.indexOf(null)>=0?null:{type:t,values:n}},hasMoreData:function(){return this._currentIndex<this._endIndex},peekSegmentType:function(){var e=this._string[this._currentIndex];return a[e]?a[e]:null},initialCommandIsMoveTo:function(){if(!this.hasMoreData())return!0;var e=this.peekSegmentType();return e===`M`||e===`m`},_isCurrentSpace:function(){var e=this._string[this._currentIndex];return e<=` `&&(e===` `||e===`
|
|
689
|
-
`||e===` `||e===`\r`||e===`\f`)},_skipOptionalSpaces:function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex+=1;return this._currentIndex<this._endIndex},_skipOptionalSpacesOrDelimiter:function(){return this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&this._string[this._currentIndex]!==`,`?!1:(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`,`&&(this._currentIndex+=1,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},_parseNumber:function(){var e=0,t=0,n=1,r=0,i=1,a=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`+`?this._currentIndex+=1:this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`-`&&(this._currentIndex+=1,i=-1),this._currentIndex===this._endIndex||(this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)&&this._string[this._currentIndex]!==`.`)return null;for(var s=this._currentIndex;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)this._currentIndex+=1;if(this._currentIndex!==s)for(var c=this._currentIndex-1,l=1;c>=s;)t+=l*(this._string[c]-`0`),--c,l*=10;if(this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`.`){if(this._currentIndex+=1,this._currentIndex>=this._endIndex||this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)n*=10,r+=(this._string.charAt(this._currentIndex)-`0`)/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1<this._endIndex&&(this._string[this._currentIndex]===`e`||this._string[this._currentIndex]===`E`)&&this._string[this._currentIndex+1]!==`x`&&this._string[this._currentIndex+1]!==`m`){if(this._currentIndex+=1,this._string[this._currentIndex]===`+`?this._currentIndex+=1:this._string[this._currentIndex]===`-`&&(this._currentIndex+=1,a=-1),this._currentIndex>=this._endIndex||this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)e*=10,e+=this._string[this._currentIndex]-`0`,this._currentIndex+=1}var u=t+r;return u*=i,e&&(u*=10**(a*e)),o===this._currentIndex?null:(this._skipOptionalSpacesOrDelimiter(),u)},_parseArcFlag:function(){if(this._currentIndex>=this._endIndex)return null;var e=null,t=this._string[this._currentIndex];if(this._currentIndex+=1,t===`0`)e=0;else if(t===`1`)e=1;else return null;return this._skipOptionalSpacesOrDelimiter(),e}};var c=function(e){if(!e||e.length===0)return[];var t=new o(e),n=[];if(t.initialCommandIsMoveTo())for(;t.hasMoreData();){var r=t.parseSegment();if(r===null)break;n.push(r)}return n},l=SVGPathElement.prototype.setAttribute,u=SVGPathElement.prototype.setAttributeNS,d=SVGPathElement.prototype.removeAttribute,f=SVGPathElement.prototype.removeAttributeNS,p=window.Symbol?Symbol():`__cachedPathData`,m=window.Symbol?Symbol():`__cachedNormalizedPathData`;SVGPathElement.prototype.setAttribute=function(e,t){e===`d`&&(this[p]=null,this[m]=null),l.call(this,e,t)},SVGPathElement.prototype.setAttributeNS=function(e,t,n){if(t===`d`){var r=`http://www.w3.org/2000/svg`;if(e)for(var i of this.ownerSVGElement.attributes)i.name===`xmlns:${e}`&&(r=i.value);r===`http://www.w3.org/2000/svg`&&(this[p]=null,this[m]=null)}u.call(this,e,t,n)},SVGPathElement.prototype.removeAttribute=function(e,t){e===`d`&&(this[p]=null,this[m]=null),d.call(this,e)},SVGPathElement.prototype.removeAttributeNS=function(e,t){if(t===`d`){var n=`http://www.w3.org/2000/svg`;if(e)for(var r of this.ownerSVGElement.attributes)r.name===`xmlns:${e}`&&(n=r.value);n===`http://www.w3.org/2000/svg`&&(this[p]=null,this[m]=null)}f.call(this,e,t)},SVGPathElement.prototype.getPathData=function(r){if(r&&r.normalize){if(this[m])return e(this[m]);var i;this[p]?i=e(this[p]):(i=c(this.getAttribute(`d`)||``),this[p]=e(i));var a=n(t(i));return this[m]=e(a),a}else if(this[p])return e(this[p]);else{var i=c(this.getAttribute(`d`)||``);return this[p]=e(i),i}},SVGPathElement.prototype.setPathData=function(e){if(e.length===0)s?this.setAttribute(`d`,``):this.removeAttribute(`d`);else{for(var t=``,n=0,r=e.length;n<r;n+=1){var i=e[n];n>0&&(t+=` `),t+=i.type,i.values&&i.values.length>0&&(t+=` `+i.values.join(` `))}this.setAttribute(`d`,t)}}}SVGRectElement.prototype.getPathData||(SVGRectElement.prototype.getPathData=function(e){var t=this.x.baseVal.value,r=this.y.baseVal.value,i=this.width.baseVal.value,a=this.height.baseVal.value,o=this.hasAttribute(`rx`)?this.rx.baseVal.value:this.ry.baseVal.value,s=this.hasAttribute(`ry`)?this.ry.baseVal.value:this.rx.baseVal.value;o>i/2&&(o=i/2),s>a/2&&(s=a/2);var c=[{type:`M`,values:[t+o,r]},{type:`H`,values:[t+i-o]},{type:`A`,values:[o,s,0,0,1,t+i,r+s]},{type:`V`,values:[r+a-s]},{type:`A`,values:[o,s,0,0,1,t+i-o,r+a]},{type:`H`,values:[t+o]},{type:`A`,values:[o,s,0,0,1,t,r+a-s]},{type:`V`,values:[r+s]},{type:`A`,values:[o,s,0,0,1,t+o,r]},{type:`Z`,values:[]}];return c=c.filter(function(e){return!(e.type===`A`&&(e.values[0]===0||e.values[1]===0))}),e&&e.normalize===!0&&(c=n(c)),c}),SVGCircleElement.prototype.getPathData||(SVGCircleElement.prototype.getPathData=function(e){var t=this.cx.baseVal.value,r=this.cy.baseVal.value,i=this.r.baseVal.value,a=[{type:`M`,values:[t+i,r]},{type:`A`,values:[i,i,0,0,1,t,r+i]},{type:`A`,values:[i,i,0,0,1,t-i,r]},{type:`A`,values:[i,i,0,0,1,t,r-i]},{type:`A`,values:[i,i,0,0,1,t+i,r]},{type:`Z`,values:[]}];return e&&e.normalize===!0&&(a=n(a)),a}),SVGEllipseElement.prototype.getPathData||(SVGEllipseElement.prototype.getPathData=function(e){var t=this.cx.baseVal.value,r=this.cy.baseVal.value,i=this.rx.baseVal.value,a=this.ry.baseVal.value,o=[{type:`M`,values:[t+i,r]},{type:`A`,values:[i,a,0,0,1,t,r+a]},{type:`A`,values:[i,a,0,0,1,t-i,r]},{type:`A`,values:[i,a,0,0,1,t,r-a]},{type:`A`,values:[i,a,0,0,1,t+i,r]},{type:`Z`,values:[]}];return e&&e.normalize===!0&&(o=n(o)),o}),SVGLineElement.prototype.getPathData||(SVGLineElement.prototype.getPathData=function(){return[{type:`M`,values:[this.x1.baseVal.value,this.y1.baseVal.value]},{type:`L`,values:[this.x2.baseVal.value,this.y2.baseVal.value]}]}),SVGPolylineElement.prototype.getPathData||(SVGPolylineElement.prototype.getPathData=function(){for(var e=[],t=0;t<this.points.numberOfItems;t+=1){var n=this.points.getItem(t);e.push({type:t===0?`M`:`L`,values:[n.x,n.y]})}return e}),SVGPolygonElement.prototype.getPathData||(SVGPolygonElement.prototype.getPathData=function(){for(var e=[],t=0;t<this.points.numberOfItems;t+=1){var n=this.points.getItem(t);e.push({type:t===0?`M`:`L`,values:[n.x,n.y]})}return e.push({type:`Z`,values:[]}),e})})();function pr(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}async function mr(e,t,n){for(let r of e)try{let e=await fetch(`${t}fonts/${r}.woff2?access_token=${n}`).then(e=>e.arrayBuffer());document.fonts.add(new FontFace(r,e))}catch{}}function hr(e,t,n=1e-4){return Math.abs(e-t)<n}async function gr(e,t,n,r){if(fr()||e.length<2e6)try{return{token:r,image:await _r(e,t,n)}}catch{}return{token:r,image:await vr(new Blob([e],{type:`image/svg+xml`}),t,n)}}function _r(e,t,n){let r=new Image;return r.width=t,r.height=n,new Promise((t,n)=>{r.onload=()=>t(r),r.onerror=()=>n(Error(`Failed to quickly generate image from svg`)),r.src=`data:image/svg+xml;base64,${btoa(e)}`})}async function vr(e,t,n){let r=new Image;r.width=t,r.height=n;let i=URL.createObjectURL(e);try{await new Promise((e,t)=>{r.onload=()=>e(),r.onerror=()=>t(Error(`Failed to safely generate image from svg`)),r.src=i})}finally{URL.revokeObjectURL(i)}return r}var yr=/\$\{([^}]+)}/g,br=new DOMParser,xr=new XMLSerializer,Sr=new Map;function Cr(e){let t=Sr.get(e);return t||(t=br.parseFromString(e,`image/svg+xml`).documentElement,Sr.set(e,t)),t}function wr(e){let t=xr.serializeToString(e);return Sr.has(t)||Sr.set(t,e),t}var Tr=class{_seen=[];_svg=null;_element=null;constructor(e){this._svg=e}setElement(){return this._element=Cr(this._svg).cloneNode(!0),this._svg=null,this._element}getSvgString(){return this._svg??wr(this._element)}getSvgSize(){let e=this._element??Cr(this._svg);return[e.width.baseVal.value,e.height.baseVal.value]}getSvgColors(){let e=[],t=[],n=(this._element??Cr(this._svg)).querySelectorAll(`[mol_edit_style=true]`);for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&t.every(e=>e.id!==a)){let n=i.getAttribute(`fill`)?.trim();if(n){let r=new Pr(n);if(r.badValue)e.push({name:`fill#${a}`,color:n});else{let{rgba:t}=r,n=i.getAttribute(`fill-opacity`);t[3]*=n?b(Number(n),0,1):1,e.push({name:`fill#${a}`,color:Pr.fromRGB(t)})}t.push(i)}let r=i.getAttribute(`stroke`)?.trim();if(r){let n=new Pr(r);if(n.badValue)e.push({name:`stroke#${a}`,color:r});else{let{rgba:t}=n,r=i.getAttribute(`stroke-opacity`);t[3]*=r?b(Number(r),0,1):1,e.push({name:`stroke#${a}`,color:Pr.fromRGB(t)})}t.push(i)}}}return e}setSvgColors(e){let t=[],n=(this._element??this.setElement()).querySelectorAll(`[mol_edit_style=true]`);for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&t.every(e=>e.id!==a)&&(i.getAttribute(`fill`)?.trim()||i.getAttribute(`stroke`)?.trim())){let n=e.find(e=>e.name===`fill#${a}`);if(n?.color){let[e,t,r,a]=n.color.rgba;i.setAttribute(`fill`,`rgb(${e},${t},${r})`),i.setAttribute(`fill-opacity`,String(a))}let r=e.find(e=>e.name===`stroke#${a}`);if(r?.color){let[e,t,n,a]=r.color.rgba;i.setAttribute(`stroke`,`rgb(${e},${t},${n})`),i.setAttribute(`stroke-opacity`,String(a))}t.push(i)}}return this}getSvgTexts(){let e=[],t=(this._element??Cr(this._svg)).querySelectorAll(`[mol_edit_text=true]`);for(let n=0;n<t.length;++n){let r=t[n],i=r.id;i&&e.every(e=>e.name!==i)&&e.push({name:i,text:r.textContent||void 0,isMultiline:/^\s*true/i.test(r.getAttribute(`mol_wrap`)??`false`)})}return e}setSvgTexts(e){this._seen=[];let t=this._element??this.setElement(),n=t.querySelectorAll(`[mol_edit_text=true]`);document.body.appendChild(t);try{let r=t.width.baseVal.value/t.viewBox.baseVal.width;for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&this._seen.every(e=>e.id!==a)){let n=e.find(e=>e.name===a);if(i.querySelector(`textPath`)){if(n)for(let e=0;e<i.childNodes.length;++e)i.childNodes[e].nodeName===`textPath`&&(i.childNodes[e].childNodes[0].nodeValue=n.text??``)}else this.wrapText(t,i,n&&(n.text??``));this.nodeChanged(i)}}this._seen.length&&(this.resetSize(r),this.resetAnchor())}finally{document.body.removeChild(t)}return this}nodeChanged(e){if(!e.id||this._seen.includes(e))return;let t=this._element??this.setElement(),n=this.getBBox(e),r=0,i=t.querySelectorAll(`[mol_wrap~="${e.id}"]`)??[];for(r=0;r<i.length;++r)this.wrapText(t,i[r]);for(i=t.querySelectorAll(`[mol_autoresizeid~="${e.id}"]`)??[],r=0;r<i.length;++r)this.autoResizeId(i[r],n);for(i=t.querySelectorAll(`[mol_samewidth~="${e.id}"]`)??[],r=0;r<i.length;++r)this.sameWidth(i[r],n);for(i=t.querySelectorAll(`[mol_sameheight~="${e.id}"]`)??[],r=0;r<i.length;++r)this.sameHeight(i[r],n);for(i=t.querySelectorAll(`[mol_stack~="${e.id}"]`)??[],r=0;r<i.length;++r)this.stack(i[r],n);for(i=t.querySelectorAll(`[mol_rectposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.rectPosition(i[r],n);for(i=t.querySelectorAll(`[mol_pathposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.pathPosition(i[r],e);for(i=t.querySelectorAll(`[mol_copyposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.copyPosition(i[r],e);this._seen.push(e)}autoResizeId(e,t){let n=e.attributes.mol_autoresizemargin?.value,r=[0,0,0,0];if(n){let e=n.split(` `).map(e=>parseFloat(e));r=e.length===1?[e[0],e[0],e[0],e[0]]:[e[0],e[1],e[2],e[3]]}hr(e.attributes.x.value,t.x-r[0])&&hr(e.attributes.y.value,t.y-r[2])&&hr(e.attributes.width.value,t.width+r[0]+r[1])&&hr(e.attributes.height.value,t.height+r[2]+r[3])||(e.attributes.x.value=t.x-r[0],e.attributes.y.value=t.y-r[2],e.attributes.width.value=t.width+r[0]+r[1],e.attributes.height.value=t.height+r[2]+r[3],this.nodeChanged(e))}sameWidth(e,t){let n=t.width+2*parseFloat(e.attributes.mol_samewidth.value.split(` `)[1]);hr(e.attributes.width.value,n)||(e.attributes.width.value=n,this.nodeChanged(e))}sameHeight(e,t){let n=t.height+2*parseFloat(e.attributes.mol_sameheight.value.split(` `)[1]);hr(e.attributes.height.value,n)||(this._seen.push(e),e.attributes.height.value=n,this.nodeChanged(e))}stack(e,t){let n=!1;switch(e.attributes.mol_stack.value.split(` `)[0]){case`top`:n=!(hr(e.attributes.width.value,t.width)&&hr(e.attributes.x.value,t.x)&&hr(e.attributes.y.value,t.y-e.attributes.height.value)),n&&(e.attributes.width.value=t.width,e.attributes.x.value=t.x,e.attributes.y.value=t.y-e.attributes.height.value);break;case`bottom`:n=!(hr(e.attributes.width.value,t.width)&&hr(e.attributes.x.value,t.x)&&hr(e.attributes.y.value,t.y+t.height)),n&&(e.attributes.width.value=t.width,e.attributes.x.value=t.x,e.attributes.y.value=t.y+t.height);break;case`left`:n=!(hr(e.attributes.height.value,t.height)&&hr(e.attributes.x.value,t.x-e.attributes.width.value)&&hr(e.attributes.y.value,t.y)),n&&(e.attributes.height.value=t.height,e.attributes.x.value=t.x-e.attributes.width.value,e.attributes.y.value=t.y);break;case`right`:n=!(hr(e.attributes.height.value,t.height)&&hr(e.attributes.x.value,t.x+t.width)&&hr(e.attributes.y.value,t.y)),n&&(e.attributes.height.value=t.height,e.attributes.x.value=t.x+t.width,e.attributes.y.value=t.y);break}n&&this.nodeChanged(e)}rectPosition(e,t){let n=e.attributes.mol_rectposition.value.split(` `)[1],r=e.attributes.mol_rectposition.value.split(` `)[2],i=parseFloat(e.attributes.mol_rectposition.value.split(` `)[3])||0,a={x:0,y:0};switch(n){case`center`:a={x:t.x+t.width/2,y:t.y+t.height/2};break;case`top`:case`bottom`:switch(a.x=t.x,r){case`start`:a.x+=i;break;case`middle`:a.x+=t.width/2+i;break;case`end`:a.x+=t.width-i;break}a.y=t.y,n===`bottom`&&(a.y+=t.height);break;case`left`:case`right`:switch(a.y=t.y,r){case`start`:a.y+=i;break;case`middle`:a.y+=t.height/2+i;break;case`end`:a.y+=t.height+i;break}a.x=t.x,n===`right`&&(a.x+=t.width);break}let o=this.getCoordinate(e,0,0);o&&!(hr(o.x,a.x)&&hr(o.y,a.y))&&(this.moveElement(e,a),this.nodeChanged(e))}pathPosition(e,t){let n=e.attributes.mol_pathposition.value.split(` `).map(e=>parseFloat(e)),r=this.getCoordinate(e,0,0),i=this.getCoordinate(t,n[1],n[2]);i&&r&&!(hr(i.x,r.x)&&hr(i.y,r.y))&&(this.moveElement(e,i),this.nodeChanged(e))}copyPosition(e,t){let n=e.attributes.mol_copyposition.value.split(` `).map(e=>parseFloat(e)),r=this.getCoordinate(e,n[0],n[1]),i=this.getCoordinate(t,n[3],n[4]);i&&r&&!(hr(i.x,r.x)&&hr(i.y,r.y))&&(this.setCoordinate(e,i,n[0],n[1]),this.nodeChanged(e))}resetSize(e){let t=this._element??this.setElement(),n=this.getBBox(t);n.x-=.1*n.width,n.y-=.1*n.height,n.width*=1.2,n.height*=1.2,t.setAttribute(`viewBox`,`${n.x} ${n.y} ${n.width} ${n.height}`),t.setAttribute(`width`,`${n.width*e}`),t.setAttribute(`height`,`${n.height*e}`)}resetAnchor(){let e=(this._element??Cr(this._svg)).querySelector(`[mol_edit_anchor]`);if(e){let t=e.getAttribute(`mol_edit_anchor`).split(` `).map(e=>parseFloat(e)),n=this.getCoordinate(e,t[0],t[1]),r=this._element??this.setElement(),i=r.getElementById(`scale`);if(i){let e=i.getAttribute(`transform`),t=(/scale\(([\d.]+)\)/i.exec(e)||[``,`1`]).map(Number.parseFloat)[1];n.x*=t,n.y*=t}r.setAttribute(`mol_svganchor`,`${n.x} ${n.y}`)}}getBBox(e){function t(e){if(e.nodeName!==`text`)return``;let t=e.textContent,n=0;for(;n<e.childNodes.length&&e.childNodes[n].nodeName===`tspan`&&e.childNodes[n].textContent.match(/\S+/)===null;)t=t.slice(e.childNodes[n].textContent.length),n++;for(n=e.childNodes.length-1;n>=0&&e.childNodes[n].nodeName===`tspan`&&e.childNodes[n].textContent.match(/\S+/)===null;)t=t.slice(0,t.length-e.childNodes[n].textContent.length),n--;let r=t.split(`
|
|
689
|
+
`||e===` `||e===`\r`||e===`\f`)},_skipOptionalSpaces:function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex+=1;return this._currentIndex<this._endIndex},_skipOptionalSpacesOrDelimiter:function(){return this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&this._string[this._currentIndex]!==`,`?!1:(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`,`&&(this._currentIndex+=1,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},_parseNumber:function(){var e=0,t=0,n=1,r=0,i=1,a=1,o=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`+`?this._currentIndex+=1:this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`-`&&(this._currentIndex+=1,i=-1),this._currentIndex===this._endIndex||(this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)&&this._string[this._currentIndex]!==`.`)return null;for(var s=this._currentIndex;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)this._currentIndex+=1;if(this._currentIndex!==s)for(var c=this._currentIndex-1,l=1;c>=s;)t+=l*(this._string[c]-`0`),--c,l*=10;if(this._currentIndex<this._endIndex&&this._string[this._currentIndex]===`.`){if(this._currentIndex+=1,this._currentIndex>=this._endIndex||this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)n*=10,r+=(this._string.charAt(this._currentIndex)-`0`)/n,this._currentIndex+=1}if(this._currentIndex!==o&&this._currentIndex+1<this._endIndex&&(this._string[this._currentIndex]===`e`||this._string[this._currentIndex]===`E`)&&this._string[this._currentIndex+1]!==`x`&&this._string[this._currentIndex+1]!==`m`){if(this._currentIndex+=1,this._string[this._currentIndex]===`+`?this._currentIndex+=1:this._string[this._currentIndex]===`-`&&(this._currentIndex+=1,a=-1),this._currentIndex>=this._endIndex||this._string[this._currentIndex]<`0`||this._string[this._currentIndex]>`9`)return null;for(;this._currentIndex<this._endIndex&&this._string[this._currentIndex]>=`0`&&this._string[this._currentIndex]<=`9`;)e*=10,e+=this._string[this._currentIndex]-`0`,this._currentIndex+=1}var u=t+r;return u*=i,e&&(u*=10**(a*e)),o===this._currentIndex?null:(this._skipOptionalSpacesOrDelimiter(),u)},_parseArcFlag:function(){if(this._currentIndex>=this._endIndex)return null;var e=null,t=this._string[this._currentIndex];if(this._currentIndex+=1,t===`0`)e=0;else if(t===`1`)e=1;else return null;return this._skipOptionalSpacesOrDelimiter(),e}};var c=function(e){if(!e||e.length===0)return[];var t=new o(e),n=[];if(t.initialCommandIsMoveTo())for(;t.hasMoreData();){var r=t.parseSegment();if(r===null)break;n.push(r)}return n},l=SVGPathElement.prototype.setAttribute,u=SVGPathElement.prototype.setAttributeNS,d=SVGPathElement.prototype.removeAttribute,f=SVGPathElement.prototype.removeAttributeNS,p=window.Symbol?Symbol():`__cachedPathData`,m=window.Symbol?Symbol():`__cachedNormalizedPathData`;SVGPathElement.prototype.setAttribute=function(e,t){e===`d`&&(this[p]=null,this[m]=null),l.call(this,e,t)},SVGPathElement.prototype.setAttributeNS=function(e,t,n){if(t===`d`){var r=`http://www.w3.org/2000/svg`;if(e)for(var i of this.ownerSVGElement.attributes)i.name===`xmlns:${e}`&&(r=i.value);r===`http://www.w3.org/2000/svg`&&(this[p]=null,this[m]=null)}u.call(this,e,t,n)},SVGPathElement.prototype.removeAttribute=function(e,t){e===`d`&&(this[p]=null,this[m]=null),d.call(this,e)},SVGPathElement.prototype.removeAttributeNS=function(e,t){if(t===`d`){var n=`http://www.w3.org/2000/svg`;if(e)for(var r of this.ownerSVGElement.attributes)r.name===`xmlns:${e}`&&(n=r.value);n===`http://www.w3.org/2000/svg`&&(this[p]=null,this[m]=null)}f.call(this,e,t)},SVGPathElement.prototype.getPathData=function(r){if(r&&r.normalize){if(this[m])return e(this[m]);var i;this[p]?i=e(this[p]):(i=c(this.getAttribute(`d`)||``),this[p]=e(i));var a=n(t(i));return this[m]=e(a),a}else if(this[p])return e(this[p]);else{var i=c(this.getAttribute(`d`)||``);return this[p]=e(i),i}},SVGPathElement.prototype.setPathData=function(e){if(e.length===0)s?this.setAttribute(`d`,``):this.removeAttribute(`d`);else{for(var t=``,n=0,r=e.length;n<r;n+=1){var i=e[n];n>0&&(t+=` `),t+=i.type,i.values&&i.values.length>0&&(t+=` `+i.values.join(` `))}this.setAttribute(`d`,t)}}}SVGRectElement.prototype.getPathData||(SVGRectElement.prototype.getPathData=function(e){var t=this.x.baseVal.value,r=this.y.baseVal.value,i=this.width.baseVal.value,a=this.height.baseVal.value,o=this.hasAttribute(`rx`)?this.rx.baseVal.value:this.ry.baseVal.value,s=this.hasAttribute(`ry`)?this.ry.baseVal.value:this.rx.baseVal.value;o>i/2&&(o=i/2),s>a/2&&(s=a/2);var c=[{type:`M`,values:[t+o,r]},{type:`H`,values:[t+i-o]},{type:`A`,values:[o,s,0,0,1,t+i,r+s]},{type:`V`,values:[r+a-s]},{type:`A`,values:[o,s,0,0,1,t+i-o,r+a]},{type:`H`,values:[t+o]},{type:`A`,values:[o,s,0,0,1,t,r+a-s]},{type:`V`,values:[r+s]},{type:`A`,values:[o,s,0,0,1,t+o,r]},{type:`Z`,values:[]}];return c=c.filter(function(e){return!(e.type===`A`&&(e.values[0]===0||e.values[1]===0))}),e&&e.normalize===!0&&(c=n(c)),c}),SVGCircleElement.prototype.getPathData||(SVGCircleElement.prototype.getPathData=function(e){var t=this.cx.baseVal.value,r=this.cy.baseVal.value,i=this.r.baseVal.value,a=[{type:`M`,values:[t+i,r]},{type:`A`,values:[i,i,0,0,1,t,r+i]},{type:`A`,values:[i,i,0,0,1,t-i,r]},{type:`A`,values:[i,i,0,0,1,t,r-i]},{type:`A`,values:[i,i,0,0,1,t+i,r]},{type:`Z`,values:[]}];return e&&e.normalize===!0&&(a=n(a)),a}),SVGEllipseElement.prototype.getPathData||(SVGEllipseElement.prototype.getPathData=function(e){var t=this.cx.baseVal.value,r=this.cy.baseVal.value,i=this.rx.baseVal.value,a=this.ry.baseVal.value,o=[{type:`M`,values:[t+i,r]},{type:`A`,values:[i,a,0,0,1,t,r+a]},{type:`A`,values:[i,a,0,0,1,t-i,r]},{type:`A`,values:[i,a,0,0,1,t,r-a]},{type:`A`,values:[i,a,0,0,1,t+i,r]},{type:`Z`,values:[]}];return e&&e.normalize===!0&&(o=n(o)),o}),SVGLineElement.prototype.getPathData||(SVGLineElement.prototype.getPathData=function(){return[{type:`M`,values:[this.x1.baseVal.value,this.y1.baseVal.value]},{type:`L`,values:[this.x2.baseVal.value,this.y2.baseVal.value]}]}),SVGPolylineElement.prototype.getPathData||(SVGPolylineElement.prototype.getPathData=function(){for(var e=[],t=0;t<this.points.numberOfItems;t+=1){var n=this.points.getItem(t);e.push({type:t===0?`M`:`L`,values:[n.x,n.y]})}return e}),SVGPolygonElement.prototype.getPathData||(SVGPolygonElement.prototype.getPathData=function(){for(var e=[],t=0;t<this.points.numberOfItems;t+=1){var n=this.points.getItem(t);e.push({type:t===0?`M`:`L`,values:[n.x,n.y]})}return e.push({type:`Z`,values:[]}),e})})();function pr(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}async function mr(e,t,n){for(let r of e)try{let e=await fetch(`${t}/fonts/${r}.woff2?access_token=${n}`).then(e=>e.arrayBuffer());document.fonts.add(new FontFace(r,e))}catch{}}function hr(e,t,n=1e-4){return Math.abs(e-t)<n}async function gr(e,t,n,r){if(fr()||e.length<2e6)try{return{token:r,image:await _r(e,t,n)}}catch{}return{token:r,image:await vr(new Blob([e],{type:`image/svg+xml`}),t,n)}}function _r(e,t,n){let r=new Image;return r.width=t,r.height=n,new Promise((t,n)=>{r.onload=()=>t(r),r.onerror=()=>n(Error(`Failed to quickly generate image from svg`)),r.src=`data:image/svg+xml;base64,${btoa(e)}`})}async function vr(e,t,n){let r=new Image;r.width=t,r.height=n;let i=URL.createObjectURL(e);try{await new Promise((e,t)=>{r.onload=()=>e(),r.onerror=()=>t(Error(`Failed to safely generate image from svg`)),r.src=i})}finally{URL.revokeObjectURL(i)}return r}var yr=/\$\{([^}]+)}/g,br=new DOMParser,xr=new XMLSerializer,Sr=new Map;function Cr(e){let t=Sr.get(e);return t||(t=br.parseFromString(e,`image/svg+xml`).documentElement,Sr.set(e,t)),t}function wr(e){let t=xr.serializeToString(e);return Sr.has(t)||Sr.set(t,e),t}var Tr=class{_seen=[];_svg=null;_element=null;constructor(e){this._svg=e}setElement(){return this._element=Cr(this._svg).cloneNode(!0),this._svg=null,this._element}getSvgString(){return this._svg??wr(this._element)}getSvgSize(){let e=this._element??Cr(this._svg);return[e.width.baseVal.value,e.height.baseVal.value]}getSvgColors(){let e=[],t=[],n=(this._element??Cr(this._svg)).querySelectorAll(`[mol_edit_style=true]`);for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&t.every(e=>e.id!==a)){let n=i.getAttribute(`fill`)?.trim();if(n){let r=new Pr(n);if(r.badValue)e.push({name:`fill#${a}`,color:n});else{let{rgba:t}=r,n=i.getAttribute(`fill-opacity`);t[3]*=n?b(Number(n),0,1):1,e.push({name:`fill#${a}`,color:Pr.fromRGB(t)})}t.push(i)}let r=i.getAttribute(`stroke`)?.trim();if(r){let n=new Pr(r);if(n.badValue)e.push({name:`stroke#${a}`,color:r});else{let{rgba:t}=n,r=i.getAttribute(`stroke-opacity`);t[3]*=r?b(Number(r),0,1):1,e.push({name:`stroke#${a}`,color:Pr.fromRGB(t)})}t.push(i)}}}return e}setSvgColors(e){let t=[],n=(this._element??this.setElement()).querySelectorAll(`[mol_edit_style=true]`);for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&t.every(e=>e.id!==a)&&(i.getAttribute(`fill`)?.trim()||i.getAttribute(`stroke`)?.trim())){let n=e.find(e=>e.name===`fill#${a}`);if(n?.color){let[e,t,r,a]=n.color.rgba;i.setAttribute(`fill`,`rgb(${e},${t},${r})`),i.setAttribute(`fill-opacity`,String(a))}let r=e.find(e=>e.name===`stroke#${a}`);if(r?.color){let[e,t,n,a]=r.color.rgba;i.setAttribute(`stroke`,`rgb(${e},${t},${n})`),i.setAttribute(`stroke-opacity`,String(a))}t.push(i)}}return this}getSvgTexts(){let e=[],t=(this._element??Cr(this._svg)).querySelectorAll(`[mol_edit_text=true]`);for(let n=0;n<t.length;++n){let r=t[n],i=r.id;i&&e.every(e=>e.name!==i)&&e.push({name:i,text:r.textContent||void 0,isMultiline:/^\s*true/i.test(r.getAttribute(`mol_wrap`)??`false`)})}return e}setSvgTexts(e){this._seen=[];let t=this._element??this.setElement(),n=t.querySelectorAll(`[mol_edit_text=true]`);document.body.appendChild(t);try{let r=t.width.baseVal.value/t.viewBox.baseVal.width;for(let r=0;r<n.length;++r){let i=n[r],a=i.id;if(a&&this._seen.every(e=>e.id!==a)){let n=e.find(e=>e.name===a);if(i.querySelector(`textPath`)){if(n)for(let e=0;e<i.childNodes.length;++e)i.childNodes[e].nodeName===`textPath`&&(i.childNodes[e].childNodes[0].nodeValue=n.text??``)}else this.wrapText(t,i,n&&(n.text??``));this.nodeChanged(i)}}this._seen.length&&(this.resetSize(r),this.resetAnchor())}finally{document.body.removeChild(t)}return this}nodeChanged(e){if(!e.id||this._seen.includes(e))return;let t=this._element??this.setElement(),n=this.getBBox(e),r=0,i=t.querySelectorAll(`[mol_wrap~="${e.id}"]`)??[];for(r=0;r<i.length;++r)this.wrapText(t,i[r]);for(i=t.querySelectorAll(`[mol_autoresizeid~="${e.id}"]`)??[],r=0;r<i.length;++r)this.autoResizeId(i[r],n);for(i=t.querySelectorAll(`[mol_samewidth~="${e.id}"]`)??[],r=0;r<i.length;++r)this.sameWidth(i[r],n);for(i=t.querySelectorAll(`[mol_sameheight~="${e.id}"]`)??[],r=0;r<i.length;++r)this.sameHeight(i[r],n);for(i=t.querySelectorAll(`[mol_stack~="${e.id}"]`)??[],r=0;r<i.length;++r)this.stack(i[r],n);for(i=t.querySelectorAll(`[mol_rectposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.rectPosition(i[r],n);for(i=t.querySelectorAll(`[mol_pathposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.pathPosition(i[r],e);for(i=t.querySelectorAll(`[mol_copyposition~="${e.id}"]`)??[],r=0;r<i.length;++r)this.copyPosition(i[r],e);this._seen.push(e)}autoResizeId(e,t){let n=e.attributes.mol_autoresizemargin?.value,r=[0,0,0,0];if(n){let e=n.split(` `).map(e=>parseFloat(e));r=e.length===1?[e[0],e[0],e[0],e[0]]:[e[0],e[1],e[2],e[3]]}hr(e.attributes.x.value,t.x-r[0])&&hr(e.attributes.y.value,t.y-r[2])&&hr(e.attributes.width.value,t.width+r[0]+r[1])&&hr(e.attributes.height.value,t.height+r[2]+r[3])||(e.attributes.x.value=t.x-r[0],e.attributes.y.value=t.y-r[2],e.attributes.width.value=t.width+r[0]+r[1],e.attributes.height.value=t.height+r[2]+r[3],this.nodeChanged(e))}sameWidth(e,t){let n=t.width+2*parseFloat(e.attributes.mol_samewidth.value.split(` `)[1]);hr(e.attributes.width.value,n)||(e.attributes.width.value=n,this.nodeChanged(e))}sameHeight(e,t){let n=t.height+2*parseFloat(e.attributes.mol_sameheight.value.split(` `)[1]);hr(e.attributes.height.value,n)||(this._seen.push(e),e.attributes.height.value=n,this.nodeChanged(e))}stack(e,t){let n=!1;switch(e.attributes.mol_stack.value.split(` `)[0]){case`top`:n=!(hr(e.attributes.width.value,t.width)&&hr(e.attributes.x.value,t.x)&&hr(e.attributes.y.value,t.y-e.attributes.height.value)),n&&(e.attributes.width.value=t.width,e.attributes.x.value=t.x,e.attributes.y.value=t.y-e.attributes.height.value);break;case`bottom`:n=!(hr(e.attributes.width.value,t.width)&&hr(e.attributes.x.value,t.x)&&hr(e.attributes.y.value,t.y+t.height)),n&&(e.attributes.width.value=t.width,e.attributes.x.value=t.x,e.attributes.y.value=t.y+t.height);break;case`left`:n=!(hr(e.attributes.height.value,t.height)&&hr(e.attributes.x.value,t.x-e.attributes.width.value)&&hr(e.attributes.y.value,t.y)),n&&(e.attributes.height.value=t.height,e.attributes.x.value=t.x-e.attributes.width.value,e.attributes.y.value=t.y);break;case`right`:n=!(hr(e.attributes.height.value,t.height)&&hr(e.attributes.x.value,t.x+t.width)&&hr(e.attributes.y.value,t.y)),n&&(e.attributes.height.value=t.height,e.attributes.x.value=t.x+t.width,e.attributes.y.value=t.y);break}n&&this.nodeChanged(e)}rectPosition(e,t){let n=e.attributes.mol_rectposition.value.split(` `)[1],r=e.attributes.mol_rectposition.value.split(` `)[2],i=parseFloat(e.attributes.mol_rectposition.value.split(` `)[3])||0,a={x:0,y:0};switch(n){case`center`:a={x:t.x+t.width/2,y:t.y+t.height/2};break;case`top`:case`bottom`:switch(a.x=t.x,r){case`start`:a.x+=i;break;case`middle`:a.x+=t.width/2+i;break;case`end`:a.x+=t.width-i;break}a.y=t.y,n===`bottom`&&(a.y+=t.height);break;case`left`:case`right`:switch(a.y=t.y,r){case`start`:a.y+=i;break;case`middle`:a.y+=t.height/2+i;break;case`end`:a.y+=t.height+i;break}a.x=t.x,n===`right`&&(a.x+=t.width);break}let o=this.getCoordinate(e,0,0);o&&!(hr(o.x,a.x)&&hr(o.y,a.y))&&(this.moveElement(e,a),this.nodeChanged(e))}pathPosition(e,t){let n=e.attributes.mol_pathposition.value.split(` `).map(e=>parseFloat(e)),r=this.getCoordinate(e,0,0),i=this.getCoordinate(t,n[1],n[2]);i&&r&&!(hr(i.x,r.x)&&hr(i.y,r.y))&&(this.moveElement(e,i),this.nodeChanged(e))}copyPosition(e,t){let n=e.attributes.mol_copyposition.value.split(` `).map(e=>parseFloat(e)),r=this.getCoordinate(e,n[0],n[1]),i=this.getCoordinate(t,n[3],n[4]);i&&r&&!(hr(i.x,r.x)&&hr(i.y,r.y))&&(this.setCoordinate(e,i,n[0],n[1]),this.nodeChanged(e))}resetSize(e){let t=this._element??this.setElement(),n=this.getBBox(t);n.x-=.1*n.width,n.y-=.1*n.height,n.width*=1.2,n.height*=1.2,t.setAttribute(`viewBox`,`${n.x} ${n.y} ${n.width} ${n.height}`),t.setAttribute(`width`,`${n.width*e}`),t.setAttribute(`height`,`${n.height*e}`)}resetAnchor(){let e=(this._element??Cr(this._svg)).querySelector(`[mol_edit_anchor]`);if(e){let t=e.getAttribute(`mol_edit_anchor`).split(` `).map(e=>parseFloat(e)),n=this.getCoordinate(e,t[0],t[1]),r=this._element??this.setElement(),i=r.getElementById(`scale`);if(i){let e=i.getAttribute(`transform`),t=(/scale\(([\d.]+)\)/i.exec(e)||[``,`1`]).map(Number.parseFloat)[1];n.x*=t,n.y*=t}r.setAttribute(`mol_svganchor`,`${n.x} ${n.y}`)}}getBBox(e){function t(e){if(e.nodeName!==`text`)return``;let t=e.textContent,n=0;for(;n<e.childNodes.length&&e.childNodes[n].nodeName===`tspan`&&e.childNodes[n].textContent.match(/\S+/)===null;)t=t.slice(e.childNodes[n].textContent.length),n++;for(n=e.childNodes.length-1;n>=0&&e.childNodes[n].nodeName===`tspan`&&e.childNodes[n].textContent.match(/\S+/)===null;)t=t.slice(0,t.length-e.childNodes[n].textContent.length),n--;let r=t.split(`
|
|
690
690
|
`);for(t=r[0],n=1;n<r.length;++n)r[n].length>t.length&&(t=r[n]);return t}let n=null,r=e.getBBox();if(e.nodeName===`text`){let i=t(e),a=r.width,o=r.x,s=i.match(/\S+.*\S+/);if(s&&s.length>0){let e=i.match(/^\s*/);e.length>0&&(o-=a/s[0].length*e[0].length),a+=a/s[0].length*(i.length-s[0].length)}n={width:a,height:r.height,x:o,y:r.y,descent:r.y+r.height-Number(e.getAttribute(`y`))}}else n={x:r.x,y:r.y,width:Math.max(1,r.width),height:Math.max(1,r.height)};return n}nodeToPoints(e){let t=[],n,r,i;for(r=e.points.length?e.points.length:e.points.numberOfItems,i=0;i<r;++i)n=e.points.getItem(i),t.push(n);return t}pointsToString(e){let t=``,n;for(n=0;n<e.length;++n)t=`${t} ${e[n].x.toString()}, ${e[n].y.toString()}`;return t}getCoordinate(e,t,n){let r={x:0,y:0},i=[],a=[];switch(e.nodeName){case`rect`:if(t===0)return r.x=parseFloat(e.getAttribute(`x`)),r.y=parseFloat(e.getAttribute(`y`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`x`))+parseFloat(e.getAttribute(`width`)),r.y=parseFloat(e.getAttribute(`y`))+parseFloat(e.getAttribute(`height`)),r;break;case`circle`:if(t===0)return r.x=parseFloat(e.getAttribute(`cx`)),r.y=parseFloat(e.getAttribute(`cy`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`cx`))+parseFloat(e.getAttribute(`r`)),r.y=parseFloat(e.getAttribute(`cy`)),r;break;case`ellipse`:if(t===0)return r.x=parseFloat(e.getAttribute(`cx`)),r.y=parseFloat(e.getAttribute(`cy`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`cx`))+parseFloat(e.getAttribute(`rx`)),r.y=parseFloat(e.getAttribute(`cy`)),r;if(t===2)return r.x=parseFloat(e.getAttribute(`cx`)),r.y=parseFloat(e.getAttribute(`cy`))-parseFloat(e.getAttribute(`ry`)),r;break;case`line`:if(t===0)return r.x=parseFloat(e.getAttribute(`x1`)),r.y=parseFloat(e.getAttribute(`y1`)),r;if(t===1)return r.x=parseFloat(e.getAttribute(`x2`)),r.y=parseFloat(e.getAttribute(`y2`)),r;break;case`polyline`:if(i=this.nodeToPoints(e),t<i.length)return r.x=i[t].x,r.y=i[t].y,r;break;case`polygon`:if(i=this.nodeToPoints(e),t<i.length)return r.x=i[t].x,r.y=i[t].y,r;break;case`path`:switch(a=e.getPathData({normalize:!0}),a[n].type){case`M`:switch(t){case 0:return r.x=a[n].values[0],r.y=a[n].values[1],r}break;case`L`:switch(t){case 0:return r.x=a[n].values[0],r.y=a[n].values[1],r}break}break}return null}setCoordinate(e,t,n,r){let i=``,a=[],o=[],s=0,c=0,l=0;switch(e.nodeName){case`rect`:n===0&&(e.setAttribute(`x`,t.x.toString()),e.setAttribute(`y`,t.y.toString())),n===1&&(s=t.x-Number(e.getAttribute(`x`)),s>=0?e.setAttribute(`width`,s.toString()):(c=Number(e.getAttribute(`x`))+s,e.setAttribute(`x`,c.toString()),e.setAttribute(`width`,`0`)),s=t.y-Number(e.getAttribute(`y`)),s>=0?e.setAttribute(`height`,s.toString()):(c=Number(e.getAttribute(`y`))+s,e.setAttribute(`y`,c.toString()),e.setAttribute(`height`,`0`)));break;case`circle`:n===0&&(e.setAttribute(`cx`,t.x.toString()),e.setAttribute(`cy`,t.y.toString())),n===1&&(c=parseFloat(e.getAttribute(`cx`))-t.x,l=parseFloat(e.getAttribute(`cy`))-t.y,s=Math.sqrt(c*c+l*l),e.setAttribute(`r`,s.toString()));break;case`ellipse`:n===0&&(e.setAttribute(`cx`,t.x.toString()),e.setAttribute(`cy`,t.y.toString())),n===1&&(s=Math.abs(parseFloat(e.getAttribute(`cx`))-t.x),e.setAttribute(`rx`,s.toString())),n===2&&(s=Math.abs(parseFloat(e.getAttribute(`cy`))-t.y),e.setAttribute(`ry`,s.toString()));break;case`line`:n===0&&(e.setAttribute(`x1`,t.x.toString()),e.setAttribute(`y2`,t.y.toString())),n===1&&(e.setAttribute(`x2`,t.x.toString()),e.setAttribute(`y2`,t.y.toString()));break;case`polyline`:a=this.nodeToPoints(e),n<a.length&&(a[n].x=t.x,a[n].y=t.y,i=this.pointsToString(a),e.setAttribute(`points`,i));break;case`polygon`:a=this.nodeToPoints(e),n<a.length&&(a[n].x=t.x,a[n].y=t.y,i=this.pointsToString(a),e.setAttribute(`points`,i));break;case`path`:if(!r)break;switch(o=e.getPathData({normalize:!0}),o[r].type){case`M`:o[r].values[0]=t.x,o[r].values[1]=t.y;break;case`L`:o[r].values[0]=t.x,o[r].values[1]=t.y;break}e.setPathData(o);break}}moveElement(e,t){let n={x:0,y:0},r={x:0,y:0},i=0,a=!1,o=[];switch(e.nodeName){case`rect`:case`circle`:case`ellipse`:n=this.getCoordinate(e,0,0),a=!hr(n.x,t.x)||!hr(n.y,t.y),a&&this.setCoordinate(e,t,0,0);break;case`polyline`:case`polygon`:if(n=this.getCoordinate(e,0,0),r.x=t.x-n.x,r.y=t.y-n.y,a=!hr(r.x,0)||!hr(r.y,0),a)for(this.setCoordinate(e,t,0,0),i=1,n=this.getCoordinate(e,i,0);n!==null;)n.x+=r.x,n.y+=r.y,this.setCoordinate(n,i,0,void 0),i++,n=this.getCoordinate(e,i,0);break;case`path`:if(n=this.getCoordinate(e,0,0),r.x=t.x-n.x,r.y=t.y-n.y,a=!hr(r.x,0)||!hr(r.y,0),a){o=e.getPathData({normalize:!0});for(let e=0;e<o.length;++e){let t=o[e];(t?.type===`M`||t?.type===`L`)&&(t.values[0]+=r.x,t.values[1]+=r.y)}e.setPathData(o)}break}return a}wrapText(e,t,n){let r=[],i=0,a,o=0,s=``,c=``,l,u,d,f=0,p=``,m,h=`http://www.w3.org/2000/svg`;for(n??=t.textContent;t.hasChildNodes();)t.removeChild(t.firstChild);let g=document.createTextNode(`gh`);t.appendChild(g);let _=t.getAttribute(`y`),v=null,y=``,b=[],x=0,S=0,C=!1;if(t.hasAttribute(`mol_wrap`)&&(b=t.getAttribute(`mol_wrap`).split(` `,4),b[0]===`true`&&(y=b[1],y===`newlineOnly`?(C=!0,y=``,x=0):x=parseFloat(b[2]),S=b.length>=4?parseFloat(b[3]):x)),y){let n=e.getElementById(y);v=this.getBBox(n||t)}else v=this.getBBox(t);let w=v.x,T=v.y,E=v.width,D=1e4;y!==``&&!C&&(D=E-2*x),v=this.getBBox(t);let O=v.height;t.hasAttribute(`font-size`)&&(O=parseFloat(t.getAttribute(`font-size`)));let k=v.y+v.height-_;if(t.removeChild(g),w+=x,T+=x+v.height,t.hasAttribute(`text-anchor`))switch(t.getAttribute(`text-anchor`)){case`end`:w=w-x+E-x;break;case`middle`:w=w-x+E/2;break}p=t.getAttribute(`id`),t.setAttribute(`x`,w.toString()),t.setAttribute(`y`,(T-k).toString()),n&&(r=n.replace(/\n/g,`
|
|
691
691
|
§`).replace(/-/g,`-§`).replace(/ /g,` §`).replace(/\t/g,` §`).split(`§`));let A=parseFloat(t.attributes.y.value);for(u=document.createElementNS(h,`tspan`),u.setAttributeNS(null,`x`,String(w)),u.setAttributeNS(null,`y`,String(A+o)),d=p+f.toString(),u.setAttribute(`id`,d),f++,s=``,i=0,l=document.createTextNode(s),u.appendChild(l),t.appendChild(u),o+=O,a=0;a<r.length;)c=s+r[a],i++,l.nodeValue=c,m=e.querySelector(`#${d}`).getComputedTextLength(),m<D?(s=c,s.length>0&&s[s.length-1]===`
|
|
692
692
|
`&&a<r.length-1&&(l.nodeValue=s,u=document.createElementNS(h,`tspan`),u.setAttributeNS(null,`x`,String(w)),u.setAttributeNS(null,`y`,String(A+o)),d=p+f.toString(),u.setAttribute(`id`,d),o+=O+S,f++,s=``,i=0,l=document.createTextNode(s),u.appendChild(l),t.appendChild(u)),a++):(i>1?l.nodeValue=s:(s=c,a++),s.length>0&&s[s.length-1]===`
|
|
@@ -916,7 +916,7 @@ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matr
|
|
|
916
916
|
`,onClick:()=>{if(!t){if(e.getSource(`location-circle`)||hi(e),n(!0),!navigator.geolocation){vi(),n(!1);return}navigator.geolocation.getCurrentPosition(r,i,{maximumAge:6e4,timeout:5e3})}}})}var bi=`<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M6.155 1.146A.546.546 0 0 1 6.53 1c.14 0 .275.053.375.146l1.588 1.5c.1.094.155.221.155.354 0 .132-.056.26-.155.353l-1.588 1.5a.546.546 0 0 1-.373.14.545.545 0 0 1-.37-.146.487.487 0 0 1-.154-.349.486.486 0 0 1 .148-.352L6.84 3.5H6c-1.878 0-3.441 1.476-3.441 3.25S4.122 10 6 10s3.441-1.476 3.441-3.25c0-.133.056-.26.155-.354a.546.546 0 0 1 .375-.146c.14 0 .275.053.374.146.1.094.155.221.155.354C10.5 9.076 8.463 11 6 11S1.5 9.076 1.5 6.75 3.537 2.5 6 2.5h.84l-.685-.647A.486.486 0 0 1 6 1.5c0-.133.056-.26.155-.354Z"/></svg>
|
|
917
917
|
`;function xi(e,t){return ni({type:`button`,className:`control-button refresh-button`,content:bi,onClick:()=>{let n=e.getContainer(),r=0;if(n.clientWidth>0&&n.clientHeight>0){let e=Math.min(n.clientWidth/t.width,n.clientHeight/t.height);r=Math.log(e)/Math.LN2}e.easeTo({center:t.center,zoom:t.zoom-t.detailLevel+r,pitch:t.pitch,bearing:t.rotation})}})}var Si=`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="currentColor"><path d="M5.374.952a4.546 4.546 0 0 1 4.656 4.175 4.55 4.55 0 0 1-.958 3.184l1.824 1.81a.55.55 0 0 1 0 .765.55.55 0 0 1-.602.121.6.6 0 0 1-.179-.12l-1.807-1.81A4.544 4.544 0 0 1 .953 5.376 4.553 4.553 0 0 1 5.374.952m1.454 1.37a3.447 3.447 0 0 0-4.505 4.51 3.45 3.45 0 0 0 3.186 2.13A3.45 3.45 0 0 0 8.957 5.51a3.455 3.455 0 0 0-2.129-3.187"/></svg>
|
|
918
918
|
`,Ci=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="currentColor"><path d="m7.038 5.96 3.03 3.03L13.1 5.958l1.01 1.01L11.078 10l3.031 3.032-1.01 1.01-3.031-3.031-3.03 3.028-1.01-1.01L9.059 10l-3.03-3.03z"/></svg>
|
|
919
|
-
`,wi={da_DK:{search:`Search`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use two fingers to move the map`,windowsHelpText:`Use Ctrl + scroll to zoom the map`,macHelpText:`Use ⌘ + scroll to zoom the map`},de_DE:{search:`Suche`,videoAlert:`Das Video ist in der veröffentlichten Karte sichtbar.`,mobileHelpText:`Verwenden Sie zwei Finger um die Karte zu bewegen`,windowsHelpText:`Verwenden Sie Strg + Scroll um in der Karte zu zoomen`,macHelpText:`Verwenden Sie ⌘ + Scroll um in der Karte zu zoomen`},en_GB:{search:`Search`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use two fingers to move the map`,windowsHelpText:`Use Ctrl + scroll to zoom the map`,macHelpText:`Use ⌘ + scroll to zoom the map`},es_ES:{search:`Buscar`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use dos dedos para mover el mapa`,windowsHelpText:`Use Ctrl + desplazamiento para hacer zoom en el mapa`,macHelpText:`Use ⌘ + desplazamiento para hacer zoom en el mapa`},fr_FR:{search:`Rechercher`,videoAlert:`Votre vidéo sera diffusée sur la carte publiée`,mobileHelpText:`Utilisez deux doigts pour déplacer la carte`,windowsHelpText:`Utilisez Ctrl + défilement pour zoomer sur la carte`,macHelpText:`Utilisez ⌘ + défilement pour zoomer sur la carte`},it_IT:{search:`Cercare`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Usa due dita per muovere la mappa`,windowsHelpText:`Usa Ctrl + Scroll per ingrandire la mappa`,macHelpText:`Usa ⌘ + Scroll per ingrandire la mappa`},nl_NL:{search:`Zoeken`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Gebruik twee vingers om de kaart te bewegen`,windowsHelpText:`Gebruik Ctrl + Scroll om de kaart te zoomen`,macHelpText:`Gebruik ⌘ + Scroll om de kaart te zoomen`}};function Ti(){let e=navigator.language.replace(`-`,`_`),t=Object.keys(wi);return t.find(t=>t===e)??t.find(t=>t.split(`_`)[0]===e.split(`_`)[0])??`en_GB`}var Ei=Ti();function Di(e){return wi[Ei][e]??e}var Oi=class{async getLocationInBounds(e,t,n=10){try{let r=await this._callGraphHopper({limit:n,q:e,point:`${t.lat},${t.lng}`});return this._mapResults(r.hits)}catch(e){return console.warn(`Geocoding failed: `,e),[]}}async _callGraphHopper(e){let t=new URLSearchParams(e);t.append(`key`,`c5c40ac9-ed73-4e20-aed6-cfe495604ca8`),t.append(`locale`,Ei.slice(0,2));let n={headers:{Accept:`application/json`}},r=`https://graphhopper.com/api/1/geocode?${t}`;return await(await fetch(r,n)).json()}_mapResults(e){return e.map(e=>({id:e.osm_id.toString(),labelTitle:e.name,position:{lng:e.point.lng,lat:e.point.lat},bbox:e.extent?[{lng:e.extent[0],lat:e.extent[1]},{lng:e.extent[2],lat:e.extent[3]}]:null,subtitle:[e.osm_value,e.city,e.state,e.country].filter(Boolean).join(`, `)}))}},ki=class{map;mapContainer;container;control;input;dropdown;inputWrapper;button;isOpen=!1;geocoder=new Oi;suggestions=[];items=[];index=0;debounce;constructor(e){this.map=e,this.container=document.createElement(`div`),this.control=document.createElement(`div`),this.input=document.createElement(`input`),this.dropdown=document.createElement(`div`),this.inputWrapper=document.createElement(`div`),this.button=document.createElement(`button`),this.mapContainer=this.map.getContainer()}init(){this.container.className=`geocoder-container`,this.control.className=`geocoder-control`,this.input.className=`geocoder-input`,this.dropdown.className=`geocoder-dropdown`,this.inputWrapper.className=`geocoder-input-wrapper`,this.button.className=`control-button`,this.input.type=`text`,this.input.placeholder=Di(`search`),this.button.innerHTML=Si;let e=document.createElement(`button`);e.className=`geocoder-clear`,e.innerHTML=Ci;let t=document.createElement(`div`);return t.className=`geocoder-scrollwrapper`,t.append(this.dropdown),this.inputWrapper.append(this.input,e),this.control.append(this.button,this.inputWrapper,t),e.addEventListener(`click`,()=>this.clearAll()),this.button.addEventListener(`click`,()=>this.toggle()),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`keydown`,e=>this.onKeyDown(e)),this.dropdown.addEventListener(`mousemove`,e=>this.onMouseMove(e)),this.mapContainer.addEventListener(`mousedown`,e=>this.clickOutside(e)),window.addEventListener(`resize`,()=>this.setMaxSizes()),this.setMaxSizes(),this.updateVisibility(),this.container.append(this.control),this.container}clickOutside(e){e.target instanceof Node&&!this.control.contains(e.target)&&this.hide()}setMaxSizes(){let{width:e,height:t}=this.mapContainer.getBoundingClientRect();this.control.style.maxWidth=`${e-40}px`,this.dropdown.style.maxHeight=`${Math.min(310,t-63)}px`}toggle(){this.isOpen=!this.isOpen,this.button.classList.toggle(`open`),this.updateVisibility(),this.isOpen&&this.input.focus()}hide(){this.isOpen&&(this.isOpen=!1,this.button.classList.remove(`open`),this.updateVisibility())}clearDropdown(){this.suggestions=[],this.items=[],this.dropdown.innerHTML=``}clearAll(){this.input.value=``,this.clearDropdown()}updateVisibility(){let e=this.isOpen;this.inputWrapper.style.display=e?`flex`:`none`,e||this.clearAll()}onInput(){let e=this.input.value.trim();if(this.debounce&&clearTimeout(this.debounce),e.length<2){this.dropdown.innerHTML=``;return}this.debounce=window.setTimeout(async()=>{this.suggestions=await this.geocoder.getLocationInBounds(e,this.map.getCenter(),20),this.items=[],this.renderSuggestions()},200)}renderSuggestions(){this.dropdown.innerHTML=``,this.items=[],this.index=0,this.suggestions.forEach(e=>{let t=document.createElement(`div`),n=document.createElement(`div`),r=document.createElement(`div`);t.className=`geocoder-suggestion`,n.className=`title`,r.className=`subtitle`,n.textContent=e.labelTitle,r.textContent=e.subtitle,t.append(n,r),t.addEventListener(`mousedown`,t=>{t.stopPropagation(),this.goToSelection(e)}),this.dropdown.appendChild(t),this.items.push({data:e,el:t})}),this.updateHighlight()}updateHighlight(){this.items.forEach((e,t)=>{e.el.classList.toggle(`highlight`,t===this.index)})}onKeyDown(e){if(e.key===`ArrowUp`)e.preventDefault(),this.index--,this.index<0&&(this.index=this.items.length-1),this.adjustScroll();else if(e.key===`ArrowDown`)e.preventDefault(),this.index++,this.index>this.items.length-1&&(this.index=0),this.adjustScroll();else if(e.key===`Enter`){e.preventDefault();let t=this.items[this.index];t&&this.goToSelection(t.data)}else e.key===`Escape`&&(e.preventDefault(),this.hide());this.updateHighlight()}onMouseMove(e){let t=e.target.closest(`.geocoder-suggestion`);this.index=this.items.findIndex(e=>e.el===t),this.updateHighlight()}goToSelection(e){e.bbox?this.map.fitBounds(e.bbox,{duration:0,animate:!1}):this.map.jumpTo({center:e.position,zoom:16}),this.input.value=e.labelTitle,this.clearDropdown()}adjustScroll(){let e=this.items[this.index].el,t=this.dropdown,n=t.getBoundingClientRect(),r=e.getBoundingClientRect();r.bottom>n.bottom?t.scrollTop+=r.bottom-n.bottom:r.top<n.top&&(t.scrollTop+=r.top-n.top)}};function Ai(e,t,n){let r=document.createElement(`div`);r.classList.add(`web-control`,`adornment`);let i=e.buttons.flatMap(e=>e===`zoom`?[`zoomIn`,`zoomOut`]:e);return(dr()?i.filter(e=>e!==`zoomIn`&&e!==`zoomOut`):i).forEach(e=>{let i;if(e===`zoomIn`)i=ri(t);else if(e===`zoomOut`)i=ii(t);else if(e===`fullscreen`)i=ui(t);else if(e===`geolocation`)i=yi(t);else if(e===`refresh`)i=xi(t,n);else if(e===`search`)i=new ki(t).init();else return;r.appendChild(i)}),r}function ji(e){return An(e,(e,t)=>e+Mi(t),0)}function Mi(e){let t=0,n;switch(e.type){case`Polygon`:return Ni(e.coordinates);case`MultiPolygon`:for(n=0;n<e.coordinates.length;n++)t+=Ni(e.coordinates[n]);return t;case`Point`:case`MultiPoint`:case`LineString`:case`MultiLineString`:return 0}return 0}function Ni(e){let t=0;if(e&&e.length>0){t+=Math.abs(Ii(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(Ii(e[n]))}return t}var Pi=xn*xn/2,Fi=Math.PI/180;function Ii(e){let t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){let i=e[r],a=e[r+1===t?0:r+1],o=e[r+2>=t?(r+2)%t:r+2],s=i[0]*Fi,c=a[1]*Fi,l=o[0]*Fi;n+=(l-s)*Math.sin(c),r++}return n*Pi}function Li(e){return e}function Ri(e){if(e==null)return Li;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;c<l;)u[c]=e[c],++c;return u}}function zi(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}function Bi(e,t){return typeof t==`string`&&(t=e.objects[t]),t.type===`GeometryCollection`?{type:`FeatureCollection`,features:t.geometries.map(function(t){return Vi(e,t)})}:Vi(e,t)}function Vi(e,t){var n=t.id,r=t.bbox,i=t.properties==null?{}:t.properties,a=Hi(e,t);return n==null&&r==null?{type:`Feature`,properties:i,geometry:a}:r==null?{type:`Feature`,id:n,properties:i,geometry:a}:{type:`Feature`,id:n,bbox:r,properties:i,geometry:a}}function Hi(e,t){var n=Ri(e.transform),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],a=0,o=i.length;a<o;++a)t.push(n(i[a],a));e<0&&zi(t,o)}function a(e){return n(e)}function o(e){for(var t=[],n=0,r=e.length;n<r;++n)i(e[n],t);return t.length<2&&t.push(t[0]),t}function s(e){for(var t=o(e);t.length<4;)t.push(t[0]);return t}function c(e){return e.map(s)}function l(e){var t=e.type,n;switch(t){case`GeometryCollection`:return{type:t,geometries:e.geometries.map(l)};case`Point`:n=a(e.coordinates);break;case`MultiPoint`:n=e.coordinates.map(a);break;case`LineString`:n=o(e.arcs);break;case`MultiLineString`:n=e.arcs.map(o);break;case`Polygon`:n=c(e.arcs);break;case`MultiPolygon`:n=e.arcs.map(c);break;default:return null}return{type:t,coordinates:n}}return l(t)}var Ui=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Wi=Math.ceil,Gi=Math.floor,Ki=`[BigNumber Error] `,qi=Ki+`Number primitive has more than 15 significant digits: `,Ji=0x5af3107a4000,J=14,Yi=9007199254740991,Xi=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],Zi=1e7,Qi=1e9;function $i(e){var t,n,r,i=v.prototype={constructor:v,toString:null,valueOf:null},a=new v(1),o=20,s=4,c=-7,l=21,u=-1e7,d=1e7,f=!1,p=1,m=0,h={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=!0;function v(e,t){var i,a,c,l,f,p,m,h,y=this;if(!(y instanceof v))return new v(e,t);if(t==null){if(e&&e._isBigNumber===!0){y.s=e.s,!e.c||e.e>d?y.c=y.e=null:e.e<u?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);l>d?y.c=y.e=null:(y.e=l,y.c=[e]);return}h=String(e)}else{if(!Ui.test(h=String(e)))return r(y,h,p);y.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(l=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(l<0&&(l=f),l+=+h.slice(f+1),h=h.substring(0,f)):l<0&&(l=h.length)}else{if(ra(t,2,g.length,`Base`),t==10&&_)return y=new v(e),S(y,o+y.e+1,s);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return r(y,h,p,t);if(y.s=1/e<0?(h=h.slice(1),-1):1,v.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error(qi+e)}else y.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=g.slice(0,t),l=f=0,m=h.length;f<m;f++)if(i.indexOf(a=h.charAt(f))<0){if(a==`.`){if(f>l){l=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,l=0;continue}return r(y,String(e),p,t)}p=!1,h=n(h,t,10,y.s),(l=h.indexOf(`.`))>-1?h=h.replace(`.`,``):l=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&v.DEBUG&&m>15&&(e>Yi||e!==Gi(e)))throw Error(qi+y.s*e);if((l=l-f-1)>d)y.c=y.e=null;else if(l<u)y.c=[y.e=0];else{if(y.e=l,y.c=[],f=(l+1)%J,l<0&&(f+=J),f<m){for(f&&y.c.push(+h.slice(0,f)),m-=J;f<m;)y.c.push(+h.slice(f,f+=J));f=J-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);y.c.push(+h)}}else y.c=[y.e=0]}v.clone=$i,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(e){var t,n;if(e!=null)if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],ra(n,0,Qi,t),o=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],ra(n,0,8,t),s=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(ra(n[0],-Qi,0,t),ra(n[1],0,Qi,t),c=n[0],l=n[1]):(ra(n,-Qi,Qi,t),c=-(l=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`))if(n=e[t],n&&n.pop)ra(n[0],-Qi,-1,t),ra(n[1],1,Qi,t),u=n[0],d=n[1];else if(ra(n,-Qi,Qi,t),n)u=-(d=n<0?-n:n);else throw Error(Ki+t+` cannot be zero: `+n);if(e.hasOwnProperty(t=`CRYPTO`))if(n=e[t],n===!!n)if(n)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=n;else throw f=!n,Error(Ki+`crypto unavailable`);else f=n;else throw Error(Ki+t+` not true or false: `+n);if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],ra(n,0,9,t),p=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],ra(n,0,Qi,t),m=n),e.hasOwnProperty(t=`FORMAT`))if(n=e[t],typeof n==`object`)h=n;else throw Error(Ki+t+` not an object: `+n);if(e.hasOwnProperty(t=`ALPHABET`))if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))_=n.slice(0,10)==`0123456789`,g=n;else throw Error(Ki+t+` invalid: `+n)}else throw Error(Ki+`Object expected: `+e);return{DECIMAL_PLACES:o,ROUNDING_MODE:s,EXPONENTIAL_AT:[c,l],RANGE:[u,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:m,FORMAT:h,ALPHABET:g}},v.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var t,n,r=e.c,i=e.e,a=e.s;out:if({}.toString.call(r)==`[object Array]`){if((a===1||a===-1)&&i>=-Qi&&i<=Qi&&i===Gi(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%J,t<1&&(t+=J),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=Ji||n!==Gi(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(a===null||a===1||a===-1))return!0;throw Error(Ki+`Invalid BigNumber: `+e)},v.maximum=v.max=function(){return b(arguments,-1)},v.minimum=v.min=function(){return b(arguments,1)},v.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return Gi(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,s,c,l=0,u=[],d=new v(a);if(e==null?e=o:ra(e,0,Qi),s=Wi(e/J),f)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)c=n[l]*131072+(n[l+1]>>>11),c>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(c%0x5af3107a4000),l+=2);l=s/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(s*=7);l<s;)c=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],c>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(c%0x5af3107a4000),l+=7);l=s/7}else throw f=!1,Error(Ki+`crypto unavailable`);if(!f)for(;l<s;)c=t(),c<9e15&&(u[l++]=c%0x5af3107a4000);for(s=u[--l],e%=J,s&&e&&(c=Xi[J-e],u[l]=Gi(s/c)*c);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=J);for(l=1,c=u[0];c>=10;c/=10,l++);l<J&&(i-=J-l)}return d.e=i,d.c=u,d}})(),v.sum=function(){for(var e=1,t=arguments,n=new v(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,c,l){var u,d,f,p,h,_,y,b,x=r.indexOf(`.`),S=o,C=s;for(x>=0&&(p=m,m=0,r=r.replace(`.`,``),b=new v(i),_=b.pow(r.length-x),m=p,b.c=n(oa(ta(_.c),_.e,`0`),10,a,e),b.e=b.c.length),y=n(r,i,a,l?(u=g,e):(u=e,g)),f=p=y.length;y[--p]==0;y.pop());if(!y[0])return u.charAt(0);if(x<0?--f:(_.c=y,_.e=f,_.s=c,_=t(_,b,S,C,a),y=_.c,h=_.r,f=_.e),d=f+S+1,x=y[d],p=a/2,h=h||d<0||y[d+1]!=null,h=C<4?(x!=null||h)&&(C==0||C==(_.s<0?3:2)):x>p||x==p&&(C==4||h||C==6&&y[d-1]&1||C==(_.s<0?8:7)),d<1||!y[0])r=h?oa(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(y.length=d,h)for(--a;++y[--d]>a;)y[d]=0,d||(++f,y=[1].concat(y));for(p=y.length;!y[--p];);for(x=0,r=``;x<=p;r+=u.charAt(y[x++]));r=oa(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%Zi,u=t/Zi|0;for(e=e.slice();c--;)a=e[c]%Zi,o=e[c]/Zi|0,r=u*a+o*l,i=l*a+r%Zi*Zi+s,s=(i/n|0)+(r/Zi|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,y,b,x,C,w,T,E,D=r.s==i.s?1:-1,O=r.c,k=i.c;if(!O||!O[0]||!k||!k[0])return new v(!r.s||!i.s||(O?k&&O[0]==k[0]:!k)?NaN:O&&O[0]==0||!k?D*0:D/0);for(h=new v(D),g=h.c=[],l=r.e-i.e,D=a+l+1,s||(s=Ji,l=ea(r.e/J)-ea(i.e/J),D=D/J|0),u=0;k[u]==(O[u]||0);u++);if(k[u]>(O[u]||0)&&l--,D<0)g.push(1),d=!0;else{for(C=O.length,T=k.length,u=0,D+=2,f=Gi(s/(k[0]+1)),f>1&&(k=e(k,f,s),O=e(O,f,s),T=k.length,C=O.length),x=T,_=O.slice(0,T),y=_.length;y<T;_[y++]=0);E=k.slice(),E=[0].concat(E),w=k[0],k[1]>=s/2&&w++;do{if(f=0,c=t(k,_,T,y),c<0){if(b=_[0],T!=y&&(b=b*s+(_[1]||0)),f=Gi(b/w),f>1)for(f>=s&&(f=s-1),p=e(k,f,s),m=p.length,y=_.length;t(p,_,m,y)==1;)f--,n(p,T<m?E:k,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=k.slice(),m=p.length;if(m<y&&(p=[0].concat(p)),n(_,p,y,s),y=_.length,c==-1)for(;t(k,_,T,y)<1;)f++,n(_,T<y?E:k,y,s),y=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[y++]=O[x]||0:(_=[O[x]],y=1)}while((x++<C||_[0]!=null)&&D--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==Ji){for(u=1,D=g[0];D>=10;D/=10,u++);S(h,a+(h.e=u+l*J-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function y(e,t,n,r){var i,a,o,u,d;if(n==null?n=s:ra(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)d=ta(e.c),d=r==1||r==2&&(o<=c||o>=l)?aa(d,o):oa(d,o,`0`);else if(e=S(new v(e),t,n),a=e.e,d=ta(e.c),u=d.length,r==1||r==2&&(t<=a||a<=c)){for(;u<t;d+=`0`,u++);d=aa(d,a)}else if(t-=o+(r===2&&a>o),d=oa(d,a,`0`),a+1>u){if(--t>0)for(d+=`.`;t--;d+=`0`);}else if(t+=a-u,t>0)for(a+1==u&&(d+=`.`);t--;d+=`0`);return e.s<0&&i?`-`+d:d}function b(e,t){for(var n,r,i=1,a=new v(e[0]);i<e.length;i++)r=new v(e[i]),(!r.s||(n=na(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function x(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*J-1)>d?e.c=e.e=null:n<u?e.c=[e.e=0]:(e.e=n,e.c=t),e}r=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,s,c){var l,u=s?o:o.replace(i,``);if(r.test(u))a.s=isNaN(u)?null:u<0?-1:1;else{if(!s&&(u=u.replace(e,function(e,t,n){return l=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!c||c==l?t:e}),c&&(l=c,u=u.replace(t,`$1`).replace(n,`0.$1`)),o!=u))return new v(u,l);if(v.DEBUG)throw Error(Ki+`Not a`+(c?` base `+c:``)+` number: `+o);a.s=null}a.c=a.e=null}})();function S(e,t,n,r){var i,a,o,s,c,l,f,p=e.c,m=Xi;if(p){out:{for(i=1,s=p[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=J,o=t,c=p[l=0],f=Gi(c/m[i-o-1]%10);else if(l=Wi((a+1)/J),l>=p.length)if(r){for(;p.length<=l;p.push(0));c=f=0,i=1,a%=J,o=a-J+1}else break out;else{for(c=s=p[l],i=1;s>=10;s/=10,i++);a%=J,o=a-J+i,f=o<0?0:Gi(c/m[i-o-1]%10)}if(r=r||t<0||p[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(f||r)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:p[l-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,r?(t-=e.e+1,p[0]=m[(J-t%J)%J],e.e=-t||0):p[0]=e.e=0,e;if(a==0?(p.length=l,s=1,l--):(p.length=l+1,s=m[J-a],p[l]=o>0?Gi(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=p[0];o>=10;o/=10,a++);for(o=p[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,p[0]==Ji&&(p[0]=1));break}else{if(p[l]+=s,p[l]!=Ji)break;p[l--]=0,s=1}for(a=p.length;p[--a]===0;p.pop());}e.e>d?e.c=e.e=null:e.e<u&&(e.c=[e.e=0])}return e}function C(e){var t,n=e.e;return n===null?e.toString():(t=ta(e.c),t=n<=c||n>=l?aa(t,n):oa(t,n,`0`),e.s<0?`-`+t:t)}return i.absoluteValue=i.abs=function(){var e=new v(this);return e.s<0&&(e.s=1),e},i.comparedTo=function(e,t){return na(this,new v(e,t))},i.decimalPlaces=i.dp=function(e,t){var n,r,i,a=this;if(e!=null)return ra(e,0,Qi),t==null?t=s:ra(t,0,8),S(new v(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-ea(this.e/J))*J,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},i.dividedBy=i.div=function(e,n){return t(this,new v(e,n),o,s)},i.dividedToIntegerBy=i.idiv=function(e,n){return t(this,new v(e,n),0,1)},i.exponentiatedBy=i.pow=function(e,t){var n,r,i,o,c,l,u,d,f,p=this;if(e=new v(e),e.c&&!e.isInteger())throw Error(Ki+`Exponent not an integer: `+C(e));if(t!=null&&(t=new v(t)),l=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new v(C(p)**(l?e.s*(2-ia(e)):+C(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new v(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return o=p.s<0&&ia(e)?-0:0,p.e>-1&&(o=1/o),new v(u?1/o:o);else m&&(o=Wi(m/J+2));for(l?(n=new v(.5),u&&(e.s=1),d=ia(e)):(i=Math.abs(+C(e)),d=i%2),f=new v(a);;){if(d){if(f=f.times(p),!f.c)break;o?f.c.length>o&&(f.c.length=o):r&&(f=f.mod(t))}if(i){if(i=Gi(i/2),i===0)break;d=i%2}else if(e=e.times(n),S(e,e.e+1,1),e.e>14)d=ia(e);else{if(i=+C(e),i===0)break;d=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}return r?f:(u&&(f=a.div(f)),t?f.mod(t):o?S(f,m,s,c):f)},i.integerValue=function(e){var t=new v(this);return e==null?e=s:ra(e,0,8),S(t,t.e+1,e)},i.isEqualTo=i.eq=function(e,t){return na(this,new v(e,t))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(e,t){return na(this,new v(e,t))>0},i.isGreaterThanOrEqualTo=i.gte=function(e,t){return(t=na(this,new v(e,t)))===1||t===0},i.isInteger=function(){return!!this.c&&ea(this.e/J)>this.c.length-2},i.isLessThan=i.lt=function(e,t){return na(this,new v(e,t))<0},i.isLessThanOrEqualTo=i.lte=function(e,t){return(t=na(this,new v(e,t)))===-1||t===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(e,t){var n,r,i,a,o=this,c=o.s;if(e=new v(e,t),t=e.s,!c||!t)return new v(NaN);if(c!=t)return e.s=-t,o.plus(e);var l=o.e/J,u=e.e/J,d=o.c,f=e.c;if(!l||!u){if(!d||!f)return d?(e.s=-t,e):new v(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new v(d[0]?o:s==3?-0:0)}if(l=ea(l),u=ea(u),d=d.slice(),c=l-u){for((a=c<0)?(c=-c,i=d):(u=l,i=f),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(a=(c=d.length)<(t=f.length))?c:t,c=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=Ji-1;r>c;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=Ji}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?x(e,d,u):(e.s=s==3?-1:1,e.c=[e.e=0],e)},i.modulo=i.mod=function(e,n){var r,i,a=this;return e=new v(e,n),!a.c||!e.s||e.c&&!e.c[0]?new v(NaN):!e.c||a.c&&!a.c[0]?new v(a):(p==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,p),e=a.minus(r.times(e)),!e.c[0]&&p==1&&(e.s=a.s),e)},i.multipliedBy=i.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,y=_.c,b=(e=new v(e,t)).c;if(!y||!b||!y[0]||!b[0])return!_.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=_.s,!y||!b?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=ea(_.e/J)+ea(e.e/J),e.s*=_.s,c=y.length,d=b.length,c<d&&(m=y,y=b,b=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=Ji,g=Zi,i=d;--i>=0;){for(n=0,f=b[i]%g,p=b[i]/g|0,o=c,a=i+o;a>i;)l=y[--o]%g,u=y[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),x(e,m,r)},i.negated=function(){var e=new v(this);return e.s=-e.s||null,e},i.plus=function(e,t){var n,r=this,i=r.s;if(e=new v(e,t),t=e.s,!i||!t)return new v(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/J,o=e.e/J,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new v(i/0);if(!s[0]||!c[0])return c[0]?e:new v(s[0]?r:i*0)}if(a=ea(a),o=ea(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/Ji|0,s[t]=Ji===s[t]?0:s[t]%Ji;return i&&(s=[i].concat(s),++o),x(e,s,o)},i.precision=i.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return ra(e,1,Qi),t==null?t=s:ra(t,0,8),S(new v(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*J+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},i.shiftedBy=function(e){return ra(e,-Yi,Yi),this.times(`1e`+e)},i.squareRoot=i.sqrt=function(){var e,n,r,i,a,c=this,l=c.c,u=c.s,d=c.e,f=o+4,p=new v(`0.5`);if(u!==1||!l||!l[0])return new v(!u||u<0&&(!l||l[0])?NaN:l?c:1/0);if(u=Math.sqrt(+C(c)),u==0||u==1/0?(n=ta(l),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=ea((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new v(n)):r=new v(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(c,a,f,1))),ta(a.c).slice(0,u)===(n=ta(r.c)).slice(0,u))if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(S(a,a.e+o+2,0),a.times(a).eq(c))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(S(r,r.e+o+2,1),e=!r.times(r).eq(c));break}}return S(r,r.e+o+1,s,e)},i.toExponential=function(e,t){return e!=null&&(ra(e,0,Qi),e++),y(this,e,t,1)},i.toFixed=function(e,t){return e!=null&&(ra(e,0,Qi),e=e+this.e+1),y(this,e,t)},i.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=h;else if(typeof n!=`object`)throw Error(Ki+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,o=r.split(`.`),s=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||``,u=o[0],d=o[1],f=i.s<0,p=f?u.slice(1):u,m=p.length;if(c&&(a=s,s=c,c=a,m-=a),s>0&&m>0){for(a=m%s||s,u=p.substr(0,a);a<m;a+=s)u+=l+p.substr(a,s);c>0&&(u+=l+p.slice(a)),f&&(u=`-`+u)}r=d?u+(n.decimalSeparator||``)+((c=+n.fractionGroupSize)?d.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):d):u}return(n.prefix||``)+r+(n.suffix||``)},i.toFraction=function(e){var n,r,i,o,c,l,u,f,p,m,h,g,_=this,y=_.c;if(e!=null&&(u=new v(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(a)))throw Error(Ki+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+C(u));if(!y)return new v(_);for(n=new v(a),p=r=new v(a),i=f=new v(a),g=ta(y),c=n.e=g.length-_.e-1,n.c[0]=Xi[(l=c%J)<0?J+l:l],e=!e||u.comparedTo(n)>0?c>0?n:p:u,l=d,d=1/0,u=new v(g),f.c[0]=0;m=t(u,n,0,1),o=r.plus(m.times(i)),o.comparedTo(e)!=1;)r=i,i=o,p=f.plus(m.times(o=p)),f=o,n=u.minus(m.times(o=n)),u=o;return o=t(e.minus(r),i,0,1),f=f.plus(o.times(p)),r=r.plus(o.times(i)),f.s=p.s=_.s,c*=2,h=t(p,i,c,s).minus(_).abs().comparedTo(t(f,r,c,s).minus(_).abs())<1?[p,i]:[f,r],d=l,h},i.toNumber=function(){return+C(this)},i.toPrecision=function(e,t){return e!=null&&ra(e,1,Qi),y(this,e,t,2)},i.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=c||a>=l?aa(ta(r.c),a):oa(ta(r.c),a,`0`):e===10&&_?(r=S(new v(r),o+a+1,s),t=oa(ta(r.c),r.e,`0`)):(ra(e,2,g.length,`Base`),t=n(oa(ta(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},i.valueOf=i.toJSON=function(){return C(this)},i._isBigNumber=!0,i[Symbol.toStringTag]=`BigNumber`,i[Symbol.for(`nodejs.util.inspect.custom`)]=i.valueOf,e!=null&&v.set(e),v}function ea(e){var t=e|0;return e>0||e===t?t:t-1}function ta(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=J-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function na(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function ra(e,t,n,r){if(e<t||e>n||e!==Gi(e))throw Error(Ki+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function ia(e){var t=e.c.length-1;return ea(e.e/J)==t&&e.c[t]%2!=0}function aa(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function oa(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}var sa=$i(),Y=class{key;left=null;right=null;constructor(e){this.key=e}},ca=class extends Y{constructor(e){super(e)}},la=class{size=0;modificationCount=0;splayCount=0;splay(e){let t=this.root;if(t==null)return this.compare(e,e),-1;let n=null,r=null,i=null,a=null,o=t,s=this.compare,c;for(;;)if(c=s(o.key,e),c>0){let t=o.left;if(t==null||(c=s(t.key,e),c>0&&(o.left=t.right,t.right=o,o=t,t=o.left,t==null)))break;n==null?r=o:n.left=o,n=o,o=t}else if(c<0){let t=o.right;if(t==null||(c=s(t.key,e),c<0&&(o.right=t.left,t.left=o,o=t,t=o.right,t==null)))break;i==null?a=o:i.right=o,i=o,o=t}else break;return i!=null&&(i.right=o.left,o.left=a),n!=null&&(n.left=o.right,o.right=r),this.root!==o&&(this.root=o,this.splayCount++),c}splayMin(e){let t=e,n=t.left;for(;n!=null;){let e=n;t.left=e.right,e.right=t,t=e,n=t.left}return t}splayMax(e){let t=e,n=t.right;for(;n!=null;){let e=n;t.right=e.left,e.left=t,t=e,n=t.right}return t}_delete(e){if(this.root==null||this.splay(e)!=0)return null;let t=this.root,n=t,r=t.left;if(this.size--,r==null)this.root=t.right;else{let e=t.right;t=this.splayMax(r),t.right=e,this.root=t}return this.modificationCount++,n}addNewRoot(e,t){this.size++,this.modificationCount++;let n=this.root;if(n==null){this.root=e;return}t<0?(e.left=n,e.right=n.right,n.right=null):(e.right=n,e.left=n.left,n.left=null),this.root=e}_first(){let e=this.root;return e==null?null:(this.root=this.splayMin(e),this.root)}_last(){let e=this.root;return e==null?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&this.splay(e)==0}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},ua=class e extends la{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>e!=null&&e!=null)}delete(e){return this.validKey(e)?this._delete(e)!=null:!1}deleteAll(e){for(let t of e)this.delete(t)}forEach(e){let t=this[Symbol.iterator](),n;for(;n=t.next(),!n.done;)e(n.value,n.value,this)}add(e){let t=this.splay(e);return t!=0&&this.addNewRoot(new ca(e),t),this}addAndReturn(e){let t=this.splay(e);return t!=0&&this.addNewRoot(new ca(e),t),this.root.key}addAll(e){for(let t of e)this.add(t)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw`Bad state: No element`;if(this.size>1)throw`Bad state: Too many element`;return this.root.key}first(){if(this.size==0)throw`Bad state: No element`;return this._first().key}last(){if(this.size==0)throw`Bad state: No element`;return this._last().key}lastBefore(e){if(e==null)throw`Invalid arguments(s)`;if(this.root==null)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(t==null)return null;let n=t.right;for(;n!=null;)t=n,n=t.right;return t.key}firstAfter(e){if(e==null)throw`Invalid arguments(s)`;if(this.root==null)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(t==null)return null;let n=t.left;for(;n!=null;)t=n,n=t.left;return t.key}retainAll(t){let n=new e(this.compare,this.validKey),r=this.modificationCount;for(let e of t){if(r!=this.modificationCount)throw`Concurrent modification during iteration.`;this.validKey(e)&&this.splay(e)==0&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(e){return!this.validKey(e)||this.splay(e)!=0?null:this.root.key}intersection(t){let n=new e(this.compare,this.validKey);for(let e of this)t.has(e)&&n.add(e);return n}difference(t){let n=new e(this.compare,this.validKey);for(let e of this)t.has(e)||n.add(e);return n}union(e){let t=this.clone();return t.addAll(e),t}clone(){let t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(e==null)return null;function t(e,n){let r,i;do{if(r=e.left,i=e.right,r!=null){let e=new ca(r.key);n.left=e,t(r,e)}if(i!=null){let t=new ca(i.key);n.right=t,e=i,n=t}}while(i!=null)}let n=new ca(e.key);return t(e,n),n}toSet(){return this.clone()}entries(){return new pa(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new fa(this.wrap())}[Symbol.toStringTag]=`[object Set]`},da=class{tree;path=[];modificationCount=null;splayCount;constructor(e){this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;let e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;e!=null;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;e!=null;)this.path.push(e),e=e.left;return this.path.length>0}throw`Concurrent modification during iteration.`}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(t!=null){for(;t!=null;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},fa=class extends da{getValue(e){return e.key}},pa=class extends da{getValue(e){return[e.key,e.key]}},X=e=>()=>e,ma=e=>{let t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):X(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function ha(e){let t=e?(t,n,r,i,a)=>t.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(a.minus(r).exponentiatedBy(2)).times(e)):X(!1);return(e,n,r)=>{let i=e.x,a=e.y,o=r.x,s=r.y,c=a.minus(s).times(n.x.minus(o)).minus(i.minus(o).times(n.y.minus(s)));return t(c,i,a,o,s)?0:c.comparedTo(0)}}var ga=e=>e,_a=e=>{if(e){let t=new ua(ma(e)),n=new ua(ma(e)),r=(e,t)=>t.addAndReturn(e),i=e=>({x:r(e.x,t),y:r(e.y,n)});return i({x:new sa(0),y:new sa(0)}),i}return ga},va=e=>({set:e=>{ya=va(e)},reset:()=>va(e),compare:ma(e),snap:_a(e),orient:ha(e)}),ya=va(),ba=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),xa=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;let n=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,r=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x,i=e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y,a=e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y;return{ll:{x:n,y:i},ur:{x:r,y:a}}},Sa=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),Ca=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),wa=e=>Ca(e,e).sqrt(),Ta=(e,t,n)=>{let r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Sa(i,r).div(wa(i)).div(wa(r))},Ea=(e,t,n)=>{let r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Ca(i,r).div(wa(i)).div(wa(r))},Da=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},Oa=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},ka=(e,t,n,r)=>{if(t.x.isZero())return Oa(n,r,e.x);if(r.x.isZero())return Oa(e,t,n.x);if(t.y.isZero())return Da(n,r,e.y);if(r.y.isZero())return Da(e,t,n.y);let i=Sa(t,r);if(i.isZero())return null;let a={x:n.x.minus(e.x),y:n.y.minus(e.y)},o=Sa(a,t).div(i),s=Sa(a,r).div(i),c=e.x.plus(s.times(t.x)),l=n.x.plus(o.times(r.x)),u=e.y.plus(s.times(t.y)),d=n.y.plus(o.times(r.y));return{x:c.plus(l).div(2),y:u.plus(d).div(2)}},Aa=class e{point;isLeft;segment;otherSE;consumedBy;static compare(t,n){let r=e.comparePoints(t.point,n.point);return r===0?(t.point!==n.point&&t.link(n),t.isLeft===n.isLeft?Ia.compare(t.segment,n.segment):t.isLeft?1:-1):r}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw Error(`Tried to link already linked events`);let t=e.point.events;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){let e=this.point.events.length;for(let t=0;t<e;t++){let n=this.point.events[t];if(n.segment.consumedBy===void 0)for(let r=t+1;r<e;r++){let e=this.point.events[r];e.consumedBy===void 0&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){let e=[];for(let t=0,n=this.point.events.length;t<n;t++){let n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){let t=new Map,n=n=>{let r=n.otherSE;t.set(n,{sine:Ta(this.point,e.point,r.point),cosine:Ea(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);let{sine:i,cosine:a}=t.get(e),{sine:o,cosine:s}=t.get(r);return i.isGreaterThanOrEqualTo(0)&&o.isGreaterThanOrEqualTo(0)?a.isLessThan(s)?1:a.isGreaterThan(s)?-1:0:i.isLessThan(0)&&o.isLessThan(0)?a.isLessThan(s)?-1:a.isGreaterThan(s)?1:0:o.isLessThan(i)?-1:o.isGreaterThan(i)?1:0}}},ja=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];if(!i.isInResult()||i.ringOut)continue;let a=null,o=i.leftSE,s=i.rightSE,c=[o],l=o.point,u=[];for(;a=o,o=s,c.push(o),o.point!==l;)for(;;){let t=o.getAvailableLinkedEvents();if(t.length===0){let e=c[0].point,t=c[c.length-1].point;throw Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(t.length===1){s=t[0].otherSE;break}let r=null;for(let e=0,t=u.length;e<t;e++)if(u[e].point===o.point){r=e;break}if(r!==null){let t=u.splice(r)[0],i=c.splice(t.index);i.unshift(i[0].otherSE),n.push(new e(i.reverse()));continue}u.push({index:c.length,point:o.point});let i=o.getLeftmostComparator(a);s=t.sort(i)[0].otherSE;break}n.push(new e(c))}return n}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point,t=[e];for(let n=1,r=this.events.length-1;n<r;n++){let r=this.events[n].point,i=this.events[n+1].point;ya.orient(r,e,i)!==0&&(t.push(r),e=r)}if(t.length===1)return null;let n=t[0],r=t[1];ya.orient(n,e,r)===0&&t.shift(),t.push(t[0]);let i=this.isExteriorRing()?1:-1,a=this.isExteriorRing()?0:t.length-1,o=this.isExteriorRing()?t.length:-1,s=[];for(let e=a;e!=o;e+=i)s.push([t[e].x.toNumber(),t[e].y.toNumber()]);return s}isExteriorRing(){if(this._isExteriorRing===void 0){let e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){let n=this.events[t];Aa.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut?.enclosingRing()===t.ringOut?t.ringOut?.enclosingRing():t.ringOut;t=n.prevInResult(),n=t?t.prevInResult():null}}},Ma=class{exteriorRing;interiorRings;constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){let e=this.exteriorRing.getGeom();if(e===null)return null;let t=[e];for(let e=0,n=this.interiorRings.length;e<n;e++){let n=this.interiorRings[e].getGeom();n!==null&&t.push(n)}return t}},Na=class{rings;polys;constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getGeom();n!==null&&e.push(n)}return e}_composePolys(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new Ma(r));else{let e=r.enclosingRing();e?.poly||t.push(new Ma(e)),e?.poly?.addInterior(r)}}return t}},Pa=class{queue;tree;segments;constructor(e,t=Ia.compare){this.queue=e,this.tree=new ua(t),this.segments=[]}process(e){let t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),n;e.isLeft&&this.tree.add(t);let r=t,i=t;do r=this.tree.lastBefore(r);while(r!=null&&r.consumedBy!=null);do i=this.tree.firstAfter(i);while(i!=null&&i.consumedBy!=null);if(e.isLeft){let a=null;if(r){let e=r.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(a=e),!r.isAnEndpoint(e))){let t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let o=null;if(i){let e=i.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(o=e),!i.isAnEndpoint(e))){let t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(a!==null||o!==null){let e=null;e=a===null?o:o===null||Aa.comparePoints(a,o)<=0?a:o,this.queue.delete(t.rightSE),n.push(t.rightSE);let r=t.split(e);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&i){let e=r.getIntersection(i);if(e!==null){if(!r.isAnEndpoint(e)){let t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!i.isAnEndpoint(e)){let t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.delete(t)}return n}_splitSafely(e,t){this.tree.delete(e);let n=e.rightSE;this.queue.delete(n);let r=e.split(t);return r.push(n),e.consumedBy===void 0&&this.tree.add(e),r}},Fa=new class{type;numMultiPolys;run(e,t,n){Fa.type=e;let r=[new za(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new za(n[e],!1));if(Fa.numMultiPolys=r.length,Fa.type===`difference`){let e=r[0],t=1;for(;t<r.length;)xa(r[t].bbox,e.bbox)===null?r.splice(t,1):t++}if(Fa.type===`intersection`)for(let e=0,t=r.length;e<t;e++){let t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(xa(t.bbox,r[n].bbox)===null)return[]}let i=new ua(Aa.compare);for(let e=0,t=r.length;e<t;e++){let t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)i.add(t[e])}let a=new Pa(i),o=null;for(i.size!=0&&(o=i.first(),i.delete(o));o;){let e=a.process(o);for(let t=0,n=e.length;t<n;t++){let n=e[t];n.consumedBy===void 0&&i.add(n)}i.size==0?o=null:(o=i.first(),i.delete(o))}return ya.reset(),new Na(ja.factory(a.segments)).getGeom()}},Z=Fa,Q=0,Ia=class e{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){let n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,a=t.rightSE.point.x;if(a.isLessThan(n))return 1;if(i.isLessThan(r))return-1;let o=e.leftSE.point.y,s=t.leftSE.point.y,c=e.rightSE.point.y,l=t.rightSE.point.y;if(n.isLessThan(r)){if(s.isLessThan(o)&&s.isLessThan(c))return 1;if(s.isGreaterThan(o)&&s.isGreaterThan(c))return-1;let n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;let r=t.comparePoint(e.rightSE.point);return r===0?-1:r}if(n.isGreaterThan(r)){if(o.isLessThan(s)&&o.isLessThan(l))return-1;if(o.isGreaterThan(s)&&o.isGreaterThan(l))return 1;let n=t.comparePoint(e.leftSE.point);if(n!==0)return n;let r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(o.isLessThan(s))return-1;if(o.isGreaterThan(s))return 1;if(i.isLessThan(a)){let n=t.comparePoint(e.rightSE.point);if(n!==0)return n}if(i.isGreaterThan(a)){let n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!i.eq(a)){let e=c.minus(o),t=i.minus(n),u=l.minus(s),d=a.minus(r);if(e.isGreaterThan(t)&&u.isLessThan(d))return 1;if(e.isLessThan(t)&&u.isGreaterThan(d))return-1}return i.isGreaterThan(a)?1:i.isLessThan(a)||c.isLessThan(l)?-1:c.isGreaterThan(l)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++Q,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(t,n,r){let i,a,o,s=Aa.comparePoints(t,n);if(s<0)i=t,a=n,o=1;else if(s>0)i=n,a=t,o=-1;else throw Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);return new e(new Aa(i,!0),new Aa(a,!1),[r],[o])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return ya.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){let t=this.bbox(),n=e.bbox(),r=xa(t,n);if(r===null)return null;let i=this.leftSE.point,a=this.rightSE.point,o=e.leftSE.point,s=e.rightSE.point,c=ba(t,o)&&this.comparePoint(o)===0,l=ba(n,i)&&e.comparePoint(i)===0,u=ba(t,s)&&this.comparePoint(s)===0,d=ba(n,a)&&e.comparePoint(a)===0;if(l&&c)return d&&!u?a:!d&&u?s:null;if(l)return u&&i.x.eq(s.x)&&i.y.eq(s.y)?null:i;if(c)return d&&a.x.eq(o.x)&&a.y.eq(o.y)?null:o;if(d&&u)return null;if(d)return a;if(u)return s;let f=ka(i,this.vector(),o,e.vector());return f===null||!ba(r,f)?null:ya.snap(f)}split(t){let n=[],r=t.events!==void 0,i=new Aa(t,!0),a=new Aa(t,!1),o=this.rightSE;this.replaceRightSE(a),n.push(a),n.push(i);let s=new e(i,o,this.rings.slice(),this.windings.slice());return Aa.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),Aa.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),a.checkForConsuming()),n}swapEvents(){let e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;let i=e.compare(n,r);if(i!==0){if(i>0){let e=n;n=r,r=e}if(n.prev===r){let e=n;n=r,r=e}for(let e=0,t=r.rings.length;e<t;e++){let t=r.rings[e],i=r.windings[e],a=n.rings.indexOf(t);a===-1?(n.rings.push(t),n.windings.push(i)):n.windings[a]+=i}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}prevInResult(){return this._prevInResult===void 0&&(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){return this._beforeState===void 0&&(this.prev?this._beforeState=(this.prev.consumedBy||this.prev).afterState():this._beforeState={rings:[],windings:[],multiPolys:[]}),this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};let t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){let r=this.rings[e],i=this.windings[e],a=t.indexOf(r);a===-1?(t.push(r),n.push(i)):n[a]+=i}let i=[],a=[];for(let e=0,r=t.length;e<r;e++){if(n[e]===0)continue;let r=t[e],o=r.poly;if(a.indexOf(o)===-1)if(r.isExterior)i.push(o);else{a.indexOf(o)===-1&&a.push(o);let e=i.indexOf(r.poly);e!==-1&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){let t=i[e].multiPoly;r.indexOf(t)===-1&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(Z.type){case`union`:this._isInResult=e.length===0!=(t.length===0);break;case`intersection`:{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===Z.numMultiPolys&&n<r;break}case`xor`:this._isInResult=Math.abs(e.length-t.length)%2==1;break;case`difference`:{let n=e=>e.length===1&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}}return this._isInResult}},La=class{poly;isExterior;segments;bbox;constructor(e,t,n){if(!Array.isArray(e)||e.length===0||(this.poly=t,this.isExterior=n,this.segments=[],typeof e[0][0]!=`number`||typeof e[0][1]!=`number`))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let r=ya.snap({x:new sa(e[0][0]),y:new sa(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if(typeof e[t][0]!=`number`||typeof e[t][1]!=`number`)throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let n=ya.snap({x:new sa(e[t][0]),y:new sa(e[t][1])});n.x.eq(i.x)&&n.y.eq(i.y)||(this.segments.push(Ia.fromRing(i,n,this)),n.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.x),n.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.y),n.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.x),n.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.y),i=n)}(!r.x.eq(i.x)||!r.y.eq(i.y))&&this.segments.push(Ia.fromRing(i,r,this))}getSweepEvents(){let e=[];for(let t=0,n=this.segments.length;t<n;t++){let n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}},Ra=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);this.exteriorRing=new La(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){let n=new La(e[t],this,!1);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){let e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},za=class{isSubject;polys;bbox;constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);try{typeof e[0][0][0]==`number`&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:new sa(1/0),y:new sa(1/0)},ur:{x:new sa(-1/0),y:new sa(-1/0)}};for(let t=0,n=e.length;t<n;t++){let n=new Ra(e[t],this);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},Ba=(e,...t)=>Z.run(`intersection`,e,t);ya.set;function Va(e,t={}){let n=[];if(kn(e,e=>{n.push(e.coordinates)}),n.length<2)throw Error(`Must specify at least 2 geometries`);let r=Ba(n[0],...n.slice(1));return r.length===0?null:r.length===1?Cn(r[0],t.properties):Dn(r,t.properties)}var Ha=1e-6,$=Math.PI,Ua=$/2,Wa=$/4,Ga=$*2,Ka=180/$,qa=$/180,Ja=Math.abs,Ya=Math.atan,Xa=Math.atan2,Za=Math.cos,Qa=Math.ceil,$a=Math.exp,eo=Math.log,to=Math.sin,no=Math.sign||function(e){return e>0?1:e<0?-1:0},ro=Math.sqrt,io=Math.tan;function ao(e){return e>1?0:e<-1?$:Math.acos(e)}function oo(e){return e>1?Ua:e<-1?-Ua:Math.asin(e)}function so(){}function co(e,t){e&&uo.hasOwnProperty(e.type)&&uo[e.type](e,t)}var lo={Feature:function(e,t){co(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)co(n[r].geometry,t)}},uo={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){fo(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)fo(n[r],t,0)},Polygon:function(e,t){po(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)po(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)co(n[r],t)}};function fo(e,t,n){var r=-1,i=e.length-n,a;for(t.lineStart();++r<i;)a=e[r],t.point(a[0],a[1],a[2]);t.lineEnd()}function po(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)fo(e[n],t,1);t.polygonEnd()}function mo(e,t){e&&lo.hasOwnProperty(e.type)?lo[e.type](e,t):co(e,t)}function ho(e){return[Xa(e[1],e[0]),oo(e[2])]}function go(e){var t=e[0],n=e[1],r=Za(n);return[r*Za(t),r*to(t),to(n)]}function _o(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function vo(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function yo(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function bo(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function xo(e){var t=ro(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}function So(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}function Co(e,t){return Ja(e)>$&&(e-=Math.round(e/Ga)*Ga),[e,t]}Co.invert=Co;function wo(e,t,n){return(e%=Ga)?t||n?So(Eo(e),Do(t,n)):Eo(e):t||n?Do(t,n):Co}function To(e){return function(t,n){return t+=e,Ja(t)>$&&(t-=Math.round(t/Ga)*Ga),[t,n]}}function Eo(e){var t=To(e);return t.invert=To(-e),t}function Do(e,t){var n=Za(e),r=to(e),i=Za(t),a=to(t);function o(e,t){var o=Za(t),s=Za(e)*o,c=to(e)*o,l=to(t),u=l*n+s*r;return[Xa(c*i-u*a,s*n-l*r),oo(u*i+c*a)]}return o.invert=function(e,t){var o=Za(t),s=Za(e)*o,c=to(e)*o,l=to(t),u=l*i-c*a;return[Xa(c*i+l*a,s*n+u*r),oo(u*n-s*r)]},o}function Oo(e){e=wo(e[0]*qa,e[1]*qa,e.length>2?e[2]*qa:0);function t(t){return t=e(t[0]*qa,t[1]*qa),t[0]*=Ka,t[1]*=Ka,t}return t.invert=function(t){return t=e.invert(t[0]*qa,t[1]*qa),t[0]*=Ka,t[1]*=Ka,t},t}function ko(e,t,n,r,i,a){if(n){var o=Za(t),s=to(t),c=r*n;i==null?(i=t+r*Ga,a=t-c/2):(i=Ao(o,i),a=Ao(o,a),(r>0?i<a:i>a)&&(i+=r*Ga));for(var l,u=i;r>0?u>a:u<a;u-=c)l=ho([o,-s*Za(u),-s*to(u)]),e.point(l[0],l[1])}}function Ao(e,t){t=go(t),t[0]-=e,xo(t);var n=ao(-t[1]);return((-t[2]<0?-n:n)+Ga-Ha)%Ga}function jo(){var e=[],t;return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:so,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Mo(e,t){return Ja(e[0]-t[0])<1e-6&&Ja(e[1]-t[1])<1e-6}function No(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Po(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(Mo(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s<t;++s)i.point((n=e[s])[0],n[1]);i.lineEnd();return}r[0]+=2*Ha}a.push(c=new No(n,e,null,!0)),o.push(c.o=new No(n,null,c,!1)),a.push(c=new No(r,e,null,!1)),o.push(c.o=new No(r,null,c,!0))}}),a.length){for(o.sort(t),Fo(a),Fo(o),s=0,c=o.length;s<c;++s)o[s].e=n=!n;for(var l=a[0],u,d;;){for(var f=l,p=!0;f.v;)if((f=f.n)===l)return;u=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(p)for(s=0,c=u.length;s<c;++s)i.point((d=u[s])[0],d[1]);else r(f.x,f.n.x,1,i);f=f.n}else{if(p)for(u=f.p.z,s=u.length-1;s>=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function Fo(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n<t;)r.n=i=e[n],i.p=r,r=i;r.n=i=e[0],i.p=r}}function Io(e){return Ja(e[0])<=$?e[0]:no(e[0])*((Ja(e[0])+$)%Ga-$)}function Lo(e,t){var n=Io(t),r=t[1],i=to(r),a=[to(n),-Za(n),0],o=0,s=0,c=new vt;i===1?r=Ua+Ha:i===-1&&(r=-Ua-Ha);for(var l=0,u=e.length;l<u;++l)if(f=(d=e[l]).length)for(var d,f,p=d[f-1],m=Io(p),h=p[1]/2+Wa,g=to(h),_=Za(h),v=0;v<f;++v,m=b,g=S,_=C,p=y){var y=d[v],b=Io(y),x=y[1]/2+Wa,S=to(x),C=Za(x),w=b-m,T=w>=0?1:-1,E=T*w,D=E>$,O=g*S;if(c.add(Xa(O*T*to(E),_*C+O*Za(E))),o+=D?w+T*Ga:w,D^m>=n^b>=n){var k=vo(go(p),go(y));xo(k);var A=vo(a,k);xo(A);var j=(D^w>=0?-1:1)*oo(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}function Ro(e,t,n,r){return function(i){var a=t(i),o=jo(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=Nt(u);var e=Lo(l,r);u.length?(c||=(i.polygonStart(),!0),Po(u,Bo,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n<a;++n)i.point((p=f[n])[0],p[1]);i.lineEnd()}return}r>1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(zo))}}return f}}function zo(e){return e.length>1}function Bo(e,t){return((e=e.x)[0]<0?e[1]-Ua-Ha:Ua-e[1])-((t=t.x)[0]<0?t[1]-Ua-Ha:Ua-t[1])}var Vo=Ro(function(){return!0},Ho,Wo,[-$,-Ua]);function Ho(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?$:-$,c=Ja(a-t);Ja(c-$)<1e-6?(e.point(t,n=(n+o)/2>0?Ua:-Ua),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=$&&(Ja(t-r)<1e-6&&(t-=r*Ha),Ja(a-s)<1e-6&&(a-=s*Ha),n=Uo(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function Uo(e,t,n,r){var i,a,o=to(e-n);return Ja(o)>1e-6?Ya((to(t)*(a=Za(r))*to(n)-to(r)*(i=Za(t))*to(e))/(i*a*o)):(t+r)/2}function Wo(e,t,n,r){var i;if(e==null)i=n*Ua,r.point(-$,i),r.point(0,i),r.point($,i),r.point($,0),r.point($,-i),r.point(0,-i),r.point(-$,-i),r.point(-$,0),r.point(-$,i);else if(Ja(e[0]-t[0])>1e-6){var a=e[0]<t[0]?$:-$;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i)}else r.point(t[0],t[1])}function Go(e){var t=Za(e),n=2*qa,r=t>0,i=Ja(t)>Ha;function a(t,r,i,a){ko(a,e,n,i,t,r)}function o(e,n){return Za(e)*Za(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?$:-$),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||Mo(t,m)||Mo(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!Mo(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=go(e),a=go(n),o=[1,0,0],s=vo(i,a),c=_o(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=vo(o,s),m=bo(o,d);yo(m,bo(s,f));var h=p,g=_o(m,h),_=_o(h,h),v=g*g-_*(_o(m,m)-1);if(!(v<0)){var y=ro(v),b=bo(h,(-g-y)/_);if(yo(b,m),b=ho(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S<x&&(T=x,x=S,S=T);var E=S-x,D=Ja(E-$)<Ha,O=D||E<1e-6;if(!D&&w<C&&(T=C,C=w,w=T),O?D?C+w>0^b[1]<(Ja(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>$^(x<=b[0]&&b[0]<=S)){var k=bo(h,(-g+y)/_);return yo(k,m),[b,ho(k)]}}}function l(t,n){var i=r?e:$-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return Ro(o,s,a,r?[0,-e]:[-$,e-$])}function Ko(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m<u)return;m<d&&(d=m)}else if(f>0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m<u)return;m<d&&(d=m)}if(m=r-s,!(!p&&m>0)){if(m/=p,p<0){if(m<u)return;m<d&&(d=m)}else if(p>0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m<u)return;m<d&&(d=m)}return u>0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var qo=1e9,Jo=-qo;function Yo(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return Ja(r[0]-e)<1e-6?i>0?0:3:Ja(r[0]-n)<1e-6?i>0?2:1:Ja(r[1]-t)<1e-6?i>0?1:0:i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=jo(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;n<i;++n)for(var a=d[n],o=1,s=a.length,c=a[0],l,u,f=c[0],p=c[1];o<s;++o)l=f,u=p,c=a[o],f=c[0],p=c[1],u<=r?p>r&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=Nt(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&Po(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(Jo,Math.min(qo,g)),_=Math.max(Jo,Math.min(qo,_))],u=[a=Math.max(Jo,Math.min(qo,a)),o=Math.max(Jo,Math.min(qo,o))];Ko(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}function Xo(e,t,n){var r=Pt(e,t-Ha,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function Zo(e,t,n){var r=Pt(e,t-Ha,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function Qo(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return Pt(Qa(r/u)*u,n,u).map(m).concat(Pt(Qa(s/d)*d,o,d).map(h)).concat(Pt(Qa(t/c)*c,e,c).filter(function(e){return Ja(e%u)>Ha}).map(f)).concat(Pt(Qa(a/l)*l,i,l).filter(function(e){return Ja(e%d)>Ha}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=Xo(a,i,90),p=Zo(t,e,g),m=Xo(s,o,90),h=Zo(r,n,g),_):g},_.extentMajor([[-180,-90+Ha],[180,90-Ha]]).extentMinor([[-180,-80-Ha],[180,80+Ha]])}var $o=e=>e,es=new vt,ts=new vt,ns,rs,is,as,os={point:so,lineStart:so,lineEnd:so,polygonStart:function(){os.lineStart=ss,os.lineEnd=us},polygonEnd:function(){os.lineStart=os.lineEnd=os.point=so,es.add(Ja(ts)),ts=new vt},result:function(){var e=es/2;return es=new vt,e}};function ss(){os.point=cs}function cs(e,t){os.point=ls,ns=is=e,rs=as=t}function ls(e,t){ts.add(as*e-is*t),is=e,as=t}function us(){ls(ns,rs)}var ds=1/0,fs=ds,ps=-ds,ms=ps,hs={point:gs,lineStart:so,lineEnd:so,polygonStart:so,polygonEnd:so,result:function(){var e=[[ds,fs],[ps,ms]];return ps=ms=-(fs=ds=1/0),e}};function gs(e,t){e<ds&&(ds=e),e>ps&&(ps=e),t<fs&&(fs=t),t>ms&&(ms=t)}var _s=0,vs=0,ys=0,bs=0,xs=0,Ss=0,Cs=0,ws=0,Ts=0,Es,Ds,Os,ks,As={point:js,lineStart:Ms,lineEnd:Fs,polygonStart:function(){As.lineStart=Is,As.lineEnd=Ls},polygonEnd:function(){As.point=js,As.lineStart=Ms,As.lineEnd=Fs},result:function(){var e=Ts?[Cs/Ts,ws/Ts]:Ss?[bs/Ss,xs/Ss]:ys?[_s/ys,vs/ys]:[NaN,NaN];return _s=vs=ys=bs=xs=Ss=Cs=ws=Ts=0,e}};function js(e,t){_s+=e,vs+=t,++ys}function Ms(){As.point=Ns}function Ns(e,t){As.point=Ps,js(Os=e,ks=t)}function Ps(e,t){var n=e-Os,r=t-ks,i=ro(n*n+r*r);bs+=i*(Os+e)/2,xs+=i*(ks+t)/2,Ss+=i,js(Os=e,ks=t)}function Fs(){As.point=js}function Is(){As.point=Rs}function Ls(){zs(Es,Ds)}function Rs(e,t){As.point=zs,js(Es=Os=e,Ds=ks=t)}function zs(e,t){var n=e-Os,r=t-ks,i=ro(n*n+r*r);bs+=i*(Os+e)/2,xs+=i*(ks+t)/2,Ss+=i,i=ks*e-Os*t,Cs+=i*(Os+e),ws+=i*(ks+t),Ts+=i*3,js(Os=e,ks=t)}function Bs(e){this._context=e}Bs.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,Ga);break}},result:so};var Vs=new vt,Hs,Us,Ws,Gs,Ks,qs={point:so,lineStart:function(){qs.point=Js},lineEnd:function(){Hs&&Ys(Us,Ws),qs.point=so},polygonStart:function(){Hs=!0},polygonEnd:function(){Hs=null},result:function(){var e=+Vs;return Vs=new vt,e}};function Js(e,t){qs.point=Ys,Us=Gs=e,Ws=Ks=t}function Ys(e,t){Gs-=e,Ks-=t,Vs.add(ro(Gs*Gs+Ks*Ks)),Gs=e,Ks=t}var Xs,Zs,Qs,$s,ec=class{constructor(e){this._append=e==null?tc:nc(e),this._radius=4.5,this._=``}pointRadius(e){return this._radius=+e,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+=`Z`),this._point=NaN}point(e,t){switch(this._point){case 0:this._append`M${e},${t}`,this._point=1;break;case 1:this._append`L${e},${t}`;break;default:if(this._append`M${e},${t}`,this._radius!==Qs||this._append!==Zs){let e=this._radius,t=this._;this._=``,this._append`m0,${e}a${e},${e} 0 1,1 0,${-2*e}a${e},${e} 0 1,1 0,${2*e}z`,Qs=e,Zs=this._append,$s=this._,this._=t}this._+=$s;break}}result(){let e=this._;return this._=``,e.length?e:null}};function tc(e){let t=1;this._+=e[0];for(let n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function nc(e){let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);if(t>15)return tc;if(t!==Xs){let e=10**t;Xs=t,Zs=function(t){let n=1;this._+=t[0];for(let r=t.length;n<r;++n)this._+=Math.round(arguments[n]*e)/e+t[n]}}return Zs}function rc(e,t){let n=3,r=4.5,i,a;function o(e){return e&&(typeof r==`function`&&a.pointRadius(+r.apply(this,arguments)),mo(e,i(a))),a.result()}return o.area=function(e){return mo(e,i(os)),os.result()},o.measure=function(e){return mo(e,i(qs)),qs.result()},o.bounds=function(e){return mo(e,i(hs)),hs.result()},o.centroid=function(e){return mo(e,i(As)),As.result()},o.projection=function(t){return arguments.length?(i=t==null?(e=null,$o):(e=t).stream,o):e},o.context=function(e){return arguments.length?(a=e==null?(t=null,new ec(n)):new Bs(t=e),typeof r!=`function`&&a.pointRadius(r),o):t},o.pointRadius=function(e){return arguments.length?(r=typeof e==`function`?e:(a.pointRadius(+e),+e),o):r},o.digits=function(e){if(!arguments.length)return n;if(e==null)n=null;else{let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);n=t}return t===null&&(a=new ec(n)),o},o.projection(e).digits(n).context(t)}function ic(e){return function(t){var n=new ac;for(var r in e)n[r]=e[r];return n.stream=t,n}}function ac(){}ac.prototype={constructor:ac,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function oc(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),mo(n,e.stream(hs)),t(hs.result()),r!=null&&e.clipExtent(r),e}function sc(e,t,n){return oc(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function cc(e,t,n){return sc(e,[[0,0],t],n)}function lc(e,t,n){return oc(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function uc(e,t,n){return oc(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var dc=16,fc=Za(30*qa);function pc(e,t){return+t?hc(e,t):mc(e)}function mc(e){return ic({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function hc(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=ro(b*b+x*x+S*S),w=oo(S/=C),T=Ja(Ja(S)-1)<1e-6||Ja(a-d)<1e-6?(a+d)/2:Xa(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||Ja((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m<fc)&&(n(r,i,a,o,s,c,D,O,T,b/=C,x/=C,S,h,g),g.point(D,O),n(D,O,T,b,x,S,l,u,d,f,p,m,h,g))}}return function(t){var r,i,a,o,s,c,l,u,d,f,p,m,h={point:g,lineStart:_,lineEnd:y,polygonStart:function(){t.polygonStart(),h.lineStart=b},polygonEnd:function(){t.polygonEnd(),h.lineStart=_}};function g(n,r){n=e(n,r),t.point(n[0],n[1])}function _(){u=NaN,h.point=v,t.lineStart()}function v(r,i){var a=go([r,i]),o=e(r,i);n(u,d,l,f,p,m,u=o[0],d=o[1],l=r,f=a[0],p=a[1],m=a[2],dc,t),t.point(u,d)}function y(){h.point=g,t.lineEnd()}function b(){_(),h.point=x,h.lineEnd=S}function x(e,t){v(r=e,t),i=u,a=d,o=f,s=p,c=m,h.point=v}function S(){n(u,d,l,f,p,m,i,a,r,o,s,c,dc,t),h.lineEnd=y,y()}return h}}var gc=ic({point:function(e,t){this.stream.point(e*qa,t*qa)}});function _c(e){return ic({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function vc(e,t,n,r,i){function a(a,o){return a*=r,o*=i,[t+e*a,n-e*o]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}function yc(e,t,n,r,i,a){if(!a)return vc(e,t,n,r,i);var o=Za(a),s=to(a),c=o*e,l=s*e,u=o/e,d=s/e,f=(s*n-o*t)/e,p=(s*t+o*n)/e;function m(e,a){return e*=r,a*=i,[c*e-l*a+t,n-l*e-c*a]}return m.invert=function(e,t){return[r*(u*e-d*t+f),i*(p-d*e-u*t)]},m}function bc(e){return xc(function(){return e})()}function xc(e){var t,n=150,r=480,i=250,a=0,o=0,s=0,c=0,l=0,u,d=0,f=1,p=1,m=null,h=Vo,g=null,_,v,y,b=$o,x=.5,S,C,w,T,E;function D(e){return w(e[0]*qa,e[1]*qa)}function O(e){return e=w.invert(e[0],e[1]),e&&[e[0]*Ka,e[1]*Ka]}D.stream=function(e){return T&&E===e?T:T=gc(_c(u)(h(S(b(E=e)))))},D.preclip=function(e){return arguments.length?(h=e,m=void 0,A()):h},D.postclip=function(e){return arguments.length?(b=e,g=_=v=y=null,A()):b},D.clipAngle=function(e){return arguments.length?(h=+e?Go(m=e*qa):(m=null,Vo),A()):m*Ka},D.clipExtent=function(e){return arguments.length?(b=e==null?(g=_=v=y=null,$o):Yo(g=+e[0][0],_=+e[0][1],v=+e[1][0],y=+e[1][1]),A()):g==null?null:[[g,_],[v,y]]},D.scale=function(e){return arguments.length?(n=+e,k()):n},D.translate=function(e){return arguments.length?(r=+e[0],i=+e[1],k()):[r,i]},D.center=function(e){return arguments.length?(a=e[0]%360*qa,o=e[1]%360*qa,k()):[a*Ka,o*Ka]},D.rotate=function(e){return arguments.length?(s=e[0]%360*qa,c=e[1]%360*qa,l=e.length>2?e[2]%360*qa:0,k()):[s*Ka,c*Ka,l*Ka]},D.angle=function(e){return arguments.length?(d=e%360*qa,k()):d*Ka},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=pc(C,x=e*e),A()):ro(x)},D.fitExtent=function(e,t){return sc(D,e,t)},D.fitSize=function(e,t){return cc(D,e,t)},D.fitWidth=function(e,t){return lc(D,e,t)},D.fitHeight=function(e,t){return uc(D,e,t)};function k(){var e=yc(n,0,0,f,p,d).apply(null,t(a,o)),m=yc(n,r-e[0],i-e[1],f,p,d);return u=wo(s,c,l),C=So(t,m),w=So(u,C),S=pc(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}function Sc(e){return function(t,n){var r=ro(t*t+n*n),i=e(r),a=to(i),o=Za(i);return[Xa(t*a,r*o),oo(r&&n*a/r)]}}function Cc(e,t){return[e,eo(io((Ua+t)/2))]}Cc.invert=function(e,t){return[e,2*Ya($a(t))-Ua]};function wc(){return Tc(Cc).scale(961/Ga)}function Tc(e){var t=bc(e),n=t.center,r=t.scale,i=t.translate,a=t.clipExtent,o=null,s,c,l;t.scale=function(e){return arguments.length?(r(e),u()):r()},t.translate=function(e){return arguments.length?(i(e),u()):i()},t.center=function(e){return arguments.length?(n(e),u()):n()},t.clipExtent=function(e){return arguments.length?(e==null?o=s=c=l=null:(o=+e[0][0],s=+e[0][1],c=+e[1][0],l=+e[1][1]),u()):o==null?null:[[o,s],[c,l]]};function u(){var n=$*r(),i=t(Oo(t.rotate()).invert([0,0]));return a(o==null?[[i[0]-n,i[1]-n],[i[0]+n,i[1]+n]]:e===Cc?[[Math.max(i[0]-n,o),s],[Math.min(i[0]+n,c),l]]:[[o,Math.max(i[1]-n,s)],[c,Math.min(i[1]+n,l)]])}return u()}function Ec(e,t){return[Za(t)*to(e),to(t)]}Ec.invert=Sc(oo);function Dc(){return bc(Ec).scale(249.5).clipAngle(90+Ha)}var Oc=100;function kc(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=e.scale??1,a=i*Oc;r.style.width=`${a}px`,r.style.height=`${a}px`,r.style.flexGrow=`0`,r.style.flexShrink=`0`;let o={id:e.id,map:t,container:r,moveEndPosition:t.getCenter(),geoJson:void 0,isGlobe:e.isGlobe,boundingBox:e.boundingBox,scale:i,backgroundColor:e.backgroundColor??`#000000`,globeBackgroundColor:e.globeBackgroundColor??`#000000`,borderColor:e.borderColor??`#000000`,primaryFillColor:e.primaryFillColor??`#000000`,primaryStrokeColor:e.primaryStrokeColor??`#000000`,secondaryFillColor:e.secondaryFillColor??`#000000`,secondaryStrokeColor:e.secondaryStrokeColor??`#000000`,graticuleColor:e.graticuleColor??`#000000`,frameColor:e.frameColor??`#000000`,frameOutlineColor:e.frameOutlineColor??`#000000`,dotColor:e.dotColor??`#000000`,dotOutlineColor:e.dotOutlineColor??`#000000`,globeFallbackActive:!1,globeGeoJsonRequested:!1,globeGeoJson:void 0};return fetch(`${n}data/insetmaps/${e.fileName}`).then(e=>e.json()).then(e=>{o.geoJson=Bi(e,Object.keys(e.objects)[0]),Ac(o)}),t.on(`moveend`,()=>{o.moveEndPosition=t.getCenter(),(o.isGlobe||o.globeFallbackActive)&&Ac(o)}),t.on(`move`,()=>{if(!o.isGlobe){let[e,r,i,a]=o.boundingBox,s=Nc(t),c=Va(Tn([s,Cn([[[e,r],[e,a],[i,a],[i,r],[e,r]]])])),l=ji(s),u=(c?ji(c):0)<l*.75;o.globeFallbackActive!==u&&(o.globeFallbackActive=u,o.moveEndPosition=t.getCenter(),Ac(o)),o.globeFallbackActive&&!o.globeGeoJsonRequested&&(o.globeGeoJsonRequested=!0,fetch(`${n}data/insetmaps/world-110m.json`).then(e=>e.json()).then(e=>{o.globeGeoJson=Bi(e,Object.keys(e.objects)[0]),o.moveEndPosition=t.getCenter(),Ac(o)}))}Mc(o)}),r}function Ac(e){let{id:t,container:n,scale:r,backgroundColor:i,globeBackgroundColor:a,secondaryFillColor:o,secondaryStrokeColor:s,primaryFillColor:c,primaryStrokeColor:l,graticuleColor:u,borderColor:d,frameColor:f,frameOutlineColor:p,dotColor:m,dotOutlineColor:h}=e,g=e.globeFallbackActive&&e.globeGeoJson!==void 0,_=g?e.globeGeoJson:e.geoJson,v=g||e.isGlobe;if(_===void 0)return;let y=Oc*r,b=y/2,x=.1*r,S=[v?`<circle cx="${b}" cy="${b}" r="${b}" fill="${a}"></circle>`:`<rect x="0" y="0" width="${y}" height="${y}" fill="${i}"></rect>`],{path:C}=jc(e),w=C({..._,features:_.features.filter(e=>e.properties?.class!==`P1`)});w&&S.push(`
|
|
919
|
+
`,wi={da_DK:{search:`Search`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use two fingers to move the map`,windowsHelpText:`Use Ctrl + scroll to zoom the map`,macHelpText:`Use ⌘ + scroll to zoom the map`},de_DE:{search:`Suche`,videoAlert:`Das Video ist in der veröffentlichten Karte sichtbar.`,mobileHelpText:`Verwenden Sie zwei Finger um die Karte zu bewegen`,windowsHelpText:`Verwenden Sie Strg + Scroll um in der Karte zu zoomen`,macHelpText:`Verwenden Sie ⌘ + Scroll um in der Karte zu zoomen`},en_GB:{search:`Search`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use two fingers to move the map`,windowsHelpText:`Use Ctrl + scroll to zoom the map`,macHelpText:`Use ⌘ + scroll to zoom the map`},es_ES:{search:`Buscar`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Use dos dedos para mover el mapa`,windowsHelpText:`Use Ctrl + desplazamiento para hacer zoom en el mapa`,macHelpText:`Use ⌘ + desplazamiento para hacer zoom en el mapa`},fr_FR:{search:`Rechercher`,videoAlert:`Votre vidéo sera diffusée sur la carte publiée`,mobileHelpText:`Utilisez deux doigts pour déplacer la carte`,windowsHelpText:`Utilisez Ctrl + défilement pour zoomer sur la carte`,macHelpText:`Utilisez ⌘ + défilement pour zoomer sur la carte`},it_IT:{search:`Cercare`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Usa due dita per muovere la mappa`,windowsHelpText:`Usa Ctrl + Scroll per ingrandire la mappa`,macHelpText:`Usa ⌘ + Scroll per ingrandire la mappa`},nl_NL:{search:`Zoeken`,videoAlert:`The video will only work when you publish the map`,mobileHelpText:`Gebruik twee vingers om de kaart te bewegen`,windowsHelpText:`Gebruik Ctrl + Scroll om de kaart te zoomen`,macHelpText:`Gebruik ⌘ + Scroll om de kaart te zoomen`}};function Ti(){let e=navigator.language.replace(`-`,`_`),t=Object.keys(wi);return t.find(t=>t===e)??t.find(t=>t.split(`_`)[0]===e.split(`_`)[0])??`en_GB`}var Ei=Ti();function Di(e){return wi[Ei][e]??e}var Oi=class{async getLocationInBounds(e,t,n=10){try{let r=await this._callGraphHopper({limit:n,q:e,point:`${t.lat},${t.lng}`});return this._mapResults(r.hits)}catch(e){return console.warn(`Geocoding failed: `,e),[]}}async _callGraphHopper(e){let t=new URLSearchParams(e);t.append(`key`,`c5c40ac9-ed73-4e20-aed6-cfe495604ca8`),t.append(`locale`,Ei.slice(0,2));let n={headers:{Accept:`application/json`}},r=`https://graphhopper.com/api/1/geocode?${t}`;return await(await fetch(r,n)).json()}_mapResults(e){return e.map(e=>({id:e.osm_id.toString(),labelTitle:e.name,position:{lng:e.point.lng,lat:e.point.lat},bbox:e.extent?[{lng:e.extent[0],lat:e.extent[1]},{lng:e.extent[2],lat:e.extent[3]}]:null,subtitle:[e.osm_value,e.city,e.state,e.country].filter(Boolean).join(`, `)}))}},ki=class{map;mapContainer;container;control;input;dropdown;inputWrapper;button;isOpen=!1;geocoder=new Oi;suggestions=[];items=[];index=0;debounce;constructor(e){this.map=e,this.container=document.createElement(`div`),this.control=document.createElement(`div`),this.input=document.createElement(`input`),this.dropdown=document.createElement(`div`),this.inputWrapper=document.createElement(`div`),this.button=document.createElement(`button`),this.mapContainer=this.map.getContainer()}init(){this.container.className=`geocoder-container`,this.control.className=`geocoder-control`,this.input.className=`geocoder-input`,this.dropdown.className=`geocoder-dropdown`,this.inputWrapper.className=`geocoder-input-wrapper`,this.button.className=`control-button`,this.input.type=`text`,this.input.placeholder=Di(`search`),this.button.innerHTML=Si;let e=document.createElement(`button`);e.className=`geocoder-clear`,e.innerHTML=Ci;let t=document.createElement(`div`);return t.className=`geocoder-scrollwrapper`,t.append(this.dropdown),this.inputWrapper.append(this.input,e),this.control.append(this.button,this.inputWrapper,t),e.addEventListener(`click`,()=>this.clearAll()),this.button.addEventListener(`click`,()=>this.toggle()),this.input.addEventListener(`input`,()=>this.onInput()),this.input.addEventListener(`keydown`,e=>this.onKeyDown(e)),this.dropdown.addEventListener(`mousemove`,e=>this.onMouseMove(e)),this.mapContainer.addEventListener(`mousedown`,e=>this.clickOutside(e)),window.addEventListener(`resize`,()=>this.setMaxSizes()),this.setMaxSizes(),this.updateVisibility(),this.container.append(this.control),this.container}clickOutside(e){e.target instanceof Node&&!this.control.contains(e.target)&&this.hide()}setMaxSizes(){let{width:e,height:t}=this.mapContainer.getBoundingClientRect();this.control.style.maxWidth=`${e-40}px`,this.dropdown.style.maxHeight=`${Math.min(310,t-63)}px`}toggle(){this.isOpen=!this.isOpen,this.button.classList.toggle(`open`),this.updateVisibility(),this.isOpen&&this.input.focus()}hide(){this.isOpen&&(this.isOpen=!1,this.button.classList.remove(`open`),this.updateVisibility())}clearDropdown(){this.suggestions=[],this.items=[],this.dropdown.innerHTML=``}clearAll(){this.input.value=``,this.clearDropdown()}updateVisibility(){let e=this.isOpen;this.inputWrapper.style.display=e?`flex`:`none`,e||this.clearAll()}onInput(){let e=this.input.value.trim();if(this.debounce&&clearTimeout(this.debounce),e.length<2){this.dropdown.innerHTML=``;return}this.debounce=window.setTimeout(async()=>{this.suggestions=await this.geocoder.getLocationInBounds(e,this.map.getCenter(),20),this.items=[],this.renderSuggestions()},200)}renderSuggestions(){this.dropdown.innerHTML=``,this.items=[],this.index=0,this.suggestions.forEach(e=>{let t=document.createElement(`div`),n=document.createElement(`div`),r=document.createElement(`div`);t.className=`geocoder-suggestion`,n.className=`title`,r.className=`subtitle`,n.textContent=e.labelTitle,r.textContent=e.subtitle,t.append(n,r),t.addEventListener(`mousedown`,t=>{t.stopPropagation(),this.goToSelection(e)}),this.dropdown.appendChild(t),this.items.push({data:e,el:t})}),this.updateHighlight()}updateHighlight(){this.items.forEach((e,t)=>{e.el.classList.toggle(`highlight`,t===this.index)})}onKeyDown(e){if(e.key===`ArrowUp`)e.preventDefault(),this.index--,this.index<0&&(this.index=this.items.length-1),this.adjustScroll();else if(e.key===`ArrowDown`)e.preventDefault(),this.index++,this.index>this.items.length-1&&(this.index=0),this.adjustScroll();else if(e.key===`Enter`){e.preventDefault();let t=this.items[this.index];t&&this.goToSelection(t.data)}else e.key===`Escape`&&(e.preventDefault(),this.hide());this.updateHighlight()}onMouseMove(e){let t=e.target.closest(`.geocoder-suggestion`);this.index=this.items.findIndex(e=>e.el===t),this.updateHighlight()}goToSelection(e){e.bbox?this.map.fitBounds(e.bbox,{duration:0,animate:!1}):this.map.jumpTo({center:e.position,zoom:16}),this.input.value=e.labelTitle,this.clearDropdown()}adjustScroll(){let e=this.items[this.index].el,t=this.dropdown,n=t.getBoundingClientRect(),r=e.getBoundingClientRect();r.bottom>n.bottom?t.scrollTop+=r.bottom-n.bottom:r.top<n.top&&(t.scrollTop+=r.top-n.top)}};function Ai(e,t,n){let r=document.createElement(`div`);r.classList.add(`web-control`,`adornment`);let i=e.buttons.flatMap(e=>e===`zoom`?[`zoomIn`,`zoomOut`]:e);return(dr()?i.filter(e=>e!==`zoomIn`&&e!==`zoomOut`):i).forEach(e=>{let i;if(e===`zoomIn`)i=ri(t);else if(e===`zoomOut`)i=ii(t);else if(e===`fullscreen`)i=ui(t);else if(e===`geolocation`)i=yi(t);else if(e===`refresh`)i=xi(t,n);else if(e===`search`)i=new ki(t).init();else return;r.appendChild(i)}),r}function ji(e){return An(e,(e,t)=>e+Mi(t),0)}function Mi(e){let t=0,n;switch(e.type){case`Polygon`:return Ni(e.coordinates);case`MultiPolygon`:for(n=0;n<e.coordinates.length;n++)t+=Ni(e.coordinates[n]);return t;case`Point`:case`MultiPoint`:case`LineString`:case`MultiLineString`:return 0}return 0}function Ni(e){let t=0;if(e&&e.length>0){t+=Math.abs(Ii(e[0]));for(let n=1;n<e.length;n++)t-=Math.abs(Ii(e[n]))}return t}var Pi=xn*xn/2,Fi=Math.PI/180;function Ii(e){let t=e.length-1;if(t<=2)return 0;let n=0,r=0;for(;r<t;){let i=e[r],a=e[r+1===t?0:r+1],o=e[r+2>=t?(r+2)%t:r+2],s=i[0]*Fi,c=a[1]*Fi,l=o[0]*Fi;n+=(l-s)*Math.sin(c),r++}return n*Pi}function Li(e){return e}function Ri(e){if(e==null)return Li;var t,n,r=e.scale[0],i=e.scale[1],a=e.translate[0],o=e.translate[1];return function(e,s){s||(t=n=0);var c=2,l=e.length,u=Array(l);for(u[0]=(t+=e[0])*r+a,u[1]=(n+=e[1])*i+o;c<l;)u[c]=e[c],++c;return u}}function zi(e,t){for(var n,r=e.length,i=r-t;i<--r;)n=e[i],e[i++]=e[r],e[r]=n}function Bi(e,t){return typeof t==`string`&&(t=e.objects[t]),t.type===`GeometryCollection`?{type:`FeatureCollection`,features:t.geometries.map(function(t){return Vi(e,t)})}:Vi(e,t)}function Vi(e,t){var n=t.id,r=t.bbox,i=t.properties==null?{}:t.properties,a=Hi(e,t);return n==null&&r==null?{type:`Feature`,properties:i,geometry:a}:r==null?{type:`Feature`,id:n,properties:i,geometry:a}:{type:`Feature`,id:n,bbox:r,properties:i,geometry:a}}function Hi(e,t){var n=Ri(e.transform),r=e.arcs;function i(e,t){t.length&&t.pop();for(var i=r[e<0?~e:e],a=0,o=i.length;a<o;++a)t.push(n(i[a],a));e<0&&zi(t,o)}function a(e){return n(e)}function o(e){for(var t=[],n=0,r=e.length;n<r;++n)i(e[n],t);return t.length<2&&t.push(t[0]),t}function s(e){for(var t=o(e);t.length<4;)t.push(t[0]);return t}function c(e){return e.map(s)}function l(e){var t=e.type,n;switch(t){case`GeometryCollection`:return{type:t,geometries:e.geometries.map(l)};case`Point`:n=a(e.coordinates);break;case`MultiPoint`:n=e.coordinates.map(a);break;case`LineString`:n=o(e.arcs);break;case`MultiLineString`:n=e.arcs.map(o);break;case`Polygon`:n=c(e.arcs);break;case`MultiPolygon`:n=e.arcs.map(c);break;default:return null}return{type:t,coordinates:n}}return l(t)}var Ui=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Wi=Math.ceil,Gi=Math.floor,Ki=`[BigNumber Error] `,qi=Ki+`Number primitive has more than 15 significant digits: `,Ji=0x5af3107a4000,J=14,Yi=9007199254740991,Xi=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,0xe8d4a51000,0x9184e72a000],Zi=1e7,Qi=1e9;function $i(e){var t,n,r,i=v.prototype={constructor:v,toString:null,valueOf:null},a=new v(1),o=20,s=4,c=-7,l=21,u=-1e7,d=1e7,f=!1,p=1,m=0,h={prefix:``,groupSize:3,secondaryGroupSize:0,groupSeparator:`,`,decimalSeparator:`.`,fractionGroupSize:0,fractionGroupSeparator:`\xA0`,suffix:``},g=`0123456789abcdefghijklmnopqrstuvwxyz`,_=!0;function v(e,t){var i,a,c,l,f,p,m,h,y=this;if(!(y instanceof v))return new v(e,t);if(t==null){if(e&&e._isBigNumber===!0){y.s=e.s,!e.c||e.e>d?y.c=y.e=null:e.e<u?y.c=[y.e=0]:(y.e=e.e,y.c=e.c.slice());return}if((p=typeof e==`number`)&&e*0==0){if(y.s=1/e<0?(e=-e,-1):1,e===~~e){for(l=0,f=e;f>=10;f/=10,l++);l>d?y.c=y.e=null:(y.e=l,y.c=[e]);return}h=String(e)}else{if(!Ui.test(h=String(e)))return r(y,h,p);y.s=h.charCodeAt(0)==45?(h=h.slice(1),-1):1}(l=h.indexOf(`.`))>-1&&(h=h.replace(`.`,``)),(f=h.search(/e/i))>0?(l<0&&(l=f),l+=+h.slice(f+1),h=h.substring(0,f)):l<0&&(l=h.length)}else{if(ra(t,2,g.length,`Base`),t==10&&_)return y=new v(e),S(y,o+y.e+1,s);if(h=String(e),p=typeof e==`number`){if(e*0!=0)return r(y,h,p,t);if(y.s=1/e<0?(h=h.slice(1),-1):1,v.DEBUG&&h.replace(/^0\.0*|\./,``).length>15)throw Error(qi+e)}else y.s=h.charCodeAt(0)===45?(h=h.slice(1),-1):1;for(i=g.slice(0,t),l=f=0,m=h.length;f<m;f++)if(i.indexOf(a=h.charAt(f))<0){if(a==`.`){if(f>l){l=m;continue}}else if(!c&&(h==h.toUpperCase()&&(h=h.toLowerCase())||h==h.toLowerCase()&&(h=h.toUpperCase()))){c=!0,f=-1,l=0;continue}return r(y,String(e),p,t)}p=!1,h=n(h,t,10,y.s),(l=h.indexOf(`.`))>-1?h=h.replace(`.`,``):l=h.length}for(f=0;h.charCodeAt(f)===48;f++);for(m=h.length;h.charCodeAt(--m)===48;);if(h=h.slice(f,++m)){if(m-=f,p&&v.DEBUG&&m>15&&(e>Yi||e!==Gi(e)))throw Error(qi+y.s*e);if((l=l-f-1)>d)y.c=y.e=null;else if(l<u)y.c=[y.e=0];else{if(y.e=l,y.c=[],f=(l+1)%J,l<0&&(f+=J),f<m){for(f&&y.c.push(+h.slice(0,f)),m-=J;f<m;)y.c.push(+h.slice(f,f+=J));f=J-(h=h.slice(f)).length}else f-=m;for(;f--;h+=`0`);y.c.push(+h)}}else y.c=[y.e=0]}v.clone=$i,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(e){var t,n;if(e!=null)if(typeof e==`object`){if(e.hasOwnProperty(t=`DECIMAL_PLACES`)&&(n=e[t],ra(n,0,Qi,t),o=n),e.hasOwnProperty(t=`ROUNDING_MODE`)&&(n=e[t],ra(n,0,8,t),s=n),e.hasOwnProperty(t=`EXPONENTIAL_AT`)&&(n=e[t],n&&n.pop?(ra(n[0],-Qi,0,t),ra(n[1],0,Qi,t),c=n[0],l=n[1]):(ra(n,-Qi,Qi,t),c=-(l=n<0?-n:n))),e.hasOwnProperty(t=`RANGE`))if(n=e[t],n&&n.pop)ra(n[0],-Qi,-1,t),ra(n[1],1,Qi,t),u=n[0],d=n[1];else if(ra(n,-Qi,Qi,t),n)u=-(d=n<0?-n:n);else throw Error(Ki+t+` cannot be zero: `+n);if(e.hasOwnProperty(t=`CRYPTO`))if(n=e[t],n===!!n)if(n)if(typeof crypto<`u`&&crypto&&(crypto.getRandomValues||crypto.randomBytes))f=n;else throw f=!n,Error(Ki+`crypto unavailable`);else f=n;else throw Error(Ki+t+` not true or false: `+n);if(e.hasOwnProperty(t=`MODULO_MODE`)&&(n=e[t],ra(n,0,9,t),p=n),e.hasOwnProperty(t=`POW_PRECISION`)&&(n=e[t],ra(n,0,Qi,t),m=n),e.hasOwnProperty(t=`FORMAT`))if(n=e[t],typeof n==`object`)h=n;else throw Error(Ki+t+` not an object: `+n);if(e.hasOwnProperty(t=`ALPHABET`))if(n=e[t],typeof n==`string`&&!/^.?$|[+\-.\s]|(.).*\1/.test(n))_=n.slice(0,10)==`0123456789`,g=n;else throw Error(Ki+t+` invalid: `+n)}else throw Error(Ki+`Object expected: `+e);return{DECIMAL_PLACES:o,ROUNDING_MODE:s,EXPONENTIAL_AT:[c,l],RANGE:[u,d],CRYPTO:f,MODULO_MODE:p,POW_PRECISION:m,FORMAT:h,ALPHABET:g}},v.isBigNumber=function(e){if(!e||e._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var t,n,r=e.c,i=e.e,a=e.s;out:if({}.toString.call(r)==`[object Array]`){if((a===1||a===-1)&&i>=-Qi&&i<=Qi&&i===Gi(i)){if(r[0]===0){if(i===0&&r.length===1)return!0;break out}if(t=(i+1)%J,t<1&&(t+=J),String(r[0]).length==t){for(t=0;t<r.length;t++)if(n=r[t],n<0||n>=Ji||n!==Gi(n))break out;if(n!==0)return!0}}}else if(r===null&&i===null&&(a===null||a===1||a===-1))return!0;throw Error(Ki+`Invalid BigNumber: `+e)},v.maximum=v.max=function(){return b(arguments,-1)},v.minimum=v.min=function(){return b(arguments,1)},v.random=(function(){var e=9007199254740992,t=Math.random()*e&2097151?function(){return Gi(Math.random()*e)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(e){var n,r,i,s,c,l=0,u=[],d=new v(a);if(e==null?e=o:ra(e,0,Qi),s=Wi(e/J),f)if(crypto.getRandomValues){for(n=crypto.getRandomValues(new Uint32Array(s*=2));l<s;)c=n[l]*131072+(n[l+1]>>>11),c>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),n[l]=r[0],n[l+1]=r[1]):(u.push(c%0x5af3107a4000),l+=2);l=s/2}else if(crypto.randomBytes){for(n=crypto.randomBytes(s*=7);l<s;)c=(n[l]&31)*281474976710656+n[l+1]*1099511627776+n[l+2]*4294967296+n[l+3]*16777216+(n[l+4]<<16)+(n[l+5]<<8)+n[l+6],c>=9e15?crypto.randomBytes(7).copy(n,l):(u.push(c%0x5af3107a4000),l+=7);l=s/7}else throw f=!1,Error(Ki+`crypto unavailable`);if(!f)for(;l<s;)c=t(),c<9e15&&(u[l++]=c%0x5af3107a4000);for(s=u[--l],e%=J,s&&e&&(c=Xi[J-e],u[l]=Gi(s/c)*c);u[l]===0;u.pop(),l--);if(l<0)u=[i=0];else{for(i=-1;u[0]===0;u.splice(0,1),i-=J);for(l=1,c=u[0];c>=10;c/=10,l++);l<J&&(i-=J-l)}return d.e=i,d.c=u,d}})(),v.sum=function(){for(var e=1,t=arguments,n=new v(t[0]);e<t.length;)n=n.plus(t[e++]);return n},n=(function(){var e=`0123456789`;function n(e,t,n,r){for(var i,a=[0],o,s=0,c=e.length;s<c;){for(o=a.length;o--;a[o]*=t);for(a[0]+=r.indexOf(e.charAt(s++)),i=0;i<a.length;i++)a[i]>n-1&&(a[i+1]??(a[i+1]=0),a[i+1]+=a[i]/n|0,a[i]%=n)}return a.reverse()}return function(r,i,a,c,l){var u,d,f,p,h,_,y,b,x=r.indexOf(`.`),S=o,C=s;for(x>=0&&(p=m,m=0,r=r.replace(`.`,``),b=new v(i),_=b.pow(r.length-x),m=p,b.c=n(oa(ta(_.c),_.e,`0`),10,a,e),b.e=b.c.length),y=n(r,i,a,l?(u=g,e):(u=e,g)),f=p=y.length;y[--p]==0;y.pop());if(!y[0])return u.charAt(0);if(x<0?--f:(_.c=y,_.e=f,_.s=c,_=t(_,b,S,C,a),y=_.c,h=_.r,f=_.e),d=f+S+1,x=y[d],p=a/2,h=h||d<0||y[d+1]!=null,h=C<4?(x!=null||h)&&(C==0||C==(_.s<0?3:2)):x>p||x==p&&(C==4||h||C==6&&y[d-1]&1||C==(_.s<0?8:7)),d<1||!y[0])r=h?oa(u.charAt(1),-S,u.charAt(0)):u.charAt(0);else{if(y.length=d,h)for(--a;++y[--d]>a;)y[d]=0,d||(++f,y=[1].concat(y));for(p=y.length;!y[--p];);for(x=0,r=``;x<=p;r+=u.charAt(y[x++]));r=oa(r,f,u.charAt(0))}return r}})(),t=(function(){function e(e,t,n){var r,i,a,o,s=0,c=e.length,l=t%Zi,u=t/Zi|0;for(e=e.slice();c--;)a=e[c]%Zi,o=e[c]/Zi|0,r=u*a+o*l,i=l*a+r%Zi*Zi+s,s=(i/n|0)+(r/Zi|0)+u*o,e[c]=i%n;return s&&(e=[s].concat(e)),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(r,i,a,o,s){var c,l,u,d,f,p,m,h,g,_,y,b,x,C,w,T,E,D=r.s==i.s?1:-1,O=r.c,k=i.c;if(!O||!O[0]||!k||!k[0])return new v(!r.s||!i.s||(O?k&&O[0]==k[0]:!k)?NaN:O&&O[0]==0||!k?D*0:D/0);for(h=new v(D),g=h.c=[],l=r.e-i.e,D=a+l+1,s||(s=Ji,l=ea(r.e/J)-ea(i.e/J),D=D/J|0),u=0;k[u]==(O[u]||0);u++);if(k[u]>(O[u]||0)&&l--,D<0)g.push(1),d=!0;else{for(C=O.length,T=k.length,u=0,D+=2,f=Gi(s/(k[0]+1)),f>1&&(k=e(k,f,s),O=e(O,f,s),T=k.length,C=O.length),x=T,_=O.slice(0,T),y=_.length;y<T;_[y++]=0);E=k.slice(),E=[0].concat(E),w=k[0],k[1]>=s/2&&w++;do{if(f=0,c=t(k,_,T,y),c<0){if(b=_[0],T!=y&&(b=b*s+(_[1]||0)),f=Gi(b/w),f>1)for(f>=s&&(f=s-1),p=e(k,f,s),m=p.length,y=_.length;t(p,_,m,y)==1;)f--,n(p,T<m?E:k,m,s),m=p.length,c=1;else f==0&&(c=f=1),p=k.slice(),m=p.length;if(m<y&&(p=[0].concat(p)),n(_,p,y,s),y=_.length,c==-1)for(;t(k,_,T,y)<1;)f++,n(_,T<y?E:k,y,s),y=_.length}else c===0&&(f++,_=[0]);g[u++]=f,_[0]?_[y++]=O[x]||0:(_=[O[x]],y=1)}while((x++<C||_[0]!=null)&&D--);d=_[0]!=null,g[0]||g.splice(0,1)}if(s==Ji){for(u=1,D=g[0];D>=10;D/=10,u++);S(h,a+(h.e=u+l*J-1)+1,o,d)}else h.e=l,h.r=+d;return h}})();function y(e,t,n,r){var i,a,o,u,d;if(n==null?n=s:ra(n,0,8),!e.c)return e.toString();if(i=e.c[0],o=e.e,t==null)d=ta(e.c),d=r==1||r==2&&(o<=c||o>=l)?aa(d,o):oa(d,o,`0`);else if(e=S(new v(e),t,n),a=e.e,d=ta(e.c),u=d.length,r==1||r==2&&(t<=a||a<=c)){for(;u<t;d+=`0`,u++);d=aa(d,a)}else if(t-=o+(r===2&&a>o),d=oa(d,a,`0`),a+1>u){if(--t>0)for(d+=`.`;t--;d+=`0`);}else if(t+=a-u,t>0)for(a+1==u&&(d+=`.`);t--;d+=`0`);return e.s<0&&i?`-`+d:d}function b(e,t){for(var n,r,i=1,a=new v(e[0]);i<e.length;i++)r=new v(e[i]),(!r.s||(n=na(a,r))===t||n===0&&a.s===t)&&(a=r);return a}function x(e,t,n){for(var r=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,r++);return(n=r+n*J-1)>d?e.c=e.e=null:n<u?e.c=[e.e=0]:(e.e=n,e.c=t),e}r=(function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,n=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,s,c){var l,u=s?o:o.replace(i,``);if(r.test(u))a.s=isNaN(u)?null:u<0?-1:1;else{if(!s&&(u=u.replace(e,function(e,t,n){return l=(n=n.toLowerCase())==`x`?16:n==`b`?2:8,!c||c==l?t:e}),c&&(l=c,u=u.replace(t,`$1`).replace(n,`0.$1`)),o!=u))return new v(u,l);if(v.DEBUG)throw Error(Ki+`Not a`+(c?` base `+c:``)+` number: `+o);a.s=null}a.c=a.e=null}})();function S(e,t,n,r){var i,a,o,s,c,l,f,p=e.c,m=Xi;if(p){out:{for(i=1,s=p[0];s>=10;s/=10,i++);if(a=t-i,a<0)a+=J,o=t,c=p[l=0],f=Gi(c/m[i-o-1]%10);else if(l=Wi((a+1)/J),l>=p.length)if(r){for(;p.length<=l;p.push(0));c=f=0,i=1,a%=J,o=a-J+1}else break out;else{for(c=s=p[l],i=1;s>=10;s/=10,i++);a%=J,o=a-J+i,f=o<0?0:Gi(c/m[i-o-1]%10)}if(r=r||t<0||p[l+1]!=null||(o<0?c:c%m[i-o-1]),r=n<4?(f||r)&&(n==0||n==(e.s<0?3:2)):f>5||f==5&&(n==4||r||n==6&&(a>0?o>0?c/m[i-o]:0:p[l-1])%10&1||n==(e.s<0?8:7)),t<1||!p[0])return p.length=0,r?(t-=e.e+1,p[0]=m[(J-t%J)%J],e.e=-t||0):p[0]=e.e=0,e;if(a==0?(p.length=l,s=1,l--):(p.length=l+1,s=m[J-a],p[l]=o>0?Gi(c/m[i-o]%m[o])*s:0),r)for(;;)if(l==0){for(a=1,o=p[0];o>=10;o/=10,a++);for(o=p[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,p[0]==Ji&&(p[0]=1));break}else{if(p[l]+=s,p[l]!=Ji)break;p[l--]=0,s=1}for(a=p.length;p[--a]===0;p.pop());}e.e>d?e.c=e.e=null:e.e<u&&(e.c=[e.e=0])}return e}function C(e){var t,n=e.e;return n===null?e.toString():(t=ta(e.c),t=n<=c||n>=l?aa(t,n):oa(t,n,`0`),e.s<0?`-`+t:t)}return i.absoluteValue=i.abs=function(){var e=new v(this);return e.s<0&&(e.s=1),e},i.comparedTo=function(e,t){return na(this,new v(e,t))},i.decimalPlaces=i.dp=function(e,t){var n,r,i,a=this;if(e!=null)return ra(e,0,Qi),t==null?t=s:ra(t,0,8),S(new v(a),e+a.e+1,t);if(!(n=a.c))return null;if(r=((i=n.length-1)-ea(this.e/J))*J,i=n[i])for(;i%10==0;i/=10,r--);return r<0&&(r=0),r},i.dividedBy=i.div=function(e,n){return t(this,new v(e,n),o,s)},i.dividedToIntegerBy=i.idiv=function(e,n){return t(this,new v(e,n),0,1)},i.exponentiatedBy=i.pow=function(e,t){var n,r,i,o,c,l,u,d,f,p=this;if(e=new v(e),e.c&&!e.isInteger())throw Error(Ki+`Exponent not an integer: `+C(e));if(t!=null&&(t=new v(t)),l=e.e>14,!p.c||!p.c[0]||p.c[0]==1&&!p.e&&p.c.length==1||!e.c||!e.c[0])return f=new v(C(p)**(l?e.s*(2-ia(e)):+C(e))),t?f.mod(t):f;if(u=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new v(NaN);r=!u&&p.isInteger()&&t.isInteger(),r&&(p=p.mod(t))}else if(e.e>9&&(p.e>0||p.e<-1||(p.e==0?p.c[0]>1||l&&p.c[1]>=24e7:p.c[0]<8e13||l&&p.c[0]<=9999975e7)))return o=p.s<0&&ia(e)?-0:0,p.e>-1&&(o=1/o),new v(u?1/o:o);else m&&(o=Wi(m/J+2));for(l?(n=new v(.5),u&&(e.s=1),d=ia(e)):(i=Math.abs(+C(e)),d=i%2),f=new v(a);;){if(d){if(f=f.times(p),!f.c)break;o?f.c.length>o&&(f.c.length=o):r&&(f=f.mod(t))}if(i){if(i=Gi(i/2),i===0)break;d=i%2}else if(e=e.times(n),S(e,e.e+1,1),e.e>14)d=ia(e);else{if(i=+C(e),i===0)break;d=i%2}p=p.times(p),o?p.c&&p.c.length>o&&(p.c.length=o):r&&(p=p.mod(t))}return r?f:(u&&(f=a.div(f)),t?f.mod(t):o?S(f,m,s,c):f)},i.integerValue=function(e){var t=new v(this);return e==null?e=s:ra(e,0,8),S(t,t.e+1,e)},i.isEqualTo=i.eq=function(e,t){return na(this,new v(e,t))===0},i.isFinite=function(){return!!this.c},i.isGreaterThan=i.gt=function(e,t){return na(this,new v(e,t))>0},i.isGreaterThanOrEqualTo=i.gte=function(e,t){return(t=na(this,new v(e,t)))===1||t===0},i.isInteger=function(){return!!this.c&&ea(this.e/J)>this.c.length-2},i.isLessThan=i.lt=function(e,t){return na(this,new v(e,t))<0},i.isLessThanOrEqualTo=i.lte=function(e,t){return(t=na(this,new v(e,t)))===-1||t===0},i.isNaN=function(){return!this.s},i.isNegative=function(){return this.s<0},i.isPositive=function(){return this.s>0},i.isZero=function(){return!!this.c&&this.c[0]==0},i.minus=function(e,t){var n,r,i,a,o=this,c=o.s;if(e=new v(e,t),t=e.s,!c||!t)return new v(NaN);if(c!=t)return e.s=-t,o.plus(e);var l=o.e/J,u=e.e/J,d=o.c,f=e.c;if(!l||!u){if(!d||!f)return d?(e.s=-t,e):new v(f?o:NaN);if(!d[0]||!f[0])return f[0]?(e.s=-t,e):new v(d[0]?o:s==3?-0:0)}if(l=ea(l),u=ea(u),d=d.slice(),c=l-u){for((a=c<0)?(c=-c,i=d):(u=l,i=f),i.reverse(),t=c;t--;i.push(0));i.reverse()}else for(r=(a=(c=d.length)<(t=f.length))?c:t,c=t=0;t<r;t++)if(d[t]!=f[t]){a=d[t]<f[t];break}if(a&&(i=d,d=f,f=i,e.s=-e.s),t=(r=f.length)-(n=d.length),t>0)for(;t--;d[n++]=0);for(t=Ji-1;r>c;){if(d[--r]<f[r]){for(n=r;n&&!d[--n];d[n]=t);--d[n],d[r]+=Ji}d[r]-=f[r]}for(;d[0]==0;d.splice(0,1),--u);return d[0]?x(e,d,u):(e.s=s==3?-1:1,e.c=[e.e=0],e)},i.modulo=i.mod=function(e,n){var r,i,a=this;return e=new v(e,n),!a.c||!e.s||e.c&&!e.c[0]?new v(NaN):!e.c||a.c&&!a.c[0]?new v(a):(p==9?(i=e.s,e.s=1,r=t(a,e,0,3),e.s=i,r.s*=i):r=t(a,e,0,p),e=a.minus(r.times(e)),!e.c[0]&&p==1&&(e.s=a.s),e)},i.multipliedBy=i.times=function(e,t){var n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=this,y=_.c,b=(e=new v(e,t)).c;if(!y||!b||!y[0]||!b[0])return!_.s||!e.s||y&&!y[0]&&!b||b&&!b[0]&&!y?e.c=e.e=e.s=null:(e.s*=_.s,!y||!b?e.c=e.e=null:(e.c=[0],e.e=0)),e;for(r=ea(_.e/J)+ea(e.e/J),e.s*=_.s,c=y.length,d=b.length,c<d&&(m=y,y=b,b=m,i=c,c=d,d=i),i=c+d,m=[];i--;m.push(0));for(h=Ji,g=Zi,i=d;--i>=0;){for(n=0,f=b[i]%g,p=b[i]/g|0,o=c,a=i+o;a>i;)l=y[--o]%g,u=y[o]/g|0,s=p*l+u*f,l=f*l+s%g*g+m[a]+n,n=(l/h|0)+(s/g|0)+p*u,m[a--]=l%h;m[a]=n}return n?++r:m.splice(0,1),x(e,m,r)},i.negated=function(){var e=new v(this);return e.s=-e.s||null,e},i.plus=function(e,t){var n,r=this,i=r.s;if(e=new v(e,t),t=e.s,!i||!t)return new v(NaN);if(i!=t)return e.s=-t,r.minus(e);var a=r.e/J,o=e.e/J,s=r.c,c=e.c;if(!a||!o){if(!s||!c)return new v(i/0);if(!s[0]||!c[0])return c[0]?e:new v(s[0]?r:i*0)}if(a=ea(a),o=ea(o),s=s.slice(),i=a-o){for(i>0?(o=a,n=c):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for(i=s.length,t=c.length,i-t<0&&(n=c,c=s,s=n,t=i),i=0;t;)i=(s[--t]=s[t]+c[t]+i)/Ji|0,s[t]=Ji===s[t]?0:s[t]%Ji;return i&&(s=[i].concat(s),++o),x(e,s,o)},i.precision=i.sd=function(e,t){var n,r,i,a=this;if(e!=null&&e!==!!e)return ra(e,1,Qi),t==null?t=s:ra(t,0,8),S(new v(a),e,t);if(!(n=a.c))return null;if(i=n.length-1,r=i*J+1,i=n[i]){for(;i%10==0;i/=10,r--);for(i=n[0];i>=10;i/=10,r++);}return e&&a.e+1>r&&(r=a.e+1),r},i.shiftedBy=function(e){return ra(e,-Yi,Yi),this.times(`1e`+e)},i.squareRoot=i.sqrt=function(){var e,n,r,i,a,c=this,l=c.c,u=c.s,d=c.e,f=o+4,p=new v(`0.5`);if(u!==1||!l||!l[0])return new v(!u||u<0&&(!l||l[0])?NaN:l?c:1/0);if(u=Math.sqrt(+C(c)),u==0||u==1/0?(n=ta(l),(n.length+d)%2==0&&(n+=`0`),u=Math.sqrt(+n),d=ea((d+1)/2)-(d<0||d%2),u==1/0?n=`5e`+d:(n=u.toExponential(),n=n.slice(0,n.indexOf(`e`)+1)+d),r=new v(n)):r=new v(u+``),r.c[0]){for(d=r.e,u=d+f,u<3&&(u=0);;)if(a=r,r=p.times(a.plus(t(c,a,f,1))),ta(a.c).slice(0,u)===(n=ta(r.c)).slice(0,u))if(r.e<d&&--u,n=n.slice(u-3,u+1),n==`9999`||!i&&n==`4999`){if(!i&&(S(a,a.e+o+2,0),a.times(a).eq(c))){r=a;break}f+=4,u+=4,i=1}else{(!+n||!+n.slice(1)&&n.charAt(0)==`5`)&&(S(r,r.e+o+2,1),e=!r.times(r).eq(c));break}}return S(r,r.e+o+1,s,e)},i.toExponential=function(e,t){return e!=null&&(ra(e,0,Qi),e++),y(this,e,t,1)},i.toFixed=function(e,t){return e!=null&&(ra(e,0,Qi),e=e+this.e+1),y(this,e,t)},i.toFormat=function(e,t,n){var r,i=this;if(n==null)e!=null&&t&&typeof t==`object`?(n=t,t=null):e&&typeof e==`object`?(n=e,e=t=null):n=h;else if(typeof n!=`object`)throw Error(Ki+`Argument not an object: `+n);if(r=i.toFixed(e,t),i.c){var a,o=r.split(`.`),s=+n.groupSize,c=+n.secondaryGroupSize,l=n.groupSeparator||``,u=o[0],d=o[1],f=i.s<0,p=f?u.slice(1):u,m=p.length;if(c&&(a=s,s=c,c=a,m-=a),s>0&&m>0){for(a=m%s||s,u=p.substr(0,a);a<m;a+=s)u+=l+p.substr(a,s);c>0&&(u+=l+p.slice(a)),f&&(u=`-`+u)}r=d?u+(n.decimalSeparator||``)+((c=+n.fractionGroupSize)?d.replace(RegExp(`\\d{`+c+`}\\B`,`g`),`$&`+(n.fractionGroupSeparator||``)):d):u}return(n.prefix||``)+r+(n.suffix||``)},i.toFraction=function(e){var n,r,i,o,c,l,u,f,p,m,h,g,_=this,y=_.c;if(e!=null&&(u=new v(e),!u.isInteger()&&(u.c||u.s!==1)||u.lt(a)))throw Error(Ki+`Argument `+(u.isInteger()?`out of range: `:`not an integer: `)+C(u));if(!y)return new v(_);for(n=new v(a),p=r=new v(a),i=f=new v(a),g=ta(y),c=n.e=g.length-_.e-1,n.c[0]=Xi[(l=c%J)<0?J+l:l],e=!e||u.comparedTo(n)>0?c>0?n:p:u,l=d,d=1/0,u=new v(g),f.c[0]=0;m=t(u,n,0,1),o=r.plus(m.times(i)),o.comparedTo(e)!=1;)r=i,i=o,p=f.plus(m.times(o=p)),f=o,n=u.minus(m.times(o=n)),u=o;return o=t(e.minus(r),i,0,1),f=f.plus(o.times(p)),r=r.plus(o.times(i)),f.s=p.s=_.s,c*=2,h=t(p,i,c,s).minus(_).abs().comparedTo(t(f,r,c,s).minus(_).abs())<1?[p,i]:[f,r],d=l,h},i.toNumber=function(){return+C(this)},i.toPrecision=function(e,t){return e!=null&&ra(e,1,Qi),y(this,e,t,2)},i.toString=function(e){var t,r=this,i=r.s,a=r.e;return a===null?i?(t=`Infinity`,i<0&&(t=`-`+t)):t=`NaN`:(e==null?t=a<=c||a>=l?aa(ta(r.c),a):oa(ta(r.c),a,`0`):e===10&&_?(r=S(new v(r),o+a+1,s),t=oa(ta(r.c),r.e,`0`)):(ra(e,2,g.length,`Base`),t=n(oa(ta(r.c),a,`0`),10,e,i,!0)),i<0&&r.c[0]&&(t=`-`+t)),t},i.valueOf=i.toJSON=function(){return C(this)},i._isBigNumber=!0,i[Symbol.toStringTag]=`BigNumber`,i[Symbol.for(`nodejs.util.inspect.custom`)]=i.valueOf,e!=null&&v.set(e),v}function ea(e){var t=e|0;return e>0||e===t?t:t-1}function ta(e){for(var t,n,r=1,i=e.length,a=e[0]+``;r<i;){for(t=e[r++]+``,n=J-t.length;n--;t=`0`+t);a+=t}for(i=a.length;a.charCodeAt(--i)===48;);return a.slice(0,i+1||1)}function na(e,t){var n,r,i=e.c,a=t.c,o=e.s,s=t.s,c=e.e,l=t.e;if(!o||!s)return null;if(n=i&&!i[0],r=a&&!a[0],n||r)return n?r?0:-s:o;if(o!=s)return o;if(n=o<0,r=c==l,!i||!a)return r?0:!i^n?1:-1;if(!r)return c>l^n?1:-1;for(s=(c=i.length)<(l=a.length)?c:l,o=0;o<s;o++)if(i[o]!=a[o])return i[o]>a[o]^n?1:-1;return c==l?0:c>l^n?1:-1}function ra(e,t,n,r){if(e<t||e>n||e!==Gi(e))throw Error(Ki+(r||`Argument`)+(typeof e==`number`?e<t||e>n?` out of range: `:` not an integer: `:` not a primitive number: `)+String(e))}function ia(e){var t=e.c.length-1;return ea(e.e/J)==t&&e.c[t]%2!=0}function aa(e,t){return(e.length>1?e.charAt(0)+`.`+e.slice(1):e)+(t<0?`e`:`e+`)+t}function oa(e,t,n){var r,i;if(t<0){for(i=n+`.`;++t;i+=n);e=i+e}else if(r=e.length,++t>r){for(i=n,t-=r;--t;i+=n);e+=i}else t<r&&(e=e.slice(0,t)+`.`+e.slice(t));return e}var sa=$i(),Y=class{key;left=null;right=null;constructor(e){this.key=e}},ca=class extends Y{constructor(e){super(e)}},la=class{size=0;modificationCount=0;splayCount=0;splay(e){let t=this.root;if(t==null)return this.compare(e,e),-1;let n=null,r=null,i=null,a=null,o=t,s=this.compare,c;for(;;)if(c=s(o.key,e),c>0){let t=o.left;if(t==null||(c=s(t.key,e),c>0&&(o.left=t.right,t.right=o,o=t,t=o.left,t==null)))break;n==null?r=o:n.left=o,n=o,o=t}else if(c<0){let t=o.right;if(t==null||(c=s(t.key,e),c<0&&(o.right=t.left,t.left=o,o=t,t=o.right,t==null)))break;i==null?a=o:i.right=o,i=o,o=t}else break;return i!=null&&(i.right=o.left,o.left=a),n!=null&&(n.left=o.right,o.right=r),this.root!==o&&(this.root=o,this.splayCount++),c}splayMin(e){let t=e,n=t.left;for(;n!=null;){let e=n;t.left=e.right,e.right=t,t=e,n=t.left}return t}splayMax(e){let t=e,n=t.right;for(;n!=null;){let e=n;t.right=e.left,e.left=t,t=e,n=t.right}return t}_delete(e){if(this.root==null||this.splay(e)!=0)return null;let t=this.root,n=t,r=t.left;if(this.size--,r==null)this.root=t.right;else{let e=t.right;t=this.splayMax(r),t.right=e,this.root=t}return this.modificationCount++,n}addNewRoot(e,t){this.size++,this.modificationCount++;let n=this.root;if(n==null){this.root=e;return}t<0?(e.left=n,e.right=n.right,n.right=null):(e.right=n,e.left=n.left,n.left=null),this.root=e}_first(){let e=this.root;return e==null?null:(this.root=this.splayMin(e),this.root)}_last(){let e=this.root;return e==null?null:(this.root=this.splayMax(e),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(e){return this.validKey(e)&&this.splay(e)==0}defaultCompare(){return(e,t)=>e<t?-1:e>t?1:0}wrap(){return{getRoot:()=>this.root,setRoot:e=>{this.root=e},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:e=>{this.splayCount=e},splay:e=>this.splay(e),has:e=>this.has(e)}}},ua=class e extends la{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(e=>e!=null&&e!=null)}delete(e){return this.validKey(e)?this._delete(e)!=null:!1}deleteAll(e){for(let t of e)this.delete(t)}forEach(e){let t=this[Symbol.iterator](),n;for(;n=t.next(),!n.done;)e(n.value,n.value,this)}add(e){let t=this.splay(e);return t!=0&&this.addNewRoot(new ca(e),t),this}addAndReturn(e){let t=this.splay(e);return t!=0&&this.addNewRoot(new ca(e),t),this.root.key}addAll(e){for(let t of e)this.add(t)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw`Bad state: No element`;if(this.size>1)throw`Bad state: Too many element`;return this.root.key}first(){if(this.size==0)throw`Bad state: No element`;return this._first().key}last(){if(this.size==0)throw`Bad state: No element`;return this._last().key}lastBefore(e){if(e==null)throw`Invalid arguments(s)`;if(this.root==null)return null;if(this.splay(e)<0)return this.root.key;let t=this.root.left;if(t==null)return null;let n=t.right;for(;n!=null;)t=n,n=t.right;return t.key}firstAfter(e){if(e==null)throw`Invalid arguments(s)`;if(this.root==null)return null;if(this.splay(e)>0)return this.root.key;let t=this.root.right;if(t==null)return null;let n=t.left;for(;n!=null;)t=n,n=t.left;return t.key}retainAll(t){let n=new e(this.compare,this.validKey),r=this.modificationCount;for(let e of t){if(r!=this.modificationCount)throw`Concurrent modification during iteration.`;this.validKey(e)&&this.splay(e)==0&&n.add(this.root.key)}n.size!=this.size&&(this.root=n.root,this.size=n.size,this.modificationCount++)}lookup(e){return!this.validKey(e)||this.splay(e)!=0?null:this.root.key}intersection(t){let n=new e(this.compare,this.validKey);for(let e of this)t.has(e)&&n.add(e);return n}difference(t){let n=new e(this.compare,this.validKey);for(let e of this)t.has(e)||n.add(e);return n}union(e){let t=this.clone();return t.addAll(e),t}clone(){let t=new e(this.compare,this.validKey);return t.size=this.size,t.root=this.copyNode(this.root),t}copyNode(e){if(e==null)return null;function t(e,n){let r,i;do{if(r=e.left,i=e.right,r!=null){let e=new ca(r.key);n.left=e,t(r,e)}if(i!=null){let t=new ca(i.key);n.right=t,e=i,n=t}}while(i!=null)}let n=new ca(e.key);return t(e,n),n}toSet(){return this.clone()}entries(){return new pa(this.wrap())}keys(){return this[Symbol.iterator]()}values(){return this[Symbol.iterator]()}[Symbol.iterator](){return new fa(this.wrap())}[Symbol.toStringTag]=`[object Set]`},da=class{tree;path=[];modificationCount=null;splayCount;constructor(e){this.tree=e,this.splayCount=e.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;let e=this.path[this.path.length-1];return this.getValue(e)}rebuildPath(e){this.path.splice(0,this.path.length),this.tree.splay(e),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(e){for(;e!=null;)this.path.push(e),e=e.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let e=this.tree.getRoot();for(;e!=null;)this.path.push(e),e=e.left;return this.path.length>0}throw`Concurrent modification during iteration.`}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let e=this.path[this.path.length-1],t=e.right;if(t!=null){for(;t!=null;)this.path.push(t),t=t.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===e;)e=this.path.pop();return this.path.length>0}},fa=class extends da{getValue(e){return e.key}},pa=class extends da{getValue(e){return[e.key,e.key]}},X=e=>()=>e,ma=e=>{let t=e?(t,n)=>n.minus(t).abs().isLessThanOrEqualTo(e):X(!1);return(e,n)=>t(e,n)?0:e.comparedTo(n)};function ha(e){let t=e?(t,n,r,i,a)=>t.exponentiatedBy(2).isLessThanOrEqualTo(i.minus(n).exponentiatedBy(2).plus(a.minus(r).exponentiatedBy(2)).times(e)):X(!1);return(e,n,r)=>{let i=e.x,a=e.y,o=r.x,s=r.y,c=a.minus(s).times(n.x.minus(o)).minus(i.minus(o).times(n.y.minus(s)));return t(c,i,a,o,s)?0:c.comparedTo(0)}}var ga=e=>e,_a=e=>{if(e){let t=new ua(ma(e)),n=new ua(ma(e)),r=(e,t)=>t.addAndReturn(e),i=e=>({x:r(e.x,t),y:r(e.y,n)});return i({x:new sa(0),y:new sa(0)}),i}return ga},va=e=>({set:e=>{ya=va(e)},reset:()=>va(e),compare:ma(e),snap:_a(e),orient:ha(e)}),ya=va(),ba=(e,t)=>e.ll.x.isLessThanOrEqualTo(t.x)&&t.x.isLessThanOrEqualTo(e.ur.x)&&e.ll.y.isLessThanOrEqualTo(t.y)&&t.y.isLessThanOrEqualTo(e.ur.y),xa=(e,t)=>{if(t.ur.x.isLessThan(e.ll.x)||e.ur.x.isLessThan(t.ll.x)||t.ur.y.isLessThan(e.ll.y)||e.ur.y.isLessThan(t.ll.y))return null;let n=e.ll.x.isLessThan(t.ll.x)?t.ll.x:e.ll.x,r=e.ur.x.isLessThan(t.ur.x)?e.ur.x:t.ur.x,i=e.ll.y.isLessThan(t.ll.y)?t.ll.y:e.ll.y,a=e.ur.y.isLessThan(t.ur.y)?e.ur.y:t.ur.y;return{ll:{x:n,y:i},ur:{x:r,y:a}}},Sa=(e,t)=>e.x.times(t.y).minus(e.y.times(t.x)),Ca=(e,t)=>e.x.times(t.x).plus(e.y.times(t.y)),wa=e=>Ca(e,e).sqrt(),Ta=(e,t,n)=>{let r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Sa(i,r).div(wa(i)).div(wa(r))},Ea=(e,t,n)=>{let r={x:t.x.minus(e.x),y:t.y.minus(e.y)},i={x:n.x.minus(e.x),y:n.y.minus(e.y)};return Ca(i,r).div(wa(i)).div(wa(r))},Da=(e,t,n)=>t.y.isZero()?null:{x:e.x.plus(t.x.div(t.y).times(n.minus(e.y))),y:n},Oa=(e,t,n)=>t.x.isZero()?null:{x:n,y:e.y.plus(t.y.div(t.x).times(n.minus(e.x)))},ka=(e,t,n,r)=>{if(t.x.isZero())return Oa(n,r,e.x);if(r.x.isZero())return Oa(e,t,n.x);if(t.y.isZero())return Da(n,r,e.y);if(r.y.isZero())return Da(e,t,n.y);let i=Sa(t,r);if(i.isZero())return null;let a={x:n.x.minus(e.x),y:n.y.minus(e.y)},o=Sa(a,t).div(i),s=Sa(a,r).div(i),c=e.x.plus(s.times(t.x)),l=n.x.plus(o.times(r.x)),u=e.y.plus(s.times(t.y)),d=n.y.plus(o.times(r.y));return{x:c.plus(l).div(2),y:u.plus(d).div(2)}},Aa=class e{point;isLeft;segment;otherSE;consumedBy;static compare(t,n){let r=e.comparePoints(t.point,n.point);return r===0?(t.point!==n.point&&t.link(n),t.isLeft===n.isLeft?Ia.compare(t.segment,n.segment):t.isLeft?1:-1):r}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw Error(`Tried to link already linked events`);let t=e.point.events;for(let e=0,n=t.length;e<n;e++){let n=t[e];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){let e=this.point.events.length;for(let t=0;t<e;t++){let n=this.point.events[t];if(n.segment.consumedBy===void 0)for(let r=t+1;r<e;r++){let e=this.point.events[r];e.consumedBy===void 0&&n.otherSE.point.events===e.otherSE.point.events&&n.segment.consume(e.segment)}}}getAvailableLinkedEvents(){let e=[];for(let t=0,n=this.point.events.length;t<n;t++){let n=this.point.events[t];n!==this&&!n.segment.ringOut&&n.segment.isInResult()&&e.push(n)}return e}getLeftmostComparator(e){let t=new Map,n=n=>{let r=n.otherSE;t.set(n,{sine:Ta(this.point,e.point,r.point),cosine:Ea(this.point,e.point,r.point)})};return(e,r)=>{t.has(e)||n(e),t.has(r)||n(r);let{sine:i,cosine:a}=t.get(e),{sine:o,cosine:s}=t.get(r);return i.isGreaterThanOrEqualTo(0)&&o.isGreaterThanOrEqualTo(0)?a.isLessThan(s)?1:a.isGreaterThan(s)?-1:0:i.isLessThan(0)&&o.isLessThan(0)?a.isLessThan(s)?-1:a.isGreaterThan(s)?1:0:o.isLessThan(i)?-1:o.isGreaterThan(i)?1:0}}},ja=class e{events;poly;_isExteriorRing;_enclosingRing;static factory(t){let n=[];for(let r=0,i=t.length;r<i;r++){let i=t[r];if(!i.isInResult()||i.ringOut)continue;let a=null,o=i.leftSE,s=i.rightSE,c=[o],l=o.point,u=[];for(;a=o,o=s,c.push(o),o.point!==l;)for(;;){let t=o.getAvailableLinkedEvents();if(t.length===0){let e=c[0].point,t=c[c.length-1].point;throw Error(`Unable to complete output ring starting at [${e.x}, ${e.y}]. Last matching segment found ends at [${t.x}, ${t.y}].`)}if(t.length===1){s=t[0].otherSE;break}let r=null;for(let e=0,t=u.length;e<t;e++)if(u[e].point===o.point){r=e;break}if(r!==null){let t=u.splice(r)[0],i=c.splice(t.index);i.unshift(i[0].otherSE),n.push(new e(i.reverse()));continue}u.push({index:c.length,point:o.point});let i=o.getLeftmostComparator(a);s=t.sort(i)[0].otherSE;break}n.push(new e(c))}return n}constructor(e){this.events=e;for(let t=0,n=e.length;t<n;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point,t=[e];for(let n=1,r=this.events.length-1;n<r;n++){let r=this.events[n].point,i=this.events[n+1].point;ya.orient(r,e,i)!==0&&(t.push(r),e=r)}if(t.length===1)return null;let n=t[0],r=t[1];ya.orient(n,e,r)===0&&t.shift(),t.push(t[0]);let i=this.isExteriorRing()?1:-1,a=this.isExteriorRing()?0:t.length-1,o=this.isExteriorRing()?t.length:-1,s=[];for(let e=a;e!=o;e+=i)s.push([t[e].x.toNumber(),t[e].y.toNumber()]);return s}isExteriorRing(){if(this._isExteriorRing===void 0){let e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let t=1,n=this.events.length;t<n;t++){let n=this.events[t];Aa.compare(e,n)>0&&(e=n)}let t=e.segment.prevInResult(),n=t?t.prevInResult():null;for(;;){if(!t)return null;if(!n)return t.ringOut;if(n.ringOut!==t.ringOut)return n.ringOut?.enclosingRing()===t.ringOut?t.ringOut?.enclosingRing():t.ringOut;t=n.prevInResult(),n=t?t.prevInResult():null}}},Ma=class{exteriorRing;interiorRings;constructor(e){this.exteriorRing=e,e.poly=this,this.interiorRings=[]}addInterior(e){this.interiorRings.push(e),e.poly=this}getGeom(){let e=this.exteriorRing.getGeom();if(e===null)return null;let t=[e];for(let e=0,n=this.interiorRings.length;e<n;e++){let n=this.interiorRings[e].getGeom();n!==null&&t.push(n)}return t}},Na=class{rings;polys;constructor(e){this.rings=e,this.polys=this._composePolys(e)}getGeom(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getGeom();n!==null&&e.push(n)}return e}_composePolys(e){let t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(!r.poly)if(r.isExteriorRing())t.push(new Ma(r));else{let e=r.enclosingRing();e?.poly||t.push(new Ma(e)),e?.poly?.addInterior(r)}}return t}},Pa=class{queue;tree;segments;constructor(e,t=Ia.compare){this.queue=e,this.tree=new ua(t),this.segments=[]}process(e){let t=e.segment,n=[];if(e.consumedBy)return e.isLeft?this.queue.delete(e.otherSE):this.tree.delete(t),n;e.isLeft&&this.tree.add(t);let r=t,i=t;do r=this.tree.lastBefore(r);while(r!=null&&r.consumedBy!=null);do i=this.tree.firstAfter(i);while(i!=null&&i.consumedBy!=null);if(e.isLeft){let a=null;if(r){let e=r.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(a=e),!r.isAnEndpoint(e))){let t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}let o=null;if(i){let e=i.getIntersection(t);if(e!==null&&(t.isAnEndpoint(e)||(o=e),!i.isAnEndpoint(e))){let t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}if(a!==null||o!==null){let e=null;e=a===null?o:o===null||Aa.comparePoints(a,o)<=0?a:o,this.queue.delete(t.rightSE),n.push(t.rightSE);let r=t.split(e);for(let e=0,t=r.length;e<t;e++)n.push(r[e])}n.length>0?(this.tree.delete(t),n.push(e)):(this.segments.push(t),t.prev=r)}else{if(r&&i){let e=r.getIntersection(i);if(e!==null){if(!r.isAnEndpoint(e)){let t=this._splitSafely(r,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}if(!i.isAnEndpoint(e)){let t=this._splitSafely(i,e);for(let e=0,r=t.length;e<r;e++)n.push(t[e])}}}this.tree.delete(t)}return n}_splitSafely(e,t){this.tree.delete(e);let n=e.rightSE;this.queue.delete(n);let r=e.split(t);return r.push(n),e.consumedBy===void 0&&this.tree.add(e),r}},Fa=new class{type;numMultiPolys;run(e,t,n){Fa.type=e;let r=[new za(t,!0)];for(let e=0,t=n.length;e<t;e++)r.push(new za(n[e],!1));if(Fa.numMultiPolys=r.length,Fa.type===`difference`){let e=r[0],t=1;for(;t<r.length;)xa(r[t].bbox,e.bbox)===null?r.splice(t,1):t++}if(Fa.type===`intersection`)for(let e=0,t=r.length;e<t;e++){let t=r[e];for(let n=e+1,i=r.length;n<i;n++)if(xa(t.bbox,r[n].bbox)===null)return[]}let i=new ua(Aa.compare);for(let e=0,t=r.length;e<t;e++){let t=r[e].getSweepEvents();for(let e=0,n=t.length;e<n;e++)i.add(t[e])}let a=new Pa(i),o=null;for(i.size!=0&&(o=i.first(),i.delete(o));o;){let e=a.process(o);for(let t=0,n=e.length;t<n;t++){let n=e[t];n.consumedBy===void 0&&i.add(n)}i.size==0?o=null:(o=i.first(),i.delete(o))}return ya.reset(),new Na(ja.factory(a.segments)).getGeom()}},Z=Fa,Q=0,Ia=class e{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){let n=e.leftSE.point.x,r=t.leftSE.point.x,i=e.rightSE.point.x,a=t.rightSE.point.x;if(a.isLessThan(n))return 1;if(i.isLessThan(r))return-1;let o=e.leftSE.point.y,s=t.leftSE.point.y,c=e.rightSE.point.y,l=t.rightSE.point.y;if(n.isLessThan(r)){if(s.isLessThan(o)&&s.isLessThan(c))return 1;if(s.isGreaterThan(o)&&s.isGreaterThan(c))return-1;let n=e.comparePoint(t.leftSE.point);if(n<0)return 1;if(n>0)return-1;let r=t.comparePoint(e.rightSE.point);return r===0?-1:r}if(n.isGreaterThan(r)){if(o.isLessThan(s)&&o.isLessThan(l))return-1;if(o.isGreaterThan(s)&&o.isGreaterThan(l))return 1;let n=t.comparePoint(e.leftSE.point);if(n!==0)return n;let r=e.comparePoint(t.rightSE.point);return r<0?1:r>0?-1:1}if(o.isLessThan(s))return-1;if(o.isGreaterThan(s))return 1;if(i.isLessThan(a)){let n=t.comparePoint(e.rightSE.point);if(n!==0)return n}if(i.isGreaterThan(a)){let n=e.comparePoint(t.rightSE.point);if(n<0)return 1;if(n>0)return-1}if(!i.eq(a)){let e=c.minus(o),t=i.minus(n),u=l.minus(s),d=a.minus(r);if(e.isGreaterThan(t)&&u.isLessThan(d))return 1;if(e.isLessThan(t)&&u.isGreaterThan(d))return-1}return i.isGreaterThan(a)?1:i.isLessThan(a)||c.isLessThan(l)?-1:c.isGreaterThan(l)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,n,r){this.id=++Q,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=n,this.windings=r}static fromRing(t,n,r){let i,a,o,s=Aa.comparePoints(t,n);if(s<0)i=t,a=n,o=1;else if(s>0)i=n,a=t,o=-1;else throw Error(`Tried to create degenerate segment at [${t.x}, ${t.y}]`);return new e(new Aa(i,!0),new Aa(a,!1),[r],[o])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return ya.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){let t=this.bbox(),n=e.bbox(),r=xa(t,n);if(r===null)return null;let i=this.leftSE.point,a=this.rightSE.point,o=e.leftSE.point,s=e.rightSE.point,c=ba(t,o)&&this.comparePoint(o)===0,l=ba(n,i)&&e.comparePoint(i)===0,u=ba(t,s)&&this.comparePoint(s)===0,d=ba(n,a)&&e.comparePoint(a)===0;if(l&&c)return d&&!u?a:!d&&u?s:null;if(l)return u&&i.x.eq(s.x)&&i.y.eq(s.y)?null:i;if(c)return d&&a.x.eq(o.x)&&a.y.eq(o.y)?null:o;if(d&&u)return null;if(d)return a;if(u)return s;let f=ka(i,this.vector(),o,e.vector());return f===null||!ba(r,f)?null:ya.snap(f)}split(t){let n=[],r=t.events!==void 0,i=new Aa(t,!0),a=new Aa(t,!1),o=this.rightSE;this.replaceRightSE(a),n.push(a),n.push(i);let s=new e(i,o,this.rings.slice(),this.windings.slice());return Aa.comparePoints(s.leftSE.point,s.rightSE.point)>0&&s.swapEvents(),Aa.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),a.checkForConsuming()),n}swapEvents(){let e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let e=0,t=this.windings.length;e<t;e++)this.windings[e]*=-1}consume(t){let n=this,r=t;for(;n.consumedBy;)n=n.consumedBy;for(;r.consumedBy;)r=r.consumedBy;let i=e.compare(n,r);if(i!==0){if(i>0){let e=n;n=r,r=e}if(n.prev===r){let e=n;n=r,r=e}for(let e=0,t=r.rings.length;e<t;e++){let t=r.rings[e],i=r.windings[e],a=n.rings.indexOf(t);a===-1?(n.rings.push(t),n.windings.push(i)):n.windings[a]+=i}r.rings=null,r.windings=null,r.consumedBy=n,r.leftSE.consumedBy=n.leftSE,r.rightSE.consumedBy=n.rightSE}}prevInResult(){return this._prevInResult===void 0&&(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null),this._prevInResult}beforeState(){return this._beforeState===void 0&&(this.prev?this._beforeState=(this.prev.consumedBy||this.prev).afterState():this._beforeState={rings:[],windings:[],multiPolys:[]}),this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};let t=this._afterState.rings,n=this._afterState.windings,r=this._afterState.multiPolys;for(let e=0,r=this.rings.length;e<r;e++){let r=this.rings[e],i=this.windings[e],a=t.indexOf(r);a===-1?(t.push(r),n.push(i)):n[a]+=i}let i=[],a=[];for(let e=0,r=t.length;e<r;e++){if(n[e]===0)continue;let r=t[e],o=r.poly;if(a.indexOf(o)===-1)if(r.isExterior)i.push(o);else{a.indexOf(o)===-1&&a.push(o);let e=i.indexOf(r.poly);e!==-1&&i.splice(e,1)}}for(let e=0,t=i.length;e<t;e++){let t=i[e].multiPoly;r.indexOf(t)===-1&&r.push(t)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(Z.type){case`union`:this._isInResult=e.length===0!=(t.length===0);break;case`intersection`:{let n,r;e.length<t.length?(n=e.length,r=t.length):(n=t.length,r=e.length),this._isInResult=r===Z.numMultiPolys&&n<r;break}case`xor`:this._isInResult=Math.abs(e.length-t.length)%2==1;break;case`difference`:{let n=e=>e.length===1&&e[0].isSubject;this._isInResult=n(e)!==n(t);break}}return this._isInResult}},La=class{poly;isExterior;segments;bbox;constructor(e,t,n){if(!Array.isArray(e)||e.length===0||(this.poly=t,this.isExterior=n,this.segments=[],typeof e[0][0]!=`number`||typeof e[0][1]!=`number`))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let r=ya.snap({x:new sa(e[0][0]),y:new sa(e[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let i=r;for(let t=1,n=e.length;t<n;t++){if(typeof e[t][0]!=`number`||typeof e[t][1]!=`number`)throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);let n=ya.snap({x:new sa(e[t][0]),y:new sa(e[t][1])});n.x.eq(i.x)&&n.y.eq(i.y)||(this.segments.push(Ia.fromRing(i,n,this)),n.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.x),n.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.y),n.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.x),n.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.y),i=n)}(!r.x.eq(i.x)||!r.y.eq(i.y))&&this.segments.push(Ia.fromRing(i,r,this))}getSweepEvents(){let e=[];for(let t=0,n=this.segments.length;t<n;t++){let n=this.segments[t];e.push(n.leftSE),e.push(n.rightSE)}return e}},Ra=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);this.exteriorRing=new La(e[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,n=e.length;t<n;t++){let n=new La(e[t],this,!1);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.interiorRings.push(n)}this.multiPoly=t}getSweepEvents(){let e=this.exteriorRing.getSweepEvents();for(let t=0,n=this.interiorRings.length;t<n;t++){let n=this.interiorRings[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},za=class{isSubject;polys;bbox;constructor(e,t){if(!Array.isArray(e))throw Error(`Input geometry is not a valid Polygon or MultiPolygon`);try{typeof e[0][0][0]==`number`&&(e=[e])}catch{}this.polys=[],this.bbox={ll:{x:new sa(1/0),y:new sa(1/0)},ur:{x:new sa(-1/0),y:new sa(-1/0)}};for(let t=0,n=e.length;t<n;t++){let n=new Ra(e[t],this);n.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=n.bbox.ll.x),n.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=n.bbox.ll.y),n.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=n.bbox.ur.x),n.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=n.bbox.ur.y),this.polys.push(n)}this.isSubject=t}getSweepEvents(){let e=[];for(let t=0,n=this.polys.length;t<n;t++){let n=this.polys[t].getSweepEvents();for(let t=0,r=n.length;t<r;t++)e.push(n[t])}return e}},Ba=(e,...t)=>Z.run(`intersection`,e,t);ya.set;function Va(e,t={}){let n=[];if(kn(e,e=>{n.push(e.coordinates)}),n.length<2)throw Error(`Must specify at least 2 geometries`);let r=Ba(n[0],...n.slice(1));return r.length===0?null:r.length===1?Cn(r[0],t.properties):Dn(r,t.properties)}var Ha=1e-6,$=Math.PI,Ua=$/2,Wa=$/4,Ga=$*2,Ka=180/$,qa=$/180,Ja=Math.abs,Ya=Math.atan,Xa=Math.atan2,Za=Math.cos,Qa=Math.ceil,$a=Math.exp,eo=Math.log,to=Math.sin,no=Math.sign||function(e){return e>0?1:e<0?-1:0},ro=Math.sqrt,io=Math.tan;function ao(e){return e>1?0:e<-1?$:Math.acos(e)}function oo(e){return e>1?Ua:e<-1?-Ua:Math.asin(e)}function so(){}function co(e,t){e&&uo.hasOwnProperty(e.type)&&uo[e.type](e,t)}var lo={Feature:function(e,t){co(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,r=-1,i=n.length;++r<i;)co(n[r].geometry,t)}},uo={Sphere:function(e,t){t.sphere()},Point:function(e,t){e=e.coordinates,t.point(e[0],e[1],e[2])},MultiPoint:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)e=n[r],t.point(e[0],e[1],e[2])},LineString:function(e,t){fo(e.coordinates,t,0)},MultiLineString:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)fo(n[r],t,0)},Polygon:function(e,t){po(e.coordinates,t)},MultiPolygon:function(e,t){for(var n=e.coordinates,r=-1,i=n.length;++r<i;)po(n[r],t)},GeometryCollection:function(e,t){for(var n=e.geometries,r=-1,i=n.length;++r<i;)co(n[r],t)}};function fo(e,t,n){var r=-1,i=e.length-n,a;for(t.lineStart();++r<i;)a=e[r],t.point(a[0],a[1],a[2]);t.lineEnd()}function po(e,t){var n=-1,r=e.length;for(t.polygonStart();++n<r;)fo(e[n],t,1);t.polygonEnd()}function mo(e,t){e&&lo.hasOwnProperty(e.type)?lo[e.type](e,t):co(e,t)}function ho(e){return[Xa(e[1],e[0]),oo(e[2])]}function go(e){var t=e[0],n=e[1],r=Za(n);return[r*Za(t),r*to(t),to(n)]}function _o(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function vo(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function yo(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function bo(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function xo(e){var t=ro(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}function So(e,t){function n(n,r){return n=e(n,r),t(n[0],n[1])}return e.invert&&t.invert&&(n.invert=function(n,r){return n=t.invert(n,r),n&&e.invert(n[0],n[1])}),n}function Co(e,t){return Ja(e)>$&&(e-=Math.round(e/Ga)*Ga),[e,t]}Co.invert=Co;function wo(e,t,n){return(e%=Ga)?t||n?So(Eo(e),Do(t,n)):Eo(e):t||n?Do(t,n):Co}function To(e){return function(t,n){return t+=e,Ja(t)>$&&(t-=Math.round(t/Ga)*Ga),[t,n]}}function Eo(e){var t=To(e);return t.invert=To(-e),t}function Do(e,t){var n=Za(e),r=to(e),i=Za(t),a=to(t);function o(e,t){var o=Za(t),s=Za(e)*o,c=to(e)*o,l=to(t),u=l*n+s*r;return[Xa(c*i-u*a,s*n-l*r),oo(u*i+c*a)]}return o.invert=function(e,t){var o=Za(t),s=Za(e)*o,c=to(e)*o,l=to(t),u=l*i-c*a;return[Xa(c*i+l*a,s*n+u*r),oo(u*n-s*r)]},o}function Oo(e){e=wo(e[0]*qa,e[1]*qa,e.length>2?e[2]*qa:0);function t(t){return t=e(t[0]*qa,t[1]*qa),t[0]*=Ka,t[1]*=Ka,t}return t.invert=function(t){return t=e.invert(t[0]*qa,t[1]*qa),t[0]*=Ka,t[1]*=Ka,t},t}function ko(e,t,n,r,i,a){if(n){var o=Za(t),s=to(t),c=r*n;i==null?(i=t+r*Ga,a=t-c/2):(i=Ao(o,i),a=Ao(o,a),(r>0?i<a:i>a)&&(i+=r*Ga));for(var l,u=i;r>0?u>a:u<a;u-=c)l=ho([o,-s*Za(u),-s*to(u)]),e.point(l[0],l[1])}}function Ao(e,t){t=go(t),t[0]-=e,xo(t);var n=ao(-t[1]);return((-t[2]<0?-n:n)+Ga-Ha)%Ga}function jo(){var e=[],t;return{point:function(e,n,r){t.push([e,n,r])},lineStart:function(){e.push(t=[])},lineEnd:so,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Mo(e,t){return Ja(e[0]-t[0])<1e-6&&Ja(e[1]-t[1])<1e-6}function No(e,t,n,r){this.x=e,this.z=t,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function Po(e,t,n,r,i){var a=[],o=[],s,c;if(e.forEach(function(e){if(!((t=e.length-1)<=0)){var t,n=e[0],r=e[t],c;if(Mo(n,r)){if(!n[2]&&!r[2]){for(i.lineStart(),s=0;s<t;++s)i.point((n=e[s])[0],n[1]);i.lineEnd();return}r[0]+=2*Ha}a.push(c=new No(n,e,null,!0)),o.push(c.o=new No(n,null,c,!1)),a.push(c=new No(r,e,null,!1)),o.push(c.o=new No(r,null,c,!0))}}),a.length){for(o.sort(t),Fo(a),Fo(o),s=0,c=o.length;s<c;++s)o[s].e=n=!n;for(var l=a[0],u,d;;){for(var f=l,p=!0;f.v;)if((f=f.n)===l)return;u=f.z,i.lineStart();do{if(f.v=f.o.v=!0,f.e){if(p)for(s=0,c=u.length;s<c;++s)i.point((d=u[s])[0],d[1]);else r(f.x,f.n.x,1,i);f=f.n}else{if(p)for(u=f.p.z,s=u.length-1;s>=0;--s)i.point((d=u[s])[0],d[1]);else r(f.x,f.p.x,-1,i);f=f.p}f=f.o,u=f.z,p=!p}while(!f.v);i.lineEnd()}}}function Fo(e){if(t=e.length){for(var t,n=0,r=e[0],i;++n<t;)r.n=i=e[n],i.p=r,r=i;r.n=i=e[0],i.p=r}}function Io(e){return Ja(e[0])<=$?e[0]:no(e[0])*((Ja(e[0])+$)%Ga-$)}function Lo(e,t){var n=Io(t),r=t[1],i=to(r),a=[to(n),-Za(n),0],o=0,s=0,c=new vt;i===1?r=Ua+Ha:i===-1&&(r=-Ua-Ha);for(var l=0,u=e.length;l<u;++l)if(f=(d=e[l]).length)for(var d,f,p=d[f-1],m=Io(p),h=p[1]/2+Wa,g=to(h),_=Za(h),v=0;v<f;++v,m=b,g=S,_=C,p=y){var y=d[v],b=Io(y),x=y[1]/2+Wa,S=to(x),C=Za(x),w=b-m,T=w>=0?1:-1,E=T*w,D=E>$,O=g*S;if(c.add(Xa(O*T*to(E),_*C+O*Za(E))),o+=D?w+T*Ga:w,D^m>=n^b>=n){var k=vo(go(p),go(y));xo(k);var A=vo(a,k);xo(A);var j=(D^w>=0?-1:1)*oo(A[2]);(r>j||r===j&&(k[0]||k[1]))&&(s+=D^w>=0?1:-1)}}return(o<-1e-6||o<1e-6&&c<-1e-12)^s&1}function Ro(e,t,n,r){return function(i){var a=t(i),o=jo(),s=t(o),c=!1,l,u,d,f={point:p,lineStart:h,lineEnd:g,polygonStart:function(){f.point=_,f.lineStart=v,f.lineEnd=y,u=[],l=[]},polygonEnd:function(){f.point=p,f.lineStart=h,f.lineEnd=g,u=Nt(u);var e=Lo(l,r);u.length?(c||=(i.polygonStart(),!0),Po(u,Bo,e,n,i)):e&&(c||=(i.polygonStart(),!0),i.lineStart(),n(null,null,1,i),i.lineEnd()),c&&=(i.polygonEnd(),!1),u=l=null},sphere:function(){i.polygonStart(),i.lineStart(),n(null,null,1,i),i.lineEnd(),i.polygonEnd()}};function p(t,n){e(t,n)&&i.point(t,n)}function m(e,t){a.point(e,t)}function h(){f.point=m,a.lineStart()}function g(){f.point=p,a.lineEnd()}function _(e,t){d.push([e,t]),s.point(e,t)}function v(){s.lineStart(),d=[]}function y(){_(d[0][0],d[0][1]),s.lineEnd();var e=s.clean(),t=o.result(),n,r=t.length,a,f,p;if(d.pop(),l.push(d),d=null,r){if(e&1){if(f=t[0],(a=f.length-1)>0){for(c||=(i.polygonStart(),!0),i.lineStart(),n=0;n<a;++n)i.point((p=f[n])[0],p[1]);i.lineEnd()}return}r>1&&e&2&&t.push(t.pop().concat(t.shift())),u.push(t.filter(zo))}}return f}}function zo(e){return e.length>1}function Bo(e,t){return((e=e.x)[0]<0?e[1]-Ua-Ha:Ua-e[1])-((t=t.x)[0]<0?t[1]-Ua-Ha:Ua-t[1])}var Vo=Ro(function(){return!0},Ho,Wo,[-$,-Ua]);function Ho(e){var t=NaN,n=NaN,r=NaN,i;return{lineStart:function(){e.lineStart(),i=1},point:function(a,o){var s=a>0?$:-$,c=Ja(a-t);Ja(c-$)<1e-6?(e.point(t,n=(n+o)/2>0?Ua:-Ua),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),e.point(a,n),i=0):r!==s&&c>=$&&(Ja(t-r)<1e-6&&(t-=r*Ha),Ja(a-s)<1e-6&&(a-=s*Ha),n=Uo(t,n,a,o),e.point(r,n),e.lineEnd(),e.lineStart(),e.point(s,n),i=0),e.point(t=a,n=o),r=s},lineEnd:function(){e.lineEnd(),t=n=NaN},clean:function(){return 2-i}}}function Uo(e,t,n,r){var i,a,o=to(e-n);return Ja(o)>1e-6?Ya((to(t)*(a=Za(r))*to(n)-to(r)*(i=Za(t))*to(e))/(i*a*o)):(t+r)/2}function Wo(e,t,n,r){var i;if(e==null)i=n*Ua,r.point(-$,i),r.point(0,i),r.point($,i),r.point($,0),r.point($,-i),r.point(0,-i),r.point(-$,-i),r.point(-$,0),r.point(-$,i);else if(Ja(e[0]-t[0])>1e-6){var a=e[0]<t[0]?$:-$;i=n*a/2,r.point(-a,i),r.point(0,i),r.point(a,i)}else r.point(t[0],t[1])}function Go(e){var t=Za(e),n=2*qa,r=t>0,i=Ja(t)>Ha;function a(t,r,i,a){ko(a,e,n,i,t,r)}function o(e,n){return Za(e)*Za(n)>t}function s(e){var t,n,a,s,u;return{lineStart:function(){s=a=!1,u=1},point:function(d,f){var p=[d,f],m,h=o(d,f),g=r?h?0:l(d,f):h?l(d+(d<0?$:-$),f):0;if(!t&&(s=a=h)&&e.lineStart(),h!==a&&(m=c(t,p),(!m||Mo(t,m)||Mo(p,m))&&(p[2]=1)),h!==a)u=0,h?(e.lineStart(),m=c(p,t),e.point(m[0],m[1])):(m=c(t,p),e.point(m[0],m[1],2),e.lineEnd()),t=m;else if(i&&t&&r^h){var _;!(g&n)&&(_=c(p,t,!0))&&(u=0,r?(e.lineStart(),e.point(_[0][0],_[0][1]),e.point(_[1][0],_[1][1]),e.lineEnd()):(e.point(_[1][0],_[1][1]),e.lineEnd(),e.lineStart(),e.point(_[0][0],_[0][1],3)))}h&&(!t||!Mo(t,p))&&e.point(p[0],p[1]),t=p,a=h,n=g},lineEnd:function(){a&&e.lineEnd(),t=null},clean:function(){return u|(s&&a)<<1}}}function c(e,n,r){var i=go(e),a=go(n),o=[1,0,0],s=vo(i,a),c=_o(s,s),l=s[0],u=c-l*l;if(!u)return!r&&e;var d=t*c/u,f=-t*l/u,p=vo(o,s),m=bo(o,d);yo(m,bo(s,f));var h=p,g=_o(m,h),_=_o(h,h),v=g*g-_*(_o(m,m)-1);if(!(v<0)){var y=ro(v),b=bo(h,(-g-y)/_);if(yo(b,m),b=ho(b),!r)return b;var x=e[0],S=n[0],C=e[1],w=n[1],T;S<x&&(T=x,x=S,S=T);var E=S-x,D=Ja(E-$)<Ha,O=D||E<1e-6;if(!D&&w<C&&(T=C,C=w,w=T),O?D?C+w>0^b[1]<(Ja(b[0]-x)<1e-6?C:w):C<=b[1]&&b[1]<=w:E>$^(x<=b[0]&&b[0]<=S)){var k=bo(h,(-g+y)/_);return yo(k,m),[b,ho(k)]}}}function l(t,n){var i=r?e:$-e,a=0;return t<-i?a|=1:t>i&&(a|=2),n<-i?a|=4:n>i&&(a|=8),a}return Ro(o,s,a,r?[0,-e]:[-$,e-$])}function Ko(e,t,n,r,i,a){var o=e[0],s=e[1],c=t[0],l=t[1],u=0,d=1,f=c-o,p=l-s,m=n-o;if(!(!f&&m>0)){if(m/=f,f<0){if(m<u)return;m<d&&(d=m)}else if(f>0){if(m>d)return;m>u&&(u=m)}if(m=i-o,!(!f&&m<0)){if(m/=f,f<0){if(m>d)return;m>u&&(u=m)}else if(f>0){if(m<u)return;m<d&&(d=m)}if(m=r-s,!(!p&&m>0)){if(m/=p,p<0){if(m<u)return;m<d&&(d=m)}else if(p>0){if(m>d)return;m>u&&(u=m)}if(m=a-s,!(!p&&m<0)){if(m/=p,p<0){if(m>d)return;m>u&&(u=m)}else if(p>0){if(m<u)return;m<d&&(d=m)}return u>0&&(e[0]=o+u*f,e[1]=s+u*p),d<1&&(t[0]=o+d*f,t[1]=s+d*p),!0}}}}}var qo=1e9,Jo=-qo;function Yo(e,t,n,r){function i(i,a){return e<=i&&i<=n&&t<=a&&a<=r}function a(i,a,s,l){var u=0,d=0;if(i==null||(u=o(i,s))!==(d=o(a,s))||c(i,a)<0^s>0)do l.point(u===0||u===3?e:n,u>1?r:t);while((u=(u+s+4)%4)!==d);else l.point(a[0],a[1])}function o(r,i){return Ja(r[0]-e)<1e-6?i>0?0:3:Ja(r[0]-n)<1e-6?i>0?2:1:Ja(r[1]-t)<1e-6?i>0?1:0:i>0?3:2}function s(e,t){return c(e.x,t.x)}function c(e,t){var n=o(e,1),r=o(t,1);return n===r?n===0?t[1]-e[1]:n===1?e[0]-t[0]:n===2?e[1]-t[1]:t[0]-e[0]:n-r}return function(o){var c=o,l=jo(),u,d,f,p,m,h,g,_,v,y,b,x={point:S,lineStart:E,lineEnd:D,polygonStart:w,polygonEnd:T};function S(e,t){i(e,t)&&c.point(e,t)}function C(){for(var t=0,n=0,i=d.length;n<i;++n)for(var a=d[n],o=1,s=a.length,c=a[0],l,u,f=c[0],p=c[1];o<s;++o)l=f,u=p,c=a[o],f=c[0],p=c[1],u<=r?p>r&&(f-l)*(r-u)>(p-u)*(e-l)&&++t:p<=r&&(f-l)*(r-u)<(p-u)*(e-l)&&--t;return t}function w(){c=l,u=[],d=[],b=!0}function T(){var e=C(),t=b&&e,n=(u=Nt(u)).length;(t||n)&&(o.polygonStart(),t&&(o.lineStart(),a(null,null,1,o),o.lineEnd()),n&&Po(u,s,e,a,o),o.polygonEnd()),c=o,u=d=f=null}function E(){x.point=O,d&&d.push(f=[]),y=!0,v=!1,g=_=NaN}function D(){u&&(O(p,m),h&&v&&l.rejoin(),u.push(l.result())),x.point=S,v&&c.lineEnd()}function O(a,o){var s=i(a,o);if(d&&f.push([a,o]),y)p=a,m=o,h=s,y=!1,s&&(c.lineStart(),c.point(a,o));else if(s&&v)c.point(a,o);else{var l=[g=Math.max(Jo,Math.min(qo,g)),_=Math.max(Jo,Math.min(qo,_))],u=[a=Math.max(Jo,Math.min(qo,a)),o=Math.max(Jo,Math.min(qo,o))];Ko(l,u,e,t,n,r)?(v||(c.lineStart(),c.point(l[0],l[1])),c.point(u[0],u[1]),s||c.lineEnd(),b=!1):s&&(c.lineStart(),c.point(a,o),b=!1)}g=a,_=o,v=s}return x}}function Xo(e,t,n){var r=Pt(e,t-Ha,n).concat(t);return function(e){return r.map(function(t){return[e,t]})}}function Zo(e,t,n){var r=Pt(e,t-Ha,n).concat(t);return function(e){return r.map(function(t){return[t,e]})}}function Qo(){var e,t,n,r,i,a,o,s,c=10,l=c,u=90,d=360,f,p,m,h,g=2.5;function _(){return{type:`MultiLineString`,coordinates:v()}}function v(){return Pt(Qa(r/u)*u,n,u).map(m).concat(Pt(Qa(s/d)*d,o,d).map(h)).concat(Pt(Qa(t/c)*c,e,c).filter(function(e){return Ja(e%u)>Ha}).map(f)).concat(Pt(Qa(a/l)*l,i,l).filter(function(e){return Ja(e%d)>Ha}).map(p))}return _.lines=function(){return v().map(function(e){return{type:`LineString`,coordinates:e}})},_.outline=function(){return{type:`Polygon`,coordinates:[m(r).concat(h(o).slice(1),m(n).reverse().slice(1),h(s).reverse().slice(1))]}},_.extent=function(e){return arguments.length?_.extentMajor(e).extentMinor(e):_.extentMinor()},_.extentMajor=function(e){return arguments.length?(r=+e[0][0],n=+e[1][0],s=+e[0][1],o=+e[1][1],r>n&&(e=r,r=n,n=e),s>o&&(e=s,s=o,o=e),_.precision(g)):[[r,s],[n,o]]},_.extentMinor=function(n){return arguments.length?(t=+n[0][0],e=+n[1][0],a=+n[0][1],i=+n[1][1],t>e&&(n=t,t=e,e=n),a>i&&(n=a,a=i,i=n),_.precision(g)):[[t,a],[e,i]]},_.step=function(e){return arguments.length?_.stepMajor(e).stepMinor(e):_.stepMinor()},_.stepMajor=function(e){return arguments.length?(u=+e[0],d=+e[1],_):[u,d]},_.stepMinor=function(e){return arguments.length?(c=+e[0],l=+e[1],_):[c,l]},_.precision=function(c){return arguments.length?(g=+c,f=Xo(a,i,90),p=Zo(t,e,g),m=Xo(s,o,90),h=Zo(r,n,g),_):g},_.extentMajor([[-180,-90+Ha],[180,90-Ha]]).extentMinor([[-180,-80-Ha],[180,80+Ha]])}var $o=e=>e,es=new vt,ts=new vt,ns,rs,is,as,os={point:so,lineStart:so,lineEnd:so,polygonStart:function(){os.lineStart=ss,os.lineEnd=us},polygonEnd:function(){os.lineStart=os.lineEnd=os.point=so,es.add(Ja(ts)),ts=new vt},result:function(){var e=es/2;return es=new vt,e}};function ss(){os.point=cs}function cs(e,t){os.point=ls,ns=is=e,rs=as=t}function ls(e,t){ts.add(as*e-is*t),is=e,as=t}function us(){ls(ns,rs)}var ds=1/0,fs=ds,ps=-ds,ms=ps,hs={point:gs,lineStart:so,lineEnd:so,polygonStart:so,polygonEnd:so,result:function(){var e=[[ds,fs],[ps,ms]];return ps=ms=-(fs=ds=1/0),e}};function gs(e,t){e<ds&&(ds=e),e>ps&&(ps=e),t<fs&&(fs=t),t>ms&&(ms=t)}var _s=0,vs=0,ys=0,bs=0,xs=0,Ss=0,Cs=0,ws=0,Ts=0,Es,Ds,Os,ks,As={point:js,lineStart:Ms,lineEnd:Fs,polygonStart:function(){As.lineStart=Is,As.lineEnd=Ls},polygonEnd:function(){As.point=js,As.lineStart=Ms,As.lineEnd=Fs},result:function(){var e=Ts?[Cs/Ts,ws/Ts]:Ss?[bs/Ss,xs/Ss]:ys?[_s/ys,vs/ys]:[NaN,NaN];return _s=vs=ys=bs=xs=Ss=Cs=ws=Ts=0,e}};function js(e,t){_s+=e,vs+=t,++ys}function Ms(){As.point=Ns}function Ns(e,t){As.point=Ps,js(Os=e,ks=t)}function Ps(e,t){var n=e-Os,r=t-ks,i=ro(n*n+r*r);bs+=i*(Os+e)/2,xs+=i*(ks+t)/2,Ss+=i,js(Os=e,ks=t)}function Fs(){As.point=js}function Is(){As.point=Rs}function Ls(){zs(Es,Ds)}function Rs(e,t){As.point=zs,js(Es=Os=e,Ds=ks=t)}function zs(e,t){var n=e-Os,r=t-ks,i=ro(n*n+r*r);bs+=i*(Os+e)/2,xs+=i*(ks+t)/2,Ss+=i,i=ks*e-Os*t,Cs+=i*(Os+e),ws+=i*(ks+t),Ts+=i*3,js(Os=e,ks=t)}function Bs(e){this._context=e}Bs.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:this._context.moveTo(e,t),this._point=1;break;case 1:this._context.lineTo(e,t);break;default:this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,Ga);break}},result:so};var Vs=new vt,Hs,Us,Ws,Gs,Ks,qs={point:so,lineStart:function(){qs.point=Js},lineEnd:function(){Hs&&Ys(Us,Ws),qs.point=so},polygonStart:function(){Hs=!0},polygonEnd:function(){Hs=null},result:function(){var e=+Vs;return Vs=new vt,e}};function Js(e,t){qs.point=Ys,Us=Gs=e,Ws=Ks=t}function Ys(e,t){Gs-=e,Ks-=t,Vs.add(ro(Gs*Gs+Ks*Ks)),Gs=e,Ks=t}var Xs,Zs,Qs,$s,ec=class{constructor(e){this._append=e==null?tc:nc(e),this._radius=4.5,this._=``}pointRadius(e){return this._radius=+e,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+=`Z`),this._point=NaN}point(e,t){switch(this._point){case 0:this._append`M${e},${t}`,this._point=1;break;case 1:this._append`L${e},${t}`;break;default:if(this._append`M${e},${t}`,this._radius!==Qs||this._append!==Zs){let e=this._radius,t=this._;this._=``,this._append`m0,${e}a${e},${e} 0 1,1 0,${-2*e}a${e},${e} 0 1,1 0,${2*e}z`,Qs=e,Zs=this._append,$s=this._,this._=t}this._+=$s;break}}result(){let e=this._;return this._=``,e.length?e:null}};function tc(e){let t=1;this._+=e[0];for(let n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function nc(e){let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);if(t>15)return tc;if(t!==Xs){let e=10**t;Xs=t,Zs=function(t){let n=1;this._+=t[0];for(let r=t.length;n<r;++n)this._+=Math.round(arguments[n]*e)/e+t[n]}}return Zs}function rc(e,t){let n=3,r=4.5,i,a;function o(e){return e&&(typeof r==`function`&&a.pointRadius(+r.apply(this,arguments)),mo(e,i(a))),a.result()}return o.area=function(e){return mo(e,i(os)),os.result()},o.measure=function(e){return mo(e,i(qs)),qs.result()},o.bounds=function(e){return mo(e,i(hs)),hs.result()},o.centroid=function(e){return mo(e,i(As)),As.result()},o.projection=function(t){return arguments.length?(i=t==null?(e=null,$o):(e=t).stream,o):e},o.context=function(e){return arguments.length?(a=e==null?(t=null,new ec(n)):new Bs(t=e),typeof r!=`function`&&a.pointRadius(r),o):t},o.pointRadius=function(e){return arguments.length?(r=typeof e==`function`?e:(a.pointRadius(+e),+e),o):r},o.digits=function(e){if(!arguments.length)return n;if(e==null)n=null;else{let t=Math.floor(e);if(!(t>=0))throw RangeError(`invalid digits: ${e}`);n=t}return t===null&&(a=new ec(n)),o},o.projection(e).digits(n).context(t)}function ic(e){return function(t){var n=new ac;for(var r in e)n[r]=e[r];return n.stream=t,n}}function ac(){}ac.prototype={constructor:ac,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function oc(e,t,n){var r=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),r!=null&&e.clipExtent(null),mo(n,e.stream(hs)),t(hs.result()),r!=null&&e.clipExtent(r),e}function sc(e,t,n){return oc(e,function(n){var r=t[1][0]-t[0][0],i=t[1][1]-t[0][1],a=Math.min(r/(n[1][0]-n[0][0]),i/(n[1][1]-n[0][1])),o=+t[0][0]+(r-a*(n[1][0]+n[0][0]))/2,s=+t[0][1]+(i-a*(n[1][1]+n[0][1]))/2;e.scale(150*a).translate([o,s])},n)}function cc(e,t,n){return sc(e,[[0,0],t],n)}function lc(e,t,n){return oc(e,function(n){var r=+t,i=r/(n[1][0]-n[0][0]),a=(r-i*(n[1][0]+n[0][0]))/2,o=-i*n[0][1];e.scale(150*i).translate([a,o])},n)}function uc(e,t,n){return oc(e,function(n){var r=+t,i=r/(n[1][1]-n[0][1]),a=-i*n[0][0],o=(r-i*(n[1][1]+n[0][1]))/2;e.scale(150*i).translate([a,o])},n)}var dc=16,fc=Za(30*qa);function pc(e,t){return+t?hc(e,t):mc(e)}function mc(e){return ic({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function hc(e,t){function n(r,i,a,o,s,c,l,u,d,f,p,m,h,g){var _=l-r,v=u-i,y=_*_+v*v;if(y>4*t&&h--){var b=o+f,x=s+p,S=c+m,C=ro(b*b+x*x+S*S),w=oo(S/=C),T=Ja(Ja(S)-1)<1e-6||Ja(a-d)<1e-6?(a+d)/2:Xa(x,b),E=e(T,w),D=E[0],O=E[1],k=D-r,A=O-i,j=v*k-_*A;(j*j/y>t||Ja((_*k+v*A)/y-.5)>.3||o*f+s*p+c*m<fc)&&(n(r,i,a,o,s,c,D,O,T,b/=C,x/=C,S,h,g),g.point(D,O),n(D,O,T,b,x,S,l,u,d,f,p,m,h,g))}}return function(t){var r,i,a,o,s,c,l,u,d,f,p,m,h={point:g,lineStart:_,lineEnd:y,polygonStart:function(){t.polygonStart(),h.lineStart=b},polygonEnd:function(){t.polygonEnd(),h.lineStart=_}};function g(n,r){n=e(n,r),t.point(n[0],n[1])}function _(){u=NaN,h.point=v,t.lineStart()}function v(r,i){var a=go([r,i]),o=e(r,i);n(u,d,l,f,p,m,u=o[0],d=o[1],l=r,f=a[0],p=a[1],m=a[2],dc,t),t.point(u,d)}function y(){h.point=g,t.lineEnd()}function b(){_(),h.point=x,h.lineEnd=S}function x(e,t){v(r=e,t),i=u,a=d,o=f,s=p,c=m,h.point=v}function S(){n(u,d,l,f,p,m,i,a,r,o,s,c,dc,t),h.lineEnd=y,y()}return h}}var gc=ic({point:function(e,t){this.stream.point(e*qa,t*qa)}});function _c(e){return ic({point:function(t,n){var r=e(t,n);return this.stream.point(r[0],r[1])}})}function vc(e,t,n,r,i){function a(a,o){return a*=r,o*=i,[t+e*a,n-e*o]}return a.invert=function(a,o){return[(a-t)/e*r,(n-o)/e*i]},a}function yc(e,t,n,r,i,a){if(!a)return vc(e,t,n,r,i);var o=Za(a),s=to(a),c=o*e,l=s*e,u=o/e,d=s/e,f=(s*n-o*t)/e,p=(s*t+o*n)/e;function m(e,a){return e*=r,a*=i,[c*e-l*a+t,n-l*e-c*a]}return m.invert=function(e,t){return[r*(u*e-d*t+f),i*(p-d*e-u*t)]},m}function bc(e){return xc(function(){return e})()}function xc(e){var t,n=150,r=480,i=250,a=0,o=0,s=0,c=0,l=0,u,d=0,f=1,p=1,m=null,h=Vo,g=null,_,v,y,b=$o,x=.5,S,C,w,T,E;function D(e){return w(e[0]*qa,e[1]*qa)}function O(e){return e=w.invert(e[0],e[1]),e&&[e[0]*Ka,e[1]*Ka]}D.stream=function(e){return T&&E===e?T:T=gc(_c(u)(h(S(b(E=e)))))},D.preclip=function(e){return arguments.length?(h=e,m=void 0,A()):h},D.postclip=function(e){return arguments.length?(b=e,g=_=v=y=null,A()):b},D.clipAngle=function(e){return arguments.length?(h=+e?Go(m=e*qa):(m=null,Vo),A()):m*Ka},D.clipExtent=function(e){return arguments.length?(b=e==null?(g=_=v=y=null,$o):Yo(g=+e[0][0],_=+e[0][1],v=+e[1][0],y=+e[1][1]),A()):g==null?null:[[g,_],[v,y]]},D.scale=function(e){return arguments.length?(n=+e,k()):n},D.translate=function(e){return arguments.length?(r=+e[0],i=+e[1],k()):[r,i]},D.center=function(e){return arguments.length?(a=e[0]%360*qa,o=e[1]%360*qa,k()):[a*Ka,o*Ka]},D.rotate=function(e){return arguments.length?(s=e[0]%360*qa,c=e[1]%360*qa,l=e.length>2?e[2]%360*qa:0,k()):[s*Ka,c*Ka,l*Ka]},D.angle=function(e){return arguments.length?(d=e%360*qa,k()):d*Ka},D.reflectX=function(e){return arguments.length?(f=e?-1:1,k()):f<0},D.reflectY=function(e){return arguments.length?(p=e?-1:1,k()):p<0},D.precision=function(e){return arguments.length?(S=pc(C,x=e*e),A()):ro(x)},D.fitExtent=function(e,t){return sc(D,e,t)},D.fitSize=function(e,t){return cc(D,e,t)},D.fitWidth=function(e,t){return lc(D,e,t)},D.fitHeight=function(e,t){return uc(D,e,t)};function k(){var e=yc(n,0,0,f,p,d).apply(null,t(a,o)),m=yc(n,r-e[0],i-e[1],f,p,d);return u=wo(s,c,l),C=So(t,m),w=So(u,C),S=pc(C,x),A()}function A(){return T=E=null,D}return function(){return t=e.apply(this,arguments),D.invert=t.invert&&O,k()}}function Sc(e){return function(t,n){var r=ro(t*t+n*n),i=e(r),a=to(i),o=Za(i);return[Xa(t*a,r*o),oo(r&&n*a/r)]}}function Cc(e,t){return[e,eo(io((Ua+t)/2))]}Cc.invert=function(e,t){return[e,2*Ya($a(t))-Ua]};function wc(){return Tc(Cc).scale(961/Ga)}function Tc(e){var t=bc(e),n=t.center,r=t.scale,i=t.translate,a=t.clipExtent,o=null,s,c,l;t.scale=function(e){return arguments.length?(r(e),u()):r()},t.translate=function(e){return arguments.length?(i(e),u()):i()},t.center=function(e){return arguments.length?(n(e),u()):n()},t.clipExtent=function(e){return arguments.length?(e==null?o=s=c=l=null:(o=+e[0][0],s=+e[0][1],c=+e[1][0],l=+e[1][1]),u()):o==null?null:[[o,s],[c,l]]};function u(){var n=$*r(),i=t(Oo(t.rotate()).invert([0,0]));return a(o==null?[[i[0]-n,i[1]-n],[i[0]+n,i[1]+n]]:e===Cc?[[Math.max(i[0]-n,o),s],[Math.min(i[0]+n,c),l]]:[[o,Math.max(i[1]-n,s)],[c,Math.min(i[1]+n,l)]])}return u()}function Ec(e,t){return[Za(t)*to(e),to(t)]}Ec.invert=Sc(oo);function Dc(){return bc(Ec).scale(249.5).clipAngle(90+Ha)}var Oc=100;function kc(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=e.scale??1,a=i*Oc;r.style.width=`${a}px`,r.style.height=`${a}px`,r.style.flexGrow=`0`,r.style.flexShrink=`0`;let o={id:e.id,map:t,container:r,moveEndPosition:t.getCenter(),geoJson:void 0,isGlobe:e.isGlobe,boundingBox:e.boundingBox,scale:i,backgroundColor:e.backgroundColor??`#000000`,globeBackgroundColor:e.globeBackgroundColor??`#000000`,borderColor:e.borderColor??`#000000`,primaryFillColor:e.primaryFillColor??`#000000`,primaryStrokeColor:e.primaryStrokeColor??`#000000`,secondaryFillColor:e.secondaryFillColor??`#000000`,secondaryStrokeColor:e.secondaryStrokeColor??`#000000`,graticuleColor:e.graticuleColor??`#000000`,frameColor:e.frameColor??`#000000`,frameOutlineColor:e.frameOutlineColor??`#000000`,dotColor:e.dotColor??`#000000`,dotOutlineColor:e.dotOutlineColor??`#000000`,globeFallbackActive:!1,globeGeoJsonRequested:!1,globeGeoJson:void 0};return fetch(`${n}/data/insetmaps/${e.fileName}`).then(e=>e.json()).then(e=>{o.geoJson=Bi(e,Object.keys(e.objects)[0]),Ac(o)}),t.on(`moveend`,()=>{o.moveEndPosition=t.getCenter(),(o.isGlobe||o.globeFallbackActive)&&Ac(o)}),t.on(`move`,()=>{if(!o.isGlobe){let[e,r,i,a]=o.boundingBox,s=Nc(t),c=Va(Tn([s,Cn([[[e,r],[e,a],[i,a],[i,r],[e,r]]])])),l=ji(s),u=(c?ji(c):0)<l*.75;o.globeFallbackActive!==u&&(o.globeFallbackActive=u,o.moveEndPosition=t.getCenter(),Ac(o)),o.globeFallbackActive&&!o.globeGeoJsonRequested&&(o.globeGeoJsonRequested=!0,fetch(`${n}/data/insetmaps/world-110m.json`).then(e=>e.json()).then(e=>{o.globeGeoJson=Bi(e,Object.keys(e.objects)[0]),o.moveEndPosition=t.getCenter(),Ac(o)}))}Mc(o)}),r}function Ac(e){let{id:t,container:n,scale:r,backgroundColor:i,globeBackgroundColor:a,secondaryFillColor:o,secondaryStrokeColor:s,primaryFillColor:c,primaryStrokeColor:l,graticuleColor:u,borderColor:d,frameColor:f,frameOutlineColor:p,dotColor:m,dotOutlineColor:h}=e,g=e.globeFallbackActive&&e.globeGeoJson!==void 0,_=g?e.globeGeoJson:e.geoJson,v=g||e.isGlobe;if(_===void 0)return;let y=Oc*r,b=y/2,x=.1*r,S=[v?`<circle cx="${b}" cy="${b}" r="${b}" fill="${a}"></circle>`:`<rect x="0" y="0" width="${y}" height="${y}" fill="${i}"></rect>`],{path:C}=jc(e),w=C({..._,features:_.features.filter(e=>e.properties?.class!==`P1`)});w&&S.push(`
|
|
920
920
|
<path
|
|
921
921
|
d="${w}"
|
|
922
922
|
fill="${o}"
|
|
@@ -1103,7 +1103,7 @@ vec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matr
|
|
|
1103
1103
|
${h?.humanized??``}
|
|
1104
1104
|
</text>
|
|
1105
1105
|
</svg>
|
|
1106
|
-
`}function Vc(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=`ArialMT`,a=[e.titleFont??i,e.subtitleFont??i];return mr(Array.from(new Set(a)),t,n).then(()=>r.innerHTML=Hc(e,i)),r}function Hc(e,t){let{title:n,titleColor:r=`#000000`,titleFont:i=t,titleFontSize:a=20,titleJustify:o=`center`,subtitle:s,subtitleColor:c=`#000000`,subtitleFont:l=t,subtitleFontSize:u=12,subtitleJustify:d=`center`,background:f=`#ffffff`,showBackground:p=!1}=e,m=0,h=0,g=0,_=0,v=0,y=n.trim().length>0?Ar([n],i,a):null,b=s.trim().length>0?Ar([s],l,u):null;if(m=Math.max(y?.width??0,b?.width??0),y){let{ascent:e,descent:t}=y;h=e+t,_=8+e}if(b){let{ascent:e,descent:t}=b;g=e+t,v=y?_+y.descent+e+6:8+e}let x=m+16,S=h+g+16,C=o===`center`?x/2:o===`right`?x-8:8,w=d===`center`?x/2:d===`right`?x-8:8,T=``;if(T+=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${S}" viewBox="0 0 ${x} ${S}">`,T+=`<rect x="0" y="0" width="${x}" height="${S}" fill="${f}" rx="6" style="visibility:${p?`visible`:`hidden`}" />`,y||b){let e=o===`center`?`middle`:o===`right`?`end`:`start`,t=d===`center`?`middle`:d===`right`?`end`:`start`;T+=`<text x="${C}" y="${_}" fill="${r}" font-family="${i}" font-size="${a}" text-anchor="${e}">`,y&&(T+=`${pr(n)}`),b&&(T+=`<tspan x="${w}" y="${v}" fill="${c}" font-family="${l}" font-size="${u}" text-anchor="${t}">`,T+=`${pr(s)}`,T+=`</tspan>`),T+=`</text>`}return T+=`</svg>`,T}var Uc={"sky-color":`#6babff`,"sky-horizon-blend":1,"horizon-color":[`interpolate-hcl`,[`linear`],[`zoom`],0,`#edf7fc`,9,`#edf7fc`,10,`#dcf0fa`],"horizon-fog-blend":.5,"fog-color":`#edf7fc`,"fog-ground-blend":.5,"atmosphere-blend":1},Wc={top_left:{x:`left`,y:`top`},top_center:{x:`center`,y:`top`},top_right:{x:`right`,y:`top`},right_center:{x:`right`,y:`center`},bottom_right:{x:`right`,y:`bottom`},bottom_center:{x:`center`,y:`bottom`},bottom_left:{x:`left`,y:`bottom`},left_center:{x:`left`,y:`center`}},Gc=[`top_left`,`top_right`,`bottom_left`,`bottom_right`,`top_center`,`left_center`,`right_center`,`bottom_center`],Kc=new Map;function qc(e,t,n,r,i,a,o){let{adornments:s=[]}=e;Jc(n,t),s.forEach(t=>{t.type===`custom`?Xc(S(t),t.position,t.stacking):t.type===`scalebar`?Xc(zc(t,n),t.position,t.stacking):t.type===`northArrow`?Xc(Qr(t,n),t.position,t.stacking):t.type===`webControls`&&t.buttons?Xc(Ai(t,n,r),t.position,t.stacking):t.type===`insetMap`?Xc(kc(t,n,a),t.position,t.stacking):t.type===`heading`?Xc(Vc(t,i,o),t.position,t.stacking):t.type===`manualLegend`?Xc(Zr(t,i,o),t.position,t.stacking):t.type===`connectedLegend`&&Xc(Wr(t,e,n,i,o),t.position,t.stacking)}),Zc(n),n.on(`moveend`,()=>Zc(n))}function Jc(e,t){let n=e.getContainer();for(let e of Gc){let r=document.createElement(`div`);r.classList.add(`adornment-container`,`${e}`),t?.[e]&&(r.style.cssText=Yc(e,t));let i=document.createElement(`div`),a=document.createElement(`div`);r.classList.add(`adornment-container`,e),i.classList.add(`inner`),a.classList.add(`inner`,`vertical`),r.append(i,a),n.appendChild(r),Kc.set(e,{horizontal:i,vertical:a})}}function Yc(e,t){let n=Wc[e],{x:r,y:i,unit:a}=t[e],o=``,s=[];return n.x===`center`?s.push(`translateX(${r}${a})`):o+=`${n.x}: ${r}${a};`,n.y===`center`?s.push(`translateY(${i}${a})`):e===`bottom_right`?o+=`${n.y}: max(${i}${a}, 25px);`:o+=`${n.y}: ${i}${a};`,s.length&&(o+=`transform: ${s.join(` `)};`),o}function Xc(e,t,n){n||=[`left_center`,`right_center`].includes(t)?`vertical`:`horizontal`;let r=Kc.get(t),i=t===`left_center`||t===`right_center`?`vertical`:`horizontal`;r?.[i].hasChildNodes()||(n=i),(r?.[n])?.appendChild(e)}function Zc(e){let t=Array.from(document.querySelectorAll(`.adornment, .maplibregl-ctrl-attrib`)),n=[];t.forEach(e=>{let t=e.getBoundingClientRect();t&&n.push([t.x,t.y,t.x+t.width,t.y+t.height])}),e.setLabelFreeAreas(n)}function Qc(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>$c(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},paint:{"fill-color":[`get`,`fill-color`]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`]},metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`]}},n)}function $c(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:d(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?jr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?jr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i},geometry:{type:`Polygon`,coordinates:qn(t)}}}function el(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>tl(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],paint:{"fill-color":[`get`,`fill-color`]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`]},metadata:{"mc-model-type":`circle`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-radius-line`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`get`,`radius-line-enabled`]],paint:{"line-color":[`get`,`radius-line-color`],"line-width":[`get`,`radius-line-width`]}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`]}},n)}function tl(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:d(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?jr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?jr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":e.radiusLineColor||t.radiusLineColor?jr(t.dataBindings??{},t.radiusLineColor,e.radiusLineColor):`#000000`,"radius-line-width":t.radiusLineWidth??0},geometry:{type:`GeometryCollection`,geometries:[{type:`Polygon`,coordinates:[Hn(t.center,t.radius)]},{type:`LineString`,coordinates:Un(t.center,t.radius,t.radiusLineBearing??0)}]}}}var nl=`Roboto-Regular`;function rl(e,t,n,r,i){let a=[],o=new Set,s=new Set,c=[`match`,[`get`,`text-font`]],l=!!t.clustering;for(let e of t.models)(e.visible??!0)&&a.push(al(t,e,r,i)),o.add(e.textFont),s.add(e.textLineHeight??1.2);if(Array.from(o).length>0){for(let e of Array.from(o))c.push(e,[`literal`,[e,nl]]);c.push([`literal`,[nl]])}e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:a},cluster:l,clusterRadius:t.clusterRadius??50,clusterMaxZoom:t.clusterMaxZoom??14}),s.forEach(r=>{e.addLayer({id:`${t.id}-${r}`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`marker`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!t.collisionDetection,"icon-ignore-placement":!t.collisionDetection,"text-allow-overlap":!t.collisionDetection,"text-ignore-placement":!t.collisionDetection,"icon-image":[`get`,`mc-image-key`],"icon-anchor":[`get`,`icon-anchor`],"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`],"text-field":`{text}`,"text-font":c,"text-max-width":[`get`,`text-max-width`],"text-offset":[`get`,`text-offset`],"text-rotate":[`get`,`text-rotate`],"text-size":[`get`,`text-size`],"text-anchor":[`get`,`text-anchor`],"text-letter-spacing":[`get`,`text-letter-spacing`],"text-line-height":r,"text-justify":[`get`,`text-justify`]},paint:{"text-color":[`get`,`text-color`],"text-halo-color":[`get`,`text-halo-color`],"text-halo-width":[`get`,`text-halo-width`]},filter:[`all`,[`==`,[`get`,`text-line-height`],r],[`!`,[`has`,`point_count`]]]},n)}),l&&(e.addLayer({id:`${t.id}-circle-cluster`,type:`circle`,source:t.id,filter:[`has`,`point_count`],paint:{"circle-color":{property:`point_count`,type:`interval`,stops:t.clusterCircleColor??[]},"circle-radius":{property:`point_count`,type:`interval`,stops:t.clusterCircleRadius??[]}}}),e.addLayer({id:`${t.id}-text-cluster`,type:`symbol`,source:t.id,filter:[`has`,`point_count`],paint:{"text-color":{property:`point_count`,type:`interval`,stops:t.clusterTextColor??[]}},layout:{"text-font":[`literal`,[nl]],"text-field":`{point_count_abbreviated}`,"text-size":{property:`point_count`,type:`interval`,stops:t.clusterTextSize??[]}}}),il(e,t))}function il(e,t){e.on(`click`,`${t.id}-circle-cluster`,async t=>{let n=e.queryRenderedFeatures(t.point).find(e=>e.properties.cluster);if(!n)return;let r=e.getSource(n.source);if(!r)return;let i=await r.getClusterExpansionZoom(Number(n.id));e.easeTo({center:n.geometry.coordinates,zoom:i})})}function al(e,t,n,r){let i=t.svg===void 0?void 0:r.getMapLibreImageKey(Nr(t.dataBindings??{},n[t.svg],e.svg?n[e.svg]:void 0),window.devicePixelRatio*(t.iconScale??1));return{type:`Feature`,id:d(t.id),properties:{id:t.id,"mc-image-key":i,"icon-anchor":t.iconAnchor??`center`,"icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":t.iconScale??1,text:e.text||t.text?Mr(t.dataBindings??{},t.text,e.text):void 0,"text-anchor":t.textAnchor??`center`,"text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":t.textSize??16,"text-color":e.textColor||t.textColor?jr(t.dataBindings??{},t.textColor,e.textColor):`#000000`,"text-halo-color":e.textHaloColor||t.textHaloColor?jr(t.dataBindings??{},t.textHaloColor,e.textHaloColor):`#000000`,"text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??`center`},geometry:{type:`Point`,coordinates:[t.lngLat.lng,t.lngLat.lat]}}}async function ol(e,t,n,r,i){let a=e.map(e=>`${n}styles/${e}.json?access_token=${r}`).map(e=>fetch(e).then(e=>e.json())),o=await Promise.all(a);await Promise.all(o.map(e=>sl(e,t,r,i)))}async function sl(e,t,n,r){for(let n in e.sources)t.getSource(n)===void 0&&t.addSource(n,e.sources[n]);e.sprite!==void 0&&await ll(t,e.sprite,n);for(let n of e.layers){t.getLayer(n.id)!==void 0&&t.removeLayer(n.id);let e=n.metadata?.[`mc-add-before`]??`mc-before-none`;t.addLayer(cl(n,r),e)}}function cl(e,t){let n=(t??{})[e.id]??{},r={...e,layout:{...e.layout,...n.layout},paint:{...e.paint,...n.paint},metadata:{...e.metadata,...n.metadata}};return n.minzoom!==void 0&&(r.minzoom=n.minzoom),n.maxzoom!==void 0&&(r.maxzoom=n.maxzoom),`filter`in n&&r.type!==`background`&&(r.filter=n.filter),r}async function ll(e,t,n){try{let r=`${t}.json?access_token=${n}`,i=`${t}.png?access_token=${n}`,[a,o]=await Promise.all([fetch(r),fetch(i)]);if(!a.ok||!o.ok)throw Error(`Failed to load sprite from ${t}`);let s=await a.json(),c=await o.blob(),l=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=URL.createObjectURL(c)}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(`Failed to get canvas context`);for(let[t,n]of Object.entries(s)){if(e.hasImage(t))continue;let{x:r,y:i,width:a,height:o,pixelRatio:s}=n;u.width=a*s,u.height=o*s,d.clearRect(0,0,u.width,u.height),d.drawImage(l,r,i,a,o,0,0,u.width,u.height);let c=d.getImageData(0,0,u.width,u.height);e.addImage(t,c,{pixelRatio:s})}}catch(e){console.error(e)}}var ul=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m0 4.647 4.282 4.4a.814.814 0 0 0 1.166-1.134L2.27 4.647l3.178-3.266A.814.814 0 1 0 4.282.246z"/></svg>
|
|
1106
|
+
`}function Vc(e,t,n){let r=document.createElement(`div`);r.className=`adornment`;let i=`ArialMT`,a=[e.titleFont??i,e.subtitleFont??i];return mr(Array.from(new Set(a)),t,n).then(()=>r.innerHTML=Hc(e,i)),r}function Hc(e,t){let{title:n,titleColor:r=`#000000`,titleFont:i=t,titleFontSize:a=20,titleJustify:o=`center`,subtitle:s,subtitleColor:c=`#000000`,subtitleFont:l=t,subtitleFontSize:u=12,subtitleJustify:d=`center`,background:f=`#ffffff`,showBackground:p=!1}=e,m=0,h=0,g=0,_=0,v=0,y=n.trim().length>0?Ar([n],i,a):null,b=s.trim().length>0?Ar([s],l,u):null;if(m=Math.max(y?.width??0,b?.width??0),y){let{ascent:e,descent:t}=y;h=e+t,_=8+e}if(b){let{ascent:e,descent:t}=b;g=e+t,v=y?_+y.descent+e+6:8+e}let x=m+16,S=h+g+16,C=o===`center`?x/2:o===`right`?x-8:8,w=d===`center`?x/2:d===`right`?x-8:8,T=``;if(T+=`<svg xmlns="http://www.w3.org/2000/svg" width="${x}" height="${S}" viewBox="0 0 ${x} ${S}">`,T+=`<rect x="0" y="0" width="${x}" height="${S}" fill="${f}" rx="6" style="visibility:${p?`visible`:`hidden`}" />`,y||b){let e=o===`center`?`middle`:o===`right`?`end`:`start`,t=d===`center`?`middle`:d===`right`?`end`:`start`;T+=`<text x="${C}" y="${_}" fill="${r}" font-family="${i}" font-size="${a}" text-anchor="${e}">`,y&&(T+=`${pr(n)}`),b&&(T+=`<tspan x="${w}" y="${v}" fill="${c}" font-family="${l}" font-size="${u}" text-anchor="${t}">`,T+=`${pr(s)}`,T+=`</tspan>`),T+=`</text>`}return T+=`</svg>`,T}var Uc={"sky-color":`#6babff`,"sky-horizon-blend":1,"horizon-color":[`interpolate-hcl`,[`linear`],[`zoom`],0,`#edf7fc`,9,`#edf7fc`,10,`#dcf0fa`],"horizon-fog-blend":.5,"fog-color":`#edf7fc`,"fog-ground-blend":.5,"atmosphere-blend":1},Wc={top_left:{x:`left`,y:`top`},top_center:{x:`center`,y:`top`},top_right:{x:`right`,y:`top`},right_center:{x:`right`,y:`center`},bottom_right:{x:`right`,y:`bottom`},bottom_center:{x:`center`,y:`bottom`},bottom_left:{x:`left`,y:`bottom`},left_center:{x:`left`,y:`center`}},Gc=[`top_left`,`top_right`,`bottom_left`,`bottom_right`,`top_center`,`left_center`,`right_center`,`bottom_center`],Kc=new Map;function qc(e,t,n,r,i,a,o){let{adornments:s=[]}=e;Jc(n,t),s.forEach(t=>{t.type===`custom`?Xc(S(t),t.position,t.stacking):t.type===`scalebar`?Xc(zc(t,n),t.position,t.stacking):t.type===`northArrow`?Xc(Qr(t,n),t.position,t.stacking):t.type===`webControls`&&t.buttons?Xc(Ai(t,n,r),t.position,t.stacking):t.type===`insetMap`?Xc(kc(t,n,a),t.position,t.stacking):t.type===`heading`?Xc(Vc(t,i,o),t.position,t.stacking):t.type===`manualLegend`?Xc(Zr(t,i,o),t.position,t.stacking):t.type===`connectedLegend`&&Xc(Wr(t,e,n,i,o),t.position,t.stacking)}),Zc(n),n.on(`moveend`,()=>Zc(n))}function Jc(e,t){let n=e.getContainer();for(let e of Gc){let r=document.createElement(`div`);r.classList.add(`adornment-container`,`${e}`),t?.[e]&&(r.style.cssText=Yc(e,t));let i=document.createElement(`div`),a=document.createElement(`div`);r.classList.add(`adornment-container`,e),i.classList.add(`inner`),a.classList.add(`inner`,`vertical`),r.append(i,a),n.appendChild(r),Kc.set(e,{horizontal:i,vertical:a})}}function Yc(e,t){let n=Wc[e],{x:r,y:i,unit:a}=t[e],o=``,s=[];return n.x===`center`?s.push(`translateX(${r}${a})`):o+=`${n.x}: ${r}${a};`,n.y===`center`?s.push(`translateY(${i}${a})`):e===`bottom_right`?o+=`${n.y}: max(${i}${a}, 25px);`:o+=`${n.y}: ${i}${a};`,s.length&&(o+=`transform: ${s.join(` `)};`),o}function Xc(e,t,n){n||=[`left_center`,`right_center`].includes(t)?`vertical`:`horizontal`;let r=Kc.get(t),i=t===`left_center`||t===`right_center`?`vertical`:`horizontal`;r?.[i].hasChildNodes()||(n=i),(r?.[n])?.appendChild(e)}function Zc(e){let t=Array.from(document.querySelectorAll(`.adornment, .maplibregl-ctrl-attrib`)),n=[];t.forEach(e=>{let t=e.getBoundingClientRect();t&&n.push([t.x,t.y,t.x+t.width,t.y+t.height])}),e.setLabelFreeAreas(n)}function Qc(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>$c(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},paint:{"fill-color":[`get`,`fill-color`]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`]},metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`polygon`,"mc-group-id":t.id},layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`]}},n)}function $c(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:d(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?jr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?jr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i},geometry:{type:`Polygon`,coordinates:qn(t)}}}function el(e,t,n,r,i){e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:t.models.filter(e=>e.visible??!0).map(e=>tl(t,e,r,i))}}),e.addLayer({id:t.id,type:`fill`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],paint:{"fill-color":[`get`,`fill-color`]}},n),e.addLayer({id:`${t.id}-pattern`,type:`fill`,source:t.id,filter:[`has`,`fill-pattern`],paint:{"fill-pattern":[`get`,`fill-pattern`]},metadata:{"mc-model-type":`circle`,"mc-group-id":t.id}},n),e.addLayer({id:`${t.id}-radius-line`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`all`,[`==`,[`geometry-type`],`LineString`],[`get`,`radius-line-enabled`]],paint:{"line-color":[`get`,`radius-line-color`],"line-width":[`get`,`radius-line-width`]}},n),e.addLayer({id:`${t.id}-outline`,type:`line`,source:t.id,metadata:{"mc-model-type":`circle`,"mc-group-id":t.id},filter:[`==`,[`geometry-type`],`Polygon`],layout:{"line-cap":`round`,"line-join":`round`},paint:{"line-width":[`get`,`outline-width`],"line-color":[`get`,`outline-color`]}},n)}function tl(e,t,n,r){let i=t.fillPattern===void 0?void 0:r.getMapLibreImageKey(n[t.fillPattern],2*window.devicePixelRatio);return{type:`Feature`,id:d(t.id),properties:{id:t.id,"fill-color":e.fillColor||t.fillColor?jr(t.dataBindings??{},t.fillColor,e.fillColor):`#000000`,"outline-color":e.outlineColor||t.outlineColor?jr(t.dataBindings??{},t.outlineColor,e.outlineColor):`#000000`,"outline-width":t.outlineWidth??0,"fill-pattern":i,"radius-line-enabled":t.radiusLineEnabled??!1,"radius-line-color":e.radiusLineColor||t.radiusLineColor?jr(t.dataBindings??{},t.radiusLineColor,e.radiusLineColor):`#000000`,"radius-line-width":t.radiusLineWidth??0},geometry:{type:`GeometryCollection`,geometries:[{type:`Polygon`,coordinates:[Hn(t.center,t.radius)]},{type:`LineString`,coordinates:Un(t.center,t.radius,t.radiusLineBearing??0)}]}}}var nl=`Roboto-Regular`;function rl(e,t,n,r,i){let a=[],o=new Set,s=new Set,c=[`match`,[`get`,`text-font`]],l=!!t.clustering;for(let e of t.models)(e.visible??!0)&&a.push(al(t,e,r,i)),o.add(e.textFont),s.add(e.textLineHeight??1.2);if(Array.from(o).length>0){for(let e of Array.from(o))c.push(e,[`literal`,[e,nl]]);c.push([`literal`,[nl]])}e.addSource(t.id,{type:`geojson`,data:{type:`FeatureCollection`,features:a},cluster:l,clusterRadius:t.clusterRadius??50,clusterMaxZoom:t.clusterMaxZoom??14}),s.forEach(r=>{e.addLayer({id:`${t.id}-${r}`,type:`symbol`,source:t.id,metadata:{"mc-model-type":`marker`,"mc-group-id":t.id},layout:{"icon-allow-overlap":!t.collisionDetection,"icon-ignore-placement":!t.collisionDetection,"text-allow-overlap":!t.collisionDetection,"text-ignore-placement":!t.collisionDetection,"icon-image":[`get`,`mc-image-key`],"icon-anchor":[`get`,`icon-anchor`],"icon-size":[`get`,`icon-size`],"icon-rotate":[`get`,`icon-rotate`],"icon-offset":[`get`,`icon-offset`],"text-field":`{text}`,"text-font":c,"text-max-width":[`get`,`text-max-width`],"text-offset":[`get`,`text-offset`],"text-rotate":[`get`,`text-rotate`],"text-size":[`get`,`text-size`],"text-anchor":[`get`,`text-anchor`],"text-letter-spacing":[`get`,`text-letter-spacing`],"text-line-height":r,"text-justify":[`get`,`text-justify`]},paint:{"text-color":[`get`,`text-color`],"text-halo-color":[`get`,`text-halo-color`],"text-halo-width":[`get`,`text-halo-width`]},filter:[`all`,[`==`,[`get`,`text-line-height`],r],[`!`,[`has`,`point_count`]]]},n)}),l&&(e.addLayer({id:`${t.id}-circle-cluster`,type:`circle`,source:t.id,filter:[`has`,`point_count`],paint:{"circle-color":{property:`point_count`,type:`interval`,stops:t.clusterCircleColor??[]},"circle-radius":{property:`point_count`,type:`interval`,stops:t.clusterCircleRadius??[]}}}),e.addLayer({id:`${t.id}-text-cluster`,type:`symbol`,source:t.id,filter:[`has`,`point_count`],paint:{"text-color":{property:`point_count`,type:`interval`,stops:t.clusterTextColor??[]}},layout:{"text-font":[`literal`,[nl]],"text-field":`{point_count_abbreviated}`,"text-size":{property:`point_count`,type:`interval`,stops:t.clusterTextSize??[]}}}),il(e,t))}function il(e,t){e.on(`click`,`${t.id}-circle-cluster`,async t=>{let n=e.queryRenderedFeatures(t.point).find(e=>e.properties.cluster);if(!n)return;let r=e.getSource(n.source);if(!r)return;let i=await r.getClusterExpansionZoom(Number(n.id));e.easeTo({center:n.geometry.coordinates,zoom:i})})}function al(e,t,n,r){let i=t.svg===void 0?void 0:r.getMapLibreImageKey(Nr(t.dataBindings??{},n[t.svg],e.svg?n[e.svg]:void 0),window.devicePixelRatio*(t.iconScale??1));return{type:`Feature`,id:d(t.id),properties:{id:t.id,"mc-image-key":i,"icon-anchor":t.iconAnchor??`center`,"icon-rotate":t.iconRotation??0,"icon-offset":t.iconOffset??[0,0],"icon-size":t.iconScale??1,text:e.text||t.text?Mr(t.dataBindings??{},t.text,e.text):void 0,"text-anchor":t.textAnchor??`center`,"text-font":t.textFont,"text-offset":[(t.textOffset?.[0]??0)/(t.textSize??16),(t.textOffset?.[1]??0)/(t.textSize??16)],"text-rotate":t.textRotation??0,"text-max-width":t.textMaxWidth??10,"text-size":t.textSize??16,"text-color":e.textColor||t.textColor?jr(t.dataBindings??{},t.textColor,e.textColor):`#000000`,"text-halo-color":e.textHaloColor||t.textHaloColor?jr(t.dataBindings??{},t.textHaloColor,e.textHaloColor):`#000000`,"text-halo-width":t.textHaloWidth??0,"text-line-height":t.textLineHeight??1.2,"text-letter-spacing":t.textLetterSpacing??0,"text-justify":t.textJustify??`center`},geometry:{type:`Point`,coordinates:[t.lngLat.lng,t.lngLat.lat]}}}async function ol(e,t,n,r,i){let a=e.map(e=>`${n}/styles/${e}.json?access_token=${r}`).map(e=>fetch(e).then(e=>e.json())),o=await Promise.all(a);await Promise.all(o.map(e=>sl(e,t,r,i)))}async function sl(e,t,n,r){for(let n in e.sources)t.getSource(n)===void 0&&t.addSource(n,e.sources[n]);e.sprite!==void 0&&await ll(t,e.sprite,n);for(let n of e.layers){t.getLayer(n.id)!==void 0&&t.removeLayer(n.id);let e=n.metadata?.[`mc-add-before`]??`mc-before-none`;t.addLayer(cl(n,r),e)}}function cl(e,t){let n=(t??{})[e.id]??{},r={...e,layout:{...e.layout,...n.layout},paint:{...e.paint,...n.paint},metadata:{...e.metadata,...n.metadata}};return n.minzoom!==void 0&&(r.minzoom=n.minzoom),n.maxzoom!==void 0&&(r.maxzoom=n.maxzoom),`filter`in n&&r.type!==`background`&&(r.filter=n.filter),r}async function ll(e,t,n){try{let r=`${t}.json?access_token=${n}`,i=`${t}.png?access_token=${n}`,[a,o]=await Promise.all([fetch(r),fetch(i)]);if(!a.ok||!o.ok)throw Error(`Failed to load sprite from ${t}`);let s=await a.json(),c=await o.blob(),l=await new Promise((e,t)=>{let n=new Image;n.onload=()=>e(n),n.onerror=e=>t(e),n.src=URL.createObjectURL(c)}),u=document.createElement(`canvas`),d=u.getContext(`2d`,{willReadFrequently:!0});if(!d)throw Error(`Failed to get canvas context`);for(let[t,n]of Object.entries(s)){if(e.hasImage(t))continue;let{x:r,y:i,width:a,height:o,pixelRatio:s}=n;u.width=a*s,u.height=o*s,d.clearRect(0,0,u.width,u.height),d.drawImage(l,r,i,a,o,0,0,u.width,u.height);let c=d.getImageData(0,0,u.width,u.height);e.addImage(t,c,{pixelRatio:s})}}catch(e){console.error(e)}}var ul=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m0 4.647 4.282 4.4a.814.814 0 0 0 1.166-1.134L2.27 4.647l3.178-3.266A.814.814 0 1 0 4.282.246z"/></svg>
|
|
1107
1107
|
`,dl=`<svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="currentColor"><path d="M.21.71a.714.714 0 0 1 1.011 0l3.78 3.78L8.778.71a.715.715 0 0 1 1.013 1.01L6.01 5.501l3.78 3.778a.715.715 0 0 1-1.01 1.012L5 6.51l-3.779 3.78A.716.716 0 0 1 .21 9.28L3.99 5.5.21 1.721A.714.714 0 0 1 .21.71"/></svg>
|
|
1108
1108
|
`,fl=`<svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10" fill="currentColor"><path d="m5.678 4.647-4.282 4.4A.814.814 0 1 1 .23 7.914l3.177-3.266L.23 1.381A.814.814 0 1 1 1.396.246z"/></svg>
|
|
1109
1109
|
`,pl=`<svg width="20" height="20" viewBox="0 0 40 40" stroke="currentColor" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 4.167 1.667 35.834h36.667z" stroke-width="2" stroke-linejoin="round"/><path d="M20 29.167v.834m0-14.167.007 8.333" stroke-width="2" stroke-linecap="round"/></svg>
|