mobility-toolbox-js 3.2.0-beta.0 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mbt.min.js CHANGED
@@ -730,7 +730,7 @@ ${V.shaderPreludeCode.vertexSource}`,define:V.shaderDefine},defaultProjectionDat
730
730
  `||R===E){n=Math.max(n,x),c.push(x),x=0,b+=S,S=0;continue}let z=t[R+1]||h.font,W=Pf(z,A);r.push(W),x+=W;let ne=pC(z);l.push(ne),S=Math.max(S,ne)}return{width:n,height:b,widths:r,heights:l,lineWidths:c}}function m1(h,t,r,l,c,n,x,b,S,R,E){h.save(),r!==1&&(h.globalAlpha===void 0?h.globalAlpha=A=>A.globalAlpha*=r:h.globalAlpha*=r),t&&h.transform.apply(h,t),l.contextInstructions?(h.translate(S,R),h.scale(E[0],E[1]),fC(l,h)):E[0]<0||E[1]<0?(h.translate(S,R),h.scale(E[0],E[1]),h.drawImage(l,c,n,x,b,0,0,x,b)):h.drawImage(l,c,n,x,b,S,R,x*E[0],b*E[1]),h.restore()}function fC(h,t){let r=h.contextInstructions;for(let l=0,c=r.length;l<c;l+=2)Array.isArray(r[l+1])?t[r[l]].apply(t,r[l+1]):t[r[l]]=r[l+1]}var ey=class extends Ef{constructor(t,r,l,c,n,x,b){super(),this.context_=t,this.pixelRatio_=r,this.extent_=l,this.transform_=c,this.transformRotation_=c?$v(Math.atan2(c[1],c[0]),10):0,this.viewRotation_=n,this.squaredTolerance_=x,this.userTransform_=b,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=mr()}drawImages_(t,r,l,c){if(!this.image_)return;let n=xn(t,r,l,c,this.transform_,this.pixelCoordinates_),x=this.context_,b=this.tmpLocalTransform_,S=x.globalAlpha;this.imageOpacity_!=1&&(x.globalAlpha=S*this.imageOpacity_);let R=this.imageRotation_;this.transformRotation_===0&&(R-=this.viewRotation_),this.imageRotateWithView_&&(R+=this.viewRotation_);for(let E=0,A=n.length;E<A;E+=2){let z=n[E]-this.imageAnchorX_,W=n[E+1]-this.imageAnchorY_;if(R!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let ne=z+this.imageAnchorX_,ge=W+this.imageAnchorY_;Ur(b,ne,ge,1,1,R,-ne,-ge),x.save(),x.transform.apply(x,b),x.translate(ne,ge),x.scale(this.imageScale_[0],this.imageScale_[1]),x.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),x.restore()}else x.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,z,W,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(x.globalAlpha=S)}drawText_(t,r,l,c){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let n=xn(t,r,l,c,this.transform_,this.pixelCoordinates_),x=this.context_,b=this.textRotation_;for(this.transformRotation_===0&&(b-=this.viewRotation_),this.textRotateWithView_&&(b+=this.viewRotation_);r<l;r+=c){let S=n[r]+this.textOffsetX_,R=n[r+1]+this.textOffsetY_;b!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(x.save(),x.translate(S-this.textOffsetX_,R-this.textOffsetY_),x.rotate(b),x.translate(this.textOffsetX_,this.textOffsetY_),x.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&x.strokeText(this.text_,0,0),this.textFillState_&&x.fillText(this.text_,0,0),x.restore()):(this.textStrokeState_&&x.strokeText(this.text_,S,R),this.textFillState_&&x.fillText(this.text_,S,R))}}moveToLineTo_(t,r,l,c,n){let x=this.context_,b=xn(t,r,l,c,this.transform_,this.pixelCoordinates_);x.moveTo(b[0],b[1]);let S=b.length;n&&(S-=2);for(let R=2;R<S;R+=2)x.lineTo(b[R],b[R+1]);return n&&x.closePath(),l}drawRings_(t,r,l,c){for(let n=0,x=l.length;n<x;++n)r=this.moveToLineTo_(t,r,l[n],c,!0);return r}drawCircle(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,t.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=wb(t,this.transform_,this.pixelCoordinates_),l=r[2]-r[0],c=r[3]-r[1],n=Math.sqrt(l*l+c*c),x=this.context_;x.beginPath(),x.arc(r[0],r[1],n,0,2*Math.PI),this.fillState_&&x.fill(),this.strokeState_&&x.stroke()}this.text_!==""&&this.drawText_(t.getCenter(),0,2,2)}}setStyle(t){this.setFillStrokeStyle(t.getFill(),t.getStroke()),this.setImageStyle(t.getImage()),this.setTextStyle(t.getText())}setTransform(t){this.transform_=t}drawGeometry(t){switch(t.getType()){case"Point":this.drawPoint(t);break;case"LineString":this.drawLineString(t);break;case"Polygon":this.drawPolygon(t);break;case"MultiPoint":this.drawMultiPoint(t);break;case"MultiLineString":this.drawMultiLineString(t);break;case"MultiPolygon":this.drawMultiPolygon(t);break;case"GeometryCollection":this.drawGeometryCollection(t);break;case"Circle":this.drawCircle(t);break;default:}}drawFeature(t,r){let l=r.getGeometryFunction()(t);l&&(this.setStyle(r),this.drawGeometry(l))}drawGeometryCollection(t){let r=t.getGeometriesArray();for(let l=0,c=r.length;l<c;++l)this.drawGeometry(r[l])}drawPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=t.getFlatCoordinates(),l=t.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawMultiPoint(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=t.getFlatCoordinates(),l=t.getStride();this.image_&&this.drawImages_(r,0,r.length,l),this.text_!==""&&this.drawText_(r,0,r.length,l)}drawLineString(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,t.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=t.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(l,0,l.length,t.getStride(),!1),r.stroke()}if(this.text_!==""){let r=t.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(t){this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=t.getExtent();if(Qi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let l=this.context_,c=t.getFlatCoordinates(),n=0,x=t.getEnds(),b=t.getStride();l.beginPath();for(let S=0,R=x.length;S<R;++S)n=this.moveToLineTo_(c,n,x[S],b,!1);l.stroke()}if(this.text_!==""){let l=t.getFlatMidpoints();this.drawText_(l,0,l.length,2)}}}drawPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(t.getOrientedFlatCoordinates(),0,t.getEnds(),t.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=t.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(t){if(this.squaredTolerance_&&(t=t.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Qi(this.extent_,t.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,l=t.getOrientedFlatCoordinates(),c=0,n=t.getEndss(),x=t.getStride();r.beginPath();for(let b=0,S=n.length;b<S;++b){let R=n[b];c=this.drawRings_(l,c,R,x)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=t.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(t){let r=this.context_,l=this.contextFillState_;l?l.fillStyle!=t.fillStyle&&(l.fillStyle=t.fillStyle,r.fillStyle=t.fillStyle):(r.fillStyle=t.fillStyle,this.contextFillState_={fillStyle:t.fillStyle})}setContextStrokeState_(t){let r=this.context_,l=this.contextStrokeState_;l?(l.lineCap!=t.lineCap&&(l.lineCap=t.lineCap,r.lineCap=t.lineCap),yn(l.lineDash,t.lineDash)||r.setLineDash(l.lineDash=t.lineDash),l.lineDashOffset!=t.lineDashOffset&&(l.lineDashOffset=t.lineDashOffset,r.lineDashOffset=t.lineDashOffset),l.lineJoin!=t.lineJoin&&(l.lineJoin=t.lineJoin,r.lineJoin=t.lineJoin),l.lineWidth!=t.lineWidth&&(l.lineWidth=t.lineWidth,r.lineWidth=t.lineWidth),l.miterLimit!=t.miterLimit&&(l.miterLimit=t.miterLimit,r.miterLimit=t.miterLimit),l.strokeStyle!=t.strokeStyle&&(l.strokeStyle=t.strokeStyle,r.strokeStyle=t.strokeStyle)):(r.lineCap=t.lineCap,r.setLineDash(t.lineDash),r.lineDashOffset=t.lineDashOffset,r.lineJoin=t.lineJoin,r.lineWidth=t.lineWidth,r.miterLimit=t.miterLimit,r.strokeStyle=t.strokeStyle,this.contextStrokeState_={lineCap:t.lineCap,lineDash:t.lineDash,lineDashOffset:t.lineDashOffset,lineJoin:t.lineJoin,lineWidth:t.lineWidth,miterLimit:t.miterLimit,strokeStyle:t.strokeStyle})}setContextTextState_(t){let r=this.context_,l=this.contextTextState_,c=t.textAlign?t.textAlign:ma;l?(l.font!=t.font&&(l.font=t.font,r.font=t.font),l.textAlign!=c&&(l.textAlign=c,r.textAlign=c),l.textBaseline!=t.textBaseline&&(l.textBaseline=t.textBaseline,r.textBaseline=t.textBaseline)):(r.font=t.font,r.textAlign=c,r.textBaseline=t.textBaseline,this.contextTextState_={font:t.font,textAlign:c,textBaseline:t.textBaseline})}setFillStrokeStyle(t,r){if(!t)this.fillState_=null;else{let l=t.getColor();this.fillState_={fillStyle:wn(l||ar)}}if(!r)this.strokeState_=null;else{let l=r.getColor(),c=r.getLineCap(),n=r.getLineDash(),x=r.getLineDashOffset(),b=r.getLineJoin(),S=r.getWidth(),R=r.getMiterLimit(),E=n||Sn;this.strokeState_={lineCap:c!==void 0?c:Ws,lineDash:this.pixelRatio_===1?E:E.map(A=>A*this.pixelRatio_),lineDashOffset:(x||Tn)*this.pixelRatio_,lineJoin:b!==void 0?b:$s,lineWidth:(S!==void 0?S:Io)*this.pixelRatio_,miterLimit:R!==void 0?R:To,strokeStyle:wn(l||Co)}}}setImageStyle(t){let r;if(!t||!(r=t.getSize())){this.image_=null;return}let l=t.getPixelRatio(this.pixelRatio_),c=t.getAnchor(),n=t.getOrigin();this.image_=t.getImage(this.pixelRatio_),this.imageAnchorX_=c[0]*l,this.imageAnchorY_=c[1]*l,this.imageHeight_=r[1]*l,this.imageOpacity_=t.getOpacity(),this.imageOriginX_=n[0],this.imageOriginY_=n[1],this.imageRotateWithView_=t.getRotateWithView(),this.imageRotation_=t.getRotation();let x=t.getScaleArray();this.imageScale_=[x[0]*this.pixelRatio_/l,x[1]*this.pixelRatio_/l],this.imageWidth_=r[0]*l}setTextStyle(t){if(!t)this.text_="";else{let r=t.getFill();if(!r)this.textFillState_=null;else{let W=r.getColor();this.textFillState_={fillStyle:wn(W||ar)}}let l=t.getStroke();if(!l)this.textStrokeState_=null;else{let W=l.getColor(),ne=l.getLineCap(),ge=l.getLineDash(),me=l.getLineDashOffset(),ve=l.getLineJoin(),Te=l.getWidth(),Oe=l.getMiterLimit();this.textStrokeState_={lineCap:ne!==void 0?ne:Ws,lineDash:ge||Sn,lineDashOffset:me||Tn,lineJoin:ve!==void 0?ve:$s,lineWidth:Te!==void 0?Te:Io,miterLimit:Oe!==void 0?Oe:To,strokeStyle:wn(W||Co)}}let c=t.getFont(),n=t.getOffsetX(),x=t.getOffsetY(),b=t.getRotateWithView(),S=t.getRotation(),R=t.getScaleArray(),E=t.getText(),A=t.getTextAlign(),z=t.getTextBaseline();this.textState_={font:c!==void 0?c:Rf,textAlign:A!==void 0?A:ma,textBaseline:z!==void 0?z:xl},this.text_=E!==void 0?Array.isArray(E)?E.reduce((W,ne,ge)=>W+=ge%2?" ":ne,""):E:"",this.textOffsetX_=n!==void 0?this.pixelRatio_*n:0,this.textOffsetY_=x!==void 0?this.pixelRatio_*x:0,this.textRotateWithView_=b!==void 0?b:!1,this.textRotation_=S!==void 0?S:0,this.textScale_=[this.pixelRatio_*R[0],this.pixelRatio_*R[1]]}}},g1=ey;var mC=.5,_1={Point:wC,LineString:xC,Polygon:TC,MultiPoint:SC,MultiLineString:vC,MultiPolygon:bC,GeometryCollection:yC,Circle:gC};function y1(h,t){return parseInt(Vt(h),10)-parseInt(Vt(t),10)}function ty(h,t){let r=iy(h,t);return r*r}function iy(h,t){return mC*h/t}function gC(h,t,r,l,c){let n=r.getFill(),x=r.getStroke();if(n||x){let S=h.getBuilder(r.getZIndex(),"Circle");S.setFillStrokeStyle(n,x),S.drawCircle(t,l,c)}let b=r.getText();if(b&&b.getText()){let S=h.getBuilder(r.getZIndex(),"Text");S.setTextStyle(b),S.drawText(t,l)}}function ry(h,t,r,l,c,n,x,b){let S=[],R=r.getImage();if(R){let z=!0,W=R.getImageState();W==Mt.LOADED||W==Mt.ERROR?z=!1:W==Mt.IDLE&&R.load(),z&&S.push(R.ready())}let E=r.getFill();E&&E.loading()&&S.push(E.ready());let A=S.length>0;return A&&Promise.all(S).then(()=>c(null)),_C(h,t,r,l,n,x,b),A}function _C(h,t,r,l,c,n,x){let b=r.getGeometryFunction()(t);if(!b)return;let S=b.simplifyTransformed(l,c);if(r.getRenderer())x1(h,S,r,t,x);else{let E=_1[S.getType()];E(h,S,r,t,x,n)}}function x1(h,t,r,l,c){if(t.getType()=="GeometryCollection"){let x=t.getGeometries();for(let b=0,S=x.length;b<S;++b)x1(h,x[b],r,l,c);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(t,l,r.getRenderer(),r.getHitDetectionRenderer(),c)}function yC(h,t,r,l,c,n){let x=t.getGeometriesArray(),b,S;for(b=0,S=x.length;b<S;++b){let R=_1[x[b].getType()];R(h,x[b],r,l,c,n)}}function xC(h,t,r,l,c){let n=r.getStroke();if(n){let b=h.getBuilder(r.getZIndex(),"LineString");b.setFillStrokeStyle(null,n),b.drawLineString(t,l,c)}let x=r.getText();if(x&&x.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(x),b.drawText(t,l,c)}}function vC(h,t,r,l,c){let n=r.getStroke();if(n){let b=h.getBuilder(r.getZIndex(),"LineString");b.setFillStrokeStyle(null,n),b.drawMultiLineString(t,l,c)}let x=r.getText();if(x&&x.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(x),b.drawText(t,l,c)}}function bC(h,t,r,l,c){let n=r.getFill(),x=r.getStroke();if(x||n){let S=h.getBuilder(r.getZIndex(),"Polygon");S.setFillStrokeStyle(n,x),S.drawMultiPolygon(t,l,c)}let b=r.getText();if(b&&b.getText()){let S=h.getBuilder(r.getZIndex(),"Text");S.setTextStyle(b),S.drawText(t,l,c)}}function wC(h,t,r,l,c,n){let x=r.getImage(),b=r.getText(),S=b&&b.getText(),R=n&&x&&S?{}:void 0;if(x){if(x.getImageState()!=Mt.LOADED)return;let E=h.getBuilder(r.getZIndex(),"Image");E.setImageStyle(x,R),E.drawPoint(t,l,c)}if(S){let E=h.getBuilder(r.getZIndex(),"Text");E.setTextStyle(b,R),E.drawText(t,l,c)}}function SC(h,t,r,l,c,n){let x=r.getImage(),b=x&&x.getOpacity()!==0,S=r.getText(),R=S&&S.getText(),E=n&&b&&R?{}:void 0;if(b){if(x.getImageState()!=Mt.LOADED)return;let A=h.getBuilder(r.getZIndex(),"Image");A.setImageStyle(x,E),A.drawMultiPoint(t,l,c)}if(R){let A=h.getBuilder(r.getZIndex(),"Text");A.setTextStyle(S,E),A.drawText(t,l,c)}}function TC(h,t,r,l,c){let n=r.getFill(),x=r.getStroke();if(n||x){let S=h.getBuilder(r.getZIndex(),"Polygon");S.setFillStrokeStyle(n,x),S.drawPolygon(t,l,c)}let b=r.getText();if(b&&b.getText()){let S=h.getBuilder(r.getZIndex(),"Text");S.setTextStyle(b),S.drawText(t,l,c)}}var CC=!1;function MC(h,t,r,l,c,n,x){let b=new XMLHttpRequest;b.open("GET",typeof h=="function"?h(r,l,c):h,!0),t.getType()=="arraybuffer"&&(b.responseType="arraybuffer"),b.withCredentials=CC,b.onload=function(S){if(!b.status||b.status>=200&&b.status<300){let R=t.getType();try{let E;R=="text"||R=="json"?E=b.responseText:R=="xml"?E=b.responseXML||b.responseText:R=="arraybuffer"&&(E=b.response),E?n(t.readFeatures(E,{extent:r,featureProjection:c}),t.readProjection(E)):x()}catch{x()}}else x()},b.onerror=x,b.send()}function ny(h,t){return function(r,l,c,n,x){MC(h,t,r,l,c,(b,S)=>{this.addFeatures(b),n!==void 0&&n(b)},x||bs)}}function v1(h,t){return[[-1/0,-1/0,1/0,1/0]]}var b1=mr(),Qu=class h{constructor(t,r,l,c,n,x){this.styleFunction,this.extent_,this.id_=x,this.type_=t,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=l||null,this.properties_=n,this.squaredTolerance_,this.stride_=c,this.simplifiedGeometry_}get(t){return this.properties_[t]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?sa(this.flatCoordinates_):Cc(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let t=Jn(this.getExtent());this.flatInteriorPoints_=Nu(this.flatCoordinates_,0,this.ends_,2,t,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let t=Fb(this.flatCoordinates_,this.ends_),r=xf(this.flatCoordinates_,0,t,2);this.flatInteriorPoints_=_f(this.flatCoordinates_,0,t,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=_l(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let t=this.flatCoordinates_,r=0,l=this.ends_;for(let c=0,n=l.length;c<n;++c){let x=l[c],b=_l(t,r,x,2,.5);Ir(this.flatMidpoints_,b),r=x}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(t){return this}simplifyTransformed(t,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(t){t=Ri(t);let r=t.getExtent(),l=t.getWorldExtent();if(r&&l){let c=sr(l)/sr(r);Ur(b1,l[0],l[3],c,-c,0,0,0),xn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,b1,this.flatCoordinates_)}}applyTransform(t){t(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=Yp((t,r)=>{if(t===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let l=this.simplifiedGeometry_.getFlatCoordinates(),c;switch(this.type_){case"LineString":l.length=gl(l,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,t,l,0),c=[l.length];break;case"MultiLineString":c=[],l.length=pf(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,t,l,0,c);break;case"Polygon":c=[],l.length=zu(l,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(t),l,0,c);break;default:}return c&&(this.simplifiedGeometry_=new h(this.type_,l,c,2,this.properties_,this.id_)),this.squaredTolerance_=t,this.simplifiedGeometry_}),this}};Qu.prototype.getFlatCoordinates=Qu.prototype.getOrientedFlatCoordinates;var Rs=Qu;function Af(h,t,r=0,l=h.length-1,c=IC){for(;l>r;){if(l-r>600){let S=l-r+1,R=t-r+1,E=Math.log(S),A=.5*Math.exp(2*E/3),z=.5*Math.sqrt(E*A*(S-A)/S)*(R-S/2<0?-1:1),W=Math.max(r,Math.floor(t-R*A/S+z)),ne=Math.min(l,Math.floor(t+(S-R)*A/S+z));Af(h,t,W,ne,c)}let n=h[t],x=r,b=l;for(ed(h,r,t),c(h[l],n)>0&&ed(h,r,l);x<b;){for(ed(h,x,b),x++,b--;c(h[x],n)<0;)x++;for(;c(h[b],n)>0;)b--}c(h[r],n)===0?ed(h,r,b):(b++,ed(h,b,l)),b<=t&&(r=b+1),t<=b&&(l=b-1)}}function ed(h,t,r){let l=h[t];h[t]=h[r],h[r]=l}function IC(h,t){return h<t?-1:h>t?1:0}var vl=class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let r=this.data,l=[];if(!kf(t,r))return l;let c=this.toBBox,n=[];for(;r;){for(let x=0;x<r.children.length;x++){let b=r.children[x],S=r.leaf?c(b):b;kf(t,S)&&(r.leaf?l.push(b):oy(t,S)?this._all(b,l):n.push(b))}r=n.pop()}return l}collides(t){let r=this.data;if(!kf(t,r))return!1;let l=[];for(;r;){for(let c=0;c<r.children.length;c++){let n=r.children[c],x=r.leaf?this.toBBox(n):n;if(kf(t,x)){if(r.leaf||oy(t,x))return!0;l.push(n)}}r=l.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let l=0;l<t.length;l++)this.insert(t[l]);return this}let r=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=r;else if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){let l=this.data;this.data=r,r=l}this._insert(r,this.data.height-r.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=qc([]),this}remove(t,r){if(!t)return this;let l=this.data,c=this.toBBox(t),n=[],x=[],b,S,R;for(;l||n.length;){if(l||(l=n.pop(),S=n[n.length-1],b=x.pop(),R=!0),l.leaf){let E=EC(t,l.children,r);if(E!==-1)return l.children.splice(E,1),n.push(l),this._condense(n),this}!R&&!l.leaf&&oy(l,c)?(n.push(l),x.push(b),b=0,S=l,l=l.children[0]):S?(b++,l=S.children[b],R=!1):l=null}return this}toBBox(t){return t}compareMinX(t,r){return t.minX-r.minX}compareMinY(t,r){return t.minY-r.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,r){let l=[];for(;t;)t.leaf?r.push(...t.children):l.push(...t.children),t=l.pop();return r}_build(t,r,l,c){let n=l-r+1,x=this._maxEntries,b;if(n<=x)return b=qc(t.slice(r,l+1)),Zc(b,this.toBBox),b;c||(c=Math.ceil(Math.log(n)/Math.log(x)),x=Math.ceil(n/Math.pow(x,c-1))),b=qc([]),b.leaf=!1,b.height=c;let S=Math.ceil(n/x),R=S*Math.ceil(Math.sqrt(x));w1(t,r,l,R,this.compareMinX);for(let E=r;E<=l;E+=R){let A=Math.min(E+R-1,l);w1(t,E,A,S,this.compareMinY);for(let z=E;z<=A;z+=S){let W=Math.min(z+S-1,A);b.children.push(this._build(t,z,W,c-1))}}return Zc(b,this.toBBox),b}_chooseSubtree(t,r,l,c){for(;c.push(r),!(r.leaf||c.length-1===l);){let n=1/0,x=1/0,b;for(let S=0;S<r.children.length;S++){let R=r.children[S],E=sy(R),A=AC(t,R)-E;A<x?(x=A,n=E<n?E:n,b=R):A===x&&E<n&&(n=E,b=R)}r=b||r.children[0]}return r}_insert(t,r,l){let c=l?t:this.toBBox(t),n=[],x=this._chooseSubtree(c,this.data,r,n);for(x.children.push(t),id(x,c);r>=0&&n[r].children.length>this._maxEntries;)this._split(n,r),r--;this._adjustParentBBoxes(c,n,r)}_split(t,r){let l=t[r],c=l.children.length,n=this._minEntries;this._chooseSplitAxis(l,n,c);let x=this._chooseSplitIndex(l,n,c),b=qc(l.children.splice(x,l.children.length-x));b.height=l.height,b.leaf=l.leaf,Zc(l,this.toBBox),Zc(b,this.toBBox),r?t[r-1].children.push(b):this._splitRoot(l,b)}_splitRoot(t,r){this.data=qc([t,r]),this.data.height=t.height+1,this.data.leaf=!1,Zc(this.data,this.toBBox)}_chooseSplitIndex(t,r,l){let c,n=1/0,x=1/0;for(let b=r;b<=l-r;b++){let S=td(t,0,b,this.toBBox),R=td(t,b,l,this.toBBox),E=LC(S,R),A=sy(S)+sy(R);E<n?(n=E,c=b,x=A<x?A:x):E===n&&A<x&&(x=A,c=b)}return c||l-r}_chooseSplitAxis(t,r,l){let c=t.leaf?this.compareMinX:PC,n=t.leaf?this.compareMinY:RC,x=this._allDistMargin(t,r,l,c),b=this._allDistMargin(t,r,l,n);x<b&&t.children.sort(c)}_allDistMargin(t,r,l,c){t.children.sort(c);let n=this.toBBox,x=td(t,0,r,n),b=td(t,l-r,l,n),S=Lf(x)+Lf(b);for(let R=r;R<l-r;R++){let E=t.children[R];id(x,t.leaf?n(E):E),S+=Lf(x)}for(let R=l-r-1;R>=r;R--){let E=t.children[R];id(b,t.leaf?n(E):E),S+=Lf(b)}return S}_adjustParentBBoxes(t,r,l){for(let c=l;c>=0;c--)id(r[c],t)}_condense(t){for(let r=t.length-1,l;r>=0;r--)t[r].children.length===0?r>0?(l=t[r-1].children,l.splice(l.indexOf(t[r]),1)):this.clear():Zc(t[r],this.toBBox)}};function EC(h,t,r){if(!r)return t.indexOf(h);for(let l=0;l<t.length;l++)if(r(h,t[l]))return l;return-1}function Zc(h,t){td(h,0,h.children.length,t,h)}function td(h,t,r,l,c){c||(c=qc(null)),c.minX=1/0,c.minY=1/0,c.maxX=-1/0,c.maxY=-1/0;for(let n=t;n<r;n++){let x=h.children[n];id(c,h.leaf?l(x):x)}return c}function id(h,t){return h.minX=Math.min(h.minX,t.minX),h.minY=Math.min(h.minY,t.minY),h.maxX=Math.max(h.maxX,t.maxX),h.maxY=Math.max(h.maxY,t.maxY),h}function PC(h,t){return h.minX-t.minX}function RC(h,t){return h.minY-t.minY}function sy(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function Lf(h){return h.maxX-h.minX+(h.maxY-h.minY)}function AC(h,t){return(Math.max(t.maxX,h.maxX)-Math.min(t.minX,h.minX))*(Math.max(t.maxY,h.maxY)-Math.min(t.minY,h.minY))}function LC(h,t){let r=Math.max(h.minX,t.minX),l=Math.max(h.minY,t.minY),c=Math.min(h.maxX,t.maxX),n=Math.min(h.maxY,t.maxY);return Math.max(0,c-r)*Math.max(0,n-l)}function oy(h,t){return h.minX<=t.minX&&h.minY<=t.minY&&t.maxX<=h.maxX&&t.maxY<=h.maxY}function kf(h,t){return t.minX<=h.maxX&&t.minY<=h.maxY&&t.maxX>=h.minX&&t.maxY>=h.minY}function qc(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function w1(h,t,r,l,c){let n=[t,r];for(;n.length;){if(r=n.pop(),t=n.pop(),r-t<=l)continue;let x=t+Math.ceil((r-t)/l/2)*l;Af(h,x,t,r,c),n.push(t,x,x,r)}}var ay=class{constructor(t){this.rbush_=new vl(t),this.items_={}}insert(t,r){let l={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3],value:r};this.rbush_.insert(l),this.items_[Vt(r)]=l}load(t,r){let l=new Array(r.length);for(let c=0,n=r.length;c<n;c++){let x=t[c],b=r[c],S={minX:x[0],minY:x[1],maxX:x[2],maxY:x[3],value:b};l[c]=S,this.items_[Vt(b)]=S}this.rbush_.load(l)}remove(t){let r=Vt(t),l=this.items_[r];return delete this.items_[r],this.rbush_.remove(l)!==null}update(t,r){let l=this.items_[Vt(r)],c=[l.minX,l.minY,l.maxX,l.maxY];Wp(c,t)||(this.remove(r),this.insert(t,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(t){let r={minX:t[0],minY:t[1],maxX:t[2],maxY:t[3]};return this.rbush_.search(r).map(function(c){return c.value})}forEach(t){return this.forEach_(this.getAll(),t)}forEachInExtent(t,r){return this.forEach_(this.getInExtent(t),r)}forEach_(t,r){let l;for(let c=0,n=t.length;c<n;c++)if(l=r(t[c]),l)return l;return l}isEmpty(){return On(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(t){let r=this.rbush_.toJSON();return bo(r.minX,r.minY,r.maxX,r.maxY,t)}concat(t){this.rbush_.load(t.rbush_.all());for(let r in t.items_)this.items_[r]=t.items_[r]}},rd=ay;var ly=class extends gr{constructor(t){super(),this.projection=Ri(t.projection),this.attributions_=S1(t.attributions),this.attributionsCollapsible_=t.attributionsCollapsible??!0,this.loading=!1,this.state_=t.state!==void 0?t.state:"ready",this.wrapX_=t.wrapX!==void 0?t.wrapX:!1,this.interpolate_=!!t.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(l,c){r.viewResolver=l,r.viewRejector=c})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(t){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(t){this.attributions_=S1(t),this.changed()}setState(t){this.state_=t,this.changed()}};function S1(h){return h?typeof h=="function"?h:(Array.isArray(h)||(h=[h]),t=>h):null}var Eo=ly;var qr={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};var Xs=class extends Ei{constructor(t,r,l){super(t),this.feature=r,this.features=l}},cy=class extends Eo{constructor(t){t=t||{},super({attributions:t.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:t.wrapX!==void 0?t.wrapX:!0}),this.on,this.once,this.un,this.loader_=bs,this.format_=t.format||null,this.overlaps_=t.overlaps===void 0?!0:t.overlaps,this.url_=t.url,t.loader!==void 0?this.loader_=t.loader:this.url_!==void 0&&(di(this.format_,"`format` must be set when `url` is set"),this.loader_=ny(this.url_,this.format_)),this.strategy_=t.strategy!==void 0?t.strategy:v1;let r=t.useSpatialIndex!==void 0?t.useSpatialIndex:!0;this.featuresRtree_=r?new rd:null,this.loadedExtentsRtree_=new rd,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let l,c;Array.isArray(t.features)?c=t.features:t.features&&(l=t.features,c=l.getArray()),!r&&l===void 0&&(l=new Xu(c)),c!==void 0&&this.addFeaturesInternal(c),l!==void 0&&this.bindFeaturesCollection_(l)}addFeature(t){this.addFeatureInternal(t),this.changed()}addFeatureInternal(t){let r=Vt(t);if(!this.addToIndex_(r,t)){this.featuresCollection_&&this.featuresCollection_.remove(t);return}this.setupChangeEvents_(r,t);let l=t.getGeometry();if(l){let c=l.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(c,t)}else this.nullGeometryFeatures_[r]=t;this.dispatchEvent(new Xs(qr.ADDFEATURE,t))}setupChangeEvents_(t,r){r instanceof Rs||(this.featureChangeKeys_[t]=[Er(r,yi.CHANGE,this.handleFeatureChange_,this),Er(r,$p.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(t,r){let l=!0;if(r.getId()!==void 0){let c=String(r.getId());if(!(c in this.idIndex_))this.idIndex_[c]=r;else if(r instanceof Rs){let n=this.idIndex_[c];n instanceof Rs?Array.isArray(n)?n.push(r):this.idIndex_[c]=[n,r]:l=!1}else l=!1}return l&&(di(!(t in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[t]=r),l}addFeatures(t){this.addFeaturesInternal(t),this.changed()}addFeaturesInternal(t){let r=[],l=[],c=[];for(let n=0,x=t.length;n<x;n++){let b=t[n],S=Vt(b);this.addToIndex_(S,b)&&l.push(b)}for(let n=0,x=l.length;n<x;n++){let b=l[n],S=Vt(b);this.setupChangeEvents_(S,b);let R=b.getGeometry();if(R){let E=R.getExtent();r.push(E),c.push(b)}else this.nullGeometryFeatures_[S]=b}if(this.featuresRtree_&&this.featuresRtree_.load(r,c),this.hasListener(qr.ADDFEATURE))for(let n=0,x=l.length;n<x;n++)this.dispatchEvent(new Xs(qr.ADDFEATURE,l[n]))}bindFeaturesCollection_(t){let r=!1;this.addEventListener(qr.ADDFEATURE,function(l){r||(r=!0,t.push(l.feature),r=!1)}),this.addEventListener(qr.REMOVEFEATURE,function(l){r||(r=!0,t.remove(l.feature),r=!1)}),t.addEventListener(Es.ADD,l=>{r||(r=!0,this.addFeature(l.element),r=!1)}),t.addEventListener(Es.REMOVE,l=>{r||(r=!0,this.removeFeature(l.element),r=!1)}),this.featuresCollection_=t}clear(t){if(t){for(let l in this.featureChangeKeys_)this.featureChangeKeys_[l].forEach(Zr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(l=>{this.removeFeatureInternal(l)});for(let l in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[l])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Xs(qr.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(t){if(this.featuresRtree_)return this.featuresRtree_.forEach(t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureAtCoordinateDirect(t,r){let l=[t[0],t[1],t[0],t[1]];return this.forEachFeatureInExtent(l,function(c){let n=c.getGeometry();if(n instanceof Rs||n.intersectsCoordinate(t))return r(c)})}forEachFeatureInExtent(t,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(t,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(t,r){return this.forEachFeatureInExtent(t,function(l){let c=l.getGeometry();if(c instanceof Rs||c.intersectsExtent(t)){let n=r(l);if(n)return n}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let t;return this.featuresCollection_?t=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(t=this.featuresRtree_.getAll(),On(this.nullGeometryFeatures_)||Ir(t,Object.values(this.nullGeometryFeatures_))),t}getFeaturesAtCoordinate(t){let r=[];return this.forEachFeatureAtCoordinateDirect(t,function(l){r.push(l)}),r}getFeaturesInExtent(t,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(t);let c=jv(t,r);return[].concat(...c.map(n=>this.featuresRtree_.getInExtent(n)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(t,r){let l=t[0],c=t[1],n=null,x=[NaN,NaN],b=1/0,S=[-1/0,-1/0,1/0,1/0];return r=r||Hp,this.featuresRtree_.forEachInExtent(S,function(R){if(r(R)){let E=R.getGeometry(),A=b;if(b=E instanceof Rs?0:E.closestPointXY(l,c,x,b),b<A){n=R;let z=Math.sqrt(b);S[0]=l-z,S[1]=c-z,S[2]=l+z,S[3]=c+z}}}),n}getExtent(t){return this.featuresRtree_.getExtent(t)}getFeatureById(t){let r=this.idIndex_[t.toString()];return r!==void 0?r:null}getFeatureByUid(t){let r=this.uidIndex_[t];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(t){let r=t.target,l=Vt(r),c=r.getGeometry();if(!c)l in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[l]=r);else{let x=c.getExtent();l in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[l],this.featuresRtree_&&this.featuresRtree_.insert(x,r)):this.featuresRtree_&&this.featuresRtree_.update(x,r)}let n=r.getId();if(n!==void 0){let x=n.toString();this.idIndex_[x]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[x]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[l]=r;this.changed(),this.dispatchEvent(new Xs(qr.CHANGEFEATURE,r))}hasFeature(t){let r=t.getId();return r!==void 0?r in this.idIndex_:Vt(t)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&On(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(t,r,l){let c=this.loadedExtentsRtree_,n=this.strategy_(t,r,l);for(let x=0,b=n.length;x<b;++x){let S=n[x];c.forEachInExtent(S,function(E){return cl(E.extent,S)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Xs(qr.FEATURESLOADSTART)),this.loader_.call(this,S,r,l,E=>{--this.loadingExtentsCount_,this.dispatchEvent(new Xs(qr.FEATURESLOADEND,void 0,E))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Xs(qr.FEATURESLOADERROR))}),c.insert(S,{extent:S.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(t){let r=this.loadedExtentsRtree_,l=r.forEachInExtent(t,function(c){if(Wp(c.extent,t))return c});l&&r.remove(l)}removeFeatures(t){let r=!1;for(let l=0,c=t.length;l<c;++l)r=this.removeFeatureInternal(t[l])||r;r&&this.changed()}removeFeature(t){if(!t)return;this.removeFeatureInternal(t)&&this.changed()}removeFeatureInternal(t){let r=Vt(t);if(!(r in this.uidIndex_))return!1;r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(t),this.featureChangeKeys_[r]?.forEach(Zr),delete this.featureChangeKeys_[r];let c=t.getId();if(c!==void 0){let n=c.toString(),x=this.idIndex_[n];x===t?delete this.idIndex_[n]:Array.isArray(x)&&(x.splice(x.indexOf(t),1),x.length===1&&(this.idIndex_[n]=x[0]))}return delete this.uidIndex_[r],this.hasListener(qr.REMOVEFEATURE)&&this.dispatchEvent(new Xs(qr.REMOVEFEATURE,t)),!0}removeFromIdIndex_(t){for(let r in this.idIndex_)if(this.idIndex_[r]===t){delete this.idIndex_[r];break}}setLoader(t){this.loader_=t}setUrl(t){di(this.format_,"`format` must be set when `url` is set"),this.url_=t,this.setLoader(ny(t,this.format_))}setOverlaps(t){this.overlaps_=t,this.changed()}},bl=cy;var hy=class h{constructor(t){t=t||{},this.patternImage_=null,this.color_=null,t.color!==void 0&&this.setColor(t.color)}clone(){let t=this.getColor();return new h({color:Array.isArray(t)?t.slice():t||void 0})}getColor(){return this.color_}setColor(t){if(t!==null&&typeof t=="object"&&"src"in t){let r=Vc(null,t.src,"anonymous",void 0,t.offset?null:t.color?t.color:null,!(t.offset&&t.size));r.ready().then(()=>{this.patternImage_=null}),r.getImageState()===Mt.IDLE&&r.load(),r.getImageState()===Mt.LOADING&&(this.patternImage_=r)}this.color_=t}getKey(){let t=this.getColor();return t?t instanceof CanvasPattern||t instanceof CanvasGradient?Vt(t):typeof t=="object"&&"src"in t?t.src+":"+t.offset:Ps(t).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Ar=hy;var uy=class h{constructor(t){t=t||{},this.color_=t.color!==void 0?t.color:null,this.lineCap_=t.lineCap,this.lineDash_=t.lineDash!==void 0?t.lineDash:null,this.lineDashOffset_=t.lineDashOffset,this.lineJoin_=t.lineJoin,this.miterLimit_=t.miterLimit,this.width_=t.width}clone(){let t=this.getColor();return new h({color:Array.isArray(t)?t.slice():t||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(t){this.color_=t}setLineCap(t){this.lineCap_=t}setLineDash(t){this.lineDash_=t}setLineDashOffset(t){this.lineDashOffset_=t}setLineJoin(t){this.lineJoin_=t}setMiterLimit(t){this.miterLimit_=t}setWidth(t){this.width_=t}},lr=uy;function Hs(h,t){return Array.isArray(h)?h:(t===void 0?t=[h,h]:(t[0]=h,t[1]=h),t)}var dy=class h{constructor(t){this.opacity_=t.opacity,this.rotateWithView_=t.rotateWithView,this.rotation_=t.rotation,this.scale_=t.scale,this.scaleArray_=Hs(t.scale),this.displacement_=t.displacement,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new h({opacity:this.getOpacity(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return St()}getImage(t){return St()}getHitDetectionImage(){return St()}getPixelRatio(t){return 1}getImageState(){return St()}getImageSize(){return St()}getOrigin(){return St()}getSize(){return St()}setDisplacement(t){this.displacement_=t}setOpacity(t){this.opacity_=t}setRotateWithView(t){this.rotateWithView_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=Hs(t)}listenImageChange(t){St()}load(){St()}unlistenImageChange(t){St()}ready(){return Promise.resolve()}},Df=dy;var py=class h extends Df{constructor(t){super({opacity:1,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,rotation:t.rotation!==void 0?t.rotation:0,scale:t.scale!==void 0?t.scale:1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=t.fill!==void 0?t.fill:null,this.origin_=[0,0],this.points_=t.points,this.radius=t.radius,this.radius2_=t.radius2,this.angle_=t.angle!==void 0?t.angle:0,this.stroke_=t.stroke!==void 0?t.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?Mt.LOADING:Mt.LOADED,this.imageState_===Mt.LOADING&&this.ready().then(()=>this.imageState_=Mt.LOADED),this.render()}clone(){let t=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(t)?t.slice():t,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}getAnchor(){let t=this.size_,r=this.getDisplacement(),l=this.getScaleArray();return[t[0]/2-r[0]/l[0],t[1]/2+r[1]/l[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(t){this.fill_=t,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(t){let r=this.fill_?.getKey(),l=`${t},${this.angle_},${this.radius},${this.radius2_},${this.points_},${r}`+Object.values(this.renderOptions_).join(","),c=jn.get(l,null,null)?.getImage(1);if(!c){let n=this.renderOptions_,x=Math.ceil(n.size*t),b=Oi(x,x);this.draw_(n,b,t),c=b.canvas,jn.set(l,null,null,new h1(c,void 0,null,Mt.LOADED,null))}return c}getPixelRatio(t){return t}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t,this.render()}listenImageChange(t){}load(){}unlistenImageChange(t){}calculateLineJoinSize_(t,r,l){if(r===0||this.points_===1/0||t!=="bevel"&&t!=="miter")return r;let c=this.radius,n=this.radius2_===void 0?c:this.radius2_;if(c<n){let Me=c;c=n,n=Me}let x=this.radius2_===void 0?this.points_:this.points_*2,b=2*Math.PI/x,S=n*Math.sin(b),R=Math.sqrt(n*n-S*S),E=c-R,A=Math.sqrt(S*S+E*E),z=A/S;if(t==="miter"&&z<=l)return z*r;let W=r/2/z,ne=r/2*(E/A),me=Math.sqrt((c+W)*(c+W)+ne*ne)-c;if(this.radius2_===void 0||t==="bevel")return me*2;let ve=c*Math.sin(b),Te=Math.sqrt(c*c-ve*ve),Oe=n-Te,ze=Math.sqrt(ve*ve+Oe*Oe)/ve;if(ze<=l){let Me=ze*r/2-n-c;return 2*Math.max(me,Me)}return me*2}createRenderOptions(){let t=Ws,r=$s,l=0,c=null,n=0,x,b=0;this.stroke_&&(x=wn(this.stroke_.getColor()??Co),b=this.stroke_.getWidth()??Io,c=this.stroke_.getLineDash(),n=this.stroke_.getLineDashOffset()??0,r=this.stroke_.getLineJoin()??$s,t=this.stroke_.getLineCap()??Ws,l=this.stroke_.getMiterLimit()??To);let S=this.calculateLineJoinSize_(r,b,l),R=Math.max(this.radius,this.radius2_||0),E=Math.ceil(2*R+S);return{strokeStyle:x,strokeWidth:b,size:E,lineCap:t,lineDash:c,lineDashOffset:n,lineJoin:r,miterLimit:l}}render(){this.renderOptions_=this.createRenderOptions();let t=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[t,t]}draw_(t,r,l){if(r.scale(l,l),r.translate(t.size/2,t.size/2),this.createPath_(r),this.fill_){let c=this.fill_.getColor();c===null&&(c=ar),r.fillStyle=wn(c),r.fill()}t.strokeStyle&&(r.strokeStyle=t.strokeStyle,r.lineWidth=t.strokeWidth,t.lineDash&&(r.setLineDash(t.lineDash),r.lineDashOffset=t.lineDashOffset),r.lineCap=t.lineCap,r.lineJoin=t.lineJoin,r.miterLimit=t.miterLimit,r.stroke())}createHitDetectionCanvas_(t){let r;if(this.fill_){let l=this.fill_.getColor(),c=0;typeof l=="string"&&(l=Ps(l)),l===null?c=1:Array.isArray(l)&&(c=l.length===4?l[3]:1),c===0&&(r=Oi(t.size,t.size),this.drawHitDetectionCanvas_(t,r))}return r?r.canvas:this.getImage(1)}createPath_(t){let r=this.points_,l=this.radius;if(r===1/0)t.arc(0,0,l,0,2*Math.PI);else{let c=this.radius2_===void 0?l:this.radius2_;this.radius2_!==void 0&&(r*=2);let n=this.angle_-Math.PI/2,x=2*Math.PI/r;for(let b=0;b<r;b++){let S=n+b*x,R=b%2===0?l:c;t.lineTo(R*Math.cos(S),R*Math.sin(S))}t.closePath()}}drawHitDetectionCanvas_(t,r){r.translate(t.size/2,t.size/2),this.createPath_(r),r.fillStyle=ar,r.fill(),t.strokeStyle&&(r.strokeStyle=t.strokeStyle,r.lineWidth=t.strokeWidth,t.lineDash&&(r.setLineDash(t.lineDash),r.lineDashOffset=t.lineDashOffset),r.lineJoin=t.lineJoin,r.miterLimit=t.miterLimit,r.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},Ff=py;var fy=class h extends Ff{constructor(t){t=t||{radius:5},super({points:1/0,fill:t.fill,radius:t.radius,stroke:t.stroke,scale:t.scale!==void 0?t.scale:1,rotation:t.rotation!==void 0?t.rotation:0,rotateWithView:t.rotateWithView!==void 0?t.rotateWithView:!1,displacement:t.displacement!==void 0?t.displacement:[0,0],declutterMode:t.declutterMode})}clone(){let t=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(t)?t.slice():t,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}setRadius(t){this.radius=t,this.render()}},Cn=fy;var ga=class h{constructor(t){t=t||{},this.geometry_=null,this.geometryFunction_=T1,t.geometry!==void 0&&this.setGeometry(t.geometry),this.fill_=t.fill!==void 0?t.fill:null,this.image_=t.image!==void 0?t.image:null,this.renderer_=t.renderer!==void 0?t.renderer:null,this.hitDetectionRenderer_=t.hitDetectionRenderer!==void 0?t.hitDetectionRenderer:null,this.stroke_=t.stroke!==void 0?t.stroke:null,this.text_=t.text!==void 0?t.text:null,this.zIndex_=t.zIndex}clone(){let t=this.getGeometry();return t&&typeof t=="object"&&(t=t.clone()),new h({geometry:t??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(t){this.renderer_=t}setHitDetectionRenderer(t){this.hitDetectionRenderer_=t}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(t){this.fill_=t}getImage(){return this.image_}setImage(t){this.image_=t}getStroke(){return this.stroke_}setStroke(t){this.stroke_=t}getText(){return this.text_}setText(t){this.text_=t}getZIndex(){return this.zIndex_}setGeometry(t){typeof t=="function"?this.geometryFunction_=t:typeof t=="string"?this.geometryFunction_=function(r){return r.get(t)}:t?t!==void 0&&(this.geometryFunction_=function(){return t}):this.geometryFunction_=T1,this.geometry_=t}setZIndex(t){this.zIndex_=t}};function C1(h){let t;if(typeof h=="function")t=h;else{let r;Array.isArray(h)?r=h:(di(typeof h.getZIndex=="function","Expected an `Style` or an array of `Style`"),r=[h]),t=function(){return r}}return t}var my=null;function gy(h,t){if(!my){let r=new Ar({color:"rgba(255,255,255,0.4)"}),l=new lr({color:"#3399CC",width:1.25});my=[new ga({image:new Cn({fill:r,stroke:l,radius:5}),fill:r,stroke:l})]}return my}function M1(){let h={},t=[255,255,255,1],r=[0,153,255,1],l=3;return h.Polygon=[new ga({fill:new Ar({color:[255,255,255,.5]})})],h.MultiPolygon=h.Polygon,h.LineString=[new ga({stroke:new lr({color:t,width:l+2})}),new ga({stroke:new lr({color:r,width:l})})],h.MultiLineString=h.LineString,h.Circle=h.Polygon.concat(h.LineString),h.Point=[new ga({image:new Cn({radius:l*2,fill:new Ar({color:r}),stroke:new lr({color:t,width:l/2})}),zIndex:1/0})],h.MultiPoint=h.Point,h.GeometryCollection=h.Polygon.concat(h.LineString,h.Point),h}function T1(h){return h.getGeometry()}var Lr=ga;var kC="#333",_y=class h{constructor(t){t=t||{},this.font_=t.font,this.rotation_=t.rotation,this.rotateWithView_=t.rotateWithView,this.keepUpright_=t.keepUpright,this.scale_=t.scale,this.scaleArray_=Hs(t.scale!==void 0?t.scale:1),this.text_=t.text,this.textAlign_=t.textAlign,this.justify_=t.justify,this.repeat_=t.repeat,this.textBaseline_=t.textBaseline,this.fill_=t.fill!==void 0?t.fill:new Ar({color:kC}),this.maxAngle_=t.maxAngle!==void 0?t.maxAngle:Math.PI/4,this.placement_=t.placement!==void 0?t.placement:"point",this.overflow_=!!t.overflow,this.stroke_=t.stroke!==void 0?t.stroke:null,this.offsetX_=t.offsetX!==void 0?t.offsetX:0,this.offsetY_=t.offsetY!==void 0?t.offsetY:0,this.backgroundFill_=t.backgroundFill?t.backgroundFill:null,this.backgroundStroke_=t.backgroundStroke?t.backgroundStroke:null,this.padding_=t.padding===void 0?null:t.padding,this.declutterMode_=t.declutterMode}clone(){let t=this.getScale();return new h({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(t)?t.slice():t,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(t){this.overflow_=t}setFont(t){this.font_=t}setMaxAngle(t){this.maxAngle_=t}setOffsetX(t){this.offsetX_=t}setOffsetY(t){this.offsetY_=t}setPlacement(t){this.placement_=t}setRepeat(t){this.repeat_=t}setRotateWithView(t){this.rotateWithView_=t}setKeepUpright(t){this.keepUpright_=t}setFill(t){this.fill_=t}setRotation(t){this.rotation_=t}setScale(t){this.scale_=t,this.scaleArray_=Hs(t!==void 0?t:1)}setStroke(t){this.stroke_=t}setText(t){this.text_=t}setTextAlign(t){this.textAlign_=t}setJustify(t){this.justify_=t}setTextBaseline(t){this.textBaseline_=t}setBackgroundFill(t){this.backgroundFill_=t}setBackgroundStroke(t){this.backgroundStroke_=t}setPadding(t){this.padding_=t}},I1=_y;var nd={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},sd=[nd.FILL],Ys=[nd.STROKE],Po=[nd.BEGIN_PATH],yy=[nd.CLOSE_PATH],wt=nd;var xy=class extends Ef{constructor(t,r,l,c){super(),this.tolerance=t,this.maxExtent=r,this.pixelRatio=c,this.maxLineWidth=0,this.resolution=l,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(t){let r=this.pixelRatio;return r==1?t:t.map(function(l){return l*r})}appendFlatPointCoordinates(t,r){let l=this.getBufferedMaxExtent(),c=this.tmpCoordinate_,n=this.coordinates,x=n.length;for(let b=0,S=t.length;b<S;b+=r)c[0]=t[b],c[1]=t[b+1],ll(l,c)&&(n[x++]=c[0],n[x++]=c[1]);return x}appendFlatLineCoordinates(t,r,l,c,n,x){let b=this.coordinates,S=b.length,R=this.getBufferedMaxExtent();x&&(r+=c);let E=t[r],A=t[r+1],z=this.tmpCoordinate_,W=!0,ne,ge,me;for(ne=r+c;ne<l;ne+=c)z[0]=t[ne],z[1]=t[ne+1],me=qp(R,z),me!==ge?(W&&(b[S++]=E,b[S++]=A,W=!1),b[S++]=z[0],b[S++]=z[1]):me===Ji.INTERSECTING?(b[S++]=z[0],b[S++]=z[1],W=!1):W=!0,E=z[0],A=z[1],ge=me;return(n&&W||ne===r+c)&&(b[S++]=E,b[S++]=A),S}drawCustomCoordinates_(t,r,l,c,n){for(let x=0,b=l.length;x<b;++x){let S=l[x],R=this.appendFlatLineCoordinates(t,r,S,c,!1,!1);n.push(R),r=S}return r}drawCustom(t,r,l,c,n){this.beginGeometry(t,r,n);let x=t.getType(),b=t.getStride(),S=this.coordinates.length,R,E,A,z,W;switch(x){case"MultiPolygon":R=t.getOrientedFlatCoordinates(),z=[];let ne=t.getEndss();W=0;for(let ge=0,me=ne.length;ge<me;++ge){let ve=[];W=this.drawCustomCoordinates_(R,W,ne[ge],b,ve),z.push(ve)}this.instructions.push([wt.CUSTOM,S,z,t,l,Fu,n]),this.hitDetectionInstructions.push([wt.CUSTOM,S,z,t,c||l,Fu,n]);break;case"Polygon":case"MultiLineString":A=[],R=x=="Polygon"?t.getOrientedFlatCoordinates():t.getFlatCoordinates(),W=this.drawCustomCoordinates_(R,0,t.getEnds(),b,A),this.instructions.push([wt.CUSTOM,S,A,t,l,ha,n]),this.hitDetectionInstructions.push([wt.CUSTOM,S,A,t,c||l,ha,n]);break;case"LineString":case"Circle":R=t.getFlatCoordinates(),E=this.appendFlatLineCoordinates(R,0,R.length,b,!1,!1),this.instructions.push([wt.CUSTOM,S,E,t,l,es,n]),this.hitDetectionInstructions.push([wt.CUSTOM,S,E,t,c||l,es,n]);break;case"MultiPoint":R=t.getFlatCoordinates(),E=this.appendFlatPointCoordinates(R,b),E>S&&(this.instructions.push([wt.CUSTOM,S,E,t,l,es,n]),this.hitDetectionInstructions.push([wt.CUSTOM,S,E,t,c||l,es,n]));break;case"Point":R=t.getFlatCoordinates(),this.coordinates.push(R[0],R[1]),E=this.coordinates.length,this.instructions.push([wt.CUSTOM,S,E,t,l,void 0,n]),this.hitDetectionInstructions.push([wt.CUSTOM,S,E,t,c||l,void 0,n]);break;default:}this.endGeometry(r)}beginGeometry(t,r,l){this.beginGeometryInstruction1_=[wt.BEGIN_GEOMETRY,r,0,t,l],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[wt.BEGIN_GEOMETRY,r,0,t,l],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let t=this.hitDetectionInstructions;t.reverse();let r,l=t.length,c,n,x=-1;for(r=0;r<l;++r)c=t[r],n=c[0],n==wt.END_GEOMETRY?x=r:n==wt.BEGIN_GEOMETRY&&(c[2]=r,Uv(this.hitDetectionInstructions,x,r),x=-1)}fillStyleToState(t,r={}){if(t){let l=t.getColor();r.fillPatternScale=l&&typeof l=="object"&&"src"in l?this.pixelRatio:1,r.fillStyle=wn(l||ar)}else r.fillStyle=void 0;return r}strokeStyleToState(t,r={}){if(t){let l=t.getColor();r.strokeStyle=wn(l||Co);let c=t.getLineCap();r.lineCap=c!==void 0?c:Ws;let n=t.getLineDash();r.lineDash=n?n.slice():Sn;let x=t.getLineDashOffset();r.lineDashOffset=x||Tn;let b=t.getLineJoin();r.lineJoin=b!==void 0?b:$s;let S=t.getWidth();r.lineWidth=S!==void 0?S:Io;let R=t.getMiterLimit();r.miterLimit=R!==void 0?R:To,r.lineWidth>this.maxLineWidth&&(this.maxLineWidth=r.lineWidth,this.bufferedMaxExtent_=null)}else r.strokeStyle=void 0,r.lineCap=void 0,r.lineDash=null,r.lineDashOffset=void 0,r.lineJoin=void 0,r.lineWidth=void 0,r.miterLimit=void 0;return r}setFillStrokeStyle(t,r){let l=this.state;this.fillStyleToState(t,l),this.strokeStyleToState(r,l)}createFill(t){let r=t.fillStyle,l=[wt.SET_FILL_STYLE,r];return typeof r!="string"&&l.push(t.fillPatternScale),l}applyStroke(t){this.instructions.push(this.createStroke(t))}createStroke(t){return[wt.SET_STROKE_STYLE,t.strokeStyle,t.lineWidth*this.pixelRatio,t.lineCap,t.lineJoin,t.miterLimit,t.lineDash?this.applyPixelRatio(t.lineDash):null,t.lineDashOffset*this.pixelRatio]}updateFillStyle(t,r){let l=t.fillStyle;(typeof l!="string"||t.currentFillStyle!=l)&&(l!==void 0&&this.instructions.push(r.call(this,t)),t.currentFillStyle=l)}updateStrokeStyle(t,r){let l=t.strokeStyle,c=t.lineCap,n=t.lineDash,x=t.lineDashOffset,b=t.lineJoin,S=t.lineWidth,R=t.miterLimit;(t.currentStrokeStyle!=l||t.currentLineCap!=c||n!=t.currentLineDash&&!yn(t.currentLineDash,n)||t.currentLineDashOffset!=x||t.currentLineJoin!=b||t.currentLineWidth!=S||t.currentMiterLimit!=R)&&(l!==void 0&&r.call(this,t),t.currentStrokeStyle=l,t.currentLineCap=c,t.currentLineDash=n,t.currentLineDashOffset=x,t.currentLineJoin=b,t.currentLineWidth=S,t.currentMiterLimit=R)}endGeometry(t){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let r=[wt.END_GEOMETRY,t];this.instructions.push(r),this.hitDetectionInstructions.push(r)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Lv(this.maxExtent),this.maxLineWidth>0)){let t=this.resolution*(this.maxLineWidth+1)/2;Kn(this.bufferedMaxExtent_,t,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Ks=xy;var vy=class extends Ks{constructor(t,r,l,c){super(t,r,l,c),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(t,r,l){if(!this.image_||this.maxExtent&&!ll(this.maxExtent,t.getFlatCoordinates()))return;this.beginGeometry(t,r,l);let c=t.getFlatCoordinates(),n=t.getStride(),x=this.coordinates.length,b=this.appendFlatPointCoordinates(c,n);this.instructions.push([wt.DRAW_IMAGE,x,b,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([wt.DRAW_IMAGE,x,b,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}drawMultiPoint(t,r,l){if(!this.image_)return;this.beginGeometry(t,r,l);let c=t.getFlatCoordinates(),n=[];for(let S=0,R=c.length;S<R;S+=t.getStride())(!this.maxExtent||ll(this.maxExtent,c.slice(S,S+2)))&&n.push(c[S],c[S+1]);let x=this.coordinates.length,b=this.appendFlatPointCoordinates(n,2);this.instructions.push([wt.DRAW_IMAGE,x,b,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([wt.DRAW_IMAGE,x,b,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(t,r){let l=t.getAnchor(),c=t.getSize(),n=t.getOrigin();this.imagePixelRatio_=t.getPixelRatio(this.pixelRatio),this.anchorX_=l[0],this.anchorY_=l[1],this.hitDetectionImage_=t.getHitDetectionImage(),this.image_=t.getImage(this.pixelRatio),this.height_=c[1],this.opacity_=t.getOpacity(),this.originX_=n[0],this.originY_=n[1],this.rotateWithView_=t.getRotateWithView(),this.rotation_=t.getRotation(),this.scale_=t.getScaleArray(),this.width_=c[0],this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=r}},E1=vy;var by=class extends Ks{constructor(t,r,l,c){super(t,r,l,c)}drawFlatCoordinates_(t,r,l,c){let n=this.coordinates.length,x=this.appendFlatLineCoordinates(t,r,l,c,!1,!1),b=[wt.MOVE_TO_LINE_TO,n,x];return this.instructions.push(b),this.hitDetectionInstructions.push(b),l}drawLineString(t,r,l){let c=this.state,n=c.strokeStyle,x=c.lineWidth;if(n===void 0||x===void 0)return;this.updateStrokeStyle(c,this.applyStroke),this.beginGeometry(t,r,l),this.hitDetectionInstructions.push([wt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,Sn,Tn],Po);let b=t.getFlatCoordinates(),S=t.getStride();this.drawFlatCoordinates_(b,0,b.length,S),this.hitDetectionInstructions.push(Ys),this.endGeometry(r)}drawMultiLineString(t,r,l){let c=this.state,n=c.strokeStyle,x=c.lineWidth;if(n===void 0||x===void 0)return;this.updateStrokeStyle(c,this.applyStroke),this.beginGeometry(t,r,l),this.hitDetectionInstructions.push([wt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,Sn,Tn],Po);let b=t.getEnds(),S=t.getFlatCoordinates(),R=t.getStride(),E=0;for(let A=0,z=b.length;A<z;++A)E=this.drawFlatCoordinates_(S,E,b[A],R);this.hitDetectionInstructions.push(Ys),this.endGeometry(r)}finish(){let t=this.state;return t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&this.instructions.push(Ys),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(t){t.lastStroke!=null&&t.lastStroke!=this.coordinates.length&&(this.instructions.push(Ys),t.lastStroke=this.coordinates.length),t.lastStroke=0,super.applyStroke(t),this.instructions.push(Po)}},P1=by;var wy=class extends Ks{constructor(t,r,l,c){super(t,r,l,c)}drawFlatCoordinatess_(t,r,l,c){let n=this.state,x=n.fillStyle!==void 0,b=n.strokeStyle!==void 0,S=l.length;this.instructions.push(Po),this.hitDetectionInstructions.push(Po);for(let R=0;R<S;++R){let E=l[R],A=this.coordinates.length,z=this.appendFlatLineCoordinates(t,r,E,c,!0,!b),W=[wt.MOVE_TO_LINE_TO,A,z];this.instructions.push(W),this.hitDetectionInstructions.push(W),b&&(this.instructions.push(yy),this.hitDetectionInstructions.push(yy)),r=E}return x&&(this.instructions.push(sd),this.hitDetectionInstructions.push(sd)),b&&(this.instructions.push(Ys),this.hitDetectionInstructions.push(Ys)),r}drawCircle(t,r,l){let c=this.state,n=c.fillStyle,x=c.strokeStyle;if(n===void 0&&x===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,r,l),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([wt.SET_FILL_STYLE,ar]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([wt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,Sn,Tn]);let b=t.getFlatCoordinates(),S=t.getStride(),R=this.coordinates.length;this.appendFlatLineCoordinates(b,0,b.length,S,!1,!1);let E=[wt.CIRCLE,R];this.instructions.push(Po,E),this.hitDetectionInstructions.push(Po,E),c.fillStyle!==void 0&&(this.instructions.push(sd),this.hitDetectionInstructions.push(sd)),c.strokeStyle!==void 0&&(this.instructions.push(Ys),this.hitDetectionInstructions.push(Ys)),this.endGeometry(r)}drawPolygon(t,r,l){let c=this.state,n=c.fillStyle,x=c.strokeStyle;if(n===void 0&&x===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,r,l),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([wt.SET_FILL_STYLE,ar]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([wt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,Sn,Tn]);let b=t.getEnds(),S=t.getOrientedFlatCoordinates(),R=t.getStride();this.drawFlatCoordinatess_(S,0,b,R),this.endGeometry(r)}drawMultiPolygon(t,r,l){let c=this.state,n=c.fillStyle,x=c.strokeStyle;if(n===void 0&&x===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(t,r,l),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([wt.SET_FILL_STYLE,ar]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([wt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,Sn,Tn]);let b=t.getEndss(),S=t.getOrientedFlatCoordinates(),R=t.getStride(),E=0;for(let A=0,z=b.length;A<z;++A)E=this.drawFlatCoordinatess_(S,E,b[A],R);this.endGeometry(r)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let t=this.tolerance;if(t!==0){let r=this.coordinates;for(let l=0,c=r.length;l<c;++l)r[l]=ua(r[l],t)}return super.finish()}setFillStrokeStyles_(){let t=this.state;t.fillStyle!==void 0&&this.updateFillStyle(t,this.createFill),t.strokeStyle!==void 0&&this.updateStrokeStyle(t,this.applyStroke)}},Sy=wy;function R1(h,t,r,l,c){let n=[],x=r,b=0,S=t.slice(r,2);for(;b<h&&x+c<l;){let[R,E]=S.slice(-2),A=t[x+c],z=t[x+c+1],W=Math.sqrt((A-R)*(A-R)+(z-E)*(z-E));if(b+=W,b>=h){let ne=(h-b+W)/W,ge=Pr(R,A,ne),me=Pr(E,z,ne);S.push(ge,me),n.push(S),S=[ge,me],b==h&&(x+=c),b=0}else if(b<h)S.push(t[x+c],t[x+c+1]),x+=c;else{let ne=W-b,ge=Pr(R,A,ne/W),me=Pr(E,z,ne/W);S.push(ge,me),n.push(S),S=[ge,me],b=0,x+=c}}return b>0&&n.push(S),n}function A1(h,t,r,l,c){let n=r,x=r,b=0,S=0,R=r,E,A,z,W,ne,ge,me,ve,Te,Oe;for(A=r;A<l;A+=c){let Pe=t[A],ze=t[A+1];ne!==void 0&&(Te=Pe-ne,Oe=ze-ge,W=Math.sqrt(Te*Te+Oe*Oe),me!==void 0&&(S+=z,E=Math.acos((me*Te+ve*Oe)/(z*W)),E>h&&(S>b&&(b=S,n=R,x=A),S=0,R=A-c)),z=W,me=Te,ve=Oe),ne=Pe,ge=ze}return S+=W,S>b?[R,A]:[n,x]}var od={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Ty=class extends Ks{constructor(t,r,l,c){super(t,r,l,c),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[ar]={fillStyle:ar},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let t=super.finish();return t.textStates=this.textStates,t.fillStates=this.fillStates,t.strokeStates=this.strokeStates,t}drawText(t,r,l){let c=this.textFillState_,n=this.textStrokeState_,x=this.textState_;if(this.text_===""||!x||!c&&!n)return;let b=this.coordinates,S=b.length,R=t.getType(),E=null,A=t.getStride();if(x.placement==="line"&&(R=="LineString"||R=="MultiLineString"||R=="Polygon"||R=="MultiPolygon")){if(!Qi(this.maxExtent,t.getExtent()))return;let z;if(E=t.getFlatCoordinates(),R=="LineString")z=[E.length];else if(R=="MultiLineString")z=t.getEnds();else if(R=="Polygon")z=t.getEnds().slice(0,1);else if(R=="MultiPolygon"){let me=t.getEndss();z=[];for(let ve=0,Te=me.length;ve<Te;++ve)z.push(me[ve][0])}this.beginGeometry(t,r,l);let W=x.repeat,ne=W?void 0:x.textAlign,ge=0;for(let me=0,ve=z.length;me<ve;++me){let Te;W?Te=R1(W*this.resolution,E,ge,z[me],A):Te=[E.slice(ge,z[me])];for(let Oe=0,Pe=Te.length;Oe<Pe;++Oe){let ze=Te[Oe],Me=0,et=ze.length;if(ne==null){let Je=A1(x.maxAngle,ze,0,ze.length,2);Me=Je[0],et=Je[1]}for(let Je=Me;Je<et;Je+=A)b.push(ze[Je],ze[Je+1]);let tt=b.length;ge=z[me],this.drawChars_(S,tt),S=tt}}this.endGeometry(r)}else{let z=x.overflow?null:[];switch(R){case"Point":case"MultiPoint":E=t.getFlatCoordinates();break;case"LineString":E=t.getFlatMidpoint();break;case"Circle":E=t.getCenter();break;case"MultiLineString":E=t.getFlatMidpoints(),A=2;break;case"Polygon":E=t.getFlatInteriorPoint(),x.overflow||z.push(E[2]/this.resolution),A=3;break;case"MultiPolygon":let Pe=t.getFlatInteriorPoints();E=[];for(let ze=0,Me=Pe.length;ze<Me;ze+=3)x.overflow||z.push(Pe[ze+2]/this.resolution),E.push(Pe[ze],Pe[ze+1]);if(E.length===0)return;A=2;break;default:}let W=this.appendFlatPointCoordinates(E,A);if(W===S)return;if(z&&(W-S)/2!==E.length/A){let Pe=S/2;z=z.filter((ze,Me)=>{let et=b[(Pe+Me)*2]===E[Me*A]&&b[(Pe+Me)*2+1]===E[Me*A+1];return et||--Pe,et})}this.saveTextStates_();let ne=x.backgroundFill?this.createFill(this.fillStyleToState(x.backgroundFill)):null,ge=x.backgroundStroke?this.createStroke(this.strokeStyleToState(x.backgroundStroke)):null;this.beginGeometry(t,r,l);let me=x.padding;if(me!=Mo&&(x.scale[0]<0||x.scale[1]<0)){let Pe=x.padding[0],ze=x.padding[1],Me=x.padding[2],et=x.padding[3];x.scale[0]<0&&(ze=-ze,et=-et),x.scale[1]<0&&(Pe=-Pe,Me=-Me),me=[Pe,ze,Me,et]}let ve=this.pixelRatio;this.instructions.push([wt.DRAW_IMAGE,S,W,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,me==Mo?Mo:me.map(function(Pe){return Pe*ve}),ne,ge,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,z]);let Te=1/ve,Oe=ne?ne.slice(0):null;Oe&&(Oe[1]=ar),this.hitDetectionInstructions.push([wt.DRAW_IMAGE,S,W,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[Te,Te],NaN,this.declutterMode_,this.declutterImageWithText_,me,Oe,ge,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?ar:this.fillKey_,this.textOffsetX_,this.textOffsetY_,z]),this.endGeometry(r)}}saveTextStates_(){let t=this.textStrokeState_,r=this.textState_,l=this.textFillState_,c=this.strokeKey_;t&&(c in this.strokeStates||(this.strokeStates[c]={strokeStyle:t.strokeStyle,lineCap:t.lineCap,lineDashOffset:t.lineDashOffset,lineWidth:t.lineWidth,lineJoin:t.lineJoin,miterLimit:t.miterLimit,lineDash:t.lineDash}));let n=this.textKey_;n in this.textStates||(this.textStates[n]={font:r.font,textAlign:r.textAlign||ma,justify:r.justify,textBaseline:r.textBaseline||xl,scale:r.scale});let x=this.fillKey_;l&&(x in this.fillStates||(this.fillStates[x]={fillStyle:l.fillStyle}))}drawChars_(t,r){let l=this.textStrokeState_,c=this.textState_,n=this.strokeKey_,x=this.textKey_,b=this.fillKey_;this.saveTextStates_();let S=this.pixelRatio,R=od[c.textBaseline],E=this.textOffsetY_*S,A=this.text_,z=l?l.lineWidth*Math.abs(c.scale[0])/2:0;this.instructions.push([wt.DRAW_CHARS,t,r,R,c.overflow,b,c.maxAngle,S,E,n,z*S,A,x,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([wt.DRAW_CHARS,t,r,R,c.overflow,b&&ar,c.maxAngle,S,E,n,z*S,A,x,1/S,this.declutterMode_,this.textKeepUpright_])}setTextStyle(t,r){let l,c,n;if(!t)this.text_="";else{let x=t.getFill();x?(c=this.textFillState_,c||(c={},this.textFillState_=c),c.fillStyle=wn(x.getColor()||ar)):(c=null,this.textFillState_=c);let b=t.getStroke();if(!b)n=null,this.textStrokeState_=n;else{n=this.textStrokeState_,n||(n={},this.textStrokeState_=n);let ge=b.getLineDash(),me=b.getLineDashOffset(),ve=b.getWidth(),Te=b.getMiterLimit();n.lineCap=b.getLineCap()||Ws,n.lineDash=ge?ge.slice():Sn,n.lineDashOffset=me===void 0?Tn:me,n.lineJoin=b.getLineJoin()||$s,n.lineWidth=ve===void 0?Io:ve,n.miterLimit=Te===void 0?To:Te,n.strokeStyle=wn(b.getColor()||Co)}l=this.textState_;let S=t.getFont()||Rf;d1(S);let R=t.getScaleArray();l.overflow=t.getOverflow(),l.font=S,l.maxAngle=t.getMaxAngle(),l.placement=t.getPlacement(),l.textAlign=t.getTextAlign(),l.repeat=t.getRepeat(),l.justify=t.getJustify(),l.textBaseline=t.getTextBaseline()||xl,l.backgroundFill=t.getBackgroundFill(),l.backgroundStroke=t.getBackgroundStroke(),l.padding=t.getPadding()||Mo,l.scale=R===void 0?[1,1]:R;let E=t.getOffsetX(),A=t.getOffsetY(),z=t.getRotateWithView(),W=t.getKeepUpright(),ne=t.getRotation();this.text_=t.getText()||"",this.textOffsetX_=E===void 0?0:E,this.textOffsetY_=A===void 0?0:A,this.textRotateWithView_=z===void 0?!1:z,this.textKeepUpright_=W===void 0?!0:W,this.textRotation_=ne===void 0?0:ne,this.strokeKey_=n?(typeof n.strokeStyle=="string"?n.strokeStyle:Vt(n.strokeStyle))+n.lineCap+n.lineDashOffset+"|"+n.lineWidth+n.lineJoin+n.miterLimit+"["+n.lineDash.join()+"]":"",this.textKey_=l.font+l.scale+(l.textAlign||"?")+(l.repeat||"?")+(l.justify||"?")+(l.textBaseline||"?"),this.fillKey_=c&&c.fillStyle?typeof c.fillStyle=="string"?c.fillStyle:"|"+Vt(c.fillStyle):""}this.declutterMode_=t.getDeclutterMode(),this.declutterImageWithText_=r}},L1=Ty;var DC={Circle:Sy,Default:Ks,Image:E1,LineString:P1,Polygon:Sy,Text:L1},Cy=class{constructor(t,r,l,c){this.tolerance_=t,this.maxExtent_=r,this.pixelRatio_=c,this.resolution_=l,this.buildersByZIndex_={}}finish(){let t={};for(let r in this.buildersByZIndex_){t[r]=t[r]||{};let l=this.buildersByZIndex_[r];for(let c in l){let n=l[c].finish();t[r][c]=n}}return t}getBuilder(t,r){let l=t!==void 0?t.toString():"0",c=this.buildersByZIndex_[l];c===void 0&&(c={},this.buildersByZIndex_[l]=c);let n=c[r];if(n===void 0){let x=DC[r];n=new x(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),c[r]=n}return n}},k1=Cy;function D1(h,t,r,l,c,n,x,b,S,R,E,A,z=!0){let W=h[t],ne=h[t+1],ge=0,me=0,ve=0,Te=0;function Oe(){ge=W,me=ne,t+=l,W=h[t],ne=h[t+1],Te+=ve,ve=Math.sqrt((W-ge)*(W-ge)+(ne-me)*(ne-me))}do Oe();while(t<r-l&&Te+ve<n);let Pe=ve===0?0:(n-Te)/ve,ze=Pr(ge,W,Pe),Me=Pr(me,ne,Pe),et=t-l,tt=Te,Je=n+b*S(R,c,E);for(;t<r-l&&Te+ve<Je;)Oe();Pe=ve===0?0:(Je-Te)/ve;let st=Pr(ge,W,Pe),bt=Pr(me,ne,Pe),lt=!1;if(z)if(A){let ht=[ze,Me,st,bt];hf(ht,0,4,2,A,ht,ht),lt=ht[0]>ht[2]}else lt=ze>st;let Tt=Math.PI,ct=[],yt=et+l===t;t=et,ve=0,Te=tt,W=h[t],ne=h[t+1];let xt;if(yt){Oe(),xt=Math.atan2(ne-me,W-ge),lt&&(xt+=xt>0?-Tt:Tt);let ht=(st+ze)/2,vt=(bt+Me)/2;return ct[0]=[ht,vt,(Je-n)/2,xt,c],ct}c=c.replace(/\n/g," ");for(let ht=0,vt=c.length;ht<vt;){Oe();let Nt=Math.atan2(ne-me,W-ge);if(lt&&(Nt+=Nt>0?-Tt:Tt),xt!==void 0){let bi=Nt-xt;if(bi+=bi>Tt?-2*Tt:bi<-Tt?2*Tt:0,Math.abs(bi)>x)return null}xt=Nt;let Ot=ht,At=0;for(;ht<vt;++ht){let bi=lt?vt-ht-1:ht,$i=b*S(R,c[bi],E);if(t+l<r&&Te+ve<n+At+$i/2)break;At+=$i}if(ht===Ot)continue;let Xe=lt?c.substring(vt-Ot,vt-ht):c.substring(Ot,ht);Pe=ve===0?0:(n+At/2-Te)/ve;let ei=Pr(ge,W,Pe),br=Pr(me,ne,Pe);ct.push([ei,br,At/2,Nt,Xe]),n+=At}return ct}var My=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(Gc(),{get:(t,r)=>{if(typeof Gc()[r]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r),this.pushMethodArgs_},set:(t,r,l)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r,l),!0)})}pushMethodArgs_=(...t)=>(this.instructions_[this.zIndex+this.offset_].push(t),this);pushFunction(t){this.instructions_[this.zIndex+this.offset_].push(t)}getContext(){return this.context_}draw(t){this.instructions_.forEach(r=>{for(let l=0,c=r.length;l<c;++l){let n=r[l];if(typeof n=="function"){n(t);continue}let x=r[++l];if(typeof t[n]=="function")t[n](...x);else{if(typeof x=="function"){t[n]=x(t);continue}t[n]=x}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},zf=My;var Wc=_n(),_a=[],Ro=[],Ao=[],ya=[];function F1(h){return h[3].declutterBox}var z1=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function Iy(h,t){return t==="start"?t=z1.test(h)?"right":"left":t==="end"&&(t=z1.test(h)?"left":"right"),od[t]}function FC(h,t,r){return r>0&&h.push(`
731
731
  `,""),h.push(t,""),h}var Ey=class{constructor(t,r,l,c,n){this.overlaps=l,this.pixelRatio=r,this.resolution=t,this.alignAndScaleFill_,this.instructions=c.instructions,this.coordinates=c.coordinates,this.coordinateCache_={},this.renderedTransform_=mr(),this.hitDetectionInstructions=c.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=c.fillStates||{},this.strokeStates=c.strokeStates||{},this.textStates=c.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=n?new zf:null}getZIndexContext(){return this.zIndexContext_}createLabel(t,r,l,c){let n=t+r+l+c;if(this.labels_[n])return this.labels_[n];let x=c?this.strokeStates[c]:null,b=l?this.fillStates[l]:null,S=this.textStates[r],R=this.pixelRatio,E=[S.scale[0]*R,S.scale[1]*R],A=S.justify?od[S.justify]:Iy(Array.isArray(t)?t[0]:t,S.textAlign||ma),z=c&&x.lineWidth?x.lineWidth:0,W=Array.isArray(t)?t:String(t).split(`
732
732
  `).reduce(FC,[]),{width:ne,height:ge,widths:me,heights:ve,lineWidths:Te}=f1(S,W),Oe=ne+z,Pe=[],ze=(Oe+2)*E[0],Me=(ge+z)*E[1],et={width:ze<0?Math.floor(ze):Math.ceil(ze),height:Me<0?Math.floor(Me):Math.ceil(Me),contextInstructions:Pe};(E[0]!=1||E[1]!=1)&&Pe.push("scale",E),c&&(Pe.push("strokeStyle",x.strokeStyle),Pe.push("lineWidth",z),Pe.push("lineCap",x.lineCap),Pe.push("lineJoin",x.lineJoin),Pe.push("miterLimit",x.miterLimit),Pe.push("setLineDash",[x.lineDash]),Pe.push("lineDashOffset",x.lineDashOffset)),l&&Pe.push("fillStyle",b.fillStyle),Pe.push("textBaseline","middle"),Pe.push("textAlign","center");let tt=.5-A,Je=A*Oe+tt*z,st=[],bt=[],lt=0,Tt=0,ct=0,yt=0,xt;for(let ht=0,vt=W.length;ht<vt;ht+=2){let Nt=W[ht];if(Nt===`
733
- `){Tt+=lt,lt=0,Je=A*Oe+tt*z,++yt;continue}let Ot=W[ht+1]||S.font;Ot!==xt&&(c&&st.push("font",Ot),l&&bt.push("font",Ot),xt=Ot),lt=Math.max(lt,ve[ct]);let At=[Nt,Je+tt*me[ct]+A*(me[ct]-Te[yt]),.5*(z+lt)+Tt];Je+=me[ct],c&&st.push("strokeText",At),l&&bt.push("fillText",At),++ct}return Array.prototype.push.apply(Pe,st),Array.prototype.push.apply(Pe,bt),this.labels_[n]=et,et}replayTextBackground_(t,r,l,c,n,x,b){t.beginPath(),t.moveTo.apply(t,r),t.lineTo.apply(t,l),t.lineTo.apply(t,c),t.lineTo.apply(t,n),t.lineTo.apply(t,r),x&&(this.alignAndScaleFill_=x[2],t.fillStyle=x[1],this.fill_(t)),b&&(this.setStrokeStyle_(t,b),t.stroke())}calculateImageOrLabelDimensions_(t,r,l,c,n,x,b,S,R,E,A,z,W,ne,ge,me){b*=z[0],S*=z[1];let ve=l-b,Te=c-S,Oe=n+R>t?t-R:n,Pe=x+E>r?r-E:x,ze=ne[3]+Oe*z[0]+ne[1],Me=ne[0]+Pe*z[1]+ne[2],et=ve-ne[3],tt=Te-ne[0];(ge||A!==0)&&(_a[0]=et,ya[0]=et,_a[1]=tt,Ro[1]=tt,Ro[0]=et+ze,Ao[0]=Ro[0],Ao[1]=tt+Me,ya[1]=Ao[1]);let Je;return A!==0?(Je=Ur(mr(),l,c,1,1,A,-l,-c),Mr(Je,_a),Mr(Je,Ro),Mr(Je,Ao),Mr(Je,ya),bo(Math.min(_a[0],Ro[0],Ao[0],ya[0]),Math.min(_a[1],Ro[1],Ao[1],ya[1]),Math.max(_a[0],Ro[0],Ao[0],ya[0]),Math.max(_a[1],Ro[1],Ao[1],ya[1]),Wc)):bo(Math.min(et,et+ze),Math.min(tt,tt+Me),Math.max(et,et+ze),Math.max(tt,tt+Me),Wc),W&&(ve=Math.round(ve),Te=Math.round(Te)),{drawImageX:ve,drawImageY:Te,drawImageW:Oe,drawImageH:Pe,originX:R,originY:E,declutterBox:{minX:Wc[0],minY:Wc[1],maxX:Wc[2],maxY:Wc[3],value:me},canvasTransform:Je,scale:z}}replayImageOrLabel_(t,r,l,c,n,x,b){let S=!!(x||b),R=c.declutterBox,E=b?b[2]*c.scale[0]/2:0;return R.minX-E<=r[0]&&R.maxX+E>=0&&R.minY-E<=r[1]&&R.maxY+E>=0&&(S&&this.replayTextBackground_(t,_a,Ro,Ao,ya,x,b),m1(t,c.canvasTransform,n,l,c.originX,c.originY,c.drawImageW,c.drawImageH,c.drawImageX,c.drawImageY,c.scale)),!0}fill_(t){let r=this.alignAndScaleFill_;if(r){let l=Mr(this.renderedTransform_,[0,0]),c=512*this.pixelRatio;t.save(),t.translate(l[0]%c,l[1]%c),r!==1&&t.scale(r,r),t.rotate(this.viewRotation_)}t.fill(),r&&t.restore()}setStrokeStyle_(t,r){t.strokeStyle=r[1],t.lineWidth=r[2],t.lineCap=r[3],t.lineJoin=r[4],t.miterLimit=r[5],t.lineDashOffset=r[7],t.setLineDash(r[6])}drawLabelWithPointPlacement_(t,r,l,c){let n=this.textStates[r],x=this.createLabel(t,r,c,l),b=this.strokeStates[l],S=this.pixelRatio,R=Iy(Array.isArray(t)?t[0]:t,n.textAlign||ma),E=od[n.textBaseline||xl],A=b&&b.lineWidth?b.lineWidth:0,z=x.width/S-2*n.scale[0],W=R*z+2*(.5-R)*A,ne=E*x.height/S+2*(.5-E)*A;return{label:x,anchorX:W,anchorY:ne}}execute_(t,r,l,c,n,x,b,S){let R=this.zIndexContext_,E;this.pixelCoordinates_&&yn(l,this.renderedTransform_)?E=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),E=xn(this.coordinates,0,this.coordinates.length,2,l,this.pixelCoordinates_),Pv(this.renderedTransform_,l));let A=0,z=c.length,W=0,ne,ge,me,ve,Te,Oe,Pe,ze,Me,et,tt,Je,st,bt=0,lt=0,Tt=this.coordinateCache_,ct=this.viewRotation_,yt=Math.round(Math.atan2(-l[1],l[0])*1e12)/1e12,xt={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ct},ht=this.instructions!=c||this.overlaps?0:200,vt,Nt,Ot,At;for(;A<z;){let Xe=c[A];switch(Xe[0]){case wt.BEGIN_GEOMETRY:vt=Xe[1],At=Xe[3],vt.getGeometry()?b!==void 0&&!Qi(b,At.getExtent())?A=Xe[2]+1:++A:A=Xe[2],R&&(R.zIndex=Xe[4]);break;case wt.BEGIN_PATH:bt>ht&&(this.fill_(t),bt=0),lt>ht&&(t.stroke(),lt=0),!bt&&!lt&&(t.beginPath(),Te=NaN,Oe=NaN),++A;break;case wt.CIRCLE:W=Xe[1];let br=E[W],bi=E[W+1],$i=E[W+2],Ni=E[W+3],Fr=$i-br,pi=Ni-bi,ti=Math.sqrt(Fr*Fr+pi*pi);t.moveTo(br+ti,bi),t.arc(br,bi,ti,0,2*Math.PI,!0),++A;break;case wt.CLOSE_PATH:t.closePath(),++A;break;case wt.CUSTOM:W=Xe[1],ne=Xe[2];let on=Xe[3],fi=Xe[4],$r=Xe[5];xt.geometry=on,xt.feature=vt,A in Tt||(Tt[A]=[]);let wr=Tt[A];$r?$r(E,W,ne,2,wr):(wr[0]=E[W],wr[1]=E[W+1],wr.length=2),R&&(R.zIndex=Xe[6]),fi(wr,xt),++A;break;case wt.DRAW_IMAGE:W=Xe[1],ne=Xe[2],Me=Xe[3],ge=Xe[4],me=Xe[5];let cr=Xe[6],zr=Xe[7],Ci=Xe[8],Ai=Xe[9],Or=Xe[10],Xr=Xe[11],an=Xe[12],ln=Xe[13];ve=Xe[14]||"declutter";let Br=Xe[15];if(!Me&&Xe.length>=20){et=Xe[19],tt=Xe[20],Je=Xe[21],st=Xe[22];let he=this.drawLabelWithPointPlacement_(et,tt,Je,st);Me=he.label,Xe[3]=Me;let We=Xe[23];ge=(he.anchorX-We)*this.pixelRatio,Xe[4]=ge;let Ue=Xe[24];me=(he.anchorY-Ue)*this.pixelRatio,Xe[5]=me,cr=Me.height,Xe[6]=cr,ln=Me.width,Xe[13]=ln}let Hr;Xe.length>25&&(Hr=Xe[25]);let En,jr,cn;Xe.length>17?(En=Xe[16],jr=Xe[17],cn=Xe[18]):(En=Mo,jr=null,cn=null),Or&&yt?Xr+=ct:!Or&&!yt&&(Xr-=ct);let Vn=0;for(;W<ne;W+=2){if(Hr&&Hr[Vn++]<ln/this.pixelRatio)continue;let he=this.calculateImageOrLabelDimensions_(Me.width,Me.height,E[W],E[W+1],ln,cr,ge,me,Ci,Ai,Xr,an,n,En,!!jr||!!cn,vt),We=[t,r,Me,he,zr,jr,cn];if(S){let Ue,ot,dt;if(Br){let Ye=ne-W;if(!Br[Ye]){Br[Ye]={args:We,declutterMode:ve};continue}let mt=Br[Ye];Ue=mt.args,ot=mt.declutterMode,delete Br[Ye],dt=F1(Ue)}let Le,$e;if(Ue&&(ot!=="declutter"||!S.collides(dt))&&(Le=!0),(ve!=="declutter"||!S.collides(he.declutterBox))&&($e=!0),ot==="declutter"&&ve==="declutter"){let Ye=Le&&$e;Le=Ye,$e=Ye}Le&&(ot!=="none"&&S.insert(dt),this.replayImageOrLabel_.apply(this,Ue)),$e&&(ve!=="none"&&S.insert(he.declutterBox),this.replayImageOrLabel_.apply(this,We))}else this.replayImageOrLabel_.apply(this,We)}++A;break;case wt.DRAW_CHARS:let rs=Xe[1],ns=Xe[2],ss=Xe[3],Un=Xe[4];st=Xe[5];let K=Xe[6],U=Xe[7],$=Xe[8];Je=Xe[9];let X=Xe[10];et=Xe[11],tt=Xe[12];let re=[Xe[13],Xe[13]];ve=Xe[14]||"declutter";let ue=Xe[15],ye=this.textStates[tt],be=ye.font,_e=[ye.scale[0]*U,ye.scale[1]*U],Re;be in this.widths_?Re=this.widths_[be]:(Re={},this.widths_[be]=Re);let Ee=gf(E,rs,ns,2),xe=Math.abs(_e[0])*Q_(be,et,Re);if(Un||xe<=Ee){let he=this.textStates[tt].textAlign,We=(Ee-xe)*Iy(et,he),Ue=D1(E,rs,ns,2,et,We,K,Math.abs(_e[0]),Q_,be,Re,yt?0:this.viewRotation_,ue);e:if(Ue){let ot=[],dt,Le,$e,Ye,mt;if(Je)for(dt=0,Le=Ue.length;dt<Le;++dt){mt=Ue[dt],$e=mt[4],Ye=this.createLabel($e,tt,"",Je),ge=mt[2]+(_e[0]<0?-X:X),me=ss*Ye.height+(.5-ss)*2*X*_e[1]/_e[0]-$;let Ct=this.calculateImageOrLabelDimensions_(Ye.width,Ye.height,mt[0],mt[1],Ye.width,Ye.height,ge,me,0,0,mt[3],re,!1,Mo,!1,vt);if(S&&ve==="declutter"&&S.collides(Ct.declutterBox))break e;ot.push([t,r,Ye,Ct,1,null,null])}if(st)for(dt=0,Le=Ue.length;dt<Le;++dt){mt=Ue[dt],$e=mt[4],Ye=this.createLabel($e,tt,st,""),ge=mt[2],me=ss*Ye.height-$;let Ct=this.calculateImageOrLabelDimensions_(Ye.width,Ye.height,mt[0],mt[1],Ye.width,Ye.height,ge,me,0,0,mt[3],re,!1,Mo,!1,vt);if(S&&ve==="declutter"&&S.collides(Ct.declutterBox))break e;ot.push([t,r,Ye,Ct,1,null,null])}S&&ve!=="none"&&S.load(ot.map(F1));for(let Ct=0,gt=ot.length;Ct<gt;++Ct)this.replayImageOrLabel_.apply(this,ot[Ct])}}++A;break;case wt.END_GEOMETRY:if(x!==void 0){vt=Xe[1];let he=x(vt,At,ve);if(he)return he}++A;break;case wt.FILL:ht?bt++:this.fill_(t),++A;break;case wt.MOVE_TO_LINE_TO:for(W=Xe[1],ne=Xe[2],Nt=E[W],Ot=E[W+1],t.moveTo(Nt,Ot),Te=Nt+.5|0,Oe=Ot+.5|0,W+=2;W<ne;W+=2)Nt=E[W],Ot=E[W+1],Pe=Nt+.5|0,ze=Ot+.5|0,(W==ne-2||Pe!==Te||ze!==Oe)&&(t.lineTo(Nt,Ot),Te=Pe,Oe=ze);++A;break;case wt.SET_FILL_STYLE:this.alignAndScaleFill_=Xe[2],bt&&(this.fill_(t),bt=0,lt&&(t.stroke(),lt=0)),t.fillStyle=Xe[1],++A;break;case wt.SET_STROKE_STYLE:lt&&(t.stroke(),lt=0),this.setStrokeStyle_(t,Xe),++A;break;case wt.STROKE:ht?lt++:t.stroke(),++A;break;default:++A;break}}bt&&this.fill_(t),lt&&t.stroke()}execute(t,r,l,c,n,x){this.viewRotation_=c,this.execute_(t,r,l,this.instructions,n,void 0,void 0,x)}executeHitDetection(t,r,l,c,n){return this.viewRotation_=l,this.execute_(t,[t.canvas.width,t.canvas.height],r,this.hitDetectionInstructions,!0,c,n)}},O1=Ey;var wl=["Polygon","Circle","LineString","Image","Text","Default"],Ay=["Image","Text"],B1=wl.filter(h=>!Ay.includes(h)),Ry=class{constructor(t,r,l,c,n,x,b){this.maxExtent_=t,this.overlaps_=c,this.pixelRatio_=l,this.resolution_=r,this.renderBuffer_=x,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=mr(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(n,b)}clip(t,r){let l=this.getClipCoords(r);t.beginPath(),t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3]),t.lineTo(l[4],l[5]),t.lineTo(l[6],l[7]),t.clip()}createExecutors_(t,r){for(let l in t){let c=this.executorsByZIndex_[l];c===void 0&&(c={},this.executorsByZIndex_[l]=c);let n=t[l];for(let x in n){let b=n[x];c[x]=new O1(this.resolution_,this.pixelRatio_,this.overlaps_,b,r)}}}hasExecutors(t){for(let r in this.executorsByZIndex_){let l=this.executorsByZIndex_[r];for(let c=0,n=t.length;c<n;++c)if(t[c]in l)return!0}return!1}forEachFeatureAtCoordinate(t,r,l,c,n,x){c=Math.round(c);let b=c*2+1,S=Ur(this.hitDetectionTransform_,c+.5,c+.5,1/r,-1/r,-l,-t[0],-t[1]),R=!this.hitDetectionContext_;R&&(this.hitDetectionContext_=Oi(b,b,void 0,{willReadFrequently:!0}));let E=this.hitDetectionContext_;E.canvas.width!==b||E.canvas.height!==b?(E.canvas.width=b,E.canvas.height=b):R||E.clearRect(0,0,b,b);let A;this.renderBuffer_!==void 0&&(A=_n(),Lg(A,t),Kn(A,r*(this.renderBuffer_+c),A));let z=zC(c),W;function ne(ze,Me,et){let tt=E.getImageData(0,0,b,b).data;for(let Je=0,st=z.length;Je<st;Je++)if(tt[z[Je]]>0){if(!x||et==="none"||W!=="Image"&&W!=="Text"||x.includes(ze)){let bt=(z[Je]-3)/4,lt=c-bt%b,Tt=c-(bt/b|0),ct=n(ze,Me,lt*lt+Tt*Tt);if(ct)return ct}E.clearRect(0,0,b,b);break}}let ge=Object.keys(this.executorsByZIndex_).map(Number);ge.sort(vs);let me,ve,Te,Oe,Pe;for(me=ge.length-1;me>=0;--me){let ze=ge[me].toString();for(Te=this.executorsByZIndex_[ze],ve=wl.length-1;ve>=0;--ve)if(W=wl[ve],Oe=Te[W],Oe!==void 0&&(Pe=Oe.executeHitDetection(E,S,l,ne,A),Pe))return Pe}}getClipCoords(t){let r=this.maxExtent_;if(!r)return null;let l=r[0],c=r[1],n=r[2],x=r[3],b=[l,c,l,x,n,x,n,c];return xn(b,0,8,2,t,b),b}isEmpty(){return On(this.executorsByZIndex_)}execute(t,r,l,c,n,x,b){let S=Object.keys(this.executorsByZIndex_).map(Number);S.sort(b?Vv:vs),x=x||wl;let R=wl.length;for(let E=0,A=S.length;E<A;++E){let z=S[E].toString(),W=this.executorsByZIndex_[z];for(let ne=0,ge=x.length;ne<ge;++ne){let me=x[ne],ve=W[me];if(ve!==void 0){let Te=b===null?void 0:ve.getZIndexContext(),Oe=Te?Te.getContext():t,Pe=this.maxExtent_&&me!=="Image"&&me!=="Text";if(Pe&&(Oe.save(),this.clip(Oe,l)),!Te||me==="Text"||me==="Image"?ve.execute(Oe,r,l,c,n,b):Te.pushFunction(ze=>ve.execute(ze,r,l,c,n,b)),Pe&&Oe.restore(),Te){Te.offset();let ze=S[E]*R+ne;this.deferredZIndexContexts_[ze]||(this.deferredZIndexContexts_[ze]=[]),this.deferredZIndexContexts_[ze].push(Te)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let t=this.deferredZIndexContexts_,r=Object.keys(t).map(Number).sort(vs);for(let l=0,c=r.length;l<c;++l)t[r[l]].forEach(n=>{n.draw(this.renderedContext_),n.clear()}),t[r[l]].length=0}},Py={};function zC(h){if(Py[h]!==void 0)return Py[h];let t=h*2+1,r=h*h,l=new Array(r+1);for(let n=0;n<=h;++n)for(let x=0;x<=h;++x){let b=n*n+x*x;if(b>r)break;let S=l[b];S||(S=[],l[b]=S),S.push(((h+n)*t+(h+x))*4+3),n>0&&S.push(((h-n)*t+(h+x))*4+3),x>0&&(S.push(((h+n)*t+(h-x))*4+3),n>0&&S.push(((h-n)*t+(h-x))*4+3))}let c=[];for(let n=0,x=l.length;n<x;++n)l[n]&&c.push(...l[n]);return Py[h]=c,c}var j1=Ry;function N1(h,t,r,l){return r!==void 0&&l!==void 0?[r/h,l/t]:r!==void 0?r/h:l!==void 0?l/t:1}var Ly=class h extends Df{constructor(t){t=t||{};let r=t.opacity!==void 0?t.opacity:1,l=t.rotation!==void 0?t.rotation:0,c=t.scale!==void 0?t.scale:1,n=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:r,rotation:l,scale:c,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:n,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;let x=t.img!==void 0?t.img:null,b=t.src;di(!(b!==void 0&&x),"`image` and `src` cannot be provided at the same time"),(b===void 0||b.length===0)&&x&&(b=x.src||Vt(x)),di(b!==void 0&&b.length>0,"A defined and non-empty `src` or `image` must be provided"),di(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let S;if(t.src!==void 0?S=Mt.IDLE:x!==void 0&&("complete"in x?x.complete?S=x.src?Mt.LOADED:Mt.IDLE:S=Mt.LOADING:S=Mt.LOADED),this.color_=t.color!==void 0?Ps(t.color):null,this.iconImage_=Vc(x,b,this.crossOrigin_,S,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let R,E;if(t.size)[R,E]=t.size;else{let A=this.getImage(1);if(A.width&&A.height)R=A.width,E=A.height;else if(A instanceof HTMLImageElement){this.initialOptions_=t;let z=()=>{if(this.unlistenImageChange(z),!this.initialOptions_)return;let W=this.iconImage_.getSize();this.setScale(N1(W[0],W[1],t.width,t.height))};this.listenImageChange(z);return}}R!==void 0&&this.setScale(N1(R,E,t.width,t.height))}}clone(){let t,r,l;return this.initialOptions_?(r=this.initialOptions_.width,l=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new h({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:r,height:l,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;let c=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!c)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=c[0]),this.anchorYUnits_=="fraction"&&(t[1]*=c[1])}if(this.anchorOrigin_!="top-left"){if(!c)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+c[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+c[1])}this.normalizedAnchor_=t}let r=this.getDisplacement(),l=this.getScaleArray();return[t[0]-r[0]/l[0],t[1]+r[1]/l[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){let r=this.getSize(),l=this.iconImage_.getSize();if(!r||!l)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=l[0]-r[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=l[1]-r[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==Mt.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){let t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==Mt.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(yi.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(yi.CHANGE,t)}ready(){return this.iconImage_.ready()}},ad=Ly;var As=.5;function G1(h,t,r,l,c,n,x,b,S){let R=S?Us(c,S):c,E=h[0]*As,A=h[1]*As,z=Oi(E,A);z.imageSmoothingEnabled=!1;let W=z.canvas,ne=new g1(z,As,c,null,x,b,S?Dc(Bn(),S):null),ge=r.length,me=Math.floor((256*256*256-1)/ge),ve={};for(let Oe=1;Oe<=ge;++Oe){let Pe=r[Oe-1],ze=Pe.getStyleFunction()||l;if(!ze)continue;let Me=ze(Pe,n);if(!Me)continue;Array.isArray(Me)||(Me=[Me]);let tt=(Oe*me).toString(16).padStart(7,"#00000");for(let Je=0,st=Me.length;Je<st;++Je){let bt=Me[Je],lt=bt.getGeometryFunction()(Pe);if(!lt||!Qi(R,lt.getExtent()))continue;let Tt=bt.clone(),ct=Tt.getFill();ct&&ct.setColor(tt);let yt=Tt.getStroke();yt&&(yt.setColor(tt),yt.setLineDash(null)),Tt.setText(void 0);let xt=bt.getImage();if(xt){let Ot=xt.getImageSize();if(!Ot)continue;let At=Oi(Ot[0],Ot[1],void 0,{alpha:!1}),Xe=At.canvas;At.fillStyle=tt,At.fillRect(0,0,Xe.width,Xe.height),Tt.setImage(new ad({img:Xe,anchor:xt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:xt.getOrigin(),opacity:1,size:xt.getSize(),scale:xt.getScale(),rotation:xt.getRotation(),rotateWithView:xt.getRotateWithView()}))}let ht=Tt.getZIndex()||0,vt=ve[ht];vt||(vt={},ve[ht]=vt,vt.Polygon=[],vt.Circle=[],vt.LineString=[],vt.Point=[]);let Nt=lt.getType();if(Nt==="GeometryCollection"){let Ot=lt.getGeometriesArrayRecursive();for(let At=0,Xe=Ot.length;At<Xe;++At){let ei=Ot[At];vt[ei.getType().replace("Multi","")].push(ei,Tt)}}else vt[Nt.replace("Multi","")].push(lt,Tt)}}let Te=Object.keys(ve).map(Number).sort(vs);for(let Oe=0,Pe=Te.length;Oe<Pe;++Oe){let ze=ve[Te[Oe]];for(let Me in ze){let et=ze[Me];for(let tt=0,Je=et.length;tt<Je;tt+=2){ne.setStyle(et[tt+1]);for(let st=0,bt=t.length;st<bt;++st)ne.setTransform(t[st]),ne.drawGeometry(et[tt])}}}return z.getImageData(0,0,W.width,W.height)}function V1(h,t,r){let l=[];if(r){let c=Math.floor(Math.round(h[0])*As),n=Math.floor(Math.round(h[1])*As),x=(Pi(c,0,r.width-1)+Pi(n,0,r.height-1)*r.width)*4,b=r.data[x],S=r.data[x+1],E=r.data[x+2]+256*(S+256*b),A=Math.floor((256*256*256-1)/t.length);E&&E%A===0&&l.push(t[E/A-1])}return l}var ky=class extends Ei{constructor(t,r,l,c){super(t),this.inversePixelTransform=r,this.frameState=l,this.context=c}},U1=ky;var OC=5,Dy=class extends Jp{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=OC}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return St()}getData(t){return null}prepareFrame(t){return St()}renderFrame(t,r){return St()}forEachFeatureAtCoordinate(t,r,l,c,n){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){let r=t.target;(r.getState()===Mt.LOADED||r.getState()===Mt.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let r=t.getState();return r!=Mt.LOADED&&r!=Mt.ERROR&&t.addEventListener(yi.CHANGE,this.boundHandleImageChange_),r==Mt.IDLE&&(t.load(),r=t.getState()),r==Mt.LOADED}renderIfReadyAndVisible(){let t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},xa=Dy;var zy=[],$c=null;function BC(){$c=Oi(1,1,void 0,{willReadFrequently:!0})}var Fy=class extends xa{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=mr(),this.pixelTransform=mr(),this.inversePixelTransform=mr(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,r,l){$c||BC(),$c.clearRect(0,0,1,1);let c;try{$c.drawImage(t,r,l,1,1,0,0,1,1),c=$c.getImageData(0,0,1,1).data}catch{return $c=null,null}return c}getBackground(t){let l=this.getLayer().getBackground();return typeof l=="function"&&(l=l(t.viewState.resolution)),l||void 0}useContainer(t,r,l){let c=this.getLayer().getClassName(),n,x;if(t&&t.className===c&&(!l||t&&t.style.backgroundColor&&yn(Ps(t.style.backgroundColor),Ps(l)))){let b=t.firstElementChild;b instanceof HTMLCanvasElement&&(x=b.getContext("2d"))}if(x&&x.canvas.style.transform===r?(this.container=t,this.context=x,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){n=document.createElement("div"),n.className=c;let b=n.style;b.position="absolute",b.width="100%",b.height="100%",x=Oi();let S=x.canvas;n.appendChild(S),b=S.style,b.position="absolute",b.left="0",b.transformOrigin="top left",this.container=n,this.context=x}!this.containerReused&&l&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=l)}clipUnrotated(t,r,l){let c=zg(l),n=Og(l),x=Fg(l),b=Dg(l);Mr(r.coordinateToPixelTransform,c),Mr(r.coordinateToPixelTransform,n),Mr(r.coordinateToPixelTransform,x),Mr(r.coordinateToPixelTransform,b);let S=this.inversePixelTransform;Mr(S,c),Mr(S,n),Mr(S,x),Mr(S,b),t.save(),t.beginPath(),t.moveTo(Math.round(c[0]),Math.round(c[1])),t.lineTo(Math.round(n[0]),Math.round(n[1])),t.lineTo(Math.round(x[0]),Math.round(x[1])),t.lineTo(Math.round(b[0]),Math.round(b[1])),t.clip()}prepareContainer(t,r){let l=t.extent,c=t.viewState.resolution,n=t.viewState.rotation,x=t.pixelRatio,b=Math.round(Ti(l)/c*x),S=Math.round(sr(l)/c*x);Ur(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/x,1/x,n,-b/2,-S/2),Av(this.inversePixelTransform,this.pixelTransform);let R=Ag(this.pixelTransform);if(this.useContainer(r,R,this.getBackground(t)),!this.containerReused){let E=this.context.canvas;E.width!=b||E.height!=S?(E.width=b,E.height=S):this.context.clearRect(0,0,b,S),R!==E.style.transform&&(E.style.transform=R)}}dispatchRenderEvent_(t,r,l){let c=this.getLayer();if(c.hasListener(t)){let n=new U1(t,this.inversePixelTransform,l,r);c.dispatchEvent(n)}}preRender(t,r){this.frameState=r,!r.declutter&&this.dispatchRenderEvent_(qs.PRERENDER,t,r)}postRender(t,r){r.declutter||this.dispatchRenderEvent_(qs.POSTRENDER,t,r)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new zf),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(qs.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(qs.POSTRENDER,this.context,t))}getRenderTransform(t,r,l,c,n,x,b){let S=n/2,R=x/2,E=c/r,A=-E,z=-t[0]+b,W=-t[1];return Ur(this.tempTransform,S,R,E,A,-l,z,W)}disposeInternal(){delete this.frameState,super.disposeInternal()}},Of=Fy;var Oy=class extends Of{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=_n(),this.wrappedRenderedExtent_=_n(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,r,l){let c=r.extent,n=r.viewState,x=n.center,b=n.resolution,S=n.projection,R=n.rotation,E=S.getExtent(),A=this.getLayer().getSource(),z=this.getLayer().getDeclutter(),W=r.pixelRatio,ne=r.viewHints,ge=!(ne[vn.ANIMATING]||ne[vn.INTERACTING]),me=this.context,ve=Math.round(Ti(c)/b*W),Te=Math.round(sr(c)/b*W),Oe=A.getWrapX()&&S.canWrapX(),Pe=Oe?Ti(E):null,ze=Oe?Math.ceil((c[2]-E[2])/Pe)+1:1,Me=Oe?Math.floor((c[0]-E[0])/Pe):0;do{let et=this.getRenderTransform(x,b,0,W,ve,Te,Me*Pe);r.declutter&&(et=et.slice(0)),t.execute(me,[me.canvas.width,me.canvas.height],et,R,ge,l===void 0?wl:l?Ay:B1,l?z&&r.declutter[z]:void 0)}while(++Me<ze)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Oi(this.context.canvas.width,this.context.canvas.height,zy))}resetDrawContext_(){if(this.opacity_!==1){let t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,l1(this.context),zy.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,r){let l=t.layerStatesArray[t.layerIndex];this.opacity_=l.opacity;let c=t.viewState;this.prepareContainer(t,r);let n=this.context,x=this.replayGroup_,b=x&&!x.isEmpty();if(!b&&!(this.getLayer().hasListener(qs.PRERENDER)||this.getLayer().hasListener(qs.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(n,t);let S=c.projection;if(this.clipped_=!1,b&&l.extent&&this.clipping){let R=Zs(l.extent,S);b=Qi(R,t.extent),this.clipped_=b&&!cl(R,t.extent),this.clipped_&&this.clipUnrotated(n,t,R)}return b&&this.renderWorlds(x,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&n.restore(),this.postRender(n,t),this.renderedRotation_!==c.rotation&&(this.renderedRotation_=c.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(r=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let l=this.frameState.size.slice(),c=this.renderedCenter_,n=this.renderedResolution_,x=this.renderedRotation_,b=this.renderedProjection_,S=this.wrappedRenderedExtent_,R=this.getLayer(),E=[],A=l[0]*As,z=l[1]*As;E.push(this.getRenderTransform(c,n,x,As,A,z,0).slice());let W=R.getSource(),ne=b.getExtent();if(W.getWrapX()&&b.canWrapX()&&!cl(ne,S)){let me=S[0],ve=Ti(ne),Te=0,Oe;for(;me<ne[0];)--Te,Oe=ve*Te,E.push(this.getRenderTransform(c,n,x,As,A,z,Oe).slice()),me+=ve;for(Te=0,me=S[2];me>ne[2];)++Te,Oe=ve*Te,E.push(this.getRenderTransform(c,n,x,As,A,z,Oe).slice()),me-=ve}let ge=Bn();this.hitDetectionImageData_=G1(l,E,this.renderedFeatures_,R.getStyleFunction(),S,n,x,ty(n,this.renderedPixelRatio_),ge?b:null)}r(V1(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,r,l,c,n){if(!this.replayGroup_)return;let x=r.viewState.resolution,b=r.viewState.rotation,S=this.getLayer(),R={},E=function(z,W,ne){let ge=Vt(z),me=R[ge];if(me){if(me!==!0&&ne<me.distanceSq){if(ne===0)return R[ge]=!0,n.splice(n.lastIndexOf(me),1),c(z,S,W);me.geometry=W,me.distanceSq=ne}}else{if(ne===0)return R[ge]=!0,c(z,S,W);n.push(R[ge]={feature:z,layer:S,geometry:W,distanceSq:ne,callback:c})}},A=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,x,b,l,E,A?r.declutter?.[A]?.all().map(z=>z.value):null)}handleFontsChanged(){let t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){let r=this.getLayer(),l=r.getSource();if(!l)return!1;let c=t.viewHints[vn.ANIMATING],n=t.viewHints[vn.INTERACTING],x=r.getUpdateWhileAnimating(),b=r.getUpdateWhileInteracting();if(this.ready&&!x&&c||!b&&n)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let S=t.extent,R=t.viewState,E=R.projection,A=R.resolution,z=t.pixelRatio,W=r.getRevision(),ne=r.getRenderBuffer(),ge=r.getRenderOrder();ge===void 0&&(ge=y1);let me=R.center.slice(),ve=Kn(S,ne*A),Te=ve.slice(),Oe=[ve.slice()],Pe=E.getExtent();if(l.getWrapX()&&E.canWrapX()&&!cl(Pe,t.extent)){let yt=Ti(Pe),xt=Math.max(Ti(ve)/2,yt);ve[0]=Pe[0]-xt,ve[2]=Pe[2]+xt,Kv(me,E);let ht=Bg(Oe[0],E);ht[0]<Pe[0]&&ht[2]<Pe[2]?Oe.push([ht[0]+yt,ht[1],ht[2]+yt,ht[3]]):ht[0]>Pe[0]&&ht[2]>Pe[2]&&Oe.push([ht[0]-yt,ht[1],ht[2]-yt,ht[3]])}if(this.ready&&this.renderedResolution_==A&&this.renderedRevision_==W&&this.renderedRenderOrder_==ge&&this.renderedFrameDeclutter_===!!t.declutter&&cl(this.wrappedRenderedExtent_,ve))return yn(this.renderedExtent_,Te)||(this.hitDetectionImageData_=null,this.renderedExtent_=Te),this.renderedCenter_=me,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let ze=new k1(iy(A,z),ve,A,z),Me=Bn(),et;if(Me){for(let yt=0,xt=Oe.length;yt<xt;++yt){let ht=Oe[yt],vt=Us(ht,E);l.loadFeatures(vt,_b(A,E),Me)}et=Dc(Me,E)}else for(let yt=0,xt=Oe.length;yt<xt;++yt)l.loadFeatures(Oe[yt],A,E);let tt=ty(A,z),Je=!0,st=(yt,xt)=>{let ht,vt=yt.getStyleFunction()||r.getStyleFunction();if(vt&&(ht=vt(yt,A)),ht){let Nt=this.renderFeature(yt,tt,ht,ze,et,this.getLayer().getDeclutter(),xt);Je=Je&&!Nt}},bt=Us(ve,E),lt=l.getFeaturesInExtent(bt);ge&&lt.sort(ge);for(let yt=0,xt=lt.length;yt<xt;++yt)st(lt[yt],yt);this.renderedFeatures_=lt,this.ready=Je;let Tt=ze.finish(),ct=new j1(ve,A,z,l.getOverlaps(),Tt,r.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=A,this.renderedRevision_=W,this.renderedRenderOrder_=ge,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=Te,this.wrappedRenderedExtent_=ve,this.renderedCenter_=me,this.renderedProjection_=E,this.renderedPixelRatio_=z,this.replayGroup_=ct,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,r,l,c,n,x,b){if(!l)return!1;let S=!1;if(Array.isArray(l))for(let R=0,E=l.length;R<E;++R)S=ry(c,t,l[R],r,this.boundHandleStyleImageChange_,n,x,b)||S;else S=ry(c,t,l,r,this.boundHandleStyleImageChange_,n,x,b);return S}},Z1=Oy;var Sl=0;var Wr=1<<Sl++,Ut=1<<Sl++,sn=1<<Sl++,Nn=1<<Sl++,ba=1<<Sl++,ld=1<<Sl++,Bf=Math.pow(2,Sl)-1,Ny={[Wr]:"boolean",[Ut]:"number",[sn]:"string",[Nn]:"color",[ba]:"number[]",[ld]:"size"},jC=Object.keys(Ny).map(Number).sort(vs);function NC(h){return h in Ny}function cd(h){let t=[];for(let r of jC)hd(h,r)&&t.push(Ny[r]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function hd(h,t){return(h&t)===t}function va(h,t){return h===t}var Bi=class{constructor(t,r){if(!NC(t))throw new Error(`literal expressions must have a specific type, got ${cd(t)}`);this.type=t,this.value=r}},jy=class{constructor(t,r,...l){this.type=t,this.operator=r,this.args=l}};function Gy(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function xr(h,t,r){switch(typeof h){case"boolean":{if(va(t,sn))return new Bi(sn,h?"true":"false");if(!hd(t,Wr))throw new Error(`got a boolean, but expected ${cd(t)}`);return new Bi(Wr,h)}case"number":{if(va(t,ld))return new Bi(ld,Hs(h));if(va(t,Wr))return new Bi(Wr,!!h);if(va(t,sn))return new Bi(sn,h.toString());if(!hd(t,Ut))throw new Error(`got a number, but expected ${cd(t)}`);return new Bi(Ut,h)}case"string":{if(va(t,Nn))return new Bi(Nn,Yu(h));if(va(t,Wr))return new Bi(Wr,!!h);if(!hd(t,sn))throw new Error(`got a string, but expected ${cd(t)}`);return new Bi(sn,h)}default:}if(!Array.isArray(h))throw new Error("expression must be an array or a primitive value");if(h.length===0)throw new Error("empty expression");if(typeof h[0]=="string")return KC(h,t,r);for(let l of h)if(typeof l!="number")throw new Error("expected an array of numbers");if(va(t,ld)){if(h.length!==2)throw new Error(`expected an array of two values for a size, got ${h.length}`);return new Bi(ld,h)}if(va(t,Nn)){if(h.length===3)return new Bi(Nn,[...h,1]);if(h.length===4)return new Bi(Nn,h);throw new Error(`expected an array of 3 or 4 values for a color, got ${h.length}`)}if(!hd(t,ba))throw new Error(`got an array of numbers, but expected ${cd(t)}`);return new Bi(ba,h)}var Ne={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},GC={[Ne.Get]:Pt(Ft(1,1/0),q1),[Ne.Var]:Pt(Ft(1,1),VC),[Ne.Has]:Pt(Ft(1,1/0),q1),[Ne.Id]:Pt(UC,Xc),[Ne.Concat]:Pt(Ft(2,1/0),Kt(sn)),[Ne.GeometryType]:Pt(ZC,Xc),[Ne.LineMetric]:Pt(Xc),[Ne.Resolution]:Pt(By,Xc),[Ne.Zoom]:Pt(By,Xc),[Ne.Time]:Pt(By,Xc),[Ne.Any]:Pt(Ft(2,1/0),Kt(Wr)),[Ne.All]:Pt(Ft(2,1/0),Kt(Wr)),[Ne.Not]:Pt(Ft(1,1),Kt(Wr)),[Ne.Equal]:Pt(Ft(2,2),Kt(Bf)),[Ne.NotEqual]:Pt(Ft(2,2),Kt(Bf)),[Ne.GreaterThan]:Pt(Ft(2,2),Kt(Ut)),[Ne.GreaterThanOrEqualTo]:Pt(Ft(2,2),Kt(Ut)),[Ne.LessThan]:Pt(Ft(2,2),Kt(Ut)),[Ne.LessThanOrEqualTo]:Pt(Ft(2,2),Kt(Ut)),[Ne.Multiply]:Pt(Ft(2,1/0),W1),[Ne.Coalesce]:Pt(Ft(2,1/0),W1),[Ne.Divide]:Pt(Ft(2,2),Kt(Ut)),[Ne.Add]:Pt(Ft(2,1/0),Kt(Ut)),[Ne.Subtract]:Pt(Ft(2,2),Kt(Ut)),[Ne.Clamp]:Pt(Ft(3,3),Kt(Ut)),[Ne.Mod]:Pt(Ft(2,2),Kt(Ut)),[Ne.Pow]:Pt(Ft(2,2),Kt(Ut)),[Ne.Abs]:Pt(Ft(1,1),Kt(Ut)),[Ne.Floor]:Pt(Ft(1,1),Kt(Ut)),[Ne.Ceil]:Pt(Ft(1,1),Kt(Ut)),[Ne.Round]:Pt(Ft(1,1),Kt(Ut)),[Ne.Sin]:Pt(Ft(1,1),Kt(Ut)),[Ne.Cos]:Pt(Ft(1,1),Kt(Ut)),[Ne.Atan]:Pt(Ft(1,2),Kt(Ut)),[Ne.Sqrt]:Pt(Ft(1,1),Kt(Ut)),[Ne.Match]:Pt(Ft(4,1/0),$1,WC),[Ne.Between]:Pt(Ft(3,3),Kt(Ut)),[Ne.Interpolate]:Pt(Ft(6,1/0),$1,$C),[Ne.Case]:Pt(Ft(3,1/0),qC,XC),[Ne.In]:Pt(Ft(2,2),HC),[Ne.Number]:Pt(Ft(1,1/0),Kt(Bf)),[Ne.String]:Pt(Ft(1,1/0),Kt(Bf)),[Ne.Array]:Pt(Ft(1,1/0),Kt(Ut)),[Ne.Color]:Pt(Ft(1,4),Kt(Ut)),[Ne.Band]:Pt(Ft(1,3),Kt(Ut)),[Ne.Palette]:Pt(Ft(2,2),YC),[Ne.ToString]:Pt(Ft(1,1),Kt(Wr|Ut|sn|Nn))};function q1(h,t,r){let l=h.length-1,c=new Array(l);for(let n=0;n<l;++n){let x=h[n+1];switch(typeof x){case"number":{c[n]=new Bi(Ut,x);break}case"string":{c[n]=new Bi(sn,x);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${x}`)}n===0&&r.properties.add(String(x))}return c}function VC(h,t,r){let l=h[1];if(typeof l!="string")throw new Error("expected a string argument for var operation");return r.variables.add(l),[new Bi(sn,l)]}function UC(h,t,r){r.featureId=!0}function ZC(h,t,r){r.geometryType=!0}function By(h,t,r){r.mapState=!0}function Xc(h,t,r){let l=h[0];if(h.length!==1)throw new Error(`expected no arguments for ${l} operation`);return[]}function Ft(h,t){return function(r,l,c){let n=r[0],x=r.length-1;if(h===t){if(x!==h){let b=h===1?"":"s";throw new Error(`expected ${h} argument${b} for ${n}, got ${x}`)}}else if(x<h||x>t){let b=t===1/0?`${h} or more`:`${h} to ${t}`;throw new Error(`expected ${b} arguments for ${n}, got ${x}`)}}}function W1(h,t,r){let l=h.length-1,c=new Array(l);for(let n=0;n<l;++n){let x=xr(h[n+1],t,r);c[n]=x}return c}function Kt(h){return function(t,r,l){let c=t.length-1,n=new Array(c);for(let x=0;x<c;++x){let b=xr(t[x+1],h,l);n[x]=b}return n}}function qC(h,t,r){let l=h[0],c=h.length-1;if(c%2===0)throw new Error(`expected an odd number of arguments for ${l}, got ${c} instead`)}function $1(h,t,r){let l=h[0],c=h.length-1;if(c%2===1)throw new Error(`expected an even number of arguments for operation ${l}, got ${c} instead`)}function WC(h,t,r){let l=h.length-1,c=sn|Ut|Wr,n=xr(h[1],c,r),x=xr(h[h.length-1],t,r),b=new Array(l-2);for(let S=0;S<l-2;S+=2){try{let R=xr(h[S+2],n.type,r);b[S]=R}catch(R){throw new Error(`failed to parse argument ${S+1} of match expression: ${R.message}`)}try{let R=xr(h[S+3],x.type,r);b[S+1]=R}catch(R){throw new Error(`failed to parse argument ${S+2} of match expression: ${R.message}`)}}return[n,...b,x]}function $C(h,t,r){let l=h[1],c;switch(l[0]){case"linear":c=1;break;case"exponential":let S=l[1];if(typeof S!="number"||S<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(S)} instead`);c=S;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(l)}`)}let n=new Bi(Ut,c),x;try{x=xr(h[2],Ut,r)}catch(S){throw new Error(`failed to parse argument 1 in interpolate expression: ${S.message}`)}let b=new Array(h.length-3);for(let S=0;S<b.length;S+=2){try{let R=xr(h[S+3],Ut,r);b[S]=R}catch(R){throw new Error(`failed to parse argument ${S+2} for interpolate expression: ${R.message}`)}try{let R=xr(h[S+4],t,r);b[S+1]=R}catch(R){throw new Error(`failed to parse argument ${S+3} for interpolate expression: ${R.message}`)}}return[n,x,...b]}function XC(h,t,r){let l=xr(h[h.length-1],t,r),c=new Array(h.length-1);for(let n=0;n<c.length-1;n+=2){try{let x=xr(h[n+1],Wr,r);c[n]=x}catch(x){throw new Error(`failed to parse argument ${n} of case expression: ${x.message}`)}try{let x=xr(h[n+2],l.type,r);c[n+1]=x}catch(x){throw new Error(`failed to parse argument ${n+1} of case expression: ${x.message}`)}}return c[c.length-1]=l,c}function HC(h,t,r){let l=h[2];if(!Array.isArray(l))throw new Error('the second argument for the "in" operator must be an array');let c;if(typeof l[0]=="string"){if(l[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(l[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');l=l[1],c=sn}else c=Ut;let n=new Array(l.length);for(let b=0;b<n.length;b++)try{let S=xr(l[b],c,r);n[b]=S}catch(S){throw new Error(`failed to parse haystack item ${b} for "in" expression: ${S.message}`)}return[xr(h[1],c,r),...n]}function YC(h,t,r){let l;try{l=xr(h[1],Ut,r)}catch(x){throw new Error(`failed to parse first argument in palette expression: ${x.message}`)}let c=h[2];if(!Array.isArray(c))throw new Error("the second argument of palette must be an array");let n=new Array(c.length);for(let x=0;x<n.length;x++){let b;try{b=xr(c[x],Nn,r)}catch(S){throw new Error(`failed to parse color at index ${x} in palette expression: ${S.message}`)}if(!(b instanceof Bi))throw new Error(`the palette color at index ${x} must be a literal value`);n[x]=b}return[l,...n]}function Pt(...h){return function(t,r,l){let c=t[0],n;for(let x=0;x<h.length;x++){let b=h[x](t,r,l);if(x==h.length-1){if(!b)throw new Error("expected last argument validator to return the parsed args");n=b}}return new jy(r,c,...n)}}function KC(h,t,r){let l=h[0],c=GC[l];if(!c)throw new Error(`unknown operator: ${l}`);return c(h,t,r)}function Vy(h){if(!h)return"";let t=h.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Vy(h.getGeometries()[0]);default:return""}}function Uy(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Js(h,t,r){let l=xr(h,t,r);return Ls(l,r)}function Ls(h,t){if(h instanceof Bi){if(h.type===Nn&&typeof h.value=="string"){let l=Yu(h.value);return function(){return l}}return function(){return h.value}}let r=h.operator;switch(r){case Ne.Number:case Ne.String:case Ne.Coalesce:return JC(h,t);case Ne.Get:case Ne.Var:case Ne.Has:return QC(h,t);case Ne.Id:return l=>l.featureId;case Ne.GeometryType:return l=>l.geometryType;case Ne.Concat:{let l=h.args.map(c=>Ls(c,t));return c=>"".concat(...l.map(n=>n(c).toString()))}case Ne.Resolution:return l=>l.resolution;case Ne.Any:case Ne.All:case Ne.Between:case Ne.In:case Ne.Not:return tM(h,t);case Ne.Equal:case Ne.NotEqual:case Ne.LessThan:case Ne.LessThanOrEqualTo:case Ne.GreaterThan:case Ne.GreaterThanOrEqualTo:return eM(h,t);case Ne.Multiply:case Ne.Divide:case Ne.Add:case Ne.Subtract:case Ne.Clamp:case Ne.Mod:case Ne.Pow:case Ne.Abs:case Ne.Floor:case Ne.Ceil:case Ne.Round:case Ne.Sin:case Ne.Cos:case Ne.Atan:case Ne.Sqrt:return iM(h,t);case Ne.Case:return rM(h,t);case Ne.Match:return nM(h,t);case Ne.Interpolate:return sM(h,t);case Ne.ToString:return oM(h,t);default:throw new Error(`Unsupported operator ${r}`)}}function JC(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.Coalesce:return n=>{for(let x=0;x<l;++x){let b=c[x](n);if(typeof b<"u"&&b!==null)return b}throw new Error("Expected one of the values to be non-null")};case Ne.Number:case Ne.String:return n=>{for(let x=0;x<l;++x){let b=c[x](n);if(typeof b===r)return b}throw new Error(`Expected one of the values to be a ${r}`)};default:throw new Error(`Unsupported assertion operator ${r}`)}}function QC(h,t){let l=h.args[0].value;switch(h.operator){case Ne.Get:return c=>{let n=h.args,x=c.properties[l];for(let b=1,S=n.length;b<S;++b){let E=n[b].value;x=x[E]}return x};case Ne.Var:return c=>c.variables[l];case Ne.Has:return c=>{let n=h.args;if(!(l in c.properties))return!1;let x=c.properties[l];for(let b=1,S=n.length;b<S;++b){let E=n[b].value;if(!x||!Object.hasOwn(x,E))return!1;x=x[E]}return!0};default:throw new Error(`Unsupported accessor operator ${h.operator}`)}}function eM(h,t){let r=h.operator,l=Ls(h.args[0],t),c=Ls(h.args[1],t);switch(r){case Ne.Equal:return n=>l(n)===c(n);case Ne.NotEqual:return n=>l(n)!==c(n);case Ne.LessThan:return n=>l(n)<c(n);case Ne.LessThanOrEqualTo:return n=>l(n)<=c(n);case Ne.GreaterThan:return n=>l(n)>c(n);case Ne.GreaterThanOrEqualTo:return n=>l(n)>=c(n);default:throw new Error(`Unsupported comparison operator ${r}`)}}function tM(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.Any:return n=>{for(let x=0;x<l;++x)if(c[x](n))return!0;return!1};case Ne.All:return n=>{for(let x=0;x<l;++x)if(!c[x](n))return!1;return!0};case Ne.Between:return n=>{let x=c[0](n),b=c[1](n),S=c[2](n);return x>=b&&x<=S};case Ne.In:return n=>{let x=c[0](n);for(let b=1;b<l;++b)if(x===c[b](n))return!0;return!1};case Ne.Not:return n=>!c[0](n);default:throw new Error(`Unsupported logical operator ${r}`)}}function iM(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.Multiply:return n=>{let x=1;for(let b=0;b<l;++b)x*=c[b](n);return x};case Ne.Divide:return n=>c[0](n)/c[1](n);case Ne.Add:return n=>{let x=0;for(let b=0;b<l;++b)x+=c[b](n);return x};case Ne.Subtract:return n=>c[0](n)-c[1](n);case Ne.Clamp:return n=>{let x=c[0](n),b=c[1](n);if(x<b)return b;let S=c[2](n);return x>S?S:x};case Ne.Mod:return n=>c[0](n)%c[1](n);case Ne.Pow:return n=>Math.pow(c[0](n),c[1](n));case Ne.Abs:return n=>Math.abs(c[0](n));case Ne.Floor:return n=>Math.floor(c[0](n));case Ne.Ceil:return n=>Math.ceil(c[0](n));case Ne.Round:return n=>Math.round(c[0](n));case Ne.Sin:return n=>Math.sin(c[0](n));case Ne.Cos:return n=>Math.cos(c[0](n));case Ne.Atan:return l===2?n=>Math.atan2(c[0](n),c[1](n)):n=>Math.atan(c[0](n));case Ne.Sqrt:return n=>Math.sqrt(c[0](n));default:throw new Error(`Unsupported numeric operator ${r}`)}}function rM(h,t){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Ls(h.args[c],t);return c=>{for(let n=0;n<r-1;n+=2)if(l[n](c))return l[n+1](c);return l[r-1](c)}}function nM(h,t){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Ls(h.args[c],t);return c=>{let n=l[0](c);for(let x=1;x<r;x+=2)if(n===l[x](c))return l[x+1](c);return l[r-1](c)}}function sM(h,t){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Ls(h.args[c],t);return c=>{let n=l[0](c),x=l[1](c),b,S;for(let R=2;R<r;R+=2){let E=l[R](c),A=l[R+1](c),z=Array.isArray(A);if(z&&(A=o1(A)),E>=x)return R===2?A:z?aM(n,x,b,S,E,A):ud(n,x,b,S,E,A);b=E,S=A}return S}}function oM(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.ToString:return n=>{let x=c[0](n);return h.args[0].type===Nn?Ku(x):x.toString()};default:throw new Error(`Unsupported convert operator ${r}`)}}function ud(h,t,r,l,c,n){let x=c-r;if(x===0)return l;let b=t-r,S=h===1?b/x:(Math.pow(h,b)-1)/(Math.pow(h,x)-1);return l+S*(n-l)}function aM(h,t,r,l,c,n){if(c-r===0)return l;let b=Z_(l),S=Z_(n),R=S[2]-b[2];R>180?R-=360:R<-180&&(R+=360);let E=[ud(h,t,r,b[0],c,S[0]),ud(h,t,r,b[1],c,S[1]),b[2]+ud(h,t,r,0,c,R),ud(h,t,r,l[3],c,n[3])];return q_(a1(E))}function lM(h){return!0}function K1(h){let t=Gy(),r=cM(h,t),l=Uy();return function(c,n){if(l.properties=c.getPropertiesInternal(),l.resolution=n,t.featureId){let x=c.getId();x!==void 0?l.featureId=x:l.featureId=null}return t.geometryType&&(l.geometryType=Vy(c.getGeometry())),r(l)}}function Wy(h){let t=Gy(),r=h.length,l=new Array(r);for(let x=0;x<r;++x)l[x]=Zy(h[x],t);let c=Uy(),n=new Array(r);return function(x,b){if(c.properties=x.getPropertiesInternal(),c.resolution=b,t.featureId){let R=x.getId();R!==void 0?c.featureId=R:c.featureId=null}let S=0;for(let R=0;R<r;++R){let E=l[R](c);E&&(n[S]=E,S+=1)}return n.length=S,n}}function cM(h,t){let r=h.length,l=new Array(r);for(let c=0;c<r;++c){let n=h[c],x="filter"in n?Js(n.filter,Wr,t):lM,b;if(Array.isArray(n.style)){let S=n.style.length;b=new Array(S);for(let R=0;R<S;++R)b[R]=Zy(n.style[R],t)}else b=[Zy(n.style,t)];l[c]={filter:x,styles:b}}return function(c){let n=[],x=!1;for(let b=0;b<r;++b){let S=l[b].filter;if(S(c)&&!(h[b].else&&x)){x=!0;for(let R of l[b].styles){let E=R(c);E&&n.push(E)}}}return n}}function Zy(h,t){let r=dd(h,"",t),l=pd(h,"",t),c=hM(h,t),n=uM(h,t),x=Mn(h,"z-index",t);if(!r&&!l&&!c&&!n&&!On(h))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(h));let b=new Lr;return function(S){let R=!0;if(r){let E=r(S);E&&(R=!1),b.setFill(E)}if(l){let E=l(S);E&&(R=!1),b.setStroke(E)}if(c){let E=c(S);E&&(R=!1),b.setText(E)}if(n){let E=n(S);E&&(R=!1),b.setImage(E)}return x&&b.setZIndex(x(S)),R?null:b}}function dd(h,t,r){let l;if(t+"fill-pattern-src"in h)l=mM(h,t+"fill-",r);else{if(h[t+"fill-color"]==="none")return n=>null;l=$y(h,t+"fill-color",r)}if(!l)return null;let c=new Ar;return function(n){let x=l(n);return x===Mf?null:(c.setColor(x),c)}}function pd(h,t,r){let l=Mn(h,t+"stroke-width",r),c=$y(h,t+"stroke-color",r);if(!l&&!c)return null;let n=Lo(h,t+"stroke-line-cap",r),x=Lo(h,t+"stroke-line-join",r),b=J1(h,t+"stroke-line-dash",r),S=Mn(h,t+"stroke-line-dash-offset",r),R=Mn(h,t+"stroke-miter-limit",r),E=new lr;return function(A){if(c){let z=c(A);if(z===Mf)return null;E.setColor(z)}if(l&&E.setWidth(l(A)),n){let z=n(A);if(z!=="butt"&&z!=="round"&&z!=="square")throw new Error("Expected butt, round, or square line cap");E.setLineCap(z)}if(x){let z=x(A);if(z!=="bevel"&&z!=="round"&&z!=="miter")throw new Error("Expected bevel, round, or miter line join");E.setLineJoin(z)}return b&&E.setLineDash(b(A)),S&&E.setLineDashOffset(S(A)),R&&E.setMiterLimit(R(A)),E}}function hM(h,t){let r="text-",l=Lo(h,r+"value",t);if(!l)return null;let c=dd(h,r,t),n=dd(h,r+"background-",t),x=pd(h,r,t),b=pd(h,r+"background-",t),S=Lo(h,r+"font",t),R=Mn(h,r+"max-angle",t),E=Mn(h,r+"offset-x",t),A=Mn(h,r+"offset-y",t),z=Hc(h,r+"overflow",t),W=Lo(h,r+"placement",t),ne=Mn(h,r+"repeat",t),ge=Gf(h,r+"scale",t),me=Hc(h,r+"rotate-with-view",t),ve=Mn(h,r+"rotation",t),Te=Lo(h,r+"align",t),Oe=Lo(h,r+"justify",t),Pe=Lo(h,r+"baseline",t),ze=Hc(h,r+"keep-upright",t),Me=J1(h,r+"padding",t),et=Vf(h,r+"declutter-mode"),tt=new I1({declutterMode:et});return function(Je){if(tt.setText(l(Je)),c&&tt.setFill(c(Je)),n&&tt.setBackgroundFill(n(Je)),x&&tt.setStroke(x(Je)),b&&tt.setBackgroundStroke(b(Je)),S&&tt.setFont(S(Je)),R&&tt.setMaxAngle(R(Je)),E&&tt.setOffsetX(E(Je)),A&&tt.setOffsetY(A(Je)),z&&tt.setOverflow(z(Je)),W){let st=W(Je);if(st!=="point"&&st!=="line")throw new Error("Expected point or line for text-placement");tt.setPlacement(st)}if(ne&&tt.setRepeat(ne(Je)),ge&&tt.setScale(ge(Je)),me&&tt.setRotateWithView(me(Je)),ve&&tt.setRotation(ve(Je)),Te){let st=Te(Je);if(st!=="left"&&st!=="center"&&st!=="right"&&st!=="end"&&st!=="start")throw new Error("Expected left, right, center, start, or end for text-align");tt.setTextAlign(st)}if(Oe){let st=Oe(Je);if(st!=="left"&&st!=="right"&&st!=="center")throw new Error("Expected left, right, or center for text-justify");tt.setJustify(st)}if(Pe){let st=Pe(Je);if(st!=="bottom"&&st!=="top"&&st!=="middle"&&st!=="alphabetic"&&st!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");tt.setTextBaseline(st)}return Me&&tt.setPadding(Me(Je)),ze&&tt.setKeepUpright(ze(Je)),tt}}function uM(h,t){return"icon-src"in h?dM(h,t):"shape-points"in h?pM(h,t):"circle-radius"in h?fM(h,t):null}function dM(h,t){let r="icon-",l=r+"src",c=Q1(h[l],l),n=jf(h,r+"anchor",t),x=Gf(h,r+"scale",t),b=Mn(h,r+"opacity",t),S=jf(h,r+"displacement",t),R=Mn(h,r+"rotation",t),E=Hc(h,r+"rotate-with-view",t),A=H1(h,r+"anchor-origin"),z=Y1(h,r+"anchor-x-units"),W=Y1(h,r+"anchor-y-units"),ne=xM(h,r+"color"),ge=_M(h,r+"cross-origin"),me=yM(h,r+"offset"),ve=H1(h,r+"offset-origin"),Te=Nf(h,r+"width"),Oe=Nf(h,r+"height"),Pe=gM(h,r+"size"),ze=Vf(h,r+"declutter-mode"),Me=new ad({src:c,anchorOrigin:A,anchorXUnits:z,anchorYUnits:W,color:ne,crossOrigin:ge,offset:me,offsetOrigin:ve,height:Oe,width:Te,size:Pe,declutterMode:ze});return function(et){return b&&Me.setOpacity(b(et)),S&&Me.setDisplacement(S(et)),R&&Me.setRotation(R(et)),E&&Me.setRotateWithView(E(et)),x&&Me.setScale(x(et)),n&&Me.setAnchor(n(et)),Me}}function pM(h,t){let r="shape-",l=r+"points",c=r+"radius",n=qy(h[l],l),x=qy(h[c],c),b=dd(h,r,t),S=pd(h,r,t),R=Gf(h,r+"scale",t),E=jf(h,r+"displacement",t),A=Mn(h,r+"rotation",t),z=Hc(h,r+"rotate-with-view",t),W=Nf(h,r+"radius2"),ne=Nf(h,r+"angle"),ge=Vf(h,r+"declutter-mode"),me=new Ff({points:n,radius:x,radius2:W,angle:ne,declutterMode:ge});return function(ve){return b&&me.setFill(b(ve)),S&&me.setStroke(S(ve)),E&&me.setDisplacement(E(ve)),A&&me.setRotation(A(ve)),z&&me.setRotateWithView(z(ve)),R&&me.setScale(R(ve)),me}}function fM(h,t){let r="circle-",l=dd(h,r,t),c=pd(h,r,t),n=Mn(h,r+"radius",t),x=Gf(h,r+"scale",t),b=jf(h,r+"displacement",t),S=Mn(h,r+"rotation",t),R=Hc(h,r+"rotate-with-view",t),E=Vf(h,r+"declutter-mode"),A=new Cn({radius:5,declutterMode:E});return function(z){return n&&A.setRadius(n(z)),l&&A.setFill(l(z)),c&&A.setStroke(c(z)),b&&A.setDisplacement(b(z)),S&&A.setRotation(S(z)),R&&A.setRotateWithView(R(z)),x&&A.setScale(x(z)),A}}function Mn(h,t,r){if(!(t in h))return;let l=Js(h[t],Ut,r);return function(c){return qy(l(c),t)}}function Lo(h,t,r){if(!(t in h))return null;let l=Js(h[t],sn,r);return function(c){return Q1(l(c),t)}}function mM(h,t,r){let l=Lo(h,t+"pattern-src",r),c=X1(h,t+"pattern-offset",r),n=X1(h,t+"pattern-size",r),x=$y(h,t+"color",r);return function(b){return{src:l(b),offset:c&&c(b),size:n&&n(b),color:x&&x(b)}}}function Hc(h,t,r){if(!(t in h))return null;let l=Js(h[t],Wr,r);return function(c){let n=l(c);if(typeof n!="boolean")throw new Error(`Expected a boolean for ${t}`);return n}}function $y(h,t,r){if(!(t in h))return null;let l=Js(h[t],Nn,r);return function(c){return ew(l(c),t)}}function J1(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba,r);return function(c){return fd(l(c),t)}}function jf(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba,r);return function(c){let n=fd(l(c),t);if(n.length!==2)throw new Error(`Expected two numbers for ${t}`);return n}}function X1(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba,r);return function(c){return tw(l(c),t)}}function Gf(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba|Ut,r);return function(c){return vM(l(c),t)}}function Nf(h,t){let r=h[t];if(r!==void 0){if(typeof r!="number")throw new Error(`Expected a number for ${t}`);return r}}function gM(h,t){let r=h[t];if(r!==void 0){if(typeof r=="number")return Hs(r);if(!Array.isArray(r))throw new Error(`Expected a number or size array for ${t}`);if(r.length!==2||typeof r[0]!="number"||typeof r[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return r}}function _M(h,t){let r=h[t];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${t}`);return r}}function H1(h,t){let r=h[t];if(r!==void 0){if(r!=="bottom-left"&&r!=="bottom-right"&&r!=="top-left"&&r!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return r}}function Y1(h,t){let r=h[t];if(r!==void 0){if(r!=="pixels"&&r!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return r}}function yM(h,t){let r=h[t];if(r!==void 0)return fd(r,t)}function Vf(h,t){let r=h[t];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${t}`);if(r!=="declutter"&&r!=="obstacle"&&r!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return r}}function xM(h,t){let r=h[t];if(r!==void 0)return ew(r,t)}function fd(h,t){if(!Array.isArray(h))throw new Error(`Expected an array for ${t}`);let r=h.length;for(let l=0;l<r;++l)if(typeof h[l]!="number")throw new Error(`Expected an array of numbers for ${t}`);return h}function Q1(h,t){if(typeof h!="string")throw new Error(`Expected a string for ${t}`);return h}function qy(h,t){if(typeof h!="number")throw new Error(`Expected a number for ${t}`);return h}function ew(h,t){if(typeof h=="string")return h;let r=fd(h,t),l=r.length;if(l<3||l>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return r}function tw(h,t){let r=fd(h,t);if(r.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return r}function vM(h,t){return typeof h=="number"?h:tw(h,t)}var iw={RENDER_ORDER:"renderOrder"},Xy=class extends Is{constructor(t){t=t||{};let r=Object.assign({},t);delete r.style,delete r.renderBuffer,delete r.updateWhileAnimating,delete r.updateWhileInteracting,super(r),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(iw.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,r){let l=this.getDeclutter();l in t.declutter||(t.declutter[l]=new vl(9)),this.getRenderer().renderDeclutter(t,r)}setRenderOrder(t){this.set(iw.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?gy:t;let r=bM(t);this.styleFunction_=t===null?void 0:C1(r),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function bM(h){if(h===void 0)return gy;if(!h)return null;if(typeof h=="function"||h instanceof Lr)return h;if(!Array.isArray(h))return Wy([h]);if(h.length===0)return[];let t=h.length,r=h[0];if(r instanceof Lr){let c=new Array(t);for(let n=0;n<t;++n){let x=h[n];if(!(x instanceof Lr))throw new Error("Expected a list of style instances");c[n]=x}return c}if("style"in r){let c=new Array(t);for(let n=0;n<t;++n){let x=h[n];if(!("style"in x))throw new Error("Expected a list of rules with a style property");c[n]=x}return K1(c)}return Wy(h)}var rw=Xy;var Hy=class extends rw{constructor(t){super(t)}createRenderer(){return new Z1(this)}},Yc=Hy;var Gn={SINGLECLICK:"singleclick",CLICK:yi.CLICK,DBLCLICK:yi.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Yy={ACTIVE:"active"};var Ky=class extends gr{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Yy.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Yy.ACTIVE,t)}setMap(t){this.map_=t}};var nw=Ky;var sw=function(h){let t=h.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var ow=Hp,aw=function(h){return h.type==Gn.CLICK};var lw=function(h){return h.type==Gn.SINGLECLICK};var cw=function(h){let t=h.originalEvent;return di(t!==void 0,"mapBrowserEvent must originate from a pointer event"),t.isPrimary&&t.button===0};var Jy=class extends nw{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==Gn.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Gn.POINTERUP){let l=this.handleUpEvent(t);this.handlingDownUpSequence=l&&this.targetPointers.length>0}}else if(t.type==Gn.POINTERDOWN){let l=this.handleDownEvent(t);this.handlingDownUpSequence=l,r=this.stopDown(l)}else t.type==Gn.POINTERMOVE&&this.handleMoveEvent(t);return!r}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};var hw=Jy;var Qy=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=is,this.supportedMediaTypes=null}getReadOptions(t,r){if(r){let l=r.dataProjection?Ri(r.dataProjection):this.readProjection(t);r.extent&&l&&l.getUnits()==="tile-pixels"&&(l=Ri(l),l.setWorldExtent(r.extent)),r={dataProjection:l,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return St()}readFeature(t,r){return St()}readFeatures(t,r){return St()}readGeometry(t,r){return St()}readProjection(t){return St()}writeFeature(t,r){return St()}writeFeatures(t,r){return St()}writeGeometry(t,r){return St()}},uw=Qy;function Uf(h,t,r){let l=r?Ri(r.featureProjection):null,c=r?Ri(r.dataProjection):null,n=h;if(l&&c&&!gb(l,c)){t&&(n=h.clone());let x=t?l:c,b=t?c:l;x.getUnits()==="tile-pixels"?n.transform(x,b):n.applyTransform(fl(x,b))}if(t&&r&&r.decimals!==void 0){let x=Math.pow(10,r.decimals),b=function(S){for(let R=0,E=S.length;R<E;++R)S[R]=Math.round(S[R]*x)/x;return S};n===h&&(n=h.clone()),n.applyTransform(b)}return n}var wM={Point:yr,LineString:Cs,Polygon:zc,MultiPoint:ju,MultiLineString:g_,MultiPolygon:S_};function SM(h,t,r){return Array.isArray(t[0])?(yf(h,0,t,r)||(h=h.slice(),Vu(h,0,t,r)),h):(Gu(h,0,t,r)||(h=h.slice(),Fc(h,0,t,r)),h)}function e0(h,t){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(n=>e0({...h,geometry:n})).flat();let l=r.type==="MultiPolygon"?"Polygon":r.type;if(l==="GeometryCollection"||l==="Circle")throw new Error("Unsupported geometry type: "+l);let c=r.layout.length;return Uf(new Rs(l,l==="Polygon"?SM(r.flatCoordinates,r.ends,c):r.flatCoordinates,r.ends?.flat(),c,h.properties||{},h.id).enableSimplifyTransformed(),!1,t)}function Zf(h,t){if(!h)return null;if(Array.isArray(h)){let l=h.map(c=>Zf(c,t));return new l_(l)}let r=wM[h.type];return Uf(new r(h.flatCoordinates,h.layout||"XY",h.ends),!1,t)}var t0=class extends uw{constructor(){super()}getType(){return"json"}readFeature(t,r){return this.readFeatureFromObject(qf(t),this.getReadOptions(t,r))}readFeatures(t,r){return this.readFeaturesFromObject(qf(t),this.getReadOptions(t,r))}readFeatureFromObject(t,r){return St()}readFeaturesFromObject(t,r){return St()}readGeometry(t,r){return this.readGeometryFromObject(qf(t),this.getReadOptions(t,r))}readGeometryFromObject(t,r){return St()}readProjection(t){return this.readProjectionFromObject(qf(t))}readProjectionFromObject(t){return St()}writeFeature(t,r){return JSON.stringify(this.writeFeatureObject(t,r))}writeFeatureObject(t,r){return St()}writeFeatures(t,r){return JSON.stringify(this.writeFeaturesObject(t,r))}writeFeaturesObject(t,r){return St()}writeGeometry(t,r){return JSON.stringify(this.writeGeometryObject(t,r))}writeGeometryObject(t,r){return St()}};function qf(h){if(typeof h=="string"){let t=JSON.parse(h);return t||null}return h!==null?h:null}var dw=t0;var i0=class extends dw{constructor(t){t=t||{},super(),this.dataProjection=Ri(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Ri(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,r){let l=null;t.type==="Feature"?l=t:l={type:"Feature",geometry:t,properties:null};let c=n0(l.geometry,r);if(this.featureClass===Rs)return e0({geometry:c,id:l.id,properties:l.properties},r);let n=new is;return this.geometryName_?n.setGeometryName(this.geometryName_):this.extractGeometryName_&&l.geometry_name&&n.setGeometryName(l.geometry_name),n.setGeometry(Zf(c,r)),"id"in l&&n.setId(l.id),l.properties&&n.setProperties(l.properties,!0),n}readFeaturesFromObject(t,r){let l=t,c=null;if(l.type==="FeatureCollection"){let n=t;c=[];let x=n.features;for(let b=0,S=x.length;b<S;++b){let R=this.readFeatureFromObject(x[b],r);R&&c.push(R)}}else c=[this.readFeatureFromObject(t,r)];return c.flat()}readGeometryFromObject(t,r){return TM(t,r)}readProjectionFromObject(t){let r=t.crs,l;if(r)if(r.type=="name")l=Ri(r.properties.name);else if(r.type==="EPSG")l=Ri("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else l=this.dataProjection;return l}writeFeatureObject(t,r){r=this.adaptOptions(r);let l={type:"Feature",geometry:null,properties:null},c=t.getId();if(c!==void 0&&(l.id=c),!t.hasProperties())return l;let n=t.getProperties(),x=t.getGeometry();return x&&(l.geometry=r0(x,r),delete n[t.getGeometryName()]),On(n)||(l.properties=n),l}writeFeaturesObject(t,r){r=this.adaptOptions(r);let l=[];for(let c=0,n=t.length;c<n;++c)l.push(this.writeFeatureObject(t[c],r));return{type:"FeatureCollection",features:l}}writeGeometryObject(t,r){return r0(t,this.adaptOptions(r))}};function n0(h,t){if(!h)return null;let r;switch(h.type){case"Point":{r=MM(h);break}case"LineString":{r=IM(h);break}case"Polygon":{r=AM(h);break}case"MultiPoint":{r=PM(h);break}case"MultiLineString":{r=EM(h);break}case"MultiPolygon":{r=RM(h);break}case"GeometryCollection":{r=CM(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function TM(h,t){let r=n0(h,t);return Zf(r,t)}function CM(h,t){return h.geometries.map(function(l){return n0(l,t)})}function MM(h){let t=h.coordinates;return{type:"Point",flatCoordinates:t,layout:la(t.length)}}function IM(h){let t=h.coordinates,r=t.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:la(t[0]?.length||2)}}function EM(h){let t=h.coordinates,r=t[0]?.[0]?.length||2,l=[],c=ca(l,0,t,r);return{type:"MultiLineString",flatCoordinates:l,ends:c,layout:la(r)}}function PM(h){let t=h.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:la(t[0]?.length||2)}}function RM(h){let t=h.coordinates,r=[],l=t[0]?.[0]?.[0].length||2,c=df(r,0,t,l);return{type:"MultiPolygon",flatCoordinates:r,ends:c,layout:la(l)}}function AM(h){let t=h.coordinates,r=[],l=t[0]?.[0]?.length,c=ca(r,0,t,l);return{type:"Polygon",flatCoordinates:r,ends:c,layout:la(l)}}function r0(h,t){h=Uf(h,!0,t);let r=h.getType(),l;switch(r){case"Point":{l=OM(h,t);break}case"LineString":{l=kM(h,t);break}case"Polygon":{l=BM(h,t);break}case"MultiPoint":{l=FM(h,t);break}case"MultiLineString":{l=DM(h,t);break}case"MultiPolygon":{l=zM(h,t);break}case"GeometryCollection":{l=LM(h,t);break}case"Circle":{l={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return l}function LM(h,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(l){return r0(l,t)})}}function kM(h,t){return{type:"LineString",coordinates:h.getCoordinates()}}function DM(h,t){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function FM(h,t){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function zM(h,t){let r;return t&&(r=t.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function OM(h,t){return{type:"Point",coordinates:h.getCoordinates()}}function BM(h,t){let r;return t&&(r=t.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var vr=i0;var pw=0,md=1,fw=[0,0,0,0],Kc=[],s0={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},gd=class extends Ei{constructor(t,r,l){super(t),this.features=r,this.mapBrowserEvent=l}},o0=class extends hw{constructor(t){super(t),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=t.condition?t.condition:cw,this.defaultDeleteCondition_=function(l){return sw(l)&&lw(l)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:ow,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new rd,this.pixelTolerance_=t.pixelTolerance!==void 0?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Yc({source:new bl({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:NM(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(t.features?r=t.features:t.source&&(this.source_=t.source,r=new Xu(this.source_.getFeatures()),this.source_.addEventListener(qr.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(qr.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Es.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Es.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=t.snapToPointer===void 0?!this.hitDetection_:t.snapToPointer}addFeature_(t){let r=t.getGeometry();if(r){let c=this.SEGMENT_WRITERS_[r.getType()];c&&c(t,r)}let l=this.getMap();l&&l.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(l.getCoordinateFromPixel(this.lastPixel_)),t.addEventListener(yi.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(t,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Xu;let l=this.featuresBeingModified_.getArray();for(let c=0,n=r.length;c<n;++c){let x=r[c].feature;x&&!l.includes(x)&&this.featuresBeingModified_.push(x)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new gd(s0.MODIFYSTART,this.featuresBeingModified_,t))}}removeFeature_(t){this.removeFeatureSegmentData_(t),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.removeEventListener(yi.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(t){let r=this.rBush_,l=[];r.forEach(function(c){t===c.feature&&l.push(c)});for(let c=l.length-1;c>=0;--c){let n=l[c];for(let x=this.dragSegments_.length-1;x>=0;--x)this.dragSegments_[x][0]===n&&this.dragSegments_.splice(x,1);r.remove(n)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){t.feature&&this.features_.push(t.feature)}handleSourceRemove_(t){t.feature&&this.features_.remove(t.feature)}handleFeatureAdd_(t){this.addFeature_(t.element)}handleFeatureChange_(t){if(!this.changingFeature_){let r=t.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(t){this.removeFeature_(t.element)}writePointGeometry_(t,r){let l=r.getCoordinates(),c={feature:t,geometry:r,segment:[l,l]};this.rBush_.insert(r.getExtent(),c)}writeMultiPointGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c],b={feature:t,geometry:r,depth:[c],index:c,segment:[x,x]};this.rBush_.insert(r.getExtent(),b)}}writeLineStringGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length-1;c<n;++c){let x=l.slice(c,c+2),b={feature:t,geometry:r,index:c,segment:x};this.rBush_.insert(Yn(x),b)}}writeMultiLineStringGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c];for(let b=0,S=x.length-1;b<S;++b){let R=x.slice(b,b+2),E={feature:t,geometry:r,depth:[c],index:b,segment:R};this.rBush_.insert(Yn(R),E)}}}writePolygonGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c];for(let b=0,S=x.length-1;b<S;++b){let R=x.slice(b,b+2),E={feature:t,geometry:r,depth:[c],index:b,segment:R};this.rBush_.insert(Yn(R),E)}}}writeMultiPolygonGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c];for(let b=0,S=x.length;b<S;++b){let R=x[b];for(let E=0,A=R.length-1;E<A;++E){let z=R.slice(E,E+2),W={feature:t,geometry:r,depth:[b,c],index:E,segment:z};this.rBush_.insert(Yn(z),W)}}}}writeCircleGeometry_(t,r){let l=r.getCenter(),c={feature:t,geometry:r,index:pw,segment:[l,l]},n={feature:t,geometry:r,index:md,segment:[l,l]},x=[c,n];c.featureSegments=x,n.featureSegments=x,this.rBush_.insert(sa(l),c);let b=r,S=Bn();if(S&&this.getMap()){let R=this.getMap().getView().getProjection();b=b.clone().transform(S,R),b=b_(b).transform(R,S)}this.rBush_.insert(b.getExtent(),n)}writeGeometryCollectionGeometry_(t,r){let l=r.getGeometriesArray();for(let c=0;c<l.length;++c){let n=l[c],x=this.SEGMENT_WRITERS_[n.getType()];x(t,n)}}createOrUpdateVertexFeature_(t,r,l,c){let n=this.vertexFeature_;return n?n.getGeometry().setCoordinates(t):(n=new is(new yr(t)),this.vertexFeature_=n,this.overlay_.getSource().addFeature(n)),n.set("features",r),n.set("geometries",l),n.set("existing",c),n}handleEvent(t){if(!t.originalEvent)return!0;this.lastPointerEvent_=t;let r;return!t.map.getView().getInteracting()&&t.type==Gn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(t.type!=Gn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),t.type==Gn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!r}findInsertVerticesAndUpdateDragSegments_(t){this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null;let r=this.vertexFeature_;if(!r)return;let l=this.getMap().getView().getProjection(),c=[],n=r.getGeometry().getCoordinates(),x=Yn([n]),b=this.rBush_.getInExtent(x),S={};b.sort(jM);for(let R=0,E=b.length;R<E;++R){let A=b[R],z=A.segment,W=Vt(A.geometry),ne=A.depth;if(ne&&(W+="-"+ne.join("-")),S[W]||(S[W]=new Array(2)),A.geometry.getType()==="Circle"&&A.index===md){let ge=gw(t,A,l);or(ge,n)&&!S[W][0]&&(this.dragSegments_.push([A,0]),S[W][0]=A);continue}if(or(z[0],n)&&!S[W][0]){this.dragSegments_.push([A,0]),S[W][0]=A;continue}if(or(z[1],n)&&!S[W][1]){if(S[W][0]&&S[W][0].index===0){let ge=A.geometry.getCoordinates();switch(A.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":ge=ge[ne[1]];case"Polygon":if(A.index!==ge[ne[0]].length-2)continue;break;default:}}this.dragSegments_.push([A,1]),S[W][1]=A;continue}Vt(z)in this.vertexSegments_&&!S[W][0]&&!S[W][1]&&c.push(A)}return c}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([n])=>n));let r=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],l=[],c=[];for(let n=0,x=this.dragSegments_.length;n<x;++n){let b=this.dragSegments_[n],S=b[0],R=S.feature;l.includes(R)||l.push(R);let E=S.geometry;c.includes(E)||c.push(E);let A=S.depth,z,W=S.segment,ne=b[1];for(;r.length<E.getStride();)r.push(W[ne][r.length]);switch(E.getType()){case"Point":z=r,W[0]=r,W[1]=r;break;case"MultiPoint":z=E.getCoordinates(),z[S.index]=r,W[0]=r,W[1]=r;break;case"LineString":z=E.getCoordinates(),z[S.index+ne]=r,W[ne]=r;break;case"MultiLineString":z=E.getCoordinates(),z[A[0]][S.index+ne]=r,W[ne]=r;break;case"Polygon":z=E.getCoordinates(),z[A[0]][S.index+ne]=r,W[ne]=r;break;case"MultiPolygon":z=E.getCoordinates(),z[A[1]][A[0]][S.index+ne]=r,W[ne]=r;break;case"Circle":let ge=E;if(W[0]=r,W[1]=r,S.index===pw)this.changingFeature_=!0,ge.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let me=t.map.getView().getProjection(),ve=qg(zi(ge.getCenter(),me),zi(r,me)),Te=Bn();if(Te){let Oe=ge.clone().transform(Te,me);Oe.setRadius(ve),ve=Oe.transform(me,Te).getRadius()}ge.setRadius(ve),this.changingFeature_=!1}break;default:}z&&this.setGeometryCoordinates_(E,z)}this.createOrUpdateVertexFeature_(r,l,c,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;let r=t.coordinate,l=this.findInsertVerticesAndUpdateDragSegments_(r);if(l?.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,l),this.vertexFeature_)){let c=this.vertexFeature_.getGeometry().getCoordinates();for(let n=l.length-1;n>=0;--n)this.insertVertex_(l[n],c);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let r=this.dragSegments_.length-1;r>=0;--r){let l=this.dragSegments_[r][0],c=l.geometry;if(c.getType()==="Circle"){let n=c,x=n.getCenter(),b=l.featureSegments[0],S=l.featureSegments[1];b.segment[0]=x,b.segment[1]=x,S.segment[0]=x,S.segment[1]=x,this.rBush_.update(sa(x),b);let R=n,E=Bn();if(E){let A=t.map.getView().getProjection();R=R.clone().transform(E,A),R=b_(R).transform(A,E)}this.rBush_.update(R.getExtent(),S)}else this.rBush_.update(Yn(l.segment),l)}return this.featuresBeingModified_&&(this.dispatchEvent(new gd(s0.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.coordinate)}handlePointerAtPixel_(t){let r=this.getMap(),l=r.getPixelFromCoordinate(t),c=r.getView().getProjection(),n=function(S,R){return mw(t,S,c)-mw(t,R,c)},x,b;if(this.hitDetection_){let S=typeof this.hitDetection_=="object"?R=>R===this.hitDetection_:void 0;r.forEachFeatureAtPixel(l,(R,E,A)=>{A&&A.getType()==="Point"&&(A=new yr(aa(A.getCoordinates(),c)));let z=A||R.getGeometry();if(z&&z.getType()==="Point"&&R instanceof is&&this.features_.getArray().includes(R)){b=z;let W=R.getGeometry().getFlatCoordinates().slice(0,2);x=[{feature:R,geometry:b,segment:[W,W]}]}return!0},{layerFilter:S})}if(!x){let S=Zs(sa(t,fw),c),R=r.getView().getResolution()*this.pixelTolerance_,E=Us(Kn(S,R,fw),c);x=this.rBush_.getInExtent(E)}if(x&&x.length>0){let S=x.sort(n)[0],R=S.segment,E=gw(t,S,c),A=r.getPixelFromCoordinate(E),z=qg(l,A);if(b||z<=this.pixelTolerance_){let W={};if(W[Vt(R)]=!0,this.snapToPointer_||(this.delta_[0]=E[0]-t[0],this.delta_[1]=E[1]-t[1]),S.geometry.getType()==="Circle"&&S.index===md)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(E,[S.feature],[S.geometry],this.snappedToVertex_);else{let ne=r.getPixelFromCoordinate(R[0]),ge=r.getPixelFromCoordinate(R[1]),me=Ec(A,ne),ve=Ec(A,ge);if(z=Math.sqrt(Math.min(me,ve)),this.snappedToVertex_=z<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(E=me>ve?R[1]:R[0]),this.createOrUpdateVertexFeature_(E,[S.feature],[S.geometry],this.snappedToVertex_);let Te={};Te[Vt(S.geometry)]=!0;for(let Oe=1,Pe=x.length;Oe<Pe;++Oe){let ze=x[Oe].segment;if(or(R[0],ze[0])&&or(R[1],ze[1])||or(R[0],ze[1])&&or(R[1],ze[0])){let Me=Vt(x[Oe].geometry);Me in Te||(Te[Me]=!0,W[Vt(ze)]=!0)}else break}}this.vertexSegments_=W;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,r){let l=t.segment,c=t.feature,n=t.geometry,x=t.depth,b=t.index,S;for(;r.length<n.getStride();)r.push(0);switch(n.getType()){case"MultiLineString":S=n.getCoordinates(),S[x[0]].splice(b+1,0,r);break;case"Polygon":S=n.getCoordinates(),S[x[0]].splice(b+1,0,r);break;case"MultiPolygon":S=n.getCoordinates(),S[x[1]][x[0]].splice(b+1,0,r);break;case"LineString":S=n.getCoordinates(),S.splice(b+1,0,r);break;default:return!1}this.setGeometryCoordinates_(n,S);let R=this.rBush_;R.remove(t),this.updateSegmentIndices_(n,b,x,1);let E={segment:[l[0],r],feature:c,geometry:n,depth:x,index:b};R.insert(Yn(E.segment),E),this.dragSegments_.push([E,1]);let A={segment:[r,l[1]],feature:c,geometry:n,depth:x,index:b+1};return R.insert(Yn(A.segment),A),this.dragSegments_.push([A,0]),!0}updatePointer_(t){return t&&this.findInsertVerticesAndUpdateDragSegments_(t),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){let t=this.vertexFeature_?.getGeometry().getCoordinates();return t?aa(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(l=>l.getType()==="Circle"||l.getType().endsWith("Point")))return!1;let t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Yn([t])).some(({segment:l})=>or(l[0],t)||or(l[1],t))}removePoint(t){if(t&&(t=zi(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Gn.POINTERDRAG){let r=this.lastPointerEvent_;this.willModifyFeatures_(r,this.dragSegments_.map(([c])=>c));let l=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new gd(s0.MODIFYEND,this.featuresBeingModified_,r)),this.featuresBeingModified_=null,l}return!1}removeVertex_(){let t=this.dragSegments_,r={},l=!1,c,n,x,b,S,R,E,A,z,W,ne;for(S=t.length-1;S>=0;--S)x=t[S],W=x[0],ne=Vt(W.feature),W.depth&&(ne+="-"+W.depth.join("-")),ne in r||(r[ne]={}),x[1]===0?(r[ne].right=W,r[ne].index=W.index):x[1]==1&&(r[ne].left=W,r[ne].index=W.index+1);for(ne in r){switch(z=r[ne].right,E=r[ne].left,R=r[ne].index,A=R-1,E!==void 0?W=E:W=z,A<0&&(A=0),b=W.geometry,n=b.getCoordinates(),c=n,l=!1,b.getType()){case"MultiLineString":n[W.depth[0]].length>2&&(n[W.depth[0]].splice(R,1),l=!0);break;case"LineString":n.length>2&&(n.splice(R,1),l=!0);break;case"MultiPolygon":c=c[W.depth[1]];case"Polygon":c=c[W.depth[0]],c.length>4&&(R==c.length-1&&(R=0),c.splice(R,1),l=!0,R===0&&(c.pop(),c.push(c[0]),A=c.length-1));break;default:}if(l){this.setGeometryCoordinates_(b,n);let ge=[];if(E!==void 0&&(this.rBush_.remove(E),ge.push(E.segment[0])),z!==void 0&&(this.rBush_.remove(z),ge.push(z.segment[1])),E!==void 0&&z!==void 0){let me={depth:W.depth,feature:W.feature,geometry:W.geometry,index:A,segment:ge};this.rBush_.insert(Yn(me.segment),me)}this.updateSegmentIndices_(b,R,W.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return l}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(l=>l.getType()==="Circle"||l.getType().endsWith("Point")))return!1;let t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Yn([t])).some(({segment:l})=>!(or(l[0],t)||or(l[1],t)))}insertPoint(t){let r=t?zi(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return r?this.findInsertVerticesAndUpdateDragSegments_(r).reduce((c,n)=>c||this.insertVertex_(n,r),!1):!1}setGeometryCoordinates_(t,r){this.changingFeature_=!0,t.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(t,r,l,c){this.rBush_.forEachInExtent(t.getExtent(),function(n){n.geometry===t&&(l===void 0||n.depth===void 0||yn(n.depth,l))&&n.index>r&&(n.index+=c)})}};function jM(h,t){return h.index-t.index}function mw(h,t,r){let l=t.geometry;if(l.getType()==="Circle"){let n=l;if(t.index===md){let x=Bn();x&&(n=n.clone().transform(x,r));let b=Ec(n.getCenter(),zi(h,r)),S=Math.sqrt(b)-n.getRadius();return S*S}}let c=zi(h,r);return Kc[0]=zi(t.segment[0],r),Kc[1]=zi(t.segment[1],r),Yv(c,Kc)}function gw(h,t,r){let l=t.geometry;if(l.getType()==="Circle"&&t.index===md){let n=l,x=Bn();return x&&(n=n.clone().transform(x,r)),aa(n.getClosestPoint(zi(h,r)),r)}let c=zi(h,r);return Kc[0]=zi(t.segment[0],r),Kc[1]=zi(t.segment[1],r),aa(Zg(c,Kc),r)}function NM(){let h=M1();return function(t,r){return h.Point}}var a0=o0;var GM=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,_w=/^([\d.]+),([\d.]+)$/,yw=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,Wf="stop-fetch",xw=h=>{let t=[];return h.forEach(r=>{let l=r.getGeometry()?.getCoordinates();l?.length&&t.push(...l)}),t},l0=class h extends jc{constructor(r={}){super(r);this.abortControllers={};this.cacheStationData={};this.format=new vr({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.apiParams=r.apiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new wu({...r}),this.routingLayer=r.routingLayer||new Yc({source:new bl,style:r.style}),this.onRouteError=r.onRouteError||(l=>{this.dispatchEvent(new Ei("change:route")),this.reset(),console.error(l)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",l=>{l.key==="active"&&this.onActiveChange(),l.key==="mot"&&this.viaPoints&&this.drawRoute()})}static getGraphsResolutions(r,l){let c=l.getView();return r.map(([,n,x])=>[c.getResolutionForZoom(n),c.getResolutionForZoom(x||n+1)])}abortRequests(){this.graphs.forEach(r=>{let l=r[0];this.abortControllers[l]&&this.abortControllers[l].abort(),this.abortControllers[l]=new AbortController}),this.abortControllers[Wf]?.abort(),this.abortControllers[Wf]=new AbortController,this.loading=!1}activate(){let r=this.getMap();r&&(this.format=new vr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(r,l=-1,c=0){this.viaPoints.splice(l===-1?this.viaPoints.length:l,c,r),this.drawRoute(),this.dispatchEvent(new Ei("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new a0({deleteCondition:r=>{let c=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})||[]).find(n=>n.getGeometry()?.getType()==="Point"&&n.get("index"));return aw(r)&&c?(this.removeViaPoint(c.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[Wf]);let r=this.viaPoints.map(l=>{if(Array.isArray(l)){let c=this.getMap()?.getView().getProjection(),[n,x]=pl(l,c);return this.snapToClosestStation?[`@${x}`,n]:[x,n]}return this.useRawViaPoints?l:`!${l}`});return this.loading=!0,this.viaPoints.forEach((l,c)=>{this.drawViaPoint(l,c,this.abortControllers[Wf])}),Promise.all(this.graphs.map(([l],c)=>{let{signal:n}=this.abortControllers[l];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:l,mot:this.mot,"resolve-hops":!1,via:`${r.join("|")}`,...this.apiParams||{}},{signal:n}).then(x=>{if(this.segments=this.format.readFeatures(x),this.mot==="foot"){let R=this.segments.reduce((E,A)=>{let z=A.get("trg");return E.find(W=>W[0]===z[0]&&W[1]===z[1])?E:[...E,z]},[]);this.segments=R.map(E=>{let A=this.segments.filter(W=>{let ne=W.get("trg");return ne[0]===E[0]&&ne[1]===E[1]}),z=xw(A);return new is({geometry:new Cs(z)})})}let b=xw(this.segments),S=new is({geometry:new Cs(b)});S.set("graph",l),S.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[c]?.length>=2&&(S.set("minResolution",this.graphsResolutions[c][0]),S.set("maxResolution",this.graphsResolutions[c][1])),this.routingLayer?.getSource()?.addFeature(S),this.loading=!1}).catch(x=>{/AbortError/.test(x.name)||(this.segments=[],this.dispatchEvent(new Ei("error")),this.onRouteError(x,this),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,l,c){let n=new is;if(n.set("viaPointIdx",l),Array.isArray(r))return n.setGeometry(new yr(r)),this.routingLayer?.getSource()?.addFeature(n),Promise.resolve(n);if(!this.useRawViaPoints||yw.test(r)){let E,A;return this.useRawViaPoints?[,E,,A]=yw.exec(r)||[]:[E,A]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${E}?key=${this.stopsApiKey}`,{signal:c.signal}).then(z=>z.json()).then(z=>{let{coordinates:W}=z?.features?.[0]?.geometry||{};return W||console.log("No coordinates found for station "+E,z),this.cacheStationData[r]=_r(W),n.set("viaPointTrack",A),n.setGeometry(new yr(_r(W))),this.routingLayer?.getSource()?.addFeature(n),n}).catch(z=>{/AbortError/.test(z.message)||(this.dispatchEvent(new Ei("error")),this.onRouteError(z,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)})}if(this.useRawViaPoints&&_w.test(r)){let[E,A]=_w.exec(r)||[];if(A&&E){let z=parseFloat(A),W=parseFloat(E),ne=_r([z,W],this.getMap()?.getView().getProjection());return n.setGeometry(new yr(ne)),this.routingLayer?.getSource()?.addFeature(n),Promise.resolve(n)}}let[,x,,b,S,,R]=GM.exec(r)||[];if(S&&b){let E=_r([parseFloat(S),parseFloat(b)],this.getMap()?.getView().getProjection());return n.set("viaPointTrack",R),n.setGeometry(new yr(E)),this.routingLayer?.getSource()?.addFeature(n),Promise.resolve(n)}return x?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${x}&limit=1`,{signal:c.signal}).then(E=>E.json()).then(E=>{let{coordinates:A}=E.features[0].geometry;return this.cacheStationData[r]=_r(A),n.set("viaPointTrack",R),n.setGeometry(new yr(_r(A))),this.routingLayer?.getSource()?.addFeature(n),n}).catch(E=>(this.dispatchEvent(new Ei("error")),this.onRouteError(E,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(r){let c=r.target.getFeaturesAtPixel(r.pixel,{hitTolerance:5,layerFilter:n=>n===this.routingLayer}).find(n=>n.getGeometry()?.getType()==="Point"&&n.get("viaPointIdx")!==void 0);if(c){this.removeViaPoint(c.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyEnd(r){let l=r.mapBrowserEvent.coordinate,{oldRoute:c,segmentIndex:n,viaPoint:x}=this.initialRouteDrag||{};return x?this.addViaPoint(l,x.get("viaPointIdx"),1):c?n===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(l,(n||0)+1):this.addViaPoint(l,0,1)}onModifyStart(r){let l=-1,c=r.features.getArray().find(x=>x.getGeometry()?.getType()==="LineString");if(c?.getGeometry()&&r.mapBrowserEvent.coordinate){let x=Kn(new yr(c.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);l=this.segments.findIndex(b=>b.getGeometry()?.intersectsExtent(x))}let n=(r.features.getArray().filter(x=>x.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={oldRoute:c?.clone(),segmentIndex:l,viaPoint:n}}removeListeners(){this.onMapClickKey&&ws(this.onMapClickKey)}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new Ei("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Ei("change:route"))}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new Ei("change:route"))}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}},vw=l0;var c0=class{constructor(t){let{apiKey:r,apiParams:l,placeholder:c,url:n}=t||{};this.apiParams={limit:20,...l||{}},this.placeholder=c||"Search for a stop...";let x={apiKey:r};n&&(x.url=n),this.api=new Su(x),this.abortController=new AbortController,this.createElement(t),this.options=t}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:t}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),t.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",cursor:"pointer",overflowY:"auto"}),t.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),t.appendChild(this.clearElt)}render(t){let r=t?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(l=>{let c=document.createElement("div");c.innerHTML=l?.properties?.name,c.onclick=n=>{this.options?.onSuggestionClick?.(l,n)},Object.assign(c.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(c)}))}search(t,r){return(t!==void 0||t!==null)&&(this.apiParams.q=t),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(l=>{this.render(l)}).catch(()=>{this.render()})}},bw=c0;var VM=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},ww=VM;var h0=class extends jc{constructor(t){let r=ww();r.className=t?.className||"mbt-stop-finder";let l={element:r,...t||{}};super(l),this.controller=new bw({onSuggestionClick:this.onSuggestionClick.bind(this),...l})}onSuggestionClick(t){let r=_r(t.geometry.coordinates);this.getMap()?.getView().setCenter(r)}search(t,r){return this.controller.search(t,r)}},Sw=h0;var Ew=Vs(Tl());var Iw=Vs(Tl()),ji=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(ji=(0,Iw.default)(h=>{console.warn(h)},1e3));var oI=(h,t)=>{(t||[]).forEach(r=>{r.set("parent",void 0)}),(h.get("children")||[]).forEach(r=>{r.set("parent",void 0)})},aI=(h,t)=>{t.properties&&(ji("Deprecated. Don't use properties options. Pass the values directly in options object."),h.setProperties(t.properties)),h.on("propertychange",r=>{if(r.key==="children"&&oI(r.target,r.oldValue),r.key==="map"){let l=r.target.get(r.key);l?(r.target.get("children")||[]).forEach(c=>{l.addLayer(c)}):r.oldValue&&(r.target.get("children")||[]).forEach(c=>{r.oldValue.removeLayer(c)})}}),h.set("options",t),h.set("children",t.children||[]),Object.defineProperties(h,{children:{get:()=>(ji("Layer.children is deprecated. Use the Layer.get('children') method instead."),h.get("children")||[]),set:r=>{ji("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),h.set("children",r||[])}},copyrights:{get:()=>(ji("Layer.copyrights is deprecated. Get the attributions from the source object"),h.get("copyrights")),set:r=>{ji("Layer.copyrights is deprecated. Set the attributions to the source object.");let l=r&&!Array.isArray(r)?[r]:r;h.set("copyrights",l||[])}},disabled:{get(){return ji("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),h.get("disabled")},set(r){ji("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),h.set("disabled",r)}},group:{get(){return ji("Layer.group is deprecated. Use the Layer.get('group') method instead."),h.get("group")}},hitTolerance:{get(){return ji("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.get("hitTolerance")||5},set(r){ji("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.set("hitTolerance",r)}},key:{get(){return ji('Layer.key is deprecated. Use the Layer.get("key") method instead.'),h.get("key")||h.get("name")}},map:{get(){return ji('Layer.map is deprecated. Use the Layer.get("map") method instead.'),h.getMapInternal()}},name:{get(){return ji("Layer.name is deprecated. Use the Layer.get('name') method instead."),h.get("name")}},olLayer:{get(){return ji("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object."),h},set(){ji("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect.")}},options:{get(){return ji('Layer.options is deprecated. Use the Layer.get("options") method instead.'),h.get("options")},set(r){return ji('Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.'),h.set("options",r)}},parent:{get(){return ji("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),h.get("parent")},set(r){ji("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),h.set("parent",r)}},visible:{get(){return ji("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),h.getVisible()},set(r){ji("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),h.setVisible(r)}}})},wa=aI;var Pw=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Pw=(0,Ew.default)(h=>{console.warn(h)},1e3));var p0=class extends xa{prepareFrame(){return!0}renderFrame(){return null}},f0=class h extends Is{constructor(t){super(t),wa(this,t),Pw("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(t){return new h({...this.get("options")||{},...t||{}})}createRenderer(){return new p0(this)}},$f=f0;var Aw=Vs(_0(),1);var lI="vectorTileFeature",y0={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},Sa=class extends xa{translateZoom;constructor(t,r){super(t),this.translateZoom=r}getFeaturesAtCoordinate(t,r=5){let l=this.getMapLibrePixels(t,r);if(!l)return[];let c=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(l,c).map(x=>this.toOlFeature(x))||[]}prepareFrame(){return!0}renderFrame(t){let r=this.getLayer(),{mapLibreMap:l}=r,c=r.getMapInternal();if(!r||!c||!l)return null;let n=l.getCanvas(),{viewState:x}=t;l.jumpTo({center:pl(x.center,x.projection),zoom:(this.translateZoom?this.translateZoom(x.zoom):x.zoom)-1,bearing:Eu(-x.rotation)});let b=r.getOpacity().toString();return n&&b!==n.style.opacity&&(n.style.opacity=b),n.isConnected?cI(n,t)||l.resize():c.render(),l.redraw(),l.getContainer()}getFeatures(t){let r=this.getLayer().getMapInternal()?.getCoordinateFromPixel(t);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(t,r,l,c){let n=this.getFeaturesAtCoordinate(t,l);return n.forEach(x=>{let b=x.getGeometry();b instanceof Rr&&c(x,this.getLayer(),b)}),n?.[0]}getMapLibrePixels(t,r){if(!t)return;let l=this.getLayer().mapLibreMap?.project(pl(t));if(l?.x===void 0||l?.y===void 0)return;let c=[l.x,l.y];if(r){let[n,x]=c;c=[[n-r,x-r],[n+r,x+r]]}return c}toOlFeature(t){let c=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";y0[c]||(y0[c]=new vr({featureProjection:c}));let n=y0[c].readFeature(t);return n&&n.set(lI,t,!0),n}};function cI(h,t){return h.width===Math.floor(t.size[0]*t.pixelRatio)&&h.height===Math.floor(t.size[1]*t.pixelRatio)}var hI=h=>{if(!h)return[];let{style:t}=h;if(!t)return[];let{sourceCaches:r}=t,l=[];return Object.values(r).forEach(c=>{if(c.used){let{attribution:n}=c.getSource();n&&(l=l.concat(n.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),uI(l)},uI=h=>{let t=h.filter(c=>c!=null&&c.trim&&c.trim()),r=t.map(c=>c.toLowerCase());return[...new Set(r)].map(c=>t.find(n=>n.toLowerCase()===c))},x0=hI;var Jc=class extends Is{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(t){super({source:new Eo({attributions:()=>x0(this.mapLibreMap)}),...t})}disposeInternal(){ws(this.olListenersKeys),this.loaded=!1,this.mapLibreMap&&(this.mapLibreMap.triggerRepaint=()=>{},this.mapLibreMap.remove()),super.disposeInternal()}setMapInternal(t){super.setMapInternal(t),t?this.loadMapLibreMap():this.dispose()}loadMapLibreMap(){this.loaded=!1;let t=this.getMapInternal();if(t&&this.olListenersKeys.push(t.on("change:target",this.loadMapLibreMap.bind(this))),!t?.getTargetElement())return;if(!this.getVisible()){this.olListenersKeys.push(this.once("change:visible",this.loadMapLibreMap.bind(this)));return}let r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";let l=this.get("mapLibreOptions");this.mapLibreMap=new Aw.Map(Object.assign({},l,{container:r,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Ei("load"))})}createRenderer(){let t=this.get("translateZoom");return new Sa(this,t)}};var w0=Vs(Tl());var _d=class extends Sa{constructor(r,l){super(r,l);this.ignoreNextRender=!1;this.setIsReady=this.setIsReady.bind(this),this.ignoreNextRender=!1}renderFrame(r){let l=this.getLayer(),{mapLibreMap:c}=l,n=l.getMapInternal();if(!l||!n||!c)return null;if(this.ready&&this.ignoreNextRender)return this.ignoreNextRender=!1,c?.getContainer();this.ready=!1,this.ignoreNextRender=!1,this.updateReadyState();let x=super.renderFrame(r);return c?.once("idle",this.setIsReady),x}setIsReady(){console.log("ici"),this.ready||(this.ready=!0,this.ignoreNextRender=!0,this.getLayer().changed())}updateReadyState(){this.getLayer()?.mapLibreMap?.off("idle",this.setIsReady),this.getLayer()?.mapLibreMap?.once("idle",this.setIsReady)}};var Lw=(h,t,r,l)=>sl(`${h}/styles/${t}/style.json`,{[l]:r}).toString(),v0=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(v0=(0,w0.default)(h=>{console.warn(h)},1e3));var b0=class h extends Jc{constructor(r){let l={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...r||{},mapLibreOptions:{...r.mapLibreOptions||{}}};!l.mapLibreOptions.style&&l.url?.includes("style.json")?l.mapLibreOptions.style=l.url:!l.mapLibreOptions.style&&l.apiKey&&l.style&&typeof l.style=="string"&&(l.mapLibreOptions.style=Lw(l.url,l.style,l.apiKey,l.apiKeyName));super(l);this.olEventsKeys=[];wa(this,r),this.set("options",r)}set apiKey(r){this.set("apiKey",r)}get apiKey(){return this.get("apiKey")}set apiKeyName(r){this.set("apiKeyName",r)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return v0("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return v0("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(r){this.set("style",r)}get url(){return this.get("url")}set url(r){this.set("url",r)}attachToMap(){let r=(0,w0.default)(this.updateMaplibreMap.bind(this),150);r(),this.olEventsKeys.push(this.on("propertychange",l=>{/(url|style|apiKey|apiKeyName)/.test(l.key)&&r()}))}clone(r){return new h({...this.get("options")||{},...r||{}})}createRenderer(){return new _d(this)}detachFromMap(){ws(this.olEventsKeys)}disposeInternal(){let r=this.getSource();super.disposeInternal(),this.setSource(r)}getStyle(){if(this.style&&typeof this.style=="object"&&this.style.name&&this.style.version)return this.style;if(this.url.includes("style.json"))return this.url;let r=this.get("options");return r?.mapLibreOptions?.style?r.mapLibreOptions.style:Lw(this.url,this.style,this.apiKey,this.apiKeyName)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(r){console.error("Error while updating MaplibreMap",r)}}},kw=b0;var Dw=Vs(Tl());var S0={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},yd=class extends xa{forEachFeatureAtCoordinate(t,r,l,c){let n=this.getFeaturesAtCoordinate(t,l);return n.forEach(x=>{c(x,this.layer_,x.getGeometry())}),n?.[0]}getFeatures(t){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(t);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(t,r=5){if(!t)return[];let l=this.getLayer(),c=l.getMapInternal(),n=l.maplibreLayer.mapLibreMap,x=c?.getView()?.getProjection()?.getCode()||"EPSG:3857",b=[];if(S0[x]||(S0[x]=new vr({featureProjection:x})),n?.isStyleLoaded()){let S=t&&n.project(pl(t));if(S?.x&&S?.y){let R=[S.x,S.y];if(r){let[A,z]=R;R=[[A-r,z-r],[A+r,z+r]]}let E=l.layers||[];l.layersFilter&&(E=n.getStyle().layers.filter(l.layersFilter)),l.queryRenderedLayersFilter&&(E=n.getStyle().layers.filter(l.queryRenderedLayersFilter)),b=n.queryRenderedFeatures(R,{layers:E.map(A=>A.id),validate:!1}).map(A=>{let z=S0[x].readFeature(A);return z&&z.set(Bc,A),z})}}return b}prepareFrame(){return!0}renderFrame(){return null}};var In=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(In=(0,Dw.default)((...h)=>{console.warn(...h)},1e3));var T0=class h extends Is{constructor(r={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){r.mapboxLayer&&(In("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),r.maplibreLayer=r.mapboxLayer,delete r.mapboxLayer),r.styleLayers&&(In("options.styleLayers is deprecated. Use options.layers instead."),r.layers=r.styleLayers,delete r.styleLayers),r.styleLayersFilter&&(In("options.styleLayersFilter is deprecated. Use options.layersFilter instead."),r.layersFilter=r.styleLayersFilter,delete r.styleLayersFilter);super({source:new Eo({}),...r});this.highlightedFeatures=[];this.olEventsKeys=[];this.selectedFeatures=[];wa(this,r),this.set("options",r),this.beforeId=r.beforeId,this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=l=>!!this.layers.find(c=>l.id===c.id))}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return In("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return In("Deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(r){In("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[r]}get styleLayers(){return In("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(r){In("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=r}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(l=>{let{id:c,source:n}=l;(!n||n&&r.getSource(n))&&c&&!r.getLayer(c)&&r.addLayer(l,this.beforeId)}),this.applyLayoutVisibility())}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.entries(this.sources).forEach(([l,c])=>{r.getSource(l)||r.addSource(l,c)})}applyLayoutVisibility(r){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:l}=this.maplibreLayer,c=l.getStyle(),n=this.getVisible()?"visible":"none",x=c.layers||[];for(let b=0;b<x.length;b+=1){let S=x[b];if(this.layersFilter(S)){let{id:R}=S;l.getLayer(R)&&(l.setLayoutProperty(R,"visibility",n),(this.getMinZoom()||this.getMaxZoom())&&l.setLayerZoomRange(R,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}attachToMap(r){if(!this.getMapInternal()||!this.maplibreLayer)return;let{mapLibreMap:c}=this.maplibreLayer;c&&(c.loaded()?this.onLoad():c.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",n=>{this.applyLayoutVisibility(n)}),this.on("propertychange",n=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(n.key)&&(this.detachFromMap(),this.attachToMap(r))}),this.maplibreLayer.on("propertychange",n=>{n.key==="style"&&n.target.maplibreMap.once("styledata",()=>{n.target.maplibreMap.once("idle",()=>{this.onLoad()})})}))}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new yd(this)}detachFromMap(){ws(this.olEventsKeys),this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources())}getFeatureInfoAtCoordinate(r){if(In("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{mapLibreMap:l}=this.maplibreLayer;if(!l.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let c=this.layers||[];return this.layersFilter&&(c=l.getStyle().layers.filter(this.layersFilter),console.log(c)),this.queryRenderedLayersFilter&&(c=l.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({coordinate:r,features:[],layer:this})}highlight(r=[]){In("Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.");let l=this.highlightedFeatures?.filter(c=>!(this.selectedFeatures||[]).map(n=>n.getId()).includes(c.getId()))||[];this.setHoverState(l,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:r}=this.maplibreLayer,l=r.getStyle();if(l?.layers&&this.layersFilter){let c=l.layers.filter(this.layersFilter);this.set("disabled",!c.length)}this.applyLayoutVisibility()}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(l=>{let{id:c}=l;c&&r.getLayer(c)&&r.removeLayer(c)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.keys(this.sources).forEach(l=>{r.getSource(l)&&r.removeSource(l)})}select(r=[]){In("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}setFeatureState(r,l){if(!this.maplibreLayer?.mapLibreMap||!r.length)return;let c=this.maplibreLayer.mapLibreMap;r.forEach(n=>{let{source:x,sourceLayer:b}=n.get(Bc)||{};if(!x&&!b||!n.getId()){n.getId()||In("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",n.getProperties());return}c.setFeatureState({id:n.getId(),source:x,sourceLayer:b},l)})}setHoverState(r,l){In(`Deprecated. Use layer.setFeatureState(features, {hover: ${l}}) instead.`),this.setFeatureState(r,{hover:l})}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap(r)):(this.detachFromMap(),super.setMapInternal(r))}},Fw=T0;var P0=Vs(Tl());var M0=Vs(Tl()),I0=Vs(Nw());var E0=class{constructor(t){this.isIdle=!1;this.getViewState=()=>({});this.shouldRender=()=>!0;this._mode=t.mode||nr.TOPOGRAPHIC,this._speed=t.speed||1,this._style=t.style||ol,this._time=t.time||new Date,this.api=t.api||new bu(t),this.bboxParameters=t.bboxParameters,this.canvas=t.canvas||document.createElement("canvas"),this.debug=t.debug||!1,this.filter=t.filter,this.hoverVehicleId=t.hoverVehicleId,this.live=t.live!==!1,this.minZoomInterpolation=t.minZoomInterpolation||8,this.pixelRatio=t.pixelRatio||(typeof window<"u"?window.devicePixelRatio:1),this.selectedVehicleId=t.selectedVehicleId,this.sort=t.sort,this.styleOptions={...Oc,...t.styleOptions||{}},this.tenant=t.tenant||"",this.trajectories={},this.useDebounce=t.useDebounce||!1,this.useRequestAnimationFrame=t.useRequestAnimationFrame||!1,this.useThrottle=t.useThrottle!==!1,this.getViewState=t.getViewState||(()=>({})),this.shouldRender=t.shouldRender||(()=>!0),this.onRender=t.onRender,this.onIdle=t.onIdle,this.onStart=t.onStart,this.onStop=t.onStop,this.format=new vr,this.motsByZoom=t.motsByZoom||[Ms,Ms,Ms,Ms,Ms,Ms,Ms,Ms,Ms,vf,vf],this.getMotsByZoom=r=>t.getMotsByZoom?t.getMotsByZoom(r,this.motsByZoom):this.motsByZoom[r],this.generalizationLevelByZoom=t.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=r=>t.getGeneralizationLevelByZoom?t.getGeneralizationLevelByZoom(r,this.generalizationLevelByZoom):this.generalizationLevelByZoom[r],this.renderTimeIntervalByZoom=t.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=r=>t.getRenderTimeIntervalByZoom?t.getRenderTimeIntervalByZoom(r,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[r],this.isUpdateBboxOnMoveEnd=t.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,I0.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,M0.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}get mode(){return this._mode}set mode(t){t!==this._mode&&(this._mode=t,this.api?.wsApi?.open&&(this.stop(),this.start()))}get speed(){return this._speed}set speed(t){this._speed=t,this.start()}get style(){return this._style}set style(t){this._style=t,this.renderTrajectories()}get time(){return this._time}set time(t){this._time=t?.getTime?t:new Date(t),this.renderTrajectories()}addTrajectory(t){this.trajectories||(this.trajectories={});let r=t.properties.train_id;r!==void 0&&(this.trajectories[r]=t),this.renderTrajectories()}attachToMap(){document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),this.canvas){let t=this.canvas.getContext("2d");t&&t.clearRect(0,0,this.canvas.width,this.canvas.height)}}getRefreshTimeInMs(){let r=this.getViewState().zoom||0,l=r!==void 0?Math.round(r):-1,c=this.getRenderTimeIntervalByZoom(l)||25,n=Math.max(25,c/(this.speed||1)),x=Math.min(n,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,I0.default)(this.renderTrajectoriesInternal,x,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,M0.default)(this.renderTrajectoriesInternal,x,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,b]=this.api.buffer;this.api.buffer=[x,b]}return n}getVehicles(t){return this.trajectories&&Object.values(this.trajectories).filter(t)||[]}getVehiclesAtCoordinate(t,r){let{resolution:l}=this.getViewState(),{hitTolerance:c,nb:n}=r||{},x=Kn([...t,...t],(c||5)*(l||1)),b=Object.values(this.trajectories||{});this.sort&&(b=b.sort(this.sort));let S=[];for(let R=0;R<b.length;R+=1){let{coordinate:E}=b[R].properties;if(E&&ll(x,E)&&S.push(b[R]),S.length===n)break}return{features:S,type:"FeatureCollection"}}onDeleteTrajectoryMessage(t){t.content&&this.removeTrajectory(t.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(!this.getViewState().visible)return;this.start()}}onTrajectoryMessage(t){if(this.updateIdleState(),!t.content)return;let r=t.content,{geometry:l,properties:{raw_coordinates:c,time_since_update:n}}=r;n<0||this.purgeTrajectory(r)||(this.debug&&this.mode===nr.TOPOGRAPHIC&&c?r.properties.olGeometry=this.format.readGeometry({coordinates:_r(c),type:"Point"}):r.properties.olGeometry=this.format.readGeometry(l),r.properties.timeOffset=Date.now()-t.timestamp,this.addTrajectory(r))}onZoomEnd(){this.startUpdateTime()}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([t,r])=>{let l=r?.properties?.time_intervals;this.time&&l?.length&&l[l.length-1][0]<this.time.getTime()&&this.removeTrajectory(t)})}purgeTrajectory(t){let l=this.getViewState().extent,{bounds:c,type:n}=t.properties;return this.isUpdateBboxOnMoveEnd&&l&&!Qi(l,c)||this.mots&&!this.mots.includes(n)?(this.removeTrajectory(t),!0):!1}removeTrajectory(t){let r;typeof t!="string"?r=t?.properties?.train_id:r=t,r!==void 0&&this.trajectories&&delete this.trajectories[r]}renderTrajectories(t){let r=this.getViewState();this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),!(!r?.center||!r?.extent||!r?.size)&&(!t&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,t)}):!t&&this.useDebounce?this.debounceRenderTrajectories(r,t):!t&&this.useThrottle?this.throttleRenderTrajectories(r,t):this.renderTrajectoriesInternal(r,t))}renderTrajectoriesInternal(t,r=!1){if(!this.trajectories||!this.shouldRender())return!1;let l=this.live?Date.now():this.time?.getTime(),c=Object.values(this.trajectories);return this.sort&&c.sort(this.sort),!this.canvas||!this.style||(this.renderState=qu(this.canvas,c,this.style,{...t,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(t.zoom||0)<this.minZoomInterpolation?!0:r,selectedVehicleId:this.selectedVehicleId,...this.styleOptions}),this.onRender?.(this.renderState,t)),!0}setBbox(){this.updateIdleState();let t=this.getViewState(),r=t.extent,l=t.zoom||0;if(!r||Number.isNaN(l))return;if(this.trajectories&&r&&l){let E=Object.keys(this.trajectories);for(let A=E.length-1;A>=0;A-=1)this.purgeTrajectory(this.trajectories[E[A]])}let c=Math.floor(l);if(!r||Number.isNaN(c))return;let[n,x,b,S]=r,R=[Math.floor(n),Math.floor(x),Math.ceil(b),Math.ceil(S),c];this.generalizationLevel=this.getGeneralizationLevelByZoom(c),this.generalizationLevel&&R.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(c),this.mots&&R.push(`mots=${this.mots}`),this.tenant&&R.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&R.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([E,A])=>{R.push(`${E}=${A}`)}),this.api.bbox=R}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}updateIdleState(){this.isIdle=!1,clearTimeout(this._idleTimeout),this._idleTimeout=window.setTimeout(()=>{this.isIdle=!0,this.onIdle?.(this)},1e3)}},Hf=E0;var PI=new vr,xd=class extends Of{forEachFeatureAtCoordinate(t,r,l,c){let n=this.getFeaturesAtCoordinate(t,l);return n.forEach(x=>{c(x,this.layer_,x.getGeometry())}),n?.[0]}getData(t){let r;try{let{pixelRatio:l}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(t[0]*(l||1),t[1]*(l||1),1,1).data||null,r}catch(l){console.error("error getting data",l)}return null}getFeatures(t){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(t);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(t,r=5){if(!t)return[];let l=this.getLayer(),c=l.engine.getVehiclesAtCoordinate(t,{hitTolerance:r,nb:l.maxNbFeaturesRequested});return PI.readFeatures(c)}prepareFrame(){return!0}renderFrame(t){let{canvas:r,engine:l,renderedViewState:c}=this.getLayer();if(this.getLayer().engine.pixelRatio=t.pixelRatio,this.ready=!!l.renderState?.renderedTrajectories&&l.isIdle,this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r instanceof HTMLCanvasElement&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),c){let{center:n,resolution:x,rotation:b}=t.viewState,{center:S,resolution:R,rotation:E}=c;if(R/x>=3){let A=r?.getContext("2d");r?.width&&r?.height&&A?.clearRect(0,0,r.width,r.height)}else{let A=this.getLayer().getMapInternal(),z=A?.getPixelFromCoordinate(S),W=A?.getPixelFromCoordinate(n);z&&W&&(this.container.style.transform=Rv(z[0]-W[0],z[1]-W[1],R/x,R/x,b-E,0,0))}}return this.container}};var RI=new Lr({image:new Cn({fill:new Ar({color:"#000000"}),radius:5}),stroke:new lr({color:"#000000",width:6}),zIndex:2}),AI=(h,t,r)=>{let l="#ffffff",c=h.get("type"),n=h.get("stroke");return n&&n[0]!=="#"&&(n=`#${n}`),l=n||r?.getBgColor(c),l=/#ffffff/i.test(l)?"#ff0000":l,[RI,new Lr({image:new Cn({fill:new Ar({color:l}),radius:4}),stroke:new lr({color:l,width:4}),zIndex:3})]},Yf=AI;var LI=new Lr({image:new Cn({fill:new Ar({color:"#000000"}),radius:5}),stroke:new lr({color:"#000000",width:6}),zIndex:2}),kI=new Lr({image:new Cn({fill:new Ar({color:"#a0a0a0"}),radius:4}),stroke:new lr({color:"#a0a0a0",width:4}),zIndex:3}),DI=()=>[LI,kI],Gw=DI;var Vw=new Cn({fill:new Ar({color:[255,0,0,1]}),radius:6,stroke:new lr({color:[0,0,0,1],width:1})}),FI=new Lr({stroke:new lr({color:[0,0,0,1],width:5})}),zI=new Lr({image:Vw,stroke:new lr({color:[255,0,0,1],width:3})}),OI=new Lr({image:Vw,stroke:new lr({color:[255,0,0,1],lineDash:[1,10],width:3})}),BI=(h,t)=>{let r=h.get("minResolution"),l=h.get("maxResolution"),c=t<=r&&t>l;if(r&&l&&!c)return[];let n=h?.getGeometry()?.getType()==="Point"?100:0,x=[FI,zI];return h.get("mot")==="foot"&&(x=[OI]),x=x.map(S=>{let R=S.clone();return R.setZIndex(n),R}),x},Uw=BI;var jI=new vr,R0=class h extends Is{constructor(r){super({source:new Eo({}),...r});this.allowRenderWhenAnimating=!1;this.maxNbFeaturesRequested=100;this.olEventsKeys=[];wa(this,r),this.engine=new Hf({getViewState:this.getViewState.bind(this),onIdle:this.onRealtimeEngineIdle.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...r}),this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new Yc({source:new bl({features:[]}),style:(l,c)=>(r.fullTrajectoryStyle||Yf)(l,c,this.engine.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.onZoomEndDebounced=(0,P0.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,P0.default)(this.onMoveEnd,100)}get api(){return this.engine.api}set api(r){this.engine.api=r}get canvas(){return this.engine.canvas}get filter(){return this.engine.filter}set filter(r){this.engine.filter=r}get hoverVehicleId(){return this.engine.hoverVehicleId}set hoverVehicleId(r){this.engine.hoverVehicleId=r}get mode(){return this.engine.mode}set mode(r){this.engine.mode=r}get pixelRatio(){return this.engine.pixelRatio}get selectedVehicleId(){return this.engine.selectedVehicleId}set selectedVehicleId(r){this.engine.selectedVehicleId=r}get sort(){return this.engine.sort}set sort(r){this.engine.sort=r}get trajectories(){return this.engine.trajectories}attachToMap(){this.engine.attachToMap();let r=this.getMapInternal();r&&(this.getVisible()&&this.engine.start(),this.olEventsKeys.push(r.on("movestart",()=>{this.engine.isUpdateBboxOnMoveEnd&&this.engine.updateIdleState()}),...r.on(["moveend","change:target"],l=>{let c=(l.map||l.target).getView();if(!c||c?.getAnimating()||c?.getInteracting())return;let n=c.getZoom();this.currentZoom!==n&&this.onZoomEndDebounced(l),this.currentZoom=n,this.onMoveEndDebounced(l)}),this.on("change:visible",l=>{l.target.getVisible()?this.engine.start():this.engine.stop()}),this.on("propertychange",l=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(l.key)&&this.vectorLayer.set(l.key,l.target.get(l.key))})))}cleanVectorLayer(){this.vectorLayer?.getSource()?.clear(!0),this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer)}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new xd(this)}detachFromMap(){ws(this.olEventsKeys),this.getMapInternal()?.removeLayer(this.vectorLayer),this.engine.detachFromMap()}async getFullTrajectory(r){let l=await this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.getMapInternal()?.getView()?.getZoom()||0)));return l?.content?.features?.length?jI.readFeatures(l?.content):[]}async getStopSequences(r){return(await this.engine.api.getStopSequence(r))?.content}async getTrajectoryInfos(r){let l=[this.getStopSequences(r),this.getFullTrajectory(r)],[c,n]=await Promise.all(l);return{fullTrajectory:n,stopSequences:c}}getVehicles(r){return this.engine.getVehicles(r)}getViewState(){let r=this.getMapInternal();if(!r?.getView())return{};let l=r.getView();return{center:l.getCenter(),extent:l.calculateExtent(),pixelRatio:this.engine.pixelRatio,resolution:l.getResolution(),rotation:l.getRotation(),size:r.getSize(),visible:this.getVisible(),zoom:l.getZoom()}}highlight(r){let l=r?.get("train_id");this.hoverVehicleId!==l&&(this.hoverVehicleId=l,this.engine.renderTrajectories(!0))}async highlightTrajectory(r){if(!r){this.cleanVectorLayer();return}let l=await this.getFullTrajectory(r);if(!l?.length){this.cleanVectorLayer();return}l.length&&this.vectorLayer?.getSource()?.addFeatures(l),this.vectorLayer.getMapInternal()&&this.vectorLayer.getMapInternal()!==this.getMapInternal()&&this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);let c=this.getZIndex();if(c!==void 0)this.vectorLayer.setZIndex(c-1),this.vectorLayer.getMapInternal()||this.getMapInternal()?.addLayer(this.vectorLayer);else if(!this.vectorLayer.getMapInternal()){let n=this.getMapInternal()?.getLayers().getArray().indexOf(this)||0;n&&this.getMapInternal()?.getLayers().insertAt(n,this.vectorLayer)}return l}onMoveEnd(){!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible()||this.engine.setBbox()}onRealtimeEngineIdle(){this.changed()}onRealtimeEngineRender(r,l){this.renderedViewState={...l};let{container:c}=this.getRenderer();c&&(c.style.transform="")}onZoomEnd(){this.engine.onZoomEnd(),!(!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}select(r){let l=r?.get("train_id");this.selectedVehicleId!==l&&(this.selectedVehicleId=l,this.engine.renderTrajectories(!0)),this.highlightTrajectory(l)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}shouldRender(){return this.allowRenderWhenAnimating?!1:this.getMapInternal()?.getView().getAnimating()||this.getMapInternal()?.getView().getInteracting()}start(){this.engine.start()}stop(){this.engine.stop()}},Zw=R0;var A0=class h extends $f{clone(t){return new h({...this.get("options"),...t})}getFeatureInfoAtCoordinate(t){let r=[],l=this.getMapInternal();if(l){let c=l.getPixelFromCoordinate(t);r=l.getFeaturesAtPixel(c,{hitTolerance:this.get("hitTolerance")||5,layerFilter:n=>n===this})||[]}return Promise.resolve({coordinate:t,features:r,layer:this})}},qw=A0;var NI=new vr,GI=(h,t,r)=>{let l,{coordinate:c,params:n,projection:x,resolution:b}=t;return h&&b&&x&&(l=h.getFeatureInfoUrl(c,b,x,{info_format:"application/json",query_layers:h.getParams().layers,...n})),fetch(l,{signal:r.signal}).then(S=>S.json()).then(S=>NI.readFeatures(S)).catch(()=>[])},vd={},VI=async(h,t,r=5)=>{Object.values(vd).forEach(n=>{n?.abort()}),vd={};let c=Cu(t).map(n=>{let x=n.getMapInternal(),b=x?.getView()?.getProjection()?.getCode(),S={coordinate:h,features:[],layer:n};if(!b)return Promise.resolve(S);if(n.getFeatureInfoAtCoordinate)return n.getFeatureInfoAtCoordinate(h);let R=n?.getSource();if(R?.getFeatureInfoUrl){let z=Vt(n);vd[z]?.abort(),vd[z]=new AbortController;let W=x?.getView()?.getResolution();return GI(R,{coordinate:h,params:{info_format:"application/json",query_layers:R.getParams().layers},projection:b,resolution:W},vd[z]).then(ne=>({coordinate:h,features:ne,layer:n})).catch(()=>({coordinate:h,features:[],layer:n}))}let E=x?.getPixelFromCoordinate(h);if(!E)return Promise.resolve(S);let A=x?.getFeaturesAtPixel(E,{hitTolerance:n.get("hitTolerance")||r||5,layerFilter:z=>z===n});return Promise.resolve({coordinate:h,features:A,layer:n})});return Promise.all(c)},Ww=VI;var tm={};dg(tm,{CopyrightControl:()=>$w,Layer:()=>Jf,RealtimeAPI:()=>bu,RealtimeLayer:()=>uS,RealtimeModes:()=>nr,RoutingAPI:()=>wu,StopsAPI:()=>Su,VECTOR_TILE_FEATURE_PROPERTY:()=>Bc,compareDepartures:()=>Wu,createCanvas:()=>xs,createRealtimeFilters:()=>Pg,debounceDeparturesMessages:()=>T_,debounceWebsocketMessages:()=>vu,getCircleCanvas:()=>Cg,getDelayBgCanvas:()=>Sg,getDelayTextCanvas:()=>Tg,getHoursAndMinutes:()=>Iv,getLayersAsFlatArray:()=>Cu,getMapGlCopyrights:()=>Tu,getMercatorResolution:()=>hS,getSourceCoordinates:()=>em,getTextCanvas:()=>Mg,getUTCDateString:()=>Cv,getUTCTimeString:()=>Mv,getUrlWithParams:()=>sl,getVehiclePosition:()=>Zu,pad:()=>Zp,realtimeConfig:()=>Oc,realtimeDefaultStyle:()=>ol,realtimeDelayStyle:()=>Ig,realtimeSimpleStyle:()=>Eg,removeDuplicate:()=>al,renderTrajectories:()=>qu,sortAndFilterDepartures:()=>$u,sortByDelay:()=>Rg});var UI=" | ",L0=class{constructor(t={}){this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this.map=t,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}render(){if(this.map&&this.container){let t=this.options?.separator||UI,r=this.options?.customAttribution||Tu(this.map),l=(Array.isArray(r)?r:[r]).join(t);this.container.innerHTML!==l&&(this.content=l,this.container.innerHTML=this.content)}}},$w=L0;var Hw=Vs(_0());var kr=[];for(let h=0;h<256;++h)kr.push((h+256).toString(16).slice(1));function Xw(h,t=0){return(kr[h[t+0]]+kr[h[t+1]]+kr[h[t+2]]+kr[h[t+3]]+"-"+kr[h[t+4]]+kr[h[t+5]]+"-"+kr[h[t+6]]+kr[h[t+7]]+"-"+kr[h[t+8]]+kr[h[t+9]]+"-"+kr[h[t+10]]+kr[h[t+11]]+kr[h[t+12]]+kr[h[t+13]]+kr[h[t+14]]+kr[h[t+15]]).toLowerCase()}var k0,ZI=new Uint8Array(16);function D0(){if(!k0){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k0=crypto.getRandomValues.bind(crypto)}return k0(ZI)}var qI=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),F0={randomUUID:qI};function WI(h,t,r){if(F0.randomUUID&&!t&&!h)return F0.randomUUID();h=h||{};let l=h.random??h.rng?.()??D0();if(l.length<16)throw new Error("Random bytes length must be >= 16");if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let c=0;c<16;++c)t[r+c]=l[c];return t}return Xw(l)}var z0=WI;var O0=class extends Hw.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||z0()}onAdd(r,l){this.map=r}onRemove(r,l){this.map=void 0}render(r){}},Jf=O0;var Dr=63710088e-1,Kw={centimeters:Dr*100,centimetres:Dr*100,degrees:360/(2*Math.PI),feet:Dr*3.28084,inches:Dr*39.37,kilometers:Dr/1e3,kilometres:Dr/1e3,meters:Dr,metres:Dr,miles:Dr/1609.344,millimeters:Dr*1e3,millimetres:Dr*1e3,nauticalmiles:Dr/1852,radians:1,yards:Dr*1.0936};function $I(h,t,r={}){let l={type:"Feature"};return(r.id===0||r.id)&&(l.id=r.id),r.bbox&&(l.bbox=r.bbox),l.properties=t||{},l.geometry=h,l}function Cl(h,t,r={}){if(!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Yw(h[0])||!Yw(h[1]))throw new Error("coordinates must contain numbers");return $I({type:"Point",coordinates:h},t,r)}function XI(h,t="kilometers"){let r=Kw[t];if(!r)throw new Error(t+" units is invalid");return h*r}function HI(h,t="kilometers"){let r=Kw[t];if(!r)throw new Error(t+" units is invalid");return h/r}function Jw(h){return h%(2*Math.PI)*180/Math.PI}function Ml(h){return h%360*Math.PI/180}function Qf(h,t="kilometers",r="kilometers"){if(!(h>=0))throw new Error("length must be a positive number");return XI(HI(h,t),r)}function Yw(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function Qw(h){return h!==null&&typeof h=="object"&&!Array.isArray(h)}function bd(h,t,r){if(h!==null)for(var l,c,n,x,b,S,R,E=0,A=0,z,W=h.type,ne=W==="FeatureCollection",ge=W==="Feature",me=ne?h.features.length:1,ve=0;ve<me;ve++){R=ne?h.features[ve].geometry:ge?h.geometry:h,z=R?R.type==="GeometryCollection":!1,b=z?R.geometries.length:1;for(var Te=0;Te<b;Te++){var Oe=0,Pe=0;if(x=z?R.geometries[Te]:R,x!==null){S=x.coordinates;var ze=x.type;switch(E=r&&(ze==="Polygon"||ze==="MultiPolygon")?1:0,ze){case null:break;case"Point":if(t(S,A,ve,Oe,Pe)===!1)return!1;A++,Oe++;break;case"LineString":case"MultiPoint":for(l=0;l<S.length;l++){if(t(S[l],A,ve,Oe,Pe)===!1)return!1;A++,ze==="MultiPoint"&&Oe++}ze==="LineString"&&Oe++;break;case"Polygon":case"MultiLineString":for(l=0;l<S.length;l++){for(c=0;c<S[l].length-E;c++){if(t(S[l][c],A,ve,Oe,Pe)===!1)return!1;A++}ze==="MultiLineString"&&Oe++,ze==="Polygon"&&Pe++}ze==="Polygon"&&Oe++;break;case"MultiPolygon":for(l=0;l<S.length;l++){for(Pe=0,c=0;c<S[l].length;c++){for(n=0;n<S[l][c].length-E;n++){if(t(S[l][c][n],A,ve,Oe,Pe)===!1)return!1;A++}Pe++}Oe++}break;case"GeometryCollection":for(l=0;l<x.geometries.length;l++)if(bd(x.geometries[l],t,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function eS(h,t={}){let r=0,l=0,c=0;return bd(h,function(n){r+=n[0],l+=n[1],c++},!0),Cl([r/c,l/c],t.properties)}function Qs(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return[...h.geometry.coordinates];if(h.type==="Point")return[...h.coordinates]}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return[...h];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function tS(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function rS(h,t,r={}){let l;return r.final?l=iS(Qs(t),Qs(h)):l=iS(Qs(h),Qs(t)),l>180?-(360-l):l}function iS(h,t){let r=Ml(h[1]),l=Ml(t[1]),c=Ml(t[0]-h[0]);c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);let n=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),x=Math.atan2(c,n);return(Jw(x)+360)%360}function nS(h,t,r={}){let l=Qs(h),c=Qs(t);c[0]+=c[0]-l[0]>180?-360:l[0]-c[0]>180?360:0;let n=YI(l,c);return Qf(n,"meters",r.units)}function YI(h,t,r){r=r===void 0?Dr:Number(r);let l=r,c=h[1]*Math.PI/180,n=t[1]*Math.PI/180,x=n-c,b=Math.abs(t[0]-h[0])*Math.PI/180;b>Math.PI&&(b-=2*Math.PI);let S=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(c/2+Math.PI/4)),R=Math.abs(S)>1e-11?x/S:Math.cos(c);return Math.sqrt(x*x+R*R*b*b)*l}function sS(h,t,r,l={}){let c=t<0,n=Qf(Math.abs(t),l.units,"meters");c&&(n=-Math.abs(n));let x=Qs(h),b=KI(x,n,r);return b[0]+=b[0]-x[0]>180?-360:x[0]-b[0]>180?360:0,Cl(b,l.properties)}function KI(h,t,r,l){l=l===void 0?Dr:Number(l);let c=t/l,n=h[0]*Math.PI/180,x=Ml(h[1]),b=Ml(r),S=c*Math.cos(b),R=x+S;Math.abs(R)>Math.PI/2&&(R=R>0?Math.PI-R:-Math.PI-R);let E=Math.log(Math.tan(R/2+Math.PI/4)/Math.tan(x/2+Math.PI/4)),A=Math.abs(E)>1e-11?S/E:Math.cos(x),z=c*Math.sin(b)/A;return[((n+z)*180/Math.PI+540)%360-180,R*180/Math.PI]}function oS(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return aS(h);case"FeatureCollection":return JI(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return B0(h);default:throw new Error("unknown GeoJSON type")}}function aS(h){let t={type:"Feature"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:t[r]=h[r]}}),t.properties=lS(h.properties),h.geometry==null?t.geometry=null:t.geometry=B0(h.geometry),t}function lS(h){let t={};return h&&Object.keys(h).forEach(r=>{let l=h[r];typeof l=="object"?l===null?t[r]=null:Array.isArray(l)?t[r]=l.map(c=>c):t[r]=lS(l):t[r]=l}),t}function JI(h){let t={type:"FeatureCollection"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"features":return;default:t[r]=h[r]}}),t.features=h.features.map(r=>aS(r)),t}function B0(h){let t={type:h.type};return h.bbox&&(t.bbox=h.bbox),h.type==="GeometryCollection"?(t.geometries=h.geometries.map(r=>B0(r)),t):(t.coordinates=cS(h.coordinates),t)}function cS(h){let t=h;return typeof t[0]!="object"?t.slice():t.map(r=>cS(r))}function QI(h,t,r){if(r=r||{},!Qw(r))throw new Error("options is invalid");let l=r.pivot,c=r.mutate;if(!h)throw new Error("geojson is required");if(t==null||isNaN(t))throw new Error("angle is required");if(t===0)return h;let n=l??eS(h);return(c===!1||c===void 0)&&(h=oS(h)),bd(h,function(x){let S=rS(n,x)+t,R=nS(n,x),E=tS(sS(n,R,S));x[0]=E[0],x[1]=E[1]}),h}var j0=QI;var eE=(h,t=1)=>{let{height:r,width:l}=h.getCanvas(),c=h.unproject({x:0,y:0}),n=h.unproject({x:0,y:r/t}),x=h.unproject({x:l/t,y:r/t}),b=h.unproject({x:l/t,y:0});return[[c.lng,c.lat],[b.lng,b.lat],[x.lng,x.lat],[n.lng,n.lat]]},em=eE;var tE=h=>{let t=h.getBounds().toArray(),r=_r(t[0]),l=_r(t[1]),c=[...r,...l],{width:n,height:x}=h.getCanvas(),b=Ti(c)/n,S=sr(c)/x;return Math.max(b,S)},hS=tE;var N0=class extends Jf{get canvas(){return this.engine.canvas}get pixelRatio(){return this.engine.pixelRatio||1}set pixelRatio(t){this.engine.pixelRatio=t||1}#e;constructor(t={}){let r=t?.id||"realtime";super({...t,id:"realtime-custom-"+r}),this.#e=r,this.engine=new Hf({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...t}),this.sourceId=this.#e,this.source={animate:!0,attribution:t.attribution?.join(", "),canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],loaded:!0,type:"canvas"},this.layer={id:this.#e,layout:{visibility:"visible"},paint:{"raster-fade-duration":0,"raster-opacity":1,"raster-resampling":"nearest"},source:this.sourceId,type:"raster"},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}getViewState(){if(!this.map)return{};this.pixelRatio||(this.pixelRatio=1);let{height:t,width:r}=this.map.getCanvas(),l=this.map.getCenter(),c=this.map.unproject({x:0,y:t/this.pixelRatio}),n=this.map.unproject({x:r/this.pixelRatio,y:0}),x=j0(Cl([c.lng,c.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,b=j0(Cl([n.lng,n.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,S=[..._r(x),..._r(b)],R=Ti(S)/(r/this.pixelRatio),E=sr(S)/(t/this.pixelRatio),A=Math.max(R,E);return{center:_r([l.lng,l.lat]),extent:S,pixelRatio:this.pixelRatio,resolution:A,rotation:-(this.map.getBearing()*Math.PI)/180,size:[r/this.pixelRatio,t/this.pixelRatio],visible:!0,zoom:this.map.getZoom()-1}}onAdd(t,r){super.onAdd(t,r),this.engine.attachToMap(),t.isStyleLoaded()&&this.onLoad(),t.on("load",this.onLoad)}onLoad(){this.map?.getSource(this.sourceId)||this.map?.addSource(this.sourceId,this.source),this.map?.getLayer(this.layer.id)||this.map?.addLayer(this.layer,this.id),this.start()}onMove(){this.engine.renderTrajectories()}onMoveEnd(){this.engine.renderTrajectories(),this.engine.isUpdateBboxOnMoveEnd&&this.engine.setBbox()}onRealtimeEngineRender(){if(this.map?.style){let t=em(this.map,this.pixelRatio),r=this.map.getSource(this.sourceId);r&&r.setCoordinates(t)}}onRemove(t,r){this.engine.detachFromMap(),this.stop(),t.off("load",this.onLoad),t.getLayer(this.layer.id)&&t.removeLayer(this.layer.id),t.getSource(this.sourceId)&&t.removeSource(this.sourceId),super.onRemove(t,r)}onZoomEnd(){this.engine.onZoomEnd()}start(){this.engine.start(),this.map?.on("move",this.onMove),this.map?.on("moveend",this.onMoveEnd),this.map?.on("zoomend",this.onZoomEnd)}stop(){this.engine.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}},uS=N0;var G0={ol:Kf,maplibre:tm};typeof window<"u"&&(window.mbt=G0);var Y6=G0;})();
733
+ `){Tt+=lt,lt=0,Je=A*Oe+tt*z,++yt;continue}let Ot=W[ht+1]||S.font;Ot!==xt&&(c&&st.push("font",Ot),l&&bt.push("font",Ot),xt=Ot),lt=Math.max(lt,ve[ct]);let At=[Nt,Je+tt*me[ct]+A*(me[ct]-Te[yt]),.5*(z+lt)+Tt];Je+=me[ct],c&&st.push("strokeText",At),l&&bt.push("fillText",At),++ct}return Array.prototype.push.apply(Pe,st),Array.prototype.push.apply(Pe,bt),this.labels_[n]=et,et}replayTextBackground_(t,r,l,c,n,x,b){t.beginPath(),t.moveTo.apply(t,r),t.lineTo.apply(t,l),t.lineTo.apply(t,c),t.lineTo.apply(t,n),t.lineTo.apply(t,r),x&&(this.alignAndScaleFill_=x[2],t.fillStyle=x[1],this.fill_(t)),b&&(this.setStrokeStyle_(t,b),t.stroke())}calculateImageOrLabelDimensions_(t,r,l,c,n,x,b,S,R,E,A,z,W,ne,ge,me){b*=z[0],S*=z[1];let ve=l-b,Te=c-S,Oe=n+R>t?t-R:n,Pe=x+E>r?r-E:x,ze=ne[3]+Oe*z[0]+ne[1],Me=ne[0]+Pe*z[1]+ne[2],et=ve-ne[3],tt=Te-ne[0];(ge||A!==0)&&(_a[0]=et,ya[0]=et,_a[1]=tt,Ro[1]=tt,Ro[0]=et+ze,Ao[0]=Ro[0],Ao[1]=tt+Me,ya[1]=Ao[1]);let Je;return A!==0?(Je=Ur(mr(),l,c,1,1,A,-l,-c),Mr(Je,_a),Mr(Je,Ro),Mr(Je,Ao),Mr(Je,ya),bo(Math.min(_a[0],Ro[0],Ao[0],ya[0]),Math.min(_a[1],Ro[1],Ao[1],ya[1]),Math.max(_a[0],Ro[0],Ao[0],ya[0]),Math.max(_a[1],Ro[1],Ao[1],ya[1]),Wc)):bo(Math.min(et,et+ze),Math.min(tt,tt+Me),Math.max(et,et+ze),Math.max(tt,tt+Me),Wc),W&&(ve=Math.round(ve),Te=Math.round(Te)),{drawImageX:ve,drawImageY:Te,drawImageW:Oe,drawImageH:Pe,originX:R,originY:E,declutterBox:{minX:Wc[0],minY:Wc[1],maxX:Wc[2],maxY:Wc[3],value:me},canvasTransform:Je,scale:z}}replayImageOrLabel_(t,r,l,c,n,x,b){let S=!!(x||b),R=c.declutterBox,E=b?b[2]*c.scale[0]/2:0;return R.minX-E<=r[0]&&R.maxX+E>=0&&R.minY-E<=r[1]&&R.maxY+E>=0&&(S&&this.replayTextBackground_(t,_a,Ro,Ao,ya,x,b),m1(t,c.canvasTransform,n,l,c.originX,c.originY,c.drawImageW,c.drawImageH,c.drawImageX,c.drawImageY,c.scale)),!0}fill_(t){let r=this.alignAndScaleFill_;if(r){let l=Mr(this.renderedTransform_,[0,0]),c=512*this.pixelRatio;t.save(),t.translate(l[0]%c,l[1]%c),r!==1&&t.scale(r,r),t.rotate(this.viewRotation_)}t.fill(),r&&t.restore()}setStrokeStyle_(t,r){t.strokeStyle=r[1],t.lineWidth=r[2],t.lineCap=r[3],t.lineJoin=r[4],t.miterLimit=r[5],t.lineDashOffset=r[7],t.setLineDash(r[6])}drawLabelWithPointPlacement_(t,r,l,c){let n=this.textStates[r],x=this.createLabel(t,r,c,l),b=this.strokeStates[l],S=this.pixelRatio,R=Iy(Array.isArray(t)?t[0]:t,n.textAlign||ma),E=od[n.textBaseline||xl],A=b&&b.lineWidth?b.lineWidth:0,z=x.width/S-2*n.scale[0],W=R*z+2*(.5-R)*A,ne=E*x.height/S+2*(.5-E)*A;return{label:x,anchorX:W,anchorY:ne}}execute_(t,r,l,c,n,x,b,S){let R=this.zIndexContext_,E;this.pixelCoordinates_&&yn(l,this.renderedTransform_)?E=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),E=xn(this.coordinates,0,this.coordinates.length,2,l,this.pixelCoordinates_),Pv(this.renderedTransform_,l));let A=0,z=c.length,W=0,ne,ge,me,ve,Te,Oe,Pe,ze,Me,et,tt,Je,st,bt=0,lt=0,Tt=this.coordinateCache_,ct=this.viewRotation_,yt=Math.round(Math.atan2(-l[1],l[0])*1e12)/1e12,xt={context:t,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:ct},ht=this.instructions!=c||this.overlaps?0:200,vt,Nt,Ot,At;for(;A<z;){let Xe=c[A];switch(Xe[0]){case wt.BEGIN_GEOMETRY:vt=Xe[1],At=Xe[3],vt.getGeometry()?b!==void 0&&!Qi(b,At.getExtent())?A=Xe[2]+1:++A:A=Xe[2],R&&(R.zIndex=Xe[4]);break;case wt.BEGIN_PATH:bt>ht&&(this.fill_(t),bt=0),lt>ht&&(t.stroke(),lt=0),!bt&&!lt&&(t.beginPath(),Te=NaN,Oe=NaN),++A;break;case wt.CIRCLE:W=Xe[1];let br=E[W],bi=E[W+1],$i=E[W+2],Ni=E[W+3],Fr=$i-br,pi=Ni-bi,ti=Math.sqrt(Fr*Fr+pi*pi);t.moveTo(br+ti,bi),t.arc(br,bi,ti,0,2*Math.PI,!0),++A;break;case wt.CLOSE_PATH:t.closePath(),++A;break;case wt.CUSTOM:W=Xe[1],ne=Xe[2];let on=Xe[3],fi=Xe[4],$r=Xe[5];xt.geometry=on,xt.feature=vt,A in Tt||(Tt[A]=[]);let wr=Tt[A];$r?$r(E,W,ne,2,wr):(wr[0]=E[W],wr[1]=E[W+1],wr.length=2),R&&(R.zIndex=Xe[6]),fi(wr,xt),++A;break;case wt.DRAW_IMAGE:W=Xe[1],ne=Xe[2],Me=Xe[3],ge=Xe[4],me=Xe[5];let cr=Xe[6],zr=Xe[7],Ci=Xe[8],Ai=Xe[9],Or=Xe[10],Xr=Xe[11],an=Xe[12],ln=Xe[13];ve=Xe[14]||"declutter";let Br=Xe[15];if(!Me&&Xe.length>=20){et=Xe[19],tt=Xe[20],Je=Xe[21],st=Xe[22];let he=this.drawLabelWithPointPlacement_(et,tt,Je,st);Me=he.label,Xe[3]=Me;let We=Xe[23];ge=(he.anchorX-We)*this.pixelRatio,Xe[4]=ge;let Ue=Xe[24];me=(he.anchorY-Ue)*this.pixelRatio,Xe[5]=me,cr=Me.height,Xe[6]=cr,ln=Me.width,Xe[13]=ln}let Hr;Xe.length>25&&(Hr=Xe[25]);let En,jr,cn;Xe.length>17?(En=Xe[16],jr=Xe[17],cn=Xe[18]):(En=Mo,jr=null,cn=null),Or&&yt?Xr+=ct:!Or&&!yt&&(Xr-=ct);let Vn=0;for(;W<ne;W+=2){if(Hr&&Hr[Vn++]<ln/this.pixelRatio)continue;let he=this.calculateImageOrLabelDimensions_(Me.width,Me.height,E[W],E[W+1],ln,cr,ge,me,Ci,Ai,Xr,an,n,En,!!jr||!!cn,vt),We=[t,r,Me,he,zr,jr,cn];if(S){let Ue,ot,dt;if(Br){let Ye=ne-W;if(!Br[Ye]){Br[Ye]={args:We,declutterMode:ve};continue}let mt=Br[Ye];Ue=mt.args,ot=mt.declutterMode,delete Br[Ye],dt=F1(Ue)}let Le,$e;if(Ue&&(ot!=="declutter"||!S.collides(dt))&&(Le=!0),(ve!=="declutter"||!S.collides(he.declutterBox))&&($e=!0),ot==="declutter"&&ve==="declutter"){let Ye=Le&&$e;Le=Ye,$e=Ye}Le&&(ot!=="none"&&S.insert(dt),this.replayImageOrLabel_.apply(this,Ue)),$e&&(ve!=="none"&&S.insert(he.declutterBox),this.replayImageOrLabel_.apply(this,We))}else this.replayImageOrLabel_.apply(this,We)}++A;break;case wt.DRAW_CHARS:let rs=Xe[1],ns=Xe[2],ss=Xe[3],Un=Xe[4];st=Xe[5];let K=Xe[6],U=Xe[7],$=Xe[8];Je=Xe[9];let X=Xe[10];et=Xe[11],tt=Xe[12];let re=[Xe[13],Xe[13]];ve=Xe[14]||"declutter";let ue=Xe[15],ye=this.textStates[tt],be=ye.font,_e=[ye.scale[0]*U,ye.scale[1]*U],Re;be in this.widths_?Re=this.widths_[be]:(Re={},this.widths_[be]=Re);let Ee=gf(E,rs,ns,2),xe=Math.abs(_e[0])*Q_(be,et,Re);if(Un||xe<=Ee){let he=this.textStates[tt].textAlign,We=(Ee-xe)*Iy(et,he),Ue=D1(E,rs,ns,2,et,We,K,Math.abs(_e[0]),Q_,be,Re,yt?0:this.viewRotation_,ue);e:if(Ue){let ot=[],dt,Le,$e,Ye,mt;if(Je)for(dt=0,Le=Ue.length;dt<Le;++dt){mt=Ue[dt],$e=mt[4],Ye=this.createLabel($e,tt,"",Je),ge=mt[2]+(_e[0]<0?-X:X),me=ss*Ye.height+(.5-ss)*2*X*_e[1]/_e[0]-$;let Ct=this.calculateImageOrLabelDimensions_(Ye.width,Ye.height,mt[0],mt[1],Ye.width,Ye.height,ge,me,0,0,mt[3],re,!1,Mo,!1,vt);if(S&&ve==="declutter"&&S.collides(Ct.declutterBox))break e;ot.push([t,r,Ye,Ct,1,null,null])}if(st)for(dt=0,Le=Ue.length;dt<Le;++dt){mt=Ue[dt],$e=mt[4],Ye=this.createLabel($e,tt,st,""),ge=mt[2],me=ss*Ye.height-$;let Ct=this.calculateImageOrLabelDimensions_(Ye.width,Ye.height,mt[0],mt[1],Ye.width,Ye.height,ge,me,0,0,mt[3],re,!1,Mo,!1,vt);if(S&&ve==="declutter"&&S.collides(Ct.declutterBox))break e;ot.push([t,r,Ye,Ct,1,null,null])}S&&ve!=="none"&&S.load(ot.map(F1));for(let Ct=0,gt=ot.length;Ct<gt;++Ct)this.replayImageOrLabel_.apply(this,ot[Ct])}}++A;break;case wt.END_GEOMETRY:if(x!==void 0){vt=Xe[1];let he=x(vt,At,ve);if(he)return he}++A;break;case wt.FILL:ht?bt++:this.fill_(t),++A;break;case wt.MOVE_TO_LINE_TO:for(W=Xe[1],ne=Xe[2],Nt=E[W],Ot=E[W+1],t.moveTo(Nt,Ot),Te=Nt+.5|0,Oe=Ot+.5|0,W+=2;W<ne;W+=2)Nt=E[W],Ot=E[W+1],Pe=Nt+.5|0,ze=Ot+.5|0,(W==ne-2||Pe!==Te||ze!==Oe)&&(t.lineTo(Nt,Ot),Te=Pe,Oe=ze);++A;break;case wt.SET_FILL_STYLE:this.alignAndScaleFill_=Xe[2],bt&&(this.fill_(t),bt=0,lt&&(t.stroke(),lt=0)),t.fillStyle=Xe[1],++A;break;case wt.SET_STROKE_STYLE:lt&&(t.stroke(),lt=0),this.setStrokeStyle_(t,Xe),++A;break;case wt.STROKE:ht?lt++:t.stroke(),++A;break;default:++A;break}}bt&&this.fill_(t),lt&&t.stroke()}execute(t,r,l,c,n,x){this.viewRotation_=c,this.execute_(t,r,l,this.instructions,n,void 0,void 0,x)}executeHitDetection(t,r,l,c,n){return this.viewRotation_=l,this.execute_(t,[t.canvas.width,t.canvas.height],r,this.hitDetectionInstructions,!0,c,n)}},O1=Ey;var wl=["Polygon","Circle","LineString","Image","Text","Default"],Ay=["Image","Text"],B1=wl.filter(h=>!Ay.includes(h)),Ry=class{constructor(t,r,l,c,n,x,b){this.maxExtent_=t,this.overlaps_=c,this.pixelRatio_=l,this.resolution_=r,this.renderBuffer_=x,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=mr(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(n,b)}clip(t,r){let l=this.getClipCoords(r);t.beginPath(),t.moveTo(l[0],l[1]),t.lineTo(l[2],l[3]),t.lineTo(l[4],l[5]),t.lineTo(l[6],l[7]),t.clip()}createExecutors_(t,r){for(let l in t){let c=this.executorsByZIndex_[l];c===void 0&&(c={},this.executorsByZIndex_[l]=c);let n=t[l];for(let x in n){let b=n[x];c[x]=new O1(this.resolution_,this.pixelRatio_,this.overlaps_,b,r)}}}hasExecutors(t){for(let r in this.executorsByZIndex_){let l=this.executorsByZIndex_[r];for(let c=0,n=t.length;c<n;++c)if(t[c]in l)return!0}return!1}forEachFeatureAtCoordinate(t,r,l,c,n,x){c=Math.round(c);let b=c*2+1,S=Ur(this.hitDetectionTransform_,c+.5,c+.5,1/r,-1/r,-l,-t[0],-t[1]),R=!this.hitDetectionContext_;R&&(this.hitDetectionContext_=Oi(b,b,void 0,{willReadFrequently:!0}));let E=this.hitDetectionContext_;E.canvas.width!==b||E.canvas.height!==b?(E.canvas.width=b,E.canvas.height=b):R||E.clearRect(0,0,b,b);let A;this.renderBuffer_!==void 0&&(A=_n(),Lg(A,t),Kn(A,r*(this.renderBuffer_+c),A));let z=zC(c),W;function ne(ze,Me,et){let tt=E.getImageData(0,0,b,b).data;for(let Je=0,st=z.length;Je<st;Je++)if(tt[z[Je]]>0){if(!x||et==="none"||W!=="Image"&&W!=="Text"||x.includes(ze)){let bt=(z[Je]-3)/4,lt=c-bt%b,Tt=c-(bt/b|0),ct=n(ze,Me,lt*lt+Tt*Tt);if(ct)return ct}E.clearRect(0,0,b,b);break}}let ge=Object.keys(this.executorsByZIndex_).map(Number);ge.sort(vs);let me,ve,Te,Oe,Pe;for(me=ge.length-1;me>=0;--me){let ze=ge[me].toString();for(Te=this.executorsByZIndex_[ze],ve=wl.length-1;ve>=0;--ve)if(W=wl[ve],Oe=Te[W],Oe!==void 0&&(Pe=Oe.executeHitDetection(E,S,l,ne,A),Pe))return Pe}}getClipCoords(t){let r=this.maxExtent_;if(!r)return null;let l=r[0],c=r[1],n=r[2],x=r[3],b=[l,c,l,x,n,x,n,c];return xn(b,0,8,2,t,b),b}isEmpty(){return On(this.executorsByZIndex_)}execute(t,r,l,c,n,x,b){let S=Object.keys(this.executorsByZIndex_).map(Number);S.sort(b?Vv:vs),x=x||wl;let R=wl.length;for(let E=0,A=S.length;E<A;++E){let z=S[E].toString(),W=this.executorsByZIndex_[z];for(let ne=0,ge=x.length;ne<ge;++ne){let me=x[ne],ve=W[me];if(ve!==void 0){let Te=b===null?void 0:ve.getZIndexContext(),Oe=Te?Te.getContext():t,Pe=this.maxExtent_&&me!=="Image"&&me!=="Text";if(Pe&&(Oe.save(),this.clip(Oe,l)),!Te||me==="Text"||me==="Image"?ve.execute(Oe,r,l,c,n,b):Te.pushFunction(ze=>ve.execute(ze,r,l,c,n,b)),Pe&&Oe.restore(),Te){Te.offset();let ze=S[E]*R+ne;this.deferredZIndexContexts_[ze]||(this.deferredZIndexContexts_[ze]=[]),this.deferredZIndexContexts_[ze].push(Te)}}}}this.renderedContext_=t}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let t=this.deferredZIndexContexts_,r=Object.keys(t).map(Number).sort(vs);for(let l=0,c=r.length;l<c;++l)t[r[l]].forEach(n=>{n.draw(this.renderedContext_),n.clear()}),t[r[l]].length=0}},Py={};function zC(h){if(Py[h]!==void 0)return Py[h];let t=h*2+1,r=h*h,l=new Array(r+1);for(let n=0;n<=h;++n)for(let x=0;x<=h;++x){let b=n*n+x*x;if(b>r)break;let S=l[b];S||(S=[],l[b]=S),S.push(((h+n)*t+(h+x))*4+3),n>0&&S.push(((h-n)*t+(h+x))*4+3),x>0&&(S.push(((h+n)*t+(h-x))*4+3),n>0&&S.push(((h-n)*t+(h-x))*4+3))}let c=[];for(let n=0,x=l.length;n<x;++n)l[n]&&c.push(...l[n]);return Py[h]=c,c}var j1=Ry;function N1(h,t,r,l){return r!==void 0&&l!==void 0?[r/h,l/t]:r!==void 0?r/h:l!==void 0?l/t:1}var Ly=class h extends Df{constructor(t){t=t||{};let r=t.opacity!==void 0?t.opacity:1,l=t.rotation!==void 0?t.rotation:0,c=t.scale!==void 0?t.scale:1,n=t.rotateWithView!==void 0?t.rotateWithView:!1;super({opacity:r,rotation:l,scale:c,displacement:t.displacement!==void 0?t.displacement:[0,0],rotateWithView:n,declutterMode:t.declutterMode}),this.anchor_=t.anchor!==void 0?t.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=t.anchorOrigin!==void 0?t.anchorOrigin:"top-left",this.anchorXUnits_=t.anchorXUnits!==void 0?t.anchorXUnits:"fraction",this.anchorYUnits_=t.anchorYUnits!==void 0?t.anchorYUnits:"fraction",this.crossOrigin_=t.crossOrigin!==void 0?t.crossOrigin:null;let x=t.img!==void 0?t.img:null,b=t.src;di(!(b!==void 0&&x),"`image` and `src` cannot be provided at the same time"),(b===void 0||b.length===0)&&x&&(b=x.src||Vt(x)),di(b!==void 0&&b.length>0,"A defined and non-empty `src` or `image` must be provided"),di(!((t.width!==void 0||t.height!==void 0)&&t.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let S;if(t.src!==void 0?S=Mt.IDLE:x!==void 0&&("complete"in x?x.complete?S=x.src?Mt.LOADED:Mt.IDLE:S=Mt.LOADING:S=Mt.LOADED),this.color_=t.color!==void 0?Ps(t.color):null,this.iconImage_=Vc(x,b,this.crossOrigin_,S,this.color_),this.offset_=t.offset!==void 0?t.offset:[0,0],this.offsetOrigin_=t.offsetOrigin!==void 0?t.offsetOrigin:"top-left",this.origin_=null,this.size_=t.size!==void 0?t.size:null,this.initialOptions_,t.width!==void 0||t.height!==void 0){let R,E;if(t.size)[R,E]=t.size;else{let A=this.getImage(1);if(A.width&&A.height)R=A.width,E=A.height;else if(A instanceof HTMLImageElement){this.initialOptions_=t;let z=()=>{if(this.unlistenImageChange(z),!this.initialOptions_)return;let W=this.iconImage_.getSize();this.setScale(N1(W[0],W[1],t.width,t.height))};this.listenImageChange(z);return}}R!==void 0&&this.setScale(N1(R,E,t.width,t.height))}}clone(){let t,r,l;return this.initialOptions_?(r=this.initialOptions_.width,l=this.initialOptions_.height):(t=this.getScale(),t=Array.isArray(t)?t.slice():t),new h({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:t,width:r,height:l,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let t=this.normalizedAnchor_;if(!t){t=this.anchor_;let c=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!c)return null;t=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(t[0]*=c[0]),this.anchorYUnits_=="fraction"&&(t[1]*=c[1])}if(this.anchorOrigin_!="top-left"){if(!c)return null;t===this.anchor_&&(t=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(t[0]=-t[0]+c[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(t[1]=-t[1]+c[1])}this.normalizedAnchor_=t}let r=this.getDisplacement(),l=this.getScaleArray();return[t[0]-r[0]/l[0],t[1]+r[1]/l[1]]}setAnchor(t){this.anchor_=t,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(t){return this.iconImage_.getImage(t)}getPixelRatio(t){return this.iconImage_.getPixelRatio(t)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let t=this.offset_;if(this.offsetOrigin_!="top-left"){let r=this.getSize(),l=this.iconImage_.getSize();if(!r||!l)return null;t=t.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(t[0]=l[0]-r[0]-t[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(t[1]=l[1]-r[1]-t[1])}return this.origin_=t,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let t=this.getScaleArray();if(this.size_)return this.size_[0]*t[0];if(this.iconImage_.getImageState()==Mt.LOADED)return this.iconImage_.getSize()[0]*t[0]}getHeight(){let t=this.getScaleArray();if(this.size_)return this.size_[1]*t[1];if(this.iconImage_.getImageState()==Mt.LOADED)return this.iconImage_.getSize()[1]*t[1]}setScale(t){delete this.initialOptions_,super.setScale(t)}listenImageChange(t){this.iconImage_.addEventListener(yi.CHANGE,t)}load(){this.iconImage_.load()}unlistenImageChange(t){this.iconImage_.removeEventListener(yi.CHANGE,t)}ready(){return this.iconImage_.ready()}},ad=Ly;var As=.5;function G1(h,t,r,l,c,n,x,b,S){let R=S?Us(c,S):c,E=h[0]*As,A=h[1]*As,z=Oi(E,A);z.imageSmoothingEnabled=!1;let W=z.canvas,ne=new g1(z,As,c,null,x,b,S?Dc(Bn(),S):null),ge=r.length,me=Math.floor((256*256*256-1)/ge),ve={};for(let Oe=1;Oe<=ge;++Oe){let Pe=r[Oe-1],ze=Pe.getStyleFunction()||l;if(!ze)continue;let Me=ze(Pe,n);if(!Me)continue;Array.isArray(Me)||(Me=[Me]);let tt=(Oe*me).toString(16).padStart(7,"#00000");for(let Je=0,st=Me.length;Je<st;++Je){let bt=Me[Je],lt=bt.getGeometryFunction()(Pe);if(!lt||!Qi(R,lt.getExtent()))continue;let Tt=bt.clone(),ct=Tt.getFill();ct&&ct.setColor(tt);let yt=Tt.getStroke();yt&&(yt.setColor(tt),yt.setLineDash(null)),Tt.setText(void 0);let xt=bt.getImage();if(xt){let Ot=xt.getImageSize();if(!Ot)continue;let At=Oi(Ot[0],Ot[1],void 0,{alpha:!1}),Xe=At.canvas;At.fillStyle=tt,At.fillRect(0,0,Xe.width,Xe.height),Tt.setImage(new ad({img:Xe,anchor:xt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:xt.getOrigin(),opacity:1,size:xt.getSize(),scale:xt.getScale(),rotation:xt.getRotation(),rotateWithView:xt.getRotateWithView()}))}let ht=Tt.getZIndex()||0,vt=ve[ht];vt||(vt={},ve[ht]=vt,vt.Polygon=[],vt.Circle=[],vt.LineString=[],vt.Point=[]);let Nt=lt.getType();if(Nt==="GeometryCollection"){let Ot=lt.getGeometriesArrayRecursive();for(let At=0,Xe=Ot.length;At<Xe;++At){let ei=Ot[At];vt[ei.getType().replace("Multi","")].push(ei,Tt)}}else vt[Nt.replace("Multi","")].push(lt,Tt)}}let Te=Object.keys(ve).map(Number).sort(vs);for(let Oe=0,Pe=Te.length;Oe<Pe;++Oe){let ze=ve[Te[Oe]];for(let Me in ze){let et=ze[Me];for(let tt=0,Je=et.length;tt<Je;tt+=2){ne.setStyle(et[tt+1]);for(let st=0,bt=t.length;st<bt;++st)ne.setTransform(t[st]),ne.drawGeometry(et[tt])}}}return z.getImageData(0,0,W.width,W.height)}function V1(h,t,r){let l=[];if(r){let c=Math.floor(Math.round(h[0])*As),n=Math.floor(Math.round(h[1])*As),x=(Pi(c,0,r.width-1)+Pi(n,0,r.height-1)*r.width)*4,b=r.data[x],S=r.data[x+1],E=r.data[x+2]+256*(S+256*b),A=Math.floor((256*256*256-1)/t.length);E&&E%A===0&&l.push(t[E/A-1])}return l}var ky=class extends Ei{constructor(t,r,l,c){super(t),this.inversePixelTransform=r,this.frameState=l,this.context=c}},U1=ky;var OC=5,Dy=class extends Jp{constructor(t){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=t,this.staleKeys_=new Array,this.maxStaleKeys=OC}getStaleKeys(){return this.staleKeys_}prependStaleKey(t){this.staleKeys_.unshift(t),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(t){return St()}getData(t){return null}prepareFrame(t){return St()}renderFrame(t,r){return St()}forEachFeatureAtCoordinate(t,r,l,c,n){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(t){let r=t.target;(r.getState()===Mt.LOADED||r.getState()===Mt.ERROR)&&this.renderIfReadyAndVisible()}loadImage(t){let r=t.getState();return r!=Mt.LOADED&&r!=Mt.ERROR&&t.addEventListener(yi.CHANGE,this.boundHandleImageChange_),r==Mt.IDLE&&(t.load(),r=t.getState()),r==Mt.LOADED}renderIfReadyAndVisible(){let t=this.getLayer();t&&t.getVisible()&&t.getSourceState()==="ready"&&t.changed()}renderDeferred(t){}disposeInternal(){delete this.layer_,super.disposeInternal()}},xa=Dy;var zy=[],$c=null;function BC(){$c=Oi(1,1,void 0,{willReadFrequently:!0})}var Fy=class extends xa{constructor(t){super(t),this.container=null,this.renderedResolution,this.tempTransform=mr(),this.pixelTransform=mr(),this.inversePixelTransform=mr(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(t,r,l){$c||BC(),$c.clearRect(0,0,1,1);let c;try{$c.drawImage(t,r,l,1,1,0,0,1,1),c=$c.getImageData(0,0,1,1).data}catch{return $c=null,null}return c}getBackground(t){let l=this.getLayer().getBackground();return typeof l=="function"&&(l=l(t.viewState.resolution)),l||void 0}useContainer(t,r,l){let c=this.getLayer().getClassName(),n,x;if(t&&t.className===c&&(!l||t&&t.style.backgroundColor&&yn(Ps(t.style.backgroundColor),Ps(l)))){let b=t.firstElementChild;b instanceof HTMLCanvasElement&&(x=b.getContext("2d"))}if(x&&x.canvas.style.transform===r?(this.container=t,this.context=x,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){n=document.createElement("div"),n.className=c;let b=n.style;b.position="absolute",b.width="100%",b.height="100%",x=Oi();let S=x.canvas;n.appendChild(S),b=S.style,b.position="absolute",b.left="0",b.transformOrigin="top left",this.container=n,this.context=x}!this.containerReused&&l&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=l)}clipUnrotated(t,r,l){let c=zg(l),n=Og(l),x=Fg(l),b=Dg(l);Mr(r.coordinateToPixelTransform,c),Mr(r.coordinateToPixelTransform,n),Mr(r.coordinateToPixelTransform,x),Mr(r.coordinateToPixelTransform,b);let S=this.inversePixelTransform;Mr(S,c),Mr(S,n),Mr(S,x),Mr(S,b),t.save(),t.beginPath(),t.moveTo(Math.round(c[0]),Math.round(c[1])),t.lineTo(Math.round(n[0]),Math.round(n[1])),t.lineTo(Math.round(x[0]),Math.round(x[1])),t.lineTo(Math.round(b[0]),Math.round(b[1])),t.clip()}prepareContainer(t,r){let l=t.extent,c=t.viewState.resolution,n=t.viewState.rotation,x=t.pixelRatio,b=Math.round(Ti(l)/c*x),S=Math.round(sr(l)/c*x);Ur(this.pixelTransform,t.size[0]/2,t.size[1]/2,1/x,1/x,n,-b/2,-S/2),Av(this.inversePixelTransform,this.pixelTransform);let R=Ag(this.pixelTransform);if(this.useContainer(r,R,this.getBackground(t)),!this.containerReused){let E=this.context.canvas;E.width!=b||E.height!=S?(E.width=b,E.height=S):this.context.clearRect(0,0,b,S),R!==E.style.transform&&(E.style.transform=R)}}dispatchRenderEvent_(t,r,l){let c=this.getLayer();if(c.hasListener(t)){let n=new U1(t,this.inversePixelTransform,l,r);c.dispatchEvent(n)}}preRender(t,r){this.frameState=r,!r.declutter&&this.dispatchRenderEvent_(qs.PRERENDER,t,r)}postRender(t,r){r.declutter||this.dispatchRenderEvent_(qs.POSTRENDER,t,r)}renderDeferredInternal(t){}getRenderContext(t){return t.declutter&&!this.deferredContext_&&(this.deferredContext_=new zf),t.declutter?this.deferredContext_.getContext():this.context}renderDeferred(t){t.declutter&&(this.dispatchRenderEvent_(qs.PRERENDER,this.context,t),t.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(t),this.dispatchRenderEvent_(qs.POSTRENDER,this.context,t))}getRenderTransform(t,r,l,c,n,x,b){let S=n/2,R=x/2,E=c/r,A=-E,z=-t[0]+b,W=-t[1];return Ur(this.tempTransform,S,R,E,A,-l,z,W)}disposeInternal(){delete this.frameState,super.disposeInternal()}},Of=Fy;var Oy=class extends Of{constructor(t){super(t),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=_n(),this.wrappedRenderedExtent_=_n(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(t,r,l){let c=r.extent,n=r.viewState,x=n.center,b=n.resolution,S=n.projection,R=n.rotation,E=S.getExtent(),A=this.getLayer().getSource(),z=this.getLayer().getDeclutter(),W=r.pixelRatio,ne=r.viewHints,ge=!(ne[vn.ANIMATING]||ne[vn.INTERACTING]),me=this.context,ve=Math.round(Ti(c)/b*W),Te=Math.round(sr(c)/b*W),Oe=A.getWrapX()&&S.canWrapX(),Pe=Oe?Ti(E):null,ze=Oe?Math.ceil((c[2]-E[2])/Pe)+1:1,Me=Oe?Math.floor((c[0]-E[0])/Pe):0;do{let et=this.getRenderTransform(x,b,0,W,ve,Te,Me*Pe);r.declutter&&(et=et.slice(0)),t.execute(me,[me.canvas.width,me.canvas.height],et,R,ge,l===void 0?wl:l?Ay:B1,l?z&&r.declutter[z]:void 0)}while(++Me<ze)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Oi(this.context.canvas.width,this.context.canvas.height,zy))}resetDrawContext_(){if(this.opacity_!==1){let t=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=t,l1(this.context),zy.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(t){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,t,!0)}renderDeferredInternal(t){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(t,r){let l=t.layerStatesArray[t.layerIndex];this.opacity_=l.opacity;let c=t.viewState;this.prepareContainer(t,r);let n=this.context,x=this.replayGroup_,b=x&&!x.isEmpty();if(!b&&!(this.getLayer().hasListener(qs.PRERENDER)||this.getLayer().hasListener(qs.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(n,t);let S=c.projection;if(this.clipped_=!1,b&&l.extent&&this.clipping){let R=Zs(l.extent,S);b=Qi(R,t.extent),this.clipped_=b&&!cl(R,t.extent),this.clipped_&&this.clipUnrotated(n,t,R)}return b&&this.renderWorlds(x,t,this.getLayer().getDeclutter()?!1:void 0),!t.declutter&&this.clipped_&&n.restore(),this.postRender(n,t),this.renderedRotation_!==c.rotation&&(this.renderedRotation_=c.rotation,this.hitDetectionImageData_=null),t.declutter||this.resetDrawContext_(),this.container}getFeatures(t){return new Promise(r=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let l=this.frameState.size.slice(),c=this.renderedCenter_,n=this.renderedResolution_,x=this.renderedRotation_,b=this.renderedProjection_,S=this.wrappedRenderedExtent_,R=this.getLayer(),E=[],A=l[0]*As,z=l[1]*As;E.push(this.getRenderTransform(c,n,x,As,A,z,0).slice());let W=R.getSource(),ne=b.getExtent();if(W.getWrapX()&&b.canWrapX()&&!cl(ne,S)){let me=S[0],ve=Ti(ne),Te=0,Oe;for(;me<ne[0];)--Te,Oe=ve*Te,E.push(this.getRenderTransform(c,n,x,As,A,z,Oe).slice()),me+=ve;for(Te=0,me=S[2];me>ne[2];)++Te,Oe=ve*Te,E.push(this.getRenderTransform(c,n,x,As,A,z,Oe).slice()),me-=ve}let ge=Bn();this.hitDetectionImageData_=G1(l,E,this.renderedFeatures_,R.getStyleFunction(),S,n,x,ty(n,this.renderedPixelRatio_),ge?b:null)}r(V1(t,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(t,r,l,c,n){if(!this.replayGroup_)return;let x=r.viewState.resolution,b=r.viewState.rotation,S=this.getLayer(),R={},E=function(z,W,ne){let ge=Vt(z),me=R[ge];if(me){if(me!==!0&&ne<me.distanceSq){if(ne===0)return R[ge]=!0,n.splice(n.lastIndexOf(me),1),c(z,S,W);me.geometry=W,me.distanceSq=ne}}else{if(ne===0)return R[ge]=!0,c(z,S,W);n.push(R[ge]={feature:z,layer:S,geometry:W,distanceSq:ne,callback:c})}},A=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(t,x,b,l,E,A?r.declutter?.[A]?.all().map(z=>z.value):null)}handleFontsChanged(){let t=this.getLayer();t.getVisible()&&this.replayGroup_&&t.changed()}handleStyleImageChange_(t){this.renderIfReadyAndVisible()}prepareFrame(t){let r=this.getLayer(),l=r.getSource();if(!l)return!1;let c=t.viewHints[vn.ANIMATING],n=t.viewHints[vn.INTERACTING],x=r.getUpdateWhileAnimating(),b=r.getUpdateWhileInteracting();if(this.ready&&!x&&c||!b&&n)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let S=t.extent,R=t.viewState,E=R.projection,A=R.resolution,z=t.pixelRatio,W=r.getRevision(),ne=r.getRenderBuffer(),ge=r.getRenderOrder();ge===void 0&&(ge=y1);let me=R.center.slice(),ve=Kn(S,ne*A),Te=ve.slice(),Oe=[ve.slice()],Pe=E.getExtent();if(l.getWrapX()&&E.canWrapX()&&!cl(Pe,t.extent)){let yt=Ti(Pe),xt=Math.max(Ti(ve)/2,yt);ve[0]=Pe[0]-xt,ve[2]=Pe[2]+xt,Kv(me,E);let ht=Bg(Oe[0],E);ht[0]<Pe[0]&&ht[2]<Pe[2]?Oe.push([ht[0]+yt,ht[1],ht[2]+yt,ht[3]]):ht[0]>Pe[0]&&ht[2]>Pe[2]&&Oe.push([ht[0]-yt,ht[1],ht[2]-yt,ht[3]])}if(this.ready&&this.renderedResolution_==A&&this.renderedRevision_==W&&this.renderedRenderOrder_==ge&&this.renderedFrameDeclutter_===!!t.declutter&&cl(this.wrappedRenderedExtent_,ve))return yn(this.renderedExtent_,Te)||(this.hitDetectionImageData_=null,this.renderedExtent_=Te),this.renderedCenter_=me,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let ze=new k1(iy(A,z),ve,A,z),Me=Bn(),et;if(Me){for(let yt=0,xt=Oe.length;yt<xt;++yt){let ht=Oe[yt],vt=Us(ht,E);l.loadFeatures(vt,_b(A,E),Me)}et=Dc(Me,E)}else for(let yt=0,xt=Oe.length;yt<xt;++yt)l.loadFeatures(Oe[yt],A,E);let tt=ty(A,z),Je=!0,st=(yt,xt)=>{let ht,vt=yt.getStyleFunction()||r.getStyleFunction();if(vt&&(ht=vt(yt,A)),ht){let Nt=this.renderFeature(yt,tt,ht,ze,et,this.getLayer().getDeclutter(),xt);Je=Je&&!Nt}},bt=Us(ve,E),lt=l.getFeaturesInExtent(bt);ge&&lt.sort(ge);for(let yt=0,xt=lt.length;yt<xt;++yt)st(lt[yt],yt);this.renderedFeatures_=lt,this.ready=Je;let Tt=ze.finish(),ct=new j1(ve,A,z,l.getOverlaps(),Tt,r.getRenderBuffer(),!!t.declutter);return this.renderedResolution_=A,this.renderedRevision_=W,this.renderedRenderOrder_=ge,this.renderedFrameDeclutter_=!!t.declutter,this.renderedExtent_=Te,this.wrappedRenderedExtent_=ve,this.renderedCenter_=me,this.renderedProjection_=E,this.renderedPixelRatio_=z,this.replayGroup_=ct,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(t,r,l,c,n,x,b){if(!l)return!1;let S=!1;if(Array.isArray(l))for(let R=0,E=l.length;R<E;++R)S=ry(c,t,l[R],r,this.boundHandleStyleImageChange_,n,x,b)||S;else S=ry(c,t,l,r,this.boundHandleStyleImageChange_,n,x,b);return S}},Z1=Oy;var Sl=0;var Wr=1<<Sl++,Ut=1<<Sl++,sn=1<<Sl++,Nn=1<<Sl++,ba=1<<Sl++,ld=1<<Sl++,Bf=Math.pow(2,Sl)-1,Ny={[Wr]:"boolean",[Ut]:"number",[sn]:"string",[Nn]:"color",[ba]:"number[]",[ld]:"size"},jC=Object.keys(Ny).map(Number).sort(vs);function NC(h){return h in Ny}function cd(h){let t=[];for(let r of jC)hd(h,r)&&t.push(Ny[r]);return t.length===0?"untyped":t.length<3?t.join(" or "):t.slice(0,-1).join(", ")+", or "+t[t.length-1]}function hd(h,t){return(h&t)===t}function va(h,t){return h===t}var Bi=class{constructor(t,r){if(!NC(t))throw new Error(`literal expressions must have a specific type, got ${cd(t)}`);this.type=t,this.value=r}},jy=class{constructor(t,r,...l){this.type=t,this.operator=r,this.args=l}};function Gy(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1,mapState:!1}}function xr(h,t,r){switch(typeof h){case"boolean":{if(va(t,sn))return new Bi(sn,h?"true":"false");if(!hd(t,Wr))throw new Error(`got a boolean, but expected ${cd(t)}`);return new Bi(Wr,h)}case"number":{if(va(t,ld))return new Bi(ld,Hs(h));if(va(t,Wr))return new Bi(Wr,!!h);if(va(t,sn))return new Bi(sn,h.toString());if(!hd(t,Ut))throw new Error(`got a number, but expected ${cd(t)}`);return new Bi(Ut,h)}case"string":{if(va(t,Nn))return new Bi(Nn,Yu(h));if(va(t,Wr))return new Bi(Wr,!!h);if(!hd(t,sn))throw new Error(`got a string, but expected ${cd(t)}`);return new Bi(sn,h)}default:}if(!Array.isArray(h))throw new Error("expression must be an array or a primitive value");if(h.length===0)throw new Error("empty expression");if(typeof h[0]=="string")return KC(h,t,r);for(let l of h)if(typeof l!="number")throw new Error("expected an array of numbers");if(va(t,ld)){if(h.length!==2)throw new Error(`expected an array of two values for a size, got ${h.length}`);return new Bi(ld,h)}if(va(t,Nn)){if(h.length===3)return new Bi(Nn,[...h,1]);if(h.length===4)return new Bi(Nn,h);throw new Error(`expected an array of 3 or 4 values for a color, got ${h.length}`)}if(!hd(t,ba))throw new Error(`got an array of numbers, but expected ${cd(t)}`);return new Bi(ba,h)}var Ne={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},GC={[Ne.Get]:Pt(Ft(1,1/0),q1),[Ne.Var]:Pt(Ft(1,1),VC),[Ne.Has]:Pt(Ft(1,1/0),q1),[Ne.Id]:Pt(UC,Xc),[Ne.Concat]:Pt(Ft(2,1/0),Kt(sn)),[Ne.GeometryType]:Pt(ZC,Xc),[Ne.LineMetric]:Pt(Xc),[Ne.Resolution]:Pt(By,Xc),[Ne.Zoom]:Pt(By,Xc),[Ne.Time]:Pt(By,Xc),[Ne.Any]:Pt(Ft(2,1/0),Kt(Wr)),[Ne.All]:Pt(Ft(2,1/0),Kt(Wr)),[Ne.Not]:Pt(Ft(1,1),Kt(Wr)),[Ne.Equal]:Pt(Ft(2,2),Kt(Bf)),[Ne.NotEqual]:Pt(Ft(2,2),Kt(Bf)),[Ne.GreaterThan]:Pt(Ft(2,2),Kt(Ut)),[Ne.GreaterThanOrEqualTo]:Pt(Ft(2,2),Kt(Ut)),[Ne.LessThan]:Pt(Ft(2,2),Kt(Ut)),[Ne.LessThanOrEqualTo]:Pt(Ft(2,2),Kt(Ut)),[Ne.Multiply]:Pt(Ft(2,1/0),W1),[Ne.Coalesce]:Pt(Ft(2,1/0),W1),[Ne.Divide]:Pt(Ft(2,2),Kt(Ut)),[Ne.Add]:Pt(Ft(2,1/0),Kt(Ut)),[Ne.Subtract]:Pt(Ft(2,2),Kt(Ut)),[Ne.Clamp]:Pt(Ft(3,3),Kt(Ut)),[Ne.Mod]:Pt(Ft(2,2),Kt(Ut)),[Ne.Pow]:Pt(Ft(2,2),Kt(Ut)),[Ne.Abs]:Pt(Ft(1,1),Kt(Ut)),[Ne.Floor]:Pt(Ft(1,1),Kt(Ut)),[Ne.Ceil]:Pt(Ft(1,1),Kt(Ut)),[Ne.Round]:Pt(Ft(1,1),Kt(Ut)),[Ne.Sin]:Pt(Ft(1,1),Kt(Ut)),[Ne.Cos]:Pt(Ft(1,1),Kt(Ut)),[Ne.Atan]:Pt(Ft(1,2),Kt(Ut)),[Ne.Sqrt]:Pt(Ft(1,1),Kt(Ut)),[Ne.Match]:Pt(Ft(4,1/0),$1,WC),[Ne.Between]:Pt(Ft(3,3),Kt(Ut)),[Ne.Interpolate]:Pt(Ft(6,1/0),$1,$C),[Ne.Case]:Pt(Ft(3,1/0),qC,XC),[Ne.In]:Pt(Ft(2,2),HC),[Ne.Number]:Pt(Ft(1,1/0),Kt(Bf)),[Ne.String]:Pt(Ft(1,1/0),Kt(Bf)),[Ne.Array]:Pt(Ft(1,1/0),Kt(Ut)),[Ne.Color]:Pt(Ft(1,4),Kt(Ut)),[Ne.Band]:Pt(Ft(1,3),Kt(Ut)),[Ne.Palette]:Pt(Ft(2,2),YC),[Ne.ToString]:Pt(Ft(1,1),Kt(Wr|Ut|sn|Nn))};function q1(h,t,r){let l=h.length-1,c=new Array(l);for(let n=0;n<l;++n){let x=h[n+1];switch(typeof x){case"number":{c[n]=new Bi(Ut,x);break}case"string":{c[n]=new Bi(sn,x);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${x}`)}n===0&&r.properties.add(String(x))}return c}function VC(h,t,r){let l=h[1];if(typeof l!="string")throw new Error("expected a string argument for var operation");return r.variables.add(l),[new Bi(sn,l)]}function UC(h,t,r){r.featureId=!0}function ZC(h,t,r){r.geometryType=!0}function By(h,t,r){r.mapState=!0}function Xc(h,t,r){let l=h[0];if(h.length!==1)throw new Error(`expected no arguments for ${l} operation`);return[]}function Ft(h,t){return function(r,l,c){let n=r[0],x=r.length-1;if(h===t){if(x!==h){let b=h===1?"":"s";throw new Error(`expected ${h} argument${b} for ${n}, got ${x}`)}}else if(x<h||x>t){let b=t===1/0?`${h} or more`:`${h} to ${t}`;throw new Error(`expected ${b} arguments for ${n}, got ${x}`)}}}function W1(h,t,r){let l=h.length-1,c=new Array(l);for(let n=0;n<l;++n){let x=xr(h[n+1],t,r);c[n]=x}return c}function Kt(h){return function(t,r,l){let c=t.length-1,n=new Array(c);for(let x=0;x<c;++x){let b=xr(t[x+1],h,l);n[x]=b}return n}}function qC(h,t,r){let l=h[0],c=h.length-1;if(c%2===0)throw new Error(`expected an odd number of arguments for ${l}, got ${c} instead`)}function $1(h,t,r){let l=h[0],c=h.length-1;if(c%2===1)throw new Error(`expected an even number of arguments for operation ${l}, got ${c} instead`)}function WC(h,t,r){let l=h.length-1,c=sn|Ut|Wr,n=xr(h[1],c,r),x=xr(h[h.length-1],t,r),b=new Array(l-2);for(let S=0;S<l-2;S+=2){try{let R=xr(h[S+2],n.type,r);b[S]=R}catch(R){throw new Error(`failed to parse argument ${S+1} of match expression: ${R.message}`)}try{let R=xr(h[S+3],x.type,r);b[S+1]=R}catch(R){throw new Error(`failed to parse argument ${S+2} of match expression: ${R.message}`)}}return[n,...b,x]}function $C(h,t,r){let l=h[1],c;switch(l[0]){case"linear":c=1;break;case"exponential":let S=l[1];if(typeof S!="number"||S<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(S)} instead`);c=S;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(l)}`)}let n=new Bi(Ut,c),x;try{x=xr(h[2],Ut,r)}catch(S){throw new Error(`failed to parse argument 1 in interpolate expression: ${S.message}`)}let b=new Array(h.length-3);for(let S=0;S<b.length;S+=2){try{let R=xr(h[S+3],Ut,r);b[S]=R}catch(R){throw new Error(`failed to parse argument ${S+2} for interpolate expression: ${R.message}`)}try{let R=xr(h[S+4],t,r);b[S+1]=R}catch(R){throw new Error(`failed to parse argument ${S+3} for interpolate expression: ${R.message}`)}}return[n,x,...b]}function XC(h,t,r){let l=xr(h[h.length-1],t,r),c=new Array(h.length-1);for(let n=0;n<c.length-1;n+=2){try{let x=xr(h[n+1],Wr,r);c[n]=x}catch(x){throw new Error(`failed to parse argument ${n} of case expression: ${x.message}`)}try{let x=xr(h[n+2],l.type,r);c[n+1]=x}catch(x){throw new Error(`failed to parse argument ${n+1} of case expression: ${x.message}`)}}return c[c.length-1]=l,c}function HC(h,t,r){let l=h[2];if(!Array.isArray(l))throw new Error('the second argument for the "in" operator must be an array');let c;if(typeof l[0]=="string"){if(l[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(l[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');l=l[1],c=sn}else c=Ut;let n=new Array(l.length);for(let b=0;b<n.length;b++)try{let S=xr(l[b],c,r);n[b]=S}catch(S){throw new Error(`failed to parse haystack item ${b} for "in" expression: ${S.message}`)}return[xr(h[1],c,r),...n]}function YC(h,t,r){let l;try{l=xr(h[1],Ut,r)}catch(x){throw new Error(`failed to parse first argument in palette expression: ${x.message}`)}let c=h[2];if(!Array.isArray(c))throw new Error("the second argument of palette must be an array");let n=new Array(c.length);for(let x=0;x<n.length;x++){let b;try{b=xr(c[x],Nn,r)}catch(S){throw new Error(`failed to parse color at index ${x} in palette expression: ${S.message}`)}if(!(b instanceof Bi))throw new Error(`the palette color at index ${x} must be a literal value`);n[x]=b}return[l,...n]}function Pt(...h){return function(t,r,l){let c=t[0],n;for(let x=0;x<h.length;x++){let b=h[x](t,r,l);if(x==h.length-1){if(!b)throw new Error("expected last argument validator to return the parsed args");n=b}}return new jy(r,c,...n)}}function KC(h,t,r){let l=h[0],c=GC[l];if(!c)throw new Error(`unknown operator: ${l}`);return c(h,t,r)}function Vy(h){if(!h)return"";let t=h.getType();switch(t){case"Point":case"LineString":case"Polygon":return t;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return t.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Vy(h.getGeometries()[0]);default:return""}}function Uy(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Js(h,t,r){let l=xr(h,t,r);return Ls(l,r)}function Ls(h,t){if(h instanceof Bi){if(h.type===Nn&&typeof h.value=="string"){let l=Yu(h.value);return function(){return l}}return function(){return h.value}}let r=h.operator;switch(r){case Ne.Number:case Ne.String:case Ne.Coalesce:return JC(h,t);case Ne.Get:case Ne.Var:case Ne.Has:return QC(h,t);case Ne.Id:return l=>l.featureId;case Ne.GeometryType:return l=>l.geometryType;case Ne.Concat:{let l=h.args.map(c=>Ls(c,t));return c=>"".concat(...l.map(n=>n(c).toString()))}case Ne.Resolution:return l=>l.resolution;case Ne.Any:case Ne.All:case Ne.Between:case Ne.In:case Ne.Not:return tM(h,t);case Ne.Equal:case Ne.NotEqual:case Ne.LessThan:case Ne.LessThanOrEqualTo:case Ne.GreaterThan:case Ne.GreaterThanOrEqualTo:return eM(h,t);case Ne.Multiply:case Ne.Divide:case Ne.Add:case Ne.Subtract:case Ne.Clamp:case Ne.Mod:case Ne.Pow:case Ne.Abs:case Ne.Floor:case Ne.Ceil:case Ne.Round:case Ne.Sin:case Ne.Cos:case Ne.Atan:case Ne.Sqrt:return iM(h,t);case Ne.Case:return rM(h,t);case Ne.Match:return nM(h,t);case Ne.Interpolate:return sM(h,t);case Ne.ToString:return oM(h,t);default:throw new Error(`Unsupported operator ${r}`)}}function JC(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.Coalesce:return n=>{for(let x=0;x<l;++x){let b=c[x](n);if(typeof b<"u"&&b!==null)return b}throw new Error("Expected one of the values to be non-null")};case Ne.Number:case Ne.String:return n=>{for(let x=0;x<l;++x){let b=c[x](n);if(typeof b===r)return b}throw new Error(`Expected one of the values to be a ${r}`)};default:throw new Error(`Unsupported assertion operator ${r}`)}}function QC(h,t){let l=h.args[0].value;switch(h.operator){case Ne.Get:return c=>{let n=h.args,x=c.properties[l];for(let b=1,S=n.length;b<S;++b){let E=n[b].value;x=x[E]}return x};case Ne.Var:return c=>c.variables[l];case Ne.Has:return c=>{let n=h.args;if(!(l in c.properties))return!1;let x=c.properties[l];for(let b=1,S=n.length;b<S;++b){let E=n[b].value;if(!x||!Object.hasOwn(x,E))return!1;x=x[E]}return!0};default:throw new Error(`Unsupported accessor operator ${h.operator}`)}}function eM(h,t){let r=h.operator,l=Ls(h.args[0],t),c=Ls(h.args[1],t);switch(r){case Ne.Equal:return n=>l(n)===c(n);case Ne.NotEqual:return n=>l(n)!==c(n);case Ne.LessThan:return n=>l(n)<c(n);case Ne.LessThanOrEqualTo:return n=>l(n)<=c(n);case Ne.GreaterThan:return n=>l(n)>c(n);case Ne.GreaterThanOrEqualTo:return n=>l(n)>=c(n);default:throw new Error(`Unsupported comparison operator ${r}`)}}function tM(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.Any:return n=>{for(let x=0;x<l;++x)if(c[x](n))return!0;return!1};case Ne.All:return n=>{for(let x=0;x<l;++x)if(!c[x](n))return!1;return!0};case Ne.Between:return n=>{let x=c[0](n),b=c[1](n),S=c[2](n);return x>=b&&x<=S};case Ne.In:return n=>{let x=c[0](n);for(let b=1;b<l;++b)if(x===c[b](n))return!0;return!1};case Ne.Not:return n=>!c[0](n);default:throw new Error(`Unsupported logical operator ${r}`)}}function iM(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.Multiply:return n=>{let x=1;for(let b=0;b<l;++b)x*=c[b](n);return x};case Ne.Divide:return n=>c[0](n)/c[1](n);case Ne.Add:return n=>{let x=0;for(let b=0;b<l;++b)x+=c[b](n);return x};case Ne.Subtract:return n=>c[0](n)-c[1](n);case Ne.Clamp:return n=>{let x=c[0](n),b=c[1](n);if(x<b)return b;let S=c[2](n);return x>S?S:x};case Ne.Mod:return n=>c[0](n)%c[1](n);case Ne.Pow:return n=>Math.pow(c[0](n),c[1](n));case Ne.Abs:return n=>Math.abs(c[0](n));case Ne.Floor:return n=>Math.floor(c[0](n));case Ne.Ceil:return n=>Math.ceil(c[0](n));case Ne.Round:return n=>Math.round(c[0](n));case Ne.Sin:return n=>Math.sin(c[0](n));case Ne.Cos:return n=>Math.cos(c[0](n));case Ne.Atan:return l===2?n=>Math.atan2(c[0](n),c[1](n)):n=>Math.atan(c[0](n));case Ne.Sqrt:return n=>Math.sqrt(c[0](n));default:throw new Error(`Unsupported numeric operator ${r}`)}}function rM(h,t){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Ls(h.args[c],t);return c=>{for(let n=0;n<r-1;n+=2)if(l[n](c))return l[n+1](c);return l[r-1](c)}}function nM(h,t){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Ls(h.args[c],t);return c=>{let n=l[0](c);for(let x=1;x<r;x+=2)if(n===l[x](c))return l[x+1](c);return l[r-1](c)}}function sM(h,t){let r=h.args.length,l=new Array(r);for(let c=0;c<r;++c)l[c]=Ls(h.args[c],t);return c=>{let n=l[0](c),x=l[1](c),b,S;for(let R=2;R<r;R+=2){let E=l[R](c),A=l[R+1](c),z=Array.isArray(A);if(z&&(A=o1(A)),E>=x)return R===2?A:z?aM(n,x,b,S,E,A):ud(n,x,b,S,E,A);b=E,S=A}return S}}function oM(h,t){let r=h.operator,l=h.args.length,c=new Array(l);for(let n=0;n<l;++n)c[n]=Ls(h.args[n],t);switch(r){case Ne.ToString:return n=>{let x=c[0](n);return h.args[0].type===Nn?Ku(x):x.toString()};default:throw new Error(`Unsupported convert operator ${r}`)}}function ud(h,t,r,l,c,n){let x=c-r;if(x===0)return l;let b=t-r,S=h===1?b/x:(Math.pow(h,b)-1)/(Math.pow(h,x)-1);return l+S*(n-l)}function aM(h,t,r,l,c,n){if(c-r===0)return l;let b=Z_(l),S=Z_(n),R=S[2]-b[2];R>180?R-=360:R<-180&&(R+=360);let E=[ud(h,t,r,b[0],c,S[0]),ud(h,t,r,b[1],c,S[1]),b[2]+ud(h,t,r,0,c,R),ud(h,t,r,l[3],c,n[3])];return q_(a1(E))}function lM(h){return!0}function K1(h){let t=Gy(),r=cM(h,t),l=Uy();return function(c,n){if(l.properties=c.getPropertiesInternal(),l.resolution=n,t.featureId){let x=c.getId();x!==void 0?l.featureId=x:l.featureId=null}return t.geometryType&&(l.geometryType=Vy(c.getGeometry())),r(l)}}function Wy(h){let t=Gy(),r=h.length,l=new Array(r);for(let x=0;x<r;++x)l[x]=Zy(h[x],t);let c=Uy(),n=new Array(r);return function(x,b){if(c.properties=x.getPropertiesInternal(),c.resolution=b,t.featureId){let R=x.getId();R!==void 0?c.featureId=R:c.featureId=null}let S=0;for(let R=0;R<r;++R){let E=l[R](c);E&&(n[S]=E,S+=1)}return n.length=S,n}}function cM(h,t){let r=h.length,l=new Array(r);for(let c=0;c<r;++c){let n=h[c],x="filter"in n?Js(n.filter,Wr,t):lM,b;if(Array.isArray(n.style)){let S=n.style.length;b=new Array(S);for(let R=0;R<S;++R)b[R]=Zy(n.style[R],t)}else b=[Zy(n.style,t)];l[c]={filter:x,styles:b}}return function(c){let n=[],x=!1;for(let b=0;b<r;++b){let S=l[b].filter;if(S(c)&&!(h[b].else&&x)){x=!0;for(let R of l[b].styles){let E=R(c);E&&n.push(E)}}}return n}}function Zy(h,t){let r=dd(h,"",t),l=pd(h,"",t),c=hM(h,t),n=uM(h,t),x=Mn(h,"z-index",t);if(!r&&!l&&!c&&!n&&!On(h))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(h));let b=new Lr;return function(S){let R=!0;if(r){let E=r(S);E&&(R=!1),b.setFill(E)}if(l){let E=l(S);E&&(R=!1),b.setStroke(E)}if(c){let E=c(S);E&&(R=!1),b.setText(E)}if(n){let E=n(S);E&&(R=!1),b.setImage(E)}return x&&b.setZIndex(x(S)),R?null:b}}function dd(h,t,r){let l;if(t+"fill-pattern-src"in h)l=mM(h,t+"fill-",r);else{if(h[t+"fill-color"]==="none")return n=>null;l=$y(h,t+"fill-color",r)}if(!l)return null;let c=new Ar;return function(n){let x=l(n);return x===Mf?null:(c.setColor(x),c)}}function pd(h,t,r){let l=Mn(h,t+"stroke-width",r),c=$y(h,t+"stroke-color",r);if(!l&&!c)return null;let n=Lo(h,t+"stroke-line-cap",r),x=Lo(h,t+"stroke-line-join",r),b=J1(h,t+"stroke-line-dash",r),S=Mn(h,t+"stroke-line-dash-offset",r),R=Mn(h,t+"stroke-miter-limit",r),E=new lr;return function(A){if(c){let z=c(A);if(z===Mf)return null;E.setColor(z)}if(l&&E.setWidth(l(A)),n){let z=n(A);if(z!=="butt"&&z!=="round"&&z!=="square")throw new Error("Expected butt, round, or square line cap");E.setLineCap(z)}if(x){let z=x(A);if(z!=="bevel"&&z!=="round"&&z!=="miter")throw new Error("Expected bevel, round, or miter line join");E.setLineJoin(z)}return b&&E.setLineDash(b(A)),S&&E.setLineDashOffset(S(A)),R&&E.setMiterLimit(R(A)),E}}function hM(h,t){let r="text-",l=Lo(h,r+"value",t);if(!l)return null;let c=dd(h,r,t),n=dd(h,r+"background-",t),x=pd(h,r,t),b=pd(h,r+"background-",t),S=Lo(h,r+"font",t),R=Mn(h,r+"max-angle",t),E=Mn(h,r+"offset-x",t),A=Mn(h,r+"offset-y",t),z=Hc(h,r+"overflow",t),W=Lo(h,r+"placement",t),ne=Mn(h,r+"repeat",t),ge=Gf(h,r+"scale",t),me=Hc(h,r+"rotate-with-view",t),ve=Mn(h,r+"rotation",t),Te=Lo(h,r+"align",t),Oe=Lo(h,r+"justify",t),Pe=Lo(h,r+"baseline",t),ze=Hc(h,r+"keep-upright",t),Me=J1(h,r+"padding",t),et=Vf(h,r+"declutter-mode"),tt=new I1({declutterMode:et});return function(Je){if(tt.setText(l(Je)),c&&tt.setFill(c(Je)),n&&tt.setBackgroundFill(n(Je)),x&&tt.setStroke(x(Je)),b&&tt.setBackgroundStroke(b(Je)),S&&tt.setFont(S(Je)),R&&tt.setMaxAngle(R(Je)),E&&tt.setOffsetX(E(Je)),A&&tt.setOffsetY(A(Je)),z&&tt.setOverflow(z(Je)),W){let st=W(Je);if(st!=="point"&&st!=="line")throw new Error("Expected point or line for text-placement");tt.setPlacement(st)}if(ne&&tt.setRepeat(ne(Je)),ge&&tt.setScale(ge(Je)),me&&tt.setRotateWithView(me(Je)),ve&&tt.setRotation(ve(Je)),Te){let st=Te(Je);if(st!=="left"&&st!=="center"&&st!=="right"&&st!=="end"&&st!=="start")throw new Error("Expected left, right, center, start, or end for text-align");tt.setTextAlign(st)}if(Oe){let st=Oe(Je);if(st!=="left"&&st!=="right"&&st!=="center")throw new Error("Expected left, right, or center for text-justify");tt.setJustify(st)}if(Pe){let st=Pe(Je);if(st!=="bottom"&&st!=="top"&&st!=="middle"&&st!=="alphabetic"&&st!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");tt.setTextBaseline(st)}return Me&&tt.setPadding(Me(Je)),ze&&tt.setKeepUpright(ze(Je)),tt}}function uM(h,t){return"icon-src"in h?dM(h,t):"shape-points"in h?pM(h,t):"circle-radius"in h?fM(h,t):null}function dM(h,t){let r="icon-",l=r+"src",c=Q1(h[l],l),n=jf(h,r+"anchor",t),x=Gf(h,r+"scale",t),b=Mn(h,r+"opacity",t),S=jf(h,r+"displacement",t),R=Mn(h,r+"rotation",t),E=Hc(h,r+"rotate-with-view",t),A=H1(h,r+"anchor-origin"),z=Y1(h,r+"anchor-x-units"),W=Y1(h,r+"anchor-y-units"),ne=xM(h,r+"color"),ge=_M(h,r+"cross-origin"),me=yM(h,r+"offset"),ve=H1(h,r+"offset-origin"),Te=Nf(h,r+"width"),Oe=Nf(h,r+"height"),Pe=gM(h,r+"size"),ze=Vf(h,r+"declutter-mode"),Me=new ad({src:c,anchorOrigin:A,anchorXUnits:z,anchorYUnits:W,color:ne,crossOrigin:ge,offset:me,offsetOrigin:ve,height:Oe,width:Te,size:Pe,declutterMode:ze});return function(et){return b&&Me.setOpacity(b(et)),S&&Me.setDisplacement(S(et)),R&&Me.setRotation(R(et)),E&&Me.setRotateWithView(E(et)),x&&Me.setScale(x(et)),n&&Me.setAnchor(n(et)),Me}}function pM(h,t){let r="shape-",l=r+"points",c=r+"radius",n=qy(h[l],l),x=qy(h[c],c),b=dd(h,r,t),S=pd(h,r,t),R=Gf(h,r+"scale",t),E=jf(h,r+"displacement",t),A=Mn(h,r+"rotation",t),z=Hc(h,r+"rotate-with-view",t),W=Nf(h,r+"radius2"),ne=Nf(h,r+"angle"),ge=Vf(h,r+"declutter-mode"),me=new Ff({points:n,radius:x,radius2:W,angle:ne,declutterMode:ge});return function(ve){return b&&me.setFill(b(ve)),S&&me.setStroke(S(ve)),E&&me.setDisplacement(E(ve)),A&&me.setRotation(A(ve)),z&&me.setRotateWithView(z(ve)),R&&me.setScale(R(ve)),me}}function fM(h,t){let r="circle-",l=dd(h,r,t),c=pd(h,r,t),n=Mn(h,r+"radius",t),x=Gf(h,r+"scale",t),b=jf(h,r+"displacement",t),S=Mn(h,r+"rotation",t),R=Hc(h,r+"rotate-with-view",t),E=Vf(h,r+"declutter-mode"),A=new Cn({radius:5,declutterMode:E});return function(z){return n&&A.setRadius(n(z)),l&&A.setFill(l(z)),c&&A.setStroke(c(z)),b&&A.setDisplacement(b(z)),S&&A.setRotation(S(z)),R&&A.setRotateWithView(R(z)),x&&A.setScale(x(z)),A}}function Mn(h,t,r){if(!(t in h))return;let l=Js(h[t],Ut,r);return function(c){return qy(l(c),t)}}function Lo(h,t,r){if(!(t in h))return null;let l=Js(h[t],sn,r);return function(c){return Q1(l(c),t)}}function mM(h,t,r){let l=Lo(h,t+"pattern-src",r),c=X1(h,t+"pattern-offset",r),n=X1(h,t+"pattern-size",r),x=$y(h,t+"color",r);return function(b){return{src:l(b),offset:c&&c(b),size:n&&n(b),color:x&&x(b)}}}function Hc(h,t,r){if(!(t in h))return null;let l=Js(h[t],Wr,r);return function(c){let n=l(c);if(typeof n!="boolean")throw new Error(`Expected a boolean for ${t}`);return n}}function $y(h,t,r){if(!(t in h))return null;let l=Js(h[t],Nn,r);return function(c){return ew(l(c),t)}}function J1(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba,r);return function(c){return fd(l(c),t)}}function jf(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba,r);return function(c){let n=fd(l(c),t);if(n.length!==2)throw new Error(`Expected two numbers for ${t}`);return n}}function X1(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba,r);return function(c){return tw(l(c),t)}}function Gf(h,t,r){if(!(t in h))return null;let l=Js(h[t],ba|Ut,r);return function(c){return vM(l(c),t)}}function Nf(h,t){let r=h[t];if(r!==void 0){if(typeof r!="number")throw new Error(`Expected a number for ${t}`);return r}}function gM(h,t){let r=h[t];if(r!==void 0){if(typeof r=="number")return Hs(r);if(!Array.isArray(r))throw new Error(`Expected a number or size array for ${t}`);if(r.length!==2||typeof r[0]!="number"||typeof r[1]!="number")throw new Error(`Expected a number or size array for ${t}`);return r}}function _M(h,t){let r=h[t];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${t}`);return r}}function H1(h,t){let r=h[t];if(r!==void 0){if(r!=="bottom-left"&&r!=="bottom-right"&&r!=="top-left"&&r!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${t}`);return r}}function Y1(h,t){let r=h[t];if(r!==void 0){if(r!=="pixels"&&r!=="fraction")throw new Error(`Expected pixels or fraction for ${t}`);return r}}function yM(h,t){let r=h[t];if(r!==void 0)return fd(r,t)}function Vf(h,t){let r=h[t];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${t}`);if(r!=="declutter"&&r!=="obstacle"&&r!=="none")throw new Error(`Expected declutter, obstacle, or none for ${t}`);return r}}function xM(h,t){let r=h[t];if(r!==void 0)return ew(r,t)}function fd(h,t){if(!Array.isArray(h))throw new Error(`Expected an array for ${t}`);let r=h.length;for(let l=0;l<r;++l)if(typeof h[l]!="number")throw new Error(`Expected an array of numbers for ${t}`);return h}function Q1(h,t){if(typeof h!="string")throw new Error(`Expected a string for ${t}`);return h}function qy(h,t){if(typeof h!="number")throw new Error(`Expected a number for ${t}`);return h}function ew(h,t){if(typeof h=="string")return h;let r=fd(h,t),l=r.length;if(l<3||l>4)throw new Error(`Expected a color with 3 or 4 values for ${t}`);return r}function tw(h,t){let r=fd(h,t);if(r.length!==2)throw new Error(`Expected an array of two numbers for ${t}`);return r}function vM(h,t){return typeof h=="number"?h:tw(h,t)}var iw={RENDER_ORDER:"renderOrder"},Xy=class extends Is{constructor(t){t=t||{};let r=Object.assign({},t);delete r.style,delete r.renderBuffer,delete r.updateWhileAnimating,delete r.updateWhileInteracting,super(r),this.declutter_=t.declutter?String(t.declutter):void 0,this.renderBuffer_=t.renderBuffer!==void 0?t.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(t.style),this.updateWhileAnimating_=t.updateWhileAnimating!==void 0?t.updateWhileAnimating:!1,this.updateWhileInteracting_=t.updateWhileInteracting!==void 0?t.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(t){return super.getFeatures(t)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(iw.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(t,r){let l=this.getDeclutter();l in t.declutter||(t.declutter[l]=new vl(9)),this.getRenderer().renderDeclutter(t,r)}setRenderOrder(t){this.set(iw.RENDER_ORDER,t)}setStyle(t){this.style_=t===void 0?gy:t;let r=bM(t);this.styleFunction_=t===null?void 0:C1(r),this.changed()}setDeclutter(t){this.declutter_=t?String(t):void 0,this.changed()}};function bM(h){if(h===void 0)return gy;if(!h)return null;if(typeof h=="function"||h instanceof Lr)return h;if(!Array.isArray(h))return Wy([h]);if(h.length===0)return[];let t=h.length,r=h[0];if(r instanceof Lr){let c=new Array(t);for(let n=0;n<t;++n){let x=h[n];if(!(x instanceof Lr))throw new Error("Expected a list of style instances");c[n]=x}return c}if("style"in r){let c=new Array(t);for(let n=0;n<t;++n){let x=h[n];if(!("style"in x))throw new Error("Expected a list of rules with a style property");c[n]=x}return K1(c)}return Wy(h)}var rw=Xy;var Hy=class extends rw{constructor(t){super(t)}createRenderer(){return new Z1(this)}},Yc=Hy;var Gn={SINGLECLICK:"singleclick",CLICK:yi.CLICK,DBLCLICK:yi.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var Yy={ACTIVE:"active"};var Ky=class extends gr{constructor(t){super(),this.on,this.once,this.un,t&&t.handleEvent&&(this.handleEvent=t.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Yy.ACTIVE)}getMap(){return this.map_}handleEvent(t){return!0}setActive(t){this.set(Yy.ACTIVE,t)}setMap(t){this.map_=t}};var nw=Ky;var sw=function(h){let t=h.originalEvent;return t.altKey&&!(t.metaKey||t.ctrlKey)&&!t.shiftKey};var ow=Hp,aw=function(h){return h.type==Gn.CLICK};var lw=function(h){return h.type==Gn.SINGLECLICK};var cw=function(h){let t=h.originalEvent;return di(t!==void 0,"mapBrowserEvent must originate from a pointer event"),t.isPrimary&&t.button===0};var Jy=class extends nw{constructor(t){t=t||{},super(t),t.handleDownEvent&&(this.handleDownEvent=t.handleDownEvent),t.handleDragEvent&&(this.handleDragEvent=t.handleDragEvent),t.handleMoveEvent&&(this.handleMoveEvent=t.handleMoveEvent),t.handleUpEvent&&(this.handleUpEvent=t.handleUpEvent),t.stopDown&&(this.stopDown=t.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(t){return!1}handleDragEvent(t){}handleEvent(t){if(!t.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(t),this.handlingDownUpSequence){if(t.type==Gn.POINTERDRAG)this.handleDragEvent(t),t.originalEvent.preventDefault();else if(t.type==Gn.POINTERUP){let l=this.handleUpEvent(t);this.handlingDownUpSequence=l&&this.targetPointers.length>0}}else if(t.type==Gn.POINTERDOWN){let l=this.handleDownEvent(t);this.handlingDownUpSequence=l,r=this.stopDown(l)}else t.type==Gn.POINTERMOVE&&this.handleMoveEvent(t);return!r}handleMoveEvent(t){}handleUpEvent(t){return!1}stopDown(t){return t}updateTrackedPointers_(t){t.activePointers&&(this.targetPointers=t.activePointers)}};var hw=Jy;var Qy=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=is,this.supportedMediaTypes=null}getReadOptions(t,r){if(r){let l=r.dataProjection?Ri(r.dataProjection):this.readProjection(t);r.extent&&l&&l.getUnits()==="tile-pixels"&&(l=Ri(l),l.setWorldExtent(r.extent)),r={dataProjection:l,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(t){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},t)}getType(){return St()}readFeature(t,r){return St()}readFeatures(t,r){return St()}readGeometry(t,r){return St()}readProjection(t){return St()}writeFeature(t,r){return St()}writeFeatures(t,r){return St()}writeGeometry(t,r){return St()}},uw=Qy;function Uf(h,t,r){let l=r?Ri(r.featureProjection):null,c=r?Ri(r.dataProjection):null,n=h;if(l&&c&&!gb(l,c)){t&&(n=h.clone());let x=t?l:c,b=t?c:l;x.getUnits()==="tile-pixels"?n.transform(x,b):n.applyTransform(fl(x,b))}if(t&&r&&r.decimals!==void 0){let x=Math.pow(10,r.decimals),b=function(S){for(let R=0,E=S.length;R<E;++R)S[R]=Math.round(S[R]*x)/x;return S};n===h&&(n=h.clone()),n.applyTransform(b)}return n}var wM={Point:yr,LineString:Cs,Polygon:zc,MultiPoint:ju,MultiLineString:g_,MultiPolygon:S_};function SM(h,t,r){return Array.isArray(t[0])?(yf(h,0,t,r)||(h=h.slice(),Vu(h,0,t,r)),h):(Gu(h,0,t,r)||(h=h.slice(),Fc(h,0,t,r)),h)}function e0(h,t){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(n=>e0({...h,geometry:n})).flat();let l=r.type==="MultiPolygon"?"Polygon":r.type;if(l==="GeometryCollection"||l==="Circle")throw new Error("Unsupported geometry type: "+l);let c=r.layout.length;return Uf(new Rs(l,l==="Polygon"?SM(r.flatCoordinates,r.ends,c):r.flatCoordinates,r.ends?.flat(),c,h.properties||{},h.id).enableSimplifyTransformed(),!1,t)}function Zf(h,t){if(!h)return null;if(Array.isArray(h)){let l=h.map(c=>Zf(c,t));return new l_(l)}let r=wM[h.type];return Uf(new r(h.flatCoordinates,h.layout||"XY",h.ends),!1,t)}var t0=class extends uw{constructor(){super()}getType(){return"json"}readFeature(t,r){return this.readFeatureFromObject(qf(t),this.getReadOptions(t,r))}readFeatures(t,r){return this.readFeaturesFromObject(qf(t),this.getReadOptions(t,r))}readFeatureFromObject(t,r){return St()}readFeaturesFromObject(t,r){return St()}readGeometry(t,r){return this.readGeometryFromObject(qf(t),this.getReadOptions(t,r))}readGeometryFromObject(t,r){return St()}readProjection(t){return this.readProjectionFromObject(qf(t))}readProjectionFromObject(t){return St()}writeFeature(t,r){return JSON.stringify(this.writeFeatureObject(t,r))}writeFeatureObject(t,r){return St()}writeFeatures(t,r){return JSON.stringify(this.writeFeaturesObject(t,r))}writeFeaturesObject(t,r){return St()}writeGeometry(t,r){return JSON.stringify(this.writeGeometryObject(t,r))}writeGeometryObject(t,r){return St()}};function qf(h){if(typeof h=="string"){let t=JSON.parse(h);return t||null}return h!==null?h:null}var dw=t0;var i0=class extends dw{constructor(t){t=t||{},super(),this.dataProjection=Ri(t.dataProjection?t.dataProjection:"EPSG:4326"),t.featureProjection&&(this.defaultFeatureProjection=Ri(t.featureProjection)),t.featureClass&&(this.featureClass=t.featureClass),this.geometryName_=t.geometryName,this.extractGeometryName_=t.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(t,r){let l=null;t.type==="Feature"?l=t:l={type:"Feature",geometry:t,properties:null};let c=n0(l.geometry,r);if(this.featureClass===Rs)return e0({geometry:c,id:l.id,properties:l.properties},r);let n=new is;return this.geometryName_?n.setGeometryName(this.geometryName_):this.extractGeometryName_&&l.geometry_name&&n.setGeometryName(l.geometry_name),n.setGeometry(Zf(c,r)),"id"in l&&n.setId(l.id),l.properties&&n.setProperties(l.properties,!0),n}readFeaturesFromObject(t,r){let l=t,c=null;if(l.type==="FeatureCollection"){let n=t;c=[];let x=n.features;for(let b=0,S=x.length;b<S;++b){let R=this.readFeatureFromObject(x[b],r);R&&c.push(R)}}else c=[this.readFeatureFromObject(t,r)];return c.flat()}readGeometryFromObject(t,r){return TM(t,r)}readProjectionFromObject(t){let r=t.crs,l;if(r)if(r.type=="name")l=Ri(r.properties.name);else if(r.type==="EPSG")l=Ri("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else l=this.dataProjection;return l}writeFeatureObject(t,r){r=this.adaptOptions(r);let l={type:"Feature",geometry:null,properties:null},c=t.getId();if(c!==void 0&&(l.id=c),!t.hasProperties())return l;let n=t.getProperties(),x=t.getGeometry();return x&&(l.geometry=r0(x,r),delete n[t.getGeometryName()]),On(n)||(l.properties=n),l}writeFeaturesObject(t,r){r=this.adaptOptions(r);let l=[];for(let c=0,n=t.length;c<n;++c)l.push(this.writeFeatureObject(t[c],r));return{type:"FeatureCollection",features:l}}writeGeometryObject(t,r){return r0(t,this.adaptOptions(r))}};function n0(h,t){if(!h)return null;let r;switch(h.type){case"Point":{r=MM(h);break}case"LineString":{r=IM(h);break}case"Polygon":{r=AM(h);break}case"MultiPoint":{r=PM(h);break}case"MultiLineString":{r=EM(h);break}case"MultiPolygon":{r=RM(h);break}case"GeometryCollection":{r=CM(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function TM(h,t){let r=n0(h,t);return Zf(r,t)}function CM(h,t){return h.geometries.map(function(l){return n0(l,t)})}function MM(h){let t=h.coordinates;return{type:"Point",flatCoordinates:t,layout:la(t.length)}}function IM(h){let t=h.coordinates,r=t.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:la(t[0]?.length||2)}}function EM(h){let t=h.coordinates,r=t[0]?.[0]?.length||2,l=[],c=ca(l,0,t,r);return{type:"MultiLineString",flatCoordinates:l,ends:c,layout:la(r)}}function PM(h){let t=h.coordinates;return{type:"MultiPoint",flatCoordinates:t.flat(),layout:la(t[0]?.length||2)}}function RM(h){let t=h.coordinates,r=[],l=t[0]?.[0]?.[0].length||2,c=df(r,0,t,l);return{type:"MultiPolygon",flatCoordinates:r,ends:c,layout:la(l)}}function AM(h){let t=h.coordinates,r=[],l=t[0]?.[0]?.length,c=ca(r,0,t,l);return{type:"Polygon",flatCoordinates:r,ends:c,layout:la(l)}}function r0(h,t){h=Uf(h,!0,t);let r=h.getType(),l;switch(r){case"Point":{l=OM(h,t);break}case"LineString":{l=kM(h,t);break}case"Polygon":{l=BM(h,t);break}case"MultiPoint":{l=FM(h,t);break}case"MultiLineString":{l=DM(h,t);break}case"MultiPolygon":{l=zM(h,t);break}case"GeometryCollection":{l=LM(h,t);break}case"Circle":{l={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return l}function LM(h,t){return t=Object.assign({},t),delete t.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(l){return r0(l,t)})}}function kM(h,t){return{type:"LineString",coordinates:h.getCoordinates()}}function DM(h,t){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function FM(h,t){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function zM(h,t){let r;return t&&(r=t.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function OM(h,t){return{type:"Point",coordinates:h.getCoordinates()}}function BM(h,t){let r;return t&&(r=t.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var vr=i0;var pw=0,md=1,fw=[0,0,0,0],Kc=[],s0={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},gd=class extends Ei{constructor(t,r,l){super(t),this.features=r,this.mapBrowserEvent=l}},o0=class extends hw{constructor(t){super(t),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=t.condition?t.condition:cw,this.defaultDeleteCondition_=function(l){return sw(l)&&lw(l)},this.deleteCondition_=t.deleteCondition?t.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=t.insertVertexCondition?t.insertVertexCondition:ow,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new rd,this.pixelTolerance_=t.pixelTolerance!==void 0?t.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new Yc({source:new bl({useSpatialIndex:!1,wrapX:!!t.wrapX}),style:t.style?t.style:NM(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(t.features?r=t.features:t.source&&(this.source_=t.source,r=new Xu(this.source_.getFeatures()),this.source_.addEventListener(qr.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(qr.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");t.hitDetection&&(this.hitDetection_=t.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Es.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Es.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=t.snapToPointer===void 0?!this.hitDetection_:t.snapToPointer}addFeature_(t){let r=t.getGeometry();if(r){let c=this.SEGMENT_WRITERS_[r.getType()];c&&c(t,r)}let l=this.getMap();l&&l.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(l.getCoordinateFromPixel(this.lastPixel_)),t.addEventListener(yi.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(t,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Xu;let l=this.featuresBeingModified_.getArray();for(let c=0,n=r.length;c<n;++c){let x=r[c].feature;x&&!l.includes(x)&&this.featuresBeingModified_.push(x)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new gd(s0.MODIFYSTART,this.featuresBeingModified_,t))}}removeFeature_(t){this.removeFeatureSegmentData_(t),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.removeEventListener(yi.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(t){let r=this.rBush_,l=[];r.forEach(function(c){t===c.feature&&l.push(c)});for(let c=l.length-1;c>=0;--c){let n=l[c];for(let x=this.dragSegments_.length-1;x>=0;--x)this.dragSegments_[x][0]===n&&this.dragSegments_.splice(x,1);r.remove(n)}}setActive(t){this.vertexFeature_&&!t&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(t)}setMap(t){this.overlay_.setMap(t),super.setMap(t)}getOverlay(){return this.overlay_}handleSourceAdd_(t){t.feature&&this.features_.push(t.feature)}handleSourceRemove_(t){t.feature&&this.features_.remove(t.feature)}handleFeatureAdd_(t){this.addFeature_(t.element)}handleFeatureChange_(t){if(!this.changingFeature_){let r=t.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(t){this.removeFeature_(t.element)}writePointGeometry_(t,r){let l=r.getCoordinates(),c={feature:t,geometry:r,segment:[l,l]};this.rBush_.insert(r.getExtent(),c)}writeMultiPointGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c],b={feature:t,geometry:r,depth:[c],index:c,segment:[x,x]};this.rBush_.insert(r.getExtent(),b)}}writeLineStringGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length-1;c<n;++c){let x=l.slice(c,c+2),b={feature:t,geometry:r,index:c,segment:x};this.rBush_.insert(Yn(x),b)}}writeMultiLineStringGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c];for(let b=0,S=x.length-1;b<S;++b){let R=x.slice(b,b+2),E={feature:t,geometry:r,depth:[c],index:b,segment:R};this.rBush_.insert(Yn(R),E)}}}writePolygonGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c];for(let b=0,S=x.length-1;b<S;++b){let R=x.slice(b,b+2),E={feature:t,geometry:r,depth:[c],index:b,segment:R};this.rBush_.insert(Yn(R),E)}}}writeMultiPolygonGeometry_(t,r){let l=r.getCoordinates();for(let c=0,n=l.length;c<n;++c){let x=l[c];for(let b=0,S=x.length;b<S;++b){let R=x[b];for(let E=0,A=R.length-1;E<A;++E){let z=R.slice(E,E+2),W={feature:t,geometry:r,depth:[b,c],index:E,segment:z};this.rBush_.insert(Yn(z),W)}}}}writeCircleGeometry_(t,r){let l=r.getCenter(),c={feature:t,geometry:r,index:pw,segment:[l,l]},n={feature:t,geometry:r,index:md,segment:[l,l]},x=[c,n];c.featureSegments=x,n.featureSegments=x,this.rBush_.insert(sa(l),c);let b=r,S=Bn();if(S&&this.getMap()){let R=this.getMap().getView().getProjection();b=b.clone().transform(S,R),b=b_(b).transform(R,S)}this.rBush_.insert(b.getExtent(),n)}writeGeometryCollectionGeometry_(t,r){let l=r.getGeometriesArray();for(let c=0;c<l.length;++c){let n=l[c],x=this.SEGMENT_WRITERS_[n.getType()];x(t,n)}}createOrUpdateVertexFeature_(t,r,l,c){let n=this.vertexFeature_;return n?n.getGeometry().setCoordinates(t):(n=new is(new yr(t)),this.vertexFeature_=n,this.overlay_.getSource().addFeature(n)),n.set("features",r),n.set("geometries",l),n.set("existing",c),n}handleEvent(t){if(!t.originalEvent)return!0;this.lastPointerEvent_=t;let r;return!t.map.getView().getInteracting()&&t.type==Gn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(t),this.vertexFeature_&&this.deleteCondition_(t)&&(t.type!=Gn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),t.type==Gn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(t)&&!r}findInsertVerticesAndUpdateDragSegments_(t){this.handlePointerAtPixel_(t),this.dragSegments_.length=0,this.featuresBeingModified_=null;let r=this.vertexFeature_;if(!r)return;let l=this.getMap().getView().getProjection(),c=[],n=r.getGeometry().getCoordinates(),x=Yn([n]),b=this.rBush_.getInExtent(x),S={};b.sort(jM);for(let R=0,E=b.length;R<E;++R){let A=b[R],z=A.segment,W=Vt(A.geometry),ne=A.depth;if(ne&&(W+="-"+ne.join("-")),S[W]||(S[W]=new Array(2)),A.geometry.getType()==="Circle"&&A.index===md){let ge=gw(t,A,l);or(ge,n)&&!S[W][0]&&(this.dragSegments_.push([A,0]),S[W][0]=A);continue}if(or(z[0],n)&&!S[W][0]){this.dragSegments_.push([A,0]),S[W][0]=A;continue}if(or(z[1],n)&&!S[W][1]){if(S[W][0]&&S[W][0].index===0){let ge=A.geometry.getCoordinates();switch(A.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":ge=ge[ne[1]];case"Polygon":if(A.index!==ge[ne[0]].length-2)continue;break;default:}}this.dragSegments_.push([A,1]),S[W][1]=A;continue}Vt(z)in this.vertexSegments_&&!S[W][0]&&!S[W][1]&&c.push(A)}return c}handleDragEvent(t){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(t,this.dragSegments_.map(([n])=>n));let r=[t.coordinate[0]+this.delta_[0],t.coordinate[1]+this.delta_[1]],l=[],c=[];for(let n=0,x=this.dragSegments_.length;n<x;++n){let b=this.dragSegments_[n],S=b[0],R=S.feature;l.includes(R)||l.push(R);let E=S.geometry;c.includes(E)||c.push(E);let A=S.depth,z,W=S.segment,ne=b[1];for(;r.length<E.getStride();)r.push(W[ne][r.length]);switch(E.getType()){case"Point":z=r,W[0]=r,W[1]=r;break;case"MultiPoint":z=E.getCoordinates(),z[S.index]=r,W[0]=r,W[1]=r;break;case"LineString":z=E.getCoordinates(),z[S.index+ne]=r,W[ne]=r;break;case"MultiLineString":z=E.getCoordinates(),z[A[0]][S.index+ne]=r,W[ne]=r;break;case"Polygon":z=E.getCoordinates(),z[A[0]][S.index+ne]=r,W[ne]=r;break;case"MultiPolygon":z=E.getCoordinates(),z[A[1]][A[0]][S.index+ne]=r,W[ne]=r;break;case"Circle":let ge=E;if(W[0]=r,W[1]=r,S.index===pw)this.changingFeature_=!0,ge.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let me=t.map.getView().getProjection(),ve=qg(zi(ge.getCenter(),me),zi(r,me)),Te=Bn();if(Te){let Oe=ge.clone().transform(Te,me);Oe.setRadius(ve),ve=Oe.transform(me,Te).getRadius()}ge.setRadius(ve),this.changingFeature_=!1}break;default:}z&&this.setGeometryCoordinates_(E,z)}this.createOrUpdateVertexFeature_(r,l,c,!0)}handleDownEvent(t){if(!this.condition_(t))return!1;let r=t.coordinate,l=this.findInsertVerticesAndUpdateDragSegments_(r);if(l?.length&&this.insertVertexCondition_(t)&&(this.willModifyFeatures_(t,l),this.vertexFeature_)){let c=this.vertexFeature_.getGeometry().getCoordinates();for(let n=l.length-1;n>=0;--n)this.insertVertex_(l[n],c);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(t){for(let r=this.dragSegments_.length-1;r>=0;--r){let l=this.dragSegments_[r][0],c=l.geometry;if(c.getType()==="Circle"){let n=c,x=n.getCenter(),b=l.featureSegments[0],S=l.featureSegments[1];b.segment[0]=x,b.segment[1]=x,S.segment[0]=x,S.segment[1]=x,this.rBush_.update(sa(x),b);let R=n,E=Bn();if(E){let A=t.map.getView().getProjection();R=R.clone().transform(E,A),R=b_(R).transform(A,E)}this.rBush_.update(R.getExtent(),S)}else this.rBush_.update(Yn(l.segment),l)}return this.featuresBeingModified_&&(this.dispatchEvent(new gd(s0.MODIFYEND,this.featuresBeingModified_,t)),this.featuresBeingModified_=null),!1}handlePointerMove_(t){this.lastPixel_=t.pixel,this.handlePointerAtPixel_(t.coordinate)}handlePointerAtPixel_(t){let r=this.getMap(),l=r.getPixelFromCoordinate(t),c=r.getView().getProjection(),n=function(S,R){return mw(t,S,c)-mw(t,R,c)},x,b;if(this.hitDetection_){let S=typeof this.hitDetection_=="object"?R=>R===this.hitDetection_:void 0;r.forEachFeatureAtPixel(l,(R,E,A)=>{A&&A.getType()==="Point"&&(A=new yr(aa(A.getCoordinates(),c)));let z=A||R.getGeometry();if(z&&z.getType()==="Point"&&R instanceof is&&this.features_.getArray().includes(R)){b=z;let W=R.getGeometry().getFlatCoordinates().slice(0,2);x=[{feature:R,geometry:b,segment:[W,W]}]}return!0},{layerFilter:S})}if(!x){let S=Zs(sa(t,fw),c),R=r.getView().getResolution()*this.pixelTolerance_,E=Us(Kn(S,R,fw),c);x=this.rBush_.getInExtent(E)}if(x&&x.length>0){let S=x.sort(n)[0],R=S.segment,E=gw(t,S,c),A=r.getPixelFromCoordinate(E),z=qg(l,A);if(b||z<=this.pixelTolerance_){let W={};if(W[Vt(R)]=!0,this.snapToPointer_||(this.delta_[0]=E[0]-t[0],this.delta_[1]=E[1]-t[1]),S.geometry.getType()==="Circle"&&S.index===md)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(E,[S.feature],[S.geometry],this.snappedToVertex_);else{let ne=r.getPixelFromCoordinate(R[0]),ge=r.getPixelFromCoordinate(R[1]),me=Ec(A,ne),ve=Ec(A,ge);if(z=Math.sqrt(Math.min(me,ve)),this.snappedToVertex_=z<=this.pixelTolerance_,!this.snappedToVertex_&&!this.insertVertexCondition_(this.lastPointerEvent_)){this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null);return}this.snappedToVertex_&&(E=me>ve?R[1]:R[0]),this.createOrUpdateVertexFeature_(E,[S.feature],[S.geometry],this.snappedToVertex_);let Te={};Te[Vt(S.geometry)]=!0;for(let Oe=1,Pe=x.length;Oe<Pe;++Oe){let ze=x[Oe].segment;if(or(R[0],ze[0])&&or(R[1],ze[1])||or(R[0],ze[1])&&or(R[1],ze[0])){let Me=Vt(x[Oe].geometry);Me in Te||(Te[Me]=!0,W[Vt(ze)]=!0)}else break}}this.vertexSegments_=W;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(t,r){let l=t.segment,c=t.feature,n=t.geometry,x=t.depth,b=t.index,S;for(;r.length<n.getStride();)r.push(0);switch(n.getType()){case"MultiLineString":S=n.getCoordinates(),S[x[0]].splice(b+1,0,r);break;case"Polygon":S=n.getCoordinates(),S[x[0]].splice(b+1,0,r);break;case"MultiPolygon":S=n.getCoordinates(),S[x[1]][x[0]].splice(b+1,0,r);break;case"LineString":S=n.getCoordinates(),S.splice(b+1,0,r);break;default:return!1}this.setGeometryCoordinates_(n,S);let R=this.rBush_;R.remove(t),this.updateSegmentIndices_(n,b,x,1);let E={segment:[l[0],r],feature:c,geometry:n,depth:x,index:b};R.insert(Yn(E.segment),E),this.dragSegments_.push([E,1]);let A={segment:[r,l[1]],feature:c,geometry:n,depth:x,index:b+1};return R.insert(Yn(A.segment),A),this.dragSegments_.push([A,0]),!0}updatePointer_(t){return t&&this.findInsertVerticesAndUpdateDragSegments_(t),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){let t=this.vertexFeature_?.getGeometry().getCoordinates();return t?aa(t,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(l=>l.getType()==="Circle"||l.getType().endsWith("Point")))return!1;let t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Yn([t])).some(({segment:l})=>or(l[0],t)||or(l[1],t))}removePoint(t){if(t&&(t=zi(t,this.getMap().getView().getProjection()),this.updatePointer_(t)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Gn.POINTERDRAG){let r=this.lastPointerEvent_;this.willModifyFeatures_(r,this.dragSegments_.map(([c])=>c));let l=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new gd(s0.MODIFYEND,this.featuresBeingModified_,r)),this.featuresBeingModified_=null,l}return!1}removeVertex_(){let t=this.dragSegments_,r={},l=!1,c,n,x,b,S,R,E,A,z,W,ne;for(S=t.length-1;S>=0;--S)x=t[S],W=x[0],ne=Vt(W.feature),W.depth&&(ne+="-"+W.depth.join("-")),ne in r||(r[ne]={}),x[1]===0?(r[ne].right=W,r[ne].index=W.index):x[1]==1&&(r[ne].left=W,r[ne].index=W.index+1);for(ne in r){switch(z=r[ne].right,E=r[ne].left,R=r[ne].index,A=R-1,E!==void 0?W=E:W=z,A<0&&(A=0),b=W.geometry,n=b.getCoordinates(),c=n,l=!1,b.getType()){case"MultiLineString":n[W.depth[0]].length>2&&(n[W.depth[0]].splice(R,1),l=!0);break;case"LineString":n.length>2&&(n.splice(R,1),l=!0);break;case"MultiPolygon":c=c[W.depth[1]];case"Polygon":c=c[W.depth[0]],c.length>4&&(R==c.length-1&&(R=0),c.splice(R,1),l=!0,R===0&&(c.pop(),c.push(c[0]),A=c.length-1));break;default:}if(l){this.setGeometryCoordinates_(b,n);let ge=[];if(E!==void 0&&(this.rBush_.remove(E),ge.push(E.segment[0])),z!==void 0&&(this.rBush_.remove(z),ge.push(z.segment[1])),E!==void 0&&z!==void 0){let me={depth:W.depth,feature:W.feature,geometry:W.geometry,index:A,segment:ge};this.rBush_.insert(Yn(me.segment),me)}this.updateSegmentIndices_(b,R,W.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),t.length=0}}return l}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(l=>l.getType()==="Circle"||l.getType().endsWith("Point")))return!1;let t=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(Yn([t])).some(({segment:l})=>!(or(l[0],t)||or(l[1],t)))}insertPoint(t){let r=t?zi(t,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return r?this.findInsertVerticesAndUpdateDragSegments_(r).reduce((c,n)=>c||this.insertVertex_(n,r),!1):!1}setGeometryCoordinates_(t,r){this.changingFeature_=!0,t.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(t,r,l,c){this.rBush_.forEachInExtent(t.getExtent(),function(n){n.geometry===t&&(l===void 0||n.depth===void 0||yn(n.depth,l))&&n.index>r&&(n.index+=c)})}};function jM(h,t){return h.index-t.index}function mw(h,t,r){let l=t.geometry;if(l.getType()==="Circle"){let n=l;if(t.index===md){let x=Bn();x&&(n=n.clone().transform(x,r));let b=Ec(n.getCenter(),zi(h,r)),S=Math.sqrt(b)-n.getRadius();return S*S}}let c=zi(h,r);return Kc[0]=zi(t.segment[0],r),Kc[1]=zi(t.segment[1],r),Yv(c,Kc)}function gw(h,t,r){let l=t.geometry;if(l.getType()==="Circle"&&t.index===md){let n=l,x=Bn();return x&&(n=n.clone().transform(x,r)),aa(n.getClosestPoint(zi(h,r)),r)}let c=zi(h,r);return Kc[0]=zi(t.segment[0],r),Kc[1]=zi(t.segment[1],r),aa(Zg(c,Kc),r)}function NM(){let h=M1();return function(t,r){return h.Point}}var a0=o0;var GM=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,_w=/^([\d.]+),([\d.]+)$/,yw=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,Wf="stop-fetch",xw=h=>{let t=[];return h.forEach(r=>{let l=r.getGeometry()?.getCoordinates();l?.length&&t.push(...l)}),t},l0=class h extends jc{constructor(r={}){super(r);this.abortControllers={};this.cacheStationData={};this.format=new vr({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.apiParams=r.apiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new wu({...r}),this.routingLayer=r.routingLayer||new Yc({source:new bl,style:r.style}),this.onRouteError=r.onRouteError||(l=>{this.dispatchEvent(new Ei("change:route")),this.reset(),console.error(l)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",l=>{l.key==="active"&&this.onActiveChange(),l.key==="mot"&&this.viaPoints&&this.drawRoute()})}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}static getGraphsResolutions(r,l){let c=l.getView();return r.map(([,n,x])=>[c.getResolutionForZoom(n),c.getResolutionForZoom(x||n+1)])}abortRequests(){this.graphs.forEach(r=>{let l=r[0];this.abortControllers[l]&&this.abortControllers[l].abort(),this.abortControllers[l]=new AbortController}),this.abortControllers[Wf]?.abort(),this.abortControllers[Wf]=new AbortController,this.loading=!1}activate(){let r=this.getMap();r&&(this.format=new vr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(r,l=-1,c=0){this.viaPoints.splice(l===-1?this.viaPoints.length:l,c,r),this.drawRoute(),this.dispatchEvent(new Ei("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new a0({deleteCondition:r=>{let c=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})||[]).find(n=>n.getGeometry()?.getType()==="Point"&&n.get("index"));return aw(r)&&c?(this.removeViaPoint(c.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[Wf]);let r=this.viaPoints.map(l=>{if(Array.isArray(l)){let c=this.getMap()?.getView().getProjection(),[n,x]=pl(l,c);return this.snapToClosestStation?[`@${x}`,n]:[x,n]}return this.useRawViaPoints?l:`!${l}`});return this.loading=!0,this.viaPoints.forEach((l,c)=>{this.drawViaPoint(l,c,this.abortControllers[Wf])}),Promise.all(this.graphs.map(([l],c)=>{let{signal:n}=this.abortControllers[l];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:l,mot:this.mot,"resolve-hops":!1,via:`${r.join("|")}`,...this.apiParams||{}},{signal:n}).then(x=>{if(this.segments=this.format.readFeatures(x),this.mot==="foot"){let R=this.segments.reduce((E,A)=>{let z=A.get("trg");return E.find(W=>W[0]===z[0]&&W[1]===z[1])?E:[...E,z]},[]);this.segments=R.map(E=>{let A=this.segments.filter(W=>{let ne=W.get("trg");return ne[0]===E[0]&&ne[1]===E[1]}),z=xw(A);return new is({geometry:new Cs(z)})})}let b=xw(this.segments),S=new is({geometry:new Cs(b)});S.set("graph",l),S.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[c]?.length>=2&&(S.set("minResolution",this.graphsResolutions[c][0]),S.set("maxResolution",this.graphsResolutions[c][1])),this.routingLayer?.getSource()?.addFeature(S),this.loading=!1}).catch(x=>{/AbortError/.test(x.name)||(this.segments=[],this.dispatchEvent(new Ei("error")),this.onRouteError(x,this),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,l,c){let n=new is;if(n.set("viaPointIdx",l),Array.isArray(r))return n.setGeometry(new yr(r)),this.routingLayer?.getSource()?.addFeature(n),Promise.resolve(n);if(!this.useRawViaPoints||yw.test(r)){let E,A;return this.useRawViaPoints?[,E,,A]=yw.exec(r)||[]:[E,A]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${E}?key=${this.stopsApiKey}`,{signal:c.signal}).then(z=>z.json()).then(z=>{let{coordinates:W}=z?.features?.[0]?.geometry||{};return W||console.log("No coordinates found for station "+E,z),this.cacheStationData[r]=_r(W),n.set("viaPointTrack",A),n.setGeometry(new yr(_r(W))),this.routingLayer?.getSource()?.addFeature(n),n}).catch(z=>{/AbortError/.test(z.message)||(this.dispatchEvent(new Ei("error")),this.onRouteError(z,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)})}if(this.useRawViaPoints&&_w.test(r)){let[E,A]=_w.exec(r)||[];if(A&&E){let z=parseFloat(A),W=parseFloat(E),ne=_r([z,W],this.getMap()?.getView().getProjection());return n.setGeometry(new yr(ne)),this.routingLayer?.getSource()?.addFeature(n),Promise.resolve(n)}}let[,x,,b,S,,R]=GM.exec(r)||[];if(S&&b){let E=_r([parseFloat(S),parseFloat(b)],this.getMap()?.getView().getProjection());return n.set("viaPointTrack",R),n.setGeometry(new yr(E)),this.routingLayer?.getSource()?.addFeature(n),Promise.resolve(n)}return x?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${x}&limit=1`,{signal:c.signal}).then(E=>E.json()).then(E=>{let{coordinates:A}=E.features[0].geometry;return this.cacheStationData[r]=_r(A),n.set("viaPointTrack",R),n.setGeometry(new yr(_r(A))),this.routingLayer?.getSource()?.addFeature(n),n}).catch(E=>(this.dispatchEvent(new Ei("error")),this.onRouteError(E,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(r){let c=r.target.getFeaturesAtPixel(r.pixel,{hitTolerance:5,layerFilter:n=>n===this.routingLayer}).find(n=>n.getGeometry()?.getType()==="Point"&&n.get("viaPointIdx")!==void 0);if(c){this.removeViaPoint(c.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyEnd(r){let l=r.mapBrowserEvent.coordinate,{oldRoute:c,segmentIndex:n,viaPoint:x}=this.initialRouteDrag||{};return x?this.addViaPoint(l,x.get("viaPointIdx"),1):c?n===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(l,(n||0)+1):this.addViaPoint(l,0,1)}onModifyStart(r){let l=-1,c=r.features.getArray().find(x=>x.getGeometry()?.getType()==="LineString");if(c?.getGeometry()&&r.mapBrowserEvent.coordinate){let x=Kn(new yr(c.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);l=this.segments.findIndex(b=>b.getGeometry()?.intersectsExtent(x))}let n=(r.features.getArray().filter(x=>x.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={oldRoute:c?.clone(),segmentIndex:l,viaPoint:n}}removeListeners(){this.onMapClickKey&&ws(this.onMapClickKey)}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new Ei("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Ei("change:route"))}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new Ei("change:route"))}},vw=l0;var c0=class{constructor(t){let{apiKey:r,apiParams:l,placeholder:c,url:n}=t||{};this.apiParams={limit:20,...l||{}},this.placeholder=c||"Search for a stop...";let x={apiKey:r};n&&(x.url=n),this.api=new Su(x),this.abortController=new AbortController,this.createElement(t),this.options=t}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:t}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),t.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",cursor:"pointer",overflowY:"auto"}),t.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),t.appendChild(this.clearElt)}render(t){let r=t?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(l=>{let c=document.createElement("div");c.innerHTML=l?.properties?.name,c.onclick=n=>{this.options?.onSuggestionClick?.(l,n)},Object.assign(c.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(c)}))}search(t,r){return(t!==void 0||t!==null)&&(this.apiParams.q=t),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(l=>{this.render(l)}).catch(()=>{this.render()})}},bw=c0;var VM=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},ww=VM;var h0=class extends jc{constructor(t){let r=ww();r.className=t?.className||"mbt-stop-finder";let l={element:r,...t||{}};super(l),this.controller=new bw({onSuggestionClick:this.onSuggestionClick.bind(this),...l})}onSuggestionClick(t){let r=_r(t.geometry.coordinates);this.getMap()?.getView().setCenter(r)}search(t,r){return this.controller.search(t,r)}},Sw=h0;var Ew=Vs(Tl());var Iw=Vs(Tl()),ji=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(ji=(0,Iw.default)(h=>{console.warn(h)},1e3));var oI=(h,t)=>{(t||[]).forEach(r=>{r.set("parent",void 0)}),(h.get("children")||[]).forEach(r=>{r.set("parent",void 0)})},aI=(h,t)=>{t.properties&&(ji("Deprecated. Don't use properties options. Pass the values directly in options object."),h.setProperties(t.properties)),h.on("propertychange",r=>{if(r.key==="children"&&oI(r.target,r.oldValue),r.key==="map"){let l=r.target.get(r.key);l?(r.target.get("children")||[]).forEach(c=>{l.addLayer(c)}):r.oldValue&&(r.target.get("children")||[]).forEach(c=>{r.oldValue.removeLayer(c)})}}),h.set("options",t),h.set("children",t.children||[]),Object.defineProperties(h,{children:{get:()=>(ji("Layer.children is deprecated. Use the Layer.get('children') method instead."),h.get("children")||[]),set:r=>{ji("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),h.set("children",r||[])}},copyrights:{get:()=>(ji("Layer.copyrights is deprecated. Get the attributions from the source object"),h.get("copyrights")),set:r=>{ji("Layer.copyrights is deprecated. Set the attributions to the source object.");let l=r&&!Array.isArray(r)?[r]:r;h.set("copyrights",l||[])}},disabled:{get(){return ji("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),h.get("disabled")},set(r){ji("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),h.set("disabled",r)}},group:{get(){return ji("Layer.group is deprecated. Use the Layer.get('group') method instead."),h.get("group")}},hitTolerance:{get(){return ji("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.get("hitTolerance")||5},set(r){ji("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.set("hitTolerance",r)}},key:{get(){return ji('Layer.key is deprecated. Use the Layer.get("key") method instead.'),h.get("key")||h.get("name")}},map:{get(){return ji('Layer.map is deprecated. Use the Layer.get("map") method instead.'),h.getMapInternal()}},name:{get(){return ji("Layer.name is deprecated. Use the Layer.get('name') method instead."),h.get("name")}},olLayer:{get(){return ji("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object."),h},set(){ji("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect.")}},options:{get(){return ji('Layer.options is deprecated. Use the Layer.get("options") method instead.'),h.get("options")},set(r){return ji('Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.'),h.set("options",r)}},parent:{get(){return ji("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),h.get("parent")},set(r){ji("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),h.set("parent",r)}},visible:{get(){return ji("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),h.getVisible()},set(r){ji("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),h.setVisible(r)}}})},wa=aI;var Pw=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Pw=(0,Ew.default)(h=>{console.warn(h)},1e3));var p0=class extends xa{prepareFrame(){return!0}renderFrame(){return null}},f0=class h extends Is{constructor(t){super(t),wa(this,t),Pw("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(t){return new h({...this.get("options")||{},...t||{}})}createRenderer(){return new p0(this)}},$f=f0;var Aw=Vs(_0(),1);var lI="vectorTileFeature",y0={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},Sa=class extends xa{translateZoom;constructor(t,r){super(t),this.translateZoom=r}getFeaturesAtCoordinate(t,r=5){let l=this.getMapLibrePixels(t,r);if(!l)return[];let c=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(l,c).map(x=>this.toOlFeature(x))||[]}prepareFrame(){return!0}renderFrame(t){let r=this.getLayer(),{mapLibreMap:l}=r,c=r.getMapInternal();if(!r||!c||!l)return null;let n=l.getCanvas(),{viewState:x}=t;l.jumpTo({center:pl(x.center,x.projection),zoom:(this.translateZoom?this.translateZoom(x.zoom):x.zoom)-1,bearing:Eu(-x.rotation)});let b=r.getOpacity().toString();return n&&b!==n.style.opacity&&(n.style.opacity=b),n.isConnected?cI(n,t)||l.resize():c.render(),l.redraw(),l.getContainer()}getFeatures(t){let r=this.getLayer().getMapInternal()?.getCoordinateFromPixel(t);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(t,r,l,c){let n=this.getFeaturesAtCoordinate(t,l);return n.forEach(x=>{let b=x.getGeometry();b instanceof Rr&&c(x,this.getLayer(),b)}),n?.[0]}getMapLibrePixels(t,r){if(!t)return;let l=this.getLayer().mapLibreMap?.project(pl(t));if(l?.x===void 0||l?.y===void 0)return;let c=[l.x,l.y];if(r){let[n,x]=c;c=[[n-r,x-r],[n+r,x+r]]}return c}toOlFeature(t){let c=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";y0[c]||(y0[c]=new vr({featureProjection:c}));let n=y0[c].readFeature(t);return n&&n.set(lI,t,!0),n}};function cI(h,t){return h.width===Math.floor(t.size[0]*t.pixelRatio)&&h.height===Math.floor(t.size[1]*t.pixelRatio)}var hI=h=>{if(!h)return[];let{style:t}=h;if(!t)return[];let{sourceCaches:r}=t,l=[];return Object.values(r).forEach(c=>{if(c.used){let{attribution:n}=c.getSource();n&&(l=l.concat(n.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),uI(l)},uI=h=>{let t=h.filter(c=>c!=null&&c.trim&&c.trim()),r=t.map(c=>c.toLowerCase());return[...new Set(r)].map(c=>t.find(n=>n.toLowerCase()===c))},x0=hI;var Jc=class extends Is{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(t){super({source:new Eo({attributions:()=>x0(this.mapLibreMap)}),...t})}disposeInternal(){ws(this.olListenersKeys),this.loaded=!1,this.mapLibreMap&&(this.mapLibreMap.triggerRepaint=()=>{},this.mapLibreMap.remove()),super.disposeInternal()}setMapInternal(t){super.setMapInternal(t),t?this.loadMapLibreMap():this.dispose()}loadMapLibreMap(){this.loaded=!1;let t=this.getMapInternal();if(t&&this.olListenersKeys.push(t.on("change:target",this.loadMapLibreMap.bind(this))),!t?.getTargetElement())return;if(!this.getVisible()){this.olListenersKeys.push(this.once("change:visible",this.loadMapLibreMap.bind(this)));return}let r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";let l=this.get("mapLibreOptions");this.mapLibreMap=new Aw.Map(Object.assign({},l,{container:r,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Ei("load"))})}createRenderer(){let t=this.get("translateZoom");return new Sa(this,t)}};var w0=Vs(Tl());var _d=class extends Sa{constructor(r,l){super(r,l);this.ignoreNextRender=!1;this.setIsReady=this.setIsReady.bind(this),this.ignoreNextRender=!1}renderFrame(r){let l=this.getLayer(),{mapLibreMap:c}=l,n=l.getMapInternal();if(!l||!n||!c)return null;if(this.ready&&this.ignoreNextRender)return this.ignoreNextRender=!1,c?.getContainer();this.ready=!1,this.ignoreNextRender=!1,this.updateReadyState();let x=super.renderFrame(r);return c?.once("idle",this.setIsReady),x}setIsReady(){console.log("ici"),this.ready||(this.ready=!0,this.ignoreNextRender=!0,this.getLayer().changed())}updateReadyState(){this.getLayer()?.mapLibreMap?.off("idle",this.setIsReady),this.getLayer()?.mapLibreMap?.once("idle",this.setIsReady)}};var Lw=(h,t,r,l)=>sl(`${h}/styles/${t}/style.json`,{[l]:r}).toString(),v0=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(v0=(0,w0.default)(h=>{console.warn(h)},1e3));var b0=class h extends Jc{constructor(r){let l={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...r||{},mapLibreOptions:{...r.mapLibreOptions||{}}};!l.mapLibreOptions.style&&l.url?.includes("style.json")?l.mapLibreOptions.style=l.url:!l.mapLibreOptions.style&&l.apiKey&&l.style&&typeof l.style=="string"&&(l.mapLibreOptions.style=Lw(l.url,l.style,l.apiKey,l.apiKeyName));super(l);this.olEventsKeys=[];wa(this,r),this.set("options",r)}set apiKey(r){this.set("apiKey",r)}get apiKey(){return this.get("apiKey")}set apiKeyName(r){this.set("apiKeyName",r)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return v0("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return v0("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(r){this.set("style",r)}get url(){return this.get("url")}set url(r){this.set("url",r)}attachToMap(){let r=(0,w0.default)(this.updateMaplibreMap.bind(this),150);r(),this.olEventsKeys.push(this.on("propertychange",l=>{/(url|style|apiKey|apiKeyName)/.test(l.key)&&r()}))}clone(r){return new h({...this.get("options")||{},...r||{}})}createRenderer(){return new _d(this)}detachFromMap(){ws(this.olEventsKeys)}disposeInternal(){let r=this.getSource();super.disposeInternal(),this.setSource(r)}getStyle(){if(this.style&&typeof this.style=="object"&&this.style.name&&this.style.version)return this.style;if(this.url.includes("style.json"))return this.url;let r=this.get("options");return r?.mapLibreOptions?.style?r.mapLibreOptions.style:Lw(this.url,this.style,this.apiKey,this.apiKeyName)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(r){console.error("Error while updating MaplibreMap",r)}}},kw=b0;var Dw=Vs(Tl());var S0={"EPSG:3857":new vr({featureProjection:"EPSG:3857"})},yd=class extends xa{forEachFeatureAtCoordinate(t,r,l,c){let n=this.getFeaturesAtCoordinate(t,l);return n.forEach(x=>{c(x,this.layer_,x.getGeometry())}),n?.[0]}getFeatures(t){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(t);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(t,r=5){if(!t)return[];let l=this.getLayer(),c=l.getMapInternal(),n=l.maplibreLayer.mapLibreMap,x=c?.getView()?.getProjection()?.getCode()||"EPSG:3857",b=[];if(S0[x]||(S0[x]=new vr({featureProjection:x})),n?.isStyleLoaded()){let S=t&&n.project(pl(t));if(S?.x&&S?.y){let R=[S.x,S.y];if(r){let[A,z]=R;R=[[A-r,z-r],[A+r,z+r]]}let E=l.layers||[];l.layersFilter&&(E=n.getStyle().layers.filter(l.layersFilter)),l.queryRenderedLayersFilter&&(E=n.getStyle().layers.filter(l.queryRenderedLayersFilter)),b=n.queryRenderedFeatures(R,{layers:E.map(A=>A.id),validate:!1}).map(A=>{let z=S0[x].readFeature(A);return z&&z.set(Bc,A),z})}}return b}prepareFrame(){return!0}renderFrame(){return null}};var In=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(In=(0,Dw.default)((...h)=>{console.warn(...h)},1e3));var T0=class h extends Is{constructor(r={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){r.mapboxLayer&&(In("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),r.maplibreLayer=r.mapboxLayer,delete r.mapboxLayer),r.styleLayers&&(In("options.styleLayers is deprecated. Use options.layers instead."),r.layers=r.styleLayers,delete r.styleLayers),r.styleLayersFilter&&(In("options.styleLayersFilter is deprecated. Use options.layersFilter instead."),r.layersFilter=r.styleLayersFilter,delete r.styleLayersFilter);super({source:new Eo({}),...r});this.highlightedFeatures=[];this.olEventsKeys=[];this.selectedFeatures=[];wa(this,r),this.set("options",r),this.beforeId=r.beforeId,this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=l=>!!this.layers.find(c=>l.id===c.id))}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return In("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return In("Deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(r){In("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[r]}get styleLayers(){return In("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(r){In("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=r}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(l=>{let{id:c,source:n}=l;(!n||n&&r.getSource(n))&&c&&!r.getLayer(c)&&r.addLayer(l,this.beforeId)}),this.applyLayoutVisibility())}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.entries(this.sources).forEach(([l,c])=>{r.getSource(l)||r.addSource(l,c)})}applyLayoutVisibility(r){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:l}=this.maplibreLayer,c=l.getStyle(),n=this.getVisible()?"visible":"none",x=c.layers||[];for(let b=0;b<x.length;b+=1){let S=x[b];if(this.layersFilter(S)){let{id:R}=S;l.getLayer(R)&&(l.setLayoutProperty(R,"visibility",n),(this.getMinZoom()||this.getMaxZoom())&&l.setLayerZoomRange(R,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}attachToMap(r){if(!this.getMapInternal()||!this.maplibreLayer)return;let{mapLibreMap:c}=this.maplibreLayer;c&&(c.loaded()?this.onLoad():c.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",n=>{this.applyLayoutVisibility(n)}),this.on("propertychange",n=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(n.key)&&(this.detachFromMap(),this.attachToMap(r))}),this.maplibreLayer.on("propertychange",n=>{n.key==="style"&&n.target.maplibreMap.once("styledata",()=>{n.target.maplibreMap.once("idle",()=>{this.onLoad()})})}))}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new yd(this)}detachFromMap(){ws(this.olEventsKeys),this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources())}getFeatureInfoAtCoordinate(r){if(In("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{mapLibreMap:l}=this.maplibreLayer;if(!l.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let c=this.layers||[];return this.layersFilter&&(c=l.getStyle().layers.filter(this.layersFilter),console.log(c)),this.queryRenderedLayersFilter&&(c=l.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({coordinate:r,features:[],layer:this})}highlight(r=[]){In("Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.");let l=this.highlightedFeatures?.filter(c=>!(this.selectedFeatures||[]).map(n=>n.getId()).includes(c.getId()))||[];this.setHoverState(l,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:r}=this.maplibreLayer,l=r.getStyle();if(l?.layers&&this.layersFilter){let c=l.layers.filter(this.layersFilter);this.set("disabled",!c.length)}this.applyLayoutVisibility()}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(l=>{let{id:c}=l;c&&r.getLayer(c)&&r.removeLayer(c)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.keys(this.sources).forEach(l=>{r.getSource(l)&&r.removeSource(l)})}select(r=[]){In("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}setFeatureState(r,l){if(!this.maplibreLayer?.mapLibreMap||!r.length)return;let c=this.maplibreLayer.mapLibreMap;r.forEach(n=>{let{source:x,sourceLayer:b}=n.get(Bc)||{};if(!x&&!b||!n.getId()){n.getId()||In("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",n.getProperties());return}c.setFeatureState({id:n.getId(),source:x,sourceLayer:b},l)})}setHoverState(r,l){In(`Deprecated. Use layer.setFeatureState(features, {hover: ${l}}) instead.`),this.setFeatureState(r,{hover:l})}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap(r)):(this.detachFromMap(),super.setMapInternal(r))}},Fw=T0;var P0=Vs(Tl());var M0=Vs(Tl()),I0=Vs(Nw());var E0=class{constructor(t){this.isIdle=!1;this.getViewState=()=>({});this.shouldRender=()=>!0;this._mode=t.mode||nr.TOPOGRAPHIC,this._speed=t.speed||1,this._style=t.style||ol,this._time=t.time||new Date,this.api=t.api||new bu(t),this.bboxParameters=t.bboxParameters,this.canvas=t.canvas||document.createElement("canvas"),this.debug=t.debug||!1,this.filter=t.filter,this.hoverVehicleId=t.hoverVehicleId,this.live=t.live!==!1,this.minZoomInterpolation=t.minZoomInterpolation||8,this.pixelRatio=t.pixelRatio||(typeof window<"u"?window.devicePixelRatio:1),this.selectedVehicleId=t.selectedVehicleId,this.sort=t.sort,this.styleOptions={...Oc,...t.styleOptions||{}},this.tenant=t.tenant||"",this.trajectories={},this.useDebounce=t.useDebounce||!1,this.useRequestAnimationFrame=t.useRequestAnimationFrame||!1,this.useThrottle=t.useThrottle!==!1,this.getViewState=t.getViewState||(()=>({})),this.shouldRender=t.shouldRender||(()=>!0),this.onRender=t.onRender,this.onIdle=t.onIdle,this.onStart=t.onStart,this.onStop=t.onStop,this.format=new vr,this.motsByZoom=t.motsByZoom||[Ms,Ms,Ms,Ms,Ms,Ms,Ms,Ms,Ms,vf,vf],this.getMotsByZoom=r=>t.getMotsByZoom?t.getMotsByZoom(r,this.motsByZoom):this.motsByZoom[r],this.generalizationLevelByZoom=t.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=r=>t.getGeneralizationLevelByZoom?t.getGeneralizationLevelByZoom(r,this.generalizationLevelByZoom):this.generalizationLevelByZoom[r],this.renderTimeIntervalByZoom=t.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=r=>t.getRenderTimeIntervalByZoom?t.getRenderTimeIntervalByZoom(r,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[r],this.isUpdateBboxOnMoveEnd=t.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,I0.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,M0.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}get mode(){return this._mode}set mode(t){t!==this._mode&&(this._mode=t,this.api?.wsApi?.open&&(this.stop(),this.start()))}get speed(){return this._speed}set speed(t){this._speed=t,this.start()}get style(){return this._style}set style(t){this._style=t,this.renderTrajectories()}get time(){return this._time}set time(t){this._time=t?.getTime?t:new Date(t),this.renderTrajectories()}addTrajectory(t){this.trajectories||(this.trajectories={});let r=t.properties.train_id;r!==void 0&&(this.trajectories[r]=t),this.renderTrajectories()}attachToMap(){document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),this.canvas){let t=this.canvas.getContext("2d");t&&t.clearRect(0,0,this.canvas.width,this.canvas.height)}}getRefreshTimeInMs(){let r=this.getViewState().zoom||0,l=r!==void 0?Math.round(r):-1,c=this.getRenderTimeIntervalByZoom(l)||25,n=Math.max(25,c/(this.speed||1)),x=Math.min(n,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,I0.default)(this.renderTrajectoriesInternal,x,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,M0.default)(this.renderTrajectoriesInternal,x,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,b]=this.api.buffer;this.api.buffer=[x,b]}return n}getVehicles(t){return this.trajectories&&Object.values(this.trajectories).filter(t)||[]}getVehiclesAtCoordinate(t,r){let{resolution:l}=this.getViewState(),{hitTolerance:c,nb:n}=r||{},x=Kn([...t,...t],(c||5)*(l||1)),b=Object.values(this.trajectories||{});this.sort&&(b=b.sort(this.sort));let S=[];for(let R=0;R<b.length;R+=1){let{coordinate:E}=b[R].properties;if(E&&ll(x,E)&&S.push(b[R]),S.length===n)break}return{features:S,type:"FeatureCollection"}}onDeleteTrajectoryMessage(t){t.content&&this.removeTrajectory(t.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(!this.getViewState().visible)return;this.start()}}onTrajectoryMessage(t){if(this.updateIdleState(),!t.content)return;let r=t.content,{geometry:l,properties:{raw_coordinates:c,time_since_update:n}}=r;n<0||this.purgeTrajectory(r)||(this.debug&&this.mode===nr.TOPOGRAPHIC&&c?r.properties.olGeometry=this.format.readGeometry({coordinates:_r(c),type:"Point"}):r.properties.olGeometry=this.format.readGeometry(l),r.properties.timeOffset=Date.now()-t.timestamp,this.addTrajectory(r))}onZoomEnd(){this.startUpdateTime()}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([t,r])=>{let l=r?.properties?.time_intervals;this.time&&l?.length&&l[l.length-1][0]<this.time.getTime()&&this.removeTrajectory(t)})}purgeTrajectory(t){let l=this.getViewState().extent,{bounds:c,type:n}=t.properties;return this.isUpdateBboxOnMoveEnd&&l&&!Qi(l,c)||this.mots&&!this.mots.includes(n)?(this.removeTrajectory(t),!0):!1}removeTrajectory(t){let r;typeof t!="string"?r=t?.properties?.train_id:r=t,r!==void 0&&this.trajectories&&delete this.trajectories[r]}renderTrajectories(t){let r=this.getViewState();this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),!(!r?.center||!r?.extent||!r?.size)&&(!t&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,t)}):!t&&this.useDebounce?this.debounceRenderTrajectories(r,t):!t&&this.useThrottle?this.throttleRenderTrajectories(r,t):this.renderTrajectoriesInternal(r,t))}renderTrajectoriesInternal(t,r=!1){if(!this.trajectories||!this.shouldRender())return!1;let l=this.live?Date.now():this.time?.getTime(),c=Object.values(this.trajectories);return this.sort&&c.sort(this.sort),!this.canvas||!this.style||(this.renderState=qu(this.canvas,c,this.style,{...t,pixelRatio:this.pixelRatio||1,time:l},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(t.zoom||0)<this.minZoomInterpolation?!0:r,selectedVehicleId:this.selectedVehicleId,...this.styleOptions}),this.onRender?.(this.renderState,t)),!0}setBbox(){this.updateIdleState();let t=this.getViewState(),r=t.extent,l=t.zoom||0;if(!r||Number.isNaN(l))return;if(this.trajectories&&r&&l){let E=Object.keys(this.trajectories);for(let A=E.length-1;A>=0;A-=1)this.purgeTrajectory(this.trajectories[E[A]])}let c=Math.floor(l);if(!r||Number.isNaN(c))return;let[n,x,b,S]=r,R=[Math.floor(n),Math.floor(x),Math.ceil(b),Math.ceil(S),c];this.generalizationLevel=this.getGeneralizationLevelByZoom(c),this.generalizationLevel&&R.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(c),this.mots&&R.push(`mots=${this.mots}`),this.tenant&&R.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&R.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([E,A])=>{R.push(`${E}=${A}`)}),this.api.bbox=R}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}updateIdleState(){this.isIdle=!1,clearTimeout(this._idleTimeout),this._idleTimeout=window.setTimeout(()=>{this.isIdle=!0,this.onIdle?.(this)},1e3)}},Hf=E0;var PI=new vr,xd=class extends Of{forEachFeatureAtCoordinate(t,r,l,c){let n=this.getFeaturesAtCoordinate(t,l);return n.forEach(x=>{c(x,this.layer_,x.getGeometry())}),n?.[0]}getData(t){let r;try{let{pixelRatio:l}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(t[0]*(l||1),t[1]*(l||1),1,1).data||null,r}catch(l){console.error("error getting data",l)}return null}getFeatures(t){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(t);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(t,r=5){if(!t)return[];let l=this.getLayer(),c=l.engine.getVehiclesAtCoordinate(t,{hitTolerance:r,nb:l.maxNbFeaturesRequested});return PI.readFeatures(c)}prepareFrame(){return!0}renderFrame(t){let{canvas:r,engine:l,renderedViewState:c}=this.getLayer();if(this.getLayer().engine.pixelRatio=t.pixelRatio,this.ready=!!l.renderState?.renderedTrajectories&&l.isIdle,this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r instanceof HTMLCanvasElement&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),c){let{center:n,resolution:x,rotation:b}=t.viewState,{center:S,resolution:R,rotation:E}=c;if(R/x>=3){let A=r?.getContext("2d");r?.width&&r?.height&&A?.clearRect(0,0,r.width,r.height)}else{let A=this.getLayer().getMapInternal(),z=A?.getPixelFromCoordinate(S),W=A?.getPixelFromCoordinate(n);z&&W&&(this.container.style.transform=Rv(z[0]-W[0],z[1]-W[1],R/x,R/x,b-E,0,0))}}return this.container}};var RI=new Lr({image:new Cn({fill:new Ar({color:"#000000"}),radius:5}),stroke:new lr({color:"#000000",width:6}),zIndex:2}),AI=(h,t,r)=>{let l="#ffffff",c=h.get("type"),n=h.get("stroke");return n&&n[0]!=="#"&&(n=`#${n}`),l=n||r?.getBgColor(c),l=/#ffffff/i.test(l)?"#ff0000":l,[RI,new Lr({image:new Cn({fill:new Ar({color:l}),radius:4}),stroke:new lr({color:l,width:4}),zIndex:3})]},Yf=AI;var LI=new Lr({image:new Cn({fill:new Ar({color:"#000000"}),radius:5}),stroke:new lr({color:"#000000",width:6}),zIndex:2}),kI=new Lr({image:new Cn({fill:new Ar({color:"#a0a0a0"}),radius:4}),stroke:new lr({color:"#a0a0a0",width:4}),zIndex:3}),DI=()=>[LI,kI],Gw=DI;var Vw=new Cn({fill:new Ar({color:[255,0,0,1]}),radius:6,stroke:new lr({color:[0,0,0,1],width:1})}),FI=new Lr({stroke:new lr({color:[0,0,0,1],width:5})}),zI=new Lr({image:Vw,stroke:new lr({color:[255,0,0,1],width:3})}),OI=new Lr({image:Vw,stroke:new lr({color:[255,0,0,1],lineDash:[1,10],width:3})}),BI=(h,t)=>{let r=h.get("minResolution"),l=h.get("maxResolution"),c=t<=r&&t>l;if(r&&l&&!c)return[];let n=h?.getGeometry()?.getType()==="Point"?100:0,x=[FI,zI];return h.get("mot")==="foot"&&(x=[OI]),x=x.map(S=>{let R=S.clone();return R.setZIndex(n),R}),x},Uw=BI;var jI=new vr,R0=class h extends Is{constructor(r){super({source:new Eo({}),...r});this.allowRenderWhenAnimating=!1;this.maxNbFeaturesRequested=100;this.olEventsKeys=[];wa(this,r),this.engine=new Hf({getViewState:this.getViewState.bind(this),onIdle:this.onRealtimeEngineIdle.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...r}),this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new Yc({source:new bl({features:[]}),style:(l,c)=>(r.fullTrajectoryStyle||Yf)(l,c,this.engine.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.onZoomEndDebounced=(0,P0.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,P0.default)(this.onMoveEnd,100)}get api(){return this.engine.api}set api(r){this.engine.api=r}get canvas(){return this.engine.canvas}get filter(){return this.engine.filter}set filter(r){this.engine.filter=r}get hoverVehicleId(){return this.engine.hoverVehicleId}set hoverVehicleId(r){this.engine.hoverVehicleId=r}get mode(){return this.engine.mode}set mode(r){this.engine.mode=r}get pixelRatio(){return this.engine.pixelRatio}get selectedVehicleId(){return this.engine.selectedVehicleId}set selectedVehicleId(r){this.engine.selectedVehicleId=r}get sort(){return this.engine.sort}set sort(r){this.engine.sort=r}get trajectories(){return this.engine.trajectories}attachToMap(){this.engine.attachToMap();let r=this.getMapInternal();r&&(this.getVisible()&&this.engine.start(),this.olEventsKeys.push(r.on("movestart",()=>{this.engine.isUpdateBboxOnMoveEnd&&this.engine.updateIdleState()}),...r.on(["moveend","change:target"],l=>{let c=(l.map||l.target).getView();if(!c||c?.getAnimating()||c?.getInteracting())return;let n=c.getZoom();this.currentZoom!==n&&this.onZoomEndDebounced(l),this.currentZoom=n,this.onMoveEndDebounced(l)}),this.on("change:visible",l=>{l.target.getVisible()?this.engine.start():this.engine.stop()}),this.on("propertychange",l=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(l.key)&&this.vectorLayer.set(l.key,l.target.get(l.key))})))}cleanVectorLayer(){this.vectorLayer?.getSource()?.clear(!0),this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer)}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new xd(this)}detachFromMap(){ws(this.olEventsKeys),this.getMapInternal()?.removeLayer(this.vectorLayer),this.engine.detachFromMap()}async getFullTrajectory(r){let l=await this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.getMapInternal()?.getView()?.getZoom()||0)));return l?.content?.features?.length?jI.readFeatures(l?.content):[]}async getStopSequences(r){return(await this.engine.api.getStopSequence(r))?.content}async getTrajectoryInfos(r){let l=[this.getStopSequences(r),this.getFullTrajectory(r)],[c,n]=await Promise.all(l);return{fullTrajectory:n,stopSequences:c}}getVehicles(r){return this.engine.getVehicles(r)}getViewState(){let r=this.getMapInternal();if(!r?.getView())return{};let l=r.getView();return{center:l.getCenter(),extent:l.calculateExtent(),pixelRatio:this.engine.pixelRatio,resolution:l.getResolution(),rotation:l.getRotation(),size:r.getSize(),visible:this.getVisible(),zoom:l.getZoom()}}highlight(r){let l=r?.get("train_id");this.hoverVehicleId!==l&&(this.hoverVehicleId=l,this.engine.renderTrajectories(!0))}async highlightTrajectory(r){let l=await this.getFullTrajectory(r);this.cleanVectorLayer(),l.length&&this.vectorLayer?.getSource()?.addFeatures(l),this.vectorLayer.getMapInternal()&&this.vectorLayer.getMapInternal()!==this.getMapInternal()&&this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);let c=this.getZIndex();if(c!==void 0)this.vectorLayer.setZIndex(c-1),this.vectorLayer.getMapInternal()||this.getMapInternal()?.addLayer(this.vectorLayer);else if(!this.vectorLayer.getMapInternal()){let n=this.getMapInternal()?.getLayers().getArray().indexOf(this)||0;n&&this.getMapInternal()?.getLayers().insertAt(n,this.vectorLayer)}return l}onMoveEnd(){!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible()||this.engine.setBbox()}onRealtimeEngineIdle(){this.changed()}onRealtimeEngineRender(r,l){this.renderedViewState={...l};let{container:c}=this.getRenderer();c&&(c.style.transform="")}onZoomEnd(){this.engine.onZoomEnd(),!(!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}select(r){let l=r?.get("train_id");this.selectedVehicleId!==l&&(this.cleanVectorLayer(),this.selectedVehicleId=l,this.engine.renderTrajectories(!0)),this.highlightTrajectory(l)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}shouldRender(){return this.allowRenderWhenAnimating?!1:this.getMapInternal()?.getView().getAnimating()||this.getMapInternal()?.getView().getInteracting()}start(){this.engine.start()}stop(){this.engine.stop()}},Zw=R0;var A0=class h extends $f{clone(t){return new h({...this.get("options"),...t})}getFeatureInfoAtCoordinate(t){let r=[],l=this.getMapInternal();if(l){let c=l.getPixelFromCoordinate(t);r=l.getFeaturesAtPixel(c,{hitTolerance:this.get("hitTolerance")||5,layerFilter:n=>n===this})||[]}return Promise.resolve({coordinate:t,features:r,layer:this})}},qw=A0;var NI=new vr,GI=(h,t,r)=>{let l,{coordinate:c,params:n,projection:x,resolution:b}=t;return h&&b&&x&&(l=h.getFeatureInfoUrl(c,b,x,{info_format:"application/json",query_layers:h.getParams().layers,...n})),fetch(l,{signal:r.signal}).then(S=>S.json()).then(S=>NI.readFeatures(S)).catch(()=>[])},vd={},VI=async(h,t,r=5)=>{Object.values(vd).forEach(n=>{n?.abort()}),vd={};let c=Cu(t).map(n=>{let x=n.getMapInternal(),b=x?.getView()?.getProjection()?.getCode(),S={coordinate:h,features:[],layer:n};if(!b)return Promise.resolve(S);if(n.getFeatureInfoAtCoordinate)return n.getFeatureInfoAtCoordinate(h);let R=n?.getSource();if(R?.getFeatureInfoUrl){let z=Vt(n);vd[z]?.abort(),vd[z]=new AbortController;let W=x?.getView()?.getResolution();return GI(R,{coordinate:h,params:{info_format:"application/json",query_layers:R.getParams().layers},projection:b,resolution:W},vd[z]).then(ne=>({coordinate:h,features:ne,layer:n})).catch(()=>({coordinate:h,features:[],layer:n}))}let E=x?.getPixelFromCoordinate(h);if(!E)return Promise.resolve(S);let A=x?.getFeaturesAtPixel(E,{hitTolerance:n.get("hitTolerance")||r||5,layerFilter:z=>z===n});return Promise.resolve({coordinate:h,features:A,layer:n})});return Promise.all(c)},Ww=VI;var tm={};dg(tm,{CopyrightControl:()=>$w,Layer:()=>Jf,RealtimeAPI:()=>bu,RealtimeLayer:()=>uS,RealtimeModes:()=>nr,RoutingAPI:()=>wu,StopsAPI:()=>Su,VECTOR_TILE_FEATURE_PROPERTY:()=>Bc,compareDepartures:()=>Wu,createCanvas:()=>xs,createRealtimeFilters:()=>Pg,debounceDeparturesMessages:()=>T_,debounceWebsocketMessages:()=>vu,getCircleCanvas:()=>Cg,getDelayBgCanvas:()=>Sg,getDelayTextCanvas:()=>Tg,getHoursAndMinutes:()=>Iv,getLayersAsFlatArray:()=>Cu,getMapGlCopyrights:()=>Tu,getMercatorResolution:()=>hS,getSourceCoordinates:()=>em,getTextCanvas:()=>Mg,getUTCDateString:()=>Cv,getUTCTimeString:()=>Mv,getUrlWithParams:()=>sl,getVehiclePosition:()=>Zu,pad:()=>Zp,realtimeConfig:()=>Oc,realtimeDefaultStyle:()=>ol,realtimeDelayStyle:()=>Ig,realtimeSimpleStyle:()=>Eg,removeDuplicate:()=>al,renderTrajectories:()=>qu,sortAndFilterDepartures:()=>$u,sortByDelay:()=>Rg});var UI=" | ",L0=class{constructor(t={}){this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this.map=t,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}render(){if(this.map&&this.container){let t=this.options?.separator||UI,r=this.options?.customAttribution||Tu(this.map),l=(Array.isArray(r)?r:[r]).join(t);this.container.innerHTML!==l&&(this.content=l,this.container.innerHTML=this.content)}}},$w=L0;var Hw=Vs(_0());var kr=[];for(let h=0;h<256;++h)kr.push((h+256).toString(16).slice(1));function Xw(h,t=0){return(kr[h[t+0]]+kr[h[t+1]]+kr[h[t+2]]+kr[h[t+3]]+"-"+kr[h[t+4]]+kr[h[t+5]]+"-"+kr[h[t+6]]+kr[h[t+7]]+"-"+kr[h[t+8]]+kr[h[t+9]]+"-"+kr[h[t+10]]+kr[h[t+11]]+kr[h[t+12]]+kr[h[t+13]]+kr[h[t+14]]+kr[h[t+15]]).toLowerCase()}var k0,ZI=new Uint8Array(16);function D0(){if(!k0){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k0=crypto.getRandomValues.bind(crypto)}return k0(ZI)}var qI=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),F0={randomUUID:qI};function WI(h,t,r){if(F0.randomUUID&&!t&&!h)return F0.randomUUID();h=h||{};let l=h.random??h.rng?.()??D0();if(l.length<16)throw new Error("Random bytes length must be >= 16");if(l[6]=l[6]&15|64,l[8]=l[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let c=0;c<16;++c)t[r+c]=l[c];return t}return Xw(l)}var z0=WI;var O0=class extends Hw.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||z0()}onAdd(r,l){this.map=r}onRemove(r,l){this.map=void 0}render(r){}},Jf=O0;var Dr=63710088e-1,Kw={centimeters:Dr*100,centimetres:Dr*100,degrees:360/(2*Math.PI),feet:Dr*3.28084,inches:Dr*39.37,kilometers:Dr/1e3,kilometres:Dr/1e3,meters:Dr,metres:Dr,miles:Dr/1609.344,millimeters:Dr*1e3,millimetres:Dr*1e3,nauticalmiles:Dr/1852,radians:1,yards:Dr*1.0936};function $I(h,t,r={}){let l={type:"Feature"};return(r.id===0||r.id)&&(l.id=r.id),r.bbox&&(l.bbox=r.bbox),l.properties=t||{},l.geometry=h,l}function Cl(h,t,r={}){if(!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Yw(h[0])||!Yw(h[1]))throw new Error("coordinates must contain numbers");return $I({type:"Point",coordinates:h},t,r)}function XI(h,t="kilometers"){let r=Kw[t];if(!r)throw new Error(t+" units is invalid");return h*r}function HI(h,t="kilometers"){let r=Kw[t];if(!r)throw new Error(t+" units is invalid");return h/r}function Jw(h){return h%(2*Math.PI)*180/Math.PI}function Ml(h){return h%360*Math.PI/180}function Qf(h,t="kilometers",r="kilometers"){if(!(h>=0))throw new Error("length must be a positive number");return XI(HI(h,t),r)}function Yw(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function Qw(h){return h!==null&&typeof h=="object"&&!Array.isArray(h)}function bd(h,t,r){if(h!==null)for(var l,c,n,x,b,S,R,E=0,A=0,z,W=h.type,ne=W==="FeatureCollection",ge=W==="Feature",me=ne?h.features.length:1,ve=0;ve<me;ve++){R=ne?h.features[ve].geometry:ge?h.geometry:h,z=R?R.type==="GeometryCollection":!1,b=z?R.geometries.length:1;for(var Te=0;Te<b;Te++){var Oe=0,Pe=0;if(x=z?R.geometries[Te]:R,x!==null){S=x.coordinates;var ze=x.type;switch(E=r&&(ze==="Polygon"||ze==="MultiPolygon")?1:0,ze){case null:break;case"Point":if(t(S,A,ve,Oe,Pe)===!1)return!1;A++,Oe++;break;case"LineString":case"MultiPoint":for(l=0;l<S.length;l++){if(t(S[l],A,ve,Oe,Pe)===!1)return!1;A++,ze==="MultiPoint"&&Oe++}ze==="LineString"&&Oe++;break;case"Polygon":case"MultiLineString":for(l=0;l<S.length;l++){for(c=0;c<S[l].length-E;c++){if(t(S[l][c],A,ve,Oe,Pe)===!1)return!1;A++}ze==="MultiLineString"&&Oe++,ze==="Polygon"&&Pe++}ze==="Polygon"&&Oe++;break;case"MultiPolygon":for(l=0;l<S.length;l++){for(Pe=0,c=0;c<S[l].length;c++){for(n=0;n<S[l][c].length-E;n++){if(t(S[l][c][n],A,ve,Oe,Pe)===!1)return!1;A++}Pe++}Oe++}break;case"GeometryCollection":for(l=0;l<x.geometries.length;l++)if(bd(x.geometries[l],t,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function eS(h,t={}){let r=0,l=0,c=0;return bd(h,function(n){r+=n[0],l+=n[1],c++},!0),Cl([r/c,l/c],t.properties)}function Qs(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return[...h.geometry.coordinates];if(h.type==="Point")return[...h.coordinates]}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return[...h];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function tS(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function rS(h,t,r={}){let l;return r.final?l=iS(Qs(t),Qs(h)):l=iS(Qs(h),Qs(t)),l>180?-(360-l):l}function iS(h,t){let r=Ml(h[1]),l=Ml(t[1]),c=Ml(t[0]-h[0]);c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);let n=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),x=Math.atan2(c,n);return(Jw(x)+360)%360}function nS(h,t,r={}){let l=Qs(h),c=Qs(t);c[0]+=c[0]-l[0]>180?-360:l[0]-c[0]>180?360:0;let n=YI(l,c);return Qf(n,"meters",r.units)}function YI(h,t,r){r=r===void 0?Dr:Number(r);let l=r,c=h[1]*Math.PI/180,n=t[1]*Math.PI/180,x=n-c,b=Math.abs(t[0]-h[0])*Math.PI/180;b>Math.PI&&(b-=2*Math.PI);let S=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(c/2+Math.PI/4)),R=Math.abs(S)>1e-11?x/S:Math.cos(c);return Math.sqrt(x*x+R*R*b*b)*l}function sS(h,t,r,l={}){let c=t<0,n=Qf(Math.abs(t),l.units,"meters");c&&(n=-Math.abs(n));let x=Qs(h),b=KI(x,n,r);return b[0]+=b[0]-x[0]>180?-360:x[0]-b[0]>180?360:0,Cl(b,l.properties)}function KI(h,t,r,l){l=l===void 0?Dr:Number(l);let c=t/l,n=h[0]*Math.PI/180,x=Ml(h[1]),b=Ml(r),S=c*Math.cos(b),R=x+S;Math.abs(R)>Math.PI/2&&(R=R>0?Math.PI-R:-Math.PI-R);let E=Math.log(Math.tan(R/2+Math.PI/4)/Math.tan(x/2+Math.PI/4)),A=Math.abs(E)>1e-11?S/E:Math.cos(x),z=c*Math.sin(b)/A;return[((n+z)*180/Math.PI+540)%360-180,R*180/Math.PI]}function oS(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return aS(h);case"FeatureCollection":return JI(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return B0(h);default:throw new Error("unknown GeoJSON type")}}function aS(h){let t={type:"Feature"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:t[r]=h[r]}}),t.properties=lS(h.properties),h.geometry==null?t.geometry=null:t.geometry=B0(h.geometry),t}function lS(h){let t={};return h&&Object.keys(h).forEach(r=>{let l=h[r];typeof l=="object"?l===null?t[r]=null:Array.isArray(l)?t[r]=l.map(c=>c):t[r]=lS(l):t[r]=l}),t}function JI(h){let t={type:"FeatureCollection"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"features":return;default:t[r]=h[r]}}),t.features=h.features.map(r=>aS(r)),t}function B0(h){let t={type:h.type};return h.bbox&&(t.bbox=h.bbox),h.type==="GeometryCollection"?(t.geometries=h.geometries.map(r=>B0(r)),t):(t.coordinates=cS(h.coordinates),t)}function cS(h){let t=h;return typeof t[0]!="object"?t.slice():t.map(r=>cS(r))}function QI(h,t,r){if(r=r||{},!Qw(r))throw new Error("options is invalid");let l=r.pivot,c=r.mutate;if(!h)throw new Error("geojson is required");if(t==null||isNaN(t))throw new Error("angle is required");if(t===0)return h;let n=l??eS(h);return(c===!1||c===void 0)&&(h=oS(h)),bd(h,function(x){let S=rS(n,x)+t,R=nS(n,x),E=tS(sS(n,R,S));x[0]=E[0],x[1]=E[1]}),h}var j0=QI;var eE=(h,t=1)=>{let{height:r,width:l}=h.getCanvas(),c=h.unproject({x:0,y:0}),n=h.unproject({x:0,y:r/t}),x=h.unproject({x:l/t,y:r/t}),b=h.unproject({x:l/t,y:0});return[[c.lng,c.lat],[b.lng,b.lat],[x.lng,x.lat],[n.lng,n.lat]]},em=eE;var tE=h=>{let t=h.getBounds().toArray(),r=_r(t[0]),l=_r(t[1]),c=[...r,...l],{width:n,height:x}=h.getCanvas(),b=Ti(c)/n,S=sr(c)/x;return Math.max(b,S)},hS=tE;var N0=class extends Jf{get canvas(){return this.engine.canvas}get pixelRatio(){return this.engine.pixelRatio||1}set pixelRatio(t){this.engine.pixelRatio=t||1}#e;constructor(t={}){let r=t?.id||"realtime";super({...t,id:"realtime-custom-"+r}),this.#e=r,this.engine=new Hf({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...t}),this.sourceId=this.#e,this.source={animate:!0,attribution:t.attribution?.join(", "),canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],loaded:!0,type:"canvas"},this.layer={id:this.#e,layout:{visibility:"visible"},paint:{"raster-fade-duration":0,"raster-opacity":1,"raster-resampling":"nearest"},source:this.sourceId,type:"raster"},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}getViewState(){if(!this.map)return{};this.pixelRatio||(this.pixelRatio=1);let{height:t,width:r}=this.map.getCanvas(),l=this.map.getCenter(),c=this.map.unproject({x:0,y:t/this.pixelRatio}),n=this.map.unproject({x:r/this.pixelRatio,y:0}),x=j0(Cl([c.lng,c.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,b=j0(Cl([n.lng,n.lat]),-this.map.getBearing(),{pivot:[l.lng,l.lat]}).geometry.coordinates,S=[..._r(x),..._r(b)],R=Ti(S)/(r/this.pixelRatio),E=sr(S)/(t/this.pixelRatio),A=Math.max(R,E);return{center:_r([l.lng,l.lat]),extent:S,pixelRatio:this.pixelRatio,resolution:A,rotation:-(this.map.getBearing()*Math.PI)/180,size:[r/this.pixelRatio,t/this.pixelRatio],visible:!0,zoom:this.map.getZoom()-1}}onAdd(t,r){super.onAdd(t,r),this.engine.attachToMap(),t.isStyleLoaded()&&this.onLoad(),t.on("load",this.onLoad)}onLoad(){this.map?.getSource(this.sourceId)||this.map?.addSource(this.sourceId,this.source),this.map?.getLayer(this.layer.id)||this.map?.addLayer(this.layer,this.id),this.start()}onMove(){this.engine.renderTrajectories()}onMoveEnd(){this.engine.renderTrajectories(),this.engine.isUpdateBboxOnMoveEnd&&this.engine.setBbox()}onRealtimeEngineRender(){if(this.map?.style){let t=em(this.map,this.pixelRatio),r=this.map.getSource(this.sourceId);r&&r.setCoordinates(t)}}onRemove(t,r){this.engine.detachFromMap(),this.stop(),t.off("load",this.onLoad),t.getLayer(this.layer.id)&&t.removeLayer(this.layer.id),t.getSource(this.sourceId)&&t.removeSource(this.sourceId),super.onRemove(t,r)}onZoomEnd(){this.engine.onZoomEnd()}start(){this.engine.start(),this.map?.on("move",this.onMove),this.map?.on("moveend",this.onMoveEnd),this.map?.on("zoomend",this.onZoomEnd)}stop(){this.engine.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}},uS=N0;var G0={ol:Kf,maplibre:tm};typeof window<"u"&&(window.mbt=G0);var Y6=G0;})();
734
734
  /*! Bundled license information:
735
735
 
736
736
  maplibre-gl/dist/maplibre-gl.js: